guix.texi 1.4 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133
  1. \input texinfo
  2. @c -*-texinfo-*-
  3. @c %**start of header
  4. @setfilename guix.info
  5. @documentencoding UTF-8
  6. @settitle GNU Guix Reference Manual
  7. @c %**end of header
  8. @include version.texi
  9. @c Identifier of the OpenPGP key used to sign tarballs and such.
  10. @set OPENPGP-SIGNING-KEY-ID 27D586A4F8900854329FF09F1260E46482E63562
  11. @set OPENPGP-SIGNING-KEY-URL https://sv.gnu.org/people/viewgpg.php?user_id=127547
  12. @c Base URL for downloads.
  13. @set BASE-URL https://ftp.gnu.org/gnu/guix
  14. @c The official substitute server used by default.
  15. @set SUBSTITUTE-SERVER-1 ci.guix.gnu.org
  16. @set SUBSTITUTE-SERVER-2 bordeaux.guix.gnu.org
  17. @set SUBSTITUTE-URLS https://@value{SUBSTITUTE-SERVER-1} https://@value{SUBSTITUTE-SERVER-2}
  18. @copying
  19. Copyright @copyright{} 2012-2022 Ludovic Courtès@*
  20. Copyright @copyright{} 2013, 2014, 2016 Andreas Enge@*
  21. Copyright @copyright{} 2013 Nikita Karetnikov@*
  22. Copyright @copyright{} 2014, 2015, 2016 Alex Kost@*
  23. Copyright @copyright{} 2015, 2016 Mathieu Lirzin@*
  24. Copyright @copyright{} 2014 Pierre-Antoine Rault@*
  25. Copyright @copyright{} 2015 Taylan Ulrich Bayırlı/Kammer@*
  26. Copyright @copyright{} 2015, 2016, 2017, 2019, 2020, 2021 Leo Famulari@*
  27. Copyright @copyright{} 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ricardo Wurmus@*
  28. Copyright @copyright{} 2016 Ben Woodcroft@*
  29. Copyright @copyright{} 2016, 2017, 2018, 2021 Chris Marusich@*
  30. Copyright @copyright{} 2016, 2017, 2018, 2019, 2020, 2021, 2022 Efraim Flashner@*
  31. Copyright @copyright{} 2016 John Darrington@*
  32. Copyright @copyright{} 2016, 2017 Nikita Gillmann@*
  33. Copyright @copyright{} 2016, 2017, 2018, 2019, 2020 Jan Nieuwenhuizen@*
  34. Copyright @copyright{} 2016, 2017, 2018, 2019, 2020, 2021 Julien Lepiller@*
  35. Copyright @copyright{} 2016 Alex ter Weele@*
  36. Copyright @copyright{} 2016, 2017, 2018, 2019, 2020, 2021 Christopher Baines@*
  37. Copyright @copyright{} 2017, 2018, 2019 Clément Lassieur@*
  38. Copyright @copyright{} 2017, 2018, 2020, 2021 Mathieu Othacehe@*
  39. Copyright @copyright{} 2017 Federico Beffa@*
  40. Copyright @copyright{} 2017, 2018 Carlo Zancanaro@*
  41. Copyright @copyright{} 2017 Thomas Danckaert@*
  42. Copyright @copyright{} 2017 humanitiesNerd@*
  43. Copyright @copyright{} 2017, 2021 Christine Lemmer-Webber@*
  44. Copyright @copyright{} 2017, 2018, 2019, 2020, 2021, 2022 Marius Bakke@*
  45. Copyright @copyright{} 2017, 2019, 2020 Hartmut Goebel@*
  46. Copyright @copyright{} 2017, 2019, 2020, 2021 Maxim Cournoyer@*
  47. Copyright @copyright{} 2017–2022 Tobias Geerinckx-Rice@*
  48. Copyright @copyright{} 2017 George Clemmer@*
  49. Copyright @copyright{} 2017 Andy Wingo@*
  50. Copyright @copyright{} 2017, 2018, 2019, 2020 Arun Isaac@*
  51. Copyright @copyright{} 2017 nee@*
  52. Copyright @copyright{} 2018 Rutger Helling@*
  53. Copyright @copyright{} 2018, 2021 Oleg Pykhalov@*
  54. Copyright @copyright{} 2018 Mike Gerwitz@*
  55. Copyright @copyright{} 2018 Pierre-Antoine Rouby@*
  56. Copyright @copyright{} 2018, 2019 Gábor Boskovits@*
  57. Copyright @copyright{} 2018, 2019, 2020 Florian Pelz@*
  58. Copyright @copyright{} 2018 Laura Lazzati@*
  59. Copyright @copyright{} 2018 Alex Vong@*
  60. Copyright @copyright{} 2019 Josh Holland@*
  61. Copyright @copyright{} 2019, 2020 Diego Nicola Barbato@*
  62. Copyright @copyright{} 2019 Ivan Petkov@*
  63. Copyright @copyright{} 2019 Jakob L. Kreuze@*
  64. Copyright @copyright{} 2019 Kyle Andrews@*
  65. Copyright @copyright{} 2019 Alex Griffin@*
  66. Copyright @copyright{} 2019, 2020, 2021, 2022 Guillaume Le Vaillant@*
  67. Copyright @copyright{} 2020 Liliana Marie Prikler@*
  68. Copyright @copyright{} 2019, 2020, 2021, 2022 Simon Tournier@*
  69. Copyright @copyright{} 2020 Wiktor Żelazny@*
  70. Copyright @copyright{} 2020 Damien Cassou@*
  71. Copyright @copyright{} 2020 Jakub Kądziołka@*
  72. Copyright @copyright{} 2020 Jack Hill@*
  73. Copyright @copyright{} 2020 Naga Malleswari@*
  74. Copyright @copyright{} 2020, 2021 Brice Waegeneire@*
  75. Copyright @copyright{} 2020 R Veera Kumar@*
  76. Copyright @copyright{} 2020, 2021 Pierre Langlois@*
  77. Copyright @copyright{} 2020 pinoaffe@*
  78. Copyright @copyright{} 2020 André Batista@*
  79. Copyright @copyright{} 2020, 2021 Alexandru-Sergiu Marton@*
  80. Copyright @copyright{} 2020 raingloom@*
  81. Copyright @copyright{} 2020 Daniel Brooks@*
  82. Copyright @copyright{} 2020 John Soo@*
  83. Copyright @copyright{} 2020 Jonathan Brielmaier@*
  84. Copyright @copyright{} 2020 Edgar Vincent@*
  85. Copyright @copyright{} 2021 Maxime Devos@*
  86. Copyright @copyright{} 2021 B. Wilson@*
  87. Copyright @copyright{} 2021 Xinglu Chen@*
  88. Copyright @copyright{} 2021 Raghav Gururajan@*
  89. Copyright @copyright{} 2021 Domagoj Stolfa@*
  90. Copyright @copyright{} 2021 Hui Lu@*
  91. Copyright @copyright{} 2021 pukkamustard@*
  92. Copyright @copyright{} 2021 Alice Brenon@*
  93. Copyright @copyright{} 2021 Josselin Poiret@*
  94. Copyright @copyright{} 2021 Andrew Tropin@*
  95. Copyright @copyright{} 2021 Sarah Morgensen@*
  96. Copyright @copyright{} 2021 Josselin Poiret@*
  97. Permission is granted to copy, distribute and/or modify this document
  98. under the terms of the GNU Free Documentation License, Version 1.3 or
  99. any later version published by the Free Software Foundation; with no
  100. Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
  101. copy of the license is included in the section entitled ``GNU Free
  102. Documentation License''.
  103. @end copying
  104. @dircategory System administration
  105. @direntry
  106. * Guix: (guix). Manage installed software and system configuration.
  107. * guix package: (guix)Invoking guix package. Installing, removing, and upgrading packages.
  108. * guix gc: (guix)Invoking guix gc. Reclaiming unused disk space.
  109. * guix pull: (guix)Invoking guix pull. Update the list of available packages.
  110. * guix system: (guix)Invoking guix system. Manage the operating system configuration.
  111. * guix deploy: (guix)Invoking guix deploy. Manage operating system configurations for remote hosts.
  112. @end direntry
  113. @dircategory Software development
  114. @direntry
  115. * guix shell: (guix)Invoking guix shell. Creating software environments.
  116. * guix environment: (guix)Invoking guix environment. Building development environments with Guix.
  117. * guix build: (guix)Invoking guix build. Building packages.
  118. * guix pack: (guix)Invoking guix pack. Creating binary bundles.
  119. @end direntry
  120. @titlepage
  121. @title GNU Guix Reference Manual
  122. @subtitle Using the GNU Guix Functional Package Manager
  123. @author The GNU Guix Developers
  124. @page
  125. @vskip 0pt plus 1filll
  126. Edition @value{EDITION} @*
  127. @value{UPDATED} @*
  128. @insertcopying
  129. @end titlepage
  130. @contents
  131. @c *********************************************************************
  132. @node Top
  133. @top GNU Guix
  134. This document describes GNU Guix version @value{VERSION}, a functional
  135. package management tool written for the GNU system.
  136. @c TRANSLATORS: You can replace the following paragraph with information on
  137. @c how to join your own translation team and how to report issues with the
  138. @c translation.
  139. This manual is also available in Simplified Chinese (@pxref{Top,,, guix.zh_CN,
  140. GNU Guix参考手册}), French (@pxref{Top,,, guix.fr, Manuel de référence de GNU
  141. Guix}), German (@pxref{Top,,, guix.de, Referenzhandbuch zu GNU Guix}),
  142. Spanish (@pxref{Top,,, guix.es, Manual de referencia de GNU Guix}), and
  143. Russian (@pxref{Top,,, guix.ru, Руководство GNU Guix}). If you
  144. would like to translate it in your native language, consider joining
  145. @uref{https://translate.fedoraproject.org/projects/guix/documentation-manual,
  146. Weblate} (@pxref{Translating Guix}).
  147. @menu
  148. * Introduction:: What is Guix about?
  149. * Installation:: Installing Guix.
  150. * System Installation:: Installing the whole operating system.
  151. * Getting Started:: Your first steps.
  152. * Package Management:: Package installation, upgrade, etc.
  153. * Channels:: Customizing the package collection.
  154. * Development:: Guix-aided software development.
  155. * Programming Interface:: Using Guix in Scheme.
  156. * Utilities:: Package management commands.
  157. * System Configuration:: Configuring the operating system.
  158. * Home Configuration:: Configuring the home environment.
  159. * Documentation:: Browsing software user manuals.
  160. * Installing Debugging Files:: Feeding the debugger.
  161. * Security Updates:: Deploying security fixes quickly.
  162. * Bootstrapping:: GNU/Linux built from scratch.
  163. * Porting:: Targeting another platform or kernel.
  164. * Contributing:: Your help needed!
  165. * Acknowledgments:: Thanks!
  166. * GNU Free Documentation License:: The license of this manual.
  167. * Concept Index:: Concepts.
  168. * Programming Index:: Data types, functions, and variables.
  169. @detailmenu
  170. --- The Detailed Node Listing ---
  171. Introduction
  172. * Managing Software the Guix Way:: What's special.
  173. * GNU Distribution:: The packages and tools.
  174. Installation
  175. * Binary Installation:: Getting Guix running in no time!
  176. * Requirements:: Software needed to build and run Guix.
  177. * Running the Test Suite:: Testing Guix.
  178. * Setting Up the Daemon:: Preparing the build daemon's environment.
  179. * Invoking guix-daemon:: Running the build daemon.
  180. * Application Setup:: Application-specific setup.
  181. * Upgrading Guix:: Upgrading Guix and its build daemon.
  182. Setting Up the Daemon
  183. * Build Environment Setup:: Preparing the isolated build environment.
  184. * Daemon Offload Setup:: Offloading builds to remote machines.
  185. * SELinux Support:: Using an SELinux policy for the daemon.
  186. System Installation
  187. * Limitations:: What you can expect.
  188. * Hardware Considerations:: Supported hardware.
  189. * USB Stick and DVD Installation:: Preparing the installation medium.
  190. * Preparing for Installation:: Networking, partitioning, etc.
  191. * Guided Graphical Installation:: Easy graphical installation.
  192. * Manual Installation:: Manual installation for wizards.
  193. * After System Installation:: When installation succeeded.
  194. * Installing Guix in a VM:: Guix System playground.
  195. * Building the Installation Image:: How this comes to be.
  196. Manual Installation
  197. * Keyboard Layout and Networking and Partitioning:: Initial setup.
  198. * Proceeding with the Installation:: Installing.
  199. Package Management
  200. * Features:: How Guix will make your life brighter.
  201. * Invoking guix package:: Package installation, removal, etc.
  202. * Substitutes:: Downloading pre-built binaries.
  203. * Packages with Multiple Outputs:: Single source package, multiple outputs.
  204. * Invoking guix gc:: Running the garbage collector.
  205. * Invoking guix pull:: Fetching the latest Guix and distribution.
  206. * Invoking guix time-machine:: Running an older revision of Guix.
  207. * Inferiors:: Interacting with another revision of Guix.
  208. * Invoking guix describe:: Display information about your Guix revision.
  209. * Invoking guix archive:: Exporting and importing store files.
  210. Substitutes
  211. * Official Substitute Servers:: One particular source of substitutes.
  212. * Substitute Server Authorization:: How to enable or disable substitutes.
  213. * Getting Substitutes from Other Servers:: Substitute diversity.
  214. * Substitute Authentication:: How Guix verifies substitutes.
  215. * Proxy Settings:: How to get substitutes via proxy.
  216. * Substitution Failure:: What happens when substitution fails.
  217. * On Trusting Binaries:: How can you trust that binary blob?
  218. Channels
  219. * Specifying Additional Channels:: Extending the package collection.
  220. * Using a Custom Guix Channel:: Using a customized Guix.
  221. * Replicating Guix:: Running the @emph{exact same} Guix.
  222. * Channel Authentication:: How Guix verifies what it fetches.
  223. * Channels with Substitutes:: Using channels with available substitutes.
  224. * Creating a Channel:: How to write your custom channel.
  225. * Package Modules in a Sub-directory:: Specifying the channel's package modules location.
  226. * Declaring Channel Dependencies:: How to depend on other channels.
  227. * Specifying Channel Authorizations:: Defining channel authors authorizations.
  228. * Primary URL:: Distinguishing mirror to original.
  229. * Writing Channel News:: Communicating information to channel's users.
  230. Development
  231. * Invoking guix shell:: Spawning one-off software environments.
  232. * Invoking guix environment:: Setting up development environments.
  233. * Invoking guix pack:: Creating software bundles.
  234. * The GCC toolchain:: Working with languages supported by GCC.
  235. * Invoking guix git authenticate:: Authenticating Git repositories.
  236. Programming Interface
  237. * Package Modules:: Packages from the programmer's viewpoint.
  238. * Defining Packages:: Defining new packages.
  239. * Defining Package Variants:: Customizing packages.
  240. * Build Systems:: Specifying how packages are built.
  241. * Build Phases:: Phases of the build process of a package.
  242. * Build Utilities:: Helpers for your package definitions and more.
  243. * Search Paths:: Declaring search path environment variables.
  244. * The Store:: Manipulating the package store.
  245. * Derivations:: Low-level interface to package derivations.
  246. * The Store Monad:: Purely functional interface to the store.
  247. * G-Expressions:: Manipulating build expressions.
  248. * Invoking guix repl:: Programming Guix in Guile.
  249. Defining Packages
  250. * package Reference:: The package data type.
  251. * origin Reference:: The origin data type.
  252. Utilities
  253. * Invoking guix build:: Building packages from the command line.
  254. * Invoking guix edit:: Editing package definitions.
  255. * Invoking guix download:: Downloading a file and printing its hash.
  256. * Invoking guix hash:: Computing the cryptographic hash of a file.
  257. * Invoking guix import:: Importing package definitions.
  258. * Invoking guix refresh:: Updating package definitions.
  259. * Invoking guix style:: Styling package definitions.
  260. * Invoking guix lint:: Finding errors in package definitions.
  261. * Invoking guix size:: Profiling disk usage.
  262. * Invoking guix graph:: Visualizing the graph of packages.
  263. * Invoking guix publish:: Sharing substitutes.
  264. * Invoking guix challenge:: Challenging substitute servers.
  265. * Invoking guix copy:: Copying to and from a remote store.
  266. * Invoking guix container:: Process isolation.
  267. * Invoking guix weather:: Assessing substitute availability.
  268. * Invoking guix processes:: Listing client processes.
  269. Invoking @command{guix build}
  270. * Common Build Options:: Build options for most commands.
  271. * Package Transformation Options:: Creating variants of packages.
  272. * Additional Build Options:: Options specific to 'guix build'.
  273. * Debugging Build Failures:: Real life packaging experience.
  274. System Configuration
  275. * Using the Configuration System:: Customizing your GNU system.
  276. * operating-system Reference:: Detail of operating-system declarations.
  277. * File Systems:: Configuring file system mounts.
  278. * Mapped Devices:: Block device extra processing.
  279. * Swap Space:: Backing RAM with disk space.
  280. * User Accounts:: Specifying user accounts.
  281. * Keyboard Layout:: How the system interprets key strokes.
  282. * Locales:: Language and cultural convention settings.
  283. * Services:: Specifying system services.
  284. * Setuid Programs:: Programs running with root privileges.
  285. * X.509 Certificates:: Authenticating HTTPS servers.
  286. * Name Service Switch:: Configuring libc's name service switch.
  287. * Initial RAM Disk:: Linux-Libre bootstrapping.
  288. * Bootloader Configuration:: Configuring the boot loader.
  289. * Invoking guix system:: Instantiating a system configuration.
  290. * Invoking guix deploy:: Deploying a system configuration to a remote host.
  291. * Running Guix in a VM:: How to run Guix System in a virtual machine.
  292. * Defining Services:: Adding new service definitions.
  293. Home Environment Configuration
  294. * Invoking guix home:: Instantiating a home environment configuration.
  295. Services
  296. * Base Services:: Essential system services.
  297. * Scheduled Job Execution:: The mcron service.
  298. * Log Rotation:: The rottlog service.
  299. * Networking Setup:: Setting up network interfaces.
  300. * Networking Services:: Firewall, SSH daemon, etc.
  301. * Unattended Upgrades:: Automated system upgrades.
  302. * X Window:: Graphical display.
  303. * Printing Services:: Local and remote printer support.
  304. * Desktop Services:: D-Bus and desktop services.
  305. * Sound Services:: ALSA and Pulseaudio services.
  306. * Database Services:: SQL databases, key-value stores, etc.
  307. * Mail Services:: IMAP, POP3, SMTP, and all that.
  308. * Messaging Services:: Messaging services.
  309. * Telephony Services:: Telephony services.
  310. * Monitoring Services:: Monitoring services.
  311. * Kerberos Services:: Kerberos services.
  312. * LDAP Services:: LDAP services.
  313. * Web Services:: Web servers.
  314. * Certificate Services:: TLS certificates via Let's Encrypt.
  315. * DNS Services:: DNS daemons.
  316. * VPN Services:: VPN daemons.
  317. * Network File System:: NFS related services.
  318. * Continuous Integration:: Cuirass and Laminar services.
  319. * Power Management Services:: Extending battery life.
  320. * Audio Services:: The MPD.
  321. * Virtualization Services:: Virtualization services.
  322. * Version Control Services:: Providing remote access to Git repositories.
  323. * Game Services:: Game servers.
  324. * PAM Mount Service:: Service to mount volumes when logging in.
  325. * Guix Services:: Services relating specifically to Guix.
  326. * Linux Services:: Services tied to the Linux kernel.
  327. * Hurd Services:: Services specific for a Hurd System.
  328. * Miscellaneous Services:: Other services.
  329. Defining Services
  330. * Service Composition:: The model for composing services.
  331. * Service Types and Services:: Types and services.
  332. * Service Reference:: API reference.
  333. * Shepherd Services:: A particular type of service.
  334. * Complex Configurations:: Defining bindings for complex configurations.
  335. Installing Debugging Files
  336. * Separate Debug Info:: Installing 'debug' outputs.
  337. * Rebuilding Debug Info:: Building missing debug info.
  338. Bootstrapping
  339. * Reduced Binary Seed Bootstrap:: A Bootstrap worthy of GNU.
  340. * Preparing to Use the Bootstrap Binaries:: Building that what matters most.
  341. @end detailmenu
  342. @end menu
  343. @c *********************************************************************
  344. @node Introduction
  345. @chapter Introduction
  346. @cindex purpose
  347. GNU Guix@footnote{``Guix'' is pronounced like ``geeks'', or ``ɡiːks''
  348. using the international phonetic alphabet (IPA).} is a package
  349. management tool for and distribution of the GNU system.
  350. Guix makes it easy for unprivileged
  351. users to install, upgrade, or remove software packages, to roll back to a
  352. previous package set, to build packages from source, and generally
  353. assists with the creation and maintenance of software environments.
  354. @cindex Guix System
  355. @cindex GuixSD, now Guix System
  356. @cindex Guix System Distribution, now Guix System
  357. You can install GNU@tie{}Guix on top of an existing GNU/Linux system where it
  358. complements the available tools without interference (@pxref{Installation}),
  359. or you can use it as a standalone operating system distribution,
  360. @dfn{Guix@tie{}System}@footnote{We used to refer to Guix System as ``Guix
  361. System Distribution'' or ``GuixSD''. We now consider it makes more sense to
  362. group everything under the ``Guix'' banner since, after all, Guix System is
  363. readily available through the @command{guix system} command, even if you're
  364. using a different distro underneath!}. @xref{GNU Distribution}.
  365. @menu
  366. * Managing Software the Guix Way:: What's special.
  367. * GNU Distribution:: The packages and tools.
  368. @end menu
  369. @node Managing Software the Guix Way
  370. @section Managing Software the Guix Way
  371. @cindex user interfaces
  372. Guix provides a command-line package management interface
  373. (@pxref{Package Management}), tools to help with software development
  374. (@pxref{Development}), command-line utilities for more advanced usage
  375. (@pxref{Utilities}), as well as Scheme programming interfaces
  376. (@pxref{Programming Interface}).
  377. @cindex build daemon
  378. Its @dfn{build daemon} is responsible for building packages on behalf of
  379. users (@pxref{Setting Up the Daemon}) and for downloading pre-built
  380. binaries from authorized sources (@pxref{Substitutes}).
  381. @cindex extensibility of the distribution
  382. @cindex customization, of packages
  383. Guix includes package definitions for many GNU and non-GNU packages, all
  384. of which @uref{https://www.gnu.org/philosophy/free-sw.html, respect the
  385. user's computing freedom}. It is @emph{extensible}: users can write
  386. their own package definitions (@pxref{Defining Packages}) and make them
  387. available as independent package modules (@pxref{Package Modules}). It
  388. is also @emph{customizable}: users can @emph{derive} specialized package
  389. definitions from existing ones, including from the command line
  390. (@pxref{Package Transformation Options}).
  391. @cindex functional package management
  392. @cindex isolation
  393. Under the hood, Guix implements the @dfn{functional package management}
  394. discipline pioneered by Nix (@pxref{Acknowledgments}).
  395. In Guix, the package build and installation process is seen
  396. as a @emph{function}, in the mathematical sense. That function takes inputs,
  397. such as build scripts, a compiler, and libraries, and
  398. returns an installed package. As a pure function, its result depends
  399. solely on its inputs---for instance, it cannot refer to software or
  400. scripts that were not explicitly passed as inputs. A build function
  401. always produces the same result when passed a given set of inputs. It
  402. cannot alter the environment of the running system in
  403. any way; for instance, it cannot create, modify, or delete files outside
  404. of its build and installation directories. This is achieved by running
  405. build processes in isolated environments (or @dfn{containers}), where only their
  406. explicit inputs are visible.
  407. @cindex store
  408. The result of package build functions is @dfn{cached} in the file
  409. system, in a special directory called @dfn{the store} (@pxref{The
  410. Store}). Each package is installed in a directory of its own in the
  411. store---by default under @file{/gnu/store}. The directory name contains
  412. a hash of all the inputs used to build that package; thus, changing an
  413. input yields a different directory name.
  414. This approach is the foundation for the salient features of Guix: support
  415. for transactional package upgrade and rollback, per-user installation, and
  416. garbage collection of packages (@pxref{Features}).
  417. @node GNU Distribution
  418. @section GNU Distribution
  419. @cindex Guix System
  420. Guix comes with a distribution of the GNU system consisting entirely of
  421. free software@footnote{The term ``free'' here refers to the
  422. @url{https://www.gnu.org/philosophy/free-sw.html,freedom provided to
  423. users of that software}.}. The
  424. distribution can be installed on its own (@pxref{System Installation}),
  425. but it is also possible to install Guix as a package manager on top of
  426. an installed GNU/Linux system (@pxref{Installation}). When we need to
  427. distinguish between the two, we refer to the standalone distribution as
  428. Guix@tie{}System.
  429. The distribution provides core GNU packages such as GNU libc, GCC, and
  430. Binutils, as well as many GNU and non-GNU applications. The complete
  431. list of available packages can be browsed
  432. @url{https://www.gnu.org/software/guix/packages,on-line} or by
  433. running @command{guix package} (@pxref{Invoking guix package}):
  434. @example
  435. guix package --list-available
  436. @end example
  437. Our goal is to provide a practical 100% free software distribution of
  438. Linux-based and other variants of GNU, with a focus on the promotion and
  439. tight integration of GNU components, and an emphasis on programs and
  440. tools that help users exert that freedom.
  441. Packages are currently available on the following platforms:
  442. @table @code
  443. @item x86_64-linux
  444. Intel/AMD @code{x86_64} architecture, Linux-Libre kernel.
  445. @item i686-linux
  446. Intel 32-bit architecture (IA32), Linux-Libre kernel.
  447. @item armhf-linux
  448. ARMv7-A architecture with hard float, Thumb-2 and NEON,
  449. using the EABI hard-float application binary interface (ABI),
  450. and Linux-Libre kernel.
  451. @item aarch64-linux
  452. little-endian 64-bit ARMv8-A processors, Linux-Libre kernel.
  453. @item i586-gnu
  454. @uref{https://hurd.gnu.org, GNU/Hurd} on the Intel 32-bit architecture
  455. (IA32).
  456. This configuration is experimental and under development. The easiest
  457. way for you to give it a try is by setting up an instance of
  458. @code{hurd-vm-service-type} on your GNU/Linux machine
  459. (@pxref{transparent-emulation-qemu, @code{hurd-vm-service-type}}).
  460. @xref{Contributing}, on how to help!
  461. @item mips64el-linux (unsupported)
  462. little-endian 64-bit MIPS processors, specifically the Loongson series,
  463. n32 ABI, and Linux-Libre kernel. This configuration is no longer fully
  464. supported; in particular, there is no ongoing work to ensure that this
  465. architecture still works. Should someone decide they wish to revive this
  466. architecture then the code is still available.
  467. @item powerpc-linux (unsupported)
  468. big-endian 32-bit PowerPC processors, specifically the PowerPC G4 with
  469. AltiVec support, and Linux-Libre kernel. This configuration is not
  470. fully supported and there is no ongoing work to ensure this architecture
  471. works.
  472. @item powerpc64le-linux
  473. little-endian 64-bit Power ISA processors, Linux-Libre kernel. This
  474. includes POWER9 systems such as the
  475. @uref{https://www.fsf.org/news/talos-ii-mainboard-and-talos-ii-lite-mainboard-now-fsf-certified-to-respect-your-freedom,
  476. RYF Talos II mainboard}. This platform is available as a "technology
  477. preview": although it is supported, substitutes are not yet available
  478. from the build farm (@pxref{Substitutes}), and some packages may fail to
  479. build (@pxref{Tracking Bugs and Patches}). That said, the Guix
  480. community is actively working on improving this support, and now is a
  481. great time to try it and get involved!
  482. @item riscv64-linux
  483. little-endian 64-bit RISC-V processors, specifically RV64GC, and
  484. Linux-Libre kernel. This playform is available as a "technology preview":
  485. although it is supported, substitutes are not yet available from the
  486. build farm (@pxref{Substitutes}), and some packages may fail to build
  487. (@pxref{Tracking Bugs and Patches}). That said, the Guix community is
  488. actively working on improving this support, and now is a great time to
  489. try it and get involved!
  490. @end table
  491. With Guix@tie{}System, you @emph{declare} all aspects of the operating system
  492. configuration and Guix takes care of instantiating the configuration in a
  493. transactional, reproducible, and stateless fashion (@pxref{System
  494. Configuration}). Guix System uses the Linux-libre kernel, the Shepherd
  495. initialization system (@pxref{Introduction,,, shepherd, The GNU Shepherd
  496. Manual}), the well-known GNU utilities and tool chain, as well as the
  497. graphical environment or system services of your choice.
  498. Guix System is available on all the above platforms except
  499. @code{mips64el-linux}, @code{powerpc-linux}, @code{powerpc64le-linux} and
  500. @code{riscv64-linux}.
  501. @noindent
  502. For information on porting to other architectures or kernels,
  503. @pxref{Porting}.
  504. Building this distribution is a cooperative effort, and you are invited
  505. to join! @xref{Contributing}, for information about how you can help.
  506. @c *********************************************************************
  507. @node Installation
  508. @chapter Installation
  509. @cindex installing Guix
  510. @quotation Note
  511. We recommend the use of this
  512. @uref{https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh,
  513. shell installer script} to install Guix on top of a running GNU/Linux system,
  514. thereafter called a @dfn{foreign distro}.@footnote{This section is concerned
  515. with the installation of the package manager, which can be done on top of a
  516. running GNU/Linux system. If, instead, you want to install the complete GNU
  517. operating system, @pxref{System Installation}.} The script automates the
  518. download, installation, and initial configuration of Guix. It should be run
  519. as the root user.
  520. @end quotation
  521. @cindex foreign distro
  522. @cindex directories related to foreign distro
  523. When installed on a foreign distro, GNU@tie{}Guix complements the available
  524. tools without interference. Its data lives exclusively in two directories,
  525. usually @file{/gnu/store} and @file{/var/guix}; other files on your system,
  526. such as @file{/etc}, are left untouched.
  527. Once installed, Guix can be updated by running @command{guix pull}
  528. (@pxref{Invoking guix pull}).
  529. If you prefer to perform the installation steps manually or want to tweak
  530. them, you may find the following subsections useful. They describe the
  531. software requirements of Guix, as well as how to install it manually and get
  532. ready to use it.
  533. @menu
  534. * Binary Installation:: Getting Guix running in no time!
  535. * Requirements:: Software needed to build and run Guix.
  536. * Running the Test Suite:: Testing Guix.
  537. * Setting Up the Daemon:: Preparing the build daemon's environment.
  538. * Invoking guix-daemon:: Running the build daemon.
  539. * Application Setup:: Application-specific setup.
  540. * Upgrading Guix:: Upgrading Guix and its build daemon.
  541. @end menu
  542. @node Binary Installation
  543. @section Binary Installation
  544. @cindex installing Guix from binaries
  545. @cindex installer script
  546. This section describes how to install Guix on an arbitrary system from a
  547. self-contained tarball providing binaries for Guix and for all its
  548. dependencies. This is often quicker than installing from source, which
  549. is described in the next sections. The only requirement is to have
  550. GNU@tie{}tar and Xz.
  551. @c Note duplicated from the ``Installation'' node.
  552. @quotation Note
  553. We recommend the use of this
  554. @uref{https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh,
  555. shell installer script}. The script automates the download, installation, and
  556. initial configuration steps described below. It should be run as the root
  557. user. As root, you can thus run this:
  558. @example
  559. cd /tmp
  560. wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh
  561. chmod +x guix-install.sh
  562. ./guix-install.sh
  563. @end example
  564. When you're done, @pxref{Application Setup} for extra configuration you
  565. might need, and @ref{Getting Started} for your first steps!
  566. @end quotation
  567. Installing goes along these lines:
  568. @enumerate
  569. @item
  570. @cindex downloading Guix binary
  571. Download the binary tarball from
  572. @indicateurl{@value{BASE-URL}/guix-binary-@value{VERSION}.x86_64-linux.tar.xz},
  573. where @code{x86_64-linux} can be replaced with @code{i686-linux} for an
  574. @code{i686} (32-bits) machine already running the kernel Linux, and so on
  575. (@pxref{GNU Distribution}).
  576. @c The following is somewhat duplicated in ``System Installation''.
  577. Make sure to download the associated @file{.sig} file and to verify the
  578. authenticity of the tarball against it, along these lines:
  579. @example
  580. $ wget @value{BASE-URL}/guix-binary-@value{VERSION}.x86_64-linux.tar.xz.sig
  581. $ gpg --verify guix-binary-@value{VERSION}.x86_64-linux.tar.xz.sig
  582. @end example
  583. If that command fails because you do not have the required public key,
  584. then run this command to import it:
  585. @example
  586. $ wget '@value{OPENPGP-SIGNING-KEY-URL}' \
  587. -qO - | gpg --import -
  588. @end example
  589. @noindent
  590. and rerun the @code{gpg --verify} command.
  591. Take note that a warning like ``This key is not certified with a trusted
  592. signature!'' is normal.
  593. @c end authentication part
  594. @item
  595. Now, you need to become the @code{root} user. Depending on your distribution,
  596. you may have to run @code{su -} or @code{sudo -i}. As @code{root}, run:
  597. @example
  598. # cd /tmp
  599. # tar --warning=no-timestamp -xf \
  600. /path/to/guix-binary-@value{VERSION}.x86_64-linux.tar.xz
  601. # mv var/guix /var/ && mv gnu /
  602. @end example
  603. This creates @file{/gnu/store} (@pxref{The Store}) and @file{/var/guix}.
  604. The latter contains a ready-to-use profile for @code{root} (see next
  605. step).
  606. Do @emph{not} unpack the tarball on a working Guix system since that
  607. would overwrite its own essential files.
  608. The @option{--warning=no-timestamp} option makes sure GNU@tie{}tar does
  609. not emit warnings about ``implausibly old time stamps'' (such
  610. warnings were triggered by GNU@tie{}tar 1.26 and older; recent
  611. versions are fine).
  612. They stem from the fact that all the
  613. files in the archive have their modification time set to 1 (which
  614. means January 1st, 1970). This is done on purpose to make sure the
  615. archive content is independent of its creation time, thus making it
  616. reproducible.
  617. @item
  618. Make the profile available under @file{~root/.config/guix/current}, which is
  619. where @command{guix pull} will install updates (@pxref{Invoking guix pull}):
  620. @example
  621. # mkdir -p ~root/.config/guix
  622. # ln -sf /var/guix/profiles/per-user/root/current-guix \
  623. ~root/.config/guix/current
  624. @end example
  625. Source @file{etc/profile} to augment @env{PATH} and other relevant
  626. environment variables:
  627. @example
  628. # GUIX_PROFILE="`echo ~root`/.config/guix/current" ; \
  629. source $GUIX_PROFILE/etc/profile
  630. @end example
  631. @item
  632. Create the group and user accounts for build users as explained below
  633. (@pxref{Build Environment Setup}).
  634. @item
  635. Run the daemon, and set it to automatically start on boot.
  636. If your host distro uses the systemd init system, this can be achieved
  637. with these commands:
  638. @c Versions of systemd that supported symlinked service files are not
  639. @c yet widely deployed, so we should suggest that users copy the service
  640. @c files into place.
  641. @c
  642. @c See this thread for more information:
  643. @c https://lists.gnu.org/archive/html/guix-devel/2017-01/msg01199.html
  644. @example
  645. # cp ~root/.config/guix/current/lib/systemd/system/gnu-store.mount \
  646. ~root/.config/guix/current/lib/systemd/system/guix-daemon.service \
  647. /etc/systemd/system/
  648. # systemctl enable --now gnu-store.mount guix-daemon
  649. @end example
  650. You may also want to arrange for @command{guix gc} to run periodically:
  651. @example
  652. # cp ~root/.config/guix/current/lib/systemd/system/guix-gc.service \
  653. ~root/.config/guix/current/lib/systemd/system/guix-gc.timer \
  654. /etc/systemd/system/
  655. # systemctl enable --now guix-gc.timer
  656. @end example
  657. You may want to edit @file{guix-gc.service} to adjust the command line
  658. options to fit your needs (@pxref{Invoking guix gc}).
  659. If your host distro uses the Upstart init system:
  660. @example
  661. # initctl reload-configuration
  662. # cp ~root/.config/guix/current/lib/upstart/system/guix-daemon.conf \
  663. /etc/init/
  664. # start guix-daemon
  665. @end example
  666. Otherwise, you can still start the daemon manually with:
  667. @example
  668. # ~root/.config/guix/current/bin/guix-daemon \
  669. --build-users-group=guixbuild
  670. @end example
  671. @item
  672. Make the @command{guix} command available to other users on the machine,
  673. for instance with:
  674. @example
  675. # mkdir -p /usr/local/bin
  676. # cd /usr/local/bin
  677. # ln -s /var/guix/profiles/per-user/root/current-guix/bin/guix
  678. @end example
  679. It is also a good idea to make the Info version of this manual available
  680. there:
  681. @example
  682. # mkdir -p /usr/local/share/info
  683. # cd /usr/local/share/info
  684. # for i in /var/guix/profiles/per-user/root/current-guix/share/info/* ;
  685. do ln -s $i ; done
  686. @end example
  687. That way, assuming @file{/usr/local/share/info} is in the search path,
  688. running @command{info guix} will open this manual (@pxref{Other Info
  689. Directories,,, texinfo, GNU Texinfo}, for more details on changing the
  690. Info search path).
  691. @item
  692. @cindex substitutes, authorization thereof
  693. To use substitutes from @code{@value{SUBSTITUTE-SERVER-1}},
  694. @code{@value{SUBSTITUTE-SERVER-2}} or a mirror (@pxref{Substitutes}),
  695. authorize them:
  696. @example
  697. # guix archive --authorize < \
  698. ~root/.config/guix/current/share/guix/@value{SUBSTITUTE-SERVER-1}.pub
  699. # guix archive --authorize < \
  700. ~root/.config/guix/current/share/guix/@value{SUBSTITUTE-SERVER-2}.pub
  701. @end example
  702. @quotation Note
  703. If you do not enable substitutes, Guix will end up building
  704. @emph{everything} from source on your machine, making each installation
  705. and upgrade very expensive. @xref{On Trusting Binaries}, for a
  706. discussion of reasons why one might want do disable substitutes.
  707. @end quotation
  708. @item
  709. Each user may need to perform a few additional steps to make their Guix
  710. environment ready for use, @pxref{Application Setup}.
  711. @end enumerate
  712. Voilà, the installation is complete!
  713. You can confirm that Guix is working by installing a sample package into
  714. the root profile:
  715. @example
  716. # guix install hello
  717. @end example
  718. The binary installation tarball can be (re)produced and verified simply
  719. by running the following command in the Guix source tree:
  720. @example
  721. make guix-binary.@var{system}.tar.xz
  722. @end example
  723. @noindent
  724. ...@: which, in turn, runs:
  725. @example
  726. guix pack -s @var{system} --localstatedir \
  727. --profile-name=current-guix guix
  728. @end example
  729. @xref{Invoking guix pack}, for more info on this handy tool.
  730. @node Requirements
  731. @section Requirements
  732. This section lists requirements when building Guix from source. The
  733. build procedure for Guix is the same as for other GNU software, and is
  734. not covered here. Please see the files @file{README} and @file{INSTALL}
  735. in the Guix source tree for additional details.
  736. @cindex official website
  737. GNU Guix is available for download from its website at
  738. @url{https://www.gnu.org/software/guix/}.
  739. GNU Guix depends on the following packages:
  740. @itemize
  741. @item @url{https://gnu.org/software/guile/, GNU Guile}, version 3.0.x,
  742. version 3.0.3 or later;
  743. @item @url{https://notabug.org/cwebber/guile-gcrypt, Guile-Gcrypt}, version
  744. 0.1.0 or later;
  745. @item
  746. @uref{https://gnutls.org/, GnuTLS}, specifically its Guile bindings
  747. (@pxref{Guile Preparations, how to install the GnuTLS bindings for
  748. Guile,, gnutls-guile, GnuTLS-Guile});
  749. @item
  750. @uref{https://notabug.org/guile-sqlite3/guile-sqlite3, Guile-SQLite3}, version 0.1.0
  751. or later;
  752. @item @uref{https://notabug.org/guile-zlib/guile-zlib, Guile-zlib},
  753. version 0.1.0 or later;
  754. @item @uref{https://notabug.org/guile-lzlib/guile-lzlib, Guile-lzlib};
  755. @item @uref{https://www.nongnu.org/guile-avahi/, Guile-Avahi};
  756. @item
  757. @uref{https://gitlab.com/guile-git/guile-git, Guile-Git}, version 0.5.0
  758. or later;
  759. @item @uref{https://savannah.nongnu.org/projects/guile-json/, Guile-JSON}
  760. 4.3.0 or later;
  761. @item @url{https://www.gnu.org/software/make/, GNU Make}.
  762. @end itemize
  763. The following dependencies are optional:
  764. @itemize
  765. @item
  766. @c Note: We need at least 0.13.0 for #:nodelay.
  767. Support for build offloading (@pxref{Daemon Offload Setup}) and
  768. @command{guix copy} (@pxref{Invoking guix copy}) depends on
  769. @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH},
  770. version 0.13.0 or later.
  771. @item
  772. @uref{https://notabug.org/guile-zstd/guile-zstd, Guile-zstd}, for zstd
  773. compression and decompression in @command{guix publish} and for
  774. substitutes (@pxref{Invoking guix publish}).
  775. @item
  776. @uref{https://ngyro.com/software/guile-semver.html, Guile-Semver} for
  777. the @code{crate} importer (@pxref{Invoking guix import}).
  778. @item
  779. @uref{https://www.nongnu.org/guile-lib/doc/ref/htmlprag/, Guile-Lib} for
  780. the @code{go} importer (@pxref{Invoking guix import}) and for some of
  781. the ``updaters'' (@pxref{Invoking guix refresh}).
  782. @item
  783. When @url{http://www.bzip.org, libbz2} is available,
  784. @command{guix-daemon} can use it to compress build logs.
  785. @end itemize
  786. Unless @option{--disable-daemon} was passed to @command{configure}, the
  787. following packages are also needed:
  788. @itemize
  789. @item @url{https://gnupg.org/, GNU libgcrypt};
  790. @item @url{https://sqlite.org, SQLite 3};
  791. @item @url{https://gcc.gnu.org, GCC's g++}, with support for the
  792. C++11 standard.
  793. @end itemize
  794. @cindex state directory
  795. When configuring Guix on a system that already has a Guix installation,
  796. be sure to specify the same state directory as the existing installation
  797. using the @option{--localstatedir} option of the @command{configure}
  798. script (@pxref{Directory Variables, @code{localstatedir},, standards,
  799. GNU Coding Standards}). Usually, this @var{localstatedir} option is
  800. set to the value @file{/var}. The @command{configure} script protects
  801. against unintended misconfiguration of @var{localstatedir} so you do not
  802. inadvertently corrupt your store (@pxref{The Store}).
  803. @node Running the Test Suite
  804. @section Running the Test Suite
  805. @cindex test suite
  806. After a successful @command{configure} and @code{make} run, it is a good
  807. idea to run the test suite. It can help catch issues with the setup or
  808. environment, or bugs in Guix itself---and really, reporting test
  809. failures is a good way to help improve the software. To run the test
  810. suite, type:
  811. @example
  812. make check
  813. @end example
  814. Test cases can run in parallel: you can use the @code{-j} option of
  815. GNU@tie{}make to speed things up. The first run may take a few minutes
  816. on a recent machine; subsequent runs will be faster because the store
  817. that is created for test purposes will already have various things in
  818. cache.
  819. It is also possible to run a subset of the tests by defining the
  820. @code{TESTS} makefile variable as in this example:
  821. @example
  822. make check TESTS="tests/store.scm tests/cpio.scm"
  823. @end example
  824. By default, tests results are displayed at a file level. In order to
  825. see the details of every individual test cases, it is possible to define
  826. the @code{SCM_LOG_DRIVER_FLAGS} makefile variable as in this example:
  827. @example
  828. make check TESTS="tests/base64.scm" SCM_LOG_DRIVER_FLAGS="--brief=no"
  829. @end example
  830. The underlying SRFI 64 custom Automake test driver used for the 'check'
  831. test suite (located at @file{build-aux/test-driver.scm}) also allows
  832. selecting which test cases to run at a finer level, via its
  833. @option{--select} and @option{--exclude} options. Here's an example, to
  834. run all the test cases from the @file{tests/packages.scm} test file
  835. whose names start with ``transaction-upgrade-entry'':
  836. @example
  837. export SCM_LOG_DRIVER_FLAGS="--select=^transaction-upgrade-entry"
  838. make check TESTS="tests/packages.scm"
  839. @end example
  840. Those wishing to inspect the results of failed tests directly from the
  841. command line can add the @option{--errors-only=yes} option to the
  842. @code{SCM_LOG_DRIVER_FLAGS} makefile variable and set the @code{VERBOSE}
  843. Automake makefile variable, as in:
  844. @example
  845. make check SCM_LOG_DRIVER_FLAGS="--brief=no --errors-only=yes" VERBOSE=1
  846. @end example
  847. The @option{--show-duration=yes} option can be used to print the
  848. duration of the individual test cases, when used in combination with
  849. @option{--brief=no}:
  850. @example
  851. make check SCM_LOG_DRIVER_FLAGS="--brief=no --show-duration=yes"
  852. @end example
  853. @xref{Parallel Test Harness,,,automake,GNU Automake} for more
  854. information about the Automake Parallel Test Harness.
  855. Upon failure, please email @email{bug-guix@@gnu.org} and attach the
  856. @file{test-suite.log} file. Please specify the Guix version being used
  857. as well as version numbers of the dependencies (@pxref{Requirements}) in
  858. your message.
  859. Guix also comes with a whole-system test suite that tests complete
  860. Guix System instances. It can only run on systems where
  861. Guix is already installed, using:
  862. @example
  863. make check-system
  864. @end example
  865. @noindent
  866. or, again, by defining @code{TESTS} to select a subset of tests to run:
  867. @example
  868. make check-system TESTS="basic mcron"
  869. @end example
  870. These system tests are defined in the @code{(gnu tests @dots{})}
  871. modules. They work by running the operating systems under test with
  872. lightweight instrumentation in a virtual machine (VM). They can be
  873. computationally intensive or rather cheap, depending on whether
  874. substitutes are available for their dependencies (@pxref{Substitutes}).
  875. Some of them require a lot of storage space to hold VM images.
  876. Again in case of test failures, please send @email{bug-guix@@gnu.org}
  877. all the details.
  878. @node Setting Up the Daemon
  879. @section Setting Up the Daemon
  880. @cindex daemon
  881. Operations such as building a package or running the garbage collector
  882. are all performed by a specialized process, the @dfn{build daemon}, on
  883. behalf of clients. Only the daemon may access the store and its
  884. associated database. Thus, any operation that manipulates the store
  885. goes through the daemon. For instance, command-line tools such as
  886. @command{guix package} and @command{guix build} communicate with the
  887. daemon (@i{via} remote procedure calls) to instruct it what to do.
  888. The following sections explain how to prepare the build daemon's
  889. environment. See also @ref{Substitutes}, for information on how to allow
  890. the daemon to download pre-built binaries.
  891. @menu
  892. * Build Environment Setup:: Preparing the isolated build environment.
  893. * Daemon Offload Setup:: Offloading builds to remote machines.
  894. * SELinux Support:: Using an SELinux policy for the daemon.
  895. @end menu
  896. @node Build Environment Setup
  897. @subsection Build Environment Setup
  898. @cindex build environment
  899. In a standard multi-user setup, Guix and its daemon---the
  900. @command{guix-daemon} program---are installed by the system
  901. administrator; @file{/gnu/store} is owned by @code{root} and
  902. @command{guix-daemon} runs as @code{root}. Unprivileged users may use
  903. Guix tools to build packages or otherwise access the store, and the
  904. daemon will do it on their behalf, ensuring that the store is kept in a
  905. consistent state, and allowing built packages to be shared among users.
  906. @cindex build users
  907. When @command{guix-daemon} runs as @code{root}, you may not want package
  908. build processes themselves to run as @code{root} too, for obvious
  909. security reasons. To avoid that, a special pool of @dfn{build users}
  910. should be created for use by build processes started by the daemon.
  911. These build users need not have a shell and a home directory: they will
  912. just be used when the daemon drops @code{root} privileges in build
  913. processes. Having several such users allows the daemon to launch
  914. distinct build processes under separate UIDs, which guarantees that they
  915. do not interfere with each other---an essential feature since builds are
  916. regarded as pure functions (@pxref{Introduction}).
  917. On a GNU/Linux system, a build user pool may be created like this (using
  918. Bash syntax and the @code{shadow} commands):
  919. @c See https://lists.gnu.org/archive/html/bug-guix/2013-01/msg00239.html
  920. @c for why `-G' is needed.
  921. @example
  922. # groupadd --system guixbuild
  923. # for i in $(seq -w 1 10);
  924. do
  925. useradd -g guixbuild -G guixbuild \
  926. -d /var/empty -s $(which nologin) \
  927. -c "Guix build user $i" --system \
  928. guixbuilder$i;
  929. done
  930. @end example
  931. @noindent
  932. The number of build users determines how many build jobs may run in
  933. parallel, as specified by the @option{--max-jobs} option
  934. (@pxref{Invoking guix-daemon, @option{--max-jobs}}). To use
  935. @command{guix system vm} and related commands, you may need to add the
  936. build users to the @code{kvm} group so they can access @file{/dev/kvm},
  937. using @code{-G guixbuild,kvm} instead of @code{-G guixbuild}
  938. (@pxref{Invoking guix system}).
  939. The @code{guix-daemon} program may then be run as @code{root} with the
  940. following command@footnote{If your machine uses the systemd init system,
  941. dropping the @file{@var{prefix}/lib/systemd/system/guix-daemon.service}
  942. file in @file{/etc/systemd/system} will ensure that
  943. @command{guix-daemon} is automatically started. Similarly, if your
  944. machine uses the Upstart init system, drop the
  945. @file{@var{prefix}/lib/upstart/system/guix-daemon.conf}
  946. file in @file{/etc/init}.}:
  947. @example
  948. # guix-daemon --build-users-group=guixbuild
  949. @end example
  950. @cindex chroot
  951. @noindent
  952. This way, the daemon starts build processes in a chroot, under one of
  953. the @code{guixbuilder} users. On GNU/Linux, by default, the chroot
  954. environment contains nothing but:
  955. @c Keep this list in sync with libstore/build.cc! -----------------------
  956. @itemize
  957. @item
  958. a minimal @code{/dev} directory, created mostly independently from the
  959. host @code{/dev}@footnote{``Mostly'', because while the set of files
  960. that appear in the chroot's @code{/dev} is fixed, most of these files
  961. can only be created if the host has them.};
  962. @item
  963. the @code{/proc} directory; it only shows the processes of the container
  964. since a separate PID name space is used;
  965. @item
  966. @file{/etc/passwd} with an entry for the current user and an entry for
  967. user @file{nobody};
  968. @item
  969. @file{/etc/group} with an entry for the user's group;
  970. @item
  971. @file{/etc/hosts} with an entry that maps @code{localhost} to
  972. @code{127.0.0.1};
  973. @item
  974. a writable @file{/tmp} directory.
  975. @end itemize
  976. The chroot does not contain a @file{/home} directory, and the @env{HOME}
  977. environment variable is set to the non-existent
  978. @file{/homeless-shelter}. This helps to highlight inappropriate uses of
  979. @env{HOME} in the build scripts of packages.
  980. You can influence the directory where the daemon stores build trees
  981. @i{via} the @env{TMPDIR} environment variable. However, the build tree
  982. within the chroot is always called @file{/tmp/guix-build-@var{name}.drv-0},
  983. where @var{name} is the derivation name---e.g., @code{coreutils-8.24}.
  984. This way, the value of @env{TMPDIR} does not leak inside build
  985. environments, which avoids discrepancies in cases where build processes
  986. capture the name of their build tree.
  987. @vindex http_proxy
  988. @vindex https_proxy
  989. The daemon also honors the @env{http_proxy} and @env{https_proxy}
  990. environment variables for HTTP and HTTPS downloads it performs, be it
  991. for fixed-output derivations (@pxref{Derivations}) or for substitutes
  992. (@pxref{Substitutes}).
  993. If you are installing Guix as an unprivileged user, it is still possible
  994. to run @command{guix-daemon} provided you pass @option{--disable-chroot}.
  995. However, build processes will not be isolated from one another, and not
  996. from the rest of the system. Thus, build processes may interfere with
  997. each other, and may access programs, libraries, and other files
  998. available on the system---making it much harder to view them as
  999. @emph{pure} functions.
  1000. @node Daemon Offload Setup
  1001. @subsection Using the Offload Facility
  1002. @cindex offloading
  1003. @cindex build hook
  1004. When desired, the build daemon can @dfn{offload} derivation builds to
  1005. other machines running Guix, using the @code{offload} @dfn{build
  1006. hook}@footnote{This feature is available only when
  1007. @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH} is
  1008. present.}. When that feature is enabled, a list of user-specified build
  1009. machines is read from @file{/etc/guix/machines.scm}; every time a build
  1010. is requested, for instance via @code{guix build}, the daemon attempts to
  1011. offload it to one of the machines that satisfy the constraints of the
  1012. derivation, in particular its system types---e.g., @code{x86_64-linux}.
  1013. A single machine can have multiple system types, either because its
  1014. architecture natively supports it, via emulation
  1015. (@pxref{transparent-emulation-qemu, Transparent Emulation with QEMU}),
  1016. or both. Missing prerequisites for the build are
  1017. copied over SSH to the target machine, which then proceeds with the
  1018. build; upon success the output(s) of the build are copied back to the
  1019. initial machine. The offload facility comes with a basic scheduler that
  1020. attempts to select the best machine. The best machine is chosen among
  1021. the available machines based on criteria such as:
  1022. @enumerate
  1023. @item
  1024. The availability of a build slot. A build machine can have as many
  1025. build slots (connections) as the value of the @code{parallel-builds}
  1026. field of its @code{build-machine} object.
  1027. @item
  1028. Its relative speed, as defined via the @code{speed} field of its
  1029. @code{build-machine} object.
  1030. @item
  1031. Its load. The normalized machine load must be lower than a threshold
  1032. value, configurable via the @code{overload-threshold} field of its
  1033. @code{build-machine} object.
  1034. @item
  1035. Disk space availability. More than a 100 MiB must be available.
  1036. @end enumerate
  1037. The @file{/etc/guix/machines.scm} file typically looks like this:
  1038. @lisp
  1039. (list (build-machine
  1040. (name "eightysix.example.org")
  1041. (systems (list "x86_64-linux" "i686-linux"))
  1042. (host-key "ssh-ed25519 AAAAC3Nza@dots{}")
  1043. (user "bob")
  1044. (speed 2.)) ;incredibly fast!
  1045. (build-machine
  1046. (name "armeight.example.org")
  1047. (systems (list "aarch64-linux"))
  1048. (host-key "ssh-rsa AAAAB3Nza@dots{}")
  1049. (user "alice")
  1050. ;; Remember 'guix offload' is spawned by
  1051. ;; 'guix-daemon' as root.
  1052. (private-key "/root/.ssh/identity-for-guix")))
  1053. @end lisp
  1054. @noindent
  1055. In the example above we specify a list of two build machines, one for
  1056. the @code{x86_64} and @code{i686} architectures and one for the
  1057. @code{aarch64} architecture.
  1058. In fact, this file is---not surprisingly!---a Scheme file that is
  1059. evaluated when the @code{offload} hook is started. Its return value
  1060. must be a list of @code{build-machine} objects. While this example
  1061. shows a fixed list of build machines, one could imagine, say, using
  1062. DNS-SD to return a list of potential build machines discovered in the
  1063. local network (@pxref{Introduction, Guile-Avahi,, guile-avahi, Using
  1064. Avahi in Guile Scheme Programs}). The @code{build-machine} data type is
  1065. detailed below.
  1066. @deftp {Data Type} build-machine
  1067. This data type represents build machines to which the daemon may offload
  1068. builds. The important fields are:
  1069. @table @code
  1070. @item name
  1071. The host name of the remote machine.
  1072. @item systems
  1073. The system types the remote machine supports---e.g., @code{(list
  1074. "x86_64-linux" "i686-linux")}.
  1075. @item user
  1076. The user account to use when connecting to the remote machine over SSH.
  1077. Note that the SSH key pair must @emph{not} be passphrase-protected, to
  1078. allow non-interactive logins.
  1079. @item host-key
  1080. This must be the machine's SSH @dfn{public host key} in OpenSSH format.
  1081. This is used to authenticate the machine when we connect to it. It is a
  1082. long string that looks like this:
  1083. @example
  1084. ssh-ed25519 AAAAC3NzaC@dots{}mde+UhL hint@@example.org
  1085. @end example
  1086. If the machine is running the OpenSSH daemon, @command{sshd}, the host
  1087. key can be found in a file such as
  1088. @file{/etc/ssh/ssh_host_ed25519_key.pub}.
  1089. If the machine is running the SSH daemon of GNU@tie{}lsh,
  1090. @command{lshd}, the host key is in @file{/etc/lsh/host-key.pub} or a
  1091. similar file. It can be converted to the OpenSSH format using
  1092. @command{lsh-export-key} (@pxref{Converting keys,,, lsh, LSH Manual}):
  1093. @example
  1094. $ lsh-export-key --openssh < /etc/lsh/host-key.pub
  1095. ssh-rsa AAAAB3NzaC1yc2EAAAAEOp8FoQAAAQEAs1eB46LV@dots{}
  1096. @end example
  1097. @end table
  1098. A number of optional fields may be specified:
  1099. @table @asis
  1100. @item @code{port} (default: @code{22})
  1101. Port number of SSH server on the machine.
  1102. @item @code{private-key} (default: @file{~root/.ssh/id_rsa})
  1103. The SSH private key file to use when connecting to the machine, in
  1104. OpenSSH format. This key must not be protected with a passphrase.
  1105. Note that the default value is the private key @emph{of the root
  1106. account}. Make sure it exists if you use the default.
  1107. @item @code{compression} (default: @code{"zlib@@openssh.com,zlib"})
  1108. @itemx @code{compression-level} (default: @code{3})
  1109. The SSH-level compression methods and compression level requested.
  1110. Note that offloading relies on SSH compression to reduce bandwidth usage
  1111. when transferring files to and from build machines.
  1112. @item @code{daemon-socket} (default: @code{"/var/guix/daemon-socket/socket"})
  1113. File name of the Unix-domain socket @command{guix-daemon} is listening
  1114. to on that machine.
  1115. @item @code{overload-threshold} (default: @code{0.6})
  1116. The load threshold above which a potential offload machine is
  1117. disregarded by the offload scheduler. The value roughly translates to
  1118. the total processor usage of the build machine, ranging from 0.0 (0%) to
  1119. 1.0 (100%). It can also be disabled by setting
  1120. @code{overload-threshold} to @code{#f}.
  1121. @item @code{parallel-builds} (default: @code{1})
  1122. The number of builds that may run in parallel on the machine.
  1123. @item @code{speed} (default: @code{1.0})
  1124. A ``relative speed factor''. The offload scheduler will tend to prefer
  1125. machines with a higher speed factor.
  1126. @item @code{features} (default: @code{'()})
  1127. A list of strings denoting specific features supported by the machine.
  1128. An example is @code{"kvm"} for machines that have the KVM Linux modules
  1129. and corresponding hardware support. Derivations can request features by
  1130. name, and they will be scheduled on matching build machines.
  1131. @end table
  1132. @end deftp
  1133. The @command{guix} command must be in the search path on the build
  1134. machines. You can check whether this is the case by running:
  1135. @example
  1136. ssh build-machine guix repl --version
  1137. @end example
  1138. There is one last thing to do once @file{machines.scm} is in place. As
  1139. explained above, when offloading, files are transferred back and forth
  1140. between the machine stores. For this to work, you first need to
  1141. generate a key pair on each machine to allow the daemon to export signed
  1142. archives of files from the store (@pxref{Invoking guix archive}):
  1143. @example
  1144. # guix archive --generate-key
  1145. @end example
  1146. @noindent
  1147. Each build machine must authorize the key of the master machine so that
  1148. it accepts store items it receives from the master:
  1149. @example
  1150. # guix archive --authorize < master-public-key.txt
  1151. @end example
  1152. @noindent
  1153. Likewise, the master machine must authorize the key of each build machine.
  1154. All the fuss with keys is here to express pairwise mutual trust
  1155. relations between the master and the build machines. Concretely, when
  1156. the master receives files from a build machine (and @i{vice versa}), its
  1157. build daemon can make sure they are genuine, have not been tampered
  1158. with, and that they are signed by an authorized key.
  1159. @cindex offload test
  1160. To test whether your setup is operational, run this command on the
  1161. master node:
  1162. @example
  1163. # guix offload test
  1164. @end example
  1165. This will attempt to connect to each of the build machines specified in
  1166. @file{/etc/guix/machines.scm}, make sure Guix is
  1167. available on each machine, attempt to export to the machine and import
  1168. from it, and report any error in the process.
  1169. If you want to test a different machine file, just specify it on the
  1170. command line:
  1171. @example
  1172. # guix offload test machines-qualif.scm
  1173. @end example
  1174. Last, you can test the subset of the machines whose name matches a
  1175. regular expression like this:
  1176. @example
  1177. # guix offload test machines.scm '\.gnu\.org$'
  1178. @end example
  1179. @cindex offload status
  1180. To display the current load of all build hosts, run this command on the
  1181. main node:
  1182. @example
  1183. # guix offload status
  1184. @end example
  1185. @node SELinux Support
  1186. @subsection SELinux Support
  1187. @cindex SELinux, daemon policy
  1188. @cindex mandatory access control, SELinux
  1189. @cindex security, guix-daemon
  1190. Guix includes an SELinux policy file at @file{etc/guix-daemon.cil} that
  1191. can be installed on a system where SELinux is enabled, in order to label
  1192. Guix files and to specify the expected behavior of the daemon. Since
  1193. Guix System does not provide an SELinux base policy, the daemon policy cannot
  1194. be used on Guix System.
  1195. @subsubsection Installing the SELinux policy
  1196. @cindex SELinux, policy installation
  1197. To install the policy run this command as root:
  1198. @example
  1199. semodule -i etc/guix-daemon.cil
  1200. @end example
  1201. Then relabel the file system with @code{restorecon} or by a different
  1202. mechanism provided by your system.
  1203. Once the policy is installed, the file system has been relabeled, and
  1204. the daemon has been restarted, it should be running in the
  1205. @code{guix_daemon_t} context. You can confirm this with the following
  1206. command:
  1207. @example
  1208. ps -Zax | grep guix-daemon
  1209. @end example
  1210. Monitor the SELinux log files as you run a command like @code{guix build
  1211. hello} to convince yourself that SELinux permits all necessary
  1212. operations.
  1213. @subsubsection Limitations
  1214. @cindex SELinux, limitations
  1215. This policy is not perfect. Here is a list of limitations or quirks
  1216. that should be considered when deploying the provided SELinux policy for
  1217. the Guix daemon.
  1218. @enumerate
  1219. @item
  1220. @code{guix_daemon_socket_t} isn’t actually used. None of the socket
  1221. operations involve contexts that have anything to do with
  1222. @code{guix_daemon_socket_t}. It doesn’t hurt to have this unused label,
  1223. but it would be preferable to define socket rules for only this label.
  1224. @item
  1225. @code{guix gc} cannot access arbitrary links to profiles. By design,
  1226. the file label of the destination of a symlink is independent of the
  1227. file label of the link itself. Although all profiles under
  1228. $localstatedir are labelled, the links to these profiles inherit the
  1229. label of the directory they are in. For links in the user’s home
  1230. directory this will be @code{user_home_t}. But for links from the root
  1231. user’s home directory, or @file{/tmp}, or the HTTP server’s working
  1232. directory, etc, this won’t work. @code{guix gc} would be prevented from
  1233. reading and following these links.
  1234. @item
  1235. The daemon’s feature to listen for TCP connections might no longer work.
  1236. This might require extra rules, because SELinux treats network sockets
  1237. differently from files.
  1238. @item
  1239. Currently all files with a name matching the regular expression
  1240. @code{/gnu/store/.+-(guix-.+|profile)/bin/guix-daemon} are assigned the
  1241. label @code{guix_daemon_exec_t}; this means that @emph{any} file with
  1242. that name in any profile would be permitted to run in the
  1243. @code{guix_daemon_t} domain. This is not ideal. An attacker could
  1244. build a package that provides this executable and convince a user to
  1245. install and run it, which lifts it into the @code{guix_daemon_t} domain.
  1246. At that point SELinux could not prevent it from accessing files that are
  1247. allowed for processes in that domain.
  1248. You will need to relabel the store directory after all upgrades to
  1249. @file{guix-daemon}, such as after running @code{guix pull}. Assuming the
  1250. store is in @file{/gnu}, you can do this with @code{restorecon -vR /gnu},
  1251. or by other means provided by your operating system.
  1252. We could generate a much more restrictive policy at installation time,
  1253. so that only the @emph{exact} file name of the currently installed
  1254. @code{guix-daemon} executable would be labelled with
  1255. @code{guix_daemon_exec_t}, instead of using a broad regular expression.
  1256. The downside is that root would have to install or upgrade the policy at
  1257. installation time whenever the Guix package that provides the
  1258. effectively running @code{guix-daemon} executable is upgraded.
  1259. @end enumerate
  1260. @node Invoking guix-daemon
  1261. @section Invoking @command{guix-daemon}
  1262. The @command{guix-daemon} program implements all the functionality to
  1263. access the store. This includes launching build processes, running the
  1264. garbage collector, querying the availability of a build result, etc. It
  1265. is normally run as @code{root} like this:
  1266. @example
  1267. # guix-daemon --build-users-group=guixbuild
  1268. @end example
  1269. @noindent
  1270. For details on how to set it up, @pxref{Setting Up the Daemon}.
  1271. @cindex chroot
  1272. @cindex container, build environment
  1273. @cindex build environment
  1274. @cindex reproducible builds
  1275. By default, @command{guix-daemon} launches build processes under
  1276. different UIDs, taken from the build group specified with
  1277. @option{--build-users-group}. In addition, each build process is run in a
  1278. chroot environment that only contains the subset of the store that the
  1279. build process depends on, as specified by its derivation
  1280. (@pxref{Programming Interface, derivation}), plus a set of specific
  1281. system directories. By default, the latter contains @file{/dev} and
  1282. @file{/dev/pts}. Furthermore, on GNU/Linux, the build environment is a
  1283. @dfn{container}: in addition to having its own file system tree, it has
  1284. a separate mount name space, its own PID name space, network name space,
  1285. etc. This helps achieve reproducible builds (@pxref{Features}).
  1286. When the daemon performs a build on behalf of the user, it creates a
  1287. build directory under @file{/tmp} or under the directory specified by
  1288. its @env{TMPDIR} environment variable. This directory is shared with
  1289. the container for the duration of the build, though within the container,
  1290. the build tree is always called @file{/tmp/guix-build-@var{name}.drv-0}.
  1291. The build directory is automatically deleted upon completion, unless the
  1292. build failed and the client specified @option{--keep-failed}
  1293. (@pxref{Common Build Options, @option{--keep-failed}}).
  1294. The daemon listens for connections and spawns one sub-process for each session
  1295. started by a client (one of the @command{guix} sub-commands). The
  1296. @command{guix processes} command allows you to get an overview of the activity
  1297. on your system by viewing each of the active sessions and clients.
  1298. @xref{Invoking guix processes}, for more information.
  1299. The following command-line options are supported:
  1300. @table @code
  1301. @item --build-users-group=@var{group}
  1302. Take users from @var{group} to run build processes (@pxref{Setting Up
  1303. the Daemon, build users}).
  1304. @item --no-substitutes
  1305. @cindex substitutes
  1306. Do not use substitutes for build products. That is, always build things
  1307. locally instead of allowing downloads of pre-built binaries
  1308. (@pxref{Substitutes}).
  1309. When the daemon runs with @option{--no-substitutes}, clients can still
  1310. explicitly enable substitution @i{via} the @code{set-build-options}
  1311. remote procedure call (@pxref{The Store}).
  1312. @anchor{daemon-substitute-urls}
  1313. @item --substitute-urls=@var{urls}
  1314. Consider @var{urls} the default whitespace-separated list of substitute
  1315. source URLs. When this option is omitted,
  1316. @indicateurl{@value{SUBSTITUTE-URLS}} is used.
  1317. This means that substitutes may be downloaded from @var{urls}, as long
  1318. as they are signed by a trusted signature (@pxref{Substitutes}).
  1319. @xref{Getting Substitutes from Other Servers}, for more information on
  1320. how to configure the daemon to get substitutes from other servers.
  1321. @cindex offloading
  1322. @item --no-offload
  1323. Do not use offload builds to other machines (@pxref{Daemon Offload
  1324. Setup}). That is, always build things locally instead of offloading
  1325. builds to remote machines.
  1326. @item --cache-failures
  1327. Cache build failures. By default, only successful builds are cached.
  1328. When this option is used, @command{guix gc --list-failures} can be used
  1329. to query the set of store items marked as failed; @command{guix gc
  1330. --clear-failures} removes store items from the set of cached failures.
  1331. @xref{Invoking guix gc}.
  1332. @item --cores=@var{n}
  1333. @itemx -c @var{n}
  1334. Use @var{n} CPU cores to build each derivation; @code{0} means as many
  1335. as available.
  1336. The default value is @code{0}, but it may be overridden by clients, such
  1337. as the @option{--cores} option of @command{guix build} (@pxref{Invoking
  1338. guix build}).
  1339. The effect is to define the @env{NIX_BUILD_CORES} environment variable
  1340. in the build process, which can then use it to exploit internal
  1341. parallelism---for instance, by running @code{make -j$NIX_BUILD_CORES}.
  1342. @item --max-jobs=@var{n}
  1343. @itemx -M @var{n}
  1344. Allow at most @var{n} build jobs in parallel. The default value is
  1345. @code{1}. Setting it to @code{0} means that no builds will be performed
  1346. locally; instead, the daemon will offload builds (@pxref{Daemon Offload
  1347. Setup}), or simply fail.
  1348. @item --max-silent-time=@var{seconds}
  1349. When the build or substitution process remains silent for more than
  1350. @var{seconds}, terminate it and report a build failure.
  1351. The default value is @code{0}, which disables the timeout.
  1352. The value specified here can be overridden by clients (@pxref{Common
  1353. Build Options, @option{--max-silent-time}}).
  1354. @item --timeout=@var{seconds}
  1355. Likewise, when the build or substitution process lasts for more than
  1356. @var{seconds}, terminate it and report a build failure.
  1357. The default value is @code{0}, which disables the timeout.
  1358. The value specified here can be overridden by clients (@pxref{Common
  1359. Build Options, @option{--timeout}}).
  1360. @item --rounds=@var{N}
  1361. Build each derivation @var{n} times in a row, and raise an error if
  1362. consecutive build results are not bit-for-bit identical. Note that this
  1363. setting can be overridden by clients such as @command{guix build}
  1364. (@pxref{Invoking guix build}).
  1365. When used in conjunction with @option{--keep-failed}, the differing
  1366. output is kept in the store, under @file{/gnu/store/@dots{}-check}.
  1367. This makes it easy to look for differences between the two results.
  1368. @item --debug
  1369. Produce debugging output.
  1370. This is useful to debug daemon start-up issues, but then it may be
  1371. overridden by clients, for example the @option{--verbosity} option of
  1372. @command{guix build} (@pxref{Invoking guix build}).
  1373. @item --chroot-directory=@var{dir}
  1374. Add @var{dir} to the build chroot.
  1375. Doing this may change the result of build processes---for instance if
  1376. they use optional dependencies found in @var{dir} when it is available,
  1377. and not otherwise. For that reason, it is not recommended to do so.
  1378. Instead, make sure that each derivation declares all the inputs that it
  1379. needs.
  1380. @item --disable-chroot
  1381. Disable chroot builds.
  1382. Using this option is not recommended since, again, it would allow build
  1383. processes to gain access to undeclared dependencies. It is necessary,
  1384. though, when @command{guix-daemon} is running under an unprivileged user
  1385. account.
  1386. @item --log-compression=@var{type}
  1387. Compress build logs according to @var{type}, one of @code{gzip},
  1388. @code{bzip2}, or @code{none}.
  1389. Unless @option{--lose-logs} is used, all the build logs are kept in the
  1390. @var{localstatedir}. To save space, the daemon automatically compresses
  1391. them with gzip by default.
  1392. @item --discover[=yes|no]
  1393. Whether to discover substitute servers on the local network using mDNS
  1394. and DNS-SD.
  1395. This feature is still experimental. However, here are a few
  1396. considerations.
  1397. @enumerate
  1398. @item
  1399. It might be faster/less expensive than fetching from remote servers;
  1400. @item
  1401. There are no security risks, only genuine substitutes will be used
  1402. (@pxref{Substitute Authentication});
  1403. @item
  1404. An attacker advertising @command{guix publish} on your LAN cannot serve
  1405. you malicious binaries, but they can learn what software you’re
  1406. installing;
  1407. @item
  1408. Servers may serve substitute over HTTP, unencrypted, so anyone on the
  1409. LAN can see what software you’re installing.
  1410. @end enumerate
  1411. It is also possible to enable or disable substitute server discovery at
  1412. run-time by running:
  1413. @example
  1414. herd discover guix-daemon on
  1415. herd discover guix-daemon off
  1416. @end example
  1417. @item --disable-deduplication
  1418. @cindex deduplication
  1419. Disable automatic file ``deduplication'' in the store.
  1420. By default, files added to the store are automatically ``deduplicated'':
  1421. if a newly added file is identical to another one found in the store,
  1422. the daemon makes the new file a hard link to the other file. This can
  1423. noticeably reduce disk usage, at the expense of slightly increased
  1424. input/output load at the end of a build process. This option disables
  1425. this optimization.
  1426. @item --gc-keep-outputs[=yes|no]
  1427. Tell whether the garbage collector (GC) must keep outputs of live
  1428. derivations.
  1429. @cindex GC roots
  1430. @cindex garbage collector roots
  1431. When set to @code{yes}, the GC will keep the outputs of any live
  1432. derivation available in the store---the @file{.drv} files. The default
  1433. is @code{no}, meaning that derivation outputs are kept only if they are
  1434. reachable from a GC root. @xref{Invoking guix gc}, for more on GC
  1435. roots.
  1436. @item --gc-keep-derivations[=yes|no]
  1437. Tell whether the garbage collector (GC) must keep derivations
  1438. corresponding to live outputs.
  1439. When set to @code{yes}, as is the case by default, the GC keeps
  1440. derivations---i.e., @file{.drv} files---as long as at least one of their
  1441. outputs is live. This allows users to keep track of the origins of
  1442. items in their store. Setting it to @code{no} saves a bit of disk
  1443. space.
  1444. In this way, setting @option{--gc-keep-derivations} to @code{yes} causes
  1445. liveness to flow from outputs to derivations, and setting
  1446. @option{--gc-keep-outputs} to @code{yes} causes liveness to flow from
  1447. derivations to outputs. When both are set to @code{yes}, the effect is
  1448. to keep all the build prerequisites (the sources, compiler, libraries,
  1449. and other build-time tools) of live objects in the store, regardless of
  1450. whether these prerequisites are reachable from a GC root. This is
  1451. convenient for developers since it saves rebuilds or downloads.
  1452. @item --impersonate-linux-2.6
  1453. On Linux-based systems, impersonate Linux 2.6. This means that the
  1454. kernel's @command{uname} system call will report 2.6 as the release number.
  1455. This might be helpful to build programs that (usually wrongfully) depend
  1456. on the kernel version number.
  1457. @item --lose-logs
  1458. Do not keep build logs. By default they are kept under
  1459. @file{@var{localstatedir}/guix/log}.
  1460. @item --system=@var{system}
  1461. Assume @var{system} as the current system type. By default it is the
  1462. architecture/kernel pair found at configure time, such as
  1463. @code{x86_64-linux}.
  1464. @item --listen=@var{endpoint}
  1465. Listen for connections on @var{endpoint}. @var{endpoint} is interpreted
  1466. as the file name of a Unix-domain socket if it starts with
  1467. @code{/} (slash sign). Otherwise, @var{endpoint} is interpreted as a
  1468. host name or host name and port to listen to. Here are a few examples:
  1469. @table @code
  1470. @item --listen=/gnu/var/daemon
  1471. Listen for connections on the @file{/gnu/var/daemon} Unix-domain socket,
  1472. creating it if needed.
  1473. @item --listen=localhost
  1474. @cindex daemon, remote access
  1475. @cindex remote access to the daemon
  1476. @cindex daemon, cluster setup
  1477. @cindex clusters, daemon setup
  1478. Listen for TCP connections on the network interface corresponding to
  1479. @code{localhost}, on port 44146.
  1480. @item --listen=128.0.0.42:1234
  1481. Listen for TCP connections on the network interface corresponding to
  1482. @code{128.0.0.42}, on port 1234.
  1483. @end table
  1484. This option can be repeated multiple times, in which case
  1485. @command{guix-daemon} accepts connections on all the specified
  1486. endpoints. Users can tell client commands what endpoint to connect to
  1487. by setting the @env{GUIX_DAEMON_SOCKET} environment variable
  1488. (@pxref{The Store, @env{GUIX_DAEMON_SOCKET}}).
  1489. @quotation Note
  1490. The daemon protocol is @emph{unauthenticated and unencrypted}. Using
  1491. @option{--listen=@var{host}} is suitable on local networks, such as
  1492. clusters, where only trusted nodes may connect to the build daemon. In
  1493. other cases where remote access to the daemon is needed, we recommend
  1494. using Unix-domain sockets along with SSH.
  1495. @end quotation
  1496. When @option{--listen} is omitted, @command{guix-daemon} listens for
  1497. connections on the Unix-domain socket located at
  1498. @file{@var{localstatedir}/guix/daemon-socket/socket}.
  1499. @end table
  1500. @node Application Setup
  1501. @section Application Setup
  1502. @cindex foreign distro
  1503. When using Guix on top of GNU/Linux distribution other than Guix System---a
  1504. so-called @dfn{foreign distro}---a few additional steps are needed to
  1505. get everything in place. Here are some of them.
  1506. @subsection Locales
  1507. @anchor{locales-and-locpath}
  1508. @cindex locales, when not on Guix System
  1509. @vindex LOCPATH
  1510. @vindex GUIX_LOCPATH
  1511. Packages installed @i{via} Guix will not use the locale data of the
  1512. host system. Instead, you must first install one of the locale packages
  1513. available with Guix and then define the @env{GUIX_LOCPATH} environment
  1514. variable:
  1515. @example
  1516. $ guix install glibc-locales
  1517. $ export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale
  1518. @end example
  1519. Note that the @code{glibc-locales} package contains data for all the
  1520. locales supported by the GNU@tie{}libc and weighs in at around
  1521. 930@tie{}MiB@footnote{The size of the @code{glibc-locales} package is
  1522. reduced down to about 213@tie{}MiB with store deduplication and further
  1523. down to about 67@tie{}MiB when using a zstd-compressed Btrfs file
  1524. system.}. If you only need a few locales, you can define your custom
  1525. locales package via the @code{make-glibc-utf8-locales} procedure from
  1526. the @code{(gnu packages base)} module. The following example defines a
  1527. package containing the various Canadian UTF-8 locales known to the
  1528. GNU@tie{}libc, that weighs around 14@tie{}MiB:
  1529. @lisp
  1530. (use-modules (gnu packages base))
  1531. (define my-glibc-locales
  1532. (make-glibc-utf8-locales
  1533. glibc
  1534. #:locales (list "en_CA" "fr_CA" "ik_CA" "iu_CA" "shs_CA")
  1535. #:name "glibc-canadian-utf8-locales"))
  1536. @end lisp
  1537. The @env{GUIX_LOCPATH} variable plays a role similar to @env{LOCPATH}
  1538. (@pxref{Locale Names, @env{LOCPATH},, libc, The GNU C Library Reference
  1539. Manual}). There are two important differences though:
  1540. @enumerate
  1541. @item
  1542. @env{GUIX_LOCPATH} is honored only by the libc in Guix, and not by the libc
  1543. provided by foreign distros. Thus, using @env{GUIX_LOCPATH} allows you
  1544. to make sure the programs of the foreign distro will not end up loading
  1545. incompatible locale data.
  1546. @item
  1547. libc suffixes each entry of @env{GUIX_LOCPATH} with @code{/X.Y}, where
  1548. @code{X.Y} is the libc version---e.g., @code{2.22}. This means that,
  1549. should your Guix profile contain a mixture of programs linked against
  1550. different libc version, each libc version will only try to load locale
  1551. data in the right format.
  1552. @end enumerate
  1553. This is important because the locale data format used by different libc
  1554. versions may be incompatible.
  1555. @subsection Name Service Switch
  1556. @cindex name service switch, glibc
  1557. @cindex NSS (name service switch), glibc
  1558. @cindex nscd (name service caching daemon)
  1559. @cindex name service caching daemon (nscd)
  1560. When using Guix on a foreign distro, we @emph{strongly recommend} that
  1561. the system run the GNU C library's @dfn{name service cache daemon},
  1562. @command{nscd}, which should be listening on the
  1563. @file{/var/run/nscd/socket} socket. Failing to do that, applications
  1564. installed with Guix may fail to look up host names or user accounts, or
  1565. may even crash. The next paragraphs explain why.
  1566. @cindex @file{nsswitch.conf}
  1567. The GNU C library implements a @dfn{name service switch} (NSS), which is
  1568. an extensible mechanism for ``name lookups'' in general: host name
  1569. resolution, user accounts, and more (@pxref{Name Service Switch,,, libc,
  1570. The GNU C Library Reference Manual}).
  1571. @cindex Network information service (NIS)
  1572. @cindex NIS (Network information service)
  1573. Being extensible, the NSS supports @dfn{plugins}, which provide new name
  1574. lookup implementations: for example, the @code{nss-mdns} plugin allow
  1575. resolution of @code{.local} host names, the @code{nis} plugin allows
  1576. user account lookup using the Network information service (NIS), and so
  1577. on. These extra ``lookup services'' are configured system-wide in
  1578. @file{/etc/nsswitch.conf}, and all the programs running on the system
  1579. honor those settings (@pxref{NSS Configuration File,,, libc, The GNU C
  1580. Reference Manual}).
  1581. When they perform a name lookup---for instance by calling the
  1582. @code{getaddrinfo} function in C---applications first try to connect to
  1583. the nscd; on success, nscd performs name lookups on their behalf. If
  1584. the nscd is not running, then they perform the name lookup by
  1585. themselves, by loading the name lookup services into their own address
  1586. space and running it. These name lookup services---the
  1587. @file{libnss_*.so} files---are @code{dlopen}'d, but they may come from
  1588. the host system's C library, rather than from the C library the
  1589. application is linked against (the C library coming from Guix).
  1590. And this is where the problem is: if your application is linked against
  1591. Guix's C library (say, glibc 2.24) and tries to load NSS plugins from
  1592. another C library (say, @code{libnss_mdns.so} for glibc 2.22), it will
  1593. likely crash or have its name lookups fail unexpectedly.
  1594. Running @command{nscd} on the system, among other advantages, eliminates
  1595. this binary incompatibility problem because those @code{libnss_*.so}
  1596. files are loaded in the @command{nscd} process, not in applications
  1597. themselves.
  1598. @subsection X11 Fonts
  1599. @cindex fonts
  1600. The majority of graphical applications use Fontconfig to locate and load
  1601. fonts and perform X11-client-side rendering. The @code{fontconfig}
  1602. package in Guix looks for fonts in @file{$HOME/.guix-profile} by
  1603. default. Thus, to allow graphical applications installed with Guix to
  1604. display fonts, you have to install fonts with Guix as well. Essential
  1605. font packages include @code{font-ghostscript}, @code{font-dejavu}, and
  1606. @code{font-gnu-freefont}.
  1607. @cindex @code{fc-cache}
  1608. @cindex font cache
  1609. Once you have installed or removed fonts, or when you notice an
  1610. application that does not find fonts, you may need to install Fontconfig
  1611. and to force an update of its font cache by running:
  1612. @example
  1613. guix install fontconfig
  1614. fc-cache -rv
  1615. @end example
  1616. To display text written in Chinese languages, Japanese, or Korean in
  1617. graphical applications, consider installing
  1618. @code{font-adobe-source-han-sans} or @code{font-wqy-zenhei}. The former
  1619. has multiple outputs, one per language family (@pxref{Packages with
  1620. Multiple Outputs}). For instance, the following command installs fonts
  1621. for Chinese languages:
  1622. @example
  1623. guix install font-adobe-source-han-sans:cn
  1624. @end example
  1625. @cindex @code{xterm}
  1626. Older programs such as @command{xterm} do not use Fontconfig and instead
  1627. rely on server-side font rendering. Such programs require to specify a
  1628. full name of a font using XLFD (X Logical Font Description), like this:
  1629. @example
  1630. -*-dejavu sans-medium-r-normal-*-*-100-*-*-*-*-*-1
  1631. @end example
  1632. To be able to use such full names for the TrueType fonts installed in
  1633. your Guix profile, you need to extend the font path of the X server:
  1634. @c Note: 'xset' does not accept symlinks so the trick below arranges to
  1635. @c get at the real directory. See <https://bugs.gnu.org/30655>.
  1636. @example
  1637. xset +fp $(dirname $(readlink -f ~/.guix-profile/share/fonts/truetype/fonts.dir))
  1638. @end example
  1639. @cindex @code{xlsfonts}
  1640. After that, you can run @code{xlsfonts} (from @code{xlsfonts} package)
  1641. to make sure your TrueType fonts are listed there.
  1642. @subsection X.509 Certificates
  1643. @cindex @code{nss-certs}
  1644. The @code{nss-certs} package provides X.509 certificates, which allow
  1645. programs to authenticate Web servers accessed over HTTPS.
  1646. When using Guix on a foreign distro, you can install this package and
  1647. define the relevant environment variables so that packages know where to
  1648. look for certificates. @xref{X.509 Certificates}, for detailed
  1649. information.
  1650. @subsection Emacs Packages
  1651. @cindex @code{emacs}
  1652. When you install Emacs packages with Guix, the Elisp files are placed
  1653. under the @file{share/emacs/site-lisp/} directory of the profile in
  1654. which they are installed. The Elisp libraries are made available to
  1655. Emacs through the @env{EMACSLOADPATH} environment variable, which is
  1656. set when installing Emacs itself.
  1657. Additionally, autoload definitions are automatically evaluated at the
  1658. initialization of Emacs, by the Guix-specific
  1659. @code{guix-emacs-autoload-packages} procedure. If, for some reason, you
  1660. want to avoid auto-loading the Emacs packages installed with Guix, you
  1661. can do so by running Emacs with the @option{--no-site-file} option
  1662. (@pxref{Init File,,, emacs, The GNU Emacs Manual}).
  1663. @node Upgrading Guix
  1664. @section Upgrading Guix
  1665. @cindex Upgrading Guix, on a foreign distro
  1666. To upgrade Guix, run:
  1667. @example
  1668. guix pull
  1669. @end example
  1670. @xref{Invoking guix pull}, for more information.
  1671. @cindex upgrading Guix for the root user, on a foreign distro
  1672. @cindex upgrading the Guix daemon, on a foreign distro
  1673. @cindex @command{guix pull} for the root user, on a foreign distro
  1674. On a foreign distro, you can upgrade the build daemon by running:
  1675. @example
  1676. sudo -i guix pull
  1677. @end example
  1678. @noindent
  1679. followed by (assuming your distro uses the systemd service management
  1680. tool):
  1681. @example
  1682. systemctl restart guix-daemon.service
  1683. @end example
  1684. On Guix System, upgrading the daemon is achieved by reconfiguring the
  1685. system (@pxref{Invoking guix system, @code{guix system reconfigure}}).
  1686. @c TODO What else?
  1687. @c *********************************************************************
  1688. @node System Installation
  1689. @chapter System Installation
  1690. @cindex installing Guix System
  1691. @cindex Guix System, installation
  1692. This section explains how to install Guix System
  1693. on a machine. Guix, as a package manager, can
  1694. also be installed on top of a running GNU/Linux system,
  1695. @pxref{Installation}.
  1696. @ifinfo
  1697. @quotation Note
  1698. @c This paragraph is for people reading this from tty2 of the
  1699. @c installation image.
  1700. You are reading this documentation with an Info reader. For details on
  1701. how to use it, hit the @key{RET} key (``return'' or ``enter'') on the
  1702. link that follows: @pxref{Top, Info reader,, info-stnd, Stand-alone GNU
  1703. Info}. Hit @kbd{l} afterwards to come back here.
  1704. Alternatively, run @command{info info} in another tty to keep the manual
  1705. available.
  1706. @end quotation
  1707. @end ifinfo
  1708. @menu
  1709. * Limitations:: What you can expect.
  1710. * Hardware Considerations:: Supported hardware.
  1711. * USB Stick and DVD Installation:: Preparing the installation medium.
  1712. * Preparing for Installation:: Networking, partitioning, etc.
  1713. * Guided Graphical Installation:: Easy graphical installation.
  1714. * Manual Installation:: Manual installation for wizards.
  1715. * After System Installation:: When installation succeeded.
  1716. * Installing Guix in a VM:: Guix System playground.
  1717. * Building the Installation Image:: How this comes to be.
  1718. @end menu
  1719. @node Limitations
  1720. @section Limitations
  1721. We consider Guix System to be ready for a wide range of ``desktop'' and server
  1722. use cases. The reliability guarantees it provides---transactional upgrades
  1723. and rollbacks, reproducibility---make it a solid foundation.
  1724. Nevertheless, before you proceed with the installation, be aware of the
  1725. following noteworthy limitations applicable to version @value{VERSION}:
  1726. @itemize
  1727. @item
  1728. More and more system services are provided (@pxref{Services}), but some
  1729. may be missing.
  1730. @item
  1731. GNOME, Xfce, LXDE, and Enlightenment are available (@pxref{Desktop Services}),
  1732. as well as a number of X11 window managers. However, KDE is currently
  1733. missing.
  1734. @end itemize
  1735. More than a disclaimer, this is an invitation to report issues (and success
  1736. stories!), and to join us in improving it. @xref{Contributing}, for more
  1737. info.
  1738. @node Hardware Considerations
  1739. @section Hardware Considerations
  1740. @cindex hardware support on Guix System
  1741. GNU@tie{}Guix focuses on respecting the user's computing freedom. It
  1742. builds around the kernel Linux-libre, which means that only hardware for
  1743. which free software drivers and firmware exist is supported. Nowadays,
  1744. a wide range of off-the-shelf hardware is supported on
  1745. GNU/Linux-libre---from keyboards to graphics cards to scanners and
  1746. Ethernet controllers. Unfortunately, there are still areas where
  1747. hardware vendors deny users control over their own computing, and such
  1748. hardware is not supported on Guix System.
  1749. @cindex WiFi, hardware support
  1750. One of the main areas where free drivers or firmware are lacking is WiFi
  1751. devices. WiFi devices known to work include those using Atheros chips
  1752. (AR9271 and AR7010), which corresponds to the @code{ath9k} Linux-libre
  1753. driver, and those using Broadcom/AirForce chips (BCM43xx with
  1754. Wireless-Core Revision 5), which corresponds to the @code{b43-open}
  1755. Linux-libre driver. Free firmware exists for both and is available
  1756. out-of-the-box on Guix System, as part of @code{%base-firmware}
  1757. (@pxref{operating-system Reference, @code{firmware}}).
  1758. @cindex RYF, Respects Your Freedom
  1759. The @uref{https://www.fsf.org/, Free Software Foundation} runs
  1760. @uref{https://www.fsf.org/ryf, @dfn{Respects Your Freedom}} (RYF), a
  1761. certification program for hardware products that respect your freedom
  1762. and your privacy and ensure that you have control over your device. We
  1763. encourage you to check the list of RYF-certified devices.
  1764. Another useful resource is the @uref{https://www.h-node.org/, H-Node}
  1765. web site. It contains a catalog of hardware devices with information
  1766. about their support in GNU/Linux.
  1767. @node USB Stick and DVD Installation
  1768. @section USB Stick and DVD Installation
  1769. An ISO-9660 installation image that can be written to a USB stick or
  1770. burnt to a DVD can be downloaded from
  1771. @indicateurl{@value{BASE-URL}/guix-system-install-@value{VERSION}.x86_64-linux.iso},
  1772. where you can replace @code{x86_64-linux} with one of:
  1773. @table @code
  1774. @item x86_64-linux
  1775. for a GNU/Linux system on Intel/AMD-compatible 64-bit CPUs;
  1776. @item i686-linux
  1777. for a 32-bit GNU/Linux system on Intel-compatible CPUs.
  1778. @end table
  1779. @c start duplication of authentication part from ``Binary Installation''
  1780. Make sure to download the associated @file{.sig} file and to verify the
  1781. authenticity of the image against it, along these lines:
  1782. @example
  1783. $ wget @value{BASE-URL}/guix-system-install-@value{VERSION}.x86_64-linux.iso.sig
  1784. $ gpg --verify guix-system-install-@value{VERSION}.x86_64-linux.iso.sig
  1785. @end example
  1786. If that command fails because you do not have the required public key,
  1787. then run this command to import it:
  1788. @example
  1789. $ wget @value{OPENPGP-SIGNING-KEY-URL} \
  1790. -qO - | gpg --import -
  1791. @end example
  1792. @noindent
  1793. and rerun the @code{gpg --verify} command.
  1794. Take note that a warning like ``This key is not certified with a trusted
  1795. signature!'' is normal.
  1796. @c end duplication
  1797. This image contains the tools necessary for an installation.
  1798. It is meant to be copied @emph{as is} to a large-enough USB stick or DVD.
  1799. @unnumberedsubsec Copying to a USB Stick
  1800. Insert a USB stick of 1@tie{}GiB or more into your machine, and determine
  1801. its device name. Assuming that the USB stick is known as @file{/dev/sdX},
  1802. copy the image with:
  1803. @example
  1804. dd if=guix-system-install-@value{VERSION}.x86_64-linux.iso of=/dev/sdX status=progress
  1805. sync
  1806. @end example
  1807. Access to @file{/dev/sdX} usually requires root privileges.
  1808. @unnumberedsubsec Burning on a DVD
  1809. Insert a blank DVD into your machine, and determine
  1810. its device name. Assuming that the DVD drive is known as @file{/dev/srX},
  1811. copy the image with:
  1812. @example
  1813. growisofs -dvd-compat -Z /dev/srX=guix-system-install-@value{VERSION}.x86_64-linux.iso
  1814. @end example
  1815. Access to @file{/dev/srX} usually requires root privileges.
  1816. @unnumberedsubsec Booting
  1817. Once this is done, you should be able to reboot the system and boot from
  1818. the USB stick or DVD@. The latter usually requires you to get in the
  1819. BIOS or UEFI boot menu, where you can choose to boot from the USB stick.
  1820. In order to boot from Libreboot, switch to the command mode by pressing
  1821. the @kbd{c} key and type @command{search_grub usb}.
  1822. @xref{Installing Guix in a VM}, if, instead, you would like to install
  1823. Guix System in a virtual machine (VM).
  1824. @node Preparing for Installation
  1825. @section Preparing for Installation
  1826. Once you have booted, you can use the guided graphical installer, which makes
  1827. it easy to get started (@pxref{Guided Graphical Installation}). Alternatively,
  1828. if you are already familiar with GNU/Linux and if you want more control than
  1829. what the graphical installer provides, you can choose the ``manual''
  1830. installation process (@pxref{Manual Installation}).
  1831. The graphical installer is available on TTY1. You can obtain root shells on
  1832. TTYs 3 to 6 by hitting @kbd{ctrl-alt-f3}, @kbd{ctrl-alt-f4}, etc. TTY2 shows
  1833. this documentation and you can reach it with @kbd{ctrl-alt-f2}. Documentation
  1834. is browsable using the Info reader commands (@pxref{Top,,, info-stnd,
  1835. Stand-alone GNU Info}). The installation system runs the GPM mouse daemon,
  1836. which allows you to select text with the left mouse button and to paste it
  1837. with the middle button.
  1838. @quotation Note
  1839. Installation requires access to the Internet so that any missing
  1840. dependencies of your system configuration can be downloaded. See the
  1841. ``Networking'' section below.
  1842. @end quotation
  1843. @node Guided Graphical Installation
  1844. @section Guided Graphical Installation
  1845. The graphical installer is a text-based user interface. It will guide you,
  1846. with dialog boxes, through the steps needed to install GNU@tie{}Guix System.
  1847. The first dialog boxes allow you to set up the system as you use it during the
  1848. installation: you can choose the language, keyboard layout, and set up
  1849. networking, which will be used during the installation. The image below shows
  1850. the networking dialog.
  1851. @image{images/installer-network,5in,, networking setup with the graphical installer}
  1852. Later steps allow you to partition your hard disk, as shown in the image
  1853. below, to choose whether or not to use encrypted file systems, to enter the
  1854. host name and root password, and to create an additional account, among other
  1855. things.
  1856. @image{images/installer-partitions,5in,, partitioning with the graphical installer}
  1857. Note that, at any time, the installer allows you to exit the current
  1858. installation step and resume at a previous step, as show in the image below.
  1859. @image{images/installer-resume,5in,, resuming the installation process}
  1860. Once you're done, the installer produces an operating system configuration and
  1861. displays it (@pxref{Using the Configuration System}). At that point you can
  1862. hit ``OK'' and installation will proceed. On success, you can reboot into the
  1863. new system and enjoy. @xref{After System Installation}, for what's next!
  1864. @node Manual Installation
  1865. @section Manual Installation
  1866. This section describes how you would ``manually'' install GNU@tie{}Guix System
  1867. on your machine. This option requires familiarity with GNU/Linux, with the
  1868. shell, and with common administration tools. If you think this is not for
  1869. you, consider using the guided graphical installer (@pxref{Guided Graphical
  1870. Installation}).
  1871. The installation system provides root shells on TTYs 3 to 6; press
  1872. @kbd{ctrl-alt-f3}, @kbd{ctrl-alt-f4}, and so on to reach them. It includes
  1873. many common tools needed to install the system. But it is also a full-blown
  1874. Guix System, which means that you can install additional packages, should you
  1875. need it, using @command{guix package} (@pxref{Invoking guix package}).
  1876. @menu
  1877. * Keyboard Layout and Networking and Partitioning:: Initial setup.
  1878. * Proceeding with the Installation:: Installing.
  1879. @end menu
  1880. @node Keyboard Layout and Networking and Partitioning
  1881. @subsection Keyboard Layout, Networking, and Partitioning
  1882. Before you can install the system, you may want to adjust the keyboard layout,
  1883. set up networking, and partition your target hard disk. This section will
  1884. guide you through this.
  1885. @subsubsection Keyboard Layout
  1886. @cindex keyboard layout
  1887. The installation image uses the US qwerty keyboard layout. If you want
  1888. to change it, you can use the @command{loadkeys} command. For example,
  1889. the following command selects the Dvorak keyboard layout:
  1890. @example
  1891. loadkeys dvorak
  1892. @end example
  1893. See the files under @file{/run/current-system/profile/share/keymaps} for
  1894. a list of available keyboard layouts. Run @command{man loadkeys} for
  1895. more information.
  1896. @subsubsection Networking
  1897. Run the following command to see what your network interfaces are called:
  1898. @example
  1899. ifconfig -a
  1900. @end example
  1901. @noindent
  1902. @dots{} or, using the GNU/Linux-specific @command{ip} command:
  1903. @example
  1904. ip address
  1905. @end example
  1906. @c https://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-net_id.c#n20
  1907. Wired interfaces have a name starting with @samp{e}; for example, the
  1908. interface corresponding to the first on-board Ethernet controller is
  1909. called @samp{eno1}. Wireless interfaces have a name starting with
  1910. @samp{w}, like @samp{w1p2s0}.
  1911. @table @asis
  1912. @item Wired connection
  1913. To configure a wired network run the following command, substituting
  1914. @var{interface} with the name of the wired interface you want to use.
  1915. @example
  1916. ifconfig @var{interface} up
  1917. @end example
  1918. @noindent
  1919. @dots{} or, using the GNU/Linux-specific @command{ip} command:
  1920. @example
  1921. ip link set @var{interface} up
  1922. @end example
  1923. @item Wireless connection
  1924. @cindex wireless
  1925. @cindex WiFi
  1926. To configure wireless networking, you can create a configuration file
  1927. for the @command{wpa_supplicant} configuration tool (its location is not
  1928. important) using one of the available text editors such as
  1929. @command{nano}:
  1930. @example
  1931. nano wpa_supplicant.conf
  1932. @end example
  1933. As an example, the following stanza can go to this file and will work
  1934. for many wireless networks, provided you give the actual SSID and
  1935. passphrase for the network you are connecting to:
  1936. @example
  1937. network=@{
  1938. ssid="@var{my-ssid}"
  1939. key_mgmt=WPA-PSK
  1940. psk="the network's secret passphrase"
  1941. @}
  1942. @end example
  1943. Start the wireless service and run it in the background with the
  1944. following command (substitute @var{interface} with the name of the
  1945. network interface you want to use):
  1946. @example
  1947. wpa_supplicant -c wpa_supplicant.conf -i @var{interface} -B
  1948. @end example
  1949. Run @command{man wpa_supplicant} for more information.
  1950. @end table
  1951. @cindex DHCP
  1952. At this point, you need to acquire an IP address. On a network where IP
  1953. addresses are automatically assigned @i{via} DHCP, you can run:
  1954. @example
  1955. dhclient -v @var{interface}
  1956. @end example
  1957. Try to ping a server to see if networking is up and running:
  1958. @example
  1959. ping -c 3 gnu.org
  1960. @end example
  1961. Setting up network access is almost always a requirement because the
  1962. image does not contain all the software and tools that may be needed.
  1963. @cindex proxy, during system installation
  1964. If you need HTTP and HTTPS access to go through a proxy, run the
  1965. following command:
  1966. @example
  1967. herd set-http-proxy guix-daemon @var{URL}
  1968. @end example
  1969. @noindent
  1970. where @var{URL} is the proxy URL, for example
  1971. @code{http://example.org:8118}.
  1972. @cindex installing over SSH
  1973. If you want to, you can continue the installation remotely by starting
  1974. an SSH server:
  1975. @example
  1976. herd start ssh-daemon
  1977. @end example
  1978. Make sure to either set a password with @command{passwd}, or configure
  1979. OpenSSH public key authentication before logging in.
  1980. @subsubsection Disk Partitioning
  1981. Unless this has already been done, the next step is to partition, and
  1982. then format the target partition(s).
  1983. The installation image includes several partitioning tools, including
  1984. Parted (@pxref{Overview,,, parted, GNU Parted User Manual}),
  1985. @command{fdisk}, and @command{cfdisk}. Run it and set up your disk with
  1986. the partition layout you want:
  1987. @example
  1988. cfdisk
  1989. @end example
  1990. If your disk uses the GUID Partition Table (GPT) format and you plan to
  1991. install BIOS-based GRUB (which is the default), make sure a BIOS Boot
  1992. Partition is available (@pxref{BIOS installation,,, grub, GNU GRUB
  1993. manual}).
  1994. @cindex EFI, installation
  1995. @cindex UEFI, installation
  1996. @cindex ESP, EFI system partition
  1997. If you instead wish to use EFI-based GRUB, a FAT32 @dfn{EFI System Partition}
  1998. (ESP) is required. This partition can be mounted at @file{/boot/efi} for
  1999. instance and must have the @code{esp} flag set. E.g., for @command{parted}:
  2000. @example
  2001. parted /dev/sda set 1 esp on
  2002. @end example
  2003. @quotation Note
  2004. @vindex grub-bootloader
  2005. @vindex grub-efi-bootloader
  2006. Unsure whether to use EFI- or BIOS-based GRUB? If the directory
  2007. @file{/sys/firmware/efi} exists in the installation image, then you should
  2008. probably perform an EFI installation, using @code{grub-efi-bootloader}.
  2009. Otherwise you should use the BIOS-based GRUB, known as
  2010. @code{grub-bootloader}. @xref{Bootloader Configuration}, for more info on
  2011. bootloaders.
  2012. @end quotation
  2013. Once you are done partitioning the target hard disk drive, you have to
  2014. create a file system on the relevant partition(s)@footnote{Currently
  2015. Guix System only supports ext4, btrfs, JFS, F2FS, and XFS file systems. In
  2016. particular, code that reads file system UUIDs and labels only works for these
  2017. file system types.}. For the ESP, if you have one and assuming it is
  2018. @file{/dev/sda1}, run:
  2019. @example
  2020. mkfs.fat -F32 /dev/sda1
  2021. @end example
  2022. For the root file system, ext4 is the most widely used format. Other
  2023. file systems, such as Btrfs, support compression, which is reported to
  2024. nicely complement file deduplication that the daemon performs
  2025. independently of the file system (@pxref{Invoking guix-daemon,
  2026. deduplication}).
  2027. Preferably, assign file systems a label so that you can easily and
  2028. reliably refer to them in @code{file-system} declarations (@pxref{File
  2029. Systems}). This is typically done using the @code{-L} option of
  2030. @command{mkfs.ext4} and related commands. So, assuming the target root
  2031. partition lives at @file{/dev/sda2}, a file system with the label
  2032. @code{my-root} can be created with:
  2033. @example
  2034. mkfs.ext4 -L my-root /dev/sda2
  2035. @end example
  2036. @cindex encrypted disk
  2037. If you are instead planning to encrypt the root partition, you can use
  2038. the Cryptsetup/LUKS utilities to do that (see @inlinefmtifelse{html,
  2039. @uref{https://linux.die.net/man/8/cryptsetup, @code{man cryptsetup}},
  2040. @code{man cryptsetup}} for more information).
  2041. @quotation Warning
  2042. Note that GRUB can unlock LUKS2 devices since version 2.06, but only
  2043. supports the PBKDF2 key derivation function, which is not the default
  2044. for @command{cryptsetup luksFormat}. You can check which key derivation
  2045. function is being used by a device by running @command{cryptsetup
  2046. luksDump @var{device}}, and looking for the PBKDF field of your
  2047. keyslots.
  2048. @end quotation
  2049. Assuming you want to store the root partition on @file{/dev/sda2}, the
  2050. command sequence to format it as a LUKS2 partition would be along these
  2051. lines:
  2052. @example
  2053. cryptsetup luksFormat --type luks2 --pbkdf pbkdf2 /dev/sda2
  2054. cryptsetup open /dev/sda2 my-partition
  2055. mkfs.ext4 -L my-root /dev/mapper/my-partition
  2056. @end example
  2057. Once that is done, mount the target file system under @file{/mnt}
  2058. with a command like (again, assuming @code{my-root} is the label of the
  2059. root file system):
  2060. @example
  2061. mount LABEL=my-root /mnt
  2062. @end example
  2063. Also mount any other file systems you would like to use on the target
  2064. system relative to this path. If you have opted for @file{/boot/efi} as an
  2065. EFI mount point for example, mount it at @file{/mnt/boot/efi} now so it is
  2066. found by @code{guix system init} afterwards.
  2067. Finally, if you plan to use one or more swap partitions (@pxref{Swap
  2068. Space}), make sure to initialize them with @command{mkswap}. Assuming
  2069. you have one swap partition on @file{/dev/sda3}, you would run:
  2070. @example
  2071. mkswap /dev/sda3
  2072. swapon /dev/sda3
  2073. @end example
  2074. Alternatively, you may use a swap file. For example, assuming that in
  2075. the new system you want to use the file @file{/swapfile} as a swap file,
  2076. you would run@footnote{This example will work for many types of file
  2077. systems (e.g., ext4). However, for copy-on-write file systems (e.g.,
  2078. btrfs), the required steps may be different. For details, see the
  2079. manual pages for @command{mkswap} and @command{swapon}.}:
  2080. @example
  2081. # This is 10 GiB of swap space. Adjust "count" to change the size.
  2082. dd if=/dev/zero of=/mnt/swapfile bs=1MiB count=10240
  2083. # For security, make the file readable and writable only by root.
  2084. chmod 600 /mnt/swapfile
  2085. mkswap /mnt/swapfile
  2086. swapon /mnt/swapfile
  2087. @end example
  2088. Note that if you have encrypted the root partition and created a swap
  2089. file in its file system as described above, then the encryption also
  2090. protects the swap file, just like any other file in that file system.
  2091. @node Proceeding with the Installation
  2092. @subsection Proceeding with the Installation
  2093. With the target partitions ready and the target root mounted on
  2094. @file{/mnt}, we're ready to go. First, run:
  2095. @example
  2096. herd start cow-store /mnt
  2097. @end example
  2098. This makes @file{/gnu/store} copy-on-write, such that packages added to it
  2099. during the installation phase are written to the target disk on @file{/mnt}
  2100. rather than kept in memory. This is necessary because the first phase of
  2101. the @command{guix system init} command (see below) entails downloads or
  2102. builds to @file{/gnu/store} which, initially, is an in-memory file system.
  2103. Next, you have to edit a file and
  2104. provide the declaration of the operating system to be installed. To
  2105. that end, the installation system comes with three text editors. We
  2106. recommend GNU nano (@pxref{Top,,, nano, GNU nano Manual}), which
  2107. supports syntax highlighting and parentheses matching; other editors
  2108. include mg (an Emacs clone), and
  2109. nvi (a clone of the original BSD @command{vi} editor).
  2110. We strongly recommend storing that file on the target root file system, say,
  2111. as @file{/mnt/etc/config.scm}. Failing to do that, you will have lost your
  2112. configuration file once you have rebooted into the newly-installed system.
  2113. @xref{Using the Configuration System}, for an overview of the
  2114. configuration file. The example configurations discussed in that
  2115. section are available under @file{/etc/configuration} in the
  2116. installation image. Thus, to get started with a system configuration
  2117. providing a graphical display server (a ``desktop'' system), you can run
  2118. something along these lines:
  2119. @example
  2120. # mkdir /mnt/etc
  2121. # cp /etc/configuration/desktop.scm /mnt/etc/config.scm
  2122. # nano /mnt/etc/config.scm
  2123. @end example
  2124. You should pay attention to what your configuration file contains, and
  2125. in particular:
  2126. @itemize
  2127. @item
  2128. Make sure the @code{bootloader-configuration} form refers to the targets
  2129. you want to install GRUB on. It should mention @code{grub-bootloader}
  2130. if you are installing GRUB in the legacy way, or
  2131. @code{grub-efi-bootloader} for newer UEFI systems. For legacy systems,
  2132. the @code{targets} field contain the names of the devices, like
  2133. @code{(list "/dev/sda")}; for UEFI systems it names the paths to mounted
  2134. EFI partitions, like @code{(list "/boot/efi")}; do make sure the paths
  2135. are currently mounted and a @code{file-system} entry is specified in
  2136. your configuration.
  2137. @item
  2138. Be sure that your file system labels match the value of their respective
  2139. @code{device} fields in your @code{file-system} configuration, assuming
  2140. your @code{file-system} configuration uses the @code{file-system-label}
  2141. procedure in its @code{device} field.
  2142. @item
  2143. If there are encrypted or RAID partitions, make sure to add a
  2144. @code{mapped-devices} field to describe them (@pxref{Mapped Devices}).
  2145. @end itemize
  2146. Once you are done preparing the configuration file, the new system must
  2147. be initialized (remember that the target root file system is mounted
  2148. under @file{/mnt}):
  2149. @example
  2150. guix system init /mnt/etc/config.scm /mnt
  2151. @end example
  2152. @noindent
  2153. This copies all the necessary files and installs GRUB on
  2154. @file{/dev/sdX}, unless you pass the @option{--no-bootloader} option. For
  2155. more information, @pxref{Invoking guix system}. This command may trigger
  2156. downloads or builds of missing packages, which can take some time.
  2157. Once that command has completed---and hopefully succeeded!---you can run
  2158. @command{reboot} and boot into the new system. The @code{root} password
  2159. in the new system is initially empty; other users' passwords need to be
  2160. initialized by running the @command{passwd} command as @code{root},
  2161. unless your configuration specifies otherwise
  2162. (@pxref{user-account-password, user account passwords}).
  2163. @xref{After System Installation}, for what's next!
  2164. @node After System Installation
  2165. @section After System Installation
  2166. Success, you've now booted into Guix System! From then on, you can update the
  2167. system whenever you want by running, say:
  2168. @example
  2169. guix pull
  2170. sudo guix system reconfigure /etc/config.scm
  2171. @end example
  2172. @noindent
  2173. This builds a new system generation with the latest packages and services
  2174. (@pxref{Invoking guix system}). We recommend doing that regularly so that
  2175. your system includes the latest security updates (@pxref{Security Updates}).
  2176. @c See <https://lists.gnu.org/archive/html/guix-devel/2019-01/msg00268.html>.
  2177. @quotation Note
  2178. @cindex sudo vs. @command{guix pull}
  2179. Note that @command{sudo guix} runs your user's @command{guix} command and
  2180. @emph{not} root's, because @command{sudo} leaves @env{PATH} unchanged. To
  2181. explicitly run root's @command{guix}, type @command{sudo -i guix @dots{}}.
  2182. The difference matters here, because @command{guix pull} updates
  2183. the @command{guix} command and package definitions only for the user it is run
  2184. as. This means that if you choose to use @command{guix system reconfigure} in
  2185. root's login shell, you'll need to @command{guix pull} separately.
  2186. @end quotation
  2187. Now, @pxref{Getting Started}, and
  2188. join us on @code{#guix} on the Libera Chat IRC network or on
  2189. @email{guix-devel@@gnu.org} to share your experience!
  2190. @node Installing Guix in a VM
  2191. @section Installing Guix in a Virtual Machine
  2192. @cindex virtual machine, Guix System installation
  2193. @cindex virtual private server (VPS)
  2194. @cindex VPS (virtual private server)
  2195. If you'd like to install Guix System in a virtual machine (VM) or on a
  2196. virtual private server (VPS) rather than on your beloved machine, this
  2197. section is for you.
  2198. To boot a @uref{https://qemu.org/,QEMU} VM for installing Guix System in a
  2199. disk image, follow these steps:
  2200. @enumerate
  2201. @item
  2202. First, retrieve and decompress the Guix system installation image as
  2203. described previously (@pxref{USB Stick and DVD Installation}).
  2204. @item
  2205. Create a disk image that will hold the installed system. To make a
  2206. qcow2-formatted disk image, use the @command{qemu-img} command:
  2207. @example
  2208. qemu-img create -f qcow2 guix-system.img 50G
  2209. @end example
  2210. The resulting file will be much smaller than 50 GB (typically less than
  2211. 1 MB), but it will grow as the virtualized storage device is filled up.
  2212. @item
  2213. Boot the USB installation image in an VM:
  2214. @example
  2215. qemu-system-x86_64 -m 1024 -smp 1 -enable-kvm \
  2216. -nic user,model=virtio-net-pci -boot menu=on,order=d \
  2217. -drive file=guix-system.img \
  2218. -drive media=cdrom,file=guix-system-install-@value{VERSION}.@var{system}.iso
  2219. @end example
  2220. @code{-enable-kvm} is optional, but significantly improves performance,
  2221. @pxref{Running Guix in a VM}.
  2222. @item
  2223. You're now root in the VM, proceed with the installation process.
  2224. @xref{Preparing for Installation}, and follow the instructions.
  2225. @end enumerate
  2226. Once installation is complete, you can boot the system that's on your
  2227. @file{guix-system.img} image. @xref{Running Guix in a VM}, for how to do
  2228. that.
  2229. @node Building the Installation Image
  2230. @section Building the Installation Image
  2231. @cindex installation image
  2232. The installation image described above was built using the @command{guix
  2233. system} command, specifically:
  2234. @example
  2235. guix system image -t iso9660 gnu/system/install.scm
  2236. @end example
  2237. Have a look at @file{gnu/system/install.scm} in the source tree,
  2238. and see also @ref{Invoking guix system} for more information
  2239. about the installation image.
  2240. @section Building the Installation Image for ARM Boards
  2241. Many ARM boards require a specific variant of the
  2242. @uref{https://www.denx.de/wiki/U-Boot/, U-Boot} bootloader.
  2243. If you build a disk image and the bootloader is not available otherwise
  2244. (on another boot drive etc), it's advisable to build an image that
  2245. includes the bootloader, specifically:
  2246. @example
  2247. guix system image --system=armhf-linux -e '((@@ (gnu system install) os-with-u-boot) (@@ (gnu system install) installation-os) "A20-OLinuXino-Lime2")'
  2248. @end example
  2249. @code{A20-OLinuXino-Lime2} is the name of the board. If you specify an invalid
  2250. board, a list of possible boards will be printed.
  2251. @c *********************************************************************
  2252. @node Getting Started
  2253. @chapter Getting Started
  2254. Presumably, you've reached this section because either you have
  2255. installed Guix on top of another distribution (@pxref{Installation}), or
  2256. you've installed the standalone Guix System (@pxref{System
  2257. Installation}). It's time for you to get started using Guix and this
  2258. section aims to help you do that and give you a feel of what it's like.
  2259. Guix is about installing software, so probably the first thing you'll
  2260. want to do is to actually look for software. Let's say you're looking
  2261. for a text editor, you can run:
  2262. @example
  2263. guix search text editor
  2264. @end example
  2265. This command shows you a number of matching @dfn{packages}, each time
  2266. showing the package's name, version, a description, and additional info.
  2267. Once you've found out the one you want to use, let's say Emacs (ah ha!),
  2268. you can go ahead and install it (run this command as a regular user,
  2269. @emph{no need for root privileges}!):
  2270. @example
  2271. guix install emacs
  2272. @end example
  2273. @cindex profile
  2274. You've installed your first package, congrats! The package is now
  2275. visible in your default @dfn{profile}, @file{$HOME/.guix-profile}---a
  2276. profile is a directory containing installed packages.
  2277. In the process, you've
  2278. probably noticed that Guix downloaded pre-built binaries; or, if you
  2279. explicitly chose to @emph{not} use pre-built binaries, then probably
  2280. Guix is still building software (@pxref{Substitutes}, for more info).
  2281. Unless you're using Guix System, the @command{guix install} command must
  2282. have printed this hint:
  2283. @example
  2284. hint: Consider setting the necessary environment variables by running:
  2285. GUIX_PROFILE="$HOME/.guix-profile"
  2286. . "$GUIX_PROFILE/etc/profile"
  2287. Alternately, see `guix package --search-paths -p "$HOME/.guix-profile"'.
  2288. @end example
  2289. Indeed, you must now tell your shell where @command{emacs} and other
  2290. programs installed with Guix are to be found. Pasting the two lines
  2291. above will do just that: it will add
  2292. @code{$HOME/.guix-profile/bin}---which is where the installed package
  2293. is---to the @code{PATH} environment variable. You can paste these two
  2294. lines in your shell so they take effect right away, but more importantly
  2295. you should add them to @file{~/.bash_profile} (or equivalent file if you
  2296. do not use Bash) so that environment variables are set next time you
  2297. spawn a shell. You only need to do this once and other search paths
  2298. environment variables will be taken care of similarly---e.g., if you
  2299. eventually install @code{python} and Python libraries,
  2300. @env{GUIX_PYTHONPATH} will be defined.
  2301. You can go on installing packages at your will. To list installed
  2302. packages, run:
  2303. @example
  2304. guix package --list-installed
  2305. @end example
  2306. To remove a package, you would unsurprisingly run @command{guix remove}.
  2307. A distinguishing feature is the ability to @dfn{roll back} any operation
  2308. you made---installation, removal, upgrade---by simply typing:
  2309. @example
  2310. guix package --roll-back
  2311. @end example
  2312. This is because each operation is in fact a @dfn{transaction} that
  2313. creates a new @dfn{generation}. These generations and the difference
  2314. between them can be displayed by running:
  2315. @example
  2316. guix package --list-generations
  2317. @end example
  2318. Now you know the basics of package management!
  2319. @quotation Going further
  2320. @xref{Package Management}, for more about package management. You may
  2321. like @dfn{declarative} package management with @command{guix package
  2322. --manifest}, managing separate @dfn{profiles} with @option{--profile},
  2323. deleting old generations, collecting garbage, and other nifty features
  2324. that will come in handy as you become more familiar with Guix. If you
  2325. are a developer, @pxref{Development} for additional tools. And if
  2326. you're curious, @pxref{Features}, to peek under the hood.
  2327. @end quotation
  2328. Once you've installed a set of packages, you will want to periodically
  2329. @emph{upgrade} them to the latest and greatest version. To do that, you
  2330. will first pull the latest revision of Guix and its package collection:
  2331. @example
  2332. guix pull
  2333. @end example
  2334. The end result is a new @command{guix} command, under
  2335. @file{~/.config/guix/current/bin}. Unless you're on Guix System, the
  2336. first time you run @command{guix pull}, be sure to follow the hint that
  2337. the command prints and, similar to what we saw above, paste these two
  2338. lines in your terminal and @file{.bash_profile}:
  2339. @example
  2340. GUIX_PROFILE="$HOME/.config/guix/current"
  2341. . "$GUIX_PROFILE/etc/profile"
  2342. @end example
  2343. @noindent
  2344. You must also instruct your shell to point to this new @command{guix}:
  2345. @example
  2346. hash guix
  2347. @end example
  2348. At this point, you're running a brand new Guix. You can thus go ahead
  2349. and actually upgrade all the packages you previously installed:
  2350. @example
  2351. guix upgrade
  2352. @end example
  2353. As you run this command, you will see that binaries are downloaded (or
  2354. perhaps some packages are built), and eventually you end up with the
  2355. upgraded packages. Should one of these upgraded packages not be to your
  2356. liking, remember you can always roll back!
  2357. You can display the exact revision of Guix you're currently using by
  2358. running:
  2359. @example
  2360. guix describe
  2361. @end example
  2362. The information it displays is @emph{all it takes to reproduce the exact
  2363. same Guix}, be it at a different point in time or on a different
  2364. machine.
  2365. @quotation Going further
  2366. @xref{Invoking guix pull}, for more information. @xref{Channels}, on
  2367. how to specify additional @dfn{channels} to pull packages from, how to
  2368. replicate Guix, and more. You may also find @command{time-machine}
  2369. handy (@pxref{Invoking guix time-machine}).
  2370. @end quotation
  2371. If you installed Guix System, one of the first things you'll want to do
  2372. is to upgrade your system. Once you've run @command{guix pull} to get
  2373. the latest Guix, you can upgrade the system like this:
  2374. @example
  2375. sudo guix system reconfigure /etc/config.scm
  2376. @end example
  2377. Upon completion, the system runs the latest versions of its software
  2378. packages. When you eventually reboot, you'll notice a sub-menu in the
  2379. bootloader that reads ``Old system generations'': it's what allows you
  2380. to boot @emph{an older generation of your system}, should the latest
  2381. generation be ``broken'' or otherwise unsatisfying. Just like for
  2382. packages, you can always @emph{roll back} to a previous generation
  2383. @emph{of the whole system}:
  2384. @example
  2385. sudo guix system roll-back
  2386. @end example
  2387. There are many things you'll probably want to tweak on your system:
  2388. adding new user accounts, adding new system services, fiddling with the
  2389. configuration of those services, etc. The system configuration is
  2390. @emph{entirely} described in the @file{/etc/config.scm} file.
  2391. @xref{Using the Configuration System}, to learn how to change it.
  2392. Now you know enough to get started!
  2393. @quotation Resources
  2394. The rest of this manual provides a reference for all things Guix. Here
  2395. are some additional resources you may find useful:
  2396. @itemize
  2397. @item
  2398. @xref{Top,,, guix-cookbook, The GNU Guix Cookbook}, for a list of
  2399. ``how-to'' style of recipes for a variety of applications.
  2400. @item
  2401. The @uref{https://guix.gnu.org/guix-refcard.pdf, GNU Guix Reference
  2402. Card} lists in two pages most of the commands and options you'll ever
  2403. need.
  2404. @item
  2405. The web site contains @uref{https://guix.gnu.org/en/videos/,
  2406. instructional videos} covering topics such as everyday use of Guix, how
  2407. to get help, and how to become a contributor.
  2408. @item
  2409. @xref{Documentation}, to learn how to access documentation on your
  2410. computer.
  2411. @end itemize
  2412. We hope you will enjoy Guix as much as the community enjoys building it!
  2413. @end quotation
  2414. @c *********************************************************************
  2415. @node Package Management
  2416. @chapter Package Management
  2417. @cindex packages
  2418. The purpose of GNU Guix is to allow users to easily install, upgrade, and
  2419. remove software packages, without having to know about their build
  2420. procedures or dependencies. Guix also goes beyond this obvious set of
  2421. features.
  2422. This chapter describes the main features of Guix, as well as the
  2423. package management tools it provides. Along with the command-line
  2424. interface described below (@pxref{Invoking guix package, @code{guix
  2425. package}}), you may also use the Emacs-Guix interface (@pxref{Top,,,
  2426. emacs-guix, The Emacs-Guix Reference Manual}), after installing
  2427. @code{emacs-guix} package (run @kbd{M-x guix-help} command to start
  2428. with it):
  2429. @example
  2430. guix install emacs-guix
  2431. @end example
  2432. @menu
  2433. * Features:: How Guix will make your life brighter.
  2434. * Invoking guix package:: Package installation, removal, etc.
  2435. * Substitutes:: Downloading pre-built binaries.
  2436. * Packages with Multiple Outputs:: Single source package, multiple outputs.
  2437. * Invoking guix gc:: Running the garbage collector.
  2438. * Invoking guix pull:: Fetching the latest Guix and distribution.
  2439. * Invoking guix time-machine:: Running an older revision of Guix.
  2440. * Inferiors:: Interacting with another revision of Guix.
  2441. * Invoking guix describe:: Display information about your Guix revision.
  2442. * Invoking guix archive:: Exporting and importing store files.
  2443. @end menu
  2444. @node Features
  2445. @section Features
  2446. Here we assume you've already made your first steps with Guix
  2447. (@pxref{Getting Started}) and would like to get an overview about what's
  2448. going on under the hood.
  2449. When using Guix, each package ends up in the @dfn{package store}, in its
  2450. own directory---something that resembles
  2451. @file{/gnu/store/xxx-package-1.2}, where @code{xxx} is a base32 string.
  2452. Instead of referring to these directories, users have their own
  2453. @dfn{profile}, which points to the packages that they actually want to
  2454. use. These profiles are stored within each user's home directory, at
  2455. @code{$HOME/.guix-profile}.
  2456. For example, @code{alice} installs GCC 4.7.2. As a result,
  2457. @file{/home/alice/.guix-profile/bin/gcc} points to
  2458. @file{/gnu/store/@dots{}-gcc-4.7.2/bin/gcc}. Now, on the same machine,
  2459. @code{bob} had already installed GCC 4.8.0. The profile of @code{bob}
  2460. simply continues to point to
  2461. @file{/gnu/store/@dots{}-gcc-4.8.0/bin/gcc}---i.e., both versions of GCC
  2462. coexist on the same system without any interference.
  2463. The @command{guix package} command is the central tool to manage
  2464. packages (@pxref{Invoking guix package}). It operates on the per-user
  2465. profiles, and can be used @emph{with normal user privileges}.
  2466. @cindex transactions
  2467. The command provides the obvious install, remove, and upgrade
  2468. operations. Each invocation is actually a @emph{transaction}: either
  2469. the specified operation succeeds, or nothing happens. Thus, if the
  2470. @command{guix package} process is terminated during the transaction,
  2471. or if a power outage occurs during the transaction, then the user's
  2472. profile remains in its previous state, and remains usable.
  2473. In addition, any package transaction may be @emph{rolled back}. So, if,
  2474. for example, an upgrade installs a new version of a package that turns
  2475. out to have a serious bug, users may roll back to the previous instance
  2476. of their profile, which was known to work well. Similarly, the global
  2477. system configuration on Guix is subject to
  2478. transactional upgrades and roll-back
  2479. (@pxref{Using the Configuration System}).
  2480. All packages in the package store may be @emph{garbage-collected}.
  2481. Guix can determine which packages are still referenced by user
  2482. profiles, and remove those that are provably no longer referenced
  2483. (@pxref{Invoking guix gc}). Users may also explicitly remove old
  2484. generations of their profile so that the packages they refer to can be
  2485. collected.
  2486. @cindex reproducibility
  2487. @cindex reproducible builds
  2488. Guix takes a @dfn{purely functional} approach to package
  2489. management, as described in the introduction (@pxref{Introduction}).
  2490. Each @file{/gnu/store} package directory name contains a hash of all the
  2491. inputs that were used to build that package---compiler, libraries, build
  2492. scripts, etc. This direct correspondence allows users to make sure a
  2493. given package installation matches the current state of their
  2494. distribution. It also helps maximize @dfn{build reproducibility}:
  2495. thanks to the isolated build environments that are used, a given build
  2496. is likely to yield bit-identical files when performed on different
  2497. machines (@pxref{Invoking guix-daemon, container}).
  2498. @cindex substitutes
  2499. This foundation allows Guix to support @dfn{transparent binary/source
  2500. deployment}. When a pre-built binary for a @file{/gnu/store} item is
  2501. available from an external source---a @dfn{substitute}, Guix just
  2502. downloads it and unpacks it;
  2503. otherwise, it builds the package from source, locally
  2504. (@pxref{Substitutes}). Because build results are usually bit-for-bit
  2505. reproducible, users do not have to trust servers that provide
  2506. substitutes: they can force a local build and @emph{challenge} providers
  2507. (@pxref{Invoking guix challenge}).
  2508. Control over the build environment is a feature that is also useful for
  2509. developers. The @command{guix shell} command allows developers of
  2510. a package to quickly set up the right development environment for their
  2511. package, without having to manually install the dependencies of the
  2512. package into their profile (@pxref{Invoking guix shell}).
  2513. @cindex replication, of software environments
  2514. @cindex provenance tracking, of software artifacts
  2515. All of Guix and its package definitions is version-controlled, and
  2516. @command{guix pull} allows you to ``travel in time'' on the history of Guix
  2517. itself (@pxref{Invoking guix pull}). This makes it possible to replicate a
  2518. Guix instance on a different machine or at a later point in time, which in
  2519. turn allows you to @emph{replicate complete software environments}, while
  2520. retaining precise @dfn{provenance tracking} of the software.
  2521. @node Invoking guix package
  2522. @section Invoking @command{guix package}
  2523. @cindex installing packages
  2524. @cindex removing packages
  2525. @cindex package installation
  2526. @cindex package removal
  2527. @cindex profile
  2528. The @command{guix package} command is the tool that allows users to
  2529. install, upgrade, and remove packages, as well as rolling back to
  2530. previous configurations. These operations work on a user
  2531. @dfn{profile}---a directory of installed packages. Each user has a
  2532. default profile in @file{$HOME/.guix-profile}.
  2533. The command operates only on the user's own profile,
  2534. and works with normal user privileges (@pxref{Features}). Its syntax
  2535. is:
  2536. @example
  2537. guix package @var{options}
  2538. @end example
  2539. @cindex transactions
  2540. Primarily, @var{options} specifies the operations to be performed during
  2541. the transaction. Upon completion, a new profile is created, but
  2542. previous @dfn{generations} of the profile remain available, should the user
  2543. want to roll back.
  2544. For example, to remove @code{lua} and install @code{guile} and
  2545. @code{guile-cairo} in a single transaction:
  2546. @example
  2547. guix package -r lua -i guile guile-cairo
  2548. @end example
  2549. @cindex aliases, for @command{guix package}
  2550. For your convenience, we also provide the following aliases:
  2551. @itemize
  2552. @item
  2553. @command{guix search} is an alias for @command{guix package -s},
  2554. @item
  2555. @command{guix install} is an alias for @command{guix package -i},
  2556. @item
  2557. @command{guix remove} is an alias for @command{guix package -r},
  2558. @item
  2559. @command{guix upgrade} is an alias for @command{guix package -u},
  2560. @item
  2561. and @command{guix show} is an alias for @command{guix package --show=}.
  2562. @end itemize
  2563. These aliases are less expressive than @command{guix package} and provide
  2564. fewer options, so in some cases you'll probably want to use @command{guix
  2565. package} directly.
  2566. @command{guix package} also supports a @dfn{declarative approach}
  2567. whereby the user specifies the exact set of packages to be available and
  2568. passes it @i{via} the @option{--manifest} option
  2569. (@pxref{profile-manifest, @option{--manifest}}).
  2570. @cindex profile
  2571. For each user, a symlink to the user's default profile is automatically
  2572. created in @file{$HOME/.guix-profile}. This symlink always points to the
  2573. current generation of the user's default profile. Thus, users can add
  2574. @file{$HOME/.guix-profile/bin} to their @env{PATH} environment
  2575. variable, and so on.
  2576. @cindex search paths
  2577. If you are not using Guix System, consider adding the
  2578. following lines to your @file{~/.bash_profile} (@pxref{Bash Startup
  2579. Files,,, bash, The GNU Bash Reference Manual}) so that newly-spawned
  2580. shells get all the right environment variable definitions:
  2581. @example
  2582. GUIX_PROFILE="$HOME/.guix-profile" ; \
  2583. source "$GUIX_PROFILE/etc/profile"
  2584. @end example
  2585. In a multi-user setup, user profiles are stored in a place registered as
  2586. a @dfn{garbage-collector root}, which @file{$HOME/.guix-profile} points
  2587. to (@pxref{Invoking guix gc}). That directory is normally
  2588. @code{@var{localstatedir}/guix/profiles/per-user/@var{user}}, where
  2589. @var{localstatedir} is the value passed to @code{configure} as
  2590. @option{--localstatedir}, and @var{user} is the user name. The
  2591. @file{per-user} directory is created when @command{guix-daemon} is
  2592. started, and the @var{user} sub-directory is created by @command{guix
  2593. package}.
  2594. The @var{options} can be among the following:
  2595. @table @code
  2596. @item --install=@var{package} @dots{}
  2597. @itemx -i @var{package} @dots{}
  2598. Install the specified @var{package}s.
  2599. Each @var{package} may specify either a simple package name, such as
  2600. @code{guile}, or a package name followed by an at-sign and version number,
  2601. such as @code{guile@@1.8.8} or simply @code{guile@@1.8} (in the latter
  2602. case, the newest version prefixed by @code{1.8} is selected).
  2603. If no version number is specified, the
  2604. newest available version will be selected. In addition, @var{package}
  2605. may contain a colon, followed by the name of one of the outputs of the
  2606. package, as in @code{gcc:doc} or @code{binutils@@2.22:lib}
  2607. (@pxref{Packages with Multiple Outputs}). Packages with a corresponding
  2608. name (and optionally version) are searched for among the GNU
  2609. distribution modules (@pxref{Package Modules}).
  2610. @cindex propagated inputs
  2611. Sometimes packages have @dfn{propagated inputs}: these are dependencies
  2612. that automatically get installed along with the required package
  2613. (@pxref{package-propagated-inputs, @code{propagated-inputs} in
  2614. @code{package} objects}, for information about propagated inputs in
  2615. package definitions).
  2616. @anchor{package-cmd-propagated-inputs}
  2617. An example is the GNU MPC library: its C header files refer to those of
  2618. the GNU MPFR library, which in turn refer to those of the GMP library.
  2619. Thus, when installing MPC, the MPFR and GMP libraries also get installed
  2620. in the profile; removing MPC also removes MPFR and GMP---unless they had
  2621. also been explicitly installed by the user.
  2622. Besides, packages sometimes rely on the definition of environment
  2623. variables for their search paths (see explanation of
  2624. @option{--search-paths} below). Any missing or possibly incorrect
  2625. environment variable definitions are reported here.
  2626. @item --install-from-expression=@var{exp}
  2627. @itemx -e @var{exp}
  2628. Install the package @var{exp} evaluates to.
  2629. @var{exp} must be a Scheme expression that evaluates to a
  2630. @code{<package>} object. This option is notably useful to disambiguate
  2631. between same-named variants of a package, with expressions such as
  2632. @code{(@@ (gnu packages base) guile-final)}.
  2633. Note that this option installs the first output of the specified
  2634. package, which may be insufficient when needing a specific output of a
  2635. multiple-output package.
  2636. @item --install-from-file=@var{file}
  2637. @itemx -f @var{file}
  2638. Install the package that the code within @var{file} evaluates to.
  2639. As an example, @var{file} might contain a definition like this
  2640. (@pxref{Defining Packages}):
  2641. @lisp
  2642. @include package-hello.scm
  2643. @end lisp
  2644. Developers may find it useful to include such a @file{guix.scm} file
  2645. in the root of their project source tree that can be used to test
  2646. development snapshots and create reproducible development environments
  2647. (@pxref{Invoking guix shell}).
  2648. The @var{file} may also contain a JSON representation of one or more
  2649. package definitions. Running @code{guix package -f} on
  2650. @file{hello.json} with the following contents would result in installing
  2651. the package @code{greeter} after building @code{myhello}:
  2652. @example
  2653. @verbatiminclude package-hello.json
  2654. @end example
  2655. @item --remove=@var{package} @dots{}
  2656. @itemx -r @var{package} @dots{}
  2657. Remove the specified @var{package}s.
  2658. As for @option{--install}, each @var{package} may specify a version number
  2659. and/or output name in addition to the package name. For instance,
  2660. @samp{-r glibc:debug} would remove the @code{debug} output of
  2661. @code{glibc}.
  2662. @item --upgrade[=@var{regexp} @dots{}]
  2663. @itemx -u [@var{regexp} @dots{}]
  2664. @cindex upgrading packages
  2665. Upgrade all the installed packages. If one or more @var{regexp}s are
  2666. specified, upgrade only installed packages whose name matches a
  2667. @var{regexp}. Also see the @option{--do-not-upgrade} option below.
  2668. Note that this upgrades package to the latest version of packages found
  2669. in the distribution currently installed. To update your distribution,
  2670. you should regularly run @command{guix pull} (@pxref{Invoking guix
  2671. pull}).
  2672. @cindex package transformations, upgrades
  2673. When upgrading, package transformations that were originally applied
  2674. when creating the profile are automatically re-applied (@pxref{Package
  2675. Transformation Options}). For example, assume you first installed Emacs
  2676. from the tip of its development branch with:
  2677. @example
  2678. guix install emacs-next --with-branch=emacs-next=master
  2679. @end example
  2680. Next time you run @command{guix upgrade}, Guix will again pull the tip
  2681. of the Emacs development branch and build @code{emacs-next} from that
  2682. checkout.
  2683. Note that transformation options such as @option{--with-branch} and
  2684. @option{--with-source} depend on external state; it is up to you to
  2685. ensure that they work as expected. You can also discard a
  2686. transformations that apply to a package by running:
  2687. @example
  2688. guix install @var{package}
  2689. @end example
  2690. @item --do-not-upgrade[=@var{regexp} @dots{}]
  2691. When used together with the @option{--upgrade} option, do @emph{not}
  2692. upgrade any packages whose name matches a @var{regexp}. For example, to
  2693. upgrade all packages in the current profile except those containing the
  2694. substring ``emacs'':
  2695. @example
  2696. $ guix package --upgrade . --do-not-upgrade emacs
  2697. @end example
  2698. @item @anchor{profile-manifest}--manifest=@var{file}
  2699. @itemx -m @var{file}
  2700. @cindex profile declaration
  2701. @cindex profile manifest
  2702. Create a new generation of the profile from the manifest object
  2703. returned by the Scheme code in @var{file}. This option can be repeated
  2704. several times, in which case the manifests are concatenated.
  2705. This allows you to @emph{declare} the profile's contents rather than
  2706. constructing it through a sequence of @option{--install} and similar
  2707. commands. The advantage is that @var{file} can be put under version
  2708. control, copied to different machines to reproduce the same profile, and
  2709. so on.
  2710. @c FIXME: Add reference to (guix profile) documentation when available.
  2711. @var{file} must return a @dfn{manifest} object, which is roughly a list
  2712. of packages:
  2713. @findex packages->manifest
  2714. @lisp
  2715. (use-package-modules guile emacs)
  2716. (packages->manifest
  2717. (list emacs
  2718. guile-2.0
  2719. ;; Use a specific package output.
  2720. (list guile-2.0 "debug")))
  2721. @end lisp
  2722. @findex specifications->manifest
  2723. In this example we have to know which modules define the @code{emacs}
  2724. and @code{guile-2.0} variables to provide the right
  2725. @code{use-package-modules} line, which can be cumbersome. We can
  2726. instead provide regular package specifications and let
  2727. @code{specifications->manifest} look up the corresponding package
  2728. objects, like this:
  2729. @lisp
  2730. (specifications->manifest
  2731. '("emacs" "guile@@2.2" "guile@@2.2:debug"))
  2732. @end lisp
  2733. @findex package->development-manifest
  2734. You might also want to create a manifest for all the dependencies of a
  2735. package, rather than the package itself:
  2736. @lisp
  2737. (package->development-manifest (specification->package "emacs"))
  2738. @end lisp
  2739. The example above gives you all the software required to develop Emacs,
  2740. similar to what @command{guix environment emacs} provides.
  2741. @xref{export-manifest, @option{--export-manifest}}, to learn how to
  2742. obtain a manifest file from an existing profile.
  2743. @item --roll-back
  2744. @cindex rolling back
  2745. @cindex undoing transactions
  2746. @cindex transactions, undoing
  2747. Roll back to the previous @dfn{generation} of the profile---i.e., undo
  2748. the last transaction.
  2749. When combined with options such as @option{--install}, roll back occurs
  2750. before any other actions.
  2751. When rolling back from the first generation that actually contains
  2752. installed packages, the profile is made to point to the @dfn{zeroth
  2753. generation}, which contains no files apart from its own metadata.
  2754. After having rolled back, installing, removing, or upgrading packages
  2755. overwrites previous future generations. Thus, the history of the
  2756. generations in a profile is always linear.
  2757. @item --switch-generation=@var{pattern}
  2758. @itemx -S @var{pattern}
  2759. @cindex generations
  2760. Switch to a particular generation defined by @var{pattern}.
  2761. @var{pattern} may be either a generation number or a number prefixed
  2762. with ``+'' or ``-''. The latter means: move forward/backward by a
  2763. specified number of generations. For example, if you want to return to
  2764. the latest generation after @option{--roll-back}, use
  2765. @option{--switch-generation=+1}.
  2766. The difference between @option{--roll-back} and
  2767. @option{--switch-generation=-1} is that @option{--switch-generation} will
  2768. not make a zeroth generation, so if a specified generation does not
  2769. exist, the current generation will not be changed.
  2770. @item --search-paths[=@var{kind}]
  2771. @cindex search paths
  2772. Report environment variable definitions, in Bash syntax, that may be
  2773. needed in order to use the set of installed packages. These environment
  2774. variables are used to specify @dfn{search paths} for files used by some
  2775. of the installed packages.
  2776. For example, GCC needs the @env{CPATH} and @env{LIBRARY_PATH}
  2777. environment variables to be defined so it can look for headers and
  2778. libraries in the user's profile (@pxref{Environment Variables,,, gcc,
  2779. Using the GNU Compiler Collection (GCC)}). If GCC and, say, the C
  2780. library are installed in the profile, then @option{--search-paths} will
  2781. suggest setting these variables to @file{@var{profile}/include} and
  2782. @file{@var{profile}/lib}, respectively (@pxref{Search Paths}, for info
  2783. on search path specifications associated with packages.)
  2784. The typical use case is to define these environment variables in the
  2785. shell:
  2786. @example
  2787. $ eval `guix package --search-paths`
  2788. @end example
  2789. @var{kind} may be one of @code{exact}, @code{prefix}, or @code{suffix},
  2790. meaning that the returned environment variable definitions will either
  2791. be exact settings, or prefixes or suffixes of the current value of these
  2792. variables. When omitted, @var{kind} defaults to @code{exact}.
  2793. This option can also be used to compute the @emph{combined} search paths
  2794. of several profiles. Consider this example:
  2795. @example
  2796. $ guix package -p foo -i guile
  2797. $ guix package -p bar -i guile-json
  2798. $ guix package -p foo -p bar --search-paths
  2799. @end example
  2800. The last command above reports about the @env{GUILE_LOAD_PATH}
  2801. variable, even though, taken individually, neither @file{foo} nor
  2802. @file{bar} would lead to that recommendation.
  2803. @cindex profile, choosing
  2804. @item --profile=@var{profile}
  2805. @itemx -p @var{profile}
  2806. Use @var{profile} instead of the user's default profile.
  2807. @var{profile} must be the name of a file that will be created upon
  2808. completion. Concretely, @var{profile} will be a mere symbolic link
  2809. (``symlink'') pointing to the actual profile where packages are
  2810. installed:
  2811. @example
  2812. $ guix install hello -p ~/code/my-profile
  2813. @dots{}
  2814. $ ~/code/my-profile/bin/hello
  2815. Hello, world!
  2816. @end example
  2817. All it takes to get rid of the profile is to remove this symlink and its
  2818. siblings that point to specific generations:
  2819. @example
  2820. $ rm ~/code/my-profile ~/code/my-profile-*-link
  2821. @end example
  2822. @item --list-profiles
  2823. List all the user's profiles:
  2824. @example
  2825. $ guix package --list-profiles
  2826. /home/charlie/.guix-profile
  2827. /home/charlie/code/my-profile
  2828. /home/charlie/code/devel-profile
  2829. /home/charlie/tmp/test
  2830. @end example
  2831. When running as root, list all the profiles of all the users.
  2832. @cindex collisions, in a profile
  2833. @cindex colliding packages in profiles
  2834. @cindex profile collisions
  2835. @item --allow-collisions
  2836. Allow colliding packages in the new profile. Use at your own risk!
  2837. By default, @command{guix package} reports as an error @dfn{collisions}
  2838. in the profile. Collisions happen when two or more different versions
  2839. or variants of a given package end up in the profile.
  2840. @item --bootstrap
  2841. Use the bootstrap Guile to build the profile. This option is only
  2842. useful to distribution developers.
  2843. @end table
  2844. In addition to these actions, @command{guix package} supports the
  2845. following options to query the current state of a profile, or the
  2846. availability of packages:
  2847. @table @option
  2848. @item --search=@var{regexp}
  2849. @itemx -s @var{regexp}
  2850. @anchor{guix-search}
  2851. @cindex searching for packages
  2852. List the available packages whose name, synopsis, or description matches
  2853. @var{regexp} (in a case-insensitive fashion), sorted by relevance.
  2854. Print all the metadata of matching packages in
  2855. @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils,
  2856. GNU recutils manual}).
  2857. This allows specific fields to be extracted using the @command{recsel}
  2858. command, for instance:
  2859. @example
  2860. $ guix package -s malloc | recsel -p name,version,relevance
  2861. name: jemalloc
  2862. version: 4.5.0
  2863. relevance: 6
  2864. name: glibc
  2865. version: 2.25
  2866. relevance: 1
  2867. name: libgc
  2868. version: 7.6.0
  2869. relevance: 1
  2870. @end example
  2871. Similarly, to show the name of all the packages available under the
  2872. terms of the GNU@tie{}LGPL version 3:
  2873. @example
  2874. $ guix package -s "" | recsel -p name -e 'license ~ "LGPL 3"'
  2875. name: elfutils
  2876. name: gmp
  2877. @dots{}
  2878. @end example
  2879. It is also possible to refine search results using several @code{-s} flags to
  2880. @command{guix package}, or several arguments to @command{guix search}. For
  2881. example, the following command returns a list of board games (this time using
  2882. the @command{guix search} alias):
  2883. @example
  2884. $ guix search '\<board\>' game | recsel -p name
  2885. name: gnubg
  2886. @dots{}
  2887. @end example
  2888. If we were to omit @code{-s game}, we would also get software packages
  2889. that deal with printed circuit boards; removing the angle brackets
  2890. around @code{board} would further add packages that have to do with
  2891. keyboards.
  2892. And now for a more elaborate example. The following command searches
  2893. for cryptographic libraries, filters out Haskell, Perl, Python, and Ruby
  2894. libraries, and prints the name and synopsis of the matching packages:
  2895. @example
  2896. $ guix search crypto library | \
  2897. recsel -e '! (name ~ "^(ghc|perl|python|ruby)")' -p name,synopsis
  2898. @end example
  2899. @noindent
  2900. @xref{Selection Expressions,,, recutils, GNU recutils manual}, for more
  2901. information on @dfn{selection expressions} for @code{recsel -e}.
  2902. @item --show=@var{package}
  2903. Show details about @var{package}, taken from the list of available packages, in
  2904. @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils, GNU
  2905. recutils manual}).
  2906. @example
  2907. $ guix package --show=guile | recsel -p name,version
  2908. name: guile
  2909. version: 3.0.5
  2910. name: guile
  2911. version: 3.0.2
  2912. name: guile
  2913. version: 2.2.7
  2914. @dots{}
  2915. @end example
  2916. You may also specify the full name of a package to only get details about a
  2917. specific version of it (this time using the @command{guix show} alias):
  2918. @example
  2919. $ guix show guile@@3.0.5 | recsel -p name,version
  2920. name: guile
  2921. version: 3.0.5
  2922. @end example
  2923. @item --list-installed[=@var{regexp}]
  2924. @itemx -I [@var{regexp}]
  2925. List the currently installed packages in the specified profile, with the
  2926. most recently installed packages shown last. When @var{regexp} is
  2927. specified, list only installed packages whose name matches @var{regexp}.
  2928. For each installed package, print the following items, separated by
  2929. tabs: the package name, its version string, the part of the package that
  2930. is installed (for instance, @code{out} for the default output,
  2931. @code{include} for its headers, etc.), and the path of this package in
  2932. the store.
  2933. @item --list-available[=@var{regexp}]
  2934. @itemx -A [@var{regexp}]
  2935. List packages currently available in the distribution for this system
  2936. (@pxref{GNU Distribution}). When @var{regexp} is specified, list only
  2937. available packages whose name matches @var{regexp}.
  2938. For each package, print the following items separated by tabs: its name,
  2939. its version string, the parts of the package (@pxref{Packages with
  2940. Multiple Outputs}), and the source location of its definition.
  2941. @item --list-generations[=@var{pattern}]
  2942. @itemx -l [@var{pattern}]
  2943. @cindex generations
  2944. Return a list of generations along with their creation dates; for each
  2945. generation, show the installed packages, with the most recently
  2946. installed packages shown last. Note that the zeroth generation is never
  2947. shown.
  2948. For each installed package, print the following items, separated by
  2949. tabs: the name of a package, its version string, the part of the package
  2950. that is installed (@pxref{Packages with Multiple Outputs}), and the
  2951. location of this package in the store.
  2952. When @var{pattern} is used, the command returns only matching
  2953. generations. Valid patterns include:
  2954. @itemize
  2955. @item @emph{Integers and comma-separated integers}. Both patterns denote
  2956. generation numbers. For instance, @option{--list-generations=1} returns
  2957. the first one.
  2958. And @option{--list-generations=1,8,2} outputs three generations in the
  2959. specified order. Neither spaces nor trailing commas are allowed.
  2960. @item @emph{Ranges}. @option{--list-generations=2..9} prints the
  2961. specified generations and everything in between. Note that the start of
  2962. a range must be smaller than its end.
  2963. It is also possible to omit the endpoint. For example,
  2964. @option{--list-generations=2..}, returns all generations starting from the
  2965. second one.
  2966. @item @emph{Durations}. You can also get the last @emph{N}@tie{}days, weeks,
  2967. or months by passing an integer along with the first letter of the
  2968. duration. For example, @option{--list-generations=20d} lists generations
  2969. that are up to 20 days old.
  2970. @end itemize
  2971. @item --delete-generations[=@var{pattern}]
  2972. @itemx -d [@var{pattern}]
  2973. When @var{pattern} is omitted, delete all generations except the current
  2974. one.
  2975. This command accepts the same patterns as @option{--list-generations}.
  2976. When @var{pattern} is specified, delete the matching generations. When
  2977. @var{pattern} specifies a duration, generations @emph{older} than the
  2978. specified duration match. For instance, @option{--delete-generations=1m}
  2979. deletes generations that are more than one month old.
  2980. If the current generation matches, it is @emph{not} deleted. Also, the
  2981. zeroth generation is never deleted.
  2982. Note that deleting generations prevents rolling back to them.
  2983. Consequently, this command must be used with care.
  2984. @cindex manifest, exporting
  2985. @anchor{export-manifest}
  2986. @item --export-manifest
  2987. Write to standard output a manifest suitable for @option{--manifest}
  2988. corresponding to the chosen profile(s).
  2989. This option is meant to help you migrate from the ``imperative''
  2990. operating mode---running @command{guix install}, @command{guix upgrade},
  2991. etc.---to the declarative mode that @option{--manifest} offers.
  2992. Be aware that the resulting manifest @emph{approximates} what your
  2993. profile actually contains; for instance, depending on how your profile
  2994. was created, it can refer to packages or package versions that are not
  2995. exactly what you specified.
  2996. Keep in mind that a manifest is purely symbolic: it only contains
  2997. package names and possibly versions, and their meaning varies over time.
  2998. If you wish to ``pin'' channels to the revisions that were used to build
  2999. the profile(s), see @option{--export-channels} below.
  3000. @cindex pinning, channel revisions of a profile
  3001. @item --export-channels
  3002. Write to standard output the list of channels used by the chosen
  3003. profile(s), in a format suitable for @command{guix pull --channels} or
  3004. @command{guix time-machine --channels} (@pxref{Channels}).
  3005. Together with @option{--export-manifest}, this option provides
  3006. information allowing you to replicate the current profile
  3007. (@pxref{Replicating Guix}).
  3008. However, note that the output of this command @emph{approximates} what
  3009. was actually used to build this profile. In particular, a single
  3010. profile might have been built from several different revisions of the
  3011. same channel. In that case, @option{--export-manifest} chooses the last
  3012. one and writes the list of other revisions in a comment. If you really
  3013. need to pick packages from different channel revisions, you can use
  3014. inferiors in your manifest to do so (@pxref{Inferiors}).
  3015. Together with @option{--export-manifest}, this is a good starting point
  3016. if you are willing to migrate from the ``imperative'' model to the fully
  3017. declarative model consisting of a manifest file along with a channels
  3018. file pinning the exact channel revision(s) you want.
  3019. @end table
  3020. Finally, since @command{guix package} may actually start build
  3021. processes, it supports all the common build options (@pxref{Common Build
  3022. Options}). It also supports package transformation options, such as
  3023. @option{--with-source}, and preserves them across upgrades
  3024. (@pxref{Package Transformation Options}).
  3025. @node Substitutes
  3026. @section Substitutes
  3027. @cindex substitutes
  3028. @cindex pre-built binaries
  3029. Guix supports transparent source/binary deployment, which means that it
  3030. can either build things locally, or download pre-built items from a
  3031. server, or both. We call these pre-built items @dfn{substitutes}---they
  3032. are substitutes for local build results. In many cases, downloading a
  3033. substitute is much faster than building things locally.
  3034. Substitutes can be anything resulting from a derivation build
  3035. (@pxref{Derivations}). Of course, in the common case, they are
  3036. pre-built package binaries, but source tarballs, for instance, which
  3037. also result from derivation builds, can be available as substitutes.
  3038. @menu
  3039. * Official Substitute Servers:: One particular source of substitutes.
  3040. * Substitute Server Authorization:: How to enable or disable substitutes.
  3041. * Getting Substitutes from Other Servers:: Substitute diversity.
  3042. * Substitute Authentication:: How Guix verifies substitutes.
  3043. * Proxy Settings:: How to get substitutes via proxy.
  3044. * Substitution Failure:: What happens when substitution fails.
  3045. * On Trusting Binaries:: How can you trust that binary blob?
  3046. @end menu
  3047. @node Official Substitute Servers
  3048. @subsection Official Substitute Servers
  3049. @cindex build farm
  3050. @code{@value{SUBSTITUTE-SERVER-1}} and
  3051. @code{@value{SUBSTITUTE-SERVER-2}} are both front-ends to official build
  3052. farms that build packages from Guix continuously for some architectures,
  3053. and make them available as substitutes. These are the default source of
  3054. substitutes; which can be overridden by passing the
  3055. @option{--substitute-urls} option either to @command{guix-daemon}
  3056. (@pxref{daemon-substitute-urls,, @code{guix-daemon --substitute-urls}})
  3057. or to client tools such as @command{guix package}
  3058. (@pxref{client-substitute-urls,, client @option{--substitute-urls}
  3059. option}).
  3060. Substitute URLs can be either HTTP or HTTPS.
  3061. HTTPS is recommended because communications are encrypted; conversely,
  3062. using HTTP makes all communications visible to an eavesdropper, who
  3063. could use the information gathered to determine, for instance, whether
  3064. your system has unpatched security vulnerabilities.
  3065. Substitutes from the official build farms are enabled by default when
  3066. using Guix System (@pxref{GNU Distribution}). However,
  3067. they are disabled by default when using Guix on a foreign distribution,
  3068. unless you have explicitly enabled them via one of the recommended
  3069. installation steps (@pxref{Installation}). The following paragraphs
  3070. describe how to enable or disable substitutes for the official build
  3071. farm; the same procedure can also be used to enable substitutes for any
  3072. other substitute server.
  3073. @node Substitute Server Authorization
  3074. @subsection Substitute Server Authorization
  3075. @cindex security
  3076. @cindex substitutes, authorization thereof
  3077. @cindex access control list (ACL), for substitutes
  3078. @cindex ACL (access control list), for substitutes
  3079. To allow Guix to download substitutes from @code{@value{SUBSTITUTE-SERVER-1}}, @code{@value{SUBSTITUTE-SERVER-2}} or a mirror, you
  3080. must add the relevant public key to the access control list (ACL) of archive
  3081. imports, using the @command{guix archive} command (@pxref{Invoking guix
  3082. archive}). Doing so implies that you trust the substitute server to not
  3083. be compromised and to serve genuine substitutes.
  3084. @quotation Note
  3085. If you are using Guix System, you can skip this section: Guix System
  3086. authorizes substitutes from @code{@value{SUBSTITUTE-SERVER-1}} and
  3087. @code{@value{SUBSTITUTE-SERVER-2}} by default.
  3088. @end quotation
  3089. The public keys for each of the project maintained substitute servers
  3090. are installed along with Guix, in @code{@var{prefix}/share/guix/}, where
  3091. @var{prefix} is the installation prefix of Guix. If you installed Guix
  3092. from source, make sure you checked the GPG signature of
  3093. @file{guix-@value{VERSION}.tar.gz}, which contains this public key file.
  3094. Then, you can run something like this:
  3095. @example
  3096. # guix archive --authorize < @var{prefix}/share/guix/@value{SUBSTITUTE-SERVER-1}.pub
  3097. # guix archive --authorize < @var{prefix}/share/guix/@value{SUBSTITUTE-SERVER-2}.pub
  3098. @end example
  3099. Once this is in place, the output of a command like @code{guix build}
  3100. should change from something like:
  3101. @example
  3102. $ guix build emacs --dry-run
  3103. The following derivations would be built:
  3104. /gnu/store/yr7bnx8xwcayd6j95r2clmkdl1qh688w-emacs-24.3.drv
  3105. /gnu/store/x8qsh1hlhgjx6cwsjyvybnfv2i37z23w-dbus-1.6.4.tar.gz.drv
  3106. /gnu/store/1ixwp12fl950d15h2cj11c73733jay0z-alsa-lib-1.0.27.1.tar.bz2.drv
  3107. /gnu/store/nlma1pw0p603fpfiqy7kn4zm105r5dmw-util-linux-2.21.drv
  3108. @dots{}
  3109. @end example
  3110. @noindent
  3111. to something like:
  3112. @example
  3113. $ guix build emacs --dry-run
  3114. 112.3 MB would be downloaded:
  3115. /gnu/store/pk3n22lbq6ydamyymqkkz7i69wiwjiwi-emacs-24.3
  3116. /gnu/store/2ygn4ncnhrpr61rssa6z0d9x22si0va3-libjpeg-8d
  3117. /gnu/store/71yz6lgx4dazma9dwn2mcjxaah9w77jq-cairo-1.12.16
  3118. /gnu/store/7zdhgp0n1518lvfn8mb96sxqfmvqrl7v-libxrender-0.9.7
  3119. @dots{}
  3120. @end example
  3121. @noindent
  3122. The text changed from ``The following derivations would be built'' to
  3123. ``112.3 MB would be downloaded''. This indicates that substitutes from
  3124. the configured substitute servers are usable and will be downloaded,
  3125. when possible, for future builds.
  3126. @cindex substitutes, how to disable
  3127. The substitute mechanism can be disabled globally by running
  3128. @code{guix-daemon} with @option{--no-substitutes} (@pxref{Invoking
  3129. guix-daemon}). It can also be disabled temporarily by passing the
  3130. @option{--no-substitutes} option to @command{guix package},
  3131. @command{guix build}, and other command-line tools.
  3132. @node Getting Substitutes from Other Servers
  3133. @subsection Getting Substitutes from Other Servers
  3134. @cindex substitute servers, adding more
  3135. Guix can look up and fetch substitutes from several servers. This is
  3136. useful when you are using packages from additional channels for which
  3137. the official server does not have substitutes but another server
  3138. provides them. Another situation where this is useful is when you would
  3139. prefer to download from your organization's substitute server, resorting
  3140. to the official server only as a fallback or dismissing it altogether.
  3141. You can give Guix a list of substitute server URLs and it will check
  3142. them in the specified order. You also need to explicitly authorize the
  3143. public keys of substitute servers to instruct Guix to accept the
  3144. substitutes they sign.
  3145. On Guix System, this is achieved by modifying the configuration of the
  3146. @code{guix} service. Since the @code{guix} service is part of the
  3147. default lists of services, @code{%base-services} and
  3148. @code{%desktop-services}, you can use @code{modify-services} to change
  3149. its configuration and add the URLs and substitute keys that you want
  3150. (@pxref{Service Reference, @code{modify-services}}).
  3151. As an example, suppose you want to fetch substitutes from
  3152. @code{guix.example.org} and to authorize the signing key of that server,
  3153. in addition to the default @code{@value{SUBSTITUTE-SERVER-1}} and
  3154. @code{@value{SUBSTITUTE-SERVER-2}}. The resulting operating system
  3155. configuration will look something like:
  3156. @lisp
  3157. (operating-system
  3158. ;; @dots{}
  3159. (services
  3160. ;; Assume we're starting from '%desktop-services'. Replace it
  3161. ;; with the list of services you're actually using.
  3162. (modify-services %desktop-services
  3163. (guix-service-type config =>
  3164. (guix-configuration
  3165. (inherit config)
  3166. (substitute-urls
  3167. (append (list "https://guix.example.org")
  3168. %default-substitute-urls))
  3169. (authorized-keys
  3170. (append (list (local-file "./key.pub"))
  3171. %default-authorized-guix-keys)))))))
  3172. @end lisp
  3173. This assumes that the file @file{key.pub} contains the signing key of
  3174. @code{guix.example.org}. With this change in place in your operating
  3175. system configuration file (say @file{/etc/config.scm}), you can
  3176. reconfigure and restart the @code{guix-daemon} service or reboot so the
  3177. changes take effect:
  3178. @example
  3179. $ sudo guix system reconfigure /etc/config.scm
  3180. $ sudo herd restart guix-daemon
  3181. @end example
  3182. If you're running Guix on a ``foreign distro'', you would instead take
  3183. the following steps to get substitutes from additional servers:
  3184. @enumerate
  3185. @item
  3186. Edit the service configuration file for @code{guix-daemon}; when using
  3187. systemd, this is normally
  3188. @file{/etc/systemd/system/guix-daemon.service}. Add the
  3189. @option{--substitute-urls} option on the @command{guix-daemon} command
  3190. line and list the URLs of interest (@pxref{daemon-substitute-urls,
  3191. @code{guix-daemon --substitute-urls}}):
  3192. @example
  3193. @dots{} --substitute-urls='https://guix.example.org @value{SUBSTITUTE-URLS}'
  3194. @end example
  3195. @item
  3196. Restart the daemon. For systemd, it goes like this:
  3197. @example
  3198. systemctl daemon-reload
  3199. systemctl restart guix-daemon.service
  3200. @end example
  3201. @item
  3202. Authorize the key of the new server (@pxref{Invoking guix archive}):
  3203. @example
  3204. guix archive --authorize < key.pub
  3205. @end example
  3206. Again this assumes @file{key.pub} contains the public key that
  3207. @code{guix.example.org} uses to sign substitutes.
  3208. @end enumerate
  3209. Now you're all set! Substitutes will be preferably taken from
  3210. @code{https://guix.example.org}, using
  3211. @code{@value{SUBSTITUTE-SERVER-1}} then
  3212. @code{@value{SUBSTITUTE-SERVER-2}} as fallback options. Of course you
  3213. can list as many substitute servers as you like, with the caveat that
  3214. substitute lookup can be slowed down if too many servers need to be
  3215. contacted.
  3216. Note that there are also situations where one may want to add the URL of
  3217. a substitute server @emph{without} authorizing its key.
  3218. @xref{Substitute Authentication}, to understand this fine point.
  3219. @node Substitute Authentication
  3220. @subsection Substitute Authentication
  3221. @cindex digital signatures
  3222. Guix detects and raises an error when attempting to use a substitute
  3223. that has been tampered with. Likewise, it ignores substitutes that are
  3224. not signed, or that are not signed by one of the keys listed in the ACL.
  3225. There is one exception though: if an unauthorized server provides
  3226. substitutes that are @emph{bit-for-bit identical} to those provided by
  3227. an authorized server, then the unauthorized server becomes eligible for
  3228. downloads. For example, assume we have chosen two substitute servers
  3229. with this option:
  3230. @example
  3231. --substitute-urls="https://a.example.org https://b.example.org"
  3232. @end example
  3233. @noindent
  3234. @cindex reproducible builds
  3235. If the ACL contains only the key for @samp{b.example.org}, and if
  3236. @samp{a.example.org} happens to serve the @emph{exact same} substitutes,
  3237. then Guix will download substitutes from @samp{a.example.org} because it
  3238. comes first in the list and can be considered a mirror of
  3239. @samp{b.example.org}. In practice, independent build machines usually
  3240. produce the same binaries, thanks to bit-reproducible builds (see
  3241. below).
  3242. When using HTTPS, the server's X.509 certificate is @emph{not} validated
  3243. (in other words, the server is not authenticated), contrary to what
  3244. HTTPS clients such as Web browsers usually do. This is because Guix
  3245. authenticates substitute information itself, as explained above, which
  3246. is what we care about (whereas X.509 certificates are about
  3247. authenticating bindings between domain names and public keys).
  3248. @node Proxy Settings
  3249. @subsection Proxy Settings
  3250. @vindex http_proxy
  3251. @vindex https_proxy
  3252. Substitutes are downloaded over HTTP or HTTPS@. The @env{http_proxy} and
  3253. @env{https_proxy} environment variables can be set in the environment of
  3254. @command{guix-daemon} and are honored for downloads of substitutes.
  3255. Note that the value of those environment variables in the environment
  3256. where @command{guix build}, @command{guix package}, and other client
  3257. commands are run has @emph{absolutely no effect}.
  3258. @node Substitution Failure
  3259. @subsection Substitution Failure
  3260. Even when a substitute for a derivation is available, sometimes the
  3261. substitution attempt will fail. This can happen for a variety of
  3262. reasons: the substitute server might be offline, the substitute may
  3263. recently have been deleted, the connection might have been interrupted,
  3264. etc.
  3265. When substitutes are enabled and a substitute for a derivation is
  3266. available, but the substitution attempt fails, Guix will attempt to
  3267. build the derivation locally depending on whether or not
  3268. @option{--fallback} was given (@pxref{fallback-option,, common build
  3269. option @option{--fallback}}). Specifically, if @option{--fallback} was
  3270. omitted, then no local build will be performed, and the derivation is
  3271. considered to have failed. However, if @option{--fallback} was given,
  3272. then Guix will attempt to build the derivation locally, and the success
  3273. or failure of the derivation depends on the success or failure of the
  3274. local build. Note that when substitutes are disabled or no substitute
  3275. is available for the derivation in question, a local build will
  3276. @emph{always} be performed, regardless of whether or not
  3277. @option{--fallback} was given.
  3278. To get an idea of how many substitutes are available right now, you can
  3279. try running the @command{guix weather} command (@pxref{Invoking guix
  3280. weather}). This command provides statistics on the substitutes provided
  3281. by a server.
  3282. @node On Trusting Binaries
  3283. @subsection On Trusting Binaries
  3284. @cindex trust, of pre-built binaries
  3285. Today, each individual's control over their own computing is at the
  3286. mercy of institutions, corporations, and groups with enough power and
  3287. determination to subvert the computing infrastructure and exploit its
  3288. weaknesses. While using substitutes can be convenient, we encourage
  3289. users to also build on their own, or even run their own build farm, such
  3290. that the project run substitute servers are less of an interesting
  3291. target. One way to help is by publishing the software you build using
  3292. @command{guix publish} so that others have one more choice of server to
  3293. download substitutes from (@pxref{Invoking guix publish}).
  3294. Guix has the foundations to maximize build reproducibility
  3295. (@pxref{Features}). In most cases, independent builds of a given
  3296. package or derivation should yield bit-identical results. Thus, through
  3297. a diverse set of independent package builds, we can strengthen the
  3298. integrity of our systems. The @command{guix challenge} command aims to
  3299. help users assess substitute servers, and to assist developers in
  3300. finding out about non-deterministic package builds (@pxref{Invoking guix
  3301. challenge}). Similarly, the @option{--check} option of @command{guix
  3302. build} allows users to check whether previously-installed substitutes
  3303. are genuine by rebuilding them locally (@pxref{build-check,
  3304. @command{guix build --check}}).
  3305. In the future, we want Guix to have support to publish and retrieve
  3306. binaries to/from other users, in a peer-to-peer fashion. If you would
  3307. like to discuss this project, join us on @email{guix-devel@@gnu.org}.
  3308. @node Packages with Multiple Outputs
  3309. @section Packages with Multiple Outputs
  3310. @cindex multiple-output packages
  3311. @cindex package outputs
  3312. @cindex outputs
  3313. Often, packages defined in Guix have a single @dfn{output}---i.e., the
  3314. source package leads to exactly one directory in the store. When running
  3315. @command{guix install glibc}, one installs the default output of the
  3316. GNU libc package; the default output is called @code{out}, but its name
  3317. can be omitted as shown in this command. In this particular case, the
  3318. default output of @code{glibc} contains all the C header files, shared
  3319. libraries, static libraries, Info documentation, and other supporting
  3320. files.
  3321. Sometimes it is more appropriate to separate the various types of files
  3322. produced from a single source package into separate outputs. For
  3323. instance, the GLib C library (used by GTK+ and related packages)
  3324. installs more than 20 MiB of reference documentation as HTML pages.
  3325. To save space for users who do not need it, the documentation goes to a
  3326. separate output, called @code{doc}. To install the main GLib output,
  3327. which contains everything but the documentation, one would run:
  3328. @example
  3329. guix install glib
  3330. @end example
  3331. @cindex documentation
  3332. The command to install its documentation is:
  3333. @example
  3334. guix install glib:doc
  3335. @end example
  3336. Some packages install programs with different ``dependency footprints''.
  3337. For instance, the WordNet package installs both command-line tools and
  3338. graphical user interfaces (GUIs). The former depend solely on the C
  3339. library, whereas the latter depend on Tcl/Tk and the underlying X
  3340. libraries. In this case, we leave the command-line tools in the default
  3341. output, whereas the GUIs are in a separate output. This allows users
  3342. who do not need the GUIs to save space. The @command{guix size} command
  3343. can help find out about such situations (@pxref{Invoking guix size}).
  3344. @command{guix graph} can also be helpful (@pxref{Invoking guix graph}).
  3345. There are several such multiple-output packages in the GNU distribution.
  3346. Other conventional output names include @code{lib} for libraries and
  3347. possibly header files, @code{bin} for stand-alone programs, and
  3348. @code{debug} for debugging information (@pxref{Installing Debugging
  3349. Files}). The outputs of a packages are listed in the third column of
  3350. the output of @command{guix package --list-available} (@pxref{Invoking
  3351. guix package}).
  3352. @node Invoking guix gc
  3353. @section Invoking @command{guix gc}
  3354. @cindex garbage collector
  3355. @cindex disk space
  3356. Packages that are installed, but not used, may be @dfn{garbage-collected}.
  3357. The @command{guix gc} command allows users to explicitly run the garbage
  3358. collector to reclaim space from the @file{/gnu/store} directory. It is
  3359. the @emph{only} way to remove files from @file{/gnu/store}---removing
  3360. files or directories manually may break it beyond repair!
  3361. @cindex GC roots
  3362. @cindex garbage collector roots
  3363. The garbage collector has a set of known @dfn{roots}: any file under
  3364. @file{/gnu/store} reachable from a root is considered @dfn{live} and
  3365. cannot be deleted; any other file is considered @dfn{dead} and may be
  3366. deleted. The set of garbage collector roots (``GC roots'' for short)
  3367. includes default user profiles; by default, the symlinks under
  3368. @file{/var/guix/gcroots} represent these GC roots. New GC roots can be
  3369. added with @command{guix build --root}, for example (@pxref{Invoking
  3370. guix build}). The @command{guix gc --list-roots} command lists them.
  3371. Prior to running @code{guix gc --collect-garbage} to make space, it is
  3372. often useful to remove old generations from user profiles; that way, old
  3373. package builds referenced by those generations can be reclaimed. This
  3374. is achieved by running @code{guix package --delete-generations}
  3375. (@pxref{Invoking guix package}).
  3376. Our recommendation is to run a garbage collection periodically, or when
  3377. you are short on disk space. For instance, to guarantee that at least
  3378. 5@tie{}GB are available on your disk, simply run:
  3379. @example
  3380. guix gc -F 5G
  3381. @end example
  3382. It is perfectly safe to run as a non-interactive periodic job
  3383. (@pxref{Scheduled Job Execution}, for how to set up such a job).
  3384. Running @command{guix gc} with no arguments will collect as
  3385. much garbage as it can, but that is often inconvenient: you may find
  3386. yourself having to rebuild or re-download software that is ``dead'' from
  3387. the GC viewpoint but that is necessary to build other pieces of
  3388. software---e.g., the compiler tool chain.
  3389. The @command{guix gc} command has three modes of operation: it can be
  3390. used to garbage-collect any dead files (the default), to delete specific
  3391. files (the @option{--delete} option), to print garbage-collector
  3392. information, or for more advanced queries. The garbage collection
  3393. options are as follows:
  3394. @table @code
  3395. @item --collect-garbage[=@var{min}]
  3396. @itemx -C [@var{min}]
  3397. Collect garbage---i.e., unreachable @file{/gnu/store} files and
  3398. sub-directories. This is the default operation when no option is
  3399. specified.
  3400. When @var{min} is given, stop once @var{min} bytes have been collected.
  3401. @var{min} may be a number of bytes, or it may include a unit as a
  3402. suffix, such as @code{MiB} for mebibytes and @code{GB} for gigabytes
  3403. (@pxref{Block size, size specifications,, coreutils, GNU Coreutils}).
  3404. When @var{min} is omitted, collect all the garbage.
  3405. @item --free-space=@var{free}
  3406. @itemx -F @var{free}
  3407. Collect garbage until @var{free} space is available under
  3408. @file{/gnu/store}, if possible; @var{free} denotes storage space, such
  3409. as @code{500MiB}, as described above.
  3410. When @var{free} or more is already available in @file{/gnu/store}, do
  3411. nothing and exit immediately.
  3412. @item --delete-generations[=@var{duration}]
  3413. @itemx -d [@var{duration}]
  3414. Before starting the garbage collection process, delete all the generations
  3415. older than @var{duration}, for all the user profiles; when run as root, this
  3416. applies to all the profiles @emph{of all the users}.
  3417. For example, this command deletes all the generations of all your profiles
  3418. that are older than 2 months (except generations that are current), and then
  3419. proceeds to free space until at least 10 GiB are available:
  3420. @example
  3421. guix gc -d 2m -F 10G
  3422. @end example
  3423. @item --delete
  3424. @itemx -D
  3425. Attempt to delete all the store files and directories specified as
  3426. arguments. This fails if some of the files are not in the store, or if
  3427. they are still live.
  3428. @item --list-failures
  3429. List store items corresponding to cached build failures.
  3430. This prints nothing unless the daemon was started with
  3431. @option{--cache-failures} (@pxref{Invoking guix-daemon,
  3432. @option{--cache-failures}}).
  3433. @item --list-roots
  3434. List the GC roots owned by the user; when run as root, list @emph{all} the GC
  3435. roots.
  3436. @item --list-busy
  3437. List store items in use by currently running processes. These store
  3438. items are effectively considered GC roots: they cannot be deleted.
  3439. @item --clear-failures
  3440. Remove the specified store items from the failed-build cache.
  3441. Again, this option only makes sense when the daemon is started with
  3442. @option{--cache-failures}. Otherwise, it does nothing.
  3443. @item --list-dead
  3444. Show the list of dead files and directories still present in the
  3445. store---i.e., files and directories no longer reachable from any root.
  3446. @item --list-live
  3447. Show the list of live store files and directories.
  3448. @end table
  3449. In addition, the references among existing store files can be queried:
  3450. @table @code
  3451. @item --references
  3452. @itemx --referrers
  3453. @cindex package dependencies
  3454. List the references (respectively, the referrers) of store files given
  3455. as arguments.
  3456. @item --requisites
  3457. @itemx -R
  3458. @cindex closure
  3459. List the requisites of the store files passed as arguments. Requisites
  3460. include the store files themselves, their references, and the references
  3461. of these, recursively. In other words, the returned list is the
  3462. @dfn{transitive closure} of the store files.
  3463. @xref{Invoking guix size}, for a tool to profile the size of the closure
  3464. of an element. @xref{Invoking guix graph}, for a tool to visualize
  3465. the graph of references.
  3466. @item --derivers
  3467. @cindex derivation
  3468. Return the derivation(s) leading to the given store items
  3469. (@pxref{Derivations}).
  3470. For example, this command:
  3471. @example
  3472. guix gc --derivers $(guix package -I ^emacs$ | cut -f4)
  3473. @end example
  3474. @noindent
  3475. returns the @file{.drv} file(s) leading to the @code{emacs} package
  3476. installed in your profile.
  3477. Note that there may be zero matching @file{.drv} files, for instance
  3478. because these files have been garbage-collected. There can also be more
  3479. than one matching @file{.drv} due to fixed-output derivations.
  3480. @end table
  3481. Lastly, the following options allow you to check the integrity of the
  3482. store and to control disk usage.
  3483. @table @option
  3484. @item --verify[=@var{options}]
  3485. @cindex integrity, of the store
  3486. @cindex integrity checking
  3487. Verify the integrity of the store.
  3488. By default, make sure that all the store items marked as valid in the
  3489. database of the daemon actually exist in @file{/gnu/store}.
  3490. When provided, @var{options} must be a comma-separated list containing one
  3491. or more of @code{contents} and @code{repair}.
  3492. When passing @option{--verify=contents}, the daemon computes the
  3493. content hash of each store item and compares it against its hash in the
  3494. database. Hash mismatches are reported as data corruptions. Because it
  3495. traverses @emph{all the files in the store}, this command can take a
  3496. long time, especially on systems with a slow disk drive.
  3497. @cindex repairing the store
  3498. @cindex corruption, recovering from
  3499. Using @option{--verify=repair} or @option{--verify=contents,repair}
  3500. causes the daemon to try to repair corrupt store items by fetching
  3501. substitutes for them (@pxref{Substitutes}). Because repairing is not
  3502. atomic, and thus potentially dangerous, it is available only to the
  3503. system administrator. A lightweight alternative, when you know exactly
  3504. which items in the store are corrupt, is @command{guix build --repair}
  3505. (@pxref{Invoking guix build}).
  3506. @item --optimize
  3507. @cindex deduplication
  3508. Optimize the store by hard-linking identical files---this is
  3509. @dfn{deduplication}.
  3510. The daemon performs deduplication after each successful build or archive
  3511. import, unless it was started with @option{--disable-deduplication}
  3512. (@pxref{Invoking guix-daemon, @option{--disable-deduplication}}). Thus,
  3513. this option is primarily useful when the daemon was running with
  3514. @option{--disable-deduplication}.
  3515. @end table
  3516. @node Invoking guix pull
  3517. @section Invoking @command{guix pull}
  3518. @cindex upgrading Guix
  3519. @cindex updating Guix
  3520. @cindex @command{guix pull}
  3521. @cindex pull
  3522. @cindex security, @command{guix pull}
  3523. @cindex authenticity, of code obtained with @command{guix pull}
  3524. Packages are installed or upgraded to the latest version available in
  3525. the distribution currently available on your local machine. To update
  3526. that distribution, along with the Guix tools, you must run @command{guix
  3527. pull}: the command downloads the latest Guix source code and package
  3528. descriptions, and deploys it. Source code is downloaded from a
  3529. @uref{https://git-scm.com, Git} repository, by default the official
  3530. GNU@tie{}Guix repository, though this can be customized. @command{guix
  3531. pull} ensures that the code it downloads is @emph{authentic} by
  3532. verifying that commits are signed by Guix developers.
  3533. Specifically, @command{guix pull} downloads code from the @dfn{channels}
  3534. (@pxref{Channels}) specified by one of the followings, in this order:
  3535. @enumerate
  3536. @item
  3537. the @option{--channels} option;
  3538. @item
  3539. the user's @file{~/.config/guix/channels.scm} file;
  3540. @item
  3541. the system-wide @file{/etc/guix/channels.scm} file;
  3542. @item
  3543. the built-in default channels specified in the @code{%default-channels}
  3544. variable.
  3545. @end enumerate
  3546. On completion, @command{guix package} will use packages and package
  3547. versions from this just-retrieved copy of Guix. Not only that, but all
  3548. the Guix commands and Scheme modules will also be taken from that latest
  3549. version. New @command{guix} sub-commands added by the update also
  3550. become available.
  3551. Any user can update their Guix copy using @command{guix pull}, and the
  3552. effect is limited to the user who ran @command{guix pull}. For
  3553. instance, when user @code{root} runs @command{guix pull}, this has no
  3554. effect on the version of Guix that user @code{alice} sees, and vice
  3555. versa.
  3556. The result of running @command{guix pull} is a @dfn{profile} available
  3557. under @file{~/.config/guix/current} containing the latest Guix. Thus,
  3558. make sure to add it to the beginning of your search path so that you use
  3559. the latest version, and similarly for the Info manual
  3560. (@pxref{Documentation}):
  3561. @example
  3562. export PATH="$HOME/.config/guix/current/bin:$PATH"
  3563. export INFOPATH="$HOME/.config/guix/current/share/info:$INFOPATH"
  3564. @end example
  3565. The @option{--list-generations} or @option{-l} option lists past generations
  3566. produced by @command{guix pull}, along with details about their provenance:
  3567. @example
  3568. $ guix pull -l
  3569. Generation 1 Jun 10 2018 00:18:18
  3570. guix 65956ad
  3571. repository URL: https://git.savannah.gnu.org/git/guix.git
  3572. branch: origin/master
  3573. commit: 65956ad3526ba09e1f7a40722c96c6ef7c0936fe
  3574. Generation 2 Jun 11 2018 11:02:49
  3575. guix e0cc7f6
  3576. repository URL: https://git.savannah.gnu.org/git/guix.git
  3577. branch: origin/master
  3578. commit: e0cc7f669bec22c37481dd03a7941c7d11a64f1d
  3579. Generation 3 Jun 13 2018 23:31:07 (current)
  3580. guix 844cc1c
  3581. repository URL: https://git.savannah.gnu.org/git/guix.git
  3582. branch: origin/master
  3583. commit: 844cc1c8f394f03b404c5bb3aee086922373490c
  3584. @end example
  3585. @xref{Invoking guix describe, @command{guix describe}}, for other ways to
  3586. describe the current status of Guix.
  3587. This @code{~/.config/guix/current} profile works exactly like the profiles
  3588. created by @command{guix package} (@pxref{Invoking guix package}). That
  3589. is, you can list generations, roll back to the previous
  3590. generation---i.e., the previous Guix---and so on:
  3591. @example
  3592. $ guix pull --roll-back
  3593. switched from generation 3 to 2
  3594. $ guix pull --delete-generations=1
  3595. deleting /var/guix/profiles/per-user/charlie/current-guix-1-link
  3596. @end example
  3597. You can also use @command{guix package} (@pxref{Invoking guix package})
  3598. to manage the profile by naming it explicitly:
  3599. @example
  3600. $ guix package -p ~/.config/guix/current --roll-back
  3601. switched from generation 3 to 2
  3602. $ guix package -p ~/.config/guix/current --delete-generations=1
  3603. deleting /var/guix/profiles/per-user/charlie/current-guix-1-link
  3604. @end example
  3605. The @command{guix pull} command is usually invoked with no arguments,
  3606. but it supports the following options:
  3607. @table @code
  3608. @item --url=@var{url}
  3609. @itemx --commit=@var{commit}
  3610. @itemx --branch=@var{branch}
  3611. Download code for the @code{guix} channel from the specified @var{url}, at the
  3612. given @var{commit} (a valid Git commit ID represented as a hexadecimal
  3613. string), or @var{branch}.
  3614. @cindex @file{channels.scm}, configuration file
  3615. @cindex configuration file for channels
  3616. These options are provided for convenience, but you can also specify your
  3617. configuration in the @file{~/.config/guix/channels.scm} file or using the
  3618. @option{--channels} option (see below).
  3619. @item --channels=@var{file}
  3620. @itemx -C @var{file}
  3621. Read the list of channels from @var{file} instead of
  3622. @file{~/.config/guix/channels.scm} or @file{/etc/guix/channels.scm}.
  3623. @var{file} must contain Scheme code that
  3624. evaluates to a list of channel objects. @xref{Channels}, for more
  3625. information.
  3626. @cindex channel news
  3627. @item --news
  3628. @itemx -N
  3629. Display news written by channel authors for their users for changes made
  3630. since the previous generation (@pxref{Channels, Writing Channel News}).
  3631. When @option{--details} is passed, additionally display new and upgraded
  3632. packages.
  3633. You can view that information for previous generations with
  3634. @command{guix pull -l}.
  3635. @item --list-generations[=@var{pattern}]
  3636. @itemx -l [@var{pattern}]
  3637. List all the generations of @file{~/.config/guix/current} or, if @var{pattern}
  3638. is provided, the subset of generations that match @var{pattern}.
  3639. The syntax of @var{pattern} is the same as with @code{guix package
  3640. --list-generations} (@pxref{Invoking guix package}).
  3641. By default, this prints information about the channels used in each
  3642. revision as well as the corresponding news entries. If you pass
  3643. @option{--details}, it will also print the list of packages added and
  3644. upgraded in each generation compared to the previous one.
  3645. @item --details
  3646. Instruct @option{--list-generations} or @option{--news} to display more
  3647. information about the differences between subsequent generations---see
  3648. above.
  3649. @item --roll-back
  3650. @cindex rolling back
  3651. @cindex undoing transactions
  3652. @cindex transactions, undoing
  3653. Roll back to the previous @dfn{generation} of @file{~/.config/guix/current}---i.e.,
  3654. undo the last transaction.
  3655. @item --switch-generation=@var{pattern}
  3656. @itemx -S @var{pattern}
  3657. @cindex generations
  3658. Switch to a particular generation defined by @var{pattern}.
  3659. @var{pattern} may be either a generation number or a number prefixed
  3660. with ``+'' or ``-''. The latter means: move forward/backward by a
  3661. specified number of generations. For example, if you want to return to
  3662. the latest generation after @option{--roll-back}, use
  3663. @option{--switch-generation=+1}.
  3664. @item --delete-generations[=@var{pattern}]
  3665. @itemx -d [@var{pattern}]
  3666. When @var{pattern} is omitted, delete all generations except the current
  3667. one.
  3668. This command accepts the same patterns as @option{--list-generations}.
  3669. When @var{pattern} is specified, delete the matching generations. When
  3670. @var{pattern} specifies a duration, generations @emph{older} than the
  3671. specified duration match. For instance, @option{--delete-generations=1m}
  3672. deletes generations that are more than one month old.
  3673. If the current generation matches, it is @emph{not} deleted.
  3674. Note that deleting generations prevents rolling back to them.
  3675. Consequently, this command must be used with care.
  3676. @xref{Invoking guix describe}, for a way to display information about the
  3677. current generation only.
  3678. @item --profile=@var{profile}
  3679. @itemx -p @var{profile}
  3680. Use @var{profile} instead of @file{~/.config/guix/current}.
  3681. @item --dry-run
  3682. @itemx -n
  3683. Show which channel commit(s) would be used and what would be built or
  3684. substituted but do not actually do it.
  3685. @item --allow-downgrades
  3686. Allow pulling older or unrelated revisions of channels than those
  3687. currently in use.
  3688. @cindex downgrade attacks, protection against
  3689. By default, @command{guix pull} protects against so-called ``downgrade
  3690. attacks'' whereby the Git repository of a channel would be reset to an
  3691. earlier or unrelated revision of itself, potentially leading you to
  3692. install older, known-vulnerable versions of software packages.
  3693. @quotation Note
  3694. Make sure you understand its security implications before using
  3695. @option{--allow-downgrades}.
  3696. @end quotation
  3697. @item --disable-authentication
  3698. Allow pulling channel code without authenticating it.
  3699. @cindex authentication, of channel code
  3700. By default, @command{guix pull} authenticates code downloaded from
  3701. channels by verifying that its commits are signed by authorized
  3702. developers, and raises an error if this is not the case. This option
  3703. instructs it to not perform any such verification.
  3704. @quotation Note
  3705. Make sure you understand its security implications before using
  3706. @option{--disable-authentication}.
  3707. @end quotation
  3708. @item --system=@var{system}
  3709. @itemx -s @var{system}
  3710. Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
  3711. the system type of the build host.
  3712. @item --bootstrap
  3713. Use the bootstrap Guile to build the latest Guix. This option is only
  3714. useful to Guix developers.
  3715. @end table
  3716. The @dfn{channel} mechanism allows you to instruct @command{guix pull} which
  3717. repository and branch to pull from, as well as @emph{additional} repositories
  3718. containing package modules that should be deployed. @xref{Channels}, for more
  3719. information.
  3720. In addition, @command{guix pull} supports all the common build options
  3721. (@pxref{Common Build Options}).
  3722. @node Invoking guix time-machine
  3723. @section Invoking @command{guix time-machine}
  3724. @cindex @command{guix time-machine}
  3725. @cindex pinning, channels
  3726. @cindex replicating Guix
  3727. @cindex reproducibility, of Guix
  3728. The @command{guix time-machine} command provides access to other
  3729. revisions of Guix, for example to install older versions of packages,
  3730. or to reproduce a computation in an identical environment. The revision
  3731. of Guix to be used is defined by a commit or by a channel
  3732. description file created by @command{guix describe}
  3733. (@pxref{Invoking guix describe}).
  3734. The general syntax is:
  3735. @example
  3736. guix time-machine @var{options}@dots{} -- @var{command} @var {arg}@dots{}
  3737. @end example
  3738. where @var{command} and @var{arg}@dots{} are passed unmodified to the
  3739. @command{guix} command of the specified revision. The @var{options} that define
  3740. this revision are the same as for @command{guix pull} (@pxref{Invoking guix pull}):
  3741. @table @code
  3742. @item --url=@var{url}
  3743. @itemx --commit=@var{commit}
  3744. @itemx --branch=@var{branch}
  3745. Use the @code{guix} channel from the specified @var{url}, at the
  3746. given @var{commit} (a valid Git commit ID represented as a hexadecimal
  3747. string), or @var{branch}.
  3748. @item --channels=@var{file}
  3749. @itemx -C @var{file}
  3750. Read the list of channels from @var{file}. @var{file} must contain
  3751. Scheme code that evaluates to a list of channel objects.
  3752. @xref{Channels} for more information.
  3753. @end table
  3754. As for @command{guix pull}, the absence of any options means that the
  3755. latest commit on the master branch will be used. The command
  3756. @example
  3757. guix time-machine -- build hello
  3758. @end example
  3759. will thus build the package @code{hello} as defined in the master branch,
  3760. which is in general a newer revision of Guix than you have installed.
  3761. Time travel works in both directions!
  3762. Note that @command{guix time-machine} can trigger builds of channels and
  3763. their dependencies, and these are controlled by the standard build
  3764. options (@pxref{Common Build Options}).
  3765. @node Inferiors
  3766. @section Inferiors
  3767. @c TODO: Remove this once we're more confident about API stability.
  3768. @quotation Note
  3769. The functionality described here is a ``technology preview'' as of version
  3770. @value{VERSION}. As such, the interface is subject to change.
  3771. @end quotation
  3772. @cindex inferiors
  3773. @cindex composition of Guix revisions
  3774. Sometimes you might need to mix packages from the revision of Guix you're
  3775. currently running with packages available in a different revision of Guix.
  3776. Guix @dfn{inferiors} allow you to achieve that by composing different Guix
  3777. revisions in arbitrary ways.
  3778. @cindex inferior packages
  3779. Technically, an ``inferior'' is essentially a separate Guix process connected
  3780. to your main Guix process through a REPL (@pxref{Invoking guix repl}). The
  3781. @code{(guix inferior)} module allows you to create inferiors and to
  3782. communicate with them. It also provides a high-level interface to browse and
  3783. manipulate the packages that an inferior provides---@dfn{inferior packages}.
  3784. When combined with channels (@pxref{Channels}), inferiors provide a simple way
  3785. to interact with a separate revision of Guix. For example, let's assume you
  3786. want to install in your profile the current @code{guile} package, along with
  3787. the @code{guile-json} as it existed in an older revision of Guix---perhaps
  3788. because the newer @code{guile-json} has an incompatible API and you want to
  3789. run your code against the old API@. To do that, you could write a manifest for
  3790. use by @code{guix package --manifest} (@pxref{Invoking guix package}); in that
  3791. manifest, you would create an inferior for that old Guix revision you care
  3792. about, and you would look up the @code{guile-json} package in the inferior:
  3793. @lisp
  3794. (use-modules (guix inferior) (guix channels)
  3795. (srfi srfi-1)) ;for 'first'
  3796. (define channels
  3797. ;; This is the old revision from which we want to
  3798. ;; extract guile-json.
  3799. (list (channel
  3800. (name 'guix)
  3801. (url "https://git.savannah.gnu.org/git/guix.git")
  3802. (commit
  3803. "65956ad3526ba09e1f7a40722c96c6ef7c0936fe"))))
  3804. (define inferior
  3805. ;; An inferior representing the above revision.
  3806. (inferior-for-channels channels))
  3807. ;; Now create a manifest with the current "guile" package
  3808. ;; and the old "guile-json" package.
  3809. (packages->manifest
  3810. (list (first (lookup-inferior-packages inferior "guile-json"))
  3811. (specification->package "guile")))
  3812. @end lisp
  3813. On its first run, @command{guix package --manifest} might have to build the
  3814. channel you specified before it can create the inferior; subsequent runs will
  3815. be much faster because the Guix revision will be cached.
  3816. The @code{(guix inferior)} module provides the following procedures to open an
  3817. inferior:
  3818. @deffn {Scheme Procedure} inferior-for-channels @var{channels} @
  3819. [#:cache-directory] [#:ttl]
  3820. Return an inferior for @var{channels}, a list of channels. Use the cache at
  3821. @var{cache-directory}, where entries can be reclaimed after @var{ttl} seconds.
  3822. This procedure opens a new connection to the build daemon.
  3823. As a side effect, this procedure may build or substitute binaries for
  3824. @var{channels}, which can take time.
  3825. @end deffn
  3826. @deffn {Scheme Procedure} open-inferior @var{directory} @
  3827. [#:command "bin/guix"]
  3828. Open the inferior Guix in @var{directory}, running
  3829. @code{@var{directory}/@var{command} repl} or equivalent. Return @code{#f} if
  3830. the inferior could not be launched.
  3831. @end deffn
  3832. @cindex inferior packages
  3833. The procedures listed below allow you to obtain and manipulate inferior
  3834. packages.
  3835. @deffn {Scheme Procedure} inferior-packages @var{inferior}
  3836. Return the list of packages known to @var{inferior}.
  3837. @end deffn
  3838. @deffn {Scheme Procedure} lookup-inferior-packages @var{inferior} @var{name} @
  3839. [@var{version}]
  3840. Return the sorted list of inferior packages matching @var{name} in
  3841. @var{inferior}, with highest version numbers first. If @var{version} is true,
  3842. return only packages with a version number prefixed by @var{version}.
  3843. @end deffn
  3844. @deffn {Scheme Procedure} inferior-package? @var{obj}
  3845. Return true if @var{obj} is an inferior package.
  3846. @end deffn
  3847. @deffn {Scheme Procedure} inferior-package-name @var{package}
  3848. @deffnx {Scheme Procedure} inferior-package-version @var{package}
  3849. @deffnx {Scheme Procedure} inferior-package-synopsis @var{package}
  3850. @deffnx {Scheme Procedure} inferior-package-description @var{package}
  3851. @deffnx {Scheme Procedure} inferior-package-home-page @var{package}
  3852. @deffnx {Scheme Procedure} inferior-package-location @var{package}
  3853. @deffnx {Scheme Procedure} inferior-package-inputs @var{package}
  3854. @deffnx {Scheme Procedure} inferior-package-native-inputs @var{package}
  3855. @deffnx {Scheme Procedure} inferior-package-propagated-inputs @var{package}
  3856. @deffnx {Scheme Procedure} inferior-package-transitive-propagated-inputs @var{package}
  3857. @deffnx {Scheme Procedure} inferior-package-native-search-paths @var{package}
  3858. @deffnx {Scheme Procedure} inferior-package-transitive-native-search-paths @var{package}
  3859. @deffnx {Scheme Procedure} inferior-package-search-paths @var{package}
  3860. These procedures are the counterpart of package record accessors
  3861. (@pxref{package Reference}). Most of them work by querying the inferior
  3862. @var{package} comes from, so the inferior must still be live when you call
  3863. these procedures.
  3864. @end deffn
  3865. Inferior packages can be used transparently like any other package or
  3866. file-like object in G-expressions (@pxref{G-Expressions}). They are also
  3867. transparently handled by the @code{packages->manifest} procedure, which is
  3868. commonly used in manifests (@pxref{Invoking guix package, the
  3869. @option{--manifest} option of @command{guix package}}). Thus you can insert
  3870. an inferior package pretty much anywhere you would insert a regular package:
  3871. in manifests, in the @code{packages} field of your @code{operating-system}
  3872. declaration, and so on.
  3873. @node Invoking guix describe
  3874. @section Invoking @command{guix describe}
  3875. @cindex reproducibility
  3876. @cindex replicating Guix
  3877. Often you may want to answer questions like: ``Which revision of Guix am I
  3878. using?'' or ``Which channels am I using?'' This is useful information in many
  3879. situations: if you want to @emph{replicate} an environment on a different
  3880. machine or user account, if you want to report a bug or to determine what
  3881. change in the channels you are using caused it, or if you want to record your
  3882. system state for reproducibility purposes. The @command{guix describe}
  3883. command answers these questions.
  3884. When run from a @command{guix pull}ed @command{guix}, @command{guix describe}
  3885. displays the channel(s) that it was built from, including their repository URL
  3886. and commit IDs (@pxref{Channels}):
  3887. @example
  3888. $ guix describe
  3889. Generation 10 Sep 03 2018 17:32:44 (current)
  3890. guix e0fa68c
  3891. repository URL: https://git.savannah.gnu.org/git/guix.git
  3892. branch: master
  3893. commit: e0fa68c7718fffd33d81af415279d6ddb518f727
  3894. @end example
  3895. If you're familiar with the Git version control system, this is similar in
  3896. spirit to @command{git describe}; the output is also similar to that of
  3897. @command{guix pull --list-generations}, but limited to the current generation
  3898. (@pxref{Invoking guix pull, the @option{--list-generations} option}). Because
  3899. the Git commit ID shown above unambiguously refers to a snapshot of Guix, this
  3900. information is all it takes to describe the revision of Guix you're using, and
  3901. also to replicate it.
  3902. To make it easier to replicate Guix, @command{guix describe} can also be asked
  3903. to return a list of channels instead of the human-readable description above:
  3904. @example
  3905. $ guix describe -f channels
  3906. (list (channel
  3907. (name 'guix)
  3908. (url "https://git.savannah.gnu.org/git/guix.git")
  3909. (commit
  3910. "e0fa68c7718fffd33d81af415279d6ddb518f727")
  3911. (introduction
  3912. (make-channel-introduction
  3913. "9edb3f66fd807b096b48283debdcddccfea34bad"
  3914. (openpgp-fingerprint
  3915. "BBB0 2DDF 2CEA F6A8 0D1D E643 A2A0 6DF2 A33A 54FA")))))
  3916. @end example
  3917. @noindent
  3918. You can save this to a file and feed it to @command{guix pull -C} on some
  3919. other machine or at a later point in time, which will instantiate @emph{this
  3920. exact Guix revision} (@pxref{Invoking guix pull, the @option{-C} option}).
  3921. From there on, since you're able to deploy the same revision of Guix, you can
  3922. just as well @emph{replicate a complete software environment}. We humbly
  3923. think that this is @emph{awesome}, and we hope you'll like it too!
  3924. The details of the options supported by @command{guix describe} are as
  3925. follows:
  3926. @table @code
  3927. @item --format=@var{format}
  3928. @itemx -f @var{format}
  3929. Produce output in the specified @var{format}, one of:
  3930. @table @code
  3931. @item human
  3932. produce human-readable output;
  3933. @item channels
  3934. produce a list of channel specifications that can be passed to @command{guix
  3935. pull -C} or installed as @file{~/.config/guix/channels.scm} (@pxref{Invoking
  3936. guix pull});
  3937. @item channels-sans-intro
  3938. like @code{channels}, but omit the @code{introduction} field; use it to
  3939. produce a channel specification suitable for Guix version 1.1.0 or
  3940. earlier---the @code{introduction} field has to do with channel
  3941. authentication (@pxref{Channels, Channel Authentication}) and is not
  3942. supported by these older versions;
  3943. @item json
  3944. @cindex JSON
  3945. produce a list of channel specifications in JSON format;
  3946. @item recutils
  3947. produce a list of channel specifications in Recutils format.
  3948. @end table
  3949. @item --list-formats
  3950. Display available formats for @option{--format} option.
  3951. @item --profile=@var{profile}
  3952. @itemx -p @var{profile}
  3953. Display information about @var{profile}.
  3954. @end table
  3955. @node Invoking guix archive
  3956. @section Invoking @command{guix archive}
  3957. @cindex @command{guix archive}
  3958. @cindex archive
  3959. The @command{guix archive} command allows users to @dfn{export} files
  3960. from the store into a single archive, and to later @dfn{import} them on
  3961. a machine that runs Guix.
  3962. In particular, it allows store files to be transferred from one machine
  3963. to the store on another machine.
  3964. @quotation Note
  3965. If you're looking for a way to produce archives in a format suitable for
  3966. tools other than Guix, @pxref{Invoking guix pack}.
  3967. @end quotation
  3968. @cindex exporting store items
  3969. To export store files as an archive to standard output, run:
  3970. @example
  3971. guix archive --export @var{options} @var{specifications}...
  3972. @end example
  3973. @var{specifications} may be either store file names or package
  3974. specifications, as for @command{guix package} (@pxref{Invoking guix
  3975. package}). For instance, the following command creates an archive
  3976. containing the @code{gui} output of the @code{git} package and the main
  3977. output of @code{emacs}:
  3978. @example
  3979. guix archive --export git:gui /gnu/store/...-emacs-24.3 > great.nar
  3980. @end example
  3981. If the specified packages are not built yet, @command{guix archive}
  3982. automatically builds them. The build process may be controlled with the
  3983. common build options (@pxref{Common Build Options}).
  3984. To transfer the @code{emacs} package to a machine connected over SSH,
  3985. one would run:
  3986. @example
  3987. guix archive --export -r emacs | ssh the-machine guix archive --import
  3988. @end example
  3989. @noindent
  3990. Similarly, a complete user profile may be transferred from one machine
  3991. to another like this:
  3992. @example
  3993. guix archive --export -r $(readlink -f ~/.guix-profile) | \
  3994. ssh the-machine guix archive --import
  3995. @end example
  3996. @noindent
  3997. However, note that, in both examples, all of @code{emacs} and the
  3998. profile as well as all of their dependencies are transferred (due to
  3999. @option{-r}), regardless of what is already available in the store on
  4000. the target machine. The @option{--missing} option can help figure out
  4001. which items are missing from the target store. The @command{guix copy}
  4002. command simplifies and optimizes this whole process, so this is probably
  4003. what you should use in this case (@pxref{Invoking guix copy}).
  4004. @cindex nar, archive format
  4005. @cindex normalized archive (nar)
  4006. @cindex nar bundle, archive format
  4007. Each store item is written in the @dfn{normalized archive} or @dfn{nar}
  4008. format (described below), and the output of @command{guix archive
  4009. --export} (and input of @command{guix archive --import}) is a @dfn{nar
  4010. bundle}.
  4011. The nar format is
  4012. comparable in spirit to `tar', but with differences
  4013. that make it more appropriate for our purposes. First, rather than
  4014. recording all Unix metadata for each file, the nar format only mentions
  4015. the file type (regular, directory, or symbolic link); Unix permissions
  4016. and owner/group are dismissed. Second, the order in which directory
  4017. entries are stored always follows the order of file names according to
  4018. the C locale collation order. This makes archive production fully
  4019. deterministic.
  4020. That nar bundle format is essentially the concatenation of zero or more
  4021. nars along with metadata for each store item it contains: its file name,
  4022. references, corresponding derivation, and a digital signature.
  4023. When exporting, the daemon digitally signs the contents of the archive,
  4024. and that digital signature is appended. When importing, the daemon
  4025. verifies the signature and rejects the import in case of an invalid
  4026. signature or if the signing key is not authorized.
  4027. @c FIXME: Add xref to daemon doc about signatures.
  4028. The main options are:
  4029. @table @code
  4030. @item --export
  4031. Export the specified store files or packages (see below). Write the
  4032. resulting archive to the standard output.
  4033. Dependencies are @emph{not} included in the output, unless
  4034. @option{--recursive} is passed.
  4035. @item -r
  4036. @itemx --recursive
  4037. When combined with @option{--export}, this instructs @command{guix archive}
  4038. to include dependencies of the given items in the archive. Thus, the
  4039. resulting archive is self-contained: it contains the closure of the
  4040. exported store items.
  4041. @item --import
  4042. Read an archive from the standard input, and import the files listed
  4043. therein into the store. Abort if the archive has an invalid digital
  4044. signature, or if it is signed by a public key not among the authorized
  4045. keys (see @option{--authorize} below).
  4046. @item --missing
  4047. Read a list of store file names from the standard input, one per line,
  4048. and write on the standard output the subset of these files missing from
  4049. the store.
  4050. @item --generate-key[=@var{parameters}]
  4051. @cindex signing, archives
  4052. Generate a new key pair for the daemon. This is a prerequisite before
  4053. archives can be exported with @option{--export}. This
  4054. operation is usually instantaneous but it can take time if the system's
  4055. entropy pool needs to be refilled. On Guix System,
  4056. @code{guix-service-type} takes care of generating this key pair the
  4057. first boot.
  4058. The generated key pair is typically stored under @file{/etc/guix}, in
  4059. @file{signing-key.pub} (public key) and @file{signing-key.sec} (private
  4060. key, which must be kept secret). When @var{parameters} is omitted,
  4061. an ECDSA key using the Ed25519 curve is generated, or, for Libgcrypt
  4062. versions before 1.6.0, it is a 4096-bit RSA key.
  4063. Alternatively, @var{parameters} can specify
  4064. @code{genkey} parameters suitable for Libgcrypt (@pxref{General
  4065. public-key related Functions, @code{gcry_pk_genkey},, gcrypt, The
  4066. Libgcrypt Reference Manual}).
  4067. @item --authorize
  4068. @cindex authorizing, archives
  4069. Authorize imports signed by the public key passed on standard input.
  4070. The public key must be in ``s-expression advanced format''---i.e., the
  4071. same format as the @file{signing-key.pub} file.
  4072. The list of authorized keys is kept in the human-editable file
  4073. @file{/etc/guix/acl}. The file contains
  4074. @url{https://people.csail.mit.edu/rivest/Sexp.txt, ``advanced-format
  4075. s-expressions''} and is structured as an access-control list in the
  4076. @url{https://theworld.com/~cme/spki.txt, Simple Public-Key Infrastructure
  4077. (SPKI)}.
  4078. @item --extract=@var{directory}
  4079. @itemx -x @var{directory}
  4080. Read a single-item archive as served by substitute servers
  4081. (@pxref{Substitutes}) and extract it to @var{directory}. This is a
  4082. low-level operation needed in only very narrow use cases; see below.
  4083. For example, the following command extracts the substitute for Emacs
  4084. served by @code{@value{SUBSTITUTE-SERVER-1}} to @file{/tmp/emacs}:
  4085. @example
  4086. $ wget -O - \
  4087. https://@value{SUBSTITUTE-SERVER-1}/nar/gzip/@dots{}-emacs-24.5 \
  4088. | gunzip | guix archive -x /tmp/emacs
  4089. @end example
  4090. Single-item archives are different from multiple-item archives produced
  4091. by @command{guix archive --export}; they contain a single store item,
  4092. and they do @emph{not} embed a signature. Thus this operation does
  4093. @emph{no} signature verification and its output should be considered
  4094. unsafe.
  4095. The primary purpose of this operation is to facilitate inspection of
  4096. archive contents coming from possibly untrusted substitute servers
  4097. (@pxref{Invoking guix challenge}).
  4098. @item --list
  4099. @itemx -t
  4100. Read a single-item archive as served by substitute servers
  4101. (@pxref{Substitutes}) and print the list of files it contains, as in
  4102. this example:
  4103. @example
  4104. $ wget -O - \
  4105. https://@value{SUBSTITUTE-SERVER-1}/nar/lzip/@dots{}-emacs-26.3 \
  4106. | lzip -d | guix archive -t
  4107. @end example
  4108. @end table
  4109. @c *********************************************************************
  4110. @node Channels
  4111. @chapter Channels
  4112. @cindex channels
  4113. @cindex @file{channels.scm}, configuration file
  4114. @cindex configuration file for channels
  4115. @cindex @command{guix pull}, configuration file
  4116. @cindex configuration of @command{guix pull}
  4117. Guix and its package collection are updated by running @command{guix pull}
  4118. (@pxref{Invoking guix pull}). By default @command{guix pull} downloads and
  4119. deploys Guix itself from the official GNU@tie{}Guix repository. This can be
  4120. customized by defining @dfn{channels} in the
  4121. @file{~/.config/guix/channels.scm} file. A channel specifies a URL and branch
  4122. of a Git repository to be deployed, and @command{guix pull} can be instructed
  4123. to pull from one or more channels. In other words, channels can be used
  4124. to @emph{customize} and to @emph{extend} Guix, as we will see below.
  4125. Guix is able to take into account security concerns and deal with authenticated
  4126. updates.
  4127. @menu
  4128. * Specifying Additional Channels:: Extending the package collection.
  4129. * Using a Custom Guix Channel:: Using a customized Guix.
  4130. * Replicating Guix:: Running the @emph{exact same} Guix.
  4131. * Channel Authentication:: How Guix verifies what it fetches.
  4132. * Channels with Substitutes:: Using channels with available substitutes.
  4133. * Creating a Channel:: How to write your custom channel.
  4134. * Package Modules in a Sub-directory:: Specifying the channel's package modules location.
  4135. * Declaring Channel Dependencies:: How to depend on other channels.
  4136. * Specifying Channel Authorizations:: Defining channel authors authorizations.
  4137. * Primary URL:: Distinguishing mirror to original.
  4138. * Writing Channel News:: Communicating information to channel's users.
  4139. @end menu
  4140. @node Specifying Additional Channels
  4141. @section Specifying Additional Channels
  4142. @cindex extending the package collection (channels)
  4143. @cindex variant packages (channels)
  4144. You can specify @emph{additional channels} to pull from. To use a channel, write
  4145. @code{~/.config/guix/channels.scm} to instruct @command{guix pull} to pull from it
  4146. @emph{in addition} to the default Guix channel(s):
  4147. @vindex %default-channels
  4148. @lisp
  4149. ;; Add variant packages to those Guix provides.
  4150. (cons (channel
  4151. (name 'variant-packages)
  4152. (url "https://example.org/variant-packages.git"))
  4153. %default-channels)
  4154. @end lisp
  4155. @noindent
  4156. Note that the snippet above is (as always!)@: Scheme code; we use @code{cons} to
  4157. add a channel the list of channels that the variable @code{%default-channels}
  4158. is bound to (@pxref{Pairs, @code{cons} and lists,, guile, GNU Guile Reference
  4159. Manual}). With this file in place, @command{guix pull} builds not only Guix
  4160. but also the package modules from your own repository. The result in
  4161. @file{~/.config/guix/current} is the union of Guix with your own package
  4162. modules:
  4163. @example
  4164. $ guix pull --list-generations
  4165. @dots{}
  4166. Generation 19 Aug 27 2018 16:20:48
  4167. guix d894ab8
  4168. repository URL: https://git.savannah.gnu.org/git/guix.git
  4169. branch: master
  4170. commit: d894ab8e9bfabcefa6c49d9ba2e834dd5a73a300
  4171. variant-packages dd3df5e
  4172. repository URL: https://example.org/variant-packages.git
  4173. branch: master
  4174. commit: dd3df5e2c8818760a8fc0bd699e55d3b69fef2bb
  4175. 11 new packages: variant-gimp, variant-emacs-with-cool-features, @dots{}
  4176. 4 packages upgraded: emacs-racket-mode@@0.0.2-2.1b78827, @dots{}
  4177. @end example
  4178. @noindent
  4179. The output of @command{guix pull} above shows that Generation@tie{}19 includes
  4180. both Guix and packages from the @code{variant-personal-packages} channel. Among
  4181. the new and upgraded packages that are listed, some like @code{variant-gimp} and
  4182. @code{variant-emacs-with-cool-features} might come from
  4183. @code{variant-packages}, while others come from the Guix default channel.
  4184. @node Using a Custom Guix Channel
  4185. @section Using a Custom Guix Channel
  4186. The channel called @code{guix} specifies where Guix itself---its command-line
  4187. tools as well as its package collection---should be downloaded. For instance,
  4188. suppose you want to update from another copy of the Guix repository at
  4189. @code{example.org}, and specifically the @code{super-hacks} branch, you can
  4190. write in @code{~/.config/guix/channels.scm} this specification:
  4191. @lisp
  4192. ;; Tell 'guix pull' to use another repo.
  4193. (list (channel
  4194. (name 'guix)
  4195. (url "https://example.org/another-guix.git")
  4196. (branch "super-hacks")))
  4197. @end lisp
  4198. @noindent
  4199. From there on, @command{guix pull} will fetch code from the @code{super-hacks}
  4200. branch of the repository at @code{example.org}. The authentication concern is
  4201. addressed below ((@pxref{Channel Authentication}).
  4202. @node Replicating Guix
  4203. @section Replicating Guix
  4204. @cindex pinning, channels
  4205. @cindex replicating Guix
  4206. @cindex reproducibility, of Guix
  4207. The @command{guix pull --list-generations} output above shows precisely which
  4208. commits were used to build this instance of Guix. We can thus replicate it,
  4209. say, on another machine, by providing a channel specification in
  4210. @file{~/.config/guix/channels.scm} that is ``pinned'' to these commits:
  4211. @lisp
  4212. ;; Deploy specific commits of my channels of interest.
  4213. (list (channel
  4214. (name 'guix)
  4215. (url "https://git.savannah.gnu.org/git/guix.git")
  4216. (commit "6298c3ffd9654d3231a6f25390b056483e8f407c"))
  4217. (channel
  4218. (name 'variant-packages)
  4219. (url "https://example.org/variant-packages.git")
  4220. (commit "dd3df5e2c8818760a8fc0bd699e55d3b69fef2bb")))
  4221. @end lisp
  4222. The @command{guix describe --format=channels} command can even generate this
  4223. list of channels directly (@pxref{Invoking guix describe}). The resulting
  4224. file can be used with the -C options of @command{guix pull}
  4225. (@pxref{Invoking guix pull}) or @command{guix time-machine}
  4226. (@pxref{Invoking guix time-machine}).
  4227. At this point the two machines run the @emph{exact same Guix}, with access to
  4228. the @emph{exact same packages}. The output of @command{guix build gimp} on
  4229. one machine will be exactly the same, bit for bit, as the output of the same
  4230. command on the other machine. It also means both machines have access to all
  4231. the source code of Guix and, transitively, to all the source code of every
  4232. package it defines.
  4233. This gives you super powers, allowing you to track the provenance of binary
  4234. artifacts with very fine grain, and to reproduce software environments at
  4235. will---some sort of ``meta reproducibility'' capabilities, if you will.
  4236. @xref{Inferiors}, for another way to take advantage of these super powers.
  4237. @node Channel Authentication
  4238. @section Channel Authentication
  4239. @anchor{channel-authentication}
  4240. @cindex authentication, of channel code
  4241. The @command{guix pull} and @command{guix time-machine} commands
  4242. @dfn{authenticate} the code retrieved from channels: they make sure each
  4243. commit that is fetched is signed by an authorized developer. The goal
  4244. is to protect from unauthorized modifications to the channel that would
  4245. lead users to run malicious code.
  4246. As a user, you must provide a @dfn{channel introduction} in your
  4247. channels file so that Guix knows how to authenticate its first commit.
  4248. A channel specification, including its introduction, looks something
  4249. along these lines:
  4250. @lisp
  4251. (channel
  4252. (name 'some-channel)
  4253. (url "https://example.org/some-channel.git")
  4254. (introduction
  4255. (make-channel-introduction
  4256. "6f0d8cc0d88abb59c324b2990bfee2876016bb86"
  4257. (openpgp-fingerprint
  4258. "CABB A931 C0FF EEC6 900D 0CFB 090B 1199 3D9A EBB5"))))
  4259. @end lisp
  4260. The specification above shows the name and URL of the channel. The call
  4261. to @code{make-channel-introduction} above specifies that authentication
  4262. of this channel starts at commit @code{6f0d8cc@dots{}}, which is signed
  4263. by the OpenPGP key with fingerprint @code{CABB A931@dots{}}.
  4264. For the main channel, called @code{guix}, you automatically get that
  4265. information from your Guix installation. For other channels, include
  4266. the channel introduction provided by the channel authors in your
  4267. @file{channels.scm} file. Make sure you retrieve the channel
  4268. introduction from a trusted source since that is the root of your trust.
  4269. If you're curious about the authentication mechanics, read on!
  4270. @node Channels with Substitutes
  4271. @section Channels with Substitutes
  4272. When running @command{guix pull}, Guix will first compile the
  4273. definitions of every available package. This is an expensive operation
  4274. for which substitutes (@pxref{Substitutes}) may be available. The
  4275. following snippet in @file{channels.scm} will ensure that @command{guix
  4276. pull} uses the latest commit with available substitutes for the package
  4277. definitions: this is done by querying the continuous integration
  4278. server at @url{https://ci.guix.gnu.org}.
  4279. @lisp
  4280. (use-modules (guix ci))
  4281. (list (channel-with-substitutes-available
  4282. %default-guix-channel
  4283. "https://ci.guix.gnu.org"))
  4284. @end lisp
  4285. Note that this does not mean that all the packages that you will
  4286. install after running @command{guix pull} will have available
  4287. substitutes. It only ensures that @command{guix pull} will not try to
  4288. compile package definitions. This is particularly useful when using
  4289. machines with limited resources.
  4290. @node Creating a Channel
  4291. @section Creating a Channel
  4292. @cindex personal packages (channels)
  4293. @cindex channels, for personal packages
  4294. Let's say you have a bunch of custom package variants or personal packages
  4295. that you think would make little sense to contribute to the Guix project, but
  4296. would like to have these packages transparently available to you at the
  4297. command line. You would first write modules containing those package
  4298. definitions (@pxref{Package Modules}), maintain them in a Git repository, and
  4299. then you and anyone else can use it as an additional channel to get packages
  4300. from. Neat, no?
  4301. @c What follows stems from discussions at
  4302. @c <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=22629#134> as well as
  4303. @c earlier discussions on guix-devel@gnu.org.
  4304. @quotation Warning
  4305. Before you, dear user, shout---``woow this is @emph{soooo coool}!''---and
  4306. publish your personal channel to the world, we would like to share a few words
  4307. of caution:
  4308. @itemize
  4309. @item
  4310. Before publishing a channel, please consider contributing your package
  4311. definitions to Guix proper (@pxref{Contributing}). Guix as a project is open
  4312. to free software of all sorts, and packages in Guix proper are readily
  4313. available to all Guix users and benefit from the project's quality assurance
  4314. process.
  4315. @item
  4316. When you maintain package definitions outside Guix, we, Guix developers,
  4317. consider that @emph{the compatibility burden is on you}. Remember that
  4318. package modules and package definitions are just Scheme code that uses various
  4319. programming interfaces (APIs). We want to remain free to change these APIs to
  4320. keep improving Guix, possibly in ways that break your channel. We never
  4321. change APIs gratuitously, but we will @emph{not} commit to freezing APIs
  4322. either.
  4323. @item
  4324. Corollary: if you're using an external channel and that channel breaks, please
  4325. @emph{report the issue to the channel authors}, not to the Guix project.
  4326. @end itemize
  4327. You've been warned! Having said this, we believe external channels are a
  4328. practical way to exert your freedom to augment Guix' package collection and to
  4329. share your improvements, which are basic tenets of
  4330. @uref{https://www.gnu.org/philosophy/free-sw.html, free software}. Please
  4331. email us at @email{guix-devel@@gnu.org} if you'd like to discuss this.
  4332. @end quotation
  4333. To create a channel, create a Git repository containing your own package
  4334. modules and make it available. The repository can contain anything, but a
  4335. useful channel will contain Guile modules that export packages. Once you
  4336. start using a channel, Guix will behave as if the root directory of that
  4337. channel's Git repository has been added to the Guile load path (@pxref{Load
  4338. Paths,,, guile, GNU Guile Reference Manual}). For example, if your channel
  4339. contains a file at @file{my-packages/my-tools.scm} that defines a Guile
  4340. module, then the module will be available under the name @code{(my-packages
  4341. my-tools)}, and you will be able to use it like any other module
  4342. (@pxref{Modules,,, guile, GNU Guile Reference Manual}).
  4343. As a channel author, consider bundling authentication material with your
  4344. channel so that users can authenticate it. @xref{Channel
  4345. Authentication}, and @ref{Specifying Channel Authorizations}, for info
  4346. on how to do it.
  4347. @node Package Modules in a Sub-directory
  4348. @section Package Modules in a Sub-directory
  4349. @cindex subdirectory, channels
  4350. As a channel author, you may want to keep your channel modules in a
  4351. sub-directory. If your modules are in the sub-directory @file{guix}, you must
  4352. add a meta-data file @file{.guix-channel} that contains:
  4353. @lisp
  4354. (channel
  4355. (version 0)
  4356. (directory "guix"))
  4357. @end lisp
  4358. @node Declaring Channel Dependencies
  4359. @section Declaring Channel Dependencies
  4360. @cindex dependencies, channels
  4361. @cindex meta-data, channels
  4362. Channel authors may decide to augment a package collection provided by other
  4363. channels. They can declare their channel to be dependent on other channels in
  4364. a meta-data file @file{.guix-channel}, which is to be placed in the root of
  4365. the channel repository.
  4366. The meta-data file should contain a simple S-expression like this:
  4367. @lisp
  4368. (channel
  4369. (version 0)
  4370. (dependencies
  4371. (channel
  4372. (name some-collection)
  4373. (url "https://example.org/first-collection.git")
  4374. ;; The 'introduction' bit below is optional: you would
  4375. ;; provide it for dependencies that can be authenticated.
  4376. (introduction
  4377. (channel-introduction
  4378. (version 0)
  4379. (commit "a8883b58dc82e167c96506cf05095f37c2c2c6cd")
  4380. (signer "CABB A931 C0FF EEC6 900D 0CFB 090B 1199 3D9A EBB5"))))
  4381. (channel
  4382. (name some-other-collection)
  4383. (url "https://example.org/second-collection.git")
  4384. (branch "testing"))))
  4385. @end lisp
  4386. In the above example this channel is declared to depend on two other channels,
  4387. which will both be fetched automatically. The modules provided by the channel
  4388. will be compiled in an environment where the modules of all these declared
  4389. channels are available.
  4390. For the sake of reliability and maintainability, you should avoid dependencies
  4391. on channels that you don't control, and you should aim to keep the number of
  4392. dependencies to a minimum.
  4393. @node Specifying Channel Authorizations
  4394. @section Specifying Channel Authorizations
  4395. @cindex channel authorizations
  4396. @anchor{channel-authorizations}
  4397. As we saw above, Guix ensures the source code it pulls from channels
  4398. comes from authorized developers. As a channel author, you need to
  4399. specify the list of authorized developers in the
  4400. @file{.guix-authorizations} file in the channel's Git repository. The
  4401. authentication rule is simple: each commit must be signed by a key
  4402. listed in the @file{.guix-authorizations} file of its parent
  4403. commit(s)@footnote{Git commits form a @dfn{directed acyclic graph}
  4404. (DAG). Each commit can have zero or more parents; ``regular'' commits
  4405. have one parent and merge commits have two parent commits. Read
  4406. @uref{https://eagain.net/articles/git-for-computer-scientists/, @i{Git
  4407. for Computer Scientists}} for a great overview.} The
  4408. @file{.guix-authorizations} file looks like this:
  4409. @lisp
  4410. ;; Example '.guix-authorizations' file.
  4411. (authorizations
  4412. (version 0) ;current file format version
  4413. (("AD17 A21E F8AE D8F1 CC02 DBD9 F8AE D8F1 765C 61E3"
  4414. (name "alice"))
  4415. ("2A39 3FFF 68F4 EF7A 3D29 12AF 68F4 EF7A 22FB B2D5"
  4416. (name "bob"))
  4417. ("CABB A931 C0FF EEC6 900D 0CFB 090B 1199 3D9A EBB5"
  4418. (name "charlie"))))
  4419. @end lisp
  4420. Each fingerprint is followed by optional key/value pairs, as in the
  4421. example above. Currently these key/value pairs are ignored.
  4422. This authentication rule creates a chicken-and-egg issue: how do we
  4423. authenticate the first commit? Related to that: how do we deal with
  4424. channels whose repository history contains unsigned commits and lack
  4425. @file{.guix-authorizations}? And how do we fork existing channels?
  4426. @cindex channel introduction
  4427. Channel introductions answer these questions by describing the first
  4428. commit of a channel that should be authenticated. The first time a
  4429. channel is fetched with @command{guix pull} or @command{guix
  4430. time-machine}, the command looks up the introductory commit and verifies
  4431. that it is signed by the specified OpenPGP key. From then on, it
  4432. authenticates commits according to the rule above. Authentication fails
  4433. if the target commit is neither a descendant nor an ancestor of the
  4434. introductory commit.
  4435. Additionally, your channel must provide all the OpenPGP keys that were
  4436. ever mentioned in @file{.guix-authorizations}, stored as @file{.key}
  4437. files, which can be either binary or ``ASCII-armored''. By default,
  4438. those @file{.key} files are searched for in the branch named
  4439. @code{keyring} but you can specify a different branch name in
  4440. @code{.guix-channel} like so:
  4441. @lisp
  4442. (channel
  4443. (version 0)
  4444. (keyring-reference "my-keyring-branch"))
  4445. @end lisp
  4446. To summarize, as the author of a channel, there are three things you have
  4447. to do to allow users to authenticate your code:
  4448. @enumerate
  4449. @item
  4450. Export the OpenPGP keys of past and present committers with @command{gpg
  4451. --export} and store them in @file{.key} files, by default in a branch
  4452. named @code{keyring} (we recommend making it an @dfn{orphan branch}).
  4453. @item
  4454. Introduce an initial @file{.guix-authorizations} in the channel's
  4455. repository. Do that in a signed commit (@pxref{Commit Access}, for
  4456. information on how to sign Git commits.)
  4457. @item
  4458. Advertise the channel introduction, for instance on your channel's web
  4459. page. The channel introduction, as we saw above, is the commit/key
  4460. pair---i.e., the commit that introduced @file{.guix-authorizations}, and
  4461. the fingerprint of the OpenPGP used to sign it.
  4462. @end enumerate
  4463. Before pushing to your public Git repository, you can run @command{guix
  4464. git-authenticate} to verify that you did sign all the commits you are
  4465. about to push with an authorized key:
  4466. @example
  4467. guix git authenticate @var{commit} @var{signer}
  4468. @end example
  4469. @noindent
  4470. where @var{commit} and @var{signer} are your channel introduction.
  4471. @xref{Invoking guix git authenticate}, for details.
  4472. Publishing a signed channel requires discipline: any mistake, such as an
  4473. unsigned commit or a commit signed by an unauthorized key, will prevent
  4474. users from pulling from your channel---well, that's the whole point of
  4475. authentication! Pay attention to merges in particular: merge commits
  4476. are considered authentic if and only if they are signed by a key present
  4477. in the @file{.guix-authorizations} file of @emph{both} branches.
  4478. @node Primary URL
  4479. @section Primary URL
  4480. @cindex primary URL, channels
  4481. Channel authors can indicate the primary URL of their channel's Git
  4482. repository in the @file{.guix-channel} file, like so:
  4483. @lisp
  4484. (channel
  4485. (version 0)
  4486. (url "https://example.org/guix.git"))
  4487. @end lisp
  4488. This allows @command{guix pull} to determine whether it is pulling code
  4489. from a mirror of the channel; when that is the case, it warns the user
  4490. that the mirror might be stale and displays the primary URL@. That way,
  4491. users cannot be tricked into fetching code from a stale mirror that does
  4492. not receive security updates.
  4493. This feature only makes sense for authenticated repositories, such as
  4494. the official @code{guix} channel, for which @command{guix pull} ensures
  4495. the code it fetches is authentic.
  4496. @node Writing Channel News
  4497. @section Writing Channel News
  4498. @cindex news, for channels
  4499. Channel authors may occasionally want to communicate to their users
  4500. information about important changes in the channel. You'd send them all
  4501. an email, but that's not convenient.
  4502. Instead, channels can provide a @dfn{news file}; when the channel users
  4503. run @command{guix pull}, that news file is automatically read and
  4504. @command{guix pull --news} can display the announcements that correspond
  4505. to the new commits that have been pulled, if any.
  4506. To do that, channel authors must first declare the name of the news file
  4507. in their @file{.guix-channel} file:
  4508. @lisp
  4509. (channel
  4510. (version 0)
  4511. (news-file "etc/news.txt"))
  4512. @end lisp
  4513. The news file itself, @file{etc/news.txt} in this example, must look
  4514. something like this:
  4515. @lisp
  4516. (channel-news
  4517. (version 0)
  4518. (entry (tag "the-bug-fix")
  4519. (title (en "Fixed terrible bug")
  4520. (fr "Oh la la"))
  4521. (body (en "@@emph@{Good news@}! It's fixed!")
  4522. (eo "Certe ĝi pli bone funkcias nun!")))
  4523. (entry (commit "bdcabe815cd28144a2d2b4bc3c5057b051fa9906")
  4524. (title (en "Added a great package")
  4525. (ca "Què vol dir guix?"))
  4526. (body (en "Don't miss the @@code@{hello@} package!"))))
  4527. @end lisp
  4528. While the news file is using the Scheme syntax, avoid naming it with a
  4529. @file{.scm} extension or else it will get picked up when building the
  4530. channel and yield an error since it is not a valid module.
  4531. Alternatively, you can move the channel module to a subdirectory and
  4532. store the news file in another directory.
  4533. The file consists of a list of @dfn{news entries}. Each entry is
  4534. associated with a commit or tag: it describes changes made in this
  4535. commit, possibly in preceding commits as well. Users see entries only
  4536. the first time they obtain the commit the entry refers to.
  4537. The @code{title} field should be a one-line summary while @code{body}
  4538. can be arbitrarily long, and both can contain Texinfo markup
  4539. (@pxref{Overview,,, texinfo, GNU Texinfo}). Both the title and body are
  4540. a list of language tag/message tuples, which allows @command{guix pull}
  4541. to display news in the language that corresponds to the user's locale.
  4542. If you want to translate news using a gettext-based workflow, you can
  4543. extract translatable strings with @command{xgettext} (@pxref{xgettext
  4544. Invocation,,, gettext, GNU Gettext Utilities}). For example, assuming
  4545. you write news entries in English first, the command below creates a PO
  4546. file containing the strings to translate:
  4547. @example
  4548. xgettext -o news.po -l scheme -ken etc/news.txt
  4549. @end example
  4550. To sum up, yes, you could use your channel as a blog. But beware, this
  4551. is @emph{not quite} what your users might expect.
  4552. @c *********************************************************************
  4553. @node Development
  4554. @chapter Development
  4555. @cindex software development
  4556. If you are a software developer, Guix provides tools that you should find
  4557. helpful---independently of the language you're developing in. This is what
  4558. this chapter is about.
  4559. The @command{guix shell} command provides a convenient way to set up
  4560. one-off software environments, be it for development purposes or to run
  4561. a command without installing it in your profile. The @command{guix
  4562. pack} command allows you to create @dfn{application bundles} that can be
  4563. easily distributed to users who do not run Guix.
  4564. @menu
  4565. * Invoking guix shell:: Spawning one-off software environments.
  4566. * Invoking guix environment:: Setting up development environments.
  4567. * Invoking guix pack:: Creating software bundles.
  4568. * The GCC toolchain:: Working with languages supported by GCC.
  4569. * Invoking guix git authenticate:: Authenticating Git repositories.
  4570. @end menu
  4571. @node Invoking guix shell
  4572. @section Invoking @command{guix shell}
  4573. @cindex reproducible build environments
  4574. @cindex development environments
  4575. @cindex @command{guix environment}
  4576. @cindex environment, package build environment
  4577. The purpose of @command{guix shell} is to make it easy to create one-off
  4578. software environments, without changing one's profile. It is typically
  4579. used to create development environments; it is also a convenient way to
  4580. run applications without ``polluting'' your profile.
  4581. @quotation Note
  4582. The @command{guix shell} command was recently introduced to supersede
  4583. @command{guix environment} (@pxref{Invoking guix environment}). If you
  4584. are familiar with @command{guix environment}, you will notice that it is
  4585. similar but also---we hope!---more convenient.
  4586. @end quotation
  4587. The general syntax is:
  4588. @example
  4589. guix shell [@var{options}] [@var{package}@dots{}]
  4590. @end example
  4591. The following example creates an environment containing Python and NumPy,
  4592. building or downloading any missing package, and runs the
  4593. @command{python3} command in that environment:
  4594. @example
  4595. guix shell python python-numpy -- python3
  4596. @end example
  4597. Development environments can be created as in the example below, which
  4598. spawns an interactive shell containing all the dependencies and
  4599. environment variables needed to work on Inkscape:
  4600. @example
  4601. guix shell --development inkscape
  4602. @end example
  4603. Exiting the shell places the user back in the original environment
  4604. before @command{guix shell} was invoked. The next garbage collection
  4605. (@pxref{Invoking guix gc}) may clean up packages that were installed in
  4606. the environment and that are no longer used outside of it.
  4607. As an added convenience, when running from a directory that contains a
  4608. @file{manifest.scm} or a @file{guix.scm} file (in this order), possibly
  4609. in a parent directory, @command{guix shell} automatically loads the
  4610. file---provided the directory is listed in
  4611. @file{~/.config/guix/shell-authorized-directories}, and only for
  4612. interactive use:
  4613. @example
  4614. guix shell
  4615. @end example
  4616. This provides an easy way to define, share, and enter development
  4617. environments.
  4618. By default, the shell session or command runs in an @emph{augmented}
  4619. environment, where the new packages are added to search path environment
  4620. variables such as @code{PATH}. You can, instead, choose to create an
  4621. @emph{isolated} environment containing nothing but the packages you
  4622. asked for. Passing the @option{--pure} option clears environment
  4623. variable definitions found in the parent environment@footnote{Be sure to
  4624. use the @option{--check} option the first time you use @command{guix
  4625. shell} interactively to make sure the shell does not undo the effect of
  4626. @option{--pure}.}; passing @option{--container} goes one step further by
  4627. spawning a @dfn{container} isolated from the rest of the system:
  4628. @example
  4629. guix shell --container emacs gcc-toolchain
  4630. @end example
  4631. The command above spawns an interactive shell in a container where
  4632. nothing but @code{emacs}, @code{gcc-toolchain}, and their dependencies
  4633. is available. The container lacks network access and shares no files
  4634. other than the current working directory with the surrounding
  4635. environment. This is useful to prevent access to system-wide resources
  4636. such as @file{/usr/bin} on foreign distros.
  4637. This @option{--container} option can also prove useful if you wish to
  4638. run a security-sensitive application, such as a web browser, in an
  4639. isolated environment. For example, the command below launches
  4640. Ungoogled-Chromium in an isolated environment, this time sharing network
  4641. access with the host and preserving its @code{DISPLAY} environment
  4642. variable, but without even sharing the current directory:
  4643. @example
  4644. guix shell --container --network --no-cwd ungoogled-chromium \
  4645. --preserve='^DISPLAY$' -- chromium
  4646. @end example
  4647. @vindex GUIX_ENVIRONMENT
  4648. @command{guix shell} defines the @env{GUIX_ENVIRONMENT}
  4649. variable in the shell it spawns; its value is the file name of the
  4650. profile of this environment. This allows users to, say, define a
  4651. specific prompt for development environments in their @file{.bashrc}
  4652. (@pxref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}):
  4653. @example
  4654. if [ -n "$GUIX_ENVIRONMENT" ]
  4655. then
  4656. export PS1="\u@@\h \w [dev]\$ "
  4657. fi
  4658. @end example
  4659. @noindent
  4660. ...@: or to browse the profile:
  4661. @example
  4662. $ ls "$GUIX_ENVIRONMENT/bin"
  4663. @end example
  4664. The available options are summarized below.
  4665. @table @code
  4666. @item --check
  4667. Set up the environment and check whether the shell would clobber
  4668. environment variables. It's a good idea to use this option the first
  4669. time you run @command{guix shell} for an interactive session to make
  4670. sure your setup is correct.
  4671. For example, if the shell modifies the @env{PATH} environment variable,
  4672. report it since you would get a different environment than what you
  4673. asked for.
  4674. Such problems usually indicate that the shell startup files are
  4675. unexpectedly modifying those environment variables. For example, if you
  4676. are using Bash, make sure that environment variables are set or modified
  4677. in @file{~/.bash_profile} and @emph{not} in @file{~/.bashrc}---the
  4678. former is sourced only by log-in shells. @xref{Bash Startup Files,,,
  4679. bash, The GNU Bash Reference Manual}, for details on Bash start-up
  4680. files.
  4681. @item --development
  4682. @itemx -D
  4683. Cause @command{guix shell} to include in the environment the
  4684. dependencies of the following package rather than the package itself.
  4685. This can be combined with other packages. For instance, the command
  4686. below starts an interactive shell containing the build-time dependencies
  4687. of GNU@tie{}Guile, plus Autoconf, Automake, and Libtool:
  4688. @example
  4689. guix shell -D guile autoconf automake libtool
  4690. @end example
  4691. @item --expression=@var{expr}
  4692. @itemx -e @var{expr}
  4693. Create an environment for the package or list of packages that
  4694. @var{expr} evaluates to.
  4695. For example, running:
  4696. @example
  4697. guix shell -D -e '(@@ (gnu packages maths) petsc-openmpi)'
  4698. @end example
  4699. starts a shell with the environment for this specific variant of the
  4700. PETSc package.
  4701. Running:
  4702. @example
  4703. guix shell -e '(@@ (gnu) %base-packages)'
  4704. @end example
  4705. starts a shell with all the base system packages available.
  4706. The above commands only use the default output of the given packages.
  4707. To select other outputs, two element tuples can be specified:
  4708. @example
  4709. guix shell -e '(list (@@ (gnu packages bash) bash) "include")'
  4710. @end example
  4711. @item --file=@var{file}
  4712. @itemx -f @var{file}
  4713. Create an environment containing the package or list of packages that
  4714. the code within @var{file} evaluates to.
  4715. As an example, @var{file} might contain a definition like this
  4716. (@pxref{Defining Packages}):
  4717. @lisp
  4718. @verbatiminclude environment-gdb.scm
  4719. @end lisp
  4720. With the file above, you can enter a development environment for GDB by
  4721. running:
  4722. @example
  4723. guix shell -D -f gdb-devel.scm
  4724. @end example
  4725. @item --manifest=@var{file}
  4726. @itemx -m @var{file}
  4727. Create an environment for the packages contained in the manifest object
  4728. returned by the Scheme code in @var{file}. This option can be repeated
  4729. several times, in which case the manifests are concatenated.
  4730. This is similar to the same-named option in @command{guix package}
  4731. (@pxref{profile-manifest, @option{--manifest}}) and uses the same
  4732. manifest files.
  4733. @item --profile=@var{profile}
  4734. @itemx -p @var{profile}
  4735. Create an environment containing the packages installed in @var{profile}.
  4736. Use @command{guix package} (@pxref{Invoking guix package}) to create
  4737. and manage profiles.
  4738. @item --pure
  4739. Unset existing environment variables when building the new environment, except
  4740. those specified with @option{--preserve} (see below). This has the effect of
  4741. creating an environment in which search paths only contain package inputs.
  4742. @item --preserve=@var{regexp}
  4743. @itemx -E @var{regexp}
  4744. When used alongside @option{--pure}, preserve the environment variables
  4745. matching @var{regexp}---in other words, put them on a ``white list'' of
  4746. environment variables that must be preserved. This option can be repeated
  4747. several times.
  4748. @example
  4749. guix shell --pure --preserve=^SLURM openmpi @dots{} \
  4750. -- mpirun @dots{}
  4751. @end example
  4752. This example runs @command{mpirun} in a context where the only environment
  4753. variables defined are @env{PATH}, environment variables whose name starts
  4754. with @samp{SLURM}, as well as the usual ``precious'' variables (@env{HOME},
  4755. @env{USER}, etc.).
  4756. @item --search-paths
  4757. Display the environment variable definitions that make up the
  4758. environment.
  4759. @item --system=@var{system}
  4760. @itemx -s @var{system}
  4761. Attempt to build for @var{system}---e.g., @code{i686-linux}.
  4762. @item --container
  4763. @itemx -C
  4764. @cindex container
  4765. Run @var{command} within an isolated container. The current working
  4766. directory outside the container is mapped inside the container.
  4767. Additionally, unless overridden with @option{--user}, a dummy home
  4768. directory is created that matches the current user's home directory, and
  4769. @file{/etc/passwd} is configured accordingly.
  4770. The spawned process runs as the current user outside the container. Inside
  4771. the container, it has the same UID and GID as the current user, unless
  4772. @option{--user} is passed (see below).
  4773. @item --network
  4774. @itemx -N
  4775. For containers, share the network namespace with the host system.
  4776. Containers created without this flag only have access to the loopback
  4777. device.
  4778. @item --link-profile
  4779. @itemx -P
  4780. For containers, link the environment profile to @file{~/.guix-profile}
  4781. within the container and set @code{GUIX_ENVIRONMENT} to that.
  4782. This is equivalent to making @file{~/.guix-profile} a symlink to the
  4783. actual profile within the container.
  4784. Linking will fail and abort the environment if the directory already
  4785. exists, which will certainly be the case if @command{guix shell}
  4786. was invoked in the user's home directory.
  4787. Certain packages are configured to look in @file{~/.guix-profile} for
  4788. configuration files and data;@footnote{For example, the
  4789. @code{fontconfig} package inspects @file{~/.guix-profile/share/fonts}
  4790. for additional fonts.} @option{--link-profile} allows these programs to
  4791. behave as expected within the environment.
  4792. @item --user=@var{user}
  4793. @itemx -u @var{user}
  4794. For containers, use the username @var{user} in place of the current
  4795. user. The generated @file{/etc/passwd} entry within the container will
  4796. contain the name @var{user}, the home directory will be
  4797. @file{/home/@var{user}}, and no user GECOS data will be copied. Furthermore,
  4798. the UID and GID inside the container are 1000. @var{user}
  4799. need not exist on the system.
  4800. Additionally, any shared or exposed path (see @option{--share} and
  4801. @option{--expose} respectively) whose target is within the current user's
  4802. home directory will be remapped relative to @file{/home/USER}; this
  4803. includes the automatic mapping of the current working directory.
  4804. @example
  4805. # will expose paths as /home/foo/wd, /home/foo/test, and /home/foo/target
  4806. cd $HOME/wd
  4807. guix shell --container --user=foo \
  4808. --expose=$HOME/test \
  4809. --expose=/tmp/target=$HOME/target
  4810. @end example
  4811. While this will limit the leaking of user identity through home paths
  4812. and each of the user fields, this is only one useful component of a
  4813. broader privacy/anonymity solution---not one in and of itself.
  4814. @item --no-cwd
  4815. For containers, the default behavior is to share the current working
  4816. directory with the isolated container and immediately change to that
  4817. directory within the container. If this is undesirable,
  4818. @option{--no-cwd} will cause the current working directory to @emph{not}
  4819. be automatically shared and will change to the user's home directory
  4820. within the container instead. See also @option{--user}.
  4821. @item --expose=@var{source}[=@var{target}]
  4822. @itemx --share=@var{source}[=@var{target}]
  4823. For containers, @option{--expose} (resp. @option{--share}) exposes the
  4824. file system @var{source} from the host system as the read-only
  4825. (resp. writable) file system @var{target} within the container. If
  4826. @var{target} is not specified, @var{source} is used as the target mount
  4827. point in the container.
  4828. The example below spawns a Guile REPL in a container in which the user's
  4829. home directory is accessible read-only via the @file{/exchange}
  4830. directory:
  4831. @example
  4832. guix shell --container --expose=$HOME=/exchange guile -- guile
  4833. @end example
  4834. @item --rebuild-cache
  4835. @cindex caching, of profiles
  4836. @cindex caching, in @command{guix shell}
  4837. In most cases, @command{guix shell} caches the environment so that
  4838. subsequent uses are instantaneous. Least-recently used cache entries
  4839. are periodically removed. The cache is also invalidated, when using
  4840. @option{--file} or @option{--manifest}, anytime the corresponding file
  4841. is modified.
  4842. The @option{--rebuild-cache} forces the cached environment to be
  4843. refreshed. This is useful when using @option{--file} or
  4844. @option{--manifest} and the @command{guix.scm} or @command{manifest.scm}
  4845. file has external dependencies, or if its behavior depends, say, on
  4846. environment variables.
  4847. @item --root=@var{file}
  4848. @itemx -r @var{file}
  4849. @cindex persistent environment
  4850. @cindex garbage collector root, for environments
  4851. Make @var{file} a symlink to the profile for this environment, and
  4852. register it as a garbage collector root.
  4853. This is useful if you want to protect your environment from garbage
  4854. collection, to make it ``persistent''.
  4855. When this option is omitted, @command{guix shell} caches profiles so
  4856. that subsequent uses of the same environment are instantaneous---this is
  4857. comparable to using @option{--root} except that @command{guix shell}
  4858. takes care of periodically removing the least-recently used garbage
  4859. collector roots.
  4860. In some cases, @command{guix shell} does not cache profiles---e.g., if
  4861. transformation options such as @option{--with-latest} are used. In
  4862. those cases, the environment is protected from garbage collection only
  4863. for the duration of the @command{guix shell} session. This means that
  4864. next time you recreate the same environment, you could have to rebuild
  4865. or re-download packages.
  4866. @xref{Invoking guix gc}, for more on GC roots.
  4867. @end table
  4868. @command{guix shell} also supports all of the common build options that
  4869. @command{guix build} supports (@pxref{Common Build Options}) as well as
  4870. package transformation options (@pxref{Package Transformation Options}).
  4871. @node Invoking guix environment
  4872. @section Invoking @command{guix environment}
  4873. The purpose of @command{guix environment} is to assist in creating
  4874. development environments.
  4875. @quotation Deprecation warning
  4876. The @command{guix environment} command is deprecated in favor of
  4877. @command{guix shell}, which performs similar functions but is more
  4878. convenient to use. @xref{Invoking guix shell}.
  4879. Being deprecated, @command{guix environment} is slated for eventual
  4880. removal, but the Guix project is committed to keeping it until May 1st,
  4881. 2023. Please get in touch with us at @email{guix-devel@@gnu.org} if you
  4882. would like to discuss it.
  4883. @end quotation
  4884. The general syntax is:
  4885. @example
  4886. guix environment @var{options} @var{package}@dots{}
  4887. @end example
  4888. The following example spawns a new shell set up for the development of
  4889. GNU@tie{}Guile:
  4890. @example
  4891. guix environment guile
  4892. @end example
  4893. If the needed dependencies are not built yet, @command{guix environment}
  4894. automatically builds them. The environment of the new shell is an
  4895. augmented version of the environment that @command{guix environment} was
  4896. run in. It contains the necessary search paths for building the given
  4897. package added to the existing environment variables. To create
  4898. a ``pure'' environment, in which the original environment variables have
  4899. been unset, use the @option{--pure} option@footnote{Users sometimes
  4900. wrongfully augment environment variables such as @env{PATH} in their
  4901. @file{~/.bashrc} file. As a consequence, when @command{guix
  4902. environment} launches it, Bash may read @file{~/.bashrc}, thereby
  4903. introducing ``impurities'' in these environment variables. It is an
  4904. error to define such environment variables in @file{.bashrc}; instead,
  4905. they should be defined in @file{.bash_profile}, which is sourced only by
  4906. log-in shells. @xref{Bash Startup Files,,, bash, The GNU Bash Reference
  4907. Manual}, for details on Bash start-up files.}.
  4908. Exiting from a Guix environment is the same as exiting from the shell,
  4909. and will place the user back in the old environment before @command{guix
  4910. environment} was invoked. The next garbage collection (@pxref{Invoking
  4911. guix gc}) will clean up packages that were installed from within the
  4912. environment and are no longer used outside of it.
  4913. @vindex GUIX_ENVIRONMENT
  4914. @command{guix environment} defines the @env{GUIX_ENVIRONMENT}
  4915. variable in the shell it spawns; its value is the file name of the
  4916. profile of this environment. This allows users to, say, define a
  4917. specific prompt for development environments in their @file{.bashrc}
  4918. (@pxref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}):
  4919. @example
  4920. if [ -n "$GUIX_ENVIRONMENT" ]
  4921. then
  4922. export PS1="\u@@\h \w [dev]\$ "
  4923. fi
  4924. @end example
  4925. @noindent
  4926. ...@: or to browse the profile:
  4927. @example
  4928. $ ls "$GUIX_ENVIRONMENT/bin"
  4929. @end example
  4930. Additionally, more than one package may be specified, in which case the
  4931. union of the inputs for the given packages are used. For example, the
  4932. command below spawns a shell where all of the dependencies of both Guile
  4933. and Emacs are available:
  4934. @example
  4935. guix environment guile emacs
  4936. @end example
  4937. Sometimes an interactive shell session is not desired. An arbitrary
  4938. command may be invoked by placing the @code{--} token to separate the
  4939. command from the rest of the arguments:
  4940. @example
  4941. guix environment guile -- make -j4
  4942. @end example
  4943. In other situations, it is more convenient to specify the list of
  4944. packages needed in the environment. For example, the following command
  4945. runs @command{python} from an environment containing Python@tie{}3 and
  4946. NumPy:
  4947. @example
  4948. guix environment --ad-hoc python-numpy python -- python3
  4949. @end example
  4950. Furthermore, one might want the dependencies of a package and also some
  4951. additional packages that are not build-time or runtime dependencies, but
  4952. are useful when developing nonetheless. Because of this, the
  4953. @option{--ad-hoc} flag is positional. Packages appearing before
  4954. @option{--ad-hoc} are interpreted as packages whose dependencies will be
  4955. added to the environment. Packages appearing after are interpreted as
  4956. packages that will be added to the environment directly. For example,
  4957. the following command creates a Guix development environment that
  4958. additionally includes Git and strace:
  4959. @example
  4960. guix environment --pure guix --ad-hoc git strace
  4961. @end example
  4962. @cindex container
  4963. Sometimes it is desirable to isolate the environment as much as
  4964. possible, for maximal purity and reproducibility. In particular, when
  4965. using Guix on a host distro that is not Guix System, it is desirable to
  4966. prevent access to @file{/usr/bin} and other system-wide resources from
  4967. the development environment. For example, the following command spawns
  4968. a Guile REPL in a ``container'' where only the store and the current
  4969. working directory are mounted:
  4970. @example
  4971. guix environment --ad-hoc --container guile -- guile
  4972. @end example
  4973. @quotation Note
  4974. The @option{--container} option requires Linux-libre 3.19 or newer.
  4975. @end quotation
  4976. @cindex certificates
  4977. Another typical use case for containers is to run security-sensitive
  4978. applications such as a web browser. To run Eolie, we must expose and
  4979. share some files and directories; we include @code{nss-certs} and expose
  4980. @file{/etc/ssl/certs/} for HTTPS authentication; finally we preserve the
  4981. @env{DISPLAY} environment variable since containerized graphical
  4982. applications won't display without it.
  4983. @example
  4984. guix environment --preserve='^DISPLAY$' --container --network \
  4985. --expose=/etc/machine-id \
  4986. --expose=/etc/ssl/certs/ \
  4987. --share=$HOME/.local/share/eolie/=$HOME/.local/share/eolie/ \
  4988. --ad-hoc eolie nss-certs dbus -- eolie
  4989. @end example
  4990. The available options are summarized below.
  4991. @table @code
  4992. @item --check
  4993. Set up the environment and check whether the shell would clobber
  4994. environment variables. @xref{Invoking guix shell, @option{--check}},
  4995. for more info.
  4996. @item --root=@var{file}
  4997. @itemx -r @var{file}
  4998. @cindex persistent environment
  4999. @cindex garbage collector root, for environments
  5000. Make @var{file} a symlink to the profile for this environment, and
  5001. register it as a garbage collector root.
  5002. This is useful if you want to protect your environment from garbage
  5003. collection, to make it ``persistent''.
  5004. When this option is omitted, the environment is protected from garbage
  5005. collection only for the duration of the @command{guix environment}
  5006. session. This means that next time you recreate the same environment,
  5007. you could have to rebuild or re-download packages. @xref{Invoking guix
  5008. gc}, for more on GC roots.
  5009. @item --expression=@var{expr}
  5010. @itemx -e @var{expr}
  5011. Create an environment for the package or list of packages that
  5012. @var{expr} evaluates to.
  5013. For example, running:
  5014. @example
  5015. guix environment -e '(@@ (gnu packages maths) petsc-openmpi)'
  5016. @end example
  5017. starts a shell with the environment for this specific variant of the
  5018. PETSc package.
  5019. Running:
  5020. @example
  5021. guix environment --ad-hoc -e '(@@ (gnu) %base-packages)'
  5022. @end example
  5023. starts a shell with all the base system packages available.
  5024. The above commands only use the default output of the given packages.
  5025. To select other outputs, two element tuples can be specified:
  5026. @example
  5027. guix environment --ad-hoc -e '(list (@@ (gnu packages bash) bash) "include")'
  5028. @end example
  5029. @item --load=@var{file}
  5030. @itemx -l @var{file}
  5031. Create an environment for the package or list of packages that the code
  5032. within @var{file} evaluates to.
  5033. As an example, @var{file} might contain a definition like this
  5034. (@pxref{Defining Packages}):
  5035. @lisp
  5036. @verbatiminclude environment-gdb.scm
  5037. @end lisp
  5038. @item --manifest=@var{file}
  5039. @itemx -m @var{file}
  5040. Create an environment for the packages contained in the manifest object
  5041. returned by the Scheme code in @var{file}. This option can be repeated
  5042. several times, in which case the manifests are concatenated.
  5043. This is similar to the same-named option in @command{guix package}
  5044. (@pxref{profile-manifest, @option{--manifest}}) and uses the same
  5045. manifest files.
  5046. @item --ad-hoc
  5047. Include all specified packages in the resulting environment, as if an
  5048. @i{ad hoc} package were defined with them as inputs. This option is
  5049. useful for quickly creating an environment without having to write a
  5050. package expression to contain the desired inputs.
  5051. For instance, the command:
  5052. @example
  5053. guix environment --ad-hoc guile guile-sdl -- guile
  5054. @end example
  5055. runs @command{guile} in an environment where Guile and Guile-SDL are
  5056. available.
  5057. Note that this example implicitly asks for the default output of
  5058. @code{guile} and @code{guile-sdl}, but it is possible to ask for a
  5059. specific output---e.g., @code{glib:bin} asks for the @code{bin} output
  5060. of @code{glib} (@pxref{Packages with Multiple Outputs}).
  5061. This option may be composed with the default behavior of @command{guix
  5062. environment}. Packages appearing before @option{--ad-hoc} are
  5063. interpreted as packages whose dependencies will be added to the
  5064. environment, the default behavior. Packages appearing after are
  5065. interpreted as packages that will be added to the environment directly.
  5066. @item --profile=@var{profile}
  5067. @itemx -p @var{profile}
  5068. Create an environment containing the packages installed in @var{profile}.
  5069. Use @command{guix package} (@pxref{Invoking guix package}) to create
  5070. and manage profiles.
  5071. @item --pure
  5072. Unset existing environment variables when building the new environment, except
  5073. those specified with @option{--preserve} (see below). This has the effect of
  5074. creating an environment in which search paths only contain package inputs.
  5075. @item --preserve=@var{regexp}
  5076. @itemx -E @var{regexp}
  5077. When used alongside @option{--pure}, preserve the environment variables
  5078. matching @var{regexp}---in other words, put them on a ``white list'' of
  5079. environment variables that must be preserved. This option can be repeated
  5080. several times.
  5081. @example
  5082. guix environment --pure --preserve=^SLURM --ad-hoc openmpi @dots{} \
  5083. -- mpirun @dots{}
  5084. @end example
  5085. This example runs @command{mpirun} in a context where the only environment
  5086. variables defined are @env{PATH}, environment variables whose name starts
  5087. with @samp{SLURM}, as well as the usual ``precious'' variables (@env{HOME},
  5088. @env{USER}, etc.).
  5089. @item --search-paths
  5090. Display the environment variable definitions that make up the
  5091. environment.
  5092. @item --system=@var{system}
  5093. @itemx -s @var{system}
  5094. Attempt to build for @var{system}---e.g., @code{i686-linux}.
  5095. @item --container
  5096. @itemx -C
  5097. @cindex container
  5098. Run @var{command} within an isolated container. The current working
  5099. directory outside the container is mapped inside the container.
  5100. Additionally, unless overridden with @option{--user}, a dummy home
  5101. directory is created that matches the current user's home directory, and
  5102. @file{/etc/passwd} is configured accordingly.
  5103. The spawned process runs as the current user outside the container. Inside
  5104. the container, it has the same UID and GID as the current user, unless
  5105. @option{--user} is passed (see below).
  5106. @item --network
  5107. @itemx -N
  5108. For containers, share the network namespace with the host system.
  5109. Containers created without this flag only have access to the loopback
  5110. device.
  5111. @item --link-profile
  5112. @itemx -P
  5113. For containers, link the environment profile to @file{~/.guix-profile}
  5114. within the container and set @code{GUIX_ENVIRONMENT} to that.
  5115. This is equivalent to making @file{~/.guix-profile} a symlink to the
  5116. actual profile within the container.
  5117. Linking will fail and abort the environment if the directory already
  5118. exists, which will certainly be the case if @command{guix environment}
  5119. was invoked in the user's home directory.
  5120. Certain packages are configured to look in @file{~/.guix-profile} for
  5121. configuration files and data;@footnote{For example, the
  5122. @code{fontconfig} package inspects @file{~/.guix-profile/share/fonts}
  5123. for additional fonts.} @option{--link-profile} allows these programs to
  5124. behave as expected within the environment.
  5125. @item --user=@var{user}
  5126. @itemx -u @var{user}
  5127. For containers, use the username @var{user} in place of the current
  5128. user. The generated @file{/etc/passwd} entry within the container will
  5129. contain the name @var{user}, the home directory will be
  5130. @file{/home/@var{user}}, and no user GECOS data will be copied. Furthermore,
  5131. the UID and GID inside the container are 1000. @var{user}
  5132. need not exist on the system.
  5133. Additionally, any shared or exposed path (see @option{--share} and
  5134. @option{--expose} respectively) whose target is within the current user's
  5135. home directory will be remapped relative to @file{/home/USER}; this
  5136. includes the automatic mapping of the current working directory.
  5137. @example
  5138. # will expose paths as /home/foo/wd, /home/foo/test, and /home/foo/target
  5139. cd $HOME/wd
  5140. guix environment --container --user=foo \
  5141. --expose=$HOME/test \
  5142. --expose=/tmp/target=$HOME/target
  5143. @end example
  5144. While this will limit the leaking of user identity through home paths
  5145. and each of the user fields, this is only one useful component of a
  5146. broader privacy/anonymity solution---not one in and of itself.
  5147. @item --no-cwd
  5148. For containers, the default behavior is to share the current working
  5149. directory with the isolated container and immediately change to that
  5150. directory within the container. If this is undesirable,
  5151. @option{--no-cwd} will cause the current working directory to @emph{not}
  5152. be automatically shared and will change to the user's home directory
  5153. within the container instead. See also @option{--user}.
  5154. @item --expose=@var{source}[=@var{target}]
  5155. @itemx --share=@var{source}[=@var{target}]
  5156. For containers, @option{--expose} (resp. @option{--share}) exposes the
  5157. file system @var{source} from the host system as the read-only
  5158. (resp. writable) file system @var{target} within the container. If
  5159. @var{target} is not specified, @var{source} is used as the target mount
  5160. point in the container.
  5161. The example below spawns a Guile REPL in a container in which the user's
  5162. home directory is accessible read-only via the @file{/exchange}
  5163. directory:
  5164. @example
  5165. guix environment --container --expose=$HOME=/exchange --ad-hoc guile -- guile
  5166. @end example
  5167. @end table
  5168. @command{guix environment}
  5169. also supports all of the common build options that @command{guix
  5170. build} supports (@pxref{Common Build Options}) as well as package
  5171. transformation options (@pxref{Package Transformation Options}).
  5172. @node Invoking guix pack
  5173. @section Invoking @command{guix pack}
  5174. Occasionally you want to pass software to people who are not (yet!)
  5175. lucky enough to be using Guix. You'd tell them to run @command{guix
  5176. package -i @var{something}}, but that's not possible in this case. This
  5177. is where @command{guix pack} comes in.
  5178. @quotation Note
  5179. If you are looking for ways to exchange binaries among machines that
  5180. already run Guix, @pxref{Invoking guix copy}, @ref{Invoking guix
  5181. publish}, and @ref{Invoking guix archive}.
  5182. @end quotation
  5183. @cindex pack
  5184. @cindex bundle
  5185. @cindex application bundle
  5186. @cindex software bundle
  5187. The @command{guix pack} command creates a shrink-wrapped @dfn{pack} or
  5188. @dfn{software bundle}: it creates a tarball or some other archive
  5189. containing the binaries of the software you're interested in, and all
  5190. its dependencies. The resulting archive can be used on any machine that
  5191. does not have Guix, and people can run the exact same binaries as those
  5192. you have with Guix. The pack itself is created in a bit-reproducible
  5193. fashion, so anyone can verify that it really contains the build results
  5194. that you pretend to be shipping.
  5195. For example, to create a bundle containing Guile, Emacs, Geiser, and all
  5196. their dependencies, you can run:
  5197. @example
  5198. $ guix pack guile emacs emacs-geiser
  5199. @dots{}
  5200. /gnu/store/@dots{}-pack.tar.gz
  5201. @end example
  5202. The result here is a tarball containing a @file{/gnu/store} directory
  5203. with all the relevant packages. The resulting tarball contains a
  5204. @dfn{profile} with the three packages of interest; the profile is the
  5205. same as would be created by @command{guix package -i}. It is this
  5206. mechanism that is used to create Guix's own standalone binary tarball
  5207. (@pxref{Binary Installation}).
  5208. Users of this pack would have to run
  5209. @file{/gnu/store/@dots{}-profile/bin/guile} to run Guile, which you may
  5210. find inconvenient. To work around it, you can create, say, a
  5211. @file{/opt/gnu/bin} symlink to the profile:
  5212. @example
  5213. guix pack -S /opt/gnu/bin=bin guile emacs emacs-geiser
  5214. @end example
  5215. @noindent
  5216. That way, users can happily type @file{/opt/gnu/bin/guile} and enjoy.
  5217. @cindex relocatable binaries, with @command{guix pack}
  5218. What if the recipient of your pack does not have root privileges on
  5219. their machine, and thus cannot unpack it in the root file system? In
  5220. that case, you will want to use the @option{--relocatable} option (see
  5221. below). This option produces @dfn{relocatable binaries}, meaning they
  5222. they can be placed anywhere in the file system hierarchy: in the example
  5223. above, users can unpack your tarball in their home directory and
  5224. directly run @file{./opt/gnu/bin/guile}.
  5225. @cindex Docker, build an image with guix pack
  5226. Alternatively, you can produce a pack in the Docker image format using
  5227. the following command:
  5228. @example
  5229. guix pack -f docker -S /bin=bin guile guile-readline
  5230. @end example
  5231. @noindent
  5232. The result is a tarball that can be passed to the @command{docker load}
  5233. command, followed by @code{docker run}:
  5234. @example
  5235. docker load < @var{file}
  5236. docker run -ti guile-guile-readline /bin/guile
  5237. @end example
  5238. @noindent
  5239. where @var{file} is the image returned by @var{guix pack}, and
  5240. @code{guile-guile-readline} is its ``image tag''. See the
  5241. @uref{https://docs.docker.com/engine/reference/commandline/load/, Docker
  5242. documentation} for more information.
  5243. @cindex Singularity, build an image with guix pack
  5244. @cindex SquashFS, build an image with guix pack
  5245. Yet another option is to produce a SquashFS image with the following
  5246. command:
  5247. @example
  5248. guix pack -f squashfs bash guile emacs emacs-geiser
  5249. @end example
  5250. @noindent
  5251. The result is a SquashFS file system image that can either be mounted or
  5252. directly be used as a file system container image with the
  5253. @uref{https://www.sylabs.io/docs/, Singularity container execution
  5254. environment}, using commands like @command{singularity shell} or
  5255. @command{singularity exec}.
  5256. Several command-line options allow you to customize your pack:
  5257. @table @code
  5258. @item --format=@var{format}
  5259. @itemx -f @var{format}
  5260. Produce a pack in the given @var{format}.
  5261. The available formats are:
  5262. @table @code
  5263. @item tarball
  5264. This is the default format. It produces a tarball containing all the
  5265. specified binaries and symlinks.
  5266. @item docker
  5267. This produces a tarball that follows the
  5268. @uref{https://github.com/docker/docker/blob/master/image/spec/v1.2.md,
  5269. Docker Image Specification}. The ``repository name'' as it appears in
  5270. the output of the @command{docker images} command is computed from
  5271. package names passed on the command line or in the manifest file.
  5272. @item squashfs
  5273. This produces a SquashFS image containing all the specified binaries and
  5274. symlinks, as well as empty mount points for virtual file systems like
  5275. procfs.
  5276. @quotation Note
  5277. Singularity @emph{requires} you to provide @file{/bin/sh} in the image.
  5278. For that reason, @command{guix pack -f squashfs} always implies @code{-S
  5279. /bin=bin}. Thus, your @command{guix pack} invocation must always start
  5280. with something like:
  5281. @example
  5282. guix pack -f squashfs bash @dots{}
  5283. @end example
  5284. If you forget the @code{bash} (or similar) package, @command{singularity
  5285. run} and @command{singularity exec} will fail with an unhelpful ``no
  5286. such file or directory'' message.
  5287. @end quotation
  5288. @item deb
  5289. This produces a Debian archive (a package with the @samp{.deb} file
  5290. extension) containing all the specified binaries and symbolic links,
  5291. that can be installed on top of any dpkg-based GNU(/Linux) distribution.
  5292. Advanced options can be revealed via the @option{--help-deb-format}
  5293. option. They allow embedding control files for more fine-grained
  5294. control, such as activating specific triggers or providing a maintainer
  5295. configure script to run arbitrary setup code upon installation.
  5296. @example
  5297. guix pack -f deb -C xz -S /usr/bin/hello=bin/hello hello
  5298. @end example
  5299. @quotation Note
  5300. Because archives produced with @command{guix pack} contain a collection
  5301. of store items and because each @command{dpkg} package must not have
  5302. conflicting files, in practice that means you likely won't be able to
  5303. install more than one such archive on a given system.
  5304. @end quotation
  5305. @quotation Warning
  5306. @command{dpkg} will assume ownership of any files contained in the pack
  5307. that it does @emph{not} know about. It is unwise to install
  5308. Guix-produced @samp{.deb} files on a system where @file{/gnu/store} is
  5309. shared by other software, such as a Guix installation or other, non-deb
  5310. packs.
  5311. @end quotation
  5312. @end table
  5313. @cindex relocatable binaries
  5314. @item --relocatable
  5315. @itemx -R
  5316. Produce @dfn{relocatable binaries}---i.e., binaries that can be placed
  5317. anywhere in the file system hierarchy and run from there.
  5318. When this option is passed once, the resulting binaries require support for
  5319. @dfn{user namespaces} in the kernel Linux; when passed
  5320. @emph{twice}@footnote{Here's a trick to memorize it: @code{-RR}, which adds
  5321. PRoot support, can be thought of as the abbreviation of ``Really
  5322. Relocatable''. Neat, isn't it?}, relocatable binaries fall to back to
  5323. other techniques if user namespaces are unavailable, and essentially
  5324. work anywhere---see below for the implications.
  5325. For example, if you create a pack containing Bash with:
  5326. @example
  5327. guix pack -RR -S /mybin=bin bash
  5328. @end example
  5329. @noindent
  5330. ...@: you can copy that pack to a machine that lacks Guix, and from your
  5331. home directory as a normal user, run:
  5332. @example
  5333. tar xf pack.tar.gz
  5334. ./mybin/sh
  5335. @end example
  5336. @noindent
  5337. In that shell, if you type @code{ls /gnu/store}, you'll notice that
  5338. @file{/gnu/store} shows up and contains all the dependencies of
  5339. @code{bash}, even though the machine actually lacks @file{/gnu/store}
  5340. altogether! That is probably the simplest way to deploy Guix-built
  5341. software on a non-Guix machine.
  5342. @quotation Note
  5343. By default, relocatable binaries rely on the @dfn{user namespace} feature of
  5344. the kernel Linux, which allows unprivileged users to mount or change root.
  5345. Old versions of Linux did not support it, and some GNU/Linux distributions
  5346. turn it off.
  5347. To produce relocatable binaries that work even in the absence of user
  5348. namespaces, pass @option{--relocatable} or @option{-R} @emph{twice}. In that
  5349. case, binaries will try user namespace support and fall back to another
  5350. @dfn{execution engine} if user namespaces are not supported. The
  5351. following execution engines are supported:
  5352. @table @code
  5353. @item default
  5354. Try user namespaces and fall back to PRoot if user namespaces are not
  5355. supported (see below).
  5356. @item performance
  5357. Try user namespaces and fall back to Fakechroot if user namespaces are
  5358. not supported (see below).
  5359. @item userns
  5360. Run the program through user namespaces and abort if they are not
  5361. supported.
  5362. @item proot
  5363. Run through PRoot. The @uref{https://proot-me.github.io/, PRoot} program
  5364. provides the necessary
  5365. support for file system virtualization. It achieves that by using the
  5366. @code{ptrace} system call on the running program. This approach has the
  5367. advantage to work without requiring special kernel support, but it incurs
  5368. run-time overhead every time a system call is made.
  5369. @item fakechroot
  5370. Run through Fakechroot. @uref{https://github.com/dex4er/fakechroot/,
  5371. Fakechroot} virtualizes file system accesses by intercepting calls to C
  5372. library functions such as @code{open}, @code{stat}, @code{exec}, and so
  5373. on. Unlike PRoot, it incurs very little overhead. However, it does not
  5374. always work: for example, some file system accesses made from within the
  5375. C library are not intercepted, and file system accesses made @i{via}
  5376. direct syscalls are not intercepted either, leading to erratic behavior.
  5377. @end table
  5378. @vindex GUIX_EXECUTION_ENGINE
  5379. When running a wrapped program, you can explicitly request one of the
  5380. execution engines listed above by setting the
  5381. @env{GUIX_EXECUTION_ENGINE} environment variable accordingly.
  5382. @end quotation
  5383. @cindex entry point, for Docker images
  5384. @item --entry-point=@var{command}
  5385. Use @var{command} as the @dfn{entry point} of the resulting pack, if the pack
  5386. format supports it---currently @code{docker} and @code{squashfs} (Singularity)
  5387. support it. @var{command} must be relative to the profile contained in the
  5388. pack.
  5389. The entry point specifies the command that tools like @code{docker run} or
  5390. @code{singularity run} automatically start by default. For example, you can
  5391. do:
  5392. @example
  5393. guix pack -f docker --entry-point=bin/guile guile
  5394. @end example
  5395. The resulting pack can easily be loaded and @code{docker run} with no extra
  5396. arguments will spawn @code{bin/guile}:
  5397. @example
  5398. docker load -i pack.tar.gz
  5399. docker run @var{image-id}
  5400. @end example
  5401. @item --expression=@var{expr}
  5402. @itemx -e @var{expr}
  5403. Consider the package @var{expr} evaluates to.
  5404. This has the same purpose as the same-named option in @command{guix
  5405. build} (@pxref{Additional Build Options, @option{--expression} in
  5406. @command{guix build}}).
  5407. @item --manifest=@var{file}
  5408. @itemx -m @var{file}
  5409. Use the packages contained in the manifest object returned by the Scheme
  5410. code in @var{file}. This option can be repeated several times, in which
  5411. case the manifests are concatenated.
  5412. This has a similar purpose as the same-named option in @command{guix
  5413. package} (@pxref{profile-manifest, @option{--manifest}}) and uses the
  5414. same manifest files. It allows you to define a collection of packages
  5415. once and use it both for creating profiles and for creating archives
  5416. for use on machines that do not have Guix installed. Note that you can
  5417. specify @emph{either} a manifest file @emph{or} a list of packages,
  5418. but not both.
  5419. @item --system=@var{system}
  5420. @itemx -s @var{system}
  5421. Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
  5422. the system type of the build host.
  5423. @item --target=@var{triplet}
  5424. @cindex cross-compilation
  5425. Cross-build for @var{triplet}, which must be a valid GNU triplet, such
  5426. as @code{"aarch64-linux-gnu"} (@pxref{Specifying target triplets, GNU
  5427. configuration triplets,, autoconf, Autoconf}).
  5428. @item --compression=@var{tool}
  5429. @itemx -C @var{tool}
  5430. Compress the resulting tarball using @var{tool}---one of @code{gzip},
  5431. @code{zstd}, @code{bzip2}, @code{xz}, @code{lzip}, or @code{none} for no
  5432. compression.
  5433. @item --symlink=@var{spec}
  5434. @itemx -S @var{spec}
  5435. Add the symlinks specified by @var{spec} to the pack. This option can
  5436. appear several times.
  5437. @var{spec} has the form @code{@var{source}=@var{target}}, where
  5438. @var{source} is the symlink that will be created and @var{target} is the
  5439. symlink target.
  5440. For instance, @code{-S /opt/gnu/bin=bin} creates a @file{/opt/gnu/bin}
  5441. symlink pointing to the @file{bin} sub-directory of the profile.
  5442. @item --save-provenance
  5443. Save provenance information for the packages passed on the command line.
  5444. Provenance information includes the URL and commit of the channels in use
  5445. (@pxref{Channels}).
  5446. Provenance information is saved in the
  5447. @file{/gnu/store/@dots{}-profile/manifest} file in the pack, along with the
  5448. usual package metadata---the name and version of each package, their
  5449. propagated inputs, and so on. It is useful information to the recipient of
  5450. the pack, who then knows how the pack was (supposedly) obtained.
  5451. This option is not enabled by default because, like timestamps, provenance
  5452. information contributes nothing to the build process. In other words, there
  5453. is an infinity of channel URLs and commit IDs that can lead to the same pack.
  5454. Recording such ``silent'' metadata in the output thus potentially breaks the
  5455. source-to-binary bitwise reproducibility property.
  5456. @item --root=@var{file}
  5457. @itemx -r @var{file}
  5458. @cindex garbage collector root, for packs
  5459. Make @var{file} a symlink to the resulting pack, and register it as a garbage
  5460. collector root.
  5461. @item --localstatedir
  5462. @itemx --profile-name=@var{name}
  5463. Include the ``local state directory'', @file{/var/guix}, in the resulting
  5464. pack, and notably the @file{/var/guix/profiles/per-user/root/@var{name}}
  5465. profile---by default @var{name} is @code{guix-profile}, which corresponds to
  5466. @file{~root/.guix-profile}.
  5467. @file{/var/guix} contains the store database (@pxref{The Store}) as well
  5468. as garbage-collector roots (@pxref{Invoking guix gc}). Providing it in
  5469. the pack means that the store is ``complete'' and manageable by Guix;
  5470. not providing it pack means that the store is ``dead'': items cannot be
  5471. added to it or removed from it after extraction of the pack.
  5472. One use case for this is the Guix self-contained binary tarball
  5473. (@pxref{Binary Installation}).
  5474. @item --derivation
  5475. @itemx -d
  5476. Print the name of the derivation that builds the pack.
  5477. @item --bootstrap
  5478. Use the bootstrap binaries to build the pack. This option is only
  5479. useful to Guix developers.
  5480. @end table
  5481. In addition, @command{guix pack} supports all the common build options
  5482. (@pxref{Common Build Options}) and all the package transformation
  5483. options (@pxref{Package Transformation Options}).
  5484. @node The GCC toolchain
  5485. @section The GCC toolchain
  5486. @cindex GCC
  5487. @cindex ld-wrapper
  5488. @cindex linker wrapper
  5489. @cindex toolchain, for C development
  5490. @cindex toolchain, for Fortran development
  5491. If you need a complete toolchain for compiling and linking C or C++
  5492. source code, use the @code{gcc-toolchain} package. This package
  5493. provides a complete GCC toolchain for C/C++ development, including GCC
  5494. itself, the GNU C Library (headers and binaries, plus debugging symbols
  5495. in the @code{debug} output), Binutils, and a linker wrapper.
  5496. The wrapper's purpose is to inspect the @code{-L} and @code{-l} switches
  5497. passed to the linker, add corresponding @code{-rpath} arguments, and
  5498. invoke the actual linker with this new set of arguments. You can instruct the
  5499. wrapper to refuse to link against libraries not in the store by setting the
  5500. @env{GUIX_LD_WRAPPER_ALLOW_IMPURITIES} environment variable to @code{no}.
  5501. The package @code{gfortran-toolchain} provides a complete GCC toolchain
  5502. for Fortran development. For other languages, please use
  5503. @samp{guix search gcc toolchain} (@pxref{guix-search,, Invoking guix package}).
  5504. @node Invoking guix git authenticate
  5505. @section Invoking @command{guix git authenticate}
  5506. The @command{guix git authenticate} command authenticates a Git checkout
  5507. following the same rule as for channels (@pxref{channel-authentication,
  5508. channel authentication}). That is, starting from a given commit, it
  5509. ensures that all subsequent commits are signed by an OpenPGP key whose
  5510. fingerprint appears in the @file{.guix-authorizations} file of its
  5511. parent commit(s).
  5512. You will find this command useful if you maintain a channel. But in
  5513. fact, this authentication mechanism is useful in a broader context, so
  5514. you might want to use it for Git repositories that have nothing to do
  5515. with Guix.
  5516. The general syntax is:
  5517. @example
  5518. guix git authenticate @var{commit} @var{signer} [@var{options}@dots{}]
  5519. @end example
  5520. By default, this command authenticates the Git checkout in the current
  5521. directory; it outputs nothing and exits with exit code zero on success
  5522. and non-zero on failure. @var{commit} above denotes the first commit
  5523. where authentication takes place, and @var{signer} is the OpenPGP
  5524. fingerprint of public key used to sign @var{commit}. Together, they
  5525. form a ``channel introduction'' (@pxref{channel-authentication, channel
  5526. introduction}). The options below allow you to fine-tune the process.
  5527. @table @code
  5528. @item --repository=@var{directory}
  5529. @itemx -r @var{directory}
  5530. Open the Git repository in @var{directory} instead of the current
  5531. directory.
  5532. @item --keyring=@var{reference}
  5533. @itemx -k @var{reference}
  5534. Load OpenPGP keyring from @var{reference}, the reference of a branch
  5535. such as @code{origin/keyring} or @code{my-keyring}. The branch must
  5536. contain OpenPGP public keys in @file{.key} files, either in binary form
  5537. or ``ASCII-armored''. By default the keyring is loaded from the branch
  5538. named @code{keyring}.
  5539. @item --stats
  5540. Display commit signing statistics upon completion.
  5541. @item --cache-key=@var{key}
  5542. Previously-authenticated commits are cached in a file under
  5543. @file{~/.cache/guix/authentication}. This option forces the cache to be
  5544. stored in file @var{key} in that directory.
  5545. @item --historical-authorizations=@var{file}
  5546. By default, any commit whose parent commit(s) lack the
  5547. @file{.guix-authorizations} file is considered inauthentic. In
  5548. contrast, this option considers the authorizations in @var{file} for any
  5549. commit that lacks @file{.guix-authorizations}. The format of @var{file}
  5550. is the same as that of @file{.guix-authorizations}
  5551. (@pxref{channel-authorizations, @file{.guix-authorizations} format}).
  5552. @end table
  5553. @c *********************************************************************
  5554. @node Programming Interface
  5555. @chapter Programming Interface
  5556. GNU Guix provides several Scheme programming interfaces (APIs) to
  5557. define, build, and query packages. The first interface allows users to
  5558. write high-level package definitions. These definitions refer to
  5559. familiar packaging concepts, such as the name and version of a package,
  5560. its build system, and its dependencies. These definitions can then be
  5561. turned into concrete build actions.
  5562. Build actions are performed by the Guix daemon, on behalf of users. In a
  5563. standard setup, the daemon has write access to the store---the
  5564. @file{/gnu/store} directory---whereas users do not. The recommended
  5565. setup also has the daemon perform builds in chroots, under specific
  5566. build users, to minimize interference with the rest of the system.
  5567. @cindex derivation
  5568. Lower-level APIs are available to interact with the daemon and the
  5569. store. To instruct the daemon to perform a build action, users actually
  5570. provide it with a @dfn{derivation}. A derivation is a low-level
  5571. representation of the build actions to be taken, and the environment in
  5572. which they should occur---derivations are to package definitions what
  5573. assembly is to C programs. The term ``derivation'' comes from the fact
  5574. that build results @emph{derive} from them.
  5575. This chapter describes all these APIs in turn, starting from high-level
  5576. package definitions.
  5577. @menu
  5578. * Package Modules:: Packages from the programmer's viewpoint.
  5579. * Defining Packages:: Defining new packages.
  5580. * Defining Package Variants:: Customizing packages.
  5581. * Build Systems:: Specifying how packages are built.
  5582. * Build Phases:: Phases of the build process of a package.
  5583. * Build Utilities:: Helpers for your package definitions and more.
  5584. * Search Paths:: Declaring search path environment variables.
  5585. * The Store:: Manipulating the package store.
  5586. * Derivations:: Low-level interface to package derivations.
  5587. * The Store Monad:: Purely functional interface to the store.
  5588. * G-Expressions:: Manipulating build expressions.
  5589. * Invoking guix repl:: Programming Guix in Guile
  5590. @end menu
  5591. @node Package Modules
  5592. @section Package Modules
  5593. From a programming viewpoint, the package definitions of the
  5594. GNU distribution are provided by Guile modules in the @code{(gnu packages
  5595. @dots{})} name space@footnote{Note that packages under the @code{(gnu
  5596. packages @dots{})} module name space are not necessarily ``GNU
  5597. packages''. This module naming scheme follows the usual Guile module
  5598. naming convention: @code{gnu} means that these modules are distributed
  5599. as part of the GNU system, and @code{packages} identifies modules that
  5600. define packages.} (@pxref{Modules, Guile modules,, guile, GNU Guile
  5601. Reference Manual}). For instance, the @code{(gnu packages emacs)}
  5602. module exports a variable named @code{emacs}, which is bound to a
  5603. @code{<package>} object (@pxref{Defining Packages}).
  5604. The @code{(gnu packages @dots{})} module name space is
  5605. automatically scanned for packages by the command-line tools. For
  5606. instance, when running @code{guix install emacs}, all the @code{(gnu
  5607. packages @dots{})} modules are scanned until one that exports a package
  5608. object whose name is @code{emacs} is found. This package search
  5609. facility is implemented in the @code{(gnu packages)} module.
  5610. @cindex customization, of packages
  5611. @cindex package module search path
  5612. Users can store package definitions in modules with different
  5613. names---e.g., @code{(my-packages emacs)}@footnote{Note that the file
  5614. name and module name must match. For instance, the @code{(my-packages
  5615. emacs)} module must be stored in a @file{my-packages/emacs.scm} file
  5616. relative to the load path specified with @option{--load-path} or
  5617. @env{GUIX_PACKAGE_PATH}. @xref{Modules and the File System,,,
  5618. guile, GNU Guile Reference Manual}, for details.}. There are two ways to make
  5619. these package definitions visible to the user interfaces:
  5620. @enumerate
  5621. @item
  5622. By adding the directory containing your package modules to the search path
  5623. with the @code{-L} flag of @command{guix package} and other commands
  5624. (@pxref{Common Build Options}), or by setting the @env{GUIX_PACKAGE_PATH}
  5625. environment variable described below.
  5626. @item
  5627. By defining a @dfn{channel} and configuring @command{guix pull} so that it
  5628. pulls from it. A channel is essentially a Git repository containing package
  5629. modules. @xref{Channels}, for more information on how to define and use
  5630. channels.
  5631. @end enumerate
  5632. @env{GUIX_PACKAGE_PATH} works similarly to other search path variables:
  5633. @defvr {Environment Variable} GUIX_PACKAGE_PATH
  5634. This is a colon-separated list of directories to search for additional
  5635. package modules. Directories listed in this variable take precedence
  5636. over the own modules of the distribution.
  5637. @end defvr
  5638. The distribution is fully @dfn{bootstrapped} and @dfn{self-contained}:
  5639. each package is built based solely on other packages in the
  5640. distribution. The root of this dependency graph is a small set of
  5641. @dfn{bootstrap binaries}, provided by the @code{(gnu packages
  5642. bootstrap)} module. For more information on bootstrapping,
  5643. @pxref{Bootstrapping}.
  5644. @node Defining Packages
  5645. @section Defining Packages
  5646. The high-level interface to package definitions is implemented in the
  5647. @code{(guix packages)} and @code{(guix build-system)} modules. As an
  5648. example, the package definition, or @dfn{recipe}, for the GNU Hello
  5649. package looks like this:
  5650. @lisp
  5651. (define-module (gnu packages hello)
  5652. #:use-module (guix packages)
  5653. #:use-module (guix download)
  5654. #:use-module (guix build-system gnu)
  5655. #:use-module (guix licenses)
  5656. #:use-module (gnu packages gawk))
  5657. (define-public hello
  5658. (package
  5659. (name "hello")
  5660. (version "2.10")
  5661. (source (origin
  5662. (method url-fetch)
  5663. (uri (string-append "mirror://gnu/hello/hello-" version
  5664. ".tar.gz"))
  5665. (sha256
  5666. (base32
  5667. "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
  5668. (build-system gnu-build-system)
  5669. (arguments '(#:configure-flags '("--enable-silent-rules")))
  5670. (inputs (list gawk))
  5671. (synopsis "Hello, GNU world: An example GNU package")
  5672. (description "Guess what GNU Hello prints!")
  5673. (home-page "https://www.gnu.org/software/hello/")
  5674. (license gpl3+)))
  5675. @end lisp
  5676. @noindent
  5677. Without being a Scheme expert, the reader may have guessed the meaning
  5678. of the various fields here. This expression binds the variable
  5679. @code{hello} to a @code{<package>} object, which is essentially a record
  5680. (@pxref{SRFI-9, Scheme records,, guile, GNU Guile Reference Manual}).
  5681. This package object can be inspected using procedures found in the
  5682. @code{(guix packages)} module; for instance, @code{(package-name hello)}
  5683. returns---surprise!---@code{"hello"}.
  5684. With luck, you may be able to import part or all of the definition of
  5685. the package you are interested in from another repository, using the
  5686. @code{guix import} command (@pxref{Invoking guix import}).
  5687. In the example above, @code{hello} is defined in a module of its own,
  5688. @code{(gnu packages hello)}. Technically, this is not strictly
  5689. necessary, but it is convenient to do so: all the packages defined in
  5690. modules under @code{(gnu packages @dots{})} are automatically known to
  5691. the command-line tools (@pxref{Package Modules}).
  5692. There are a few points worth noting in the above package definition:
  5693. @itemize
  5694. @item
  5695. The @code{source} field of the package is an @code{<origin>} object
  5696. (@pxref{origin Reference}, for the complete reference).
  5697. Here, the @code{url-fetch} method from @code{(guix download)} is used,
  5698. meaning that the source is a file to be downloaded over FTP or HTTP.
  5699. The @code{mirror://gnu} prefix instructs @code{url-fetch} to use one of
  5700. the GNU mirrors defined in @code{(guix download)}.
  5701. The @code{sha256} field specifies the expected SHA256 hash of the file
  5702. being downloaded. It is mandatory, and allows Guix to check the
  5703. integrity of the file. The @code{(base32 @dots{})} form introduces the
  5704. base32 representation of the hash. You can obtain this information with
  5705. @code{guix download} (@pxref{Invoking guix download}) and @code{guix
  5706. hash} (@pxref{Invoking guix hash}).
  5707. @cindex patches
  5708. When needed, the @code{origin} form can also have a @code{patches} field
  5709. listing patches to be applied, and a @code{snippet} field giving a
  5710. Scheme expression to modify the source code.
  5711. @item
  5712. @cindex GNU Build System
  5713. The @code{build-system} field specifies the procedure to build the
  5714. package (@pxref{Build Systems}). Here, @code{gnu-build-system}
  5715. represents the familiar GNU Build System, where packages may be
  5716. configured, built, and installed with the usual @code{./configure &&
  5717. make && make check && make install} command sequence.
  5718. When you start packaging non-trivial software, you may need tools to
  5719. manipulate those build phases, manipulate files, and so on. @xref{Build
  5720. Utilities}, for more on this.
  5721. @item
  5722. The @code{arguments} field specifies options for the build system
  5723. (@pxref{Build Systems}). Here it is interpreted by
  5724. @code{gnu-build-system} as a request run @file{configure} with the
  5725. @option{--enable-silent-rules} flag.
  5726. @cindex quote
  5727. @cindex quoting
  5728. @findex '
  5729. @findex quote
  5730. @cindex backquote (quasiquote)
  5731. @findex `
  5732. @findex quasiquote
  5733. @cindex comma (unquote)
  5734. @findex ,
  5735. @findex unquote
  5736. What about these quote (@code{'}) characters? They are Scheme syntax to
  5737. introduce a literal list; @code{'} is synonymous with @code{quote}.
  5738. Sometimes you'll also see @code{`} (a backquote, synonymous with
  5739. @code{quasiquote}) and @code{,} (a comma, synonymous with @code{unquote}).
  5740. @xref{Expression Syntax, quoting,, guile, GNU Guile Reference Manual},
  5741. for details. Here the value of the @code{arguments} field is a list of
  5742. arguments passed to the build system down the road, as with @code{apply}
  5743. (@pxref{Fly Evaluation, @code{apply},, guile, GNU Guile Reference
  5744. Manual}).
  5745. The hash-colon (@code{#:}) sequence defines a Scheme @dfn{keyword}
  5746. (@pxref{Keywords,,, guile, GNU Guile Reference Manual}), and
  5747. @code{#:configure-flags} is a keyword used to pass a keyword argument
  5748. to the build system (@pxref{Coding With Keywords,,, guile, GNU Guile
  5749. Reference Manual}).
  5750. @item
  5751. The @code{inputs} field specifies inputs to the build process---i.e.,
  5752. build-time or run-time dependencies of the package. Here, we add
  5753. an input, a reference to the @code{gawk}
  5754. variable; @code{gawk} is itself bound to a @code{<package>} object.
  5755. Note that GCC, Coreutils, Bash, and other essential tools do not need to
  5756. be specified as inputs here. Instead, @code{gnu-build-system} takes care
  5757. of ensuring that they are present (@pxref{Build Systems}).
  5758. However, any other dependencies need to be specified in the
  5759. @code{inputs} field. Any dependency not specified here will simply be
  5760. unavailable to the build process, possibly leading to a build failure.
  5761. @end itemize
  5762. @xref{package Reference}, for a full description of possible fields.
  5763. Once a package definition is in place, the
  5764. package may actually be built using the @code{guix build} command-line
  5765. tool (@pxref{Invoking guix build}), troubleshooting any build failures
  5766. you encounter (@pxref{Debugging Build Failures}). You can easily jump back to the
  5767. package definition using the @command{guix edit} command
  5768. (@pxref{Invoking guix edit}).
  5769. @xref{Packaging Guidelines}, for
  5770. more information on how to test package definitions, and
  5771. @ref{Invoking guix lint}, for information on how to check a definition
  5772. for style conformance.
  5773. @vindex GUIX_PACKAGE_PATH
  5774. Lastly, @pxref{Channels}, for information
  5775. on how to extend the distribution by adding your own package definitions
  5776. in a ``channel''.
  5777. Finally, updating the package definition to a new upstream version
  5778. can be partly automated by the @command{guix refresh} command
  5779. (@pxref{Invoking guix refresh}).
  5780. Behind the scenes, a derivation corresponding to the @code{<package>}
  5781. object is first computed by the @code{package-derivation} procedure.
  5782. That derivation is stored in a @file{.drv} file under @file{/gnu/store}.
  5783. The build actions it prescribes may then be realized by using the
  5784. @code{build-derivations} procedure (@pxref{The Store}).
  5785. @deffn {Scheme Procedure} package-derivation @var{store} @var{package} [@var{system}]
  5786. Return the @code{<derivation>} object of @var{package} for @var{system}
  5787. (@pxref{Derivations}).
  5788. @var{package} must be a valid @code{<package>} object, and @var{system}
  5789. must be a string denoting the target system type---e.g.,
  5790. @code{"x86_64-linux"} for an x86_64 Linux-based GNU system. @var{store}
  5791. must be a connection to the daemon, which operates on the store
  5792. (@pxref{The Store}).
  5793. @end deffn
  5794. @noindent
  5795. @cindex cross-compilation
  5796. Similarly, it is possible to compute a derivation that cross-builds a
  5797. package for some other system:
  5798. @deffn {Scheme Procedure} package-cross-derivation @var{store} @
  5799. @var{package} @var{target} [@var{system}]
  5800. Return the @code{<derivation>} object of @var{package} cross-built from
  5801. @var{system} to @var{target}.
  5802. @var{target} must be a valid GNU triplet denoting the target hardware
  5803. and operating system, such as @code{"aarch64-linux-gnu"}
  5804. (@pxref{Specifying Target Triplets,,, autoconf, Autoconf}).
  5805. @end deffn
  5806. Once you have package definitions, you can easily define @emph{variants}
  5807. of those packages. @xref{Defining Package Variants}, for more on that.
  5808. @menu
  5809. * package Reference:: The package data type.
  5810. * origin Reference:: The origin data type.
  5811. @end menu
  5812. @node package Reference
  5813. @subsection @code{package} Reference
  5814. This section summarizes all the options available in @code{package}
  5815. declarations (@pxref{Defining Packages}).
  5816. @deftp {Data Type} package
  5817. This is the data type representing a package recipe.
  5818. @table @asis
  5819. @item @code{name}
  5820. The name of the package, as a string.
  5821. @item @code{version}
  5822. The version of the package, as a string. @xref{Version Numbers}, for
  5823. guidelines.
  5824. @item @code{source}
  5825. An object telling how the source code for the package should be
  5826. acquired. Most of the time, this is an @code{origin} object, which
  5827. denotes a file fetched from the Internet (@pxref{origin Reference}). It
  5828. can also be any other ``file-like'' object such as a @code{local-file},
  5829. which denotes a file from the local file system (@pxref{G-Expressions,
  5830. @code{local-file}}).
  5831. @item @code{build-system}
  5832. The build system that should be used to build the package (@pxref{Build
  5833. Systems}).
  5834. @item @code{arguments} (default: @code{'()})
  5835. The arguments that should be passed to the build system. This is a
  5836. list, typically containing sequential keyword-value pairs.
  5837. @item @code{inputs} (default: @code{'()})
  5838. @itemx @code{native-inputs} (default: @code{'()})
  5839. @itemx @code{propagated-inputs} (default: @code{'()})
  5840. @cindex inputs, of packages
  5841. These fields list dependencies of the package. Each element of these
  5842. lists is either a package, origin, or other ``file-like object''
  5843. (@pxref{G-Expressions}); to specify the output of that file-like object
  5844. that should be used, pass a two-element list where the second element is
  5845. the output (@pxref{Packages with Multiple Outputs}, for more on package
  5846. outputs). For example, the list below specifies three inputs:
  5847. @lisp
  5848. (list libffi libunistring
  5849. `(,glib "bin")) ;the "bin" output of GLib
  5850. @end lisp
  5851. In the example above, the @code{"out"} output of @code{libffi} and
  5852. @code{libunistring} is used.
  5853. @quotation Compatibility Note
  5854. Until version 1.3.0, input lists were a list of tuples,
  5855. where each tuple has a label for the input (a string) as its
  5856. first element, a package, origin, or derivation as its second element,
  5857. and optionally the name of the output thereof that should be used, which
  5858. defaults to @code{"out"}. For example, the list below is equivalent to
  5859. the one above, but using the @dfn{old input style}:
  5860. @lisp
  5861. ;; Old input style (deprecated).
  5862. `(("libffi" ,libffi)
  5863. ("libunistring" ,libunistring)
  5864. ("glib:bin" ,glib "bin")) ;the "bin" output of GLib
  5865. @end lisp
  5866. This style is now deprecated; it is still supported but support will be
  5867. removed in a future version. It should not be used for new package
  5868. definitions. @xref{Invoking guix style}, on how to migrate to the new
  5869. style.
  5870. @end quotation
  5871. @cindex cross compilation, package dependencies
  5872. The distinction between @code{native-inputs} and @code{inputs} is
  5873. necessary when considering cross-compilation. When cross-compiling,
  5874. dependencies listed in @code{inputs} are built for the @emph{target}
  5875. architecture; conversely, dependencies listed in @code{native-inputs}
  5876. are built for the architecture of the @emph{build} machine.
  5877. @code{native-inputs} is typically used to list tools needed at
  5878. build time, but not at run time, such as Autoconf, Automake, pkg-config,
  5879. Gettext, or Bison. @command{guix lint} can report likely mistakes in
  5880. this area (@pxref{Invoking guix lint}).
  5881. @anchor{package-propagated-inputs}
  5882. Lastly, @code{propagated-inputs} is similar to @code{inputs}, but the
  5883. specified packages will be automatically installed to profiles
  5884. (@pxref{Features, the role of profiles in Guix}) alongside the package
  5885. they belong to (@pxref{package-cmd-propagated-inputs, @command{guix
  5886. package}}, for information on how @command{guix package} deals with
  5887. propagated inputs).
  5888. For example this is necessary when packaging a C/C++ library that needs
  5889. headers of another library to compile, or when a pkg-config file refers
  5890. to another one @i{via} its @code{Requires} field.
  5891. Another example where @code{propagated-inputs} is useful is for languages
  5892. that lack a facility to record the run-time search path akin to the
  5893. @code{RUNPATH} of ELF files; this includes Guile, Python, Perl, and
  5894. more. When packaging libraries written in those languages, ensure they
  5895. can find library code they depend on at run time by listing run-time
  5896. dependencies in @code{propagated-inputs} rather than @code{inputs}.
  5897. @item @code{outputs} (default: @code{'("out")})
  5898. The list of output names of the package. @xref{Packages with Multiple
  5899. Outputs}, for typical uses of additional outputs.
  5900. @item @code{native-search-paths} (default: @code{'()})
  5901. @itemx @code{search-paths} (default: @code{'()})
  5902. A list of @code{search-path-specification} objects describing
  5903. search-path environment variables honored by the package. @xref{Search
  5904. Paths}, for more on search path specifications.
  5905. As for inputs, the distinction between @code{native-search-paths} and
  5906. @code{search-paths} only matters when cross-compiling. In a
  5907. cross-compilation context, @code{native-search-paths} applies
  5908. exclusively to native inputs whereas @code{search-paths} applies only to
  5909. host inputs.
  5910. Packages such as cross-compilers care about target inputs---for
  5911. instance, our (modified) GCC cross-compiler has
  5912. @env{CROSS_C_INCLUDE_PATH} in @code{search-paths}, which allows it to
  5913. pick @file{.h} files for the target system and @emph{not} those of
  5914. native inputs. For the majority of packages though, only
  5915. @code{native-search-paths} makes sense.
  5916. @item @code{replacement} (default: @code{#f})
  5917. This must be either @code{#f} or a package object that will be used as a
  5918. @dfn{replacement} for this package. @xref{Security Updates, grafts},
  5919. for details.
  5920. @item @code{synopsis}
  5921. A one-line description of the package.
  5922. @item @code{description}
  5923. A more elaborate description of the package.
  5924. @item @code{license}
  5925. @cindex license, of packages
  5926. The license of the package; a value from @code{(guix licenses)},
  5927. or a list of such values.
  5928. @item @code{home-page}
  5929. The URL to the home-page of the package, as a string.
  5930. @item @code{supported-systems} (default: @code{%supported-systems})
  5931. The list of systems supported by the package, as strings of the form
  5932. @code{architecture-kernel}, for example @code{"x86_64-linux"}.
  5933. @item @code{location} (default: source location of the @code{package} form)
  5934. The source location of the package. It is useful to override this when
  5935. inheriting from another package, in which case this field is not
  5936. automatically corrected.
  5937. @end table
  5938. @end deftp
  5939. @deffn {Scheme Syntax} this-package
  5940. When used in the @emph{lexical scope} of a package field definition, this
  5941. identifier resolves to the package being defined.
  5942. The example below shows how to add a package as a native input of itself when
  5943. cross-compiling:
  5944. @lisp
  5945. (package
  5946. (name "guile")
  5947. ;; ...
  5948. ;; When cross-compiled, Guile, for example, depends on
  5949. ;; a native version of itself. Add it here.
  5950. (native-inputs (if (%current-target-system)
  5951. (list this-package)
  5952. '())))
  5953. @end lisp
  5954. It is an error to refer to @code{this-package} outside a package definition.
  5955. @end deffn
  5956. The following helper procedures are provided to help deal with package
  5957. inputs.
  5958. @deffn {Scheme Procedure} lookup-package-input @var{package} @var{name}
  5959. @deffnx {Scheme Procedure} lookup-package-native-input @var{package} @var{name}
  5960. @deffnx {Scheme Procedure} lookup-package-propagated-input @var{package} @var{name}
  5961. @deffnx {Scheme Procedure} lookup-package-direct-input @var{package} @var{name}
  5962. Look up @var{name} among @var{package}'s inputs (or native, propagated,
  5963. or direct inputs). Return it if found, @code{#f} otherwise.
  5964. @var{name} is the name of a package depended on. Here's how you might
  5965. use it:
  5966. @lisp
  5967. (use-modules (guix packages) (gnu packages base))
  5968. (lookup-package-direct-input coreutils "gmp")
  5969. @result{} #<package gmp@@6.2.1 @dots{}>
  5970. @end lisp
  5971. In this example we obtain the @code{gmp} package that is among the
  5972. direct inputs of @code{coreutils}.
  5973. @end deffn
  5974. @cindex development inputs, of a package
  5975. @cindex implicit inputs, of a package
  5976. Sometimes you will want to obtain the list of inputs needed to
  5977. @emph{develop} a package---all the inputs that are visible when the
  5978. package is compiled. This is what the @code{package-development-inputs}
  5979. procedure returns.
  5980. @deffn {Scheme Procedure} package-development-inputs @var{package} @
  5981. [@var{system}] [#:target #f]
  5982. Return the list of inputs required by @var{package} for development
  5983. purposes on @var{system}. When @var{target} is true, return the inputs
  5984. needed to cross-compile @var{package} from @var{system} to
  5985. @var{triplet}, where @var{triplet} is a triplet such as
  5986. @code{"aarch64-linux-gnu"}.
  5987. Note that the result includes both explicit inputs and implicit
  5988. inputs---inputs automatically added by the build system (@pxref{Build
  5989. Systems}). Let us take the @code{hello} package to illustrate that:
  5990. @lisp
  5991. (use-modules (gnu packages base) (guix packages))
  5992. hello
  5993. @result{} #<package hello@@2.10 gnu/packages/base.scm:79 7f585d4f6790>
  5994. (package-direct-inputs hello)
  5995. @result{} ()
  5996. (package-development-inputs hello)
  5997. @result{} (("source" @dots{}) ("tar" #<package tar@@1.32 @dots{}>) @dots{})
  5998. @end lisp
  5999. In this example, @code{package-direct-inputs} returns the empty list,
  6000. because @code{hello} has zero explicit dependencies. Conversely,
  6001. @code{package-development-inputs} includes inputs implicitly added by
  6002. @code{gnu-build-system} that are required to build @code{hello}: tar,
  6003. gzip, GCC, libc, Bash, and more. To visualize it, @command{guix graph
  6004. hello} would show you explicit inputs, whereas @command{guix graph -t
  6005. bag hello} would include implicit inputs (@pxref{Invoking guix graph}).
  6006. @end deffn
  6007. Because packages are regular Scheme objects that capture a complete
  6008. dependency graph and associated build procedures, it is often useful to
  6009. write procedures that take a package and return a modified version
  6010. thereof according to some parameters. Below are a few examples.
  6011. @cindex tool chain, choosing a package's tool chain
  6012. @deffn {Scheme Procedure} package-with-c-toolchain @var{package} @var{toolchain}
  6013. Return a variant of @var{package} that uses @var{toolchain} instead of
  6014. the default GNU C/C++ toolchain. @var{toolchain} must be a list of
  6015. inputs (label/package tuples) providing equivalent functionality, such
  6016. as the @code{gcc-toolchain} package.
  6017. The example below returns a variant of the @code{hello} package built
  6018. with GCC@tie{}10.x and the rest of the GNU tool chain (Binutils and the
  6019. GNU C Library) instead of the default tool chain:
  6020. @lisp
  6021. (let ((toolchain (specification->package "gcc-toolchain@@10")))
  6022. (package-with-c-toolchain hello `(("toolchain" ,toolchain))))
  6023. @end lisp
  6024. The build tool chain is part of the @dfn{implicit inputs} of
  6025. packages---it's usually not listed as part of the various ``inputs''
  6026. fields and is instead pulled in by the build system. Consequently, this
  6027. procedure works by changing the build system of @var{package} so that it
  6028. pulls in @var{toolchain} instead of the defaults. @ref{Build Systems},
  6029. for more on build systems.
  6030. @end deffn
  6031. @node origin Reference
  6032. @subsection @code{origin} Reference
  6033. This section documents @dfn{origins}. An @code{origin} declaration
  6034. specifies data that must be ``produced''---downloaded, usually---and
  6035. whose content hash is known in advance. Origins are primarily used to
  6036. represent the source code of packages (@pxref{Defining Packages}). For
  6037. that reason, the @code{origin} form allows you to declare patches to
  6038. apply to the original source code as well as code snippets to modify it.
  6039. @deftp {Data Type} origin
  6040. This is the data type representing a source code origin.
  6041. @table @asis
  6042. @item @code{uri}
  6043. An object containing the URI of the source. The object type depends on
  6044. the @code{method} (see below). For example, when using the
  6045. @var{url-fetch} method of @code{(guix download)}, the valid @code{uri}
  6046. values are: a URL represented as a string, or a list thereof.
  6047. @cindex fixed-output derivations, for download
  6048. @item @code{method}
  6049. A monadic procedure that handles the given URI@. The procedure must
  6050. accept at least three arguments: the value of the @code{uri} field and
  6051. the hash algorithm and hash value specified by the @code{hash} field.
  6052. It must return a store item or a derivation in the store monad
  6053. (@pxref{The Store Monad}); most methods return a fixed-output derivation
  6054. (@pxref{Derivations}).
  6055. Commonly used methods include @code{url-fetch}, which fetches data from
  6056. a URL, and @code{git-fetch}, which fetches data from a Git repository
  6057. (see below).
  6058. @item @code{sha256}
  6059. A bytevector containing the SHA-256 hash of the source. This is
  6060. equivalent to providing a @code{content-hash} SHA256 object in the
  6061. @code{hash} field described below.
  6062. @item @code{hash}
  6063. The @code{content-hash} object of the source---see below for how to use
  6064. @code{content-hash}.
  6065. You can obtain this information using @code{guix download}
  6066. (@pxref{Invoking guix download}) or @code{guix hash} (@pxref{Invoking
  6067. guix hash}).
  6068. @item @code{file-name} (default: @code{#f})
  6069. The file name under which the source code should be saved. When this is
  6070. @code{#f}, a sensible default value will be used in most cases. In case
  6071. the source is fetched from a URL, the file name from the URL will be
  6072. used. For version control checkouts, it is recommended to provide the
  6073. file name explicitly because the default is not very descriptive.
  6074. @item @code{patches} (default: @code{'()})
  6075. A list of file names, origins, or file-like objects (@pxref{G-Expressions,
  6076. file-like objects}) pointing to patches to be applied to the source.
  6077. This list of patches must be unconditional. In particular, it cannot
  6078. depend on the value of @code{%current-system} or
  6079. @code{%current-target-system}.
  6080. @item @code{snippet} (default: @code{#f})
  6081. A G-expression (@pxref{G-Expressions}) or S-expression that will be run
  6082. in the source directory. This is a convenient way to modify the source,
  6083. sometimes more convenient than a patch.
  6084. @item @code{patch-flags} (default: @code{'("-p1")})
  6085. A list of command-line flags that should be passed to the @code{patch}
  6086. command.
  6087. @item @code{patch-inputs} (default: @code{#f})
  6088. Input packages or derivations to the patching process. When this is
  6089. @code{#f}, the usual set of inputs necessary for patching are provided,
  6090. such as GNU@tie{}Patch.
  6091. @item @code{modules} (default: @code{'()})
  6092. A list of Guile modules that should be loaded during the patching
  6093. process and while running the code in the @code{snippet} field.
  6094. @item @code{patch-guile} (default: @code{#f})
  6095. The Guile package that should be used in the patching process. When
  6096. this is @code{#f}, a sensible default is used.
  6097. @end table
  6098. @end deftp
  6099. @deftp {Data Type} content-hash @var{value} [@var{algorithm}]
  6100. Construct a content hash object for the given @var{algorithm}, and with
  6101. @var{value} as its hash value. When @var{algorithm} is omitted, assume
  6102. it is @code{sha256}.
  6103. @var{value} can be a literal string, in which case it is base32-decoded,
  6104. or it can be a bytevector.
  6105. The following forms are all equivalent:
  6106. @lisp
  6107. (content-hash "05zxkyz9bv3j9h0xyid1rhvh3klhsmrpkf3bcs6frvlgyr2gwilj")
  6108. (content-hash "05zxkyz9bv3j9h0xyid1rhvh3klhsmrpkf3bcs6frvlgyr2gwilj"
  6109. sha256)
  6110. (content-hash (base32
  6111. "05zxkyz9bv3j9h0xyid1rhvh3klhsmrpkf3bcs6frvlgyr2gwilj"))
  6112. (content-hash (base64 "kkb+RPaP7uyMZmu4eXPVkM4BN8yhRd8BTHLslb6f/Rc=")
  6113. sha256)
  6114. @end lisp
  6115. Technically, @code{content-hash} is currently implemented as a macro.
  6116. It performs sanity checks at macro-expansion time, when possible, such
  6117. as ensuring that @var{value} has the right size for @var{algorithm}.
  6118. @end deftp
  6119. As we have seen above, how exactly the data an origin refers to is
  6120. retrieved is determined by its @code{method} field. The @code{(guix
  6121. download)} module provides the most common method, @code{url-fetch},
  6122. described below.
  6123. @deffn {Scheme Procedure} url-fetch @var{url} @var{hash-algo} @var{hash} @
  6124. [name] [#:executable? #f]
  6125. Return a fixed-output derivation that fetches data from @var{url} (a
  6126. string, or a list of strings denoting alternate URLs), which is expected
  6127. to have hash @var{hash} of type @var{hash-algo} (a symbol). By default,
  6128. the file name is the base name of URL; optionally, @var{name} can
  6129. specify a different file name. When @var{executable?} is true, make the
  6130. downloaded file executable.
  6131. When one of the URL starts with @code{mirror://}, then its host part is
  6132. interpreted as the name of a mirror scheme, taken from @file{%mirror-file}.
  6133. Alternatively, when URL starts with @code{file://}, return the
  6134. corresponding file name in the store.
  6135. @end deffn
  6136. Likewise, the @code{(guix git-download)} module defines the
  6137. @code{git-fetch} origin method, which fetches data from a Git version
  6138. control repository, and the @code{git-reference} data type to describe
  6139. the repository and revision to fetch.
  6140. @deffn {Scheme Procedure} git-fetch @var{ref} @var{hash-algo} @var{hash}
  6141. Return a fixed-output derivation that fetches @var{ref}, a
  6142. @code{<git-reference>} object. The output is expected to have recursive
  6143. hash @var{hash} of type @var{hash-algo} (a symbol). Use @var{name} as
  6144. the file name, or a generic name if @code{#f}.
  6145. @end deffn
  6146. @deftp {Data Type} git-reference
  6147. This data type represents a Git reference for @code{git-fetch} to
  6148. retrieve.
  6149. @table @asis
  6150. @item @code{url}
  6151. The URL of the Git repository to clone.
  6152. @item @code{commit}
  6153. This string denotes either the commit to fetch (a hexadecimal string),
  6154. or the tag to fetch. You can also use a ``short'' commit ID or a
  6155. @command{git describe} style identifier such as
  6156. @code{v1.0.1-10-g58d7909c97}.
  6157. @item @code{recursive?} (default: @code{#f})
  6158. This Boolean indicates whether to recursively fetch Git sub-modules.
  6159. @end table
  6160. The example below denotes the @code{v2.10} tag of the GNU@tie{}Hello
  6161. repository:
  6162. @lisp
  6163. (git-reference
  6164. (url "https://git.savannah.gnu.org/git/hello.git")
  6165. (commit "v2.10"))
  6166. @end lisp
  6167. This is equivalent to the reference below, which explicitly names the
  6168. commit:
  6169. @lisp
  6170. (git-reference
  6171. (url "https://git.savannah.gnu.org/git/hello.git")
  6172. (commit "dc7dc56a00e48fe6f231a58f6537139fe2908fb9"))
  6173. @end lisp
  6174. @end deftp
  6175. For Mercurial repositories, the module @code{(guix hg-download)} defines
  6176. the @code{hg-fetch} origin method and @code{hg-reference} data type for
  6177. support of the Mercurial version control system.
  6178. @deffn {Scheme Procedure} hg-fetch @var{ref} @var{hash-algo} @var{hash} @
  6179. [name]
  6180. Return a fixed-output derivation that fetches @var{ref}, a
  6181. @code{<hg-reference>} object. The output is expected to have recursive
  6182. hash @var{hash} of type @var{hash-algo} (a symbol). Use @var{name} as
  6183. the file name, or a generic name if @code{#false}.
  6184. @end deffn
  6185. @node Defining Package Variants
  6186. @section Defining Package Variants
  6187. @cindex customizing packages
  6188. @cindex variants, of packages
  6189. One of the nice things with Guix is that, given a package definition,
  6190. you can easily @emph{derive} variants of that package---for a different
  6191. upstream version, with different dependencies, different compilation
  6192. options, and so on. Some of these custom packages can be defined
  6193. straight from the command line (@pxref{Package Transformation Options}).
  6194. This section describes how to define package variants in code. This can
  6195. be useful in ``manifests'' (@pxref{profile-manifest,
  6196. @option{--manifest}}) and in your own package collection
  6197. (@pxref{Creating a Channel}), among others!
  6198. @cindex inherit, for package definitions
  6199. As discussed earlier, packages are first-class objects in the Scheme
  6200. language. The @code{(guix packages)} module provides the @code{package}
  6201. construct to define new package objects (@pxref{package Reference}).
  6202. The easiest way to define a package variant is using the @code{inherit}
  6203. keyword together with @code{package}. This allows you to inherit from a
  6204. package definition while overriding the fields you want.
  6205. For example, given the @code{hello} variable, which contains a
  6206. definition for the current version of GNU@tie{}Hello, here's how you
  6207. would define a variant for version 2.2 (released in 2006, it's
  6208. vintage!):
  6209. @lisp
  6210. (use-modules (gnu packages base)) ;for 'hello'
  6211. (define hello-2.2
  6212. (package
  6213. (inherit hello)
  6214. (version "2.2")
  6215. (source (origin
  6216. (method url-fetch)
  6217. (uri (string-append "mirror://gnu/hello/hello-" version
  6218. ".tar.gz"))
  6219. (sha256
  6220. (base32
  6221. "0lappv4slgb5spyqbh6yl5r013zv72yqg2pcl30mginf3wdqd8k9"))))))
  6222. @end lisp
  6223. The example above corresponds to what the @option{--with-source} package
  6224. transformation option does. Essentially @code{hello-2.2} preserves all
  6225. the fields of @code{hello}, except @code{version} and @code{source},
  6226. which it overrides. Note that the original @code{hello} variable is
  6227. still there, in the @code{(gnu packages base)} module, unchanged. When
  6228. you define a custom package like this, you are really @emph{adding} a
  6229. new package definition; the original one remains available.
  6230. You can just as well define variants with a different set of
  6231. dependencies than the original package. For example, the default
  6232. @code{gdb} package depends on @code{guile}, but since that is an
  6233. optional dependency, you can define a variant that removes that
  6234. dependency like so:
  6235. @lisp
  6236. (use-modules (gnu packages gdb)) ;for 'gdb'
  6237. (define gdb-sans-guile
  6238. (package
  6239. (inherit gdb)
  6240. (inputs (modify-inputs (package-inputs gdb)
  6241. (delete "guile")))))
  6242. @end lisp
  6243. The @code{modify-inputs} form above removes the @code{"guile"} package
  6244. from the @code{inputs} field of @code{gdb}. The @code{modify-inputs}
  6245. macro is a helper that can prove useful anytime you want to remove, add,
  6246. or replace package inputs.
  6247. @deffn {Scheme Syntax} modify-inputs @var{inputs} @var{clauses}
  6248. Modify the given package inputs, as returned by @code{package-inputs} & co.,
  6249. according to the given clauses. Each clause must have one of the
  6250. following forms:
  6251. @table @code
  6252. @item (delete @var{name}@dots{})
  6253. Delete from the inputs packages with the given @var{name}s (strings).
  6254. @item (append @var{package}@dots{})
  6255. Add @var{package}s to the end of the input list.
  6256. @item (prepend @var{package}@dots{})
  6257. Add @var{package}s to the front of the input list.
  6258. @end table
  6259. The example below removes the GMP and ACL inputs of Coreutils and adds
  6260. libcap to the back of the input list:
  6261. @lisp
  6262. (modify-inputs (package-inputs coreutils)
  6263. (delete "gmp" "acl")
  6264. (append libcap))
  6265. @end lisp
  6266. The example below replaces the @code{guile} package from the inputs of
  6267. @code{guile-redis} with @code{guile-2.2}:
  6268. @lisp
  6269. (modify-inputs (package-inputs guile-redis)
  6270. (replace "guile" guile-2.2))
  6271. @end lisp
  6272. The last type of clause is @code{prepend}, to add inputs to the front of
  6273. the list.
  6274. @end deffn
  6275. In some cases, you may find it useful to write functions
  6276. (``procedures'', in Scheme parlance) that return a package based on some
  6277. parameters. For example, consider the @code{luasocket} library for the
  6278. Lua programming language. We want to create @code{luasocket} packages
  6279. for major versions of Lua. One way to do that is to define a procedure
  6280. that takes a Lua package and returns a @code{luasocket} package that
  6281. depends on it:
  6282. @lisp
  6283. (define (make-lua-socket name lua)
  6284. ;; Return a luasocket package built with LUA.
  6285. (package
  6286. (name name)
  6287. (version "3.0")
  6288. ;; several fields omitted
  6289. (inputs (list lua))
  6290. (synopsis "Socket library for Lua")))
  6291. (define-public lua5.1-socket
  6292. (make-lua-socket "lua5.1-socket" lua-5.1))
  6293. (define-public lua5.2-socket
  6294. (make-lua-socket "lua5.2-socket" lua-5.2))
  6295. @end lisp
  6296. Here we have defined packages @code{lua5.1-socket} and
  6297. @code{lua5.2-socket} by calling @code{make-lua-socket} with different
  6298. arguments. @xref{Procedures,,, guile, GNU Guile Reference Manual}, for
  6299. more info on procedures. Having top-level public definitions for these
  6300. two packages means that they can be referred to from the command line
  6301. (@pxref{Package Modules}).
  6302. @cindex package transformations
  6303. These are pretty simple package variants. As a convenience, the
  6304. @code{(guix transformations)} module provides a high-level interface
  6305. that directly maps to the more sophisticated package transformation
  6306. options (@pxref{Package Transformation Options}):
  6307. @deffn {Scheme Procedure} options->transformation @var{opts}
  6308. Return a procedure that, when passed an object to build (package,
  6309. derivation, etc.), applies the transformations specified by @var{opts} and returns
  6310. the resulting objects. @var{opts} must be a list of symbol/string pairs such as:
  6311. @lisp
  6312. ((with-branch . "guile-gcrypt=master")
  6313. (without-tests . "libgcrypt"))
  6314. @end lisp
  6315. Each symbol names a transformation and the corresponding string is an argument
  6316. to that transformation.
  6317. @end deffn
  6318. For instance, a manifest equivalent to this command:
  6319. @example
  6320. guix build guix \
  6321. --with-branch=guile-gcrypt=master \
  6322. --with-debug-info=zlib
  6323. @end example
  6324. @noindent
  6325. ... would look like this:
  6326. @lisp
  6327. (use-modules (guix transformations))
  6328. (define transform
  6329. ;; The package transformation procedure.
  6330. (options->transformation
  6331. '((with-branch . "guile-gcrypt=master")
  6332. (with-debug-info . "zlib"))))
  6333. (packages->manifest
  6334. (list (transform (specification->package "guix"))))
  6335. @end lisp
  6336. @cindex input rewriting
  6337. @cindex dependency graph rewriting
  6338. The @code{options->transformation} procedure is convenient, but it's
  6339. perhaps also not as flexible as you may like. How is it implemented?
  6340. The astute reader probably noticed that most package transformation
  6341. options go beyond the superficial changes shown in the first examples of
  6342. this section: they involve @dfn{input rewriting}, whereby the dependency
  6343. graph of a package is rewritten by replacing specific inputs by others.
  6344. Dependency graph rewriting, for the purposes of swapping packages in the
  6345. graph, is what the @code{package-input-rewriting} procedure in
  6346. @code{(guix packages)} implements.
  6347. @deffn {Scheme Procedure} package-input-rewriting @var{replacements} @
  6348. [@var{rewrite-name}] [#:deep? #t]
  6349. Return a procedure that, when passed a package, replaces its direct and
  6350. indirect dependencies, including implicit inputs when @var{deep?} is
  6351. true, according to @var{replacements}. @var{replacements} is a list of
  6352. package pairs; the first element of each pair is the package to replace,
  6353. and the second one is the replacement.
  6354. Optionally, @var{rewrite-name} is a one-argument procedure that takes
  6355. the name of a package and returns its new name after rewrite.
  6356. @end deffn
  6357. @noindent
  6358. Consider this example:
  6359. @lisp
  6360. (define libressl-instead-of-openssl
  6361. ;; This is a procedure to replace OPENSSL by LIBRESSL,
  6362. ;; recursively.
  6363. (package-input-rewriting `((,openssl . ,libressl))))
  6364. (define git-with-libressl
  6365. (libressl-instead-of-openssl git))
  6366. @end lisp
  6367. @noindent
  6368. Here we first define a rewriting procedure that replaces @var{openssl}
  6369. with @var{libressl}. Then we use it to define a @dfn{variant} of the
  6370. @var{git} package that uses @var{libressl} instead of @var{openssl}.
  6371. This is exactly what the @option{--with-input} command-line option does
  6372. (@pxref{Package Transformation Options, @option{--with-input}}).
  6373. The following variant of @code{package-input-rewriting} can match packages to
  6374. be replaced by name rather than by identity.
  6375. @deffn {Scheme Procedure} package-input-rewriting/spec @var{replacements} [#:deep? #t]
  6376. Return a procedure that, given a package, applies the given
  6377. @var{replacements} to all the package graph, including implicit inputs
  6378. unless @var{deep?} is false. @var{replacements} is a list of
  6379. spec/procedures pair; each spec is a package specification such as
  6380. @code{"gcc"} or @code{"guile@@2"}, and each procedure takes a matching
  6381. package and returns a replacement for that package.
  6382. @end deffn
  6383. The example above could be rewritten this way:
  6384. @lisp
  6385. (define libressl-instead-of-openssl
  6386. ;; Replace all the packages called "openssl" with LibreSSL.
  6387. (package-input-rewriting/spec `(("openssl" . ,(const libressl)))))
  6388. @end lisp
  6389. The key difference here is that, this time, packages are matched by spec and
  6390. not by identity. In other words, any package in the graph that is called
  6391. @code{openssl} will be replaced.
  6392. A more generic procedure to rewrite a package dependency graph is
  6393. @code{package-mapping}: it supports arbitrary changes to nodes in the
  6394. graph.
  6395. @deffn {Scheme Procedure} package-mapping @var{proc} [@var{cut?}] [#:deep? #f]
  6396. Return a procedure that, given a package, applies @var{proc} to all the packages
  6397. depended on and returns the resulting package. The procedure stops recursion
  6398. when @var{cut?} returns true for a given package. When @var{deep?} is true, @var{proc} is
  6399. applied to implicit inputs as well.
  6400. @end deffn
  6401. @node Build Systems
  6402. @section Build Systems
  6403. @cindex build system
  6404. Each package definition specifies a @dfn{build system} and arguments for
  6405. that build system (@pxref{Defining Packages}). This @code{build-system}
  6406. field represents the build procedure of the package, as well as implicit
  6407. dependencies of that build procedure.
  6408. Build systems are @code{<build-system>} objects. The interface to
  6409. create and manipulate them is provided by the @code{(guix build-system)}
  6410. module, and actual build systems are exported by specific modules.
  6411. @cindex bag (low-level package representation)
  6412. Under the hood, build systems first compile package objects to
  6413. @dfn{bags}. A @dfn{bag} is like a package, but with less
  6414. ornamentation---in other words, a bag is a lower-level representation of
  6415. a package, which includes all the inputs of that package, including some
  6416. that were implicitly added by the build system. This intermediate
  6417. representation is then compiled to a derivation (@pxref{Derivations}).
  6418. The @code{package-with-c-toolchain} is an example of a way to change the
  6419. implicit inputs that a package's build system pulls in (@pxref{package
  6420. Reference, @code{package-with-c-toolchain}}).
  6421. Build systems accept an optional list of @dfn{arguments}. In package
  6422. definitions, these are passed @i{via} the @code{arguments} field
  6423. (@pxref{Defining Packages}). They are typically keyword arguments
  6424. (@pxref{Optional Arguments, keyword arguments in Guile,, guile, GNU
  6425. Guile Reference Manual}). The value of these arguments is usually
  6426. evaluated in the @dfn{build stratum}---i.e., by a Guile process launched
  6427. by the daemon (@pxref{Derivations}).
  6428. The main build system is @code{gnu-build-system}, which implements the
  6429. standard build procedure for GNU and many other packages. It
  6430. is provided by the @code{(guix build-system gnu)} module.
  6431. @defvr {Scheme Variable} gnu-build-system
  6432. @code{gnu-build-system} represents the GNU Build System, and variants
  6433. thereof (@pxref{Configuration, configuration and makefile conventions,,
  6434. standards, GNU Coding Standards}).
  6435. @cindex build phases
  6436. In a nutshell, packages using it are configured, built, and installed with
  6437. the usual @code{./configure && make && make check && make install}
  6438. command sequence. In practice, a few additional steps are often needed.
  6439. All these steps are split up in separate @dfn{phases}.
  6440. @xref{Build Phases}, for more info on build phases and ways to customize
  6441. them.
  6442. In addition, this build system ensures that the ``standard'' environment
  6443. for GNU packages is available. This includes tools such as GCC, libc,
  6444. Coreutils, Bash, Make, Diffutils, grep, and sed (see the @code{(guix
  6445. build-system gnu)} module for a complete list). We call these the
  6446. @dfn{implicit inputs} of a package, because package definitions do not
  6447. have to mention them.
  6448. This build system supports a number of keyword arguments, which can be
  6449. passed @i{via} the @code{arguments} field of a package. Here are some
  6450. of the main parameters:
  6451. @table @code
  6452. @item #:phases
  6453. This argument specifies build-side code that evaluates to an alist of
  6454. build phases. @xref{Build Phases}, for more information.
  6455. @item #:configure-flags
  6456. This is a list of flags (strings) passed to the @command{configure}
  6457. script. @xref{Defining Packages}, for an example.
  6458. @item #:make-flags
  6459. This list of strings contains flags passed as arguments to
  6460. @command{make} invocations in the @code{build}, @code{check}, and
  6461. @code{install} phases.
  6462. @item #:out-of-source?
  6463. This Boolean, @code{#f} by default, indicates whether to run builds in a
  6464. build directory separate from the source tree.
  6465. When it is true, the @code{configure} phase creates a separate build
  6466. directory, changes to that directory, and runs the @code{configure}
  6467. script from there. This is useful for packages that require it, such as
  6468. @code{glibc}.
  6469. @item #:tests?
  6470. This Boolean, @code{#t} by default, indicates whether the @code{check}
  6471. phase should run the package's test suite.
  6472. @item #:test-target
  6473. This string, @code{"check"} by default, gives the name of the makefile
  6474. target used by the @code{check} phase.
  6475. @item #:parallel-build?
  6476. @itemx #:parallel-tests?
  6477. These Boolean values specify whether to build, respectively run the test
  6478. suite, in parallel, with the @code{-j} flag of @command{make}. When
  6479. they are true, @code{make} is passed @code{-j@var{n}}, where @var{n} is
  6480. the number specified as the @option{--cores} option of
  6481. @command{guix-daemon} or that of the @command{guix} client command
  6482. (@pxref{Common Build Options, @option{--cores}}).
  6483. @cindex RUNPATH, validation
  6484. @item #:validate-runpath?
  6485. This Boolean, @code{#t} by default, determines whether to ``validate''
  6486. the @code{RUNPATH} of ELF binaries (@code{.so} shared libraries as well
  6487. as executables) previously installed by the @code{install} phase.
  6488. This validation step consists in making sure that all the shared
  6489. libraries needed by an ELF binary, which are listed as
  6490. @code{DT_NEEDED} entries in its @code{PT_DYNAMIC} segment, appear in the
  6491. @code{DT_RUNPATH} entry of that binary. In other words, it ensures that
  6492. running or using those binaries will not result in a ``file not found''
  6493. error at run time. @xref{Options, @option{-rpath},, ld, The GNU
  6494. Linker}, for more information on @code{RUNPATH}.
  6495. @item #:substitutable?
  6496. This Boolean, @code{#t} by default, tells whether the package outputs
  6497. should be substitutable---i.e., whether users should be able to obtain
  6498. substitutes for them instead of building locally (@pxref{Substitutes}).
  6499. @item #:allowed-references
  6500. @itemx #:disallowed-references
  6501. When true, these arguments must be a list of dependencies that must not
  6502. appear among the references of the build results. If, upon build
  6503. completion, some of these references are retained, the build process
  6504. fails.
  6505. This is useful to ensure that a package does not erroneously keep a
  6506. reference to some of it build-time inputs, in cases where doing so
  6507. would, for example, unnecessarily increase its size (@pxref{Invoking
  6508. guix size}).
  6509. @end table
  6510. Most other build systems support these keyword arguments.
  6511. @end defvr
  6512. Other @code{<build-system>} objects are defined to support other
  6513. conventions and tools used by free software packages. They inherit most
  6514. of @code{gnu-build-system}, and differ mainly in the set of inputs
  6515. implicitly added to the build process, and in the list of phases
  6516. executed. Some of these build systems are listed below.
  6517. @defvr {Scheme Variable} ant-build-system
  6518. This variable is exported by @code{(guix build-system ant)}. It
  6519. implements the build procedure for Java packages that can be built with
  6520. @url{https://ant.apache.org/, Ant build tool}.
  6521. It adds both @code{ant} and the @dfn{Java Development Kit} (JDK) as
  6522. provided by the @code{icedtea} package to the set of inputs. Different
  6523. packages can be specified with the @code{#:ant} and @code{#:jdk}
  6524. parameters, respectively.
  6525. When the original package does not provide a suitable Ant build file,
  6526. the parameter @code{#:jar-name} can be used to generate a minimal Ant
  6527. build file @file{build.xml} with tasks to build the specified jar
  6528. archive. In this case the parameter @code{#:source-dir} can be used to
  6529. specify the source sub-directory, defaulting to ``src''.
  6530. The @code{#:main-class} parameter can be used with the minimal ant
  6531. buildfile to specify the main class of the resulting jar. This makes the
  6532. jar file executable. The @code{#:test-include} parameter can be used to
  6533. specify the list of junit tests to run. It defaults to
  6534. @code{(list "**/*Test.java")}. The @code{#:test-exclude} can be used to
  6535. disable some tests. It defaults to @code{(list "**/Abstract*.java")},
  6536. because abstract classes cannot be run as tests.
  6537. The parameter @code{#:build-target} can be used to specify the Ant task
  6538. that should be run during the @code{build} phase. By default the
  6539. ``jar'' task will be run.
  6540. @end defvr
  6541. @defvr {Scheme Variable} android-ndk-build-system
  6542. @cindex Android distribution
  6543. @cindex Android NDK build system
  6544. This variable is exported by @code{(guix build-system android-ndk)}. It
  6545. implements a build procedure for Android NDK (native development kit)
  6546. packages using a Guix-specific build process.
  6547. The build system assumes that packages install their public interface
  6548. (header) files to the subdirectory @file{include} of the @code{out} output and
  6549. their libraries to the subdirectory @file{lib} the @code{out} output.
  6550. It's also assumed that the union of all the dependencies of a package
  6551. has no conflicting files.
  6552. For the time being, cross-compilation is not supported - so right now
  6553. the libraries and header files are assumed to be host tools.
  6554. @end defvr
  6555. @defvr {Scheme Variable} asdf-build-system/source
  6556. @defvrx {Scheme Variable} asdf-build-system/sbcl
  6557. @defvrx {Scheme Variable} asdf-build-system/ecl
  6558. These variables, exported by @code{(guix build-system asdf)}, implement
  6559. build procedures for Common Lisp packages using
  6560. @url{https://common-lisp.net/project/asdf/, ``ASDF''}. ASDF is a system
  6561. definition facility for Common Lisp programs and libraries.
  6562. The @code{asdf-build-system/source} system installs the packages in
  6563. source form, and can be loaded using any common lisp implementation, via
  6564. ASDF@. The others, such as @code{asdf-build-system/sbcl}, install binary
  6565. systems in the format which a particular implementation understands.
  6566. These build systems can also be used to produce executable programs, or
  6567. lisp images which contain a set of packages pre-loaded.
  6568. The build system uses naming conventions. For binary packages, the
  6569. package name should be prefixed with the lisp implementation, such as
  6570. @code{sbcl-} for @code{asdf-build-system/sbcl}.
  6571. Additionally, the corresponding source package should be labeled using
  6572. the same convention as python packages (see @ref{Python Modules}), using
  6573. the @code{cl-} prefix.
  6574. In order to create executable programs and images, the build-side
  6575. procedures @code{build-program} and @code{build-image} can be used.
  6576. They should be called in a build phase after the
  6577. @code{create-asdf-configuration} phase, so that the system which was
  6578. just built can be used within the resulting image. @code{build-program}
  6579. requires a list of Common Lisp expressions to be passed as the
  6580. @code{#:entry-program} argument.
  6581. By default, all the @file{.asd} files present in the sources are read to
  6582. find system definitions. The @code{#:asd-files} parameter can be used
  6583. to specify the list of @file{.asd} files to read. Furthermore, if the
  6584. package defines a system for its tests in a separate file, it will be
  6585. loaded before the tests are run if it is specified by the
  6586. @code{#:test-asd-file} parameter. If it is not set, the files
  6587. @code{<system>-tests.asd}, @code{<system>-test.asd}, @code{tests.asd},
  6588. and @code{test.asd} will be tried if they exist.
  6589. If for some reason the package must be named in a different way than the
  6590. naming conventions suggest, or if several systems must be compiled, the
  6591. @code{#:asd-systems} parameter can be used to specify the list of system
  6592. names.
  6593. @end defvr
  6594. @defvr {Scheme Variable} cargo-build-system
  6595. @cindex Rust programming language
  6596. @cindex Cargo (Rust build system)
  6597. This variable is exported by @code{(guix build-system cargo)}. It
  6598. supports builds of packages using Cargo, the build tool of the
  6599. @uref{https://www.rust-lang.org, Rust programming language}.
  6600. It adds @code{rustc} and @code{cargo} to the set of inputs.
  6601. A different Rust package can be specified with the @code{#:rust} parameter.
  6602. Regular cargo dependencies should be added to the package definition similarly
  6603. to other packages; those needed only at build time to native-inputs, others to
  6604. inputs. If you need to add source-only crates then you should add them to via
  6605. the @code{#:cargo-inputs} parameter as a list of name and spec pairs, where the
  6606. spec can be a package or a source definition. Note that the spec must
  6607. evaluate to a path to a gzipped tarball which includes a @code{Cargo.toml}
  6608. file at its root, or it will be ignored. Similarly, cargo dev-dependencies
  6609. should be added to the package definition via the
  6610. @code{#:cargo-development-inputs} parameter.
  6611. In its @code{configure} phase, this build system will make any source inputs
  6612. specified in the @code{#:cargo-inputs} and @code{#:cargo-development-inputs}
  6613. parameters available to cargo. It will also remove an included
  6614. @code{Cargo.lock} file to be recreated by @code{cargo} during the
  6615. @code{build} phase. The @code{package} phase will run @code{cargo package}
  6616. to create a source crate for future use. The @code{install} phase installs
  6617. the binaries defined by the crate. Unless @code{install-source? #f} is
  6618. defined it will also install a source crate repository of itself and unpacked
  6619. sources, to ease in future hacking on rust packages.
  6620. @end defvr
  6621. @defvr {Scheme Variable} chicken-build-system
  6622. This variable is exported by @code{(guix build-system chicken)}. It
  6623. builds @uref{https://call-cc.org/, CHICKEN Scheme} modules, also called
  6624. ``eggs'' or ``extensions''. CHICKEN generates C source code, which then
  6625. gets compiled by a C compiler, in this case GCC.
  6626. This build system adds @code{chicken} to the package inputs, as well as
  6627. the packages of @code{gnu-build-system}.
  6628. The build system can't (yet) deduce the egg's name automatically, so just like
  6629. with @code{go-build-system} and its @code{#:import-path}, you should define
  6630. @code{#:egg-name} in the package's @code{arguments} field.
  6631. For example, if you are packaging the @code{srfi-1} egg:
  6632. @lisp
  6633. (arguments '(#:egg-name "srfi-1"))
  6634. @end lisp
  6635. Egg dependencies must be defined in @code{propagated-inputs}, not @code{inputs}
  6636. because CHICKEN doesn't embed absolute references in compiled eggs.
  6637. Test dependencies should go to @code{native-inputs}, as usual.
  6638. @end defvr
  6639. @defvr {Scheme Variable} copy-build-system
  6640. This variable is exported by @code{(guix build-system copy)}. It
  6641. supports builds of simple packages that don't require much compiling,
  6642. mostly just moving files around.
  6643. It adds much of the @code{gnu-build-system} packages to the set of
  6644. inputs. Because of this, the @code{copy-build-system} does not require
  6645. all the boilerplate code often needed for the
  6646. @code{trivial-build-system}.
  6647. To further simplify the file installation process, an
  6648. @code{#:install-plan} argument is exposed to let the packager specify
  6649. which files go where. The install plan is a list of @code{(@var{source}
  6650. @var{target} [@var{filters}])}. @var{filters} are optional.
  6651. @itemize
  6652. @item When @var{source} matches a file or directory without trailing slash, install it to @var{target}.
  6653. @itemize
  6654. @item If @var{target} has a trailing slash, install @var{source} basename beneath @var{target}.
  6655. @item Otherwise install @var{source} as @var{target}.
  6656. @end itemize
  6657. @item When @var{source} is a directory with a trailing slash, or when @var{filters} are used,
  6658. the trailing slash of @var{target} is implied with the same meaning
  6659. as above.
  6660. @itemize
  6661. @item Without @var{filters}, install the full @var{source} @emph{content} to @var{target}.
  6662. @item With @var{filters} among @code{#:include}, @code{#:include-regexp}, @code{#:exclude},
  6663. @code{#:exclude-regexp}, only select files are installed depending on
  6664. the filters. Each filters is specified by a list of strings.
  6665. @itemize
  6666. @item With @code{#:include}, install all the files which the path suffix matches
  6667. at least one of the elements in the given list.
  6668. @item With @code{#:include-regexp}, install all the files which the
  6669. subpaths match at least one of the regular expressions in the given
  6670. list.
  6671. @item The @code{#:exclude} and @code{#:exclude-regexp} filters
  6672. are the complement of their inclusion counterpart. Without @code{#:include} flags,
  6673. install all files but those matching the exclusion filters.
  6674. If both inclusions and exclusions are specified, the exclusions are done
  6675. on top of the inclusions.
  6676. @end itemize
  6677. @end itemize
  6678. In all cases, the paths relative to @var{source} are preserved within
  6679. @var{target}.
  6680. @end itemize
  6681. Examples:
  6682. @itemize
  6683. @item @code{("foo/bar" "share/my-app/")}: Install @file{bar} to @file{share/my-app/bar}.
  6684. @item @code{("foo/bar" "share/my-app/baz")}: Install @file{bar} to @file{share/my-app/baz}.
  6685. @item @code{("foo/" "share/my-app")}: Install the content of @file{foo} inside @file{share/my-app},
  6686. e.g., install @file{foo/sub/file} to @file{share/my-app/sub/file}.
  6687. @item @code{("foo/" "share/my-app" #:include ("sub/file"))}: Install only @file{foo/sub/file} to
  6688. @file{share/my-app/sub/file}.
  6689. @item @code{("foo/sub" "share/my-app" #:include ("file"))}: Install @file{foo/sub/file} to
  6690. @file{share/my-app/file}.
  6691. @end itemize
  6692. @end defvr
  6693. @cindex Clojure (programming language)
  6694. @cindex simple Clojure build system
  6695. @defvr {Scheme Variable} clojure-build-system
  6696. This variable is exported by @code{(guix build-system clojure)}. It implements
  6697. a simple build procedure for @uref{https://clojure.org/, Clojure} packages
  6698. using plain old @code{compile} in Clojure. Cross-compilation is not supported
  6699. yet.
  6700. It adds @code{clojure}, @code{icedtea} and @code{zip} to the set of inputs.
  6701. Different packages can be specified with the @code{#:clojure}, @code{#:jdk} and
  6702. @code{#:zip} parameters, respectively.
  6703. A list of source directories, test directories and jar names can be specified
  6704. with the @code{#:source-dirs}, @code{#:test-dirs} and @code{#:jar-names}
  6705. parameters, respectively. Compile directory and main class can be specified
  6706. with the @code{#:compile-dir} and @code{#:main-class} parameters, respectively.
  6707. Other parameters are documented below.
  6708. This build system is an extension of @code{ant-build-system}, but with the
  6709. following phases changed:
  6710. @table @code
  6711. @item build
  6712. This phase calls @code{compile} in Clojure to compile source files and runs
  6713. @command{jar} to create jars from both source files and compiled files
  6714. according to the include list and exclude list specified in
  6715. @code{#:aot-include} and @code{#:aot-exclude}, respectively. The exclude list
  6716. has priority over the include list. These lists consist of symbols
  6717. representing Clojure libraries or the special keyword @code{#:all} representing
  6718. all Clojure libraries found under the source directories. The parameter
  6719. @code{#:omit-source?} decides if source should be included into the jars.
  6720. @item check
  6721. This phase runs tests according to the include list and exclude list specified
  6722. in @code{#:test-include} and @code{#:test-exclude}, respectively. Their
  6723. meanings are analogous to that of @code{#:aot-include} and
  6724. @code{#:aot-exclude}, except that the special keyword @code{#:all} now
  6725. stands for all Clojure libraries found under the test directories. The
  6726. parameter @code{#:tests?} decides if tests should be run.
  6727. @item install
  6728. This phase installs all jars built previously.
  6729. @end table
  6730. Apart from the above, this build system also contains an additional phase:
  6731. @table @code
  6732. @item install-doc
  6733. This phase installs all top-level files with base name matching
  6734. @code{%doc-regex}. A different regex can be specified with the
  6735. @code{#:doc-regex} parameter. All files (recursively) inside the documentation
  6736. directories specified in @code{#:doc-dirs} are installed as well.
  6737. @end table
  6738. @end defvr
  6739. @defvr {Scheme Variable} cmake-build-system
  6740. This variable is exported by @code{(guix build-system cmake)}. It
  6741. implements the build procedure for packages using the
  6742. @url{https://www.cmake.org, CMake build tool}.
  6743. It automatically adds the @code{cmake} package to the set of inputs.
  6744. Which package is used can be specified with the @code{#:cmake}
  6745. parameter.
  6746. The @code{#:configure-flags} parameter is taken as a list of flags
  6747. passed to the @command{cmake} command. The @code{#:build-type}
  6748. parameter specifies in abstract terms the flags passed to the compiler;
  6749. it defaults to @code{"RelWithDebInfo"} (short for ``release mode with
  6750. debugging information''), which roughly means that code is compiled with
  6751. @code{-O2 -g}, as is the case for Autoconf-based packages by default.
  6752. @end defvr
  6753. @defvr {Scheme Variable} dune-build-system
  6754. This variable is exported by @code{(guix build-system dune)}. It
  6755. supports builds of packages using @uref{https://dune.build/, Dune}, a build
  6756. tool for the OCaml programming language. It is implemented as an extension
  6757. of the @code{ocaml-build-system} which is described below. As such, the
  6758. @code{#:ocaml} and @code{#:findlib} parameters can be passed to this build
  6759. system.
  6760. It automatically adds the @code{dune} package to the set of inputs.
  6761. Which package is used can be specified with the @code{#:dune}
  6762. parameter.
  6763. There is no @code{configure} phase because dune packages typically don't
  6764. need to be configured. The @code{#:build-flags} parameter is taken as a
  6765. list of flags passed to the @code{dune} command during the build.
  6766. The @code{#:jbuild?} parameter can be passed to use the @code{jbuild}
  6767. command instead of the more recent @code{dune} command while building
  6768. a package. Its default value is @code{#f}.
  6769. The @code{#:package} parameter can be passed to specify a package name, which
  6770. is useful when a package contains multiple packages and you want to build
  6771. only one of them. This is equivalent to passing the @code{-p} argument to
  6772. @code{dune}.
  6773. @end defvr
  6774. @defvr {Scheme Variable} go-build-system
  6775. This variable is exported by @code{(guix build-system go)}. It
  6776. implements a build procedure for Go packages using the standard
  6777. @url{https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies,
  6778. Go build mechanisms}.
  6779. The user is expected to provide a value for the key @code{#:import-path}
  6780. and, in some cases, @code{#:unpack-path}. The
  6781. @url{https://golang.org/doc/code.html#ImportPaths, import path}
  6782. corresponds to the file system path expected by the package's build
  6783. scripts and any referring packages, and provides a unique way to
  6784. refer to a Go package. It is typically based on a combination of the
  6785. package source code's remote URI and file system hierarchy structure. In
  6786. some cases, you will need to unpack the package's source code to a
  6787. different directory structure than the one indicated by the import path,
  6788. and @code{#:unpack-path} should be used in such cases.
  6789. Packages that provide Go libraries should install their source code into
  6790. the built output. The key @code{#:install-source?}, which defaults to
  6791. @code{#t}, controls whether or not the source code is installed. It can
  6792. be set to @code{#f} for packages that only provide executable files.
  6793. Packages can be cross-built, and if a specific architecture or operating
  6794. system is desired then the keywords @code{#:goarch} and @code{#:goos}
  6795. can be used to force the package to be built for that architecture and
  6796. operating system. The combinations known to Go can be found
  6797. @url{"https://golang.org/doc/install/source#environment", in their
  6798. documentation}.
  6799. @end defvr
  6800. @defvr {Scheme Variable} glib-or-gtk-build-system
  6801. This variable is exported by @code{(guix build-system glib-or-gtk)}. It
  6802. is intended for use with packages making use of GLib or GTK+.
  6803. This build system adds the following two phases to the ones defined by
  6804. @code{gnu-build-system}:
  6805. @table @code
  6806. @item glib-or-gtk-wrap
  6807. The phase @code{glib-or-gtk-wrap} ensures that programs in
  6808. @file{bin/} are able to find GLib ``schemas'' and
  6809. @uref{https://developer.gnome.org/gtk3/stable/gtk-running.html, GTK+
  6810. modules}. This is achieved by wrapping the programs in launch scripts
  6811. that appropriately set the @env{XDG_DATA_DIRS} and @env{GTK_PATH}
  6812. environment variables.
  6813. It is possible to exclude specific package outputs from that wrapping
  6814. process by listing their names in the
  6815. @code{#:glib-or-gtk-wrap-excluded-outputs} parameter. This is useful
  6816. when an output is known not to contain any GLib or GTK+ binaries, and
  6817. where wrapping would gratuitously add a dependency of that output on
  6818. GLib and GTK+.
  6819. @item glib-or-gtk-compile-schemas
  6820. The phase @code{glib-or-gtk-compile-schemas} makes sure that all
  6821. @uref{https://developer.gnome.org/gio/stable/glib-compile-schemas.html,
  6822. GSettings schemas} of GLib are compiled. Compilation is performed by the
  6823. @command{glib-compile-schemas} program. It is provided by the package
  6824. @code{glib:bin} which is automatically imported by the build system.
  6825. The @code{glib} package providing @command{glib-compile-schemas} can be
  6826. specified with the @code{#:glib} parameter.
  6827. @end table
  6828. Both phases are executed after the @code{install} phase.
  6829. @end defvr
  6830. @defvr {Scheme Variable} guile-build-system
  6831. This build system is for Guile packages that consist exclusively of Scheme
  6832. code and that are so lean that they don't even have a makefile, let alone a
  6833. @file{configure} script. It compiles Scheme code using @command{guild
  6834. compile} (@pxref{Compilation,,, guile, GNU Guile Reference Manual}) and
  6835. installs the @file{.scm} and @file{.go} files in the right place. It also
  6836. installs documentation.
  6837. This build system supports cross-compilation by using the
  6838. @option{--target} option of @samp{guild compile}.
  6839. Packages built with @code{guile-build-system} must provide a Guile package in
  6840. their @code{native-inputs} field.
  6841. @end defvr
  6842. @defvr {Scheme Variable} julia-build-system
  6843. This variable is exported by @code{(guix build-system julia)}. It
  6844. implements the build procedure used by @uref{https://julialang.org/,
  6845. julia} packages, which essentially is similar to running @samp{julia -e
  6846. 'using Pkg; Pkg.add(package)'} in an environment where
  6847. @env{JULIA_LOAD_PATH} contains the paths to all Julia package inputs.
  6848. Tests are run by calling @code{/test/runtests.jl}.
  6849. The Julia package name and uuid is read from the file
  6850. @file{Project.toml}. These values can be overridden by passing the
  6851. argument @code{#:julia-package-name} (which must be correctly
  6852. capitalized) or @code{#:julia-package-uuid}.
  6853. Julia packages usually manage their binary dependencies via
  6854. @code{JLLWrappers.jl}, a Julia package that creates a module (named
  6855. after the wrapped library followed by @code{_jll.jl}.
  6856. To add the binary path @code{_jll.jl} packages, you need to patch the
  6857. files under @file{src/wrappers/}, replacing the call to the macro
  6858. @code{JLLWrappers.@@generate_wrapper_header}, adding as a second
  6859. argument containing the store path the binary.
  6860. As an example, in the MbedTLS Julia package, we add a build phase
  6861. (@pxref{Build Phases}) to insert the absolute file name of the wrapped
  6862. MbedTLS package:
  6863. @lisp
  6864. (add-after 'unpack 'override-binary-path
  6865. (lambda* (#:key inputs #:allow-other-keys)
  6866. (for-each (lambda (wrapper)
  6867. (substitute* wrapper
  6868. (("generate_wrapper_header.*")
  6869. (string-append
  6870. "generate_wrapper_header(\"MbedTLS\", \""
  6871. (assoc-ref inputs "mbedtls-apache") "\")\n"))))
  6872. ;; There's a Julia file for each platform, override them all.
  6873. (find-files "src/wrappers/" "\\.jl$"))))
  6874. @end lisp
  6875. Some older packages that aren't using @file{Project.toml} yet, will
  6876. require this file to be created, too. It is internally done if the
  6877. arguments @code{#:julia-package-name} and @code{#:julia-package-uuid}
  6878. are provided.
  6879. @end defvr
  6880. @defvr {Scheme Variable} maven-build-system
  6881. This variable is exported by @code{(guix build-system maven)}. It implements
  6882. a build procedure for @uref{https://maven.apache.org, Maven} packages. Maven
  6883. is a dependency and lifecycle management tool for Java. A user of Maven
  6884. specifies dependencies and plugins in a @file{pom.xml} file that Maven reads.
  6885. When Maven does not have one of the dependencies or plugins in its repository,
  6886. it will download them and use them to build the package.
  6887. The maven build system ensures that maven will not try to download any
  6888. dependency by running in offline mode. Maven will fail if a dependency is
  6889. missing. Before running Maven, the @file{pom.xml} (and subprojects) are
  6890. modified to specify the version of dependencies and plugins that match the
  6891. versions available in the guix build environment. Dependencies and plugins
  6892. must be installed in the fake maven repository at @file{lib/m2}, and are
  6893. symlinked into a proper repository before maven is run. Maven is instructed
  6894. to use that repository for the build and installs built artifacts there.
  6895. Changed files are copied to the @file{lib/m2} directory of the package output.
  6896. You can specify a @file{pom.xml} file with the @code{#:pom-file} argument,
  6897. or let the build system use the default @file{pom.xml} file in the sources.
  6898. In case you need to specify a dependency's version manually, you can use the
  6899. @code{#:local-packages} argument. It takes an association list where the key
  6900. is the groupId of the package and its value is an association list where the
  6901. key is the artifactId of the package and its value is the version you want to
  6902. override in the @file{pom.xml}.
  6903. Some packages use dependencies or plugins that are not useful at runtime nor
  6904. at build time in Guix. You can alter the @file{pom.xml} file to remove them
  6905. using the @code{#:exclude} argument. Its value is an association list where
  6906. the key is the groupId of the plugin or dependency you want to remove, and
  6907. the value is a list of artifactId you want to remove.
  6908. You can override the default @code{jdk} and @code{maven} packages with the
  6909. corresponding argument, @code{#:jdk} and @code{#:maven}.
  6910. The @code{#:maven-plugins} argument is a list of maven plugins used during
  6911. the build, with the same format as the @code{inputs} fields of the package
  6912. declaration. Its default value is @code{(default-maven-plugins)} which is
  6913. also exported.
  6914. @end defvr
  6915. @defvr {Scheme Variable} minetest-mod-build-system
  6916. This variable is exported by @code{(guix build-system minetest)}. It
  6917. implements a build procedure for @uref{https://www.minetest.net, Minetest}
  6918. mods, which consists of copying Lua code, images and other resources to
  6919. the location Minetest searches for mods. The build system also minimises
  6920. PNG images and verifies that Minetest can load the mod without errors.
  6921. @end defvr
  6922. @defvr {Scheme Variable} minify-build-system
  6923. This variable is exported by @code{(guix build-system minify)}. It
  6924. implements a minification procedure for simple JavaScript packages.
  6925. It adds @code{uglify-js} to the set of inputs and uses it to compress
  6926. all JavaScript files in the @file{src} directory. A different minifier
  6927. package can be specified with the @code{#:uglify-js} parameter, but it
  6928. is expected that the package writes the minified code to the standard
  6929. output.
  6930. When the input JavaScript files are not all located in the @file{src}
  6931. directory, the parameter @code{#:javascript-files} can be used to
  6932. specify a list of file names to feed to the minifier.
  6933. @end defvr
  6934. @defvr {Scheme Variable} ocaml-build-system
  6935. This variable is exported by @code{(guix build-system ocaml)}. It implements
  6936. a build procedure for @uref{https://ocaml.org, OCaml} packages, which consists
  6937. of choosing the correct set of commands to run for each package. OCaml
  6938. packages can expect many different commands to be run. This build system will
  6939. try some of them.
  6940. When the package has a @file{setup.ml} file present at the top-level, it will
  6941. run @code{ocaml setup.ml -configure}, @code{ocaml setup.ml -build} and
  6942. @code{ocaml setup.ml -install}. The build system will assume that this file
  6943. was generated by @uref{http://oasis.forge.ocamlcore.org/, OASIS} and will take
  6944. care of setting the prefix and enabling tests if they are not disabled. You
  6945. can pass configure and build flags with the @code{#:configure-flags} and
  6946. @code{#:build-flags}. The @code{#:test-flags} key can be passed to change the
  6947. set of flags used to enable tests. The @code{#:use-make?} key can be used to
  6948. bypass this system in the build and install phases.
  6949. When the package has a @file{configure} file, it is assumed that it is a
  6950. hand-made configure script that requires a different argument format than
  6951. in the @code{gnu-build-system}. You can add more flags with the
  6952. @code{#:configure-flags} key.
  6953. When the package has a @file{Makefile} file (or @code{#:use-make?} is
  6954. @code{#t}), it will be used and more flags can be passed to the build and
  6955. install phases with the @code{#:make-flags} key.
  6956. Finally, some packages do not have these files and use a somewhat standard
  6957. location for its build system. In that case, the build system will run
  6958. @code{ocaml pkg/pkg.ml} or @code{ocaml pkg/build.ml} and take care of
  6959. providing the path to the required findlib module. Additional flags can
  6960. be passed via the @code{#:build-flags} key. Install is taken care of by
  6961. @command{opam-installer}. In this case, the @code{opam} package must
  6962. be added to the @code{native-inputs} field of the package definition.
  6963. Note that most OCaml packages assume they will be installed in the same
  6964. directory as OCaml, which is not what we want in guix. In particular, they
  6965. will install @file{.so} files in their module's directory, which is usually
  6966. fine because it is in the OCaml compiler directory. In guix though, these
  6967. libraries cannot be found and we use @env{CAML_LD_LIBRARY_PATH}. This
  6968. variable points to @file{lib/ocaml/site-lib/stubslibs} and this is where
  6969. @file{.so} libraries should be installed.
  6970. @end defvr
  6971. @defvr {Scheme Variable} python-build-system
  6972. This variable is exported by @code{(guix build-system python)}. It
  6973. implements the more or less standard build procedure used by Python
  6974. packages, which consists in running @code{python setup.py build} and
  6975. then @code{python setup.py install --prefix=/gnu/store/@dots{}}.
  6976. For packages that install stand-alone Python programs under @code{bin/},
  6977. it takes care of wrapping these programs so that their
  6978. @env{GUIX_PYTHONPATH} environment variable points to all the Python
  6979. libraries they depend on.
  6980. Which Python package is used to perform the build can be specified with
  6981. the @code{#:python} parameter. This is a useful way to force a package
  6982. to be built for a specific version of the Python interpreter, which
  6983. might be necessary if the package is only compatible with a single
  6984. interpreter version.
  6985. By default guix calls @code{setup.py} under control of
  6986. @code{setuptools}, much like @command{pip} does. Some packages are not
  6987. compatible with setuptools (and pip), thus you can disable this by
  6988. setting the @code{#:use-setuptools?} parameter to @code{#f}.
  6989. If a @code{"python"} output is available, the package is installed into it
  6990. instead of the default @code{"out"} output. This is useful for packages that
  6991. include a Python package as only a part of the software, and thus want to
  6992. combine the phases of @code{python-build-system} with another build system.
  6993. Python bindings are a common usecase.
  6994. @end defvr
  6995. @defvr {Scheme Variable} perl-build-system
  6996. This variable is exported by @code{(guix build-system perl)}. It
  6997. implements the standard build procedure for Perl packages, which either
  6998. consists in running @code{perl Build.PL --prefix=/gnu/store/@dots{}},
  6999. followed by @code{Build} and @code{Build install}; or in running
  7000. @code{perl Makefile.PL PREFIX=/gnu/store/@dots{}}, followed by
  7001. @code{make} and @code{make install}, depending on which of
  7002. @code{Build.PL} or @code{Makefile.PL} is present in the package
  7003. distribution. Preference is given to the former if both @code{Build.PL}
  7004. and @code{Makefile.PL} exist in the package distribution. This
  7005. preference can be reversed by specifying @code{#t} for the
  7006. @code{#:make-maker?} parameter.
  7007. The initial @code{perl Makefile.PL} or @code{perl Build.PL} invocation
  7008. passes flags specified by the @code{#:make-maker-flags} or
  7009. @code{#:module-build-flags} parameter, respectively.
  7010. Which Perl package is used can be specified with @code{#:perl}.
  7011. @end defvr
  7012. @defvr {Scheme Variable} renpy-build-system
  7013. This variable is exported by @code{(guix build-system renpy)}. It implements
  7014. the more or less standard build procedure used by Ren'py games, which consists
  7015. of loading @code{#:game} once, thereby creating bytecode for it.
  7016. It further creates a wrapper script in @code{bin/} and a desktop entry in
  7017. @code{share/applications}, both of which can be used to launch the game.
  7018. Which Ren'py package is used can be specified with @code{#:renpy}.
  7019. Games can also be installed in outputs other than ``out'' by using
  7020. @code{#:output}.
  7021. @end defvr
  7022. @defvr {Scheme Variable} qt-build-system
  7023. This variable is exported by @code{(guix build-system qt)}. It
  7024. is intended for use with applications using Qt or KDE.
  7025. This build system adds the following two phases to the ones defined by
  7026. @code{cmake-build-system}:
  7027. @table @code
  7028. @item check-setup
  7029. The phase @code{check-setup} prepares the environment for running
  7030. the checks as commonly used by Qt test programs.
  7031. For now this only sets some environment variables:
  7032. @code{QT_QPA_PLATFORM=offscreen},
  7033. @code{DBUS_FATAL_WARNINGS=0} and
  7034. @code{CTEST_OUTPUT_ON_FAILURE=1}.
  7035. This phase is added before the @code{check} phase.
  7036. It's a separate phase to ease adjusting if necessary.
  7037. @item qt-wrap
  7038. The phase @code{qt-wrap}
  7039. searches for Qt5 plugin paths, QML paths and some XDG in the inputs
  7040. and output. In case some path is found, all programs in the output's
  7041. @file{bin/}, @file{sbin/}, @file{libexec/} and @file{lib/libexec/} directories
  7042. are wrapped in scripts defining the necessary environment variables.
  7043. It is possible to exclude specific package outputs from that wrapping process
  7044. by listing their names in the @code{#:qt-wrap-excluded-outputs} parameter.
  7045. This is useful when an output is known not to contain any Qt binaries, and
  7046. where wrapping would gratuitously add a dependency of that output on Qt, KDE,
  7047. or such.
  7048. This phase is added after the @code{install} phase.
  7049. @end table
  7050. @end defvr
  7051. @defvr {Scheme Variable} r-build-system
  7052. This variable is exported by @code{(guix build-system r)}. It
  7053. implements the build procedure used by @uref{https://r-project.org, R}
  7054. packages, which essentially is little more than running @samp{R CMD
  7055. INSTALL --library=/gnu/store/@dots{}} in an environment where
  7056. @env{R_LIBS_SITE} contains the paths to all R package inputs. Tests are
  7057. run after installation using the R function
  7058. @code{tools::testInstalledPackage}.
  7059. @end defvr
  7060. @defvr {Scheme Variable} rakudo-build-system
  7061. This variable is exported by @code{(guix build-system rakudo)}. It
  7062. implements the build procedure used by @uref{https://rakudo.org/,
  7063. Rakudo} for @uref{https://perl6.org/, Perl6} packages. It installs the
  7064. package to @code{/gnu/store/@dots{}/NAME-VERSION/share/perl6} and
  7065. installs the binaries, library files and the resources, as well as wrap
  7066. the files under the @code{bin/} directory. Tests can be skipped by
  7067. passing @code{#f} to the @code{tests?} parameter.
  7068. Which rakudo package is used can be specified with @code{rakudo}.
  7069. Which perl6-tap-harness package used for the tests can be specified with
  7070. @code{#:prove6} or removed by passing @code{#f} to the
  7071. @code{with-prove6?} parameter.
  7072. Which perl6-zef package used for tests and installing can be specified
  7073. with @code{#:zef} or removed by passing @code{#f} to the
  7074. @code{with-zef?} parameter.
  7075. @end defvr
  7076. @defvr {Scheme Variable} texlive-build-system
  7077. This variable is exported by @code{(guix build-system texlive)}. It is
  7078. used to build TeX packages in batch mode with a specified engine. The
  7079. build system sets the @env{TEXINPUTS} variable to find all TeX source
  7080. files in the inputs.
  7081. By default it runs @code{luatex} on all files ending on @code{ins}. A
  7082. different engine and format can be specified with the
  7083. @code{#:tex-format} argument. Different build targets can be specified
  7084. with the @code{#:build-targets} argument, which expects a list of file
  7085. names. The build system adds only @code{texlive-bin} and
  7086. @code{texlive-latex-base} (both from @code{(gnu packages tex}) to the
  7087. inputs. Both can be overridden with the arguments @code{#:texlive-bin}
  7088. and @code{#:texlive-latex-base}, respectively.
  7089. The @code{#:tex-directory} parameter tells the build system where to
  7090. install the built files under the texmf tree.
  7091. @end defvr
  7092. @defvr {Scheme Variable} ruby-build-system
  7093. This variable is exported by @code{(guix build-system ruby)}. It
  7094. implements the RubyGems build procedure used by Ruby packages, which
  7095. involves running @code{gem build} followed by @code{gem install}.
  7096. The @code{source} field of a package that uses this build system
  7097. typically references a gem archive, since this is the format that Ruby
  7098. developers use when releasing their software. The build system unpacks
  7099. the gem archive, potentially patches the source, runs the test suite,
  7100. repackages the gem, and installs it. Additionally, directories and
  7101. tarballs may be referenced to allow building unreleased gems from Git or
  7102. a traditional source release tarball.
  7103. Which Ruby package is used can be specified with the @code{#:ruby}
  7104. parameter. A list of additional flags to be passed to the @command{gem}
  7105. command can be specified with the @code{#:gem-flags} parameter.
  7106. @end defvr
  7107. @defvr {Scheme Variable} waf-build-system
  7108. This variable is exported by @code{(guix build-system waf)}. It
  7109. implements a build procedure around the @code{waf} script. The common
  7110. phases---@code{configure}, @code{build}, and @code{install}---are
  7111. implemented by passing their names as arguments to the @code{waf}
  7112. script.
  7113. The @code{waf} script is executed by the Python interpreter. Which
  7114. Python package is used to run the script can be specified with the
  7115. @code{#:python} parameter.
  7116. @end defvr
  7117. @defvr {Scheme Variable} scons-build-system
  7118. This variable is exported by @code{(guix build-system scons)}. It
  7119. implements the build procedure used by the SCons software construction
  7120. tool. This build system runs @code{scons} to build the package,
  7121. @code{scons test} to run tests, and then @code{scons install} to install
  7122. the package.
  7123. Additional flags to be passed to @code{scons} can be specified with the
  7124. @code{#:scons-flags} parameter. The default build and install targets
  7125. can be overridden with @code{#:build-targets} and
  7126. @code{#:install-targets} respectively. The version of Python used to
  7127. run SCons can be specified by selecting the appropriate SCons package
  7128. with the @code{#:scons} parameter.
  7129. @end defvr
  7130. @defvr {Scheme Variable} haskell-build-system
  7131. This variable is exported by @code{(guix build-system haskell)}. It
  7132. implements the Cabal build procedure used by Haskell packages, which
  7133. involves running @code{runhaskell Setup.hs configure
  7134. --prefix=/gnu/store/@dots{}} and @code{runhaskell Setup.hs build}.
  7135. Instead of installing the package by running @code{runhaskell Setup.hs
  7136. install}, to avoid trying to register libraries in the read-only
  7137. compiler store directory, the build system uses @code{runhaskell
  7138. Setup.hs copy}, followed by @code{runhaskell Setup.hs register}. In
  7139. addition, the build system generates the package documentation by
  7140. running @code{runhaskell Setup.hs haddock}, unless @code{#:haddock? #f}
  7141. is passed. Optional Haddock parameters can be passed with the help of
  7142. the @code{#:haddock-flags} parameter. If the file @code{Setup.hs} is
  7143. not found, the build system looks for @code{Setup.lhs} instead.
  7144. Which Haskell compiler is used can be specified with the @code{#:haskell}
  7145. parameter which defaults to @code{ghc}.
  7146. @end defvr
  7147. @defvr {Scheme Variable} dub-build-system
  7148. This variable is exported by @code{(guix build-system dub)}. It
  7149. implements the Dub build procedure used by D packages, which
  7150. involves running @code{dub build} and @code{dub run}.
  7151. Installation is done by copying the files manually.
  7152. Which D compiler is used can be specified with the @code{#:ldc}
  7153. parameter which defaults to @code{ldc}.
  7154. @end defvr
  7155. @anchor{emacs-build-system}
  7156. @defvr {Scheme Variable} emacs-build-system
  7157. This variable is exported by @code{(guix build-system emacs)}. It
  7158. implements an installation procedure similar to the packaging system
  7159. of Emacs itself (@pxref{Packages,,, emacs, The GNU Emacs Manual}).
  7160. It first creates the @code{@code{package}-autoloads.el} file, then it
  7161. byte compiles all Emacs Lisp files. Differently from the Emacs
  7162. packaging system, the Info documentation files are moved to the standard
  7163. documentation directory and the @file{dir} file is deleted. The Elisp
  7164. package files are installed directly under @file{share/emacs/site-lisp}.
  7165. @end defvr
  7166. @defvr {Scheme Variable} font-build-system
  7167. This variable is exported by @code{(guix build-system font)}. It
  7168. implements an installation procedure for font packages where upstream
  7169. provides pre-compiled TrueType, OpenType, etc.@: font files that merely
  7170. need to be copied into place. It copies font files to standard
  7171. locations in the output directory.
  7172. @end defvr
  7173. @defvr {Scheme Variable} meson-build-system
  7174. This variable is exported by @code{(guix build-system meson)}. It
  7175. implements the build procedure for packages that use
  7176. @url{https://mesonbuild.com, Meson} as their build system.
  7177. It adds both Meson and @uref{https://ninja-build.org/, Ninja} to the set
  7178. of inputs, and they can be changed with the parameters @code{#:meson}
  7179. and @code{#:ninja} if needed.
  7180. This build system is an extension of @code{gnu-build-system}, but with the
  7181. following phases changed to some specific for Meson:
  7182. @table @code
  7183. @item configure
  7184. The phase runs @code{meson} with the flags specified in
  7185. @code{#:configure-flags}. The flag @option{--buildtype} is always set to
  7186. @code{debugoptimized} unless something else is specified in
  7187. @code{#:build-type}.
  7188. @item build
  7189. The phase runs @code{ninja} to build the package in parallel by default, but
  7190. this can be changed with @code{#:parallel-build?}.
  7191. @item check
  7192. The phase runs @samp{meson test} with a base set of options that cannot
  7193. be overridden. This base set of options can be extended via the
  7194. @code{#:test-options} argument, for example to select or skip a specific
  7195. test suite.
  7196. @item install
  7197. The phase runs @code{ninja install} and can not be changed.
  7198. @end table
  7199. Apart from that, the build system also adds the following phases:
  7200. @table @code
  7201. @item fix-runpath
  7202. This phase ensures that all binaries can find the libraries they need.
  7203. It searches for required libraries in subdirectories of the package
  7204. being built, and adds those to @code{RUNPATH} where needed. It also
  7205. removes references to libraries left over from the build phase by
  7206. @code{meson}, such as test dependencies, that aren't actually required
  7207. for the program to run.
  7208. @item glib-or-gtk-wrap
  7209. This phase is the phase provided by @code{glib-or-gtk-build-system}, and it
  7210. is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
  7211. @item glib-or-gtk-compile-schemas
  7212. This phase is the phase provided by @code{glib-or-gtk-build-system}, and it
  7213. is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
  7214. @end table
  7215. @end defvr
  7216. @defvr {Scheme Variable} linux-module-build-system
  7217. @code{linux-module-build-system} allows building Linux kernel modules.
  7218. @cindex build phases
  7219. This build system is an extension of @code{gnu-build-system}, but with the
  7220. following phases changed:
  7221. @table @code
  7222. @item configure
  7223. This phase configures the environment so that the Linux kernel's Makefile
  7224. can be used to build the external kernel module.
  7225. @item build
  7226. This phase uses the Linux kernel's Makefile in order to build the external
  7227. kernel module.
  7228. @item install
  7229. This phase uses the Linux kernel's Makefile in order to install the external
  7230. kernel module.
  7231. @end table
  7232. It is possible and useful to specify the Linux kernel to use for building
  7233. the module (in the @code{arguments} form of a package using the
  7234. @code{linux-module-build-system}, use the key @code{#:linux} to specify it).
  7235. @end defvr
  7236. @defvr {Scheme Variable} node-build-system
  7237. This variable is exported by @code{(guix build-system node)}. It
  7238. implements the build procedure used by @uref{https://nodejs.org,
  7239. Node.js}, which implements an approximation of the @code{npm install}
  7240. command, followed by an @code{npm test} command.
  7241. Which Node.js package is used to interpret the @code{npm} commands can
  7242. be specified with the @code{#:node} parameter which defaults to
  7243. @code{node}.
  7244. @end defvr
  7245. Lastly, for packages that do not need anything as sophisticated, a
  7246. ``trivial'' build system is provided. It is trivial in the sense that
  7247. it provides basically no support: it does not pull any implicit inputs,
  7248. and does not have a notion of build phases.
  7249. @defvr {Scheme Variable} trivial-build-system
  7250. This variable is exported by @code{(guix build-system trivial)}.
  7251. This build system requires a @code{#:builder} argument. This argument
  7252. must be a Scheme expression that builds the package output(s)---as
  7253. with @code{build-expression->derivation} (@pxref{Derivations,
  7254. @code{build-expression->derivation}}).
  7255. @end defvr
  7256. @node Build Phases
  7257. @section Build Phases
  7258. @cindex build phases, for packages
  7259. Almost all package build systems implement a notion @dfn{build phases}:
  7260. a sequence of actions that the build system executes, when you build the
  7261. package, leading to the installed byproducts in the store. A notable
  7262. exception is the ``bare-bones'' @code{trivial-build-system}
  7263. (@pxref{Build Systems}).
  7264. As discussed in the previous section, those build systems provide a
  7265. standard list of phases. For @code{gnu-build-system}, the main build
  7266. phases are the following:
  7267. @table @code
  7268. @item set-paths
  7269. Define search path environment variables for all the input packages,
  7270. including @env{PATH} (@pxref{Search Paths}).
  7271. @item unpack
  7272. Unpack the source tarball, and change the current directory to the
  7273. extracted source tree. If the source is actually a directory, copy it
  7274. to the build tree, and enter that directory.
  7275. @item patch-source-shebangs
  7276. Patch shebangs encountered in source files so they refer to the right
  7277. store file names. For instance, this changes @code{#!/bin/sh} to
  7278. @code{#!/gnu/store/@dots{}-bash-4.3/bin/sh}.
  7279. @item configure
  7280. Run the @file{configure} script with a number of default options, such
  7281. as @option{--prefix=/gnu/store/@dots{}}, as well as the options specified
  7282. by the @code{#:configure-flags} argument.
  7283. @item build
  7284. Run @code{make} with the list of flags specified with
  7285. @code{#:make-flags}. If the @code{#:parallel-build?} argument is true
  7286. (the default), build with @code{make -j}.
  7287. @item check
  7288. Run @code{make check}, or some other target specified with
  7289. @code{#:test-target}, unless @code{#:tests? #f} is passed. If the
  7290. @code{#:parallel-tests?} argument is true (the default), run @code{make
  7291. check -j}.
  7292. @item install
  7293. Run @code{make install} with the flags listed in @code{#:make-flags}.
  7294. @item patch-shebangs
  7295. Patch shebangs on the installed executable files.
  7296. @item strip
  7297. Strip debugging symbols from ELF files (unless @code{#:strip-binaries?}
  7298. is false), copying them to the @code{debug} output when available
  7299. (@pxref{Installing Debugging Files}).
  7300. @end table
  7301. Other build systems have similar phases, with some variations. For
  7302. example, @code{cmake-build-system} has same-named phases but its
  7303. @code{configure} phases runs @code{cmake} instead of @code{./configure}.
  7304. Others, such as @code{python-build-system}, have a wholly different list
  7305. of standard phases. All this code runs on the @dfn{build side}: it is
  7306. evaluated when you actually build the package, in a dedicated build
  7307. process spawned by the build daemon (@pxref{Invoking guix-daemon}).
  7308. Build phases are represented as association lists or ``alists''
  7309. (@pxref{Association Lists,,, guile, GNU Guile Reference Manual}) where
  7310. each key is a symbol for the name of the phase and the associated value
  7311. is a procedure that accepts an arbitrary number of arguments. By
  7312. convention, those procedures receive information about the build in the
  7313. form of @dfn{keyword parameters}, which they can use or ignore.
  7314. @vindex %standard-phases
  7315. For example, here is how @code{(guix build gnu-build-system)} defines
  7316. @code{%standard-phases}, the variable holding its alist of build
  7317. phases@footnote{We present a simplified view of those build phases, but
  7318. do take a look at @code{(guix build gnu-build-system)} to see all the
  7319. details!}:
  7320. @lisp
  7321. ;; The build phases of 'gnu-build-system'.
  7322. (define* (unpack #:key source #:allow-other-keys)
  7323. ;; Extract the source tarball.
  7324. (invoke "tar" "xvf" source))
  7325. (define* (configure #:key outputs #:allow-other-keys)
  7326. ;; Run the 'configure' script. Install to output "out".
  7327. (let ((out (assoc-ref outputs "out")))
  7328. (invoke "./configure"
  7329. (string-append "--prefix=" out))))
  7330. (define* (build #:allow-other-keys)
  7331. ;; Compile.
  7332. (invoke "make"))
  7333. (define* (check #:key (test-target "check") (tests? #true)
  7334. #:allow-other-keys)
  7335. ;; Run the test suite.
  7336. (if tests?
  7337. (invoke "make" test-target)
  7338. (display "test suite not run\n")))
  7339. (define* (install #:allow-other-keys)
  7340. ;; Install files to the prefix 'configure' specified.
  7341. (invoke "make" "install"))
  7342. (define %standard-phases
  7343. ;; The list of standard phases (quite a few are omitted
  7344. ;; for brevity). Each element is a symbol/procedure pair.
  7345. (list (cons 'unpack unpack)
  7346. (cons 'configure configure)
  7347. (cons 'build build)
  7348. (cons 'check check)
  7349. (cons 'install install)))
  7350. @end lisp
  7351. This shows how @code{%standard-phases} is defined as a list of
  7352. symbol/procedure pairs (@pxref{Pairs,,, guile, GNU Guile Reference
  7353. Manual}). The first pair associates the @code{unpack} procedure with
  7354. the @code{unpack} symbol---a name; the second pair defines the
  7355. @code{configure} phase similarly, and so on. When building a package
  7356. that uses @code{gnu-build-system} with its default list of phases, those
  7357. phases are executed sequentially. You can see the name of each phase
  7358. started and completed in the build log of packages that you build.
  7359. Let's now look at the procedures themselves. Each one is defined with
  7360. @code{define*}: @code{#:key} lists keyword parameters the procedure
  7361. accepts, possibly with a default value, and @code{#:allow-other-keys}
  7362. specifies that other keyword parameters are ignored (@pxref{Optional
  7363. Arguments,,, guile, GNU Guile Reference Manual}).
  7364. The @code{unpack} procedure honors the @code{source} parameter, which
  7365. the build system uses to pass the file name of the source tarball (or
  7366. version control checkout), and it ignores other parameters. The
  7367. @code{configure} phase only cares about the @code{outputs} parameter, an
  7368. alist mapping package output names to their store file name
  7369. (@pxref{Packages with Multiple Outputs}). It extracts the file name of
  7370. for @code{out}, the default output, and passes it to
  7371. @command{./configure} as the installation prefix, meaning that
  7372. @command{make install} will eventually copy all the files in that
  7373. directory (@pxref{Configuration, configuration and makefile
  7374. conventions,, standards, GNU Coding Standards}). @code{build} and
  7375. @code{install} ignore all their arguments. @code{check} honors the
  7376. @code{test-target} argument, which specifies the name of the Makefile
  7377. target to run tests; it prints a message and skips tests when
  7378. @code{tests?} is false.
  7379. @cindex build phases, customizing
  7380. The list of phases used for a particular package can be changed with the
  7381. @code{#:phases} parameter of the build system. Changing the set of
  7382. build phases boils down to building a new alist of phases based on the
  7383. @code{%standard-phases} alist described above. This can be done with
  7384. standard alist procedures such as @code{alist-delete} (@pxref{SRFI-1
  7385. Association Lists,,, guile, GNU Guile Reference Manual}); however, it is
  7386. more convenient to do so with @code{modify-phases} (@pxref{Build
  7387. Utilities, @code{modify-phases}}).
  7388. Here is an example of a package definition that removes the
  7389. @code{configure} phase of @code{%standard-phases} and inserts a new
  7390. phase before the @code{build} phase, called
  7391. @code{set-prefix-in-makefile}:
  7392. @lisp
  7393. (define-public example
  7394. (package
  7395. (name "example")
  7396. ;; other fields omitted
  7397. (build-system gnu-build-system)
  7398. (arguments
  7399. '(#:phases (modify-phases %standard-phases
  7400. (delete 'configure)
  7401. (add-before 'build 'set-prefix-in-makefile
  7402. (lambda* (#:key outputs #:allow-other-keys)
  7403. ;; Modify the makefile so that its
  7404. ;; 'PREFIX' variable points to "out".
  7405. (let ((out (assoc-ref outputs "out")))
  7406. (substitute* "Makefile"
  7407. (("PREFIX =.*")
  7408. (string-append "PREFIX = "
  7409. out "\n")))
  7410. #true))))))))
  7411. @end lisp
  7412. The new phase that is inserted is written as an anonymous procedure,
  7413. introduced with @code{lambda*}; it honors the @code{outputs} parameter
  7414. we have seen before. @xref{Build Utilities}, for more about the helpers
  7415. used by this phase, and for more examples of @code{modify-phases}.
  7416. @cindex code staging
  7417. @cindex staging, of code
  7418. Keep in mind that build phases are code evaluated at the time the
  7419. package is actually built. This explains why the whole
  7420. @code{modify-phases} expression above is quoted (it comes after the
  7421. @code{'} or apostrophe): it is @dfn{staged} for later execution.
  7422. @xref{G-Expressions}, for an explanation of code staging and the
  7423. @dfn{code strata} involved.
  7424. @node Build Utilities
  7425. @section Build Utilities
  7426. As soon as you start writing non-trivial package definitions
  7427. (@pxref{Defining Packages}) or other build actions
  7428. (@pxref{G-Expressions}), you will likely start looking for helpers for
  7429. ``shell-like'' actions---creating directories, copying and deleting
  7430. files recursively, manipulating build phases, and so on. The
  7431. @code{(guix build utils)} module provides such utility procedures.
  7432. Most build systems load @code{(guix build utils)} (@pxref{Build
  7433. Systems}). Thus, when writing custom build phases for your package
  7434. definitions, you can usually assume those procedures are in scope.
  7435. When writing G-expressions, you can import @code{(guix build utils)} on
  7436. the ``build side'' using @code{with-imported-modules} and then put it in
  7437. scope with the @code{use-modules} form (@pxref{Using Guile Modules,,,
  7438. guile, GNU Guile Reference Manual}):
  7439. @lisp
  7440. (with-imported-modules '((guix build utils)) ;import it
  7441. (computed-file "empty-tree"
  7442. #~(begin
  7443. ;; Put it in scope.
  7444. (use-modules (guix build utils))
  7445. ;; Happily use its 'mkdir-p' procedure.
  7446. (mkdir-p (string-append #$output "/a/b/c")))))
  7447. @end lisp
  7448. The remainder of this section is the reference for most of the utility
  7449. procedures provided by @code{(guix build utils)}.
  7450. @c TODO Document what's missing.
  7451. @subsection Dealing with Store File Names
  7452. This section documents procedures that deal with store file names.
  7453. @deffn {Scheme Procedure} %store-directory
  7454. Return the directory name of the store.
  7455. @end deffn
  7456. @deffn {Scheme Procedure} store-file-name? @var{file}
  7457. Return true if @var{file} is in the store.
  7458. @end deffn
  7459. @deffn {Scheme Procedure} strip-store-file-name @var{file}
  7460. Strip the @file{/gnu/store} and hash from @var{file}, a store file name.
  7461. The result is typically a @code{"@var{package}-@var{version}"} string.
  7462. @end deffn
  7463. @deffn {Scheme Procedure} package-name->name+version @var{name}
  7464. Given @var{name}, a package name like @code{"foo-0.9.1b"}, return two
  7465. values: @code{"foo"} and @code{"0.9.1b"}. When the version part is
  7466. unavailable, @var{name} and @code{#f} are returned. The first hyphen
  7467. followed by a digit is considered to introduce the version part.
  7468. @end deffn
  7469. @subsection File Types
  7470. The procedures below deal with files and file types.
  7471. @deffn {Scheme Procedure} directory-exists? @var{dir}
  7472. Return @code{#t} if @var{dir} exists and is a directory.
  7473. @end deffn
  7474. @deffn {Scheme Procedure} executable-file? @var{file}
  7475. Return @code{#t} if @var{file} exists and is executable.
  7476. @end deffn
  7477. @deffn {Scheme Procedure} symbolic-link? @var{file}
  7478. Return @code{#t} if @var{file} is a symbolic link (aka. a ``symlink'').
  7479. @end deffn
  7480. @deffn {Scheme Procedure} elf-file? @var{file}
  7481. @deffnx {Scheme Procedure} ar-file? @var{file}
  7482. @deffnx {Scheme Procedure} gzip-file? @var{file}
  7483. Return @code{#t} if @var{file} is, respectively, an ELF file, an
  7484. @code{ar} archive (such as a @file{.a} static library), or a gzip file.
  7485. @end deffn
  7486. @deffn {Scheme Procedure} reset-gzip-timestamp @var{file} [#:keep-mtime? #t]
  7487. If @var{file} is a gzip file, reset its embedded timestamp (as with
  7488. @command{gzip --no-name}) and return true. Otherwise return @code{#f}.
  7489. When @var{keep-mtime?} is true, preserve @var{file}'s modification time.
  7490. @end deffn
  7491. @subsection File Manipulation
  7492. The following procedures and macros help create, modify, and delete
  7493. files. They provide functionality comparable to common shell utilities
  7494. such as @command{mkdir -p}, @command{cp -r}, @command{rm -r}, and
  7495. @command{sed}. They complement Guile's extensive, but low-level, file
  7496. system interface (@pxref{POSIX,,, guile, GNU Guile Reference Manual}).
  7497. @deffn {Scheme Syntax} with-directory-excursion @var{directory} @var{body}@dots{}
  7498. Run @var{body} with @var{directory} as the process's current directory.
  7499. Essentially, this macro changes the current directory to @var{directory}
  7500. before evaluating @var{body}, using @code{chdir} (@pxref{Processes,,,
  7501. guile, GNU Guile Reference Manual}). It changes back to the initial
  7502. directory when the dynamic extent of @var{body} is left, be it @i{via}
  7503. normal procedure return or @i{via} a non-local exit such as an
  7504. exception.
  7505. @end deffn
  7506. @deffn {Scheme Procedure} mkdir-p @var{dir}
  7507. Create directory @var{dir} and all its ancestors.
  7508. @end deffn
  7509. @deffn {Scheme Procedure} install-file @var{file} @var{directory}
  7510. Create @var{directory} if it does not exist and copy @var{file} in there
  7511. under the same name.
  7512. @end deffn
  7513. @deffn {Scheme Procedure} make-file-writable @var{file}
  7514. Make @var{file} writable for its owner.
  7515. @end deffn
  7516. @deffn {Scheme Procedure} copy-recursively @var{source} @var{destination} @
  7517. [#:log (current-output-port)] [#:follow-symlinks? #f] @
  7518. [#:copy-file copy-file] [#:keep-mtime? #f] [#:keep-permissions? #t]
  7519. Copy @var{source} directory to @var{destination}. Follow symlinks if
  7520. @var{follow-symlinks?} is true; otherwise, just preserve them. Call
  7521. @var{copy-file} to copy regular files. When @var{keep-mtime?} is true,
  7522. keep the modification time of the files in @var{source} on those of
  7523. @var{destination}. When @var{keep-permissions?} is true, preserve file
  7524. permissions. Write verbose output to the @var{log} port.
  7525. @end deffn
  7526. @deffn {Scheme Procedure} delete-file-recursively @var{dir} @
  7527. [#:follow-mounts? #f]
  7528. Delete @var{dir} recursively, like @command{rm -rf}, without following
  7529. symlinks. Don't follow mount points either, unless @var{follow-mounts?}
  7530. is true. Report but ignore errors.
  7531. @end deffn
  7532. @deffn {Scheme Syntax} substitute* @var{file} @
  7533. ((@var{regexp} @var{match-var}@dots{}) @var{body}@dots{}) @dots{}
  7534. Substitute @var{regexp} in @var{file} by the string returned by
  7535. @var{body}. @var{body} is evaluated with each @var{match-var} bound to
  7536. the corresponding positional regexp sub-expression. For example:
  7537. @lisp
  7538. (substitute* file
  7539. (("hello")
  7540. "good morning\n")
  7541. (("foo([a-z]+)bar(.*)$" all letters end)
  7542. (string-append "baz" letters end)))
  7543. @end lisp
  7544. Here, anytime a line of @var{file} contains @code{hello}, it is replaced
  7545. by @code{good morning}. Anytime a line of @var{file} matches the second
  7546. regexp, @code{all} is bound to the complete match, @code{letters} is bound
  7547. to the first sub-expression, and @code{end} is bound to the last one.
  7548. When one of the @var{match-var} is @code{_}, no variable is bound to the
  7549. corresponding match substring.
  7550. Alternatively, @var{file} may be a list of file names, in which case
  7551. they are all subject to the substitutions.
  7552. Be careful about using @code{$} to match the end of a line; by itself it
  7553. won't match the terminating newline of a line.
  7554. @end deffn
  7555. @subsection File Search
  7556. @cindex file, searching
  7557. This section documents procedures to search and filter files.
  7558. @deffn {Scheme Procedure} file-name-predicate @var{regexp}
  7559. Return a predicate that returns true when passed a file name whose base
  7560. name matches @var{regexp}.
  7561. @end deffn
  7562. @deffn {Scheme Procedure} find-files @var{dir} [@var{pred}] @
  7563. [#:stat lstat] [#:directories? #f] [#:fail-on-error? #f]
  7564. Return the lexicographically sorted list of files under @var{dir} for
  7565. which @var{pred} returns true. @var{pred} is passed two arguments: the
  7566. absolute file name, and its stat buffer; the default predicate always
  7567. returns true. @var{pred} can also be a regular expression, in which
  7568. case it is equivalent to @code{(file-name-predicate @var{pred})}.
  7569. @var{stat} is used to obtain file information; using @code{lstat} means
  7570. that symlinks are not followed. If @var{directories?} is true, then
  7571. directories will also be included. If @var{fail-on-error?} is true,
  7572. raise an exception upon error.
  7573. @end deffn
  7574. Here are a few examples where we assume that the current directory is
  7575. the root of the Guix source tree:
  7576. @lisp
  7577. ;; List all the regular files in the current directory.
  7578. (find-files ".")
  7579. @result{} ("./.dir-locals.el" "./.gitignore" @dots{})
  7580. ;; List all the .scm files under gnu/services.
  7581. (find-files "gnu/services" "\\.scm$")
  7582. @result{} ("gnu/services/admin.scm" "gnu/services/audio.scm" @dots{})
  7583. ;; List ar files in the current directory.
  7584. (find-files "." (lambda (file stat) (ar-file? file)))
  7585. @result{} ("./libformat.a" "./libstore.a" @dots{})
  7586. @end lisp
  7587. @deffn {Scheme Procedure} which @var{program}
  7588. Return the complete file name for @var{program} as found in
  7589. @code{$PATH}, or @code{#f} if @var{program} could not be found.
  7590. @end deffn
  7591. @deffn {Scheme Procedure} search-input-file @var{inputs} @var{name}
  7592. @deffnx {Scheme Procedure} search-input-directory @var{inputs} @var{name}
  7593. Return the complete file name for @var{name} as found in @var{inputs};
  7594. @code{search-input-file} searches for a regular file and
  7595. @code{search-input-directory} searches for a directory. If @var{name}
  7596. could not be found, an exception is raised.
  7597. Here, @var{inputs} must be an association list like @code{inputs} and
  7598. @code{native-inputs} as available to build phases (@pxref{Build
  7599. Phases}).
  7600. @end deffn
  7601. Here is a (simplified) example of how @code{search-input-file} is used
  7602. in a build phase of the @code{wireguard-tools} package:
  7603. @lisp
  7604. (add-after 'install 'wrap-wg-quick
  7605. (lambda* (#:key inputs outputs #:allow-other-keys)
  7606. (let ((coreutils (string-append (assoc-ref inputs "coreutils")
  7607. "/bin")))
  7608. (wrap-program (search-input-file outputs "bin/wg-quick")
  7609. #:sh (search-input-file inputs "bin/bash")
  7610. `("PATH" ":" prefix ,(list coreutils))))))
  7611. @end lisp
  7612. @subsection Program Invocation
  7613. @cindex program invocation, from Scheme
  7614. @cindex invoking programs, from Scheme
  7615. You'll find handy procedures to spawn processes in this module,
  7616. essentially convenient wrappers around Guile's @code{system*}
  7617. (@pxref{Processes, @code{system*},, guile, GNU Guile Reference Manual}).
  7618. @deffn {Scheme Procedure} invoke @var{program} @var{args}@dots{}
  7619. Invoke @var{program} with the given @var{args}. Raise an
  7620. @code{&invoke-error} exception if the exit code is non-zero; otherwise
  7621. return @code{#t}.
  7622. The advantage compared to @code{system*} is that you do not need to
  7623. check the return value. This reduces boilerplate in shell-script-like
  7624. snippets for instance in package build phases.
  7625. @end deffn
  7626. @deffn {Scheme Procedure} invoke-error? @var{c}
  7627. Return true if @var{c} is an @code{&invoke-error} condition.
  7628. @end deffn
  7629. @deffn {Scheme Procedure} invoke-error-program @var{c}
  7630. @deffnx {Scheme Procedure} invoke-error-arguments @var{c}
  7631. @deffnx {Scheme Procedure} invoke-error-exit-status @var{c}
  7632. @deffnx {Scheme Procedure} invoke-error-term-signal @var{c}
  7633. @deffnx {Scheme Procedure} invoke-error-stop-signal @var{c}
  7634. Access specific fields of @var{c}, an @code{&invoke-error} condition.
  7635. @end deffn
  7636. @deffn {Scheme Procedure} report-invoke-error @var{c} [@var{port}]
  7637. Report to @var{port} (by default the current error port) about @var{c},
  7638. an @code{&invoke-error} condition, in a human-friendly way.
  7639. Typical usage would look like this:
  7640. @lisp
  7641. (use-modules (srfi srfi-34) ;for 'guard'
  7642. (guix build utils))
  7643. (guard (c ((invoke-error? c)
  7644. (report-invoke-error c)))
  7645. (invoke "date" "--imaginary-option"))
  7646. @print{} command "date" "--imaginary-option" failed with status 1
  7647. @end lisp
  7648. @end deffn
  7649. @deffn {Scheme Procedure} invoke/quiet @var{program} @var{args}@dots{}
  7650. Invoke @var{program} with @var{args} and capture @var{program}'s
  7651. standard output and standard error. If @var{program} succeeds, print
  7652. nothing and return the unspecified value; otherwise, raise a
  7653. @code{&message} error condition that includes the status code and the
  7654. output of @var{program}.
  7655. Here's an example:
  7656. @lisp
  7657. (use-modules (srfi srfi-34) ;for 'guard'
  7658. (srfi srfi-35) ;for 'message-condition?'
  7659. (guix build utils))
  7660. (guard (c ((message-condition? c)
  7661. (display (condition-message c))))
  7662. (invoke/quiet "date") ;all is fine
  7663. (invoke/quiet "date" "--imaginary-option"))
  7664. @print{} 'date --imaginary-option' exited with status 1; output follows:
  7665. date: unrecognized option '--imaginary-option'
  7666. Try 'date --help' for more information.
  7667. @end lisp
  7668. @end deffn
  7669. @subsection Build Phases
  7670. @cindex build phases
  7671. The @code{(guix build utils)} also contains tools to manipulate build
  7672. phases as used by build systems (@pxref{Build Systems}). Build phases
  7673. are represented as association lists or ``alists'' (@pxref{Association
  7674. Lists,,, guile, GNU Guile Reference Manual}) where each key is a symbol
  7675. naming the phase and the associated value is a procedure (@pxref{Build
  7676. Phases}).
  7677. Guile core and the @code{(srfi srfi-1)} module both provide tools to
  7678. manipulate alists. The @code{(guix build utils)} module complements
  7679. those with tools written with build phases in mind.
  7680. @cindex build phases, modifying
  7681. @deffn {Scheme Syntax} modify-phases @var{phases} @var{clause}@dots{}
  7682. Modify @var{phases} sequentially as per each @var{clause}, which may
  7683. have one of the following forms:
  7684. @lisp
  7685. (delete @var{old-phase-name})
  7686. (replace @var{old-phase-name} @var{new-phase})
  7687. (add-before @var{old-phase-name} @var{new-phase-name} @var{new-phase})
  7688. (add-after @var{old-phase-name} @var{new-phase-name} @var{new-phase})
  7689. @end lisp
  7690. Where every @var{phase-name} above is an expression evaluating to a
  7691. symbol, and @var{new-phase} an expression evaluating to a procedure.
  7692. @end deffn
  7693. The example below is taken from the definition of the @code{grep}
  7694. package. It adds a phase to run after the @code{install} phase, called
  7695. @code{fix-egrep-and-fgrep}. That phase is a procedure (@code{lambda*}
  7696. is for anonymous procedures) that takes a @code{#:outputs} keyword
  7697. argument and ignores extra keyword arguments (@pxref{Optional
  7698. Arguments,,, guile, GNU Guile Reference Manual}, for more on
  7699. @code{lambda*} and optional and keyword arguments.) The phase uses
  7700. @code{substitute*} to modify the installed @file{egrep} and @file{fgrep}
  7701. scripts so that they refer to @code{grep} by its absolute file name:
  7702. @lisp
  7703. (modify-phases %standard-phases
  7704. (add-after 'install 'fix-egrep-and-fgrep
  7705. ;; Patch 'egrep' and 'fgrep' to execute 'grep' via its
  7706. ;; absolute file name instead of searching for it in $PATH.
  7707. (lambda* (#:key outputs #:allow-other-keys)
  7708. (let* ((out (assoc-ref outputs "out"))
  7709. (bin (string-append out "/bin")))
  7710. (substitute* (list (string-append bin "/egrep")
  7711. (string-append bin "/fgrep"))
  7712. (("^exec grep")
  7713. (string-append "exec " bin "/grep")))))))
  7714. @end lisp
  7715. In the example below, phases are modified in two ways: the standard
  7716. @code{configure} phase is deleted, presumably because the package does
  7717. not have a @file{configure} script or anything similar, and the default
  7718. @code{install} phase is replaced by one that manually copies the
  7719. executable files to be installed:
  7720. @lisp
  7721. (modify-phases %standard-phases
  7722. (delete 'configure) ;no 'configure' script
  7723. (replace 'install
  7724. (lambda* (#:key outputs #:allow-other-keys)
  7725. ;; The package's Makefile doesn't provide an "install"
  7726. ;; rule so do it by ourselves.
  7727. (let ((bin (string-append (assoc-ref outputs "out")
  7728. "/bin")))
  7729. (install-file "footswitch" bin)
  7730. (install-file "scythe" bin)))))
  7731. @end lisp
  7732. @c TODO: Add more examples.
  7733. @subsection Wrappers
  7734. @cindex program wrappers
  7735. @cindex wrapping programs
  7736. It is not unusual for a command to require certain environment variables
  7737. to be set for proper functioning, typically search paths (@pxref{Search
  7738. Paths}). Failing to do that, the command might fail to find files or
  7739. other commands it relies on, or it might pick the ``wrong''
  7740. ones---depending on the environment in which it runs. Examples include:
  7741. @itemize
  7742. @item
  7743. a shell script that assumes all the commands it uses are in @env{PATH};
  7744. @item
  7745. a Guile program that assumes all its modules are in @env{GUILE_LOAD_PATH}
  7746. and @env{GUILE_LOAD_COMPILED_PATH};
  7747. @item
  7748. a Qt application that expects to find certain plugins in
  7749. @env{QT_PLUGIN_PATH}.
  7750. @end itemize
  7751. For a package writer, the goal is to make sure commands always work the
  7752. same rather than depend on some external settings. One way to achieve
  7753. that is to @dfn{wrap} commands in a thin script that sets those
  7754. environment variables, thereby ensuring that those run-time dependencies
  7755. are always found. The wrapper would be used to set @env{PATH},
  7756. @env{GUILE_LOAD_PATH}, or @env{QT_PLUGIN_PATH} in the examples above.
  7757. To ease that task, the @code{(guix build utils)} module provides a
  7758. couple of helpers to wrap commands.
  7759. @deffn {Scheme Procedure} wrap-program @var{program} @
  7760. [#:sh @var{sh}] [#:rest @var{variables}]
  7761. Make a wrapper for @var{program}. @var{variables} should look like this:
  7762. @lisp
  7763. '(@var{variable} @var{delimiter} @var{position} @var{list-of-directories})
  7764. @end lisp
  7765. where @var{delimiter} is optional. @code{:} will be used if
  7766. @var{delimiter} is not given.
  7767. For example, this call:
  7768. @lisp
  7769. (wrap-program "foo"
  7770. '("PATH" ":" = ("/gnu/.../bar/bin"))
  7771. '("CERT_PATH" suffix ("/gnu/.../baz/certs"
  7772. "/qux/certs")))
  7773. @end lisp
  7774. will copy @file{foo} to @file{.foo-real} and create the file @file{foo}
  7775. with the following contents:
  7776. @example
  7777. #!location/of/bin/bash
  7778. export PATH="/gnu/.../bar/bin"
  7779. export CERT_PATH="$CERT_PATH$@{CERT_PATH:+:@}/gnu/.../baz/certs:/qux/certs"
  7780. exec -a $0 location/of/.foo-real "$@@"
  7781. @end example
  7782. If @var{program} has previously been wrapped by @code{wrap-program}, the
  7783. wrapper is extended with definitions for @var{variables}. If it is not,
  7784. @var{sh} will be used as the interpreter.
  7785. @end deffn
  7786. @deffn {Scheme Procedure} wrap-script @var{program} @
  7787. [#:guile @var{guile}] [#:rest @var{variables}]
  7788. Wrap the script @var{program} such that @var{variables} are set first.
  7789. The format of @var{variables} is the same as in the @code{wrap-program}
  7790. procedure. This procedure differs from @code{wrap-program} in that it
  7791. does not create a separate shell script. Instead, @var{program} is
  7792. modified directly by prepending a Guile script, which is interpreted as
  7793. a comment in the script's language.
  7794. Special encoding comments as supported by Python are recreated on the
  7795. second line.
  7796. Note that this procedure can only be used once per file as Guile scripts are
  7797. not supported.
  7798. @end deffn
  7799. @node Search Paths
  7800. @section Search Paths
  7801. @cindex search path
  7802. Many programs and libraries look for input data in a @dfn{search path},
  7803. a list of directories: shells like Bash look for executables in the
  7804. command search path, a C compiler looks for @file{.h} files in its
  7805. header search path, the Python interpreter looks for @file{.py}
  7806. files in its search path, the spell checker has a search path for
  7807. dictionaries, and so on.
  7808. Search paths can usually be defined or overridden @i{via} environment
  7809. variables (@pxref{Environment Variables,,, libc, The GNU C Library
  7810. Reference Manual}). For example, the search paths mentioned above can
  7811. be changed by defining the @env{PATH}, @env{C_INCLUDE_PATH},
  7812. @env{PYTHONPATH} (or @env{GUIX_PYTHONPATH}), and @env{DICPATH}
  7813. environment variables---you know, all these something-PATH variables
  7814. that you need to get right or things ``won't be found''.
  7815. You may have noticed from the command line that Guix ``knows'' which
  7816. search path environment variables should be defined, and how. When you
  7817. install packages in your default profile, the file
  7818. @file{~/.guix-profile/etc/profile} is created, which you can ``source''
  7819. from the shell to set those variables. Likewise, if you ask
  7820. @command{guix shell} to create an environment containing Python and
  7821. NumPy, a Python library, and if you pass it the @option{--search-paths}
  7822. option, it will tell you about @env{PATH} and @env{GUIX_PYTHONPATH}
  7823. (@pxref{Invoking guix shell}):
  7824. @example
  7825. $ guix shell python python-numpy --pure --search-paths
  7826. export PATH="/gnu/store/@dots{}-profile/bin"
  7827. export GUIX_PYTHONPATH="/gnu/store/@dots{}-profile/lib/python3.9/site-packages"
  7828. @end example
  7829. When you omit @option{--search-paths}, it defines these environment
  7830. variables right away, such that Python can readily find NumPy:
  7831. @example
  7832. $ guix shell python python-numpy -- python3
  7833. Python 3.9.6 (default, Jan 1 1970, 00:00:01)
  7834. [GCC 10.3.0] on linux
  7835. Type "help", "copyright", "credits" or "license" for more information.
  7836. >>> import numpy
  7837. >>> numpy.version.version
  7838. '1.20.3'
  7839. @end example
  7840. For this to work, the definition of the @code{python} package
  7841. @emph{declares} the search path it cares about and its associated
  7842. environment variable, @env{GUIX_PYTHONPATH}. It looks like this:
  7843. @lisp
  7844. (package
  7845. (name "python")
  7846. (version "3.9.9")
  7847. ;; some fields omitted...
  7848. (native-search-paths
  7849. (list (search-path-specification
  7850. (variable "GUIX_PYTHONPATH")
  7851. (files (list "lib/python/3.9/site-packages"))))))
  7852. @end lisp
  7853. What this @code{native-search-paths} field says is that, when the
  7854. @code{python} package is used, the @env{GUIX_PYTHONPATH} environment
  7855. variable must be defined to include all the
  7856. @file{lib/python/3.9/site-packages} sub-directories encountered in its
  7857. environment. (The @code{native-} bit means that, if we are in a
  7858. cross-compilation environment, only native inputs may be added to the
  7859. search path; @pxref{package Reference, @code{search-paths}}.)
  7860. In the NumPy example above, the profile where
  7861. @code{python} appears contains exactly one such sub-directory, and
  7862. @env{GUIX_PYTHONPATH} is set to that. When there are several
  7863. @file{lib/python/3.9/site-packages}---this is the case in package build
  7864. environments---they are all added to @env{GUIX_PYTHONPATH}, separated by
  7865. colons (@code{:}).
  7866. @quotation Note
  7867. Notice that @env{GUIX_PYTHONPATH} is specified as part of the definition
  7868. of the @code{python} package, and @emph{not} as part of that of
  7869. @code{python-numpy}. This is because this environment variable
  7870. ``belongs'' to Python, not NumPy: Python actually reads the value of
  7871. that variable and honors it.
  7872. Corollary: if you create a profile that does not contain @code{python},
  7873. @code{GUIX_PYTHONPATH} will @emph{not} be defined, even if it contains
  7874. packages that provide @file{.py} files:
  7875. @example
  7876. $ guix shell python-numpy --search-paths --pure
  7877. export PATH="/gnu/store/@dots{}-profile/bin"
  7878. @end example
  7879. This makes a lot of sense if we look at this profile in isolation: no
  7880. software in this profile would read @env{GUIX_PYTHONPATH}.
  7881. @end quotation
  7882. Of course, there are many variations on that theme: some packages honor
  7883. more than one search path, some use separators other than colon, some
  7884. accumulate several directories in their search path, and so on. A more
  7885. complex example is the search path of libxml2: the value of the
  7886. @env{XML_CATALOG_FILES} environment variable is space-separated, it must
  7887. contain a list of @file{catalog.xml} files (not directories), which are
  7888. to be found in @file{xml} sub-directories---nothing less. The search
  7889. path specification looks like this:
  7890. @lisp
  7891. (package
  7892. (name "libxml2")
  7893. ;; some fields omitted
  7894. (native-search-paths
  7895. (list (search-path-specification
  7896. (variable "XML_CATALOG_FILES")
  7897. (separator " ")
  7898. (files '("xml"))
  7899. (file-pattern "^catalog\\.xml$")
  7900. (file-type 'regular)))))
  7901. @end lisp
  7902. Worry not, search path specifications are usually not this tricky.
  7903. The @code{(guix search-paths)} module defines the data type of search
  7904. path specifications and a number of helper procedures. Below is the
  7905. reference of search path specifications.
  7906. @deftp {Data Type} search-path-specification
  7907. The data type for search path specifications.
  7908. @table @asis
  7909. @item @code{variable}
  7910. The name of the environment variable for this search path (a string).
  7911. @item @code{files}
  7912. The list of sub-directories (strings) that should be added to the search
  7913. path.
  7914. @item @code{separator} (default: @code{":"})
  7915. The string used to separate search path components.
  7916. As a special case, a @code{separator} value of @code{#f} specifies a
  7917. ``single-component search path''---in other words, a search path that
  7918. cannot contain more than one element. This is useful in some cases,
  7919. such as the @code{SSL_CERT_DIR} variable (honored by OpenSSL, cURL, and
  7920. a few other packages) or the @code{ASPELL_DICT_DIR} variable (honored by
  7921. the GNU Aspell spell checker), both of which must point to a single
  7922. directory.
  7923. @item @code{file-type} (default: @code{'directory})
  7924. The type of file being matched---@code{'directory} or @code{'regular},
  7925. though it can be any symbol returned by @code{stat:type} (@pxref{File
  7926. System, @code{stat},, guile, GNU Guile Reference Manual}).
  7927. In the libxml2 example above, we would match regular files; in the
  7928. Python example, we would match directories.
  7929. @item @code{file-pattern} (default: @code{#f})
  7930. This must be either @code{#f} or a regular expression specifying
  7931. files to be matched @emph{within} the sub-directories specified by the
  7932. @code{files} field.
  7933. Again, the libxml2 example shows a situation where this is needed.
  7934. @end table
  7935. @end deftp
  7936. How do you turn search path specifications on one hand and a bunch of
  7937. directories on the other hand in a set of environment variable
  7938. definitions? That's the job of @code{evaluate-search-paths}.
  7939. @deffn {Scheme Procedure} evaluate-search-paths @var{search-paths} @
  7940. @var{directories} [@var{getenv}]
  7941. Evaluate @var{search-paths}, a list of search-path specifications, for
  7942. @var{directories}, a list of directory names, and return a list of
  7943. specification/value pairs. Use @var{getenv} to determine the current
  7944. settings and report only settings not already effective.
  7945. @end deffn
  7946. The @code{(guix profiles)} provides a higher-level helper procedure,
  7947. @code{load-profile}, that sets the environment variables of a profile.
  7948. @node The Store
  7949. @section The Store
  7950. @cindex store
  7951. @cindex store items
  7952. @cindex store paths
  7953. Conceptually, the @dfn{store} is the place where derivations that have
  7954. been built successfully are stored---by default, @file{/gnu/store}.
  7955. Sub-directories in the store are referred to as @dfn{store items} or
  7956. sometimes @dfn{store paths}. The store has an associated database that
  7957. contains information such as the store paths referred to by each store
  7958. path, and the list of @emph{valid} store items---results of successful
  7959. builds. This database resides in @file{@var{localstatedir}/guix/db},
  7960. where @var{localstatedir} is the state directory specified @i{via}
  7961. @option{--localstatedir} at configure time, usually @file{/var}.
  7962. The store is @emph{always} accessed by the daemon on behalf of its clients
  7963. (@pxref{Invoking guix-daemon}). To manipulate the store, clients
  7964. connect to the daemon over a Unix-domain socket, send requests to it,
  7965. and read the result---these are remote procedure calls, or RPCs.
  7966. @quotation Note
  7967. Users must @emph{never} modify files under @file{/gnu/store} directly.
  7968. This would lead to inconsistencies and break the immutability
  7969. assumptions of Guix's functional model (@pxref{Introduction}).
  7970. @xref{Invoking guix gc, @command{guix gc --verify}}, for information on
  7971. how to check the integrity of the store and attempt recovery from
  7972. accidental modifications.
  7973. @end quotation
  7974. The @code{(guix store)} module provides procedures to connect to the
  7975. daemon, and to perform RPCs. These are described below. By default,
  7976. @code{open-connection}, and thus all the @command{guix} commands,
  7977. connect to the local daemon or to the URI specified by the
  7978. @env{GUIX_DAEMON_SOCKET} environment variable.
  7979. @defvr {Environment Variable} GUIX_DAEMON_SOCKET
  7980. When set, the value of this variable should be a file name or a URI
  7981. designating the daemon endpoint. When it is a file name, it denotes a
  7982. Unix-domain socket to connect to. In addition to file names, the
  7983. supported URI schemes are:
  7984. @table @code
  7985. @item file
  7986. @itemx unix
  7987. These are for Unix-domain sockets.
  7988. @code{file:///var/guix/daemon-socket/socket} is equivalent to
  7989. @file{/var/guix/daemon-socket/socket}.
  7990. @item guix
  7991. @cindex daemon, remote access
  7992. @cindex remote access to the daemon
  7993. @cindex daemon, cluster setup
  7994. @cindex clusters, daemon setup
  7995. These URIs denote connections over TCP/IP, without encryption nor
  7996. authentication of the remote host. The URI must specify the host name
  7997. and optionally a port number (by default port 44146 is used):
  7998. @example
  7999. guix://master.guix.example.org:1234
  8000. @end example
  8001. This setup is suitable on local networks, such as clusters, where only
  8002. trusted nodes may connect to the build daemon at
  8003. @code{master.guix.example.org}.
  8004. The @option{--listen} option of @command{guix-daemon} can be used to
  8005. instruct it to listen for TCP connections (@pxref{Invoking guix-daemon,
  8006. @option{--listen}}).
  8007. @item ssh
  8008. @cindex SSH access to build daemons
  8009. These URIs allow you to connect to a remote daemon over SSH@. This
  8010. feature requires Guile-SSH (@pxref{Requirements}) and a working
  8011. @command{guile} binary in @env{PATH} on the destination machine. It
  8012. supports public key and GSSAPI authentication. A typical URL might look
  8013. like this:
  8014. @example
  8015. ssh://charlie@@guix.example.org:22
  8016. @end example
  8017. As for @command{guix copy}, the usual OpenSSH client configuration files
  8018. are honored (@pxref{Invoking guix copy}).
  8019. @end table
  8020. Additional URI schemes may be supported in the future.
  8021. @c XXX: Remove this note when the protocol incurs fewer round trips
  8022. @c and when (guix derivations) no longer relies on file system access.
  8023. @quotation Note
  8024. The ability to connect to remote build daemons is considered
  8025. experimental as of @value{VERSION}. Please get in touch with us to
  8026. share any problems or suggestions you may have (@pxref{Contributing}).
  8027. @end quotation
  8028. @end defvr
  8029. @deffn {Scheme Procedure} open-connection [@var{uri}] [#:reserve-space? #t]
  8030. Connect to the daemon over the Unix-domain socket at @var{uri} (a string). When
  8031. @var{reserve-space?} is true, instruct it to reserve a little bit of
  8032. extra space on the file system so that the garbage collector can still
  8033. operate should the disk become full. Return a server object.
  8034. @var{file} defaults to @code{%default-socket-path}, which is the normal
  8035. location given the options that were passed to @command{configure}.
  8036. @end deffn
  8037. @deffn {Scheme Procedure} close-connection @var{server}
  8038. Close the connection to @var{server}.
  8039. @end deffn
  8040. @defvr {Scheme Variable} current-build-output-port
  8041. This variable is bound to a SRFI-39 parameter, which refers to the port
  8042. where build and error logs sent by the daemon should be written.
  8043. @end defvr
  8044. Procedures that make RPCs all take a server object as their first
  8045. argument.
  8046. @deffn {Scheme Procedure} valid-path? @var{server} @var{path}
  8047. @cindex invalid store items
  8048. Return @code{#t} when @var{path} designates a valid store item and
  8049. @code{#f} otherwise (an invalid item may exist on disk but still be
  8050. invalid, for instance because it is the result of an aborted or failed
  8051. build).
  8052. A @code{&store-protocol-error} condition is raised if @var{path} is not
  8053. prefixed by the store directory (@file{/gnu/store}).
  8054. @end deffn
  8055. @deffn {Scheme Procedure} add-text-to-store @var{server} @var{name} @var{text} [@var{references}]
  8056. Add @var{text} under file @var{name} in the store, and return its store
  8057. path. @var{references} is the list of store paths referred to by the
  8058. resulting store path.
  8059. @end deffn
  8060. @deffn {Scheme Procedure} build-derivations @var{store} @var{derivations} @
  8061. [@var{mode}]
  8062. Build @var{derivations}, a list of @code{<derivation>} objects, @file{.drv}
  8063. file names, or derivation/output pairs, using the specified
  8064. @var{mode}---@code{(build-mode normal)} by default.
  8065. @end deffn
  8066. Note that the @code{(guix monads)} module provides a monad as well as
  8067. monadic versions of the above procedures, with the goal of making it
  8068. more convenient to work with code that accesses the store (@pxref{The
  8069. Store Monad}).
  8070. @c FIXME
  8071. @i{This section is currently incomplete.}
  8072. @node Derivations
  8073. @section Derivations
  8074. @cindex derivations
  8075. Low-level build actions and the environment in which they are performed
  8076. are represented by @dfn{derivations}. A derivation contains the
  8077. following pieces of information:
  8078. @itemize
  8079. @item
  8080. The outputs of the derivation---derivations produce at least one file or
  8081. directory in the store, but may produce more.
  8082. @item
  8083. @cindex build-time dependencies
  8084. @cindex dependencies, build-time
  8085. The inputs of the derivations---i.e., its build-time dependencies---which may
  8086. be other derivations or plain files in the store (patches, build scripts,
  8087. etc.).
  8088. @item
  8089. The system type targeted by the derivation---e.g., @code{x86_64-linux}.
  8090. @item
  8091. The file name of a build script in the store, along with the arguments
  8092. to be passed.
  8093. @item
  8094. A list of environment variables to be defined.
  8095. @end itemize
  8096. @cindex derivation path
  8097. Derivations allow clients of the daemon to communicate build actions to
  8098. the store. They exist in two forms: as an in-memory representation,
  8099. both on the client- and daemon-side, and as files in the store whose
  8100. name end in @file{.drv}---these files are referred to as @dfn{derivation
  8101. paths}. Derivations paths can be passed to the @code{build-derivations}
  8102. procedure to perform the build actions they prescribe (@pxref{The
  8103. Store}).
  8104. @cindex fixed-output derivations
  8105. Operations such as file downloads and version-control checkouts for
  8106. which the expected content hash is known in advance are modeled as
  8107. @dfn{fixed-output derivations}. Unlike regular derivations, the outputs
  8108. of a fixed-output derivation are independent of its inputs---e.g., a
  8109. source code download produces the same result regardless of the download
  8110. method and tools being used.
  8111. @cindex references
  8112. @cindex run-time dependencies
  8113. @cindex dependencies, run-time
  8114. The outputs of derivations---i.e., the build results---have a set of
  8115. @dfn{references}, as reported by the @code{references} RPC or the
  8116. @command{guix gc --references} command (@pxref{Invoking guix gc}). References
  8117. are the set of run-time dependencies of the build results. References are a
  8118. subset of the inputs of the derivation; this subset is automatically computed
  8119. by the build daemon by scanning all the files in the outputs.
  8120. The @code{(guix derivations)} module provides a representation of
  8121. derivations as Scheme objects, along with procedures to create and
  8122. otherwise manipulate derivations. The lowest-level primitive to create
  8123. a derivation is the @code{derivation} procedure:
  8124. @deffn {Scheme Procedure} derivation @var{store} @var{name} @var{builder} @
  8125. @var{args} [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
  8126. [#:recursive? #f] [#:inputs '()] [#:env-vars '()] @
  8127. [#:system (%current-system)] [#:references-graphs #f] @
  8128. [#:allowed-references #f] [#:disallowed-references #f] @
  8129. [#:leaked-env-vars #f] [#:local-build? #f] @
  8130. [#:substitutable? #t] [#:properties '()]
  8131. Build a derivation with the given arguments, and return the resulting
  8132. @code{<derivation>} object.
  8133. When @var{hash} and @var{hash-algo} are given, a
  8134. @dfn{fixed-output derivation} is created---i.e., one whose result is
  8135. known in advance, such as a file download. If, in addition,
  8136. @var{recursive?} is true, then that fixed output may be an executable
  8137. file or a directory and @var{hash} must be the hash of an archive
  8138. containing this output.
  8139. When @var{references-graphs} is true, it must be a list of file
  8140. name/store path pairs. In that case, the reference graph of each store
  8141. path is exported in the build environment in the corresponding file, in
  8142. a simple text format.
  8143. When @var{allowed-references} is true, it must be a list of store items
  8144. or outputs that the derivation's output may refer to. Likewise,
  8145. @var{disallowed-references}, if true, must be a list of things the
  8146. outputs may @emph{not} refer to.
  8147. When @var{leaked-env-vars} is true, it must be a list of strings
  8148. denoting environment variables that are allowed to ``leak'' from the
  8149. daemon's environment to the build environment. This is only applicable
  8150. to fixed-output derivations---i.e., when @var{hash} is true. The main
  8151. use is to allow variables such as @code{http_proxy} to be passed to
  8152. derivations that download files.
  8153. When @var{local-build?} is true, declare that the derivation is not a
  8154. good candidate for offloading and should rather be built locally
  8155. (@pxref{Daemon Offload Setup}). This is the case for small derivations
  8156. where the costs of data transfers would outweigh the benefits.
  8157. When @var{substitutable?} is false, declare that substitutes of the
  8158. derivation's output should not be used (@pxref{Substitutes}). This is
  8159. useful, for instance, when building packages that capture details of the
  8160. host CPU instruction set.
  8161. @var{properties} must be an association list describing ``properties'' of the
  8162. derivation. It is kept as-is, uninterpreted, in the derivation.
  8163. @end deffn
  8164. @noindent
  8165. Here's an example with a shell script as its builder, assuming
  8166. @var{store} is an open connection to the daemon, and @var{bash} points
  8167. to a Bash executable in the store:
  8168. @lisp
  8169. (use-modules (guix utils)
  8170. (guix store)
  8171. (guix derivations))
  8172. (let ((builder ; add the Bash script to the store
  8173. (add-text-to-store store "my-builder.sh"
  8174. "echo hello world > $out\n" '())))
  8175. (derivation store "foo"
  8176. bash `("-e" ,builder)
  8177. #:inputs `((,bash) (,builder))
  8178. #:env-vars '(("HOME" . "/homeless"))))
  8179. @result{} #<derivation /gnu/store/@dots{}-foo.drv => /gnu/store/@dots{}-foo>
  8180. @end lisp
  8181. As can be guessed, this primitive is cumbersome to use directly. A
  8182. better approach is to write build scripts in Scheme, of course! The
  8183. best course of action for that is to write the build code as a
  8184. ``G-expression'', and to pass it to @code{gexp->derivation}. For more
  8185. information, @pxref{G-Expressions}.
  8186. Once upon a time, @code{gexp->derivation} did not exist and constructing
  8187. derivations with build code written in Scheme was achieved with
  8188. @code{build-expression->derivation}, documented below. This procedure
  8189. is now deprecated in favor of the much nicer @code{gexp->derivation}.
  8190. @deffn {Scheme Procedure} build-expression->derivation @var{store} @
  8191. @var{name} @var{exp} @
  8192. [#:system (%current-system)] [#:inputs '()] @
  8193. [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
  8194. [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
  8195. [#:references-graphs #f] [#:allowed-references #f] @
  8196. [#:disallowed-references #f] @
  8197. [#:local-build? #f] [#:substitutable? #t] [#:guile-for-build #f]
  8198. Return a derivation that executes Scheme expression @var{exp} as a
  8199. builder for derivation @var{name}. @var{inputs} must be a list of
  8200. @code{(name drv-path sub-drv)} tuples; when @var{sub-drv} is omitted,
  8201. @code{"out"} is assumed. @var{modules} is a list of names of Guile
  8202. modules from the current search path to be copied in the store,
  8203. compiled, and made available in the load path during the execution of
  8204. @var{exp}---e.g., @code{((guix build utils) (guix build
  8205. gnu-build-system))}.
  8206. @var{exp} is evaluated in an environment where @code{%outputs} is bound
  8207. to a list of output/path pairs, and where @code{%build-inputs} is bound
  8208. to a list of string/output-path pairs made from @var{inputs}.
  8209. Optionally, @var{env-vars} is a list of string pairs specifying the name
  8210. and value of environment variables visible to the builder. The builder
  8211. terminates by passing the result of @var{exp} to @code{exit}; thus, when
  8212. @var{exp} returns @code{#f}, the build is considered to have failed.
  8213. @var{exp} is built using @var{guile-for-build} (a derivation). When
  8214. @var{guile-for-build} is omitted or is @code{#f}, the value of the
  8215. @code{%guile-for-build} fluid is used instead.
  8216. See the @code{derivation} procedure for the meaning of
  8217. @var{references-graphs}, @var{allowed-references},
  8218. @var{disallowed-references}, @var{local-build?}, and
  8219. @var{substitutable?}.
  8220. @end deffn
  8221. @noindent
  8222. Here's an example of a single-output derivation that creates a directory
  8223. containing one file:
  8224. @lisp
  8225. (let ((builder '(let ((out (assoc-ref %outputs "out")))
  8226. (mkdir out) ; create /gnu/store/@dots{}-goo
  8227. (call-with-output-file (string-append out "/test")
  8228. (lambda (p)
  8229. (display '(hello guix) p))))))
  8230. (build-expression->derivation store "goo" builder))
  8231. @result{} #<derivation /gnu/store/@dots{}-goo.drv => @dots{}>
  8232. @end lisp
  8233. @node The Store Monad
  8234. @section The Store Monad
  8235. @cindex monad
  8236. The procedures that operate on the store described in the previous
  8237. sections all take an open connection to the build daemon as their first
  8238. argument. Although the underlying model is functional, they either have
  8239. side effects or depend on the current state of the store.
  8240. The former is inconvenient: the connection to the build daemon has to be
  8241. carried around in all those functions, making it impossible to compose
  8242. functions that do not take that parameter with functions that do. The
  8243. latter can be problematic: since store operations have side effects
  8244. and/or depend on external state, they have to be properly sequenced.
  8245. @cindex monadic values
  8246. @cindex monadic functions
  8247. This is where the @code{(guix monads)} module comes in. This module
  8248. provides a framework for working with @dfn{monads}, and a particularly
  8249. useful monad for our uses, the @dfn{store monad}. Monads are a
  8250. construct that allows two things: associating ``context'' with values
  8251. (in our case, the context is the store), and building sequences of
  8252. computations (here computations include accesses to the store). Values
  8253. in a monad---values that carry this additional context---are called
  8254. @dfn{monadic values}; procedures that return such values are called
  8255. @dfn{monadic procedures}.
  8256. Consider this ``normal'' procedure:
  8257. @lisp
  8258. (define (sh-symlink store)
  8259. ;; Return a derivation that symlinks the 'bash' executable.
  8260. (let* ((drv (package-derivation store bash))
  8261. (out (derivation->output-path drv))
  8262. (sh (string-append out "/bin/bash")))
  8263. (build-expression->derivation store "sh"
  8264. `(symlink ,sh %output))))
  8265. @end lisp
  8266. Using @code{(guix monads)} and @code{(guix gexp)}, it may be rewritten
  8267. as a monadic function:
  8268. @lisp
  8269. (define (sh-symlink)
  8270. ;; Same, but return a monadic value.
  8271. (mlet %store-monad ((drv (package->derivation bash)))
  8272. (gexp->derivation "sh"
  8273. #~(symlink (string-append #$drv "/bin/bash")
  8274. #$output))))
  8275. @end lisp
  8276. There are several things to note in the second version: the @code{store}
  8277. parameter is now implicit and is ``threaded'' in the calls to the
  8278. @code{package->derivation} and @code{gexp->derivation} monadic
  8279. procedures, and the monadic value returned by @code{package->derivation}
  8280. is @dfn{bound} using @code{mlet} instead of plain @code{let}.
  8281. As it turns out, the call to @code{package->derivation} can even be
  8282. omitted since it will take place implicitly, as we will see later
  8283. (@pxref{G-Expressions}):
  8284. @lisp
  8285. (define (sh-symlink)
  8286. (gexp->derivation "sh"
  8287. #~(symlink (string-append #$bash "/bin/bash")
  8288. #$output)))
  8289. @end lisp
  8290. @c See
  8291. @c <https://syntaxexclamation.wordpress.com/2014/06/26/escaping-continuations/>
  8292. @c for the funny quote.
  8293. Calling the monadic @code{sh-symlink} has no effect. As someone once
  8294. said, ``you exit a monad like you exit a building on fire: by running''.
  8295. So, to exit the monad and get the desired effect, one must use
  8296. @code{run-with-store}:
  8297. @lisp
  8298. (run-with-store (open-connection) (sh-symlink))
  8299. @result{} /gnu/store/...-sh-symlink
  8300. @end lisp
  8301. Note that the @code{(guix monad-repl)} module extends the Guile REPL with
  8302. new ``meta-commands'' to make it easier to deal with monadic procedures:
  8303. @code{run-in-store}, and @code{enter-store-monad}. The former is used
  8304. to ``run'' a single monadic value through the store:
  8305. @example
  8306. scheme@@(guile-user)> ,run-in-store (package->derivation hello)
  8307. $1 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
  8308. @end example
  8309. The latter enters a recursive REPL, where all the return values are
  8310. automatically run through the store:
  8311. @example
  8312. scheme@@(guile-user)> ,enter-store-monad
  8313. store-monad@@(guile-user) [1]> (package->derivation hello)
  8314. $2 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
  8315. store-monad@@(guile-user) [1]> (text-file "foo" "Hello!")
  8316. $3 = "/gnu/store/@dots{}-foo"
  8317. store-monad@@(guile-user) [1]> ,q
  8318. scheme@@(guile-user)>
  8319. @end example
  8320. @noindent
  8321. Note that non-monadic values cannot be returned in the
  8322. @code{store-monad} REPL.
  8323. The main syntactic forms to deal with monads in general are provided by
  8324. the @code{(guix monads)} module and are described below.
  8325. @deffn {Scheme Syntax} with-monad @var{monad} @var{body} ...
  8326. Evaluate any @code{>>=} or @code{return} forms in @var{body} as being
  8327. in @var{monad}.
  8328. @end deffn
  8329. @deffn {Scheme Syntax} return @var{val}
  8330. Return a monadic value that encapsulates @var{val}.
  8331. @end deffn
  8332. @deffn {Scheme Syntax} >>= @var{mval} @var{mproc} ...
  8333. @dfn{Bind} monadic value @var{mval}, passing its ``contents'' to monadic
  8334. procedures @var{mproc}@dots{}@footnote{This operation is commonly
  8335. referred to as ``bind'', but that name denotes an unrelated procedure in
  8336. Guile. Thus we use this somewhat cryptic symbol inherited from the
  8337. Haskell language.}. There can be one @var{mproc} or several of them, as
  8338. in this example:
  8339. @lisp
  8340. (run-with-state
  8341. (with-monad %state-monad
  8342. (>>= (return 1)
  8343. (lambda (x) (return (+ 1 x)))
  8344. (lambda (x) (return (* 2 x)))))
  8345. 'some-state)
  8346. @result{} 4
  8347. @result{} some-state
  8348. @end lisp
  8349. @end deffn
  8350. @deffn {Scheme Syntax} mlet @var{monad} ((@var{var} @var{mval}) ...) @
  8351. @var{body} ...
  8352. @deffnx {Scheme Syntax} mlet* @var{monad} ((@var{var} @var{mval}) ...) @
  8353. @var{body} ...
  8354. Bind the variables @var{var} to the monadic values @var{mval} in
  8355. @var{body}, which is a sequence of expressions. As with the bind
  8356. operator, this can be thought of as ``unpacking'' the raw, non-monadic
  8357. value ``contained'' in @var{mval} and making @var{var} refer to that
  8358. raw, non-monadic value within the scope of the @var{body}. The form
  8359. (@var{var} -> @var{val}) binds @var{var} to the ``normal'' value
  8360. @var{val}, as per @code{let}. The binding operations occur in sequence
  8361. from left to right. The last expression of @var{body} must be a monadic
  8362. expression, and its result will become the result of the @code{mlet} or
  8363. @code{mlet*} when run in the @var{monad}.
  8364. @code{mlet*} is to @code{mlet} what @code{let*} is to @code{let}
  8365. (@pxref{Local Bindings,,, guile, GNU Guile Reference Manual}).
  8366. @end deffn
  8367. @deffn {Scheme System} mbegin @var{monad} @var{mexp} ...
  8368. Bind @var{mexp} and the following monadic expressions in sequence,
  8369. returning the result of the last expression. Every expression in the
  8370. sequence must be a monadic expression.
  8371. This is akin to @code{mlet}, except that the return values of the
  8372. monadic expressions are ignored. In that sense, it is analogous to
  8373. @code{begin}, but applied to monadic expressions.
  8374. @end deffn
  8375. @deffn {Scheme System} mwhen @var{condition} @var{mexp0} @var{mexp*} ...
  8376. When @var{condition} is true, evaluate the sequence of monadic
  8377. expressions @var{mexp0}..@var{mexp*} as in an @code{mbegin}. When
  8378. @var{condition} is false, return @code{*unspecified*} in the current
  8379. monad. Every expression in the sequence must be a monadic expression.
  8380. @end deffn
  8381. @deffn {Scheme System} munless @var{condition} @var{mexp0} @var{mexp*} ...
  8382. When @var{condition} is false, evaluate the sequence of monadic
  8383. expressions @var{mexp0}..@var{mexp*} as in an @code{mbegin}. When
  8384. @var{condition} is true, return @code{*unspecified*} in the current
  8385. monad. Every expression in the sequence must be a monadic expression.
  8386. @end deffn
  8387. @cindex state monad
  8388. The @code{(guix monads)} module provides the @dfn{state monad}, which
  8389. allows an additional value---the state---to be @emph{threaded} through
  8390. monadic procedure calls.
  8391. @defvr {Scheme Variable} %state-monad
  8392. The state monad. Procedures in the state monad can access and change
  8393. the state that is threaded.
  8394. Consider the example below. The @code{square} procedure returns a value
  8395. in the state monad. It returns the square of its argument, but also
  8396. increments the current state value:
  8397. @lisp
  8398. (define (square x)
  8399. (mlet %state-monad ((count (current-state)))
  8400. (mbegin %state-monad
  8401. (set-current-state (+ 1 count))
  8402. (return (* x x)))))
  8403. (run-with-state (sequence %state-monad (map square (iota 3))) 0)
  8404. @result{} (0 1 4)
  8405. @result{} 3
  8406. @end lisp
  8407. When ``run'' through @code{%state-monad}, we obtain that additional state
  8408. value, which is the number of @code{square} calls.
  8409. @end defvr
  8410. @deffn {Monadic Procedure} current-state
  8411. Return the current state as a monadic value.
  8412. @end deffn
  8413. @deffn {Monadic Procedure} set-current-state @var{value}
  8414. Set the current state to @var{value} and return the previous state as a
  8415. monadic value.
  8416. @end deffn
  8417. @deffn {Monadic Procedure} state-push @var{value}
  8418. Push @var{value} to the current state, which is assumed to be a list,
  8419. and return the previous state as a monadic value.
  8420. @end deffn
  8421. @deffn {Monadic Procedure} state-pop
  8422. Pop a value from the current state and return it as a monadic value.
  8423. The state is assumed to be a list.
  8424. @end deffn
  8425. @deffn {Scheme Procedure} run-with-state @var{mval} [@var{state}]
  8426. Run monadic value @var{mval} starting with @var{state} as the initial
  8427. state. Return two values: the resulting value, and the resulting state.
  8428. @end deffn
  8429. The main interface to the store monad, provided by the @code{(guix
  8430. store)} module, is as follows.
  8431. @defvr {Scheme Variable} %store-monad
  8432. The store monad---an alias for @code{%state-monad}.
  8433. Values in the store monad encapsulate accesses to the store. When its
  8434. effect is needed, a value of the store monad must be ``evaluated'' by
  8435. passing it to the @code{run-with-store} procedure (see below).
  8436. @end defvr
  8437. @deffn {Scheme Procedure} run-with-store @var{store} @var{mval} [#:guile-for-build] [#:system (%current-system)]
  8438. Run @var{mval}, a monadic value in the store monad, in @var{store}, an
  8439. open store connection.
  8440. @end deffn
  8441. @deffn {Monadic Procedure} text-file @var{name} @var{text} [@var{references}]
  8442. Return as a monadic value the absolute file name in the store of the file
  8443. containing @var{text}, a string. @var{references} is a list of store items that the
  8444. resulting text file refers to; it defaults to the empty list.
  8445. @end deffn
  8446. @deffn {Monadic Procedure} binary-file @var{name} @var{data} [@var{references}]
  8447. Return as a monadic value the absolute file name in the store of the file
  8448. containing @var{data}, a bytevector. @var{references} is a list of store
  8449. items that the resulting binary file refers to; it defaults to the empty list.
  8450. @end deffn
  8451. @deffn {Monadic Procedure} interned-file @var{file} [@var{name}] @
  8452. [#:recursive? #t] [#:select? (const #t)]
  8453. Return the name of @var{file} once interned in the store. Use
  8454. @var{name} as its store name, or the basename of @var{file} if
  8455. @var{name} is omitted.
  8456. When @var{recursive?} is true, the contents of @var{file} are added
  8457. recursively; if @var{file} designates a flat file and @var{recursive?}
  8458. is true, its contents are added, and its permission bits are kept.
  8459. When @var{recursive?} is true, call @code{(@var{select?} @var{file}
  8460. @var{stat})} for each directory entry, where @var{file} is the entry's
  8461. absolute file name and @var{stat} is the result of @code{lstat}; exclude
  8462. entries for which @var{select?} does not return true.
  8463. The example below adds a file to the store, under two different names:
  8464. @lisp
  8465. (run-with-store (open-connection)
  8466. (mlet %store-monad ((a (interned-file "README"))
  8467. (b (interned-file "README" "LEGU-MIN")))
  8468. (return (list a b))))
  8469. @result{} ("/gnu/store/rwm@dots{}-README" "/gnu/store/44i@dots{}-LEGU-MIN")
  8470. @end lisp
  8471. @end deffn
  8472. The @code{(guix packages)} module exports the following package-related
  8473. monadic procedures:
  8474. @deffn {Monadic Procedure} package-file @var{package} [@var{file}] @
  8475. [#:system (%current-system)] [#:target #f] @
  8476. [#:output "out"]
  8477. Return as a monadic
  8478. value in the absolute file name of @var{file} within the @var{output}
  8479. directory of @var{package}. When @var{file} is omitted, return the name
  8480. of the @var{output} directory of @var{package}. When @var{target} is
  8481. true, use it as a cross-compilation target triplet.
  8482. Note that this procedure does @emph{not} build @var{package}. Thus, the
  8483. result might or might not designate an existing file. We recommend not
  8484. using this procedure unless you know what you are doing.
  8485. @end deffn
  8486. @deffn {Monadic Procedure} package->derivation @var{package} [@var{system}]
  8487. @deffnx {Monadic Procedure} package->cross-derivation @var{package} @
  8488. @var{target} [@var{system}]
  8489. Monadic version of @code{package-derivation} and
  8490. @code{package-cross-derivation} (@pxref{Defining Packages}).
  8491. @end deffn
  8492. @node G-Expressions
  8493. @section G-Expressions
  8494. @cindex G-expression
  8495. @cindex build code quoting
  8496. So we have ``derivations'', which represent a sequence of build actions
  8497. to be performed to produce an item in the store (@pxref{Derivations}).
  8498. These build actions are performed when asking the daemon to actually
  8499. build the derivations; they are run by the daemon in a container
  8500. (@pxref{Invoking guix-daemon}).
  8501. @cindex code staging
  8502. @cindex staging, of code
  8503. @cindex strata of code
  8504. It should come as no surprise that we like to write these build actions
  8505. in Scheme. When we do that, we end up with two @dfn{strata} of Scheme
  8506. code@footnote{The term @dfn{stratum} in this context was coined by
  8507. Manuel Serrano et al.@: in the context of their work on Hop. Oleg
  8508. Kiselyov, who has written insightful
  8509. @url{http://okmij.org/ftp/meta-programming/#meta-scheme, essays and code
  8510. on this topic}, refers to this kind of code generation as
  8511. @dfn{staging}.}: the ``host code''---code that defines packages, talks
  8512. to the daemon, etc.---and the ``build code''---code that actually
  8513. performs build actions, such as making directories, invoking
  8514. @command{make}, and so on (@pxref{Build Phases}).
  8515. To describe a derivation and its build actions, one typically needs to
  8516. embed build code inside host code. It boils down to manipulating build
  8517. code as data, and the homoiconicity of Scheme---code has a direct
  8518. representation as data---comes in handy for that. But we need more than
  8519. the normal @code{quasiquote} mechanism in Scheme to construct build
  8520. expressions.
  8521. The @code{(guix gexp)} module implements @dfn{G-expressions}, a form of
  8522. S-expressions adapted to build expressions. G-expressions, or
  8523. @dfn{gexps}, consist essentially of three syntactic forms: @code{gexp},
  8524. @code{ungexp}, and @code{ungexp-splicing} (or simply: @code{#~},
  8525. @code{#$}, and @code{#$@@}), which are comparable to
  8526. @code{quasiquote}, @code{unquote}, and @code{unquote-splicing},
  8527. respectively (@pxref{Expression Syntax, @code{quasiquote},, guile,
  8528. GNU Guile Reference Manual}). However, there are major differences:
  8529. @itemize
  8530. @item
  8531. Gexps are meant to be written to a file and run or manipulated by other
  8532. processes.
  8533. @item
  8534. When a high-level object such as a package or derivation is unquoted
  8535. inside a gexp, the result is as if its output file name had been
  8536. introduced.
  8537. @item
  8538. Gexps carry information about the packages or derivations they refer to,
  8539. and these dependencies are automatically added as inputs to the build
  8540. processes that use them.
  8541. @end itemize
  8542. @cindex lowering, of high-level objects in gexps
  8543. This mechanism is not limited to package and derivation
  8544. objects: @dfn{compilers} able to ``lower'' other high-level objects to
  8545. derivations or files in the store can be defined,
  8546. such that these objects can also be inserted
  8547. into gexps. For example, a useful type of high-level objects that can be
  8548. inserted in a gexp is ``file-like objects'', which make it easy to
  8549. add files to the store and to refer to them in
  8550. derivations and such (see @code{local-file} and @code{plain-file}
  8551. below).
  8552. To illustrate the idea, here is an example of a gexp:
  8553. @lisp
  8554. (define build-exp
  8555. #~(begin
  8556. (mkdir #$output)
  8557. (chdir #$output)
  8558. (symlink (string-append #$coreutils "/bin/ls")
  8559. "list-files")))
  8560. @end lisp
  8561. This gexp can be passed to @code{gexp->derivation}; we obtain a
  8562. derivation that builds a directory containing exactly one symlink to
  8563. @file{/gnu/store/@dots{}-coreutils-8.22/bin/ls}:
  8564. @lisp
  8565. (gexp->derivation "the-thing" build-exp)
  8566. @end lisp
  8567. As one would expect, the @code{"/gnu/store/@dots{}-coreutils-8.22"} string is
  8568. substituted to the reference to the @var{coreutils} package in the
  8569. actual build code, and @var{coreutils} is automatically made an input to
  8570. the derivation. Likewise, @code{#$output} (equivalent to @code{(ungexp
  8571. output)}) is replaced by a string containing the directory name of the
  8572. output of the derivation.
  8573. @cindex cross compilation
  8574. In a cross-compilation context, it is useful to distinguish between
  8575. references to the @emph{native} build of a package---that can run on the
  8576. host---versus references to cross builds of a package. To that end, the
  8577. @code{#+} plays the same role as @code{#$}, but is a reference to a
  8578. native package build:
  8579. @lisp
  8580. (gexp->derivation "vi"
  8581. #~(begin
  8582. (mkdir #$output)
  8583. (mkdir (string-append #$output "/bin"))
  8584. (system* (string-append #+coreutils "/bin/ln")
  8585. "-s"
  8586. (string-append #$emacs "/bin/emacs")
  8587. (string-append #$output "/bin/vi")))
  8588. #:target "aarch64-linux-gnu")
  8589. @end lisp
  8590. @noindent
  8591. In the example above, the native build of @var{coreutils} is used, so
  8592. that @command{ln} can actually run on the host; but then the
  8593. cross-compiled build of @var{emacs} is referenced.
  8594. @cindex imported modules, for gexps
  8595. @findex with-imported-modules
  8596. Another gexp feature is @dfn{imported modules}: sometimes you want to be
  8597. able to use certain Guile modules from the ``host environment'' in the
  8598. gexp, so those modules should be imported in the ``build environment''.
  8599. The @code{with-imported-modules} form allows you to express that:
  8600. @lisp
  8601. (let ((build (with-imported-modules '((guix build utils))
  8602. #~(begin
  8603. (use-modules (guix build utils))
  8604. (mkdir-p (string-append #$output "/bin"))))))
  8605. (gexp->derivation "empty-dir"
  8606. #~(begin
  8607. #$build
  8608. (display "success!\n")
  8609. #t)))
  8610. @end lisp
  8611. @noindent
  8612. In this example, the @code{(guix build utils)} module is automatically
  8613. pulled into the isolated build environment of our gexp, such that
  8614. @code{(use-modules (guix build utils))} works as expected.
  8615. @cindex module closure
  8616. @findex source-module-closure
  8617. Usually you want the @emph{closure} of the module to be imported---i.e.,
  8618. the module itself and all the modules it depends on---rather than just
  8619. the module; failing to do that, attempts to use the module will fail
  8620. because of missing dependent modules. The @code{source-module-closure}
  8621. procedure computes the closure of a module by looking at its source file
  8622. headers, which comes in handy in this case:
  8623. @lisp
  8624. (use-modules (guix modules)) ;for 'source-module-closure'
  8625. (with-imported-modules (source-module-closure
  8626. '((guix build utils)
  8627. (gnu build image)))
  8628. (gexp->derivation "something-with-vms"
  8629. #~(begin
  8630. (use-modules (guix build utils)
  8631. (gnu build image))
  8632. @dots{})))
  8633. @end lisp
  8634. @cindex extensions, for gexps
  8635. @findex with-extensions
  8636. In the same vein, sometimes you want to import not just pure-Scheme
  8637. modules, but also ``extensions'' such as Guile bindings to C libraries
  8638. or other ``full-blown'' packages. Say you need the @code{guile-json}
  8639. package available on the build side, here's how you would do it:
  8640. @lisp
  8641. (use-modules (gnu packages guile)) ;for 'guile-json'
  8642. (with-extensions (list guile-json)
  8643. (gexp->derivation "something-with-json"
  8644. #~(begin
  8645. (use-modules (json))
  8646. @dots{})))
  8647. @end lisp
  8648. The syntactic form to construct gexps is summarized below.
  8649. @deffn {Scheme Syntax} #~@var{exp}
  8650. @deffnx {Scheme Syntax} (gexp @var{exp})
  8651. Return a G-expression containing @var{exp}. @var{exp} may contain one
  8652. or more of the following forms:
  8653. @table @code
  8654. @item #$@var{obj}
  8655. @itemx (ungexp @var{obj})
  8656. Introduce a reference to @var{obj}. @var{obj} may have one of the
  8657. supported types, for example a package or a
  8658. derivation, in which case the @code{ungexp} form is replaced by its
  8659. output file name---e.g., @code{"/gnu/store/@dots{}-coreutils-8.22}.
  8660. If @var{obj} is a list, it is traversed and references to supported
  8661. objects are substituted similarly.
  8662. If @var{obj} is another gexp, its contents are inserted and its
  8663. dependencies are added to those of the containing gexp.
  8664. If @var{obj} is another kind of object, it is inserted as is.
  8665. @item #$@var{obj}:@var{output}
  8666. @itemx (ungexp @var{obj} @var{output})
  8667. This is like the form above, but referring explicitly to the
  8668. @var{output} of @var{obj}---this is useful when @var{obj} produces
  8669. multiple outputs (@pxref{Packages with Multiple Outputs}).
  8670. @item #+@var{obj}
  8671. @itemx #+@var{obj}:output
  8672. @itemx (ungexp-native @var{obj})
  8673. @itemx (ungexp-native @var{obj} @var{output})
  8674. Same as @code{ungexp}, but produces a reference to the @emph{native}
  8675. build of @var{obj} when used in a cross compilation context.
  8676. @item #$output[:@var{output}]
  8677. @itemx (ungexp output [@var{output}])
  8678. Insert a reference to derivation output @var{output}, or to the main
  8679. output when @var{output} is omitted.
  8680. This only makes sense for gexps passed to @code{gexp->derivation}.
  8681. @item #$@@@var{lst}
  8682. @itemx (ungexp-splicing @var{lst})
  8683. Like the above, but splices the contents of @var{lst} inside the
  8684. containing list.
  8685. @item #+@@@var{lst}
  8686. @itemx (ungexp-native-splicing @var{lst})
  8687. Like the above, but refers to native builds of the objects listed in
  8688. @var{lst}.
  8689. @end table
  8690. G-expressions created by @code{gexp} or @code{#~} are run-time objects
  8691. of the @code{gexp?} type (see below).
  8692. @end deffn
  8693. @deffn {Scheme Syntax} with-imported-modules @var{modules} @var{body}@dots{}
  8694. Mark the gexps defined in @var{body}@dots{} as requiring @var{modules}
  8695. in their execution environment.
  8696. Each item in @var{modules} can be the name of a module, such as
  8697. @code{(guix build utils)}, or it can be a module name, followed by an
  8698. arrow, followed by a file-like object:
  8699. @lisp
  8700. `((guix build utils)
  8701. (guix gcrypt)
  8702. ((guix config) => ,(scheme-file "config.scm"
  8703. #~(define-module @dots{}))))
  8704. @end lisp
  8705. @noindent
  8706. In the example above, the first two modules are taken from the search
  8707. path, and the last one is created from the given file-like object.
  8708. This form has @emph{lexical} scope: it has an effect on the gexps
  8709. directly defined in @var{body}@dots{}, but not on those defined, say, in
  8710. procedures called from @var{body}@dots{}.
  8711. @end deffn
  8712. @deffn {Scheme Syntax} with-extensions @var{extensions} @var{body}@dots{}
  8713. Mark the gexps defined in @var{body}@dots{} as requiring
  8714. @var{extensions} in their build and execution environment.
  8715. @var{extensions} is typically a list of package objects such as those
  8716. defined in the @code{(gnu packages guile)} module.
  8717. Concretely, the packages listed in @var{extensions} are added to the
  8718. load path while compiling imported modules in @var{body}@dots{}; they
  8719. are also added to the load path of the gexp returned by
  8720. @var{body}@dots{}.
  8721. @end deffn
  8722. @deffn {Scheme Procedure} gexp? @var{obj}
  8723. Return @code{#t} if @var{obj} is a G-expression.
  8724. @end deffn
  8725. G-expressions are meant to be written to disk, either as code building
  8726. some derivation, or as plain files in the store. The monadic procedures
  8727. below allow you to do that (@pxref{The Store Monad}, for more
  8728. information about monads).
  8729. @deffn {Monadic Procedure} gexp->derivation @var{name} @var{exp} @
  8730. [#:system (%current-system)] [#:target #f] [#:graft? #t] @
  8731. [#:hash #f] [#:hash-algo #f] @
  8732. [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
  8733. [#:module-path @code{%load-path}] @
  8734. [#:effective-version "2.2"] @
  8735. [#:references-graphs #f] [#:allowed-references #f] @
  8736. [#:disallowed-references #f] @
  8737. [#:leaked-env-vars #f] @
  8738. [#:script-name (string-append @var{name} "-builder")] @
  8739. [#:deprecation-warnings #f] @
  8740. [#:local-build? #f] [#:substitutable? #t] @
  8741. [#:properties '()] [#:guile-for-build #f]
  8742. Return a derivation @var{name} that runs @var{exp} (a gexp) with
  8743. @var{guile-for-build} (a derivation) on @var{system}; @var{exp} is
  8744. stored in a file called @var{script-name}. When @var{target} is true,
  8745. it is used as the cross-compilation target triplet for packages referred
  8746. to by @var{exp}.
  8747. @var{modules} is deprecated in favor of @code{with-imported-modules}.
  8748. Its meaning is to
  8749. make @var{modules} available in the evaluation context of @var{exp};
  8750. @var{modules} is a list of names of Guile modules searched in
  8751. @var{module-path} to be copied in the store, compiled, and made available in
  8752. the load path during the execution of @var{exp}---e.g., @code{((guix
  8753. build utils) (guix build gnu-build-system))}.
  8754. @var{effective-version} determines the string to use when adding extensions of
  8755. @var{exp} (see @code{with-extensions}) to the search path---e.g., @code{"2.2"}.
  8756. @var{graft?} determines whether packages referred to by @var{exp} should be grafted when
  8757. applicable.
  8758. When @var{references-graphs} is true, it must be a list of tuples of one of the
  8759. following forms:
  8760. @example
  8761. (@var{file-name} @var{package})
  8762. (@var{file-name} @var{package} @var{output})
  8763. (@var{file-name} @var{derivation})
  8764. (@var{file-name} @var{derivation} @var{output})
  8765. (@var{file-name} @var{store-item})
  8766. @end example
  8767. The right-hand-side of each element of @var{references-graphs} is automatically made
  8768. an input of the build process of @var{exp}. In the build environment, each
  8769. @var{file-name} contains the reference graph of the corresponding item, in a simple
  8770. text format.
  8771. @var{allowed-references} must be either @code{#f} or a list of output names and packages.
  8772. In the latter case, the list denotes store items that the result is allowed to
  8773. refer to. Any reference to another store item will lead to a build error.
  8774. Similarly for @var{disallowed-references}, which can list items that must not be
  8775. referenced by the outputs.
  8776. @var{deprecation-warnings} determines whether to show deprecation warnings while
  8777. compiling modules. It can be @code{#f}, @code{#t}, or @code{'detailed}.
  8778. The other arguments are as for @code{derivation} (@pxref{Derivations}).
  8779. @end deffn
  8780. @cindex file-like objects
  8781. The @code{local-file}, @code{plain-file}, @code{computed-file},
  8782. @code{program-file}, and @code{scheme-file} procedures below return
  8783. @dfn{file-like objects}. That is, when unquoted in a G-expression,
  8784. these objects lead to a file in the store. Consider this G-expression:
  8785. @lisp
  8786. #~(system* #$(file-append glibc "/sbin/nscd") "-f"
  8787. #$(local-file "/tmp/my-nscd.conf"))
  8788. @end lisp
  8789. The effect here is to ``intern'' @file{/tmp/my-nscd.conf} by copying it
  8790. to the store. Once expanded, for instance @i{via}
  8791. @code{gexp->derivation}, the G-expression refers to that copy under
  8792. @file{/gnu/store}; thus, modifying or removing the file in @file{/tmp}
  8793. does not have any effect on what the G-expression does.
  8794. @code{plain-file} can be used similarly; it differs in that the file
  8795. content is directly passed as a string.
  8796. @deffn {Scheme Procedure} local-file @var{file} [@var{name}] @
  8797. [#:recursive? #f] [#:select? (const #t)]
  8798. Return an object representing local file @var{file} to add to the store;
  8799. this object can be used in a gexp. If @var{file} is a literal string
  8800. denoting a relative file name, it is looked up relative to the source
  8801. file where it appears; if @var{file} is not a literal string, it is
  8802. looked up relative to the current working directory at run time.
  8803. @var{file} will be added to the store under @var{name}--by default the
  8804. base name of @var{file}.
  8805. When @var{recursive?} is true, the contents of @var{file} are added recursively; if @var{file}
  8806. designates a flat file and @var{recursive?} is true, its contents are added, and its
  8807. permission bits are kept.
  8808. When @var{recursive?} is true, call @code{(@var{select?} @var{file}
  8809. @var{stat})} for each directory entry, where @var{file} is the entry's
  8810. absolute file name and @var{stat} is the result of @code{lstat}; exclude
  8811. entries for which @var{select?} does not return true.
  8812. This is the declarative counterpart of the @code{interned-file} monadic
  8813. procedure (@pxref{The Store Monad, @code{interned-file}}).
  8814. @end deffn
  8815. @deffn {Scheme Procedure} plain-file @var{name} @var{content}
  8816. Return an object representing a text file called @var{name} with the given
  8817. @var{content} (a string or a bytevector) to be added to the store.
  8818. This is the declarative counterpart of @code{text-file}.
  8819. @end deffn
  8820. @deffn {Scheme Procedure} computed-file @var{name} @var{gexp} @
  8821. [#:local-build? #t]
  8822. [#:options '()]
  8823. Return an object representing the store item @var{name}, a file or
  8824. directory computed by @var{gexp}. When @var{local-build?} is true (the
  8825. default), the derivation is built locally. @var{options} is a list of
  8826. additional arguments to pass to @code{gexp->derivation}.
  8827. This is the declarative counterpart of @code{gexp->derivation}.
  8828. @end deffn
  8829. @deffn {Monadic Procedure} gexp->script @var{name} @var{exp} @
  8830. [#:guile (default-guile)] [#:module-path %load-path] @
  8831. [#:system (%current-system)] [#:target #f]
  8832. Return an executable script @var{name} that runs @var{exp} using
  8833. @var{guile}, with @var{exp}'s imported modules in its search path.
  8834. Look up @var{exp}'s modules in @var{module-path}.
  8835. The example below builds a script that simply invokes the @command{ls}
  8836. command:
  8837. @lisp
  8838. (use-modules (guix gexp) (gnu packages base))
  8839. (gexp->script "list-files"
  8840. #~(execl #$(file-append coreutils "/bin/ls")
  8841. "ls"))
  8842. @end lisp
  8843. When ``running'' it through the store (@pxref{The Store Monad,
  8844. @code{run-with-store}}), we obtain a derivation that produces an
  8845. executable file @file{/gnu/store/@dots{}-list-files} along these lines:
  8846. @example
  8847. #!/gnu/store/@dots{}-guile-2.0.11/bin/guile -ds
  8848. !#
  8849. (execl "/gnu/store/@dots{}-coreutils-8.22"/bin/ls" "ls")
  8850. @end example
  8851. @end deffn
  8852. @deffn {Scheme Procedure} program-file @var{name} @var{exp} @
  8853. [#:guile #f] [#:module-path %load-path]
  8854. Return an object representing the executable store item @var{name} that
  8855. runs @var{gexp}. @var{guile} is the Guile package used to execute that
  8856. script. Imported modules of @var{gexp} are looked up in @var{module-path}.
  8857. This is the declarative counterpart of @code{gexp->script}.
  8858. @end deffn
  8859. @deffn {Monadic Procedure} gexp->file @var{name} @var{exp} @
  8860. [#:set-load-path? #t] [#:module-path %load-path] @
  8861. [#:splice? #f] @
  8862. [#:guile (default-guile)]
  8863. Return a derivation that builds a file @var{name} containing @var{exp}.
  8864. When @var{splice?} is true, @var{exp} is considered to be a list of
  8865. expressions that will be spliced in the resulting file.
  8866. When @var{set-load-path?} is true, emit code in the resulting file to
  8867. set @code{%load-path} and @code{%load-compiled-path} to honor
  8868. @var{exp}'s imported modules. Look up @var{exp}'s modules in
  8869. @var{module-path}.
  8870. The resulting file holds references to all the dependencies of @var{exp}
  8871. or a subset thereof.
  8872. @end deffn
  8873. @deffn {Scheme Procedure} scheme-file @var{name} @var{exp} @
  8874. [#:splice? #f] [#:set-load-path? #t]
  8875. Return an object representing the Scheme file @var{name} that contains
  8876. @var{exp}.
  8877. This is the declarative counterpart of @code{gexp->file}.
  8878. @end deffn
  8879. @deffn {Monadic Procedure} text-file* @var{name} @var{text} @dots{}
  8880. Return as a monadic value a derivation that builds a text file
  8881. containing all of @var{text}. @var{text} may list, in addition to
  8882. strings, objects of any type that can be used in a gexp: packages,
  8883. derivations, local file objects, etc. The resulting store file holds
  8884. references to all these.
  8885. This variant should be preferred over @code{text-file} anytime the file
  8886. to create will reference items from the store. This is typically the
  8887. case when building a configuration file that embeds store file names,
  8888. like this:
  8889. @lisp
  8890. (define (profile.sh)
  8891. ;; Return the name of a shell script in the store that
  8892. ;; initializes the 'PATH' environment variable.
  8893. (text-file* "profile.sh"
  8894. "export PATH=" coreutils "/bin:"
  8895. grep "/bin:" sed "/bin\n"))
  8896. @end lisp
  8897. In this example, the resulting @file{/gnu/store/@dots{}-profile.sh} file
  8898. will reference @var{coreutils}, @var{grep}, and @var{sed}, thereby
  8899. preventing them from being garbage-collected during its lifetime.
  8900. @end deffn
  8901. @deffn {Scheme Procedure} mixed-text-file @var{name} @var{text} @dots{}
  8902. Return an object representing store file @var{name} containing
  8903. @var{text}. @var{text} is a sequence of strings and file-like objects,
  8904. as in:
  8905. @lisp
  8906. (mixed-text-file "profile"
  8907. "export PATH=" coreutils "/bin:" grep "/bin")
  8908. @end lisp
  8909. This is the declarative counterpart of @code{text-file*}.
  8910. @end deffn
  8911. @deffn {Scheme Procedure} file-union @var{name} @var{files}
  8912. Return a @code{<computed-file>} that builds a directory containing all of @var{files}.
  8913. Each item in @var{files} must be a two-element list where the first element is the
  8914. file name to use in the new directory, and the second element is a gexp
  8915. denoting the target file. Here's an example:
  8916. @lisp
  8917. (file-union "etc"
  8918. `(("hosts" ,(plain-file "hosts"
  8919. "127.0.0.1 localhost"))
  8920. ("bashrc" ,(plain-file "bashrc"
  8921. "alias ls='ls --color=auto'"))))
  8922. @end lisp
  8923. This yields an @code{etc} directory containing these two files.
  8924. @end deffn
  8925. @deffn {Scheme Procedure} directory-union @var{name} @var{things}
  8926. Return a directory that is the union of @var{things}, where @var{things} is a list of
  8927. file-like objects denoting directories. For example:
  8928. @lisp
  8929. (directory-union "guile+emacs" (list guile emacs))
  8930. @end lisp
  8931. yields a directory that is the union of the @code{guile} and @code{emacs} packages.
  8932. @end deffn
  8933. @deffn {Scheme Procedure} file-append @var{obj} @var{suffix} @dots{}
  8934. Return a file-like object that expands to the concatenation of @var{obj}
  8935. and @var{suffix}, where @var{obj} is a lowerable object and each
  8936. @var{suffix} is a string.
  8937. As an example, consider this gexp:
  8938. @lisp
  8939. (gexp->script "run-uname"
  8940. #~(system* #$(file-append coreutils
  8941. "/bin/uname")))
  8942. @end lisp
  8943. The same effect could be achieved with:
  8944. @lisp
  8945. (gexp->script "run-uname"
  8946. #~(system* (string-append #$coreutils
  8947. "/bin/uname")))
  8948. @end lisp
  8949. There is one difference though: in the @code{file-append} case, the
  8950. resulting script contains the absolute file name as a string, whereas in
  8951. the second case, the resulting script contains a @code{(string-append
  8952. @dots{})} expression to construct the file name @emph{at run time}.
  8953. @end deffn
  8954. @deffn {Scheme Syntax} let-system @var{system} @var{body}@dots{}
  8955. @deffnx {Scheme Syntax} let-system (@var{system} @var{target}) @var{body}@dots{}
  8956. Bind @var{system} to the currently targeted system---e.g.,
  8957. @code{"x86_64-linux"}---within @var{body}.
  8958. In the second case, additionally bind @var{target} to the current
  8959. cross-compilation target---a GNU triplet such as
  8960. @code{"arm-linux-gnueabihf"}---or @code{#f} if we are not
  8961. cross-compiling.
  8962. @code{let-system} is useful in the occasional case where the object
  8963. spliced into the gexp depends on the target system, as in this example:
  8964. @lisp
  8965. #~(system*
  8966. #+(let-system system
  8967. (cond ((string-prefix? "armhf-" system)
  8968. (file-append qemu "/bin/qemu-system-arm"))
  8969. ((string-prefix? "x86_64-" system)
  8970. (file-append qemu "/bin/qemu-system-x86_64"))
  8971. (else
  8972. (error "dunno!"))))
  8973. "-net" "user" #$image)
  8974. @end lisp
  8975. @end deffn
  8976. @deffn {Scheme Syntax} with-parameters ((@var{parameter} @var{value}) @dots{}) @var{exp}
  8977. This macro is similar to the @code{parameterize} form for
  8978. dynamically-bound @dfn{parameters} (@pxref{Parameters,,, guile, GNU
  8979. Guile Reference Manual}). The key difference is that it takes effect
  8980. when the file-like object returned by @var{exp} is lowered to a
  8981. derivation or store item.
  8982. A typical use of @code{with-parameters} is to force the system in effect
  8983. for a given object:
  8984. @lisp
  8985. (with-parameters ((%current-system "i686-linux"))
  8986. coreutils)
  8987. @end lisp
  8988. The example above returns an object that corresponds to the i686 build
  8989. of Coreutils, regardless of the current value of @code{%current-system}.
  8990. @end deffn
  8991. Of course, in addition to gexps embedded in ``host'' code, there are
  8992. also modules containing build tools. To make it clear that they are
  8993. meant to be used in the build stratum, these modules are kept in the
  8994. @code{(guix build @dots{})} name space.
  8995. @cindex lowering, of high-level objects in gexps
  8996. Internally, high-level objects are @dfn{lowered}, using their compiler,
  8997. to either derivations or store items. For instance, lowering a package
  8998. yields a derivation, and lowering a @code{plain-file} yields a store
  8999. item. This is achieved using the @code{lower-object} monadic procedure.
  9000. @deffn {Monadic Procedure} lower-object @var{obj} [@var{system}] @
  9001. [#:target #f]
  9002. Return as a value in @code{%store-monad} the derivation or store item
  9003. corresponding to @var{obj} for @var{system}, cross-compiling for
  9004. @var{target} if @var{target} is true. @var{obj} must be an object that
  9005. has an associated gexp compiler, such as a @code{<package>}.
  9006. @end deffn
  9007. @deffn {Procedure} gexp->approximate-sexp @var{gexp}
  9008. Sometimes, it may be useful to convert a G-exp into a S-exp. For
  9009. example, some linters (@pxref{Invoking guix lint}) peek into the build
  9010. phases of a package to detect potential problems. This conversion can
  9011. be achieved with this procedure. However, some information can be lost
  9012. in the process. More specifically, lowerable objects will be silently
  9013. replaced with some arbitrary object -- currently the list
  9014. @code{(*approximate*)}, but this may change.
  9015. @end deffn
  9016. @node Invoking guix repl
  9017. @section Invoking @command{guix repl}
  9018. @cindex REPL, read-eval-print loop, script
  9019. The @command{guix repl} command makes it easier to program Guix in Guile
  9020. by launching a Guile @dfn{read-eval-print loop} (REPL) for interactive
  9021. programming (@pxref{Using Guile Interactively,,, guile,
  9022. GNU Guile Reference Manual}), or by running Guile scripts
  9023. (@pxref{Running Guile Scripts,,, guile,
  9024. GNU Guile Reference Manual}).
  9025. Compared to just launching the @command{guile}
  9026. command, @command{guix repl} guarantees that all the Guix modules and all its
  9027. dependencies are available in the search path.
  9028. The general syntax is:
  9029. @example
  9030. guix repl @var{options} [@var{file} @var{args}]
  9031. @end example
  9032. When a @var{file} argument is provided, @var{file} is
  9033. executed as a Guile scripts:
  9034. @example
  9035. guix repl my-script.scm
  9036. @end example
  9037. To pass arguments to the script, use @code{--} to prevent them from
  9038. being interpreted as arguments to @command{guix repl} itself:
  9039. @example
  9040. guix repl -- my-script.scm --input=foo.txt
  9041. @end example
  9042. To make a script executable directly from the shell, using the guix
  9043. executable that is on the user's search path, add the following two
  9044. lines at the top of the script:
  9045. @example
  9046. @code{#!/usr/bin/env -S guix repl --}
  9047. @code{!#}
  9048. @end example
  9049. Without a file name argument, a Guile REPL is started:
  9050. @example
  9051. $ guix repl
  9052. scheme@@(guile-user)> ,use (gnu packages base)
  9053. scheme@@(guile-user)> coreutils
  9054. $1 = #<package coreutils@@8.29 gnu/packages/base.scm:327 3e28300>
  9055. @end example
  9056. @cindex inferiors
  9057. In addition, @command{guix repl} implements a simple machine-readable REPL
  9058. protocol for use by @code{(guix inferior)}, a facility to interact with
  9059. @dfn{inferiors}, separate processes running a potentially different revision
  9060. of Guix.
  9061. The available options are as follows:
  9062. @table @code
  9063. @item --type=@var{type}
  9064. @itemx -t @var{type}
  9065. Start a REPL of the given @var{TYPE}, which can be one of the following:
  9066. @table @code
  9067. @item guile
  9068. This is default, and it spawns a standard full-featured Guile REPL.
  9069. @item machine
  9070. Spawn a REPL that uses the machine-readable protocol. This is the protocol
  9071. that the @code{(guix inferior)} module speaks.
  9072. @end table
  9073. @item --listen=@var{endpoint}
  9074. By default, @command{guix repl} reads from standard input and writes to
  9075. standard output. When this option is passed, it will instead listen for
  9076. connections on @var{endpoint}. Here are examples of valid options:
  9077. @table @code
  9078. @item --listen=tcp:37146
  9079. Accept connections on localhost on port 37146.
  9080. @item --listen=unix:/tmp/socket
  9081. Accept connections on the Unix-domain socket @file{/tmp/socket}.
  9082. @end table
  9083. @item --load-path=@var{directory}
  9084. @itemx -L @var{directory}
  9085. Add @var{directory} to the front of the package module search path
  9086. (@pxref{Package Modules}).
  9087. This allows users to define their own packages and make them visible to
  9088. the script or REPL.
  9089. @item -q
  9090. Inhibit loading of the @file{~/.guile} file. By default, that
  9091. configuration file is loaded when spawning a @code{guile} REPL.
  9092. @end table
  9093. @c *********************************************************************
  9094. @node Utilities
  9095. @chapter Utilities
  9096. This section describes Guix command-line utilities. Some of them are
  9097. primarily targeted at developers and users who write new package
  9098. definitions, while others are more generally useful. They complement
  9099. the Scheme programming interface of Guix in a convenient way.
  9100. @menu
  9101. * Invoking guix build:: Building packages from the command line.
  9102. * Invoking guix edit:: Editing package definitions.
  9103. * Invoking guix download:: Downloading a file and printing its hash.
  9104. * Invoking guix hash:: Computing the cryptographic hash of a file.
  9105. * Invoking guix import:: Importing package definitions.
  9106. * Invoking guix refresh:: Updating package definitions.
  9107. * Invoking guix style:: Styling package definitions.
  9108. * Invoking guix lint:: Finding errors in package definitions.
  9109. * Invoking guix size:: Profiling disk usage.
  9110. * Invoking guix graph:: Visualizing the graph of packages.
  9111. * Invoking guix publish:: Sharing substitutes.
  9112. * Invoking guix challenge:: Challenging substitute servers.
  9113. * Invoking guix copy:: Copying to and from a remote store.
  9114. * Invoking guix container:: Process isolation.
  9115. * Invoking guix weather:: Assessing substitute availability.
  9116. * Invoking guix processes:: Listing client processes.
  9117. @end menu
  9118. @node Invoking guix build
  9119. @section Invoking @command{guix build}
  9120. @cindex package building
  9121. @cindex @command{guix build}
  9122. The @command{guix build} command builds packages or derivations and
  9123. their dependencies, and prints the resulting store paths. Note that it
  9124. does not modify the user's profile---this is the job of the
  9125. @command{guix package} command (@pxref{Invoking guix package}). Thus,
  9126. it is mainly useful for distribution developers.
  9127. The general syntax is:
  9128. @example
  9129. guix build @var{options} @var{package-or-derivation}@dots{}
  9130. @end example
  9131. As an example, the following command builds the latest versions of Emacs
  9132. and of Guile, displays their build logs, and finally displays the
  9133. resulting directories:
  9134. @example
  9135. guix build emacs guile
  9136. @end example
  9137. Similarly, the following command builds all the available packages:
  9138. @example
  9139. guix build --quiet --keep-going \
  9140. $(guix package -A | awk '@{ print $1 "@@" $2 @}')
  9141. @end example
  9142. @var{package-or-derivation} may be either the name of a package found in
  9143. the software distribution such as @code{coreutils} or
  9144. @code{coreutils@@8.20}, or a derivation such as
  9145. @file{/gnu/store/@dots{}-coreutils-8.19.drv}. In the former case, a
  9146. package with the corresponding name (and optionally version) is searched
  9147. for among the GNU distribution modules (@pxref{Package Modules}).
  9148. Alternatively, the @option{--expression} option may be used to specify a
  9149. Scheme expression that evaluates to a package; this is useful when
  9150. disambiguating among several same-named packages or package variants is
  9151. needed.
  9152. There may be zero or more @var{options}. The available options are
  9153. described in the subsections below.
  9154. @menu
  9155. * Common Build Options:: Build options for most commands.
  9156. * Package Transformation Options:: Creating variants of packages.
  9157. * Additional Build Options:: Options specific to 'guix build'.
  9158. * Debugging Build Failures:: Real life packaging experience.
  9159. @end menu
  9160. @node Common Build Options
  9161. @subsection Common Build Options
  9162. A number of options that control the build process are common to
  9163. @command{guix build} and other commands that can spawn builds, such as
  9164. @command{guix package} or @command{guix archive}. These are the
  9165. following:
  9166. @table @code
  9167. @item --load-path=@var{directory}
  9168. @itemx -L @var{directory}
  9169. Add @var{directory} to the front of the package module search path
  9170. (@pxref{Package Modules}).
  9171. This allows users to define their own packages and make them visible to
  9172. the command-line tools.
  9173. @item --keep-failed
  9174. @itemx -K
  9175. Keep the build tree of failed builds. Thus, if a build fails, its build
  9176. tree is kept under @file{/tmp}, in a directory whose name is shown at
  9177. the end of the build log. This is useful when debugging build issues.
  9178. @xref{Debugging Build Failures}, for tips and tricks on how to debug
  9179. build issues.
  9180. This option implies @option{--no-offload}, and it has no effect when
  9181. connecting to a remote daemon with a @code{guix://} URI (@pxref{The
  9182. Store, the @env{GUIX_DAEMON_SOCKET} variable}).
  9183. @item --keep-going
  9184. @itemx -k
  9185. Keep going when some of the derivations fail to build; return only once
  9186. all the builds have either completed or failed.
  9187. The default behavior is to stop as soon as one of the specified
  9188. derivations has failed.
  9189. @item --dry-run
  9190. @itemx -n
  9191. Do not build the derivations.
  9192. @anchor{fallback-option}
  9193. @item --fallback
  9194. When substituting a pre-built binary fails, fall back to building
  9195. packages locally (@pxref{Substitution Failure}).
  9196. @item --substitute-urls=@var{urls}
  9197. @anchor{client-substitute-urls}
  9198. Consider @var{urls} the whitespace-separated list of substitute source
  9199. URLs, overriding the default list of URLs of @command{guix-daemon}
  9200. (@pxref{daemon-substitute-urls,, @command{guix-daemon} URLs}).
  9201. This means that substitutes may be downloaded from @var{urls}, provided
  9202. they are signed by a key authorized by the system administrator
  9203. (@pxref{Substitutes}).
  9204. When @var{urls} is the empty string, substitutes are effectively
  9205. disabled.
  9206. @item --no-substitutes
  9207. Do not use substitutes for build products. That is, always build things
  9208. locally instead of allowing downloads of pre-built binaries
  9209. (@pxref{Substitutes}).
  9210. @item --no-grafts
  9211. Do not ``graft'' packages. In practice, this means that package updates
  9212. available as grafts are not applied. @xref{Security Updates}, for more
  9213. information on grafts.
  9214. @item --rounds=@var{n}
  9215. Build each derivation @var{n} times in a row, and raise an error if
  9216. consecutive build results are not bit-for-bit identical.
  9217. This is a useful way to detect non-deterministic builds processes.
  9218. Non-deterministic build processes are a problem because they make it
  9219. practically impossible for users to @emph{verify} whether third-party
  9220. binaries are genuine. @xref{Invoking guix challenge}, for more.
  9221. When used in conjunction with @option{--keep-failed}, the differing
  9222. output is kept in the store, under @file{/gnu/store/@dots{}-check}.
  9223. This makes it easy to look for differences between the two results.
  9224. @item --no-offload
  9225. Do not use offload builds to other machines (@pxref{Daemon Offload
  9226. Setup}). That is, always build things locally instead of offloading
  9227. builds to remote machines.
  9228. @item --max-silent-time=@var{seconds}
  9229. When the build or substitution process remains silent for more than
  9230. @var{seconds}, terminate it and report a build failure.
  9231. By default, the daemon's setting is honored (@pxref{Invoking
  9232. guix-daemon, @option{--max-silent-time}}).
  9233. @item --timeout=@var{seconds}
  9234. Likewise, when the build or substitution process lasts for more than
  9235. @var{seconds}, terminate it and report a build failure.
  9236. By default, the daemon's setting is honored (@pxref{Invoking
  9237. guix-daemon, @option{--timeout}}).
  9238. @c Note: This option is actually not part of %standard-build-options but
  9239. @c most programs honor it.
  9240. @cindex verbosity, of the command-line tools
  9241. @cindex build logs, verbosity
  9242. @item -v @var{level}
  9243. @itemx --verbosity=@var{level}
  9244. Use the given verbosity @var{level}, an integer. Choosing 0 means that
  9245. no output is produced, 1 is for quiet output; 2 is similar to 1 but it
  9246. additionally displays download URLs; 3 shows all the build log output on
  9247. standard error.
  9248. @item --cores=@var{n}
  9249. @itemx -c @var{n}
  9250. Allow the use of up to @var{n} CPU cores for the build. The special
  9251. value @code{0} means to use as many CPU cores as available.
  9252. @item --max-jobs=@var{n}
  9253. @itemx -M @var{n}
  9254. Allow at most @var{n} build jobs in parallel. @xref{Invoking
  9255. guix-daemon, @option{--max-jobs}}, for details about this option and the
  9256. equivalent @command{guix-daemon} option.
  9257. @item --debug=@var{level}
  9258. Produce debugging output coming from the build daemon. @var{level} must be an
  9259. integer between 0 and 5; higher means more verbose output. Setting a level of
  9260. 4 or more may be helpful when debugging setup issues with the build daemon.
  9261. @end table
  9262. Behind the scenes, @command{guix build} is essentially an interface to
  9263. the @code{package-derivation} procedure of the @code{(guix packages)}
  9264. module, and to the @code{build-derivations} procedure of the @code{(guix
  9265. derivations)} module.
  9266. In addition to options explicitly passed on the command line,
  9267. @command{guix build} and other @command{guix} commands that support
  9268. building honor the @env{GUIX_BUILD_OPTIONS} environment variable.
  9269. @defvr {Environment Variable} GUIX_BUILD_OPTIONS
  9270. Users can define this variable to a list of command line options that
  9271. will automatically be used by @command{guix build} and other
  9272. @command{guix} commands that can perform builds, as in the example
  9273. below:
  9274. @example
  9275. $ export GUIX_BUILD_OPTIONS="--no-substitutes -c 2 -L /foo/bar"
  9276. @end example
  9277. These options are parsed independently, and the result is appended to
  9278. the parsed command-line options.
  9279. @end defvr
  9280. @node Package Transformation Options
  9281. @subsection Package Transformation Options
  9282. @cindex package variants
  9283. Another set of command-line options supported by @command{guix build}
  9284. and also @command{guix package} are @dfn{package transformation
  9285. options}. These are options that make it possible to define @dfn{package
  9286. variants}---for instance, packages built from different source code.
  9287. This is a convenient way to create customized packages on the fly
  9288. without having to type in the definitions of package variants
  9289. (@pxref{Defining Packages}).
  9290. Package transformation options are preserved across upgrades:
  9291. @command{guix upgrade} attempts to apply transformation options
  9292. initially used when creating the profile to the upgraded packages.
  9293. The available options are listed below. Most commands support them and
  9294. also support a @option{--help-transform} option that lists all the
  9295. available options and a synopsis (these options are not shown in the
  9296. @option{--help} output for brevity).
  9297. @table @code
  9298. @cindex performance, tuning code
  9299. @cindex optimization, of package code
  9300. @cindex tuning, of package code
  9301. @cindex SIMD support
  9302. @cindex tunable packages
  9303. @cindex package multi-versioning
  9304. @item --tune[=@var{cpu}]
  9305. Use versions of the packages marked as ``tunable'' optimized for
  9306. @var{cpu}. When @var{cpu} is @code{native}, or when it is omitted, tune
  9307. for the CPU on which the @command{guix} command is running.
  9308. Valid @var{cpu} names are those recognized by the underlying compiler,
  9309. by default the GNU Compiler Collection. On x86_64 processors, this
  9310. includes CPU names such as @code{nehalem}, @code{haswell}, and
  9311. @code{skylake} (@pxref{x86 Options, @code{-march},, gcc, Using the GNU
  9312. Compiler Collection (GCC)}).
  9313. As new generations of CPUs come out, they augment the standard
  9314. instruction set architecture (ISA) with additional instructions, in
  9315. particular instructions for single-instruction/multiple-data (SIMD)
  9316. parallel processing. For example, while Core2 and Skylake CPUs both
  9317. implement the x86_64 ISA, only the latter supports AVX2 SIMD
  9318. instructions.
  9319. The primary gain one can expect from @option{--tune} is for programs
  9320. that can make use of those SIMD capabilities @emph{and} that do not
  9321. already have a mechanism to select the right optimized code at run time.
  9322. Packages that have the @code{tunable?} property set are considered
  9323. @dfn{tunable packages} by the @option{--tune} option; a package
  9324. definition with the property set looks like this:
  9325. @lisp
  9326. (package
  9327. (name "hello-simd")
  9328. ;; ...
  9329. ;; This package may benefit from SIMD extensions so
  9330. ;; mark it as "tunable".
  9331. (properties '((tunable? . #t))))
  9332. @end lisp
  9333. Other packages are not considered tunable. This allows Guix to use
  9334. generic binaries in the cases where tuning for a specific CPU is
  9335. unlikely to provide any gain.
  9336. Tuned packages are built with @code{-march=@var{CPU}}; under the hood,
  9337. the @option{-march} option is passed to the actual wrapper by a compiler
  9338. wrapper. Since the build machine may not be able to run code for the
  9339. target CPU micro-architecture, the test suite is not run when building a
  9340. tuned package.
  9341. To reduce rebuilds to the minimum, tuned packages are @emph{grafted}
  9342. onto packages that depend on them (@pxref{Security Updates, grafts}).
  9343. Thus, using @option{--no-grafts} cancels the effect of @option{--tune}.
  9344. We call this technique @dfn{package multi-versioning}: several variants
  9345. of tunable packages may be built, one for each CPU variant. It is the
  9346. coarse-grain counterpart of @dfn{function multi-versioning} as
  9347. implemented by the GNU tool chain (@pxref{Function Multiversioning,,,
  9348. gcc, Using the GNU Compiler Collection (GCC)}).
  9349. @item --with-source=@var{source}
  9350. @itemx --with-source=@var{package}=@var{source}
  9351. @itemx --with-source=@var{package}@@@var{version}=@var{source}
  9352. Use @var{source} as the source of @var{package}, and @var{version} as
  9353. its version number.
  9354. @var{source} must be a file name or a URL, as for @command{guix
  9355. download} (@pxref{Invoking guix download}).
  9356. When @var{package} is omitted,
  9357. it is taken to be the package name specified on the
  9358. command line that matches the base of @var{source}---e.g.,
  9359. if @var{source} is @code{/src/guile-2.0.10.tar.gz}, the corresponding
  9360. package is @code{guile}.
  9361. Likewise, when @var{version} is omitted, the version string is inferred from
  9362. @var{source}; in the previous example, it is @code{2.0.10}.
  9363. This option allows users to try out versions of packages other than the
  9364. one provided by the distribution. The example below downloads
  9365. @file{ed-1.7.tar.gz} from a GNU mirror and uses that as the source for
  9366. the @code{ed} package:
  9367. @example
  9368. guix build ed --with-source=mirror://gnu/ed/ed-1.7.tar.gz
  9369. @end example
  9370. As a developer, @option{--with-source} makes it easy to test release
  9371. candidates:
  9372. @example
  9373. guix build guile --with-source=../guile-2.0.9.219-e1bb7.tar.xz
  9374. @end example
  9375. @dots{} or to build from a checkout in a pristine environment:
  9376. @example
  9377. $ git clone git://git.sv.gnu.org/guix.git
  9378. $ guix build guix --with-source=guix@@1.0=./guix
  9379. @end example
  9380. @item --with-input=@var{package}=@var{replacement}
  9381. Replace dependency on @var{package} by a dependency on
  9382. @var{replacement}. @var{package} must be a package name, and
  9383. @var{replacement} must be a package specification such as @code{guile}
  9384. or @code{guile@@1.8}.
  9385. For instance, the following command builds Guix, but replaces its
  9386. dependency on the current stable version of Guile with a dependency on
  9387. the legacy version of Guile, @code{guile@@2.0}:
  9388. @example
  9389. guix build --with-input=guile=guile@@2.0 guix
  9390. @end example
  9391. This is a recursive, deep replacement. So in this example, both
  9392. @code{guix} and its dependency @code{guile-json} (which also depends on
  9393. @code{guile}) get rebuilt against @code{guile@@2.0}.
  9394. This is implemented using the @code{package-input-rewriting} Scheme
  9395. procedure (@pxref{Defining Packages, @code{package-input-rewriting}}).
  9396. @item --with-graft=@var{package}=@var{replacement}
  9397. This is similar to @option{--with-input} but with an important difference:
  9398. instead of rebuilding the whole dependency chain, @var{replacement} is
  9399. built and then @dfn{grafted} onto the binaries that were initially
  9400. referring to @var{package}. @xref{Security Updates}, for more
  9401. information on grafts.
  9402. For example, the command below grafts version 3.5.4 of GnuTLS onto Wget
  9403. and all its dependencies, replacing references to the version of GnuTLS
  9404. they currently refer to:
  9405. @example
  9406. guix build --with-graft=gnutls=gnutls@@3.5.4 wget
  9407. @end example
  9408. This has the advantage of being much faster than rebuilding everything.
  9409. But there is a caveat: it works if and only if @var{package} and
  9410. @var{replacement} are strictly compatible---for example, if they provide
  9411. a library, the application binary interface (ABI) of those libraries
  9412. must be compatible. If @var{replacement} is somehow incompatible with
  9413. @var{package}, then the resulting package may be unusable. Use with
  9414. care!
  9415. @cindex debugging info, rebuilding
  9416. @item --with-debug-info=@var{package}
  9417. Build @var{package} in a way that preserves its debugging info and graft
  9418. it onto packages that depend on it. This is useful if @var{package}
  9419. does not already provide debugging info as a @code{debug} output
  9420. (@pxref{Installing Debugging Files}).
  9421. For example, suppose you're experiencing a crash in Inkscape and would
  9422. like to see what's up in GLib, a library deep down in Inkscape's
  9423. dependency graph. GLib lacks a @code{debug} output, so debugging is
  9424. tough. Fortunately, you rebuild GLib with debugging info and tack it on
  9425. Inkscape:
  9426. @example
  9427. guix install inkscape --with-debug-info=glib
  9428. @end example
  9429. Only GLib needs to be recompiled so this takes a reasonable amount of
  9430. time. @xref{Installing Debugging Files}, for more info.
  9431. @quotation Note
  9432. Under the hood, this option works by passing the @samp{#:strip-binaries?
  9433. #f} to the build system of the package of interest (@pxref{Build
  9434. Systems}). Most build systems support that option but some do not. In
  9435. that case, an error is raised.
  9436. Likewise, if a C/C++ package is built without @code{-g} (which is rarely
  9437. the case), debugging info will remain unavailable even when
  9438. @code{#:strip-binaries?} is false.
  9439. @end quotation
  9440. @cindex tool chain, changing the build tool chain of a package
  9441. @item --with-c-toolchain=@var{package}=@var{toolchain}
  9442. This option changes the compilation of @var{package} and everything that
  9443. depends on it so that they get built with @var{toolchain} instead of the
  9444. default GNU tool chain for C/C++.
  9445. Consider this example:
  9446. @example
  9447. guix build octave-cli \
  9448. --with-c-toolchain=fftw=gcc-toolchain@@10 \
  9449. --with-c-toolchain=fftwf=gcc-toolchain@@10
  9450. @end example
  9451. The command above builds a variant of the @code{fftw} and @code{fftwf}
  9452. packages using version 10 of @code{gcc-toolchain} instead of the default
  9453. tool chain, and then builds a variant of the GNU@tie{}Octave
  9454. command-line interface using them. GNU@tie{}Octave itself is also built
  9455. with @code{gcc-toolchain@@10}.
  9456. This other example builds the Hardware Locality (@code{hwloc}) library
  9457. and its dependents up to @code{intel-mpi-benchmarks} with the Clang C
  9458. compiler:
  9459. @example
  9460. guix build --with-c-toolchain=hwloc=clang-toolchain \
  9461. intel-mpi-benchmarks
  9462. @end example
  9463. @quotation Note
  9464. There can be application binary interface (ABI) incompatibilities among
  9465. tool chains. This is particularly true of the C++ standard library and
  9466. run-time support libraries such as that of OpenMP@. By rebuilding all
  9467. dependents with the same tool chain, @option{--with-c-toolchain} minimizes
  9468. the risks of incompatibility but cannot entirely eliminate them. Choose
  9469. @var{package} wisely.
  9470. @end quotation
  9471. @item --with-git-url=@var{package}=@var{url}
  9472. @cindex Git, using the latest commit
  9473. @cindex latest commit, building
  9474. Build @var{package} from the latest commit of the @code{master} branch of the
  9475. Git repository at @var{url}. Git sub-modules of the repository are fetched,
  9476. recursively.
  9477. For example, the following command builds the NumPy Python library against the
  9478. latest commit of the master branch of Python itself:
  9479. @example
  9480. guix build python-numpy \
  9481. --with-git-url=python=https://github.com/python/cpython
  9482. @end example
  9483. This option can also be combined with @option{--with-branch} or
  9484. @option{--with-commit} (see below).
  9485. @cindex continuous integration
  9486. Obviously, since it uses the latest commit of the given branch, the result of
  9487. such a command varies over time. Nevertheless it is a convenient way to
  9488. rebuild entire software stacks against the latest commit of one or more
  9489. packages. This is particularly useful in the context of continuous
  9490. integration (CI).
  9491. Checkouts are kept in a cache under @file{~/.cache/guix/checkouts} to speed up
  9492. consecutive accesses to the same repository. You may want to clean it up once
  9493. in a while to save disk space.
  9494. @item --with-branch=@var{package}=@var{branch}
  9495. Build @var{package} from the latest commit of @var{branch}. If the
  9496. @code{source} field of @var{package} is an origin with the @code{git-fetch}
  9497. method (@pxref{origin Reference}) or a @code{git-checkout} object, the
  9498. repository URL is taken from that @code{source}. Otherwise you have to use
  9499. @option{--with-git-url} to specify the URL of the Git repository.
  9500. For instance, the following command builds @code{guile-sqlite3} from the
  9501. latest commit of its @code{master} branch, and then builds @code{guix} (which
  9502. depends on it) and @code{cuirass} (which depends on @code{guix}) against this
  9503. specific @code{guile-sqlite3} build:
  9504. @example
  9505. guix build --with-branch=guile-sqlite3=master cuirass
  9506. @end example
  9507. @item --with-commit=@var{package}=@var{commit}
  9508. This is similar to @option{--with-branch}, except that it builds from
  9509. @var{commit} rather than the tip of a branch. @var{commit} must be a valid
  9510. Git commit SHA1 identifier, a tag, or a @command{git describe} style
  9511. identifier such as @code{1.0-3-gabc123}.
  9512. @item --with-patch=@var{package}=@var{file}
  9513. Add @var{file} to the list of patches applied to @var{package}, where
  9514. @var{package} is a spec such as @code{python@@3.8} or @code{glibc}.
  9515. @var{file} must contain a patch; it is applied with the flags specified
  9516. in the @code{origin} of @var{package} (@pxref{origin Reference}), which
  9517. by default includes @code{-p1} (@pxref{patch Directories,,, diffutils,
  9518. Comparing and Merging Files}).
  9519. As an example, the command below rebuilds Coreutils with the GNU C
  9520. Library (glibc) patched with the given patch:
  9521. @example
  9522. guix build coreutils --with-patch=glibc=./glibc-frob.patch
  9523. @end example
  9524. In this example, glibc itself as well as everything that leads to
  9525. Coreutils in the dependency graph is rebuilt.
  9526. @cindex upstream, latest version
  9527. @item --with-latest=@var{package}
  9528. So you like living on the bleeding edge? This option is for you! It
  9529. replaces occurrences of @var{package} in the dependency graph with its
  9530. latest upstream version, as reported by @command{guix refresh}
  9531. (@pxref{Invoking guix refresh}).
  9532. It does so by determining the latest upstream release of @var{package}
  9533. (if possible), downloading it, and authenticating it @emph{if} it comes
  9534. with an OpenPGP signature.
  9535. As an example, the command below builds Guix against the latest version
  9536. of Guile-JSON:
  9537. @example
  9538. guix build guix --with-latest=guile-json
  9539. @end example
  9540. There are limitations. First, in cases where the tool cannot or does
  9541. not know how to authenticate source code, you are at risk of running
  9542. malicious code; a warning is emitted in this case. Second, this option
  9543. simply changes the source used in the existing package definitions,
  9544. which is not always sufficient: there might be additional dependencies
  9545. that need to be added, patches to apply, and more generally the quality
  9546. assurance work that Guix developers normally do will be missing.
  9547. You've been warned! In all the other cases, it's a snappy way to stay
  9548. on top. We encourage you to submit patches updating the actual package
  9549. definitions once you have successfully tested an upgrade
  9550. (@pxref{Contributing}).
  9551. @cindex test suite, skipping
  9552. @item --without-tests=@var{package}
  9553. Build @var{package} without running its tests. This can be useful in
  9554. situations where you want to skip the lengthy test suite of a
  9555. intermediate package, or if a package's test suite fails in a
  9556. non-deterministic fashion. It should be used with care because running
  9557. the test suite is a good way to ensure a package is working as intended.
  9558. Turning off tests leads to a different store item. Consequently, when
  9559. using this option, anything that depends on @var{package} must be
  9560. rebuilt, as in this example:
  9561. @example
  9562. guix install --without-tests=python python-notebook
  9563. @end example
  9564. The command above installs @code{python-notebook} on top of
  9565. @code{python} built without running its test suite. To do so, it also
  9566. rebuilds everything that depends on @code{python}, including
  9567. @code{python-notebook} itself.
  9568. Internally, @option{--without-tests} relies on changing the
  9569. @code{#:tests?} option of a package's @code{check} phase (@pxref{Build
  9570. Systems}). Note that some packages use a customized @code{check} phase
  9571. that does not respect a @code{#:tests? #f} setting. Therefore,
  9572. @option{--without-tests} has no effect on these packages.
  9573. @end table
  9574. Wondering how to achieve the same effect using Scheme code, for example
  9575. in your manifest, or how to write your own package transformation?
  9576. @xref{Defining Package Variants}, for an overview of the programming
  9577. interfaces available.
  9578. @node Additional Build Options
  9579. @subsection Additional Build Options
  9580. The command-line options presented below are specific to @command{guix
  9581. build}.
  9582. @table @code
  9583. @item --quiet
  9584. @itemx -q
  9585. Build quietly, without displaying the build log; this is equivalent to
  9586. @option{--verbosity=0}. Upon completion, the build log is kept in @file{/var}
  9587. (or similar) and can always be retrieved using the @option{--log-file} option.
  9588. @item --file=@var{file}
  9589. @itemx -f @var{file}
  9590. Build the package, derivation, or other file-like object that the code within
  9591. @var{file} evaluates to (@pxref{G-Expressions, file-like objects}).
  9592. As an example, @var{file} might contain a package definition like this
  9593. (@pxref{Defining Packages}):
  9594. @lisp
  9595. @include package-hello.scm
  9596. @end lisp
  9597. The @var{file} may also contain a JSON representation of one or more
  9598. package definitions. Running @code{guix build -f} on @file{hello.json}
  9599. with the following contents would result in building the packages
  9600. @code{myhello} and @code{greeter}:
  9601. @example
  9602. @verbatiminclude package-hello.json
  9603. @end example
  9604. @item --manifest=@var{manifest}
  9605. @itemx -m @var{manifest}
  9606. Build all packages listed in the given @var{manifest}
  9607. (@pxref{profile-manifest, @option{--manifest}}).
  9608. @item --expression=@var{expr}
  9609. @itemx -e @var{expr}
  9610. Build the package or derivation @var{expr} evaluates to.
  9611. For example, @var{expr} may be @code{(@@ (gnu packages guile)
  9612. guile-1.8)}, which unambiguously designates this specific variant of
  9613. version 1.8 of Guile.
  9614. Alternatively, @var{expr} may be a G-expression, in which case it is used
  9615. as a build program passed to @code{gexp->derivation}
  9616. (@pxref{G-Expressions}).
  9617. Lastly, @var{expr} may refer to a zero-argument monadic procedure
  9618. (@pxref{The Store Monad}). The procedure must return a derivation as a
  9619. monadic value, which is then passed through @code{run-with-store}.
  9620. @item --source
  9621. @itemx -S
  9622. Build the source derivations of the packages, rather than the packages
  9623. themselves.
  9624. For instance, @code{guix build -S gcc} returns something like
  9625. @file{/gnu/store/@dots{}-gcc-4.7.2.tar.bz2}, which is the GCC
  9626. source tarball.
  9627. The returned source tarball is the result of applying any patches and
  9628. code snippets specified in the package @code{origin} (@pxref{Defining
  9629. Packages}).
  9630. @cindex source, verification
  9631. As with other derivations, the result of building a source derivation
  9632. can be verified using the @option{--check} option (@pxref{build-check}).
  9633. This is useful to validate that a (potentially already built or
  9634. substituted, thus cached) package source matches against its declared
  9635. hash.
  9636. Note that @command{guix build -S} compiles the sources only of the
  9637. specified packages. They do not include the sources of statically
  9638. linked dependencies and by themselves are insufficient for reproducing
  9639. the packages.
  9640. @item --sources
  9641. Fetch and return the source of @var{package-or-derivation} and all their
  9642. dependencies, recursively. This is a handy way to obtain a local copy
  9643. of all the source code needed to build @var{packages}, allowing you to
  9644. eventually build them even without network access. It is an extension
  9645. of the @option{--source} option and can accept one of the following
  9646. optional argument values:
  9647. @table @code
  9648. @item package
  9649. This value causes the @option{--sources} option to behave in the same way
  9650. as the @option{--source} option.
  9651. @item all
  9652. Build the source derivations of all packages, including any source that
  9653. might be listed as @code{inputs}. This is the default value.
  9654. @example
  9655. $ guix build --sources tzdata
  9656. The following derivations will be built:
  9657. /gnu/store/@dots{}-tzdata2015b.tar.gz.drv
  9658. /gnu/store/@dots{}-tzcode2015b.tar.gz.drv
  9659. @end example
  9660. @item transitive
  9661. Build the source derivations of all packages, as well of all transitive
  9662. inputs to the packages. This can be used e.g.@: to
  9663. prefetch package source for later offline building.
  9664. @example
  9665. $ guix build --sources=transitive tzdata
  9666. The following derivations will be built:
  9667. /gnu/store/@dots{}-tzcode2015b.tar.gz.drv
  9668. /gnu/store/@dots{}-findutils-4.4.2.tar.xz.drv
  9669. /gnu/store/@dots{}-grep-2.21.tar.xz.drv
  9670. /gnu/store/@dots{}-coreutils-8.23.tar.xz.drv
  9671. /gnu/store/@dots{}-make-4.1.tar.xz.drv
  9672. /gnu/store/@dots{}-bash-4.3.tar.xz.drv
  9673. @dots{}
  9674. @end example
  9675. @end table
  9676. @item --system=@var{system}
  9677. @itemx -s @var{system}
  9678. Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
  9679. the system type of the build host. The @command{guix build} command allows
  9680. you to repeat this option several times, in which case it builds for all the
  9681. specified systems; other commands ignore extraneous @option{-s} options.
  9682. @quotation Note
  9683. The @option{--system} flag is for @emph{native} compilation and must not
  9684. be confused with cross-compilation. See @option{--target} below for
  9685. information on cross-compilation.
  9686. @end quotation
  9687. An example use of this is on Linux-based systems, which can emulate
  9688. different personalities. For instance, passing
  9689. @option{--system=i686-linux} on an @code{x86_64-linux} system or
  9690. @option{--system=armhf-linux} on an @code{aarch64-linux} system allows
  9691. you to build packages in a complete 32-bit environment.
  9692. @quotation Note
  9693. Building for an @code{armhf-linux} system is unconditionally enabled on
  9694. @code{aarch64-linux} machines, although certain aarch64 chipsets do not
  9695. allow for this functionality, notably the ThunderX.
  9696. @end quotation
  9697. Similarly, when transparent emulation with QEMU and @code{binfmt_misc}
  9698. is enabled (@pxref{Virtualization Services,
  9699. @code{qemu-binfmt-service-type}}), you can build for any system for
  9700. which a QEMU @code{binfmt_misc} handler is installed.
  9701. Builds for a system other than that of the machine you are using can
  9702. also be offloaded to a remote machine of the right architecture.
  9703. @xref{Daemon Offload Setup}, for more information on offloading.
  9704. @item --target=@var{triplet}
  9705. @cindex cross-compilation
  9706. Cross-build for @var{triplet}, which must be a valid GNU triplet, such
  9707. as @code{"aarch64-linux-gnu"} (@pxref{Specifying Target Triplets, GNU
  9708. configuration triplets,, autoconf, Autoconf}).
  9709. @anchor{build-check}
  9710. @item --check
  9711. @cindex determinism, checking
  9712. @cindex reproducibility, checking
  9713. Rebuild @var{package-or-derivation}, which are already available in the
  9714. store, and raise an error if the build results are not bit-for-bit
  9715. identical.
  9716. This mechanism allows you to check whether previously installed
  9717. substitutes are genuine (@pxref{Substitutes}), or whether the build result
  9718. of a package is deterministic. @xref{Invoking guix challenge}, for more
  9719. background information and tools.
  9720. When used in conjunction with @option{--keep-failed}, the differing
  9721. output is kept in the store, under @file{/gnu/store/@dots{}-check}.
  9722. This makes it easy to look for differences between the two results.
  9723. @item --repair
  9724. @cindex repairing store items
  9725. @cindex corruption, recovering from
  9726. Attempt to repair the specified store items, if they are corrupt, by
  9727. re-downloading or rebuilding them.
  9728. This operation is not atomic and thus restricted to @code{root}.
  9729. @item --derivations
  9730. @itemx -d
  9731. Return the derivation paths, not the output paths, of the given
  9732. packages.
  9733. @item --root=@var{file}
  9734. @itemx -r @var{file}
  9735. @cindex GC roots, adding
  9736. @cindex garbage collector roots, adding
  9737. Make @var{file} a symlink to the result, and register it as a garbage
  9738. collector root.
  9739. Consequently, the results of this @command{guix build} invocation are
  9740. protected from garbage collection until @var{file} is removed. When
  9741. that option is omitted, build results are eligible for garbage
  9742. collection as soon as the build completes. @xref{Invoking guix gc}, for
  9743. more on GC roots.
  9744. @item --log-file
  9745. @cindex build logs, access
  9746. Return the build log file names or URLs for the given
  9747. @var{package-or-derivation}, or raise an error if build logs are
  9748. missing.
  9749. This works regardless of how packages or derivations are specified. For
  9750. instance, the following invocations are equivalent:
  9751. @example
  9752. guix build --log-file $(guix build -d guile)
  9753. guix build --log-file $(guix build guile)
  9754. guix build --log-file guile
  9755. guix build --log-file -e '(@@ (gnu packages guile) guile-2.0)'
  9756. @end example
  9757. If a log is unavailable locally, and unless @option{--no-substitutes} is
  9758. passed, the command looks for a corresponding log on one of the
  9759. substitute servers (as specified with @option{--substitute-urls}).
  9760. So for instance, imagine you want to see the build log of GDB on MIPS,
  9761. but you are actually on an @code{x86_64} machine:
  9762. @example
  9763. $ guix build --log-file gdb -s aarch64-linux
  9764. https://@value{SUBSTITUTE-SERVER-1}/log/@dots{}-gdb-7.10
  9765. @end example
  9766. You can freely access a huge library of build logs!
  9767. @end table
  9768. @node Debugging Build Failures
  9769. @subsection Debugging Build Failures
  9770. @cindex build failures, debugging
  9771. When defining a new package (@pxref{Defining Packages}), you will
  9772. probably find yourself spending some time debugging and tweaking the
  9773. build until it succeeds. To do that, you need to operate the build
  9774. commands yourself in an environment as close as possible to the one the
  9775. build daemon uses.
  9776. To that end, the first thing to do is to use the @option{--keep-failed}
  9777. or @option{-K} option of @command{guix build}, which will keep the
  9778. failed build tree in @file{/tmp} or whatever directory you specified as
  9779. @env{TMPDIR} (@pxref{Common Build Options, @option{--keep-failed}}).
  9780. From there on, you can @command{cd} to the failed build tree and source
  9781. the @file{environment-variables} file, which contains all the
  9782. environment variable definitions that were in place when the build
  9783. failed. So let's say you're debugging a build failure in package
  9784. @code{foo}; a typical session would look like this:
  9785. @example
  9786. $ guix build foo -K
  9787. @dots{} @i{build fails}
  9788. $ cd /tmp/guix-build-foo.drv-0
  9789. $ source ./environment-variables
  9790. $ cd foo-1.2
  9791. @end example
  9792. Now, you can invoke commands as if you were the daemon (almost) and
  9793. troubleshoot your build process.
  9794. Sometimes it happens that, for example, a package's tests pass when you
  9795. run them manually but they fail when the daemon runs them. This can
  9796. happen because the daemon runs builds in containers where, unlike in our
  9797. environment above, network access is missing, @file{/bin/sh} does not
  9798. exist, etc. (@pxref{Build Environment Setup}).
  9799. In such cases, you may need to run inspect the build process from within
  9800. a container similar to the one the build daemon creates:
  9801. @example
  9802. $ guix build -K foo
  9803. @dots{}
  9804. $ cd /tmp/guix-build-foo.drv-0
  9805. $ guix shell --no-grafts -C -D foo strace gdb
  9806. [env]# source ./environment-variables
  9807. [env]# cd foo-1.2
  9808. @end example
  9809. Here, @command{guix shell -C} creates a container and spawns a new
  9810. shell in it (@pxref{Invoking guix shell}). The @command{strace gdb}
  9811. part adds the @command{strace} and @command{gdb} commands to
  9812. the container, which you may find handy while debugging. The
  9813. @option{--no-grafts} option makes sure we get the exact same
  9814. environment, with ungrafted packages (@pxref{Security Updates}, for more
  9815. info on grafts).
  9816. To get closer to a container like that used by the build daemon, we can
  9817. remove @file{/bin/sh}:
  9818. @example
  9819. [env]# rm /bin/sh
  9820. @end example
  9821. (Don't worry, this is harmless: this is all happening in the throw-away
  9822. container created by @command{guix shell}.)
  9823. The @command{strace} command is probably not in the search path, but we
  9824. can run:
  9825. @example
  9826. [env]# $GUIX_ENVIRONMENT/bin/strace -f -o log make check
  9827. @end example
  9828. In this way, not only you will have reproduced the environment variables
  9829. the daemon uses, you will also be running the build process in a container
  9830. similar to the one the daemon uses.
  9831. @node Invoking guix edit
  9832. @section Invoking @command{guix edit}
  9833. @cindex @command{guix edit}
  9834. @cindex package definition, editing
  9835. So many packages, so many source files! The @command{guix edit} command
  9836. facilitates the life of users and packagers by pointing their editor at
  9837. the source file containing the definition of the specified packages.
  9838. For instance:
  9839. @example
  9840. guix edit gcc@@4.9 vim
  9841. @end example
  9842. @noindent
  9843. launches the program specified in the @env{VISUAL} or in the
  9844. @env{EDITOR} environment variable to view the recipe of GCC@tie{}4.9.3
  9845. and that of Vim.
  9846. If you are using a Guix Git checkout (@pxref{Building from Git}), or
  9847. have created your own packages on @env{GUIX_PACKAGE_PATH}
  9848. (@pxref{Package Modules}), you will be able to edit the package
  9849. recipes. In other cases, you will be able to examine the read-only recipes
  9850. for packages currently in the store.
  9851. Instead of @env{GUIX_PACKAGE_PATH}, the command-line option
  9852. @option{--load-path=@var{directory}} (or in short @option{-L
  9853. @var{directory}}) allows you to add @var{directory} to the front of the
  9854. package module search path and so make your own packages visible.
  9855. @node Invoking guix download
  9856. @section Invoking @command{guix download}
  9857. @cindex @command{guix download}
  9858. @cindex downloading package sources
  9859. When writing a package definition, developers typically need to download
  9860. a source tarball, compute its SHA256 hash, and write that
  9861. hash in the package definition (@pxref{Defining Packages}). The
  9862. @command{guix download} tool helps with this task: it downloads a file
  9863. from the given URI, adds it to the store, and prints both its file name
  9864. in the store and its SHA256 hash.
  9865. The fact that the downloaded file is added to the store saves bandwidth:
  9866. when the developer eventually tries to build the newly defined package
  9867. with @command{guix build}, the source tarball will not have to be
  9868. downloaded again because it is already in the store. It is also a
  9869. convenient way to temporarily stash files, which may be deleted
  9870. eventually (@pxref{Invoking guix gc}).
  9871. The @command{guix download} command supports the same URIs as used in
  9872. package definitions. In particular, it supports @code{mirror://} URIs.
  9873. @code{https} URIs (HTTP over TLS) are supported @emph{provided} the
  9874. Guile bindings for GnuTLS are available in the user's environment; when
  9875. they are not available, an error is raised. @xref{Guile Preparations,
  9876. how to install the GnuTLS bindings for Guile,, gnutls-guile,
  9877. GnuTLS-Guile}, for more information.
  9878. @command{guix download} verifies HTTPS server certificates by loading
  9879. the certificates of X.509 authorities from the directory pointed to by
  9880. the @env{SSL_CERT_DIR} environment variable (@pxref{X.509
  9881. Certificates}), unless @option{--no-check-certificate} is used.
  9882. The following options are available:
  9883. @table @code
  9884. @item --hash=@var{algorithm}
  9885. @itemx -H @var{algorithm}
  9886. Compute a hash using the specified @var{algorithm}. @xref{Invoking guix
  9887. hash}, for more information.
  9888. @item --format=@var{fmt}
  9889. @itemx -f @var{fmt}
  9890. Write the hash in the format specified by @var{fmt}. For more
  9891. information on the valid values for @var{fmt}, @pxref{Invoking guix hash}.
  9892. @item --no-check-certificate
  9893. Do not validate the X.509 certificates of HTTPS servers.
  9894. When using this option, you have @emph{absolutely no guarantee} that you
  9895. are communicating with the authentic server responsible for the given
  9896. URL, which makes you vulnerable to ``man-in-the-middle'' attacks.
  9897. @item --output=@var{file}
  9898. @itemx -o @var{file}
  9899. Save the downloaded file to @var{file} instead of adding it to the
  9900. store.
  9901. @end table
  9902. @node Invoking guix hash
  9903. @section Invoking @command{guix hash}
  9904. @cindex @command{guix hash}
  9905. The @command{guix hash} command computes the hash of a file.
  9906. It is primarily a convenience tool for anyone contributing to the
  9907. distribution: it computes the cryptographic hash of one or more files, which can be
  9908. used in the definition of a package (@pxref{Defining Packages}).
  9909. The general syntax is:
  9910. @example
  9911. guix hash @var{option} @var{file} ...
  9912. @end example
  9913. When @var{file} is @code{-} (a hyphen), @command{guix hash} computes the
  9914. hash of data read from standard input. @command{guix hash} has the
  9915. following options:
  9916. @table @code
  9917. @item --hash=@var{algorithm}
  9918. @itemx -H @var{algorithm}
  9919. Compute a hash using the specified @var{algorithm}, @code{sha256} by
  9920. default.
  9921. @var{algorithm} must be the name of a cryptographic hash algorithm
  9922. supported by Libgcrypt @i{via} Guile-Gcrypt---e.g., @code{sha512} or
  9923. @code{sha3-256} (@pxref{Hash Functions,,, guile-gcrypt, Guile-Gcrypt
  9924. Reference Manual}).
  9925. @item --format=@var{fmt}
  9926. @itemx -f @var{fmt}
  9927. Write the hash in the format specified by @var{fmt}.
  9928. Supported formats: @code{base64}, @code{nix-base32}, @code{base32}, @code{base16}
  9929. (@code{hex} and @code{hexadecimal} can be used as well).
  9930. If the @option{--format} option is not specified, @command{guix hash}
  9931. will output the hash in @code{nix-base32}. This representation is used
  9932. in the definitions of packages.
  9933. @item --recursive
  9934. @itemx -r
  9935. The @option{--recursive} option is deprecated in favor of
  9936. @option{--serializer=nar} (see below); @option{-r} remains accepted as a
  9937. convenient shorthand.
  9938. @item --serializer=@var{type}
  9939. @itemx -S @var{type}
  9940. Compute the hash on @var{file} using @var{type} serialization.
  9941. @var{type} may be one of the following:
  9942. @table @code
  9943. @item none
  9944. This is the default: it computes the hash of a file's contents.
  9945. @item nar
  9946. Compute the hash of a ``normalized archive'' (or ``nar'') containing
  9947. @var{file}, including its children if it is a directory. Some of the
  9948. metadata of @var{file} is part of the archive; for instance, when
  9949. @var{file} is a regular file, the hash is different depending on whether
  9950. @var{file} is executable or not. Metadata such as time stamps have no
  9951. impact on the hash (@pxref{Invoking guix archive}, for more info on the
  9952. nar format).
  9953. @c FIXME: Replace xref above with xref to an ``Archive'' section when
  9954. @c it exists.
  9955. @item git
  9956. Compute the hash of the file or directory as a Git ``tree'', following
  9957. the same method as the Git version control system.
  9958. @end table
  9959. @item --exclude-vcs
  9960. @itemx -x
  9961. When combined with @option{--recursive}, exclude version control system
  9962. directories (@file{.bzr}, @file{.git}, @file{.hg}, etc.).
  9963. @vindex git-fetch
  9964. As an example, here is how you would compute the hash of a Git checkout,
  9965. which is useful when using the @code{git-fetch} method (@pxref{origin
  9966. Reference}):
  9967. @example
  9968. $ git clone http://example.org/foo.git
  9969. $ cd foo
  9970. $ guix hash -x --serializer=nar .
  9971. @end example
  9972. @end table
  9973. @node Invoking guix import
  9974. @section Invoking @command{guix import}
  9975. @cindex importing packages
  9976. @cindex package import
  9977. @cindex package conversion
  9978. @cindex Invoking @command{guix import}
  9979. The @command{guix import} command is useful for people who would like to
  9980. add a package to the distribution with as little work as
  9981. possible---a legitimate demand. The command knows of a few
  9982. repositories from which it can ``import'' package metadata. The result
  9983. is a package definition, or a template thereof, in the format we know
  9984. (@pxref{Defining Packages}).
  9985. The general syntax is:
  9986. @example
  9987. guix import @var{importer} @var{options}@dots{}
  9988. @end example
  9989. @var{importer} specifies the source from which to import package
  9990. metadata, and @var{options} specifies a package identifier and other
  9991. options specific to @var{importer}.
  9992. Some of the importers rely on the ability to run the @command{gpgv} command.
  9993. For these, GnuPG must be installed and in @code{$PATH}; run @code{guix install
  9994. gnupg} if needed.
  9995. Currently, the available ``importers'' are:
  9996. @table @code
  9997. @item gnu
  9998. Import metadata for the given GNU package. This provides a template
  9999. for the latest version of that GNU package, including the hash of its
  10000. source tarball, and its canonical synopsis and description.
  10001. Additional information such as the package dependencies and its
  10002. license needs to be figured out manually.
  10003. For example, the following command returns a package definition for
  10004. GNU@tie{}Hello:
  10005. @example
  10006. guix import gnu hello
  10007. @end example
  10008. Specific command-line options are:
  10009. @table @code
  10010. @item --key-download=@var{policy}
  10011. As for @command{guix refresh}, specify the policy to handle missing
  10012. OpenPGP keys when verifying the package signature. @xref{Invoking guix
  10013. refresh, @option{--key-download}}.
  10014. @end table
  10015. @item pypi
  10016. @cindex pypi
  10017. Import metadata from the @uref{https://pypi.python.org/, Python Package
  10018. Index}. Information is taken from the JSON-formatted description
  10019. available at @code{pypi.python.org} and usually includes all the relevant
  10020. information, including package dependencies. For maximum efficiency, it
  10021. is recommended to install the @command{unzip} utility, so that the
  10022. importer can unzip Python wheels and gather data from them.
  10023. The command below imports metadata for the latest version of the
  10024. @code{itsdangerous} Python package:
  10025. @example
  10026. guix import pypi itsdangerous
  10027. @end example
  10028. You can also ask for a specific version:
  10029. @example
  10030. guix import pypi itsdangerous@@1.1.0
  10031. @end example
  10032. @table @code
  10033. @item --recursive
  10034. @itemx -r
  10035. Traverse the dependency graph of the given upstream package recursively
  10036. and generate package expressions for all those packages that are not yet
  10037. in Guix.
  10038. @end table
  10039. @item gem
  10040. @cindex gem
  10041. Import metadata from @uref{https://rubygems.org/, RubyGems}. Information
  10042. is taken from the JSON-formatted description available at
  10043. @code{rubygems.org} and includes most relevant information, including
  10044. runtime dependencies. There are some caveats, however. The metadata
  10045. doesn't distinguish between synopses and descriptions, so the same string
  10046. is used for both fields. Additionally, the details of non-Ruby
  10047. dependencies required to build native extensions is unavailable and left
  10048. as an exercise to the packager.
  10049. The command below imports metadata for the @code{rails} Ruby package:
  10050. @example
  10051. guix import gem rails
  10052. @end example
  10053. @table @code
  10054. @item --recursive
  10055. @itemx -r
  10056. Traverse the dependency graph of the given upstream package recursively
  10057. and generate package expressions for all those packages that are not yet
  10058. in Guix.
  10059. @end table
  10060. @item minetest
  10061. @cindex minetest
  10062. @cindex ContentDB
  10063. Import metadata from @uref{https://content.minetest.net, ContentDB}.
  10064. Information is taken from the JSON-formatted metadata provided through
  10065. @uref{https://content.minetest.net/help/api/, ContentDB's API} and
  10066. includes most relevant information, including dependencies. There are
  10067. some caveats, however. The license information is often incomplete.
  10068. The commit hash is sometimes missing. The descriptions are in the
  10069. Markdown format, but Guix uses Texinfo instead. Texture packs and
  10070. subgames are unsupported.
  10071. The command below imports metadata for the Mesecons mod by Jeija:
  10072. @example
  10073. guix import minetest Jeija/mesecons
  10074. @end example
  10075. The author name can also be left out:
  10076. @example
  10077. guix import minetest mesecons
  10078. @end example
  10079. @table @code
  10080. @item --recursive
  10081. @itemx -r
  10082. Traverse the dependency graph of the given upstream package recursively
  10083. and generate package expressions for all those packages that are not yet
  10084. in Guix.
  10085. @end table
  10086. @item cpan
  10087. @cindex CPAN
  10088. Import metadata from @uref{https://www.metacpan.org/, MetaCPAN}.
  10089. Information is taken from the JSON-formatted metadata provided through
  10090. @uref{https://fastapi.metacpan.org/, MetaCPAN's API} and includes most
  10091. relevant information, such as module dependencies. License information
  10092. should be checked closely. If Perl is available in the store, then the
  10093. @code{corelist} utility will be used to filter core modules out of the
  10094. list of dependencies.
  10095. The command command below imports metadata for the Acme::Boolean Perl
  10096. module:
  10097. @example
  10098. guix import cpan Acme::Boolean
  10099. @end example
  10100. @item cran
  10101. @cindex CRAN
  10102. @cindex Bioconductor
  10103. Import metadata from @uref{https://cran.r-project.org/, CRAN}, the
  10104. central repository for the @uref{https://r-project.org, GNU@tie{}R
  10105. statistical and graphical environment}.
  10106. Information is extracted from the @file{DESCRIPTION} file of the package.
  10107. The command command below imports metadata for the Cairo R package:
  10108. @example
  10109. guix import cran Cairo
  10110. @end example
  10111. You can also ask for a specific version:
  10112. @example
  10113. guix import cran rasterVis@@0.50.3
  10114. @end example
  10115. When @option{--recursive} is added, the importer will traverse the
  10116. dependency graph of the given upstream package recursively and generate
  10117. package expressions for all those packages that are not yet in Guix.
  10118. When @option{--style=specification} is added, the importer will generate
  10119. package definitions whose inputs are package specifications instead of
  10120. references to package variables. This is useful when generated package
  10121. definitions are to be appended to existing user modules, as the list of
  10122. used package modules need not be changed. The default is
  10123. @option{--style=variable}.
  10124. When @option{--archive=bioconductor} is added, metadata is imported from
  10125. @uref{https://www.bioconductor.org/, Bioconductor}, a repository of R
  10126. packages for the analysis and comprehension of high-throughput
  10127. genomic data in bioinformatics.
  10128. Information is extracted from the @file{DESCRIPTION} file contained in the
  10129. package archive.
  10130. The command below imports metadata for the GenomicRanges R package:
  10131. @example
  10132. guix import cran --archive=bioconductor GenomicRanges
  10133. @end example
  10134. Finally, you can also import R packages that have not yet been published on
  10135. CRAN or Bioconductor as long as they are in a git repository. Use
  10136. @option{--archive=git} followed by the URL of the git repository:
  10137. @example
  10138. guix import cran --archive=git https://github.com/immunogenomics/harmony
  10139. @end example
  10140. @item texlive
  10141. @cindex TeX Live
  10142. @cindex CTAN
  10143. Import TeX package information from the TeX Live package database for
  10144. TeX packages that are part of the @uref{https://www.tug.org/texlive/,
  10145. TeX Live distribution}.
  10146. Information about the package is obtained from the TeX Live package
  10147. database, a plain text file that is included in the @code{texlive-bin}
  10148. package. The source code is downloaded from possibly multiple locations
  10149. in the SVN repository of the Tex Live project.
  10150. The command command below imports metadata for the @code{fontspec}
  10151. TeX package:
  10152. @example
  10153. guix import texlive fontspec
  10154. @end example
  10155. @item json
  10156. @cindex JSON, import
  10157. Import package metadata from a local JSON file. Consider the following
  10158. example package definition in JSON format:
  10159. @example
  10160. @{
  10161. "name": "hello",
  10162. "version": "2.10",
  10163. "source": "mirror://gnu/hello/hello-2.10.tar.gz",
  10164. "build-system": "gnu",
  10165. "home-page": "https://www.gnu.org/software/hello/",
  10166. "synopsis": "Hello, GNU world: An example GNU package",
  10167. "description": "GNU Hello prints a greeting.",
  10168. "license": "GPL-3.0+",
  10169. "native-inputs": ["gettext"]
  10170. @}
  10171. @end example
  10172. The field names are the same as for the @code{<package>} record
  10173. (@xref{Defining Packages}). References to other packages are provided
  10174. as JSON lists of quoted package specification strings such as
  10175. @code{guile} or @code{guile@@2.0}.
  10176. The importer also supports a more explicit source definition using the
  10177. common fields for @code{<origin>} records:
  10178. @example
  10179. @{
  10180. @dots{}
  10181. "source": @{
  10182. "method": "url-fetch",
  10183. "uri": "mirror://gnu/hello/hello-2.10.tar.gz",
  10184. "sha256": @{
  10185. "base32": "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"
  10186. @}
  10187. @}
  10188. @dots{}
  10189. @}
  10190. @end example
  10191. The command below reads metadata from the JSON file @code{hello.json}
  10192. and outputs a package expression:
  10193. @example
  10194. guix import json hello.json
  10195. @end example
  10196. @item hackage
  10197. @cindex hackage
  10198. Import metadata from the Haskell community's central package archive
  10199. @uref{https://hackage.haskell.org/, Hackage}. Information is taken from
  10200. Cabal files and includes all the relevant information, including package
  10201. dependencies.
  10202. Specific command-line options are:
  10203. @table @code
  10204. @item --stdin
  10205. @itemx -s
  10206. Read a Cabal file from standard input.
  10207. @item --no-test-dependencies
  10208. @itemx -t
  10209. Do not include dependencies required only by the test suites.
  10210. @item --cabal-environment=@var{alist}
  10211. @itemx -e @var{alist}
  10212. @var{alist} is a Scheme alist defining the environment in which the
  10213. Cabal conditionals are evaluated. The accepted keys are: @code{os},
  10214. @code{arch}, @code{impl} and a string representing the name of a flag.
  10215. The value associated with a flag has to be either the symbol
  10216. @code{true} or @code{false}. The value associated with other keys
  10217. has to conform to the Cabal file format definition. The default value
  10218. associated with the keys @code{os}, @code{arch} and @code{impl} is
  10219. @samp{linux}, @samp{x86_64} and @samp{ghc}, respectively.
  10220. @item --recursive
  10221. @itemx -r
  10222. Traverse the dependency graph of the given upstream package recursively
  10223. and generate package expressions for all those packages that are not yet
  10224. in Guix.
  10225. @end table
  10226. The command below imports metadata for the latest version of the
  10227. HTTP Haskell package without including test dependencies and
  10228. specifying the value of the flag @samp{network-uri} as @code{false}:
  10229. @example
  10230. guix import hackage -t -e "'((\"network-uri\" . false))" HTTP
  10231. @end example
  10232. A specific package version may optionally be specified by following the
  10233. package name by an at-sign and a version number as in the following example:
  10234. @example
  10235. guix import hackage mtl@@2.1.3.1
  10236. @end example
  10237. @item stackage
  10238. @cindex stackage
  10239. The @code{stackage} importer is a wrapper around the @code{hackage} one.
  10240. It takes a package name, looks up the package version included in a
  10241. long-term support (LTS) @uref{https://www.stackage.org, Stackage}
  10242. release and uses the @code{hackage} importer to retrieve its metadata.
  10243. Note that it is up to you to select an LTS release compatible with the
  10244. GHC compiler used by Guix.
  10245. Specific command-line options are:
  10246. @table @code
  10247. @item --no-test-dependencies
  10248. @itemx -t
  10249. Do not include dependencies required only by the test suites.
  10250. @item --lts-version=@var{version}
  10251. @itemx -l @var{version}
  10252. @var{version} is the desired LTS release version. If omitted the latest
  10253. release is used.
  10254. @item --recursive
  10255. @itemx -r
  10256. Traverse the dependency graph of the given upstream package recursively
  10257. and generate package expressions for all those packages that are not yet
  10258. in Guix.
  10259. @end table
  10260. The command below imports metadata for the HTTP Haskell package
  10261. included in the LTS Stackage release version 7.18:
  10262. @example
  10263. guix import stackage --lts-version=7.18 HTTP
  10264. @end example
  10265. @item elpa
  10266. @cindex elpa
  10267. Import metadata from an Emacs Lisp Package Archive (ELPA) package
  10268. repository (@pxref{Packages,,, emacs, The GNU Emacs Manual}).
  10269. Specific command-line options are:
  10270. @table @code
  10271. @item --archive=@var{repo}
  10272. @itemx -a @var{repo}
  10273. @var{repo} identifies the archive repository from which to retrieve the
  10274. information. Currently the supported repositories and their identifiers
  10275. are:
  10276. @itemize -
  10277. @item
  10278. @uref{https://elpa.gnu.org/packages, GNU}, selected by the @code{gnu}
  10279. identifier. This is the default.
  10280. Packages from @code{elpa.gnu.org} are signed with one of the keys
  10281. contained in the GnuPG keyring at
  10282. @file{share/emacs/25.1/etc/package-keyring.gpg} (or similar) in the
  10283. @code{emacs} package (@pxref{Package Installation, ELPA package
  10284. signatures,, emacs, The GNU Emacs Manual}).
  10285. @item
  10286. @uref{https://elpa.nongnu.org/nongnu/, NonGNU}, selected by the
  10287. @code{nongnu} identifier.
  10288. @item
  10289. @uref{https://stable.melpa.org/packages, MELPA-Stable}, selected by the
  10290. @code{melpa-stable} identifier.
  10291. @item
  10292. @uref{https://melpa.org/packages, MELPA}, selected by the @code{melpa}
  10293. identifier.
  10294. @end itemize
  10295. @item --recursive
  10296. @itemx -r
  10297. Traverse the dependency graph of the given upstream package recursively
  10298. and generate package expressions for all those packages that are not yet
  10299. in Guix.
  10300. @end table
  10301. @item crate
  10302. @cindex crate
  10303. Import metadata from the crates.io Rust package repository
  10304. @uref{https://crates.io, crates.io}, as in this example:
  10305. @example
  10306. guix import crate blake2-rfc
  10307. @end example
  10308. The crate importer also allows you to specify a version string:
  10309. @example
  10310. guix import crate constant-time-eq@@0.1.0
  10311. @end example
  10312. Additional options include:
  10313. @table @code
  10314. @item --recursive
  10315. @itemx -r
  10316. Traverse the dependency graph of the given upstream package recursively
  10317. and generate package expressions for all those packages that are not yet
  10318. in Guix.
  10319. @end table
  10320. @item opam
  10321. @cindex OPAM
  10322. @cindex OCaml
  10323. Import metadata from the @uref{https://opam.ocaml.org/, OPAM} package
  10324. repository used by the OCaml community.
  10325. Additional options include:
  10326. @table @code
  10327. @item --recursive
  10328. @itemx -r
  10329. Traverse the dependency graph of the given upstream package recursively
  10330. and generate package expressions for all those packages that are not yet
  10331. in Guix.
  10332. @item --repo
  10333. By default, packages are searched in the official OPAM repository. This
  10334. option, which can be used more than once, lets you add other repositories
  10335. which will be searched for packages. It accepts as valid arguments:
  10336. @itemize
  10337. @item the name of a known repository - can be one of @code{opam},
  10338. @code{coq} (equivalent to @code{coq-released}),
  10339. @code{coq-core-dev}, @code{coq-extra-dev} or @code{grew}.
  10340. @item the URL of a repository as expected by the
  10341. @code{opam repository add} command (for instance, the URL equivalent
  10342. of the above @code{opam} name would be
  10343. @uref{https://opam.ocaml.org}).
  10344. @item the path to a local copy of a repository (a directory containing a
  10345. @file{packages/} sub-directory).
  10346. @end itemize
  10347. Repositories are assumed to be passed to this option by order of
  10348. preference. The additional repositories will not replace the default
  10349. @code{opam} repository, which is always kept as a fallback.
  10350. Also, please note that versions are not compared across repositories.
  10351. The first repository (from left to right) that has at least one version
  10352. of a given package will prevail over any others, and the version
  10353. imported will be the latest one found @emph{in this repository only}.
  10354. @end table
  10355. @item go
  10356. @cindex go
  10357. Import metadata for a Go module using
  10358. @uref{https://proxy.golang.org, proxy.golang.org}.
  10359. @example
  10360. guix import go gopkg.in/yaml.v2
  10361. @end example
  10362. It is possible to use a package specification with a @code{@@VERSION}
  10363. suffix to import a specific version.
  10364. Additional options include:
  10365. @table @code
  10366. @item --recursive
  10367. @itemx -r
  10368. Traverse the dependency graph of the given upstream package recursively
  10369. and generate package expressions for all those packages that are not yet
  10370. in Guix.
  10371. @item --pin-versions
  10372. When using this option, the importer preserves the exact versions of the
  10373. Go modules dependencies instead of using their latest available
  10374. versions. This can be useful when attempting to import packages that
  10375. recursively depend on former versions of themselves to build. When
  10376. using this mode, the symbol of the package is made by appending the
  10377. version to its name, so that multiple versions of the same package can
  10378. coexist.
  10379. @end table
  10380. @item egg
  10381. @cindex egg
  10382. Import metadata for @uref{https://wiki.call-cc.org/eggs, CHICKEN eggs}.
  10383. The information is taken from @file{PACKAGE.egg} files found in the
  10384. @uref{git://code.call-cc.org/eggs-5-all, eggs-5-all} Git
  10385. repository. However, it does not provide all the information that we
  10386. need, there is no ``description'' field, and the licenses used are not
  10387. always precise (BSD is often used instead of BSD-N).
  10388. @example
  10389. guix import egg sourcehut
  10390. @end example
  10391. You can also ask for a specific version:
  10392. @example
  10393. guix import egg arrays@@1.0
  10394. @end example
  10395. Additional options include:
  10396. @table @code
  10397. @item --recursive
  10398. @itemx -r
  10399. Traverse the dependency graph of the given upstream package recursively
  10400. and generate package expressions for all those packages that are not yet
  10401. in Guix.
  10402. @end table
  10403. @end table
  10404. The structure of the @command{guix import} code is modular. It would be
  10405. useful to have more importers for other package formats, and your help
  10406. is welcome here (@pxref{Contributing}).
  10407. @node Invoking guix refresh
  10408. @section Invoking @command{guix refresh}
  10409. @cindex @command {guix refresh}
  10410. The primary audience of the @command{guix refresh} command is packagers.
  10411. As a user, you may be interested in the @option{--with-latest} option,
  10412. which can bring you package update superpowers built upon @command{guix
  10413. refresh} (@pxref{Package Transformation Options,
  10414. @option{--with-latest}}). By default, @command{guix refresh} reports
  10415. any packages provided by the distribution that are outdated compared to
  10416. the latest upstream version, like this:
  10417. @example
  10418. $ guix refresh
  10419. gnu/packages/gettext.scm:29:13: gettext would be upgraded from 0.18.1.1 to 0.18.2.1
  10420. gnu/packages/glib.scm:77:12: glib would be upgraded from 2.34.3 to 2.37.0
  10421. @end example
  10422. Alternatively, one can specify packages to consider, in which case a
  10423. warning is emitted for packages that lack an updater:
  10424. @example
  10425. $ guix refresh coreutils guile guile-ssh
  10426. gnu/packages/ssh.scm:205:2: warning: no updater for guile-ssh
  10427. gnu/packages/guile.scm:136:12: guile would be upgraded from 2.0.12 to 2.0.13
  10428. @end example
  10429. @command{guix refresh} browses the upstream repository of each package and determines
  10430. the highest version number of the releases therein. The command
  10431. knows how to update specific types of packages: GNU packages, ELPA
  10432. packages, etc.---see the documentation for @option{--type} below. There
  10433. are many packages, though, for which it lacks a method to determine
  10434. whether a new upstream release is available. However, the mechanism is
  10435. extensible, so feel free to get in touch with us to add a new method!
  10436. @table @code
  10437. @item --recursive
  10438. Consider the packages specified, and all the packages upon which they depend.
  10439. @example
  10440. $ guix refresh --recursive coreutils
  10441. gnu/packages/acl.scm:40:13: acl would be upgraded from 2.2.53 to 2.3.1
  10442. gnu/packages/m4.scm:30:12: 1.4.18 is already the latest version of m4
  10443. gnu/packages/xml.scm:68:2: warning: no updater for expat
  10444. gnu/packages/multiprecision.scm:40:12: 6.1.2 is already the latest version of gmp
  10445. @dots{}
  10446. @end example
  10447. @end table
  10448. Sometimes the upstream name differs from the package name used in Guix,
  10449. and @command{guix refresh} needs a little help. Most updaters honor the
  10450. @code{upstream-name} property in package definitions, which can be used
  10451. to that effect:
  10452. @lisp
  10453. (define-public network-manager
  10454. (package
  10455. (name "network-manager")
  10456. ;; @dots{}
  10457. (properties '((upstream-name . "NetworkManager")))))
  10458. @end lisp
  10459. When passed @option{--update}, it modifies distribution source files to
  10460. update the version numbers and source tarball hashes of those package
  10461. recipes (@pxref{Defining Packages}). This is achieved by downloading
  10462. each package's latest source tarball and its associated OpenPGP
  10463. signature, authenticating the downloaded tarball against its signature
  10464. using @command{gpgv}, and finally computing its hash---note that GnuPG must be
  10465. installed and in @code{$PATH}; run @code{guix install gnupg} if needed.
  10466. When the public
  10467. key used to sign the tarball is missing from the user's keyring, an
  10468. attempt is made to automatically retrieve it from a public key server;
  10469. when this is successful, the key is added to the user's keyring; otherwise,
  10470. @command{guix refresh} reports an error.
  10471. The following options are supported:
  10472. @table @code
  10473. @item --expression=@var{expr}
  10474. @itemx -e @var{expr}
  10475. Consider the package @var{expr} evaluates to.
  10476. This is useful to precisely refer to a package, as in this example:
  10477. @example
  10478. guix refresh -l -e '(@@@@ (gnu packages commencement) glibc-final)'
  10479. @end example
  10480. This command lists the dependents of the ``final'' libc (essentially all
  10481. the packages).
  10482. @item --update
  10483. @itemx -u
  10484. Update distribution source files (package recipes) in place. This is
  10485. usually run from a checkout of the Guix source tree (@pxref{Running
  10486. Guix Before It Is Installed}):
  10487. @example
  10488. $ ./pre-inst-env guix refresh -s non-core -u
  10489. @end example
  10490. @xref{Defining Packages}, for more information on package definitions.
  10491. @item --select=[@var{subset}]
  10492. @itemx -s @var{subset}
  10493. Select all the packages in @var{subset}, one of @code{core} or
  10494. @code{non-core}.
  10495. The @code{core} subset refers to all the packages at the core of the
  10496. distribution---i.e., packages that are used to build ``everything
  10497. else''. This includes GCC, libc, Binutils, Bash, etc. Usually,
  10498. changing one of these packages in the distribution entails a rebuild of
  10499. all the others. Thus, such updates are an inconvenience to users in
  10500. terms of build time or bandwidth used to achieve the upgrade.
  10501. The @code{non-core} subset refers to the remaining packages. It is
  10502. typically useful in cases where an update of the core packages would be
  10503. inconvenient.
  10504. @item --manifest=@var{file}
  10505. @itemx -m @var{file}
  10506. Select all the packages from the manifest in @var{file}. This is useful to
  10507. check if any packages of the user manifest can be updated.
  10508. @item --type=@var{updater}
  10509. @itemx -t @var{updater}
  10510. Select only packages handled by @var{updater} (may be a comma-separated
  10511. list of updaters). Currently, @var{updater} may be one of:
  10512. @table @code
  10513. @item gnu
  10514. the updater for GNU packages;
  10515. @item savannah
  10516. the updater for packages hosted at @uref{https://savannah.gnu.org, Savannah};
  10517. @item sourceforge
  10518. the updater for packages hosted at @uref{https://sourceforge.net, SourceForge};
  10519. @item gnome
  10520. the updater for GNOME packages;
  10521. @item kde
  10522. the updater for KDE packages;
  10523. @item xorg
  10524. the updater for X.org packages;
  10525. @item kernel.org
  10526. the updater for packages hosted on kernel.org;
  10527. @item egg
  10528. the updater for @uref{https://wiki.call-cc.org/eggs/, Egg} packages;
  10529. @item elpa
  10530. the updater for @uref{https://elpa.gnu.org/, ELPA} packages;
  10531. @item cran
  10532. the updater for @uref{https://cran.r-project.org/, CRAN} packages;
  10533. @item bioconductor
  10534. the updater for @uref{https://www.bioconductor.org/, Bioconductor} R packages;
  10535. @item cpan
  10536. the updater for @uref{https://www.cpan.org/, CPAN} packages;
  10537. @item pypi
  10538. the updater for @uref{https://pypi.python.org, PyPI} packages.
  10539. @item gem
  10540. the updater for @uref{https://rubygems.org, RubyGems} packages.
  10541. @item github
  10542. the updater for @uref{https://github.com, GitHub} packages.
  10543. @item hackage
  10544. the updater for @uref{https://hackage.haskell.org, Hackage} packages.
  10545. @item stackage
  10546. the updater for @uref{https://www.stackage.org, Stackage} packages.
  10547. @item crate
  10548. the updater for @uref{https://crates.io, Crates} packages.
  10549. @item launchpad
  10550. the updater for @uref{https://launchpad.net, Launchpad} packages.
  10551. @item generic-html
  10552. a generic updater that crawls the HTML page where the source tarball of
  10553. the package is hosted, when applicable.
  10554. @item generic-git
  10555. a generic updater for packages hosted on Git repositories. It tries to
  10556. be smart about parsing Git tag names, but if it is not able to parse the
  10557. tag name and compare tags correctly, users can define the following
  10558. properties for a package.
  10559. @itemize
  10560. @item @code{release-tag-prefix}: a regular expression for matching a prefix of
  10561. the tag name.
  10562. @item @code{release-tag-suffix}: a regular expression for matching a suffix of
  10563. the tag name.
  10564. @item @code{release-tag-version-delimiter}: a string used as the delimiter in
  10565. the tag name for separating the numbers of the version.
  10566. @item @code{accept-pre-releases}: by default, the updater will ignore
  10567. pre-releases; to make it also look for pre-releases, set the this
  10568. property to @code{#t}.
  10569. @end itemize
  10570. @lisp
  10571. (package
  10572. (name "foo")
  10573. ;; ...
  10574. (properties
  10575. '((release-tag-prefix . "^release0-")
  10576. (release-tag-suffix . "[a-z]?$")
  10577. (release-tag-version-delimiter . ":"))))
  10578. @end lisp
  10579. @end table
  10580. For instance, the following command only checks for updates of Emacs
  10581. packages hosted at @code{elpa.gnu.org} and for updates of CRAN packages:
  10582. @example
  10583. $ guix refresh --type=elpa,cran
  10584. gnu/packages/statistics.scm:819:13: r-testthat would be upgraded from 0.10.0 to 0.11.0
  10585. gnu/packages/emacs.scm:856:13: emacs-auctex would be upgraded from 11.88.6 to 11.88.9
  10586. @end example
  10587. @item --list-updaters
  10588. @itemx -L
  10589. List available updaters and exit (see @option{--type} above).
  10590. For each updater, display the fraction of packages it covers; at the
  10591. end, display the fraction of packages covered by all these updaters.
  10592. @end table
  10593. In addition, @command{guix refresh} can be passed one or more package
  10594. names, as in this example:
  10595. @example
  10596. $ ./pre-inst-env guix refresh -u emacs idutils gcc@@4.8
  10597. @end example
  10598. @noindent
  10599. The command above specifically updates the @code{emacs} and
  10600. @code{idutils} packages. The @option{--select} option would have no
  10601. effect in this case. You might also want to update definitions that
  10602. correspond to the packages installed in your profile:
  10603. @example
  10604. $ ./pre-inst-env guix refresh -u \
  10605. $(guix package --list-installed | cut -f1)
  10606. @end example
  10607. When considering whether to upgrade a package, it is sometimes
  10608. convenient to know which packages would be affected by the upgrade and
  10609. should be checked for compatibility. For this the following option may
  10610. be used when passing @command{guix refresh} one or more package names:
  10611. @table @code
  10612. @item --list-dependent
  10613. @itemx -l
  10614. List top-level dependent packages that would need to be rebuilt as a
  10615. result of upgrading one or more packages.
  10616. @xref{Invoking guix graph, the @code{reverse-package} type of
  10617. @command{guix graph}}, for information on how to visualize the list of
  10618. dependents of a package.
  10619. @end table
  10620. Be aware that the @option{--list-dependent} option only
  10621. @emph{approximates} the rebuilds that would be required as a result of
  10622. an upgrade. More rebuilds might be required under some circumstances.
  10623. @example
  10624. $ guix refresh --list-dependent flex
  10625. Building the following 120 packages would ensure 213 dependent packages are rebuilt:
  10626. hop@@2.4.0 emacs-geiser@@0.13 notmuch@@0.18 mu@@0.9.9.5 cflow@@1.4 idutils@@4.6 @dots{}
  10627. @end example
  10628. The command above lists a set of packages that could be built to check
  10629. for compatibility with an upgraded @code{flex} package.
  10630. @table @code
  10631. @item --list-transitive
  10632. List all the packages which one or more packages depend upon.
  10633. @example
  10634. $ guix refresh --list-transitive flex
  10635. flex@@2.6.4 depends on the following 25 packages: perl@@5.28.0 help2man@@1.47.6
  10636. 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{}
  10637. @end example
  10638. @end table
  10639. The command above lists a set of packages which, when changed, would cause
  10640. @code{flex} to be rebuilt.
  10641. The following options can be used to customize GnuPG operation:
  10642. @table @code
  10643. @item --gpg=@var{command}
  10644. Use @var{command} as the GnuPG 2.x command. @var{command} is searched
  10645. for in @code{$PATH}.
  10646. @item --keyring=@var{file}
  10647. Use @var{file} as the keyring for upstream keys. @var{file} must be in the
  10648. @dfn{keybox format}. Keybox files usually have a name ending in @file{.kbx}
  10649. and the GNU@tie{}Privacy Guard (GPG) can manipulate these files
  10650. (@pxref{kbxutil, @command{kbxutil},, gnupg, Using the GNU Privacy Guard}, for
  10651. information on a tool to manipulate keybox files).
  10652. When this option is omitted, @command{guix refresh} uses
  10653. @file{~/.config/guix/upstream/trustedkeys.kbx} as the keyring for upstream
  10654. signing keys. OpenPGP signatures are checked against keys from this keyring;
  10655. missing keys are downloaded to this keyring as well (see
  10656. @option{--key-download} below).
  10657. You can export keys from your default GPG keyring into a keybox file using
  10658. commands like this one:
  10659. @example
  10660. gpg --export rms@@gnu.org | kbxutil --import-openpgp >> mykeyring.kbx
  10661. @end example
  10662. Likewise, you can fetch keys to a specific keybox file like this:
  10663. @example
  10664. gpg --no-default-keyring --keyring mykeyring.kbx \
  10665. --recv-keys @value{OPENPGP-SIGNING-KEY-ID}
  10666. @end example
  10667. @xref{GPG Configuration Options, @option{--keyring},, gnupg, Using the GNU
  10668. Privacy Guard}, for more information on GPG's @option{--keyring} option.
  10669. @item --key-download=@var{policy}
  10670. Handle missing OpenPGP keys according to @var{policy}, which may be one
  10671. of:
  10672. @table @code
  10673. @item always
  10674. Always download missing OpenPGP keys from the key server, and add them
  10675. to the user's GnuPG keyring.
  10676. @item never
  10677. Never try to download missing OpenPGP keys. Instead just bail out.
  10678. @item interactive
  10679. When a package signed with an unknown OpenPGP key is encountered, ask
  10680. the user whether to download it or not. This is the default behavior.
  10681. @end table
  10682. @item --key-server=@var{host}
  10683. Use @var{host} as the OpenPGP key server when importing a public key.
  10684. @item --load-path=@var{directory}
  10685. Add @var{directory} to the front of the package module search path
  10686. (@pxref{Package Modules}).
  10687. This allows users to define their own packages and make them visible to
  10688. the command-line tools.
  10689. @end table
  10690. The @code{github} updater uses the
  10691. @uref{https://developer.github.com/v3/, GitHub API} to query for new
  10692. releases. When used repeatedly e.g.@: when refreshing all packages,
  10693. GitHub will eventually refuse to answer any further API requests. By
  10694. default 60 API requests per hour are allowed, and a full refresh on all
  10695. GitHub packages in Guix requires more than this. Authentication with
  10696. GitHub through the use of an API token alleviates these limits. To use
  10697. an API token, set the environment variable @env{GUIX_GITHUB_TOKEN} to a
  10698. token procured from @uref{https://github.com/settings/tokens} or
  10699. otherwise.
  10700. @node Invoking guix style
  10701. @section Invoking @command{guix style}
  10702. The @command{guix style} command helps packagers style their package
  10703. definitions according to the latest fashionable trends. The command
  10704. currently provides the following styling rules:
  10705. @itemize
  10706. @item
  10707. formatting package definitions according to the project's conventions
  10708. (@pxref{Formatting Code});
  10709. @item
  10710. rewriting package inputs to the ``new style'', as explained below.
  10711. @end itemize
  10712. The way package inputs are written is going through a transition
  10713. (@pxref{package Reference}, for more on package inputs). Until version
  10714. 1.3.0, package inputs were written using the ``old style'', where each
  10715. input was given an explicit label, most of the time the package name:
  10716. @lisp
  10717. (package
  10718. ;; @dots{}
  10719. ;; The "old style" (deprecated).
  10720. (inputs `(("libunistring" ,libunistring)
  10721. ("libffi" ,libffi))))
  10722. @end lisp
  10723. Today, the old style is deprecated and the preferred style looks like
  10724. this:
  10725. @lisp
  10726. (package
  10727. ;; @dots{}
  10728. ;; The "new style".
  10729. (inputs (list libunistring libffi)))
  10730. @end lisp
  10731. Likewise, uses of @code{alist-delete} and friends to manipulate inputs
  10732. is now deprecated in favor of @code{modify-inputs} (@pxref{Defining
  10733. Package Variants}, for more info on @code{modify-inputs}).
  10734. In the vast majority of cases, this is a purely mechanical change on the
  10735. surface syntax that does not even incur a package rebuild. Running
  10736. @command{guix style -S inputs} can do that for you, whether you're working on
  10737. packages in Guix proper or in an external channel.
  10738. The general syntax is:
  10739. @example
  10740. guix style [@var{options}] @var{package}@dots{}
  10741. @end example
  10742. This causes @command{guix style} to analyze and rewrite the definition
  10743. of @var{package}@dots{} or, when @var{package} is omitted, of @emph{all}
  10744. the packages. The @option{--styling} or @option{-S} option allows you
  10745. to select the style rule, the default rule being @code{format}---see
  10746. below.
  10747. The available options are listed below.
  10748. @table @code
  10749. @item --dry-run
  10750. @itemx -n
  10751. Show source file locations that would be edited but do not modify them.
  10752. @item --styling=@var{rule}
  10753. @itemx -S @var{rule}
  10754. Apply @var{rule}, one of the following styling rules:
  10755. @table @code
  10756. @item format
  10757. Format the given package definition(s)---this is the default styling
  10758. rule. For example, a packager running Guix on a checkout
  10759. (@pxref{Running Guix Before It Is Installed}) might want to reformat the
  10760. definition of the Coreutils package like so:
  10761. @example
  10762. ./pre-inst-env guix style coreutils
  10763. @end example
  10764. @item inputs
  10765. Rewrite package inputs to the ``new style'', as described above. This
  10766. is how you would rewrite inputs of package @code{whatnot} in your own
  10767. channel:
  10768. @example
  10769. guix style -L ~/my/channel -S inputs whatnot
  10770. @end example
  10771. Rewriting is done in a conservative way: preserving comments and bailing
  10772. out if it cannot make sense of the code that appears in an inputs field.
  10773. The @option{--input-simplification} option described below provides
  10774. fine-grain control over when inputs should be simplified.
  10775. @end table
  10776. @item --load-path=@var{directory}
  10777. @itemx -L @var{directory}
  10778. Add @var{directory} to the front of the package module search path
  10779. (@pxref{Package Modules}).
  10780. @item --expression=@var{expr}
  10781. @itemx -e @var{expr}
  10782. Style the package @var{expr} evaluates to.
  10783. For example, running:
  10784. @example
  10785. guix style -e '(@@ (gnu packages gcc) gcc-5)'
  10786. @end example
  10787. styles the @code{gcc-5} package definition.
  10788. @item --input-simplification=@var{policy}
  10789. When using the @code{inputs} styling rule, with @samp{-S inputs}, this
  10790. option specifies the package input simplification policy for cases where
  10791. an input label does not match the corresponding package name.
  10792. @var{policy} may be one of the following:
  10793. @table @code
  10794. @item silent
  10795. Simplify inputs only when the change is ``silent'', meaning that the
  10796. package does not need to be rebuilt (its derivation is unchanged).
  10797. @item safe
  10798. Simplify inputs only when that is ``safe'' to do: the package might need
  10799. to be rebuilt, but the change is known to have no observable effect.
  10800. @item always
  10801. Simplify inputs even when input labels do not match package names, and
  10802. even if that might have an observable effect.
  10803. @end table
  10804. The default is @code{silent}, meaning that input simplifications do not
  10805. trigger any package rebuild.
  10806. @end table
  10807. @node Invoking guix lint
  10808. @section Invoking @command{guix lint}
  10809. @cindex @command{guix lint}
  10810. @cindex package, checking for errors
  10811. The @command{guix lint} command is meant to help package developers avoid
  10812. common errors and use a consistent style. It runs a number of checks on
  10813. a given set of packages in order to find common mistakes in their
  10814. definitions. Available @dfn{checkers} include (see
  10815. @option{--list-checkers} for a complete list):
  10816. @table @code
  10817. @item synopsis
  10818. @itemx description
  10819. Validate certain typographical and stylistic rules about package
  10820. descriptions and synopses.
  10821. @item inputs-should-be-native
  10822. Identify inputs that should most likely be native inputs.
  10823. @item source
  10824. @itemx home-page
  10825. @itemx mirror-url
  10826. @itemx github-url
  10827. @itemx source-file-name
  10828. Probe @code{home-page} and @code{source} URLs and report those that are
  10829. invalid. Suggest a @code{mirror://} URL when applicable. If the
  10830. @code{source} URL redirects to a GitHub URL, recommend usage of the GitHub
  10831. URL@. Check that the source file name is meaningful, e.g.@: is not just a
  10832. version number or ``git-checkout'', without a declared @code{file-name}
  10833. (@pxref{origin Reference}).
  10834. @item source-unstable-tarball
  10835. Parse the @code{source} URL to determine if a tarball from GitHub is
  10836. autogenerated or if it is a release tarball. Unfortunately GitHub's
  10837. autogenerated tarballs are sometimes regenerated.
  10838. @item derivation
  10839. Check that the derivation of the given packages can be successfully
  10840. computed for all the supported systems (@pxref{Derivations}).
  10841. @item profile-collisions
  10842. Check whether installing the given packages in a profile would lead to
  10843. collisions. Collisions occur when several packages with the same name
  10844. but a different version or a different store file name are propagated.
  10845. @xref{package Reference, @code{propagated-inputs}}, for more information
  10846. on propagated inputs.
  10847. @item archival
  10848. @cindex Software Heritage, source code archive
  10849. @cindex archival of source code, Software Heritage
  10850. Checks whether the package's source code is archived at
  10851. @uref{https://www.softwareheritage.org, Software Heritage}.
  10852. When the source code that is not archived comes from a version-control system
  10853. (VCS)---e.g., it's obtained with @code{git-fetch}, send Software Heritage a
  10854. ``save'' request so that it eventually archives it. This ensures that the
  10855. source will remain available in the long term, and that Guix can fall back to
  10856. Software Heritage should the source code disappear from its original host.
  10857. The status of recent ``save'' requests can be
  10858. @uref{https://archive.softwareheritage.org/save/#requests, viewed on-line}.
  10859. When source code is a tarball obtained with @code{url-fetch}, simply print a
  10860. message when it is not archived. As of this writing, Software Heritage does
  10861. not allow requests to save arbitrary tarballs; we are working on ways to
  10862. ensure that non-VCS source code is also archived.
  10863. Software Heritage
  10864. @uref{https://archive.softwareheritage.org/api/#rate-limiting, limits the
  10865. request rate per IP address}. When the limit is reached, @command{guix lint}
  10866. prints a message and the @code{archival} checker stops doing anything until
  10867. that limit has been reset.
  10868. @item cve
  10869. @cindex security vulnerabilities
  10870. @cindex CVE, Common Vulnerabilities and Exposures
  10871. Report known vulnerabilities found in the Common Vulnerabilities and
  10872. Exposures (CVE) databases of the current and past year
  10873. @uref{https://nvd.nist.gov/vuln/data-feeds, published by the US
  10874. NIST}.
  10875. To view information about a particular vulnerability, visit pages such as:
  10876. @itemize
  10877. @item
  10878. @indicateurl{https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-YYYY-ABCD}
  10879. @item
  10880. @indicateurl{https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-YYYY-ABCD}
  10881. @end itemize
  10882. @noindent
  10883. where @code{CVE-YYYY-ABCD} is the CVE identifier---e.g.,
  10884. @code{CVE-2015-7554}.
  10885. Package developers can specify in package recipes the
  10886. @uref{https://nvd.nist.gov/products/cpe,Common Platform Enumeration (CPE)}
  10887. name and version of the package when they differ from the name or version
  10888. that Guix uses, as in this example:
  10889. @lisp
  10890. (package
  10891. (name "grub")
  10892. ;; @dots{}
  10893. ;; CPE calls this package "grub2".
  10894. (properties '((cpe-name . "grub2")
  10895. (cpe-version . "2.3"))))
  10896. @end lisp
  10897. @c See <https://www.openwall.com/lists/oss-security/2017/03/15/3>.
  10898. Some entries in the CVE database do not specify which version of a
  10899. package they apply to, and would thus ``stick around'' forever. Package
  10900. developers who found CVE alerts and verified they can be ignored can
  10901. declare them as in this example:
  10902. @lisp
  10903. (package
  10904. (name "t1lib")
  10905. ;; @dots{}
  10906. ;; These CVEs no longer apply and can be safely ignored.
  10907. (properties `((lint-hidden-cve . ("CVE-2011-0433"
  10908. "CVE-2011-1553"
  10909. "CVE-2011-1554"
  10910. "CVE-2011-5244")))))
  10911. @end lisp
  10912. @item formatting
  10913. Warn about obvious source code formatting issues: trailing white space,
  10914. use of tabulations, etc.
  10915. @item input-labels
  10916. Report old-style input labels that do not match the name of the
  10917. corresponding package. This aims to help migrate from the ``old input
  10918. style''. @xref{package Reference}, for more information on package
  10919. inputs and input styles. @xref{Invoking guix style}, on how to migrate
  10920. to the new style.
  10921. @end table
  10922. The general syntax is:
  10923. @example
  10924. guix lint @var{options} @var{package}@dots{}
  10925. @end example
  10926. If no package is given on the command line, then all packages are checked.
  10927. The @var{options} may be zero or more of the following:
  10928. @table @code
  10929. @item --list-checkers
  10930. @itemx -l
  10931. List and describe all the available checkers that will be run on packages
  10932. and exit.
  10933. @item --checkers
  10934. @itemx -c
  10935. Only enable the checkers specified in a comma-separated list using the
  10936. names returned by @option{--list-checkers}.
  10937. @item --exclude
  10938. @itemx -x
  10939. Only disable the checkers specified in a comma-separated list using the
  10940. names returned by @option{--list-checkers}.
  10941. @item --no-network
  10942. @itemx -n
  10943. Only enable the checkers that do not depend on Internet access.
  10944. @item --load-path=@var{directory}
  10945. @itemx -L @var{directory}
  10946. Add @var{directory} to the front of the package module search path
  10947. (@pxref{Package Modules}).
  10948. This allows users to define their own packages and make them visible to
  10949. the command-line tools.
  10950. @end table
  10951. @node Invoking guix size
  10952. @section Invoking @command{guix size}
  10953. @cindex size
  10954. @cindex package size
  10955. @cindex closure
  10956. @cindex @command{guix size}
  10957. The @command{guix size} command helps package developers profile the
  10958. disk usage of packages. It is easy to overlook the impact of an
  10959. additional dependency added to a package, or the impact of using a
  10960. single output for a package that could easily be split (@pxref{Packages
  10961. with Multiple Outputs}). Such are the typical issues that
  10962. @command{guix size} can highlight.
  10963. The command can be passed one or more package specifications
  10964. such as @code{gcc@@4.8}
  10965. or @code{guile:debug}, or a file name in the store. Consider this
  10966. example:
  10967. @example
  10968. $ guix size coreutils
  10969. store item total self
  10970. /gnu/store/@dots{}-gcc-5.5.0-lib 60.4 30.1 38.1%
  10971. /gnu/store/@dots{}-glibc-2.27 30.3 28.8 36.6%
  10972. /gnu/store/@dots{}-coreutils-8.28 78.9 15.0 19.0%
  10973. /gnu/store/@dots{}-gmp-6.1.2 63.1 2.7 3.4%
  10974. /gnu/store/@dots{}-bash-static-4.4.12 1.5 1.5 1.9%
  10975. /gnu/store/@dots{}-acl-2.2.52 61.1 0.4 0.5%
  10976. /gnu/store/@dots{}-attr-2.4.47 60.6 0.2 0.3%
  10977. /gnu/store/@dots{}-libcap-2.25 60.5 0.2 0.2%
  10978. total: 78.9 MiB
  10979. @end example
  10980. @cindex closure
  10981. The store items listed here constitute the @dfn{transitive closure} of
  10982. Coreutils---i.e., Coreutils and all its dependencies, recursively---as
  10983. would be returned by:
  10984. @example
  10985. $ guix gc -R /gnu/store/@dots{}-coreutils-8.23
  10986. @end example
  10987. Here the output shows three columns next to store items. The first column,
  10988. labeled ``total'', shows the size in mebibytes (MiB) of the closure of
  10989. the store item---that is, its own size plus the size of all its
  10990. dependencies. The next column, labeled ``self'', shows the size of the
  10991. item itself. The last column shows the ratio of the size of the item
  10992. itself to the space occupied by all the items listed here.
  10993. In this example, we see that the closure of Coreutils weighs in at
  10994. 79@tie{}MiB, most of which is taken by libc and GCC's run-time support
  10995. libraries. (That libc and GCC's libraries represent a large fraction of
  10996. the closure is not a problem @i{per se} because they are always available
  10997. on the system anyway.)
  10998. Since the command also accepts store file names, assessing the size of
  10999. a build result is straightforward:
  11000. @example
  11001. guix size $(guix system build config.scm)
  11002. @end example
  11003. When the package(s) passed to @command{guix size} are available in the
  11004. store@footnote{More precisely, @command{guix size} looks for the
  11005. @emph{ungrafted} variant of the given package(s), as returned by
  11006. @code{guix build @var{package} --no-grafts}. @xref{Security Updates},
  11007. for information on grafts.}, @command{guix size} queries the daemon to determine its
  11008. dependencies, and measures its size in the store, similar to @command{du
  11009. -ms --apparent-size} (@pxref{du invocation,,, coreutils, GNU
  11010. Coreutils}).
  11011. When the given packages are @emph{not} in the store, @command{guix size}
  11012. reports information based on the available substitutes
  11013. (@pxref{Substitutes}). This makes it possible it to profile disk usage of
  11014. store items that are not even on disk, only available remotely.
  11015. You can also specify several package names:
  11016. @example
  11017. $ guix size coreutils grep sed bash
  11018. store item total self
  11019. /gnu/store/@dots{}-coreutils-8.24 77.8 13.8 13.4%
  11020. /gnu/store/@dots{}-grep-2.22 73.1 0.8 0.8%
  11021. /gnu/store/@dots{}-bash-4.3.42 72.3 4.7 4.6%
  11022. /gnu/store/@dots{}-readline-6.3 67.6 1.2 1.2%
  11023. @dots{}
  11024. total: 102.3 MiB
  11025. @end example
  11026. @noindent
  11027. In this example we see that the combination of the four packages takes
  11028. 102.3@tie{}MiB in total, which is much less than the sum of each closure
  11029. since they have a lot of dependencies in common.
  11030. When looking at the profile returned by @command{guix size}, you may
  11031. find yourself wondering why a given package shows up in the profile at
  11032. all. To understand it, you can use @command{guix graph --path -t
  11033. references} to display the shortest path between the two packages
  11034. (@pxref{Invoking guix graph}).
  11035. The available options are:
  11036. @table @option
  11037. @item --substitute-urls=@var{urls}
  11038. Use substitute information from @var{urls}.
  11039. @xref{client-substitute-urls, the same option for @code{guix build}}.
  11040. @item --sort=@var{key}
  11041. Sort lines according to @var{key}, one of the following options:
  11042. @table @code
  11043. @item self
  11044. the size of each item (the default);
  11045. @item closure
  11046. the total size of the item's closure.
  11047. @end table
  11048. @item --map-file=@var{file}
  11049. Write a graphical map of disk usage in PNG format to @var{file}.
  11050. For the example above, the map looks like this:
  11051. @image{images/coreutils-size-map,5in,, map of Coreutils disk usage
  11052. produced by @command{guix size}}
  11053. This option requires that
  11054. @uref{https://wingolog.org/software/guile-charting/, Guile-Charting} be
  11055. installed and visible in Guile's module search path. When that is not
  11056. the case, @command{guix size} fails as it tries to load it.
  11057. @item --system=@var{system}
  11058. @itemx -s @var{system}
  11059. Consider packages for @var{system}---e.g., @code{x86_64-linux}.
  11060. @item --load-path=@var{directory}
  11061. @itemx -L @var{directory}
  11062. Add @var{directory} to the front of the package module search path
  11063. (@pxref{Package Modules}).
  11064. This allows users to define their own packages and make them visible to
  11065. the command-line tools.
  11066. @end table
  11067. @node Invoking guix graph
  11068. @section Invoking @command{guix graph}
  11069. @cindex DAG
  11070. @cindex @command{guix graph}
  11071. @cindex package dependencies
  11072. Packages and their dependencies form a @dfn{graph}, specifically a
  11073. directed acyclic graph (DAG). It can quickly become difficult to have a
  11074. mental model of the package DAG, so the @command{guix graph} command
  11075. provides a visual representation of the DAG@. By default,
  11076. @command{guix graph} emits a DAG representation in the input format of
  11077. @uref{https://www.graphviz.org/, Graphviz}, so its output can be passed
  11078. directly to the @command{dot} command of Graphviz. It can also emit an
  11079. HTML page with embedded JavaScript code to display a ``chord diagram''
  11080. in a Web browser, using the @uref{https://d3js.org/, d3.js} library, or
  11081. emit Cypher queries to construct a graph in a graph database supporting
  11082. the @uref{https://www.opencypher.org/, openCypher} query language. With
  11083. @option{--path}, it simply displays the shortest path between two
  11084. packages. The general syntax is:
  11085. @example
  11086. guix graph @var{options} @var{package}@dots{}
  11087. @end example
  11088. For example, the following command generates a PDF file representing the
  11089. package DAG for the GNU@tie{}Core Utilities, showing its build-time
  11090. dependencies:
  11091. @example
  11092. guix graph coreutils | dot -Tpdf > dag.pdf
  11093. @end example
  11094. The output looks like this:
  11095. @image{images/coreutils-graph,2in,,Dependency graph of the GNU Coreutils}
  11096. Nice little graph, no?
  11097. You may find it more pleasant to navigate the graph interactively with
  11098. @command{xdot} (from the @code{xdot} package):
  11099. @example
  11100. guix graph coreutils | xdot -
  11101. @end example
  11102. But there is more than one graph! The one above is concise: it is the
  11103. graph of package objects, omitting implicit inputs such as GCC, libc,
  11104. grep, etc. It is often useful to have such a concise graph, but
  11105. sometimes one may want to see more details. @command{guix graph} supports
  11106. several types of graphs, allowing you to choose the level of detail:
  11107. @table @code
  11108. @item package
  11109. This is the default type used in the example above. It shows the DAG of
  11110. package objects, excluding implicit dependencies. It is concise, but
  11111. filters out many details.
  11112. @item reverse-package
  11113. This shows the @emph{reverse} DAG of packages. For example:
  11114. @example
  11115. guix graph --type=reverse-package ocaml
  11116. @end example
  11117. ...@: yields the graph of packages that @emph{explicitly} depend on OCaml (if
  11118. you are also interested in cases where OCaml is an implicit dependency, see
  11119. @code{reverse-bag} below).
  11120. Note that for core packages this can yield huge graphs. If all you want
  11121. is to know the number of packages that depend on a given package, use
  11122. @command{guix refresh --list-dependent} (@pxref{Invoking guix refresh,
  11123. @option{--list-dependent}}).
  11124. @item bag-emerged
  11125. This is the package DAG, @emph{including} implicit inputs.
  11126. For instance, the following command:
  11127. @example
  11128. guix graph --type=bag-emerged coreutils
  11129. @end example
  11130. ...@: yields this bigger graph:
  11131. @image{images/coreutils-bag-graph,,5in,Detailed dependency graph of the GNU Coreutils}
  11132. At the bottom of the graph, we see all the implicit inputs of
  11133. @var{gnu-build-system} (@pxref{Build Systems, @code{gnu-build-system}}).
  11134. Now, note that the dependencies of these implicit inputs---that is, the
  11135. @dfn{bootstrap dependencies} (@pxref{Bootstrapping})---are not shown
  11136. here, for conciseness.
  11137. @item bag
  11138. Similar to @code{bag-emerged}, but this time including all the bootstrap
  11139. dependencies.
  11140. @item bag-with-origins
  11141. Similar to @code{bag}, but also showing origins and their dependencies.
  11142. @item reverse-bag
  11143. This shows the @emph{reverse} DAG of packages. Unlike @code{reverse-package},
  11144. it also takes implicit dependencies into account. For example:
  11145. @example
  11146. guix graph -t reverse-bag dune
  11147. @end example
  11148. @noindent
  11149. ...@: yields the graph of all packages that depend on Dune, directly or
  11150. indirectly. Since Dune is an @emph{implicit} dependency of many packages
  11151. @i{via} @code{dune-build-system}, this shows a large number of packages,
  11152. whereas @code{reverse-package} would show very few if any.
  11153. @item derivation
  11154. This is the most detailed representation: It shows the DAG of
  11155. derivations (@pxref{Derivations}) and plain store items. Compared to
  11156. the above representation, many additional nodes are visible, including
  11157. build scripts, patches, Guile modules, etc.
  11158. For this type of graph, it is also possible to pass a @file{.drv} file
  11159. name instead of a package name, as in:
  11160. @example
  11161. guix graph -t derivation $(guix system build -d my-config.scm)
  11162. @end example
  11163. @item module
  11164. This is the graph of @dfn{package modules} (@pxref{Package Modules}).
  11165. For example, the following command shows the graph for the package
  11166. module that defines the @code{guile} package:
  11167. @example
  11168. guix graph -t module guile | xdot -
  11169. @end example
  11170. @end table
  11171. All the types above correspond to @emph{build-time dependencies}. The
  11172. following graph type represents the @emph{run-time dependencies}:
  11173. @table @code
  11174. @item references
  11175. This is the graph of @dfn{references} of a package output, as returned
  11176. by @command{guix gc --references} (@pxref{Invoking guix gc}).
  11177. If the given package output is not available in the store, @command{guix
  11178. graph} attempts to obtain dependency information from substitutes.
  11179. Here you can also pass a store file name instead of a package name. For
  11180. example, the command below produces the reference graph of your profile
  11181. (which can be big!):
  11182. @example
  11183. guix graph -t references $(readlink -f ~/.guix-profile)
  11184. @end example
  11185. @item referrers
  11186. This is the graph of the @dfn{referrers} of a store item, as returned by
  11187. @command{guix gc --referrers} (@pxref{Invoking guix gc}).
  11188. This relies exclusively on local information from your store. For
  11189. instance, let us suppose that the current Inkscape is available in 10
  11190. profiles on your machine; @command{guix graph -t referrers inkscape}
  11191. will show a graph rooted at Inkscape and with those 10 profiles linked
  11192. to it.
  11193. It can help determine what is preventing a store item from being garbage
  11194. collected.
  11195. @end table
  11196. @cindex shortest path, between packages
  11197. Often, the graph of the package you are interested in does not fit on
  11198. your screen, and anyway all you want to know is @emph{why} that package
  11199. actually depends on some seemingly unrelated package. The
  11200. @option{--path} option instructs @command{guix graph} to display the
  11201. shortest path between two packages (or derivations, or store items,
  11202. etc.):
  11203. @example
  11204. $ guix graph --path emacs libunistring
  11205. emacs@@26.3
  11206. mailutils@@3.9
  11207. libunistring@@0.9.10
  11208. $ guix graph --path -t derivation emacs libunistring
  11209. /gnu/store/@dots{}-emacs-26.3.drv
  11210. /gnu/store/@dots{}-mailutils-3.9.drv
  11211. /gnu/store/@dots{}-libunistring-0.9.10.drv
  11212. $ guix graph --path -t references emacs libunistring
  11213. /gnu/store/@dots{}-emacs-26.3
  11214. /gnu/store/@dots{}-libidn2-2.2.0
  11215. /gnu/store/@dots{}-libunistring-0.9.10
  11216. @end example
  11217. Sometimes you still want to visualize the graph but would like to trim
  11218. it so it can actually be displayed. One way to do it is via the
  11219. @option{--max-depth} (or @option{-M}) option, which lets you specify the
  11220. maximum depth of the graph. In the example below, we visualize only
  11221. @code{libreoffice} and the nodes whose distance to @code{libreoffice} is
  11222. at most 2:
  11223. @example
  11224. guix graph -M 2 libreoffice | xdot -f fdp -
  11225. @end example
  11226. Mind you, that's still a big ball of spaghetti, but at least
  11227. @command{dot} can render it quickly and it can be browsed somewhat.
  11228. The available options are the following:
  11229. @table @option
  11230. @item --type=@var{type}
  11231. @itemx -t @var{type}
  11232. Produce a graph output of @var{type}, where @var{type} must be one of
  11233. the values listed above.
  11234. @item --list-types
  11235. List the supported graph types.
  11236. @item --backend=@var{backend}
  11237. @itemx -b @var{backend}
  11238. Produce a graph using the selected @var{backend}.
  11239. @item --list-backends
  11240. List the supported graph backends.
  11241. Currently, the available backends are Graphviz and d3.js.
  11242. @item --path
  11243. Display the shortest path between two nodes of the type specified by
  11244. @option{--type}. The example below shows the shortest path between
  11245. @code{libreoffice} and @code{llvm} according to the references of
  11246. @code{libreoffice}:
  11247. @example
  11248. $ guix graph --path -t references libreoffice llvm
  11249. /gnu/store/@dots{}-libreoffice-6.4.2.2
  11250. /gnu/store/@dots{}-libepoxy-1.5.4
  11251. /gnu/store/@dots{}-mesa-19.3.4
  11252. /gnu/store/@dots{}-llvm-9.0.1
  11253. @end example
  11254. @item --expression=@var{expr}
  11255. @itemx -e @var{expr}
  11256. Consider the package @var{expr} evaluates to.
  11257. This is useful to precisely refer to a package, as in this example:
  11258. @example
  11259. guix graph -e '(@@@@ (gnu packages commencement) gnu-make-final)'
  11260. @end example
  11261. @item --system=@var{system}
  11262. @itemx -s @var{system}
  11263. Display the graph for @var{system}---e.g., @code{i686-linux}.
  11264. The package dependency graph is largely architecture-independent, but there
  11265. are some architecture-dependent bits that this option allows you to visualize.
  11266. @item --load-path=@var{directory}
  11267. @itemx -L @var{directory}
  11268. Add @var{directory} to the front of the package module search path
  11269. (@pxref{Package Modules}).
  11270. This allows users to define their own packages and make them visible to
  11271. the command-line tools.
  11272. @end table
  11273. On top of that, @command{guix graph} supports all the usual package
  11274. transformation options (@pxref{Package Transformation Options}). This
  11275. makes it easy to view the effect of a graph-rewriting transformation
  11276. such as @option{--with-input}. For example, the command below outputs
  11277. the graph of @code{git} once @code{openssl} has been replaced by
  11278. @code{libressl} everywhere in the graph:
  11279. @example
  11280. guix graph git --with-input=openssl=libressl
  11281. @end example
  11282. So many possibilities, so much fun!
  11283. @node Invoking guix publish
  11284. @section Invoking @command{guix publish}
  11285. @cindex @command{guix publish}
  11286. The purpose of @command{guix publish} is to enable users to easily share
  11287. their store with others, who can then use it as a substitute server
  11288. (@pxref{Substitutes}).
  11289. When @command{guix publish} runs, it spawns an HTTP server which allows
  11290. anyone with network access to obtain substitutes from it. This means
  11291. that any machine running Guix can also act as if it were a build farm,
  11292. since the HTTP interface is compatible with Cuirass, the software behind
  11293. the @code{@value{SUBSTITUTE-SERVER-1}} build farm.
  11294. For security, each substitute is signed, allowing recipients to check
  11295. their authenticity and integrity (@pxref{Substitutes}). Because
  11296. @command{guix publish} uses the signing key of the system, which is only
  11297. readable by the system administrator, it must be started as root; the
  11298. @option{--user} option makes it drop root privileges early on.
  11299. The signing key pair must be generated before @command{guix publish} is
  11300. launched, using @command{guix archive --generate-key} (@pxref{Invoking
  11301. guix archive}).
  11302. When the @option{--advertise} option is passed, the server advertises
  11303. its availability on the local network using multicast DNS (mDNS) and DNS
  11304. service discovery (DNS-SD), currently @i{via} Guile-Avahi (@pxref{Top,,,
  11305. guile-avahi, Using Avahi in Guile Scheme Programs}).
  11306. The general syntax is:
  11307. @example
  11308. guix publish @var{options}@dots{}
  11309. @end example
  11310. Running @command{guix publish} without any additional arguments will
  11311. spawn an HTTP server on port 8080:
  11312. @example
  11313. guix publish
  11314. @end example
  11315. Once a publishing server has been authorized, the daemon may download
  11316. substitutes from it. @xref{Getting Substitutes from Other Servers}.
  11317. By default, @command{guix publish} compresses archives on the fly as it
  11318. serves them. This ``on-the-fly'' mode is convenient in that it requires
  11319. no setup and is immediately available. However, when serving lots of
  11320. clients, we recommend using the @option{--cache} option, which enables
  11321. caching of the archives before they are sent to clients---see below for
  11322. details. The @command{guix weather} command provides a handy way to
  11323. check what a server provides (@pxref{Invoking guix weather}).
  11324. As a bonus, @command{guix publish} also serves as a content-addressed
  11325. mirror for source files referenced in @code{origin} records
  11326. (@pxref{origin Reference}). For instance, assuming @command{guix
  11327. publish} is running on @code{example.org}, the following URL returns the
  11328. raw @file{hello-2.10.tar.gz} file with the given SHA256 hash
  11329. (represented in @code{nix-base32} format, @pxref{Invoking guix hash}):
  11330. @example
  11331. http://example.org/file/hello-2.10.tar.gz/sha256/0ssi1@dots{}ndq1i
  11332. @end example
  11333. Obviously, these URLs only work for files that are in the store; in
  11334. other cases, they return 404 (``Not Found'').
  11335. @cindex build logs, publication
  11336. Build logs are available from @code{/log} URLs like:
  11337. @example
  11338. http://example.org/log/gwspk@dots{}-guile-2.2.3
  11339. @end example
  11340. @noindent
  11341. When @command{guix-daemon} is configured to save compressed build logs,
  11342. as is the case by default (@pxref{Invoking guix-daemon}), @code{/log}
  11343. URLs return the compressed log as-is, with an appropriate
  11344. @code{Content-Type} and/or @code{Content-Encoding} header. We recommend
  11345. running @command{guix-daemon} with @option{--log-compression=gzip} since
  11346. Web browsers can automatically decompress it, which is not the case with
  11347. Bzip2 compression.
  11348. The following options are available:
  11349. @table @code
  11350. @item --port=@var{port}
  11351. @itemx -p @var{port}
  11352. Listen for HTTP requests on @var{port}.
  11353. @item --listen=@var{host}
  11354. Listen on the network interface for @var{host}. The default is to
  11355. accept connections from any interface.
  11356. @item --user=@var{user}
  11357. @itemx -u @var{user}
  11358. Change privileges to @var{user} as soon as possible---i.e., once the
  11359. server socket is open and the signing key has been read.
  11360. @item --compression[=@var{method}[:@var{level}]]
  11361. @itemx -C [@var{method}[:@var{level}]]
  11362. Compress data using the given @var{method} and @var{level}. @var{method} is
  11363. one of @code{lzip}, @code{zstd}, and @code{gzip}; when @var{method} is
  11364. omitted, @code{gzip} is used.
  11365. When @var{level} is zero, disable compression. The range 1 to 9 corresponds
  11366. to different compression levels: 1 is the fastest, and 9 is the best
  11367. (CPU-intensive). The default is 3.
  11368. Usually, @code{lzip} compresses noticeably better than @code{gzip} for a
  11369. small increase in CPU usage; see
  11370. @uref{https://nongnu.org/lzip/lzip_benchmark.html,benchmarks on the lzip
  11371. Web page}. However, @code{lzip} achieves low decompression throughput
  11372. (on the order of 50@tie{}MiB/s on modern hardware), which can be a
  11373. bottleneck for someone who downloads over a fast network connection.
  11374. The compression ratio of @code{zstd} is between that of @code{lzip} and
  11375. that of @code{gzip}; its main advantage is a
  11376. @uref{https://facebook.github.io/zstd/,high decompression speed}.
  11377. Unless @option{--cache} is used, compression occurs on the fly and
  11378. the compressed streams are not
  11379. cached. Thus, to reduce load on the machine that runs @command{guix
  11380. publish}, it may be a good idea to choose a low compression level, to
  11381. run @command{guix publish} behind a caching proxy, or to use
  11382. @option{--cache}. Using @option{--cache} has the advantage that it
  11383. allows @command{guix publish} to add @code{Content-Length} HTTP header
  11384. to its responses.
  11385. This option can be repeated, in which case every substitute gets compressed
  11386. using all the selected methods, and all of them are advertised. This is
  11387. useful when users may not support all the compression methods: they can select
  11388. the one they support.
  11389. @item --cache=@var{directory}
  11390. @itemx -c @var{directory}
  11391. Cache archives and meta-data (@code{.narinfo} URLs) to @var{directory}
  11392. and only serve archives that are in cache.
  11393. When this option is omitted, archives and meta-data are created
  11394. on-the-fly. This can reduce the available bandwidth, especially when
  11395. compression is enabled, since this may become CPU-bound. Another
  11396. drawback of the default mode is that the length of archives is not known
  11397. in advance, so @command{guix publish} does not add a
  11398. @code{Content-Length} HTTP header to its responses, which in turn
  11399. prevents clients from knowing the amount of data being downloaded.
  11400. Conversely, when @option{--cache} is used, the first request for a store
  11401. item (@i{via} a @code{.narinfo} URL) triggers a
  11402. background process to @dfn{bake} the archive---computing its
  11403. @code{.narinfo} and compressing the archive, if needed. Once the
  11404. archive is cached in @var{directory}, subsequent requests succeed and
  11405. are served directly from the cache, which guarantees that clients get
  11406. the best possible bandwidth.
  11407. That first @code{.narinfo} request nonetheless returns 200, provided the
  11408. requested store item is ``small enough'', below the cache bypass
  11409. threshold---see @option{--cache-bypass-threshold} below. That way,
  11410. clients do not have to wait until the archive is baked. For larger
  11411. store items, the first @code{.narinfo} request returns 404, meaning that
  11412. clients have to wait until the archive is baked.
  11413. The ``baking'' process is performed by worker threads. By default, one
  11414. thread per CPU core is created, but this can be customized. See
  11415. @option{--workers} below.
  11416. When @option{--ttl} is used, cached entries are automatically deleted
  11417. when they have expired.
  11418. @item --workers=@var{N}
  11419. When @option{--cache} is used, request the allocation of @var{N} worker
  11420. threads to ``bake'' archives.
  11421. @item --ttl=@var{ttl}
  11422. Produce @code{Cache-Control} HTTP headers that advertise a time-to-live
  11423. (TTL) of @var{ttl}. @var{ttl} must denote a duration: @code{5d} means 5
  11424. days, @code{1m} means 1 month, and so on.
  11425. This allows the user's Guix to keep substitute information in cache for
  11426. @var{ttl}. However, note that @code{guix publish} does not itself
  11427. guarantee that the store items it provides will indeed remain available
  11428. for as long as @var{ttl}.
  11429. Additionally, when @option{--cache} is used, cached entries that have
  11430. not been accessed for @var{ttl} and that no longer have a corresponding
  11431. item in the store, may be deleted.
  11432. @item --negative-ttl=@var{ttl}
  11433. Similarly produce @code{Cache-Control} HTTP headers to advertise the
  11434. time-to-live (TTL) of @emph{negative} lookups---missing store items, for
  11435. which the HTTP 404 code is returned. By default, no negative TTL is
  11436. advertised.
  11437. This parameter can help adjust server load and substitute latency by
  11438. instructing cooperating clients to be more or less patient when a store
  11439. item is missing.
  11440. @item --cache-bypass-threshold=@var{size}
  11441. When used in conjunction with @option{--cache}, store items smaller than
  11442. @var{size} are immediately available, even when they are not yet in
  11443. cache. @var{size} is a size in bytes, or it can be suffixed by @code{M}
  11444. for megabytes and so on. The default is @code{10M}.
  11445. ``Cache bypass'' allows you to reduce the publication delay for clients
  11446. at the expense of possibly additional I/O and CPU use on the server
  11447. side: depending on the client access patterns, those store items can end
  11448. up being baked several times until a copy is available in cache.
  11449. Increasing the threshold may be useful for sites that have few users, or
  11450. to guarantee that users get substitutes even for store items that are
  11451. not popular.
  11452. @item --nar-path=@var{path}
  11453. Use @var{path} as the prefix for the URLs of ``nar'' files
  11454. (@pxref{Invoking guix archive, normalized archives}).
  11455. By default, nars are served at a URL such as
  11456. @code{/nar/gzip/@dots{}-coreutils-8.25}. This option allows you to
  11457. change the @code{/nar} part to @var{path}.
  11458. @item --public-key=@var{file}
  11459. @itemx --private-key=@var{file}
  11460. Use the specific @var{file}s as the public/private key pair used to sign
  11461. the store items being published.
  11462. The files must correspond to the same key pair (the private key is used
  11463. for signing and the public key is merely advertised in the signature
  11464. metadata). They must contain keys in the canonical s-expression format
  11465. as produced by @command{guix archive --generate-key} (@pxref{Invoking
  11466. guix archive}). By default, @file{/etc/guix/signing-key.pub} and
  11467. @file{/etc/guix/signing-key.sec} are used.
  11468. @item --repl[=@var{port}]
  11469. @itemx -r [@var{port}]
  11470. Spawn a Guile REPL server (@pxref{REPL Servers,,, guile, GNU Guile
  11471. Reference Manual}) on @var{port} (37146 by default). This is used
  11472. primarily for debugging a running @command{guix publish} server.
  11473. @end table
  11474. Enabling @command{guix publish} on Guix System is a one-liner: just
  11475. instantiate a @code{guix-publish-service-type} service in the @code{services} field
  11476. of the @code{operating-system} declaration (@pxref{guix-publish-service-type,
  11477. @code{guix-publish-service-type}}).
  11478. If you are instead running Guix on a ``foreign distro'', follow these
  11479. instructions:
  11480. @itemize
  11481. @item
  11482. If your host distro uses the systemd init system:
  11483. @example
  11484. # ln -s ~root/.guix-profile/lib/systemd/system/guix-publish.service \
  11485. /etc/systemd/system/
  11486. # systemctl start guix-publish && systemctl enable guix-publish
  11487. @end example
  11488. @item
  11489. If your host distro uses the Upstart init system:
  11490. @example
  11491. # ln -s ~root/.guix-profile/lib/upstart/system/guix-publish.conf /etc/init/
  11492. # start guix-publish
  11493. @end example
  11494. @item
  11495. Otherwise, proceed similarly with your distro's init system.
  11496. @end itemize
  11497. @node Invoking guix challenge
  11498. @section Invoking @command{guix challenge}
  11499. @cindex reproducible builds
  11500. @cindex verifiable builds
  11501. @cindex @command{guix challenge}
  11502. @cindex challenge
  11503. Do the binaries provided by this server really correspond to the source
  11504. code it claims to build? Is a package build process deterministic?
  11505. These are the questions the @command{guix challenge} command attempts to
  11506. answer.
  11507. The former is obviously an important question: Before using a substitute
  11508. server (@pxref{Substitutes}), one had better @emph{verify} that it
  11509. provides the right binaries, and thus @emph{challenge} it. The latter
  11510. is what enables the former: If package builds are deterministic, then
  11511. independent builds of the package should yield the exact same result,
  11512. bit for bit; if a server provides a binary different from the one
  11513. obtained locally, it may be either corrupt or malicious.
  11514. We know that the hash that shows up in @file{/gnu/store} file names is
  11515. the hash of all the inputs of the process that built the file or
  11516. directory---compilers, libraries, build scripts,
  11517. etc. (@pxref{Introduction}). Assuming deterministic build processes,
  11518. one store file name should map to exactly one build output.
  11519. @command{guix challenge} checks whether there is, indeed, a single
  11520. mapping by comparing the build outputs of several independent builds of
  11521. any given store item.
  11522. The command output looks like this:
  11523. @smallexample
  11524. $ guix challenge --substitute-urls="https://@value{SUBSTITUTE-SERVER-1} https://guix.example.org"
  11525. updating list of substitutes from 'https://@value{SUBSTITUTE-SERVER-1}'... 100.0%
  11526. updating list of substitutes from 'https://guix.example.org'... 100.0%
  11527. /gnu/store/@dots{}-openssl-1.0.2d contents differ:
  11528. local hash: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q
  11529. https://@value{SUBSTITUTE-SERVER-1}/nar/@dots{}-openssl-1.0.2d: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q
  11530. https://guix.example.org/nar/@dots{}-openssl-1.0.2d: 1zy4fmaaqcnjrzzajkdn3f5gmjk754b43qkq47llbyak9z0qjyim
  11531. differing files:
  11532. /lib/libcrypto.so.1.1
  11533. /lib/libssl.so.1.1
  11534. /gnu/store/@dots{}-git-2.5.0 contents differ:
  11535. local hash: 00p3bmryhjxrhpn2gxs2fy0a15lnip05l97205pgbk5ra395hyha
  11536. https://@value{SUBSTITUTE-SERVER-1}/nar/@dots{}-git-2.5.0: 069nb85bv4d4a6slrwjdy8v1cn4cwspm3kdbmyb81d6zckj3nq9f
  11537. https://guix.example.org/nar/@dots{}-git-2.5.0: 0mdqa9w1p6cmli6976v4wi0sw9r4p5prkj7lzfd1877wk11c9c73
  11538. differing file:
  11539. /libexec/git-core/git-fsck
  11540. /gnu/store/@dots{}-pius-2.1.1 contents differ:
  11541. local hash: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax
  11542. https://@value{SUBSTITUTE-SERVER-1}/nar/@dots{}-pius-2.1.1: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax
  11543. https://guix.example.org/nar/@dots{}-pius-2.1.1: 1cy25x1a4fzq5rk0pmvc8xhwyffnqz95h2bpvqsz2mpvlbccy0gs
  11544. differing file:
  11545. /share/man/man1/pius.1.gz
  11546. @dots{}
  11547. 6,406 store items were analyzed:
  11548. - 4,749 (74.1%) were identical
  11549. - 525 (8.2%) differed
  11550. - 1,132 (17.7%) were inconclusive
  11551. @end smallexample
  11552. @noindent
  11553. In this example, @command{guix challenge} first scans the store to
  11554. determine the set of locally-built derivations---as opposed to store
  11555. items that were downloaded from a substitute server---and then queries
  11556. all the substitute servers. It then reports those store items for which
  11557. the servers obtained a result different from the local build.
  11558. @cindex non-determinism, in package builds
  11559. As an example, @code{guix.example.org} always gets a different answer.
  11560. Conversely, @code{@value{SUBSTITUTE-SERVER-1}} agrees with local builds, except in the
  11561. case of Git. This might indicate that the build process of Git is
  11562. non-deterministic, meaning that its output varies as a function of
  11563. various things that Guix does not fully control, in spite of building
  11564. packages in isolated environments (@pxref{Features}). Most common
  11565. sources of non-determinism include the addition of timestamps in build
  11566. results, the inclusion of random numbers, and directory listings sorted
  11567. by inode number. See @uref{https://reproducible-builds.org/docs/}, for
  11568. more information.
  11569. To find out what is wrong with this Git binary, the easiest approach is
  11570. to run:
  11571. @example
  11572. guix challenge git \
  11573. --diff=diffoscope \
  11574. --substitute-urls="https://@value{SUBSTITUTE-SERVER-1} https://guix.example.org"
  11575. @end example
  11576. This automatically invokes @command{diffoscope}, which displays detailed
  11577. information about files that differ.
  11578. Alternatively, we can do something along these lines (@pxref{Invoking guix
  11579. archive}):
  11580. @example
  11581. $ wget -q -O - https://@value{SUBSTITUTE-SERVER-1}/nar/lzip/@dots{}-git-2.5.0 \
  11582. | lzip -d | guix archive -x /tmp/git
  11583. $ diff -ur --no-dereference /gnu/store/@dots{}-git.2.5.0 /tmp/git
  11584. @end example
  11585. This command shows the difference between the files resulting from the
  11586. local build, and the files resulting from the build on
  11587. @code{@value{SUBSTITUTE-SERVER-1}} (@pxref{Overview, Comparing and Merging Files,,
  11588. diffutils, Comparing and Merging Files}). The @command{diff} command
  11589. works great for text files. When binary files differ, a better option
  11590. is @uref{https://diffoscope.org/, Diffoscope}, a tool that helps
  11591. visualize differences for all kinds of files.
  11592. Once you have done that work, you can tell whether the differences are due
  11593. to a non-deterministic build process or to a malicious server. We try
  11594. hard to remove sources of non-determinism in packages to make it easier
  11595. to verify substitutes, but of course, this is a process that
  11596. involves not just Guix, but a large part of the free software community.
  11597. In the meantime, @command{guix challenge} is one tool to help address
  11598. the problem.
  11599. If you are writing packages for Guix, you are encouraged to check
  11600. whether @code{@value{SUBSTITUTE-SERVER-1}} and other substitute servers obtain the
  11601. same build result as you did with:
  11602. @example
  11603. $ guix challenge @var{package}
  11604. @end example
  11605. @noindent
  11606. where @var{package} is a package specification such as
  11607. @code{guile@@2.0} or @code{glibc:debug}.
  11608. The general syntax is:
  11609. @example
  11610. guix challenge @var{options} [@var{packages}@dots{}]
  11611. @end example
  11612. When a difference is found between the hash of a locally-built item and
  11613. that of a server-provided substitute, or among substitutes provided by
  11614. different servers, the command displays it as in the example above and
  11615. its exit code is 2 (other non-zero exit codes denote other kinds of
  11616. errors).
  11617. The one option that matters is:
  11618. @table @code
  11619. @item --substitute-urls=@var{urls}
  11620. Consider @var{urls} the whitespace-separated list of substitute source
  11621. URLs to compare to.
  11622. @item --diff=@var{mode}
  11623. Upon mismatches, show differences according to @var{mode}, one of:
  11624. @table @asis
  11625. @item @code{simple} (the default)
  11626. Show the list of files that differ.
  11627. @item @code{diffoscope}
  11628. @itemx @var{command}
  11629. Invoke @uref{https://diffoscope.org/, Diffoscope}, passing it
  11630. two directories whose contents do not match.
  11631. When @var{command} is an absolute file name, run @var{command} instead
  11632. of Diffoscope.
  11633. @item @code{none}
  11634. Do not show further details about the differences.
  11635. @end table
  11636. Thus, unless @option{--diff=none} is passed, @command{guix challenge}
  11637. downloads the store items from the given substitute servers so that it
  11638. can compare them.
  11639. @item --verbose
  11640. @itemx -v
  11641. Show details about matches (identical contents) in addition to
  11642. information about mismatches.
  11643. @end table
  11644. @node Invoking guix copy
  11645. @section Invoking @command{guix copy}
  11646. @cindex copy, of store items, over SSH
  11647. @cindex SSH, copy of store items
  11648. @cindex sharing store items across machines
  11649. @cindex transferring store items across machines
  11650. The @command{guix copy} command copies items from the store of one
  11651. machine to that of another machine over a secure shell (SSH)
  11652. connection@footnote{This command is available only when Guile-SSH was
  11653. found. @xref{Requirements}, for details.}. For example, the following
  11654. command copies the @code{coreutils} package, the user's profile, and all
  11655. their dependencies over to @var{host}, logged in as @var{user}:
  11656. @example
  11657. guix copy --to=@var{user}@@@var{host} \
  11658. coreutils $(readlink -f ~/.guix-profile)
  11659. @end example
  11660. If some of the items to be copied are already present on @var{host},
  11661. they are not actually sent.
  11662. The command below retrieves @code{libreoffice} and @code{gimp} from
  11663. @var{host}, assuming they are available there:
  11664. @example
  11665. guix copy --from=@var{host} libreoffice gimp
  11666. @end example
  11667. The SSH connection is established using the Guile-SSH client, which is
  11668. compatible with OpenSSH: it honors @file{~/.ssh/known_hosts} and
  11669. @file{~/.ssh/config}, and uses the SSH agent for authentication.
  11670. The key used to sign items that are sent must be accepted by the remote
  11671. machine. Likewise, the key used by the remote machine to sign items you
  11672. are retrieving must be in @file{/etc/guix/acl} so it is accepted by your
  11673. own daemon. @xref{Invoking guix archive}, for more information about
  11674. store item authentication.
  11675. The general syntax is:
  11676. @example
  11677. guix copy [--to=@var{spec}|--from=@var{spec}] @var{items}@dots{}
  11678. @end example
  11679. You must always specify one of the following options:
  11680. @table @code
  11681. @item --to=@var{spec}
  11682. @itemx --from=@var{spec}
  11683. Specify the host to send to or receive from. @var{spec} must be an SSH
  11684. spec such as @code{example.org}, @code{charlie@@example.org}, or
  11685. @code{charlie@@example.org:2222}.
  11686. @end table
  11687. The @var{items} can be either package names, such as @code{gimp}, or
  11688. store items, such as @file{/gnu/store/@dots{}-idutils-4.6}.
  11689. When specifying the name of a package to send, it is first built if
  11690. needed, unless @option{--dry-run} was specified. Common build options
  11691. are supported (@pxref{Common Build Options}).
  11692. @node Invoking guix container
  11693. @section Invoking @command{guix container}
  11694. @cindex container
  11695. @cindex @command{guix container}
  11696. @quotation Note
  11697. As of version @value{VERSION}, this tool is experimental. The interface
  11698. is subject to radical change in the future.
  11699. @end quotation
  11700. The purpose of @command{guix container} is to manipulate processes
  11701. running within an isolated environment, commonly known as a
  11702. ``container'', typically created by the @command{guix shell}
  11703. (@pxref{Invoking guix shell}) and @command{guix system container}
  11704. (@pxref{Invoking guix system}) commands.
  11705. The general syntax is:
  11706. @example
  11707. guix container @var{action} @var{options}@dots{}
  11708. @end example
  11709. @var{action} specifies the operation to perform with a container, and
  11710. @var{options} specifies the context-specific arguments for the action.
  11711. The following actions are available:
  11712. @table @code
  11713. @item exec
  11714. Execute a command within the context of a running container.
  11715. The syntax is:
  11716. @example
  11717. guix container exec @var{pid} @var{program} @var{arguments}@dots{}
  11718. @end example
  11719. @var{pid} specifies the process ID of the running container.
  11720. @var{program} specifies an executable file name within the root file
  11721. system of the container. @var{arguments} are the additional options that
  11722. will be passed to @var{program}.
  11723. The following command launches an interactive login shell inside a
  11724. Guix system container, started by @command{guix system container}, and whose
  11725. process ID is 9001:
  11726. @example
  11727. guix container exec 9001 /run/current-system/profile/bin/bash --login
  11728. @end example
  11729. Note that the @var{pid} cannot be the parent process of a container. It
  11730. must be PID 1 of the container or one of its child processes.
  11731. @end table
  11732. @node Invoking guix weather
  11733. @section Invoking @command{guix weather}
  11734. Occasionally you're grumpy because substitutes are lacking and you end
  11735. up building packages by yourself (@pxref{Substitutes}). The
  11736. @command{guix weather} command reports on substitute availability on the
  11737. specified servers so you can have an idea of whether you'll be grumpy
  11738. today. It can sometimes be useful info as a user, but it is primarily
  11739. useful to people running @command{guix publish} (@pxref{Invoking guix
  11740. publish}).
  11741. @cindex statistics, for substitutes
  11742. @cindex availability of substitutes
  11743. @cindex substitute availability
  11744. @cindex weather, substitute availability
  11745. Here's a sample run:
  11746. @example
  11747. $ guix weather --substitute-urls=https://guix.example.org
  11748. computing 5,872 package derivations for x86_64-linux...
  11749. looking for 6,128 store items on https://guix.example.org..
  11750. updating list of substitutes from 'https://guix.example.org'... 100.0%
  11751. https://guix.example.org
  11752. 43.4% substitutes available (2,658 out of 6,128)
  11753. 7,032.5 MiB of nars (compressed)
  11754. 19,824.2 MiB on disk (uncompressed)
  11755. 0.030 seconds per request (182.9 seconds in total)
  11756. 33.5 requests per second
  11757. 9.8% (342 out of 3,470) of the missing items are queued
  11758. 867 queued builds
  11759. x86_64-linux: 518 (59.7%)
  11760. i686-linux: 221 (25.5%)
  11761. aarch64-linux: 128 (14.8%)
  11762. build rate: 23.41 builds per hour
  11763. x86_64-linux: 11.16 builds per hour
  11764. i686-linux: 6.03 builds per hour
  11765. aarch64-linux: 6.41 builds per hour
  11766. @end example
  11767. @cindex continuous integration, statistics
  11768. As you can see, it reports the fraction of all the packages for which
  11769. substitutes are available on the server---regardless of whether
  11770. substitutes are enabled, and regardless of whether this server's signing
  11771. key is authorized. It also reports the size of the compressed archives
  11772. (``nars'') provided by the server, the size the corresponding store
  11773. items occupy in the store (assuming deduplication is turned off), and
  11774. the server's throughput. The second part gives continuous integration
  11775. (CI) statistics, if the server supports it. In addition, using the
  11776. @option{--coverage} option, @command{guix weather} can list ``important''
  11777. package substitutes missing on the server (see below).
  11778. To achieve that, @command{guix weather} queries over HTTP(S) meta-data
  11779. (@dfn{narinfos}) for all the relevant store items. Like @command{guix
  11780. challenge}, it ignores signatures on those substitutes, which is
  11781. innocuous since the command only gathers statistics and cannot install
  11782. those substitutes.
  11783. The general syntax is:
  11784. @example
  11785. guix weather @var{options}@dots{} [@var{packages}@dots{}]
  11786. @end example
  11787. When @var{packages} is omitted, @command{guix weather} checks the availability
  11788. of substitutes for @emph{all} the packages, or for those specified with
  11789. @option{--manifest}; otherwise it only considers the specified packages. It
  11790. is also possible to query specific system types with @option{--system}.
  11791. @command{guix weather} exits with a non-zero code when the fraction of
  11792. available substitutes is below 100%.
  11793. The available options are listed below.
  11794. @table @code
  11795. @item --substitute-urls=@var{urls}
  11796. @var{urls} is the space-separated list of substitute server URLs to
  11797. query. When this option is omitted, the default set of substitute
  11798. servers is queried.
  11799. @item --system=@var{system}
  11800. @itemx -s @var{system}
  11801. Query substitutes for @var{system}---e.g., @code{aarch64-linux}. This
  11802. option can be repeated, in which case @command{guix weather} will query
  11803. substitutes for several system types.
  11804. @item --manifest=@var{file}
  11805. Instead of querying substitutes for all the packages, only ask for those
  11806. specified in @var{file}. @var{file} must contain a @dfn{manifest}, as
  11807. with the @code{-m} option of @command{guix package} (@pxref{Invoking
  11808. guix package}).
  11809. This option can be repeated several times, in which case the manifests
  11810. are concatenated.
  11811. @item --coverage[=@var{count}]
  11812. @itemx -c [@var{count}]
  11813. Report on substitute coverage for packages: list packages with at least
  11814. @var{count} dependents (zero by default) for which substitutes are
  11815. unavailable. Dependent packages themselves are not listed: if @var{b} depends
  11816. on @var{a} and @var{a} has no substitutes, only @var{a} is listed, even though
  11817. @var{b} usually lacks substitutes as well. The result looks like this:
  11818. @example
  11819. $ guix weather --substitute-urls=@value{SUBSTITUTE-URLS} -c 10
  11820. computing 8,983 package derivations for x86_64-linux...
  11821. looking for 9,343 store items on @value{SUBSTITUTE-URLS}...
  11822. updating substitutes from '@value{SUBSTITUTE-URLS}'... 100.0%
  11823. @value{SUBSTITUTE-URLS}
  11824. 64.7% substitutes available (6,047 out of 9,343)
  11825. @dots{}
  11826. 2502 packages are missing from '@value{SUBSTITUTE-URLS}' for 'x86_64-linux', among which:
  11827. 58 kcoreaddons@@5.49.0 /gnu/store/@dots{}-kcoreaddons-5.49.0
  11828. 46 qgpgme@@1.11.1 /gnu/store/@dots{}-qgpgme-1.11.1
  11829. 37 perl-http-cookiejar@@0.008 /gnu/store/@dots{}-perl-http-cookiejar-0.008
  11830. @dots{}
  11831. @end example
  11832. What this example shows is that @code{kcoreaddons} and presumably the 58
  11833. packages that depend on it have no substitutes at
  11834. @code{@value{SUBSTITUTE-SERVER-1}}; likewise for @code{qgpgme} and the 46
  11835. packages that depend on it.
  11836. If you are a Guix developer, or if you are taking care of this build farm,
  11837. you'll probably want to have a closer look at these packages: they may simply
  11838. fail to build.
  11839. @item --display-missing
  11840. Display the list of store items for which substitutes are missing.
  11841. @end table
  11842. @node Invoking guix processes
  11843. @section Invoking @command{guix processes}
  11844. The @command{guix processes} command can be useful to developers and system
  11845. administrators, especially on multi-user machines and on build farms: it lists
  11846. the current sessions (connections to the daemon), as well as information about
  11847. the processes involved@footnote{Remote sessions, when @command{guix-daemon} is
  11848. started with @option{--listen} specifying a TCP endpoint, are @emph{not}
  11849. listed.}. Here's an example of the information it returns:
  11850. @example
  11851. $ sudo guix processes
  11852. SessionPID: 19002
  11853. ClientPID: 19090
  11854. ClientCommand: guix shell python
  11855. SessionPID: 19402
  11856. ClientPID: 19367
  11857. ClientCommand: guix publish -u guix-publish -p 3000 -C 9 @dots{}
  11858. SessionPID: 19444
  11859. ClientPID: 19419
  11860. ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{}
  11861. LockHeld: /gnu/store/@dots{}-perl-ipc-cmd-0.96.lock
  11862. LockHeld: /gnu/store/@dots{}-python-six-bootstrap-1.11.0.lock
  11863. LockHeld: /gnu/store/@dots{}-libjpeg-turbo-2.0.0.lock
  11864. ChildPID: 20495
  11865. ChildCommand: guix offload x86_64-linux 7200 1 28800
  11866. ChildPID: 27733
  11867. ChildCommand: guix offload x86_64-linux 7200 1 28800
  11868. ChildPID: 27793
  11869. ChildCommand: guix offload x86_64-linux 7200 1 28800
  11870. @end example
  11871. In this example we see that @command{guix-daemon} has three clients:
  11872. @command{guix environment}, @command{guix publish}, and the Cuirass continuous
  11873. integration tool; their process identifier (PID) is given by the
  11874. @code{ClientPID} field. The @code{SessionPID} field gives the PID of the
  11875. @command{guix-daemon} sub-process of this particular session.
  11876. The @code{LockHeld} fields show which store items are currently locked
  11877. by this session, which corresponds to store items being built or
  11878. substituted (the @code{LockHeld} field is not displayed when
  11879. @command{guix processes} is not running as root). Last, by looking at
  11880. the @code{ChildPID} and @code{ChildCommand} fields, we understand that
  11881. these three builds are being offloaded (@pxref{Daemon Offload Setup}).
  11882. The output is in Recutils format so we can use the handy @command{recsel}
  11883. command to select sessions of interest (@pxref{Selection Expressions,,,
  11884. recutils, GNU recutils manual}). As an example, the command shows the command
  11885. line and PID of the client that triggered the build of a Perl package:
  11886. @example
  11887. $ sudo guix processes | \
  11888. recsel -p ClientPID,ClientCommand -e 'LockHeld ~ "perl"'
  11889. ClientPID: 19419
  11890. ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{}
  11891. @end example
  11892. Additional options are listed below.
  11893. @table @code
  11894. @item --format=@var{format}
  11895. @itemx -f @var{format}
  11896. Produce output in the specified @var{format}, one of:
  11897. @table @code
  11898. @item recutils
  11899. The default option. It outputs a set of Session recutils records
  11900. that include each @code{ChildProcess} as a field.
  11901. @item normalized
  11902. Normalize the output records into record sets (@pxref{Record Sets,,,
  11903. recutils, GNU recutils manual}). Normalizing into record sets allows
  11904. joins across record types. The example below lists the PID of each
  11905. @code{ChildProcess} and the associated PID for @code{Session} that
  11906. spawned the @code{ChildProcess} where the @code{Session} was started
  11907. using @command{guix build}.
  11908. @example
  11909. $ guix processes --format=normalized | \
  11910. recsel \
  11911. -j Session \
  11912. -t ChildProcess \
  11913. -p Session.PID,PID \
  11914. -e 'Session.ClientCommand ~ "guix build"'
  11915. PID: 4435
  11916. Session_PID: 4278
  11917. PID: 4554
  11918. Session_PID: 4278
  11919. PID: 4646
  11920. Session_PID: 4278
  11921. @end example
  11922. @end table
  11923. @end table
  11924. @node System Configuration
  11925. @chapter System Configuration
  11926. @cindex system configuration
  11927. Guix System supports a consistent whole-system configuration
  11928. mechanism. By that we mean that all aspects of the global system
  11929. configuration---such as the available system services, timezone and
  11930. locale settings, user accounts---are declared in a single place. Such
  11931. a @dfn{system configuration} can be @dfn{instantiated}---i.e., effected.
  11932. One of the advantages of putting all the system configuration under the
  11933. control of Guix is that it supports transactional system upgrades, and
  11934. makes it possible to roll back to a previous system instantiation,
  11935. should something go wrong with the new one (@pxref{Features}). Another
  11936. advantage is that it makes it easy to replicate the exact same configuration
  11937. across different machines, or at different points in time, without
  11938. having to resort to additional administration tools layered on top of
  11939. the own tools of the system.
  11940. @c Yes, we're talking of Puppet, Chef, & co. here. ↑
  11941. This section describes this mechanism. First we focus on the system
  11942. administrator's viewpoint---explaining how the system is configured and
  11943. instantiated. Then we show how this mechanism can be extended, for
  11944. instance to support new system services.
  11945. @menu
  11946. * Using the Configuration System:: Customizing your GNU system.
  11947. * operating-system Reference:: Detail of operating-system declarations.
  11948. * File Systems:: Configuring file system mounts.
  11949. * Mapped Devices:: Block device extra processing.
  11950. * Swap Space:: Backing RAM with disk space.
  11951. * User Accounts:: Specifying user accounts.
  11952. * Keyboard Layout:: How the system interprets key strokes.
  11953. * Locales:: Language and cultural convention settings.
  11954. * Services:: Specifying system services.
  11955. * Setuid Programs:: Programs running with root privileges.
  11956. * X.509 Certificates:: Authenticating HTTPS servers.
  11957. * Name Service Switch:: Configuring libc's name service switch.
  11958. * Initial RAM Disk:: Linux-Libre bootstrapping.
  11959. * Bootloader Configuration:: Configuring the boot loader.
  11960. * Invoking guix system:: Instantiating a system configuration.
  11961. * Invoking guix deploy:: Deploying a system configuration to a remote host.
  11962. * Running Guix in a VM:: How to run Guix System in a virtual machine.
  11963. * Defining Services:: Adding new service definitions.
  11964. @end menu
  11965. @node Using the Configuration System
  11966. @section Using the Configuration System
  11967. The operating system is configured by providing an
  11968. @code{operating-system} declaration in a file that can then be passed to
  11969. the @command{guix system} command (@pxref{Invoking guix system}). A
  11970. simple setup, with the default system services, the default Linux-Libre
  11971. kernel, initial RAM disk, and boot loader looks like this:
  11972. @findex operating-system
  11973. @lisp
  11974. @include os-config-bare-bones.texi
  11975. @end lisp
  11976. This example should be self-describing. Some of the fields defined
  11977. above, such as @code{host-name} and @code{bootloader}, are mandatory.
  11978. Others, such as @code{packages} and @code{services}, can be omitted, in
  11979. which case they get a default value.
  11980. Below we discuss the effect of some of the most important fields
  11981. (@pxref{operating-system Reference}, for details about all the available
  11982. fields), and how to @dfn{instantiate} the operating system using
  11983. @command{guix system}.
  11984. @unnumberedsubsec Bootloader
  11985. @cindex legacy boot, on Intel machines
  11986. @cindex BIOS boot, on Intel machines
  11987. @cindex UEFI boot
  11988. @cindex EFI boot
  11989. The @code{bootloader} field describes the method that will be used to boot
  11990. your system. Machines based on Intel processors can boot in ``legacy'' BIOS
  11991. mode, as in the example above. However, more recent machines rely instead on
  11992. the @dfn{Unified Extensible Firmware Interface} (UEFI) to boot. In that case,
  11993. the @code{bootloader} field should contain something along these lines:
  11994. @lisp
  11995. (bootloader-configuration
  11996. (bootloader grub-efi-bootloader)
  11997. (targets '("/boot/efi")))
  11998. @end lisp
  11999. @xref{Bootloader Configuration}, for more information on the available
  12000. configuration options.
  12001. @unnumberedsubsec Globally-Visible Packages
  12002. @vindex %base-packages
  12003. The @code{packages} field lists packages that will be globally visible
  12004. on the system, for all user accounts---i.e., in every user's @env{PATH}
  12005. environment variable---in addition to the per-user profiles
  12006. (@pxref{Invoking guix package}). The @code{%base-packages} variable
  12007. provides all the tools one would expect for basic user and administrator
  12008. tasks---including the GNU Core Utilities, the GNU Networking Utilities,
  12009. the @command{mg} lightweight text editor, @command{find}, @command{grep},
  12010. etc. The example above adds GNU@tie{}Screen to those,
  12011. taken from the @code{(gnu packages screen)}
  12012. module (@pxref{Package Modules}). The
  12013. @code{(list package output)} syntax can be used to add a specific output
  12014. of a package:
  12015. @lisp
  12016. (use-modules (gnu packages))
  12017. (use-modules (gnu packages dns))
  12018. (operating-system
  12019. ;; ...
  12020. (packages (cons (list isc-bind "utils")
  12021. %base-packages)))
  12022. @end lisp
  12023. @findex specification->package
  12024. Referring to packages by variable name, like @code{isc-bind} above, has
  12025. the advantage of being unambiguous; it also allows typos and such to be
  12026. diagnosed right away as ``unbound variables''. The downside is that one
  12027. needs to know which module defines which package, and to augment the
  12028. @code{use-package-modules} line accordingly. To avoid that, one can use
  12029. the @code{specification->package} procedure of the @code{(gnu packages)}
  12030. module, which returns the best package for a given name or name and
  12031. version:
  12032. @lisp
  12033. (use-modules (gnu packages))
  12034. (operating-system
  12035. ;; ...
  12036. (packages (append (map specification->package
  12037. '("tcpdump" "htop" "gnupg@@2.0"))
  12038. %base-packages)))
  12039. @end lisp
  12040. @unnumberedsubsec System Services
  12041. @cindex services
  12042. @vindex %base-services
  12043. The @code{services} field lists @dfn{system services} to be made
  12044. available when the system starts (@pxref{Services}).
  12045. The @code{operating-system} declaration above specifies that, in
  12046. addition to the basic services, we want the OpenSSH secure shell
  12047. daemon listening on port 2222 (@pxref{Networking Services,
  12048. @code{openssh-service-type}}). Under the hood,
  12049. @code{openssh-service-type} arranges so that @command{sshd} is started with the
  12050. right command-line options, possibly with supporting configuration files
  12051. generated as needed (@pxref{Defining Services}).
  12052. @cindex customization, of services
  12053. @findex modify-services
  12054. Occasionally, instead of using the base services as is, you will want to
  12055. customize them. To do this, use @code{modify-services} (@pxref{Service
  12056. Reference, @code{modify-services}}) to modify the list.
  12057. @anchor{auto-login to TTY} For example, suppose you want to modify
  12058. @code{guix-daemon} and Mingetty (the console log-in) in the
  12059. @code{%base-services} list (@pxref{Base Services,
  12060. @code{%base-services}}). To do that, you can write the following in
  12061. your operating system declaration:
  12062. @lisp
  12063. (define %my-services
  12064. ;; My very own list of services.
  12065. (modify-services %base-services
  12066. (guix-service-type config =>
  12067. (guix-configuration
  12068. (inherit config)
  12069. ;; Fetch substitutes from example.org.
  12070. (substitute-urls
  12071. (list "https://example.org/guix"
  12072. "https://ci.guix.gnu.org"))))
  12073. (mingetty-service-type config =>
  12074. (mingetty-configuration
  12075. (inherit config)
  12076. ;; Automatically log in as "guest".
  12077. (auto-login "guest")))))
  12078. (operating-system
  12079. ;; @dots{}
  12080. (services %my-services))
  12081. @end lisp
  12082. This changes the configuration---i.e., the service parameters---of the
  12083. @code{guix-service-type} instance, and that of all the
  12084. @code{mingetty-service-type} instances in the @code{%base-services} list
  12085. (@pxref{Auto-Login to a Specific TTY, see the cookbook for how to
  12086. auto-login one user to a specific TTY,, guix-cookbook, GNU Guix Cookbook})).
  12087. Observe how this is accomplished: first, we arrange for the original
  12088. configuration to be bound to the identifier @code{config} in the
  12089. @var{body}, and then we write the @var{body} so that it evaluates to the
  12090. desired configuration. In particular, notice how we use @code{inherit}
  12091. to create a new configuration which has the same values as the old
  12092. configuration, but with a few modifications.
  12093. @cindex encrypted disk
  12094. The configuration for a typical ``desktop'' usage, with an encrypted
  12095. root partition, a swap file on the root partition, the X11 display
  12096. server, GNOME and Xfce (users can choose which of these desktop
  12097. environments to use at the log-in screen by pressing @kbd{F1}), network
  12098. management, power management, and more, would look like this:
  12099. @lisp
  12100. @include os-config-desktop.texi
  12101. @end lisp
  12102. A graphical system with a choice of lightweight window managers
  12103. instead of full-blown desktop environments would look like this:
  12104. @lisp
  12105. @include os-config-lightweight-desktop.texi
  12106. @end lisp
  12107. This example refers to the @file{/boot/efi} file system by its UUID,
  12108. @code{1234-ABCD}. Replace this UUID with the right UUID on your system,
  12109. as returned by the @command{blkid} command.
  12110. @xref{Desktop Services}, for the exact list of services provided by
  12111. @code{%desktop-services}. @xref{X.509 Certificates}, for background
  12112. information about the @code{nss-certs} package that is used here.
  12113. Again, @code{%desktop-services} is just a list of service objects. If
  12114. you want to remove services from there, you can do so using the
  12115. procedures for list filtering (@pxref{SRFI-1 Filtering and
  12116. Partitioning,,, guile, GNU Guile Reference Manual}). For instance, the
  12117. following expression returns a list that contains all the services in
  12118. @code{%desktop-services} minus the Avahi service:
  12119. @lisp
  12120. (remove (lambda (service)
  12121. (eq? (service-kind service) avahi-service-type))
  12122. %desktop-services)
  12123. @end lisp
  12124. Alternatively, the @code{modify-services} macro can be used:
  12125. @lisp
  12126. (modify-services %desktop-services
  12127. (delete avahi-service-type))
  12128. @end lisp
  12129. @unnumberedsubsec Instantiating the System
  12130. Assuming the @code{operating-system} declaration
  12131. is stored in the @file{my-system-config.scm}
  12132. file, the @command{guix system reconfigure my-system-config.scm} command
  12133. instantiates that configuration, and makes it the default GRUB boot
  12134. entry (@pxref{Invoking guix system}).
  12135. The normal way to change the system configuration is by updating this
  12136. file and re-running @command{guix system reconfigure}. One should never
  12137. have to touch files in @file{/etc} or to run commands that modify the
  12138. system state such as @command{useradd} or @command{grub-install}. In
  12139. fact, you must avoid that since that would not only void your warranty
  12140. but also prevent you from rolling back to previous versions of your
  12141. system, should you ever need to.
  12142. @cindex roll-back, of the operating system
  12143. Speaking of roll-back, each time you run @command{guix system
  12144. reconfigure}, a new @dfn{generation} of the system is created---without
  12145. modifying or deleting previous generations. Old system generations get
  12146. an entry in the bootloader boot menu, allowing you to boot them in case
  12147. something went wrong with the latest generation. Reassuring, no? The
  12148. @command{guix system list-generations} command lists the system
  12149. generations available on disk. It is also possible to roll back the
  12150. system via the commands @command{guix system roll-back} and
  12151. @command{guix system switch-generation}.
  12152. Although the @command{guix system reconfigure} command will not modify
  12153. previous generations, you must take care when the current generation is not
  12154. the latest (e.g., after invoking @command{guix system roll-back}), since
  12155. the operation might overwrite a later generation (@pxref{Invoking guix
  12156. system}).
  12157. @unnumberedsubsec The Programming Interface
  12158. At the Scheme level, the bulk of an @code{operating-system} declaration
  12159. is instantiated with the following monadic procedure (@pxref{The Store
  12160. Monad}):
  12161. @deffn {Monadic Procedure} operating-system-derivation os
  12162. Return a derivation that builds @var{os}, an @code{operating-system}
  12163. object (@pxref{Derivations}).
  12164. The output of the derivation is a single directory that refers to all
  12165. the packages, configuration files, and other supporting files needed to
  12166. instantiate @var{os}.
  12167. @end deffn
  12168. This procedure is provided by the @code{(gnu system)} module. Along
  12169. with @code{(gnu services)} (@pxref{Services}), this module contains the
  12170. guts of Guix System. Make sure to visit it!
  12171. @node operating-system Reference
  12172. @section @code{operating-system} Reference
  12173. This section summarizes all the options available in
  12174. @code{operating-system} declarations (@pxref{Using the Configuration
  12175. System}).
  12176. @deftp {Data Type} operating-system
  12177. This is the data type representing an operating system configuration.
  12178. By that, we mean all the global system configuration, not per-user
  12179. configuration (@pxref{Using the Configuration System}).
  12180. @table @asis
  12181. @item @code{kernel} (default: @code{linux-libre})
  12182. The package object of the operating system kernel to
  12183. use@footnote{Currently only the Linux-libre kernel is fully supported.
  12184. Using GNU@tie{}mach with the GNU@tie{}Hurd is experimental and only
  12185. available when building a virtual machine disk image.}.
  12186. @cindex hurd
  12187. @item @code{hurd} (default: @code{#f})
  12188. The package object of the Hurd to be started by the kernel. When this
  12189. field is set, produce a GNU/Hurd operating system. In that case,
  12190. @code{kernel} must also be set to the @code{gnumach} package---the
  12191. microkernel the Hurd runs on.
  12192. @quotation Warning
  12193. This feature is experimental and only supported for disk images.
  12194. @end quotation
  12195. @item @code{kernel-loadable-modules} (default: '())
  12196. A list of objects (usually packages) to collect loadable kernel modules
  12197. from--e.g. @code{(list ddcci-driver-linux)}.
  12198. @item @code{kernel-arguments} (default: @code{%default-kernel-arguments})
  12199. List of strings or gexps representing additional arguments to pass on
  12200. the command-line of the kernel---e.g., @code{("console=ttyS0")}.
  12201. @item @code{bootloader}
  12202. The system bootloader configuration object. @xref{Bootloader Configuration}.
  12203. @item @code{label}
  12204. This is the label (a string) as it appears in the bootloader's menu entry.
  12205. The default label includes the kernel name and version.
  12206. @item @code{keyboard-layout} (default: @code{#f})
  12207. This field specifies the keyboard layout to use in the console. It can be
  12208. either @code{#f}, in which case the default keyboard layout is used (usually
  12209. US English), or a @code{<keyboard-layout>} record. @xref{Keyboard Layout},
  12210. for more information.
  12211. This keyboard layout is in effect as soon as the kernel has booted. For
  12212. instance, it is the keyboard layout in effect when you type a passphrase if
  12213. your root file system is on a @code{luks-device-mapping} mapped device
  12214. (@pxref{Mapped Devices}).
  12215. @quotation Note
  12216. This does @emph{not} specify the keyboard layout used by the bootloader, nor
  12217. that used by the graphical display server. @xref{Bootloader Configuration},
  12218. for information on how to specify the bootloader's keyboard layout. @xref{X
  12219. Window}, for information on how to specify the keyboard layout used by the X
  12220. Window System.
  12221. @end quotation
  12222. @item @code{initrd-modules} (default: @code{%base-initrd-modules})
  12223. @cindex initrd
  12224. @cindex initial RAM disk
  12225. The list of Linux kernel modules that need to be available in the
  12226. initial RAM disk. @xref{Initial RAM Disk}.
  12227. @item @code{initrd} (default: @code{base-initrd})
  12228. A procedure that returns an initial RAM disk for the Linux
  12229. kernel. This field is provided to support low-level customization and
  12230. should rarely be needed for casual use. @xref{Initial RAM Disk}.
  12231. @item @code{firmware} (default: @code{%base-firmware})
  12232. @cindex firmware
  12233. List of firmware packages loadable by the operating system kernel.
  12234. The default includes firmware needed for Atheros- and Broadcom-based
  12235. WiFi devices (Linux-libre modules @code{ath9k} and @code{b43-open},
  12236. respectively). @xref{Hardware Considerations}, for more info on
  12237. supported hardware.
  12238. @item @code{host-name}
  12239. The host name.
  12240. @item @code{hosts-file}
  12241. @cindex hosts file
  12242. A file-like object (@pxref{G-Expressions, file-like objects}) for use as
  12243. @file{/etc/hosts} (@pxref{Host Names,,, libc, The GNU C Library
  12244. Reference Manual}). The default is a file with entries for
  12245. @code{localhost} and @var{host-name}.
  12246. @item @code{mapped-devices} (default: @code{'()})
  12247. A list of mapped devices. @xref{Mapped Devices}.
  12248. @item @code{file-systems}
  12249. A list of file systems. @xref{File Systems}.
  12250. @item @code{swap-devices} (default: @code{'()})
  12251. @cindex swap devices
  12252. A list of swap spaces. @xref{Swap Space}.
  12253. @item @code{users} (default: @code{%base-user-accounts})
  12254. @itemx @code{groups} (default: @code{%base-groups})
  12255. List of user accounts and groups. @xref{User Accounts}.
  12256. If the @code{users} list lacks a user account with UID@tie{}0, a
  12257. ``root'' account with UID@tie{}0 is automatically added.
  12258. @item @code{skeletons} (default: @code{(default-skeletons)})
  12259. A list of target file name/file-like object tuples (@pxref{G-Expressions,
  12260. file-like objects}). These are the skeleton files that will be added to
  12261. the home directory of newly-created user accounts.
  12262. For instance, a valid value may look like this:
  12263. @lisp
  12264. `((".bashrc" ,(plain-file "bashrc" "echo Hello\n"))
  12265. (".guile" ,(plain-file "guile"
  12266. "(use-modules (ice-9 readline))
  12267. (activate-readline)")))
  12268. @end lisp
  12269. @item @code{issue} (default: @code{%default-issue})
  12270. A string denoting the contents of the @file{/etc/issue} file, which is
  12271. displayed when users log in on a text console.
  12272. @item @code{packages} (default: @code{%base-packages})
  12273. A list of packages to be installed in the global profile, which is accessible
  12274. at @file{/run/current-system/profile}. Each element is either a package
  12275. variable or a package/output tuple. Here's a simple example of both:
  12276. @lisp
  12277. (cons* git ; the default "out" output
  12278. (list git "send-email") ; another output of git
  12279. %base-packages) ; the default set
  12280. @end lisp
  12281. The default set includes core utilities and it is good practice to
  12282. install non-core utilities in user profiles (@pxref{Invoking guix
  12283. package}).
  12284. @item @code{timezone}
  12285. A timezone identifying string---e.g., @code{"Europe/Paris"}.
  12286. You can run the @command{tzselect} command to find out which timezone
  12287. string corresponds to your region. Choosing an invalid timezone name
  12288. causes @command{guix system} to fail.
  12289. @item @code{locale} (default: @code{"en_US.utf8"})
  12290. The name of the default locale (@pxref{Locale Names,,, libc, The GNU C
  12291. Library Reference Manual}). @xref{Locales}, for more information.
  12292. @item @code{locale-definitions} (default: @code{%default-locale-definitions})
  12293. The list of locale definitions to be compiled and that may be used at
  12294. run time. @xref{Locales}.
  12295. @item @code{locale-libcs} (default: @code{(list @var{glibc})})
  12296. The list of GNU@tie{}libc packages whose locale data and tools are used
  12297. to build the locale definitions. @xref{Locales}, for compatibility
  12298. considerations that justify this option.
  12299. @item @code{name-service-switch} (default: @code{%default-nss})
  12300. Configuration of the libc name service switch (NSS)---a
  12301. @code{<name-service-switch>} object. @xref{Name Service Switch}, for
  12302. details.
  12303. @item @code{services} (default: @code{%base-services})
  12304. A list of service objects denoting system services. @xref{Services}.
  12305. @cindex essential services
  12306. @item @code{essential-services} (default: ...)
  12307. The list of ``essential services''---i.e., things like instances of
  12308. @code{system-service-type} and @code{host-name-service-type} (@pxref{Service
  12309. Reference}), which are derived from the operating system definition itself.
  12310. As a user you should @emph{never} need to touch this field.
  12311. @item @code{pam-services} (default: @code{(base-pam-services)})
  12312. @cindex PAM
  12313. @cindex pluggable authentication modules
  12314. Linux @dfn{pluggable authentication module} (PAM) services.
  12315. @c FIXME: Add xref to PAM services section.
  12316. @item @code{setuid-programs} (default: @code{%setuid-programs})
  12317. List of @code{<setuid-program>}. @xref{Setuid Programs}, for more
  12318. information.
  12319. @item @code{sudoers-file} (default: @code{%sudoers-specification})
  12320. @cindex sudoers file
  12321. The contents of the @file{/etc/sudoers} file as a file-like object
  12322. (@pxref{G-Expressions, @code{local-file} and @code{plain-file}}).
  12323. This file specifies which users can use the @command{sudo} command, what
  12324. they are allowed to do, and what privileges they may gain. The default
  12325. is that only @code{root} and members of the @code{wheel} group may use
  12326. @code{sudo}.
  12327. @end table
  12328. @deffn {Scheme Syntax} this-operating-system
  12329. When used in the @emph{lexical scope} of an operating system field definition,
  12330. this identifier resolves to the operating system being defined.
  12331. The example below shows how to refer to the operating system being defined in
  12332. the definition of the @code{label} field:
  12333. @lisp
  12334. (use-modules (gnu) (guix))
  12335. (operating-system
  12336. ;; ...
  12337. (label (package-full-name
  12338. (operating-system-kernel this-operating-system))))
  12339. @end lisp
  12340. It is an error to refer to @code{this-operating-system} outside an operating
  12341. system definition.
  12342. @end deffn
  12343. @end deftp
  12344. @node File Systems
  12345. @section File Systems
  12346. The list of file systems to be mounted is specified in the
  12347. @code{file-systems} field of the operating system declaration
  12348. (@pxref{Using the Configuration System}). Each file system is declared
  12349. using the @code{file-system} form, like this:
  12350. @lisp
  12351. (file-system
  12352. (mount-point "/home")
  12353. (device "/dev/sda3")
  12354. (type "ext4"))
  12355. @end lisp
  12356. As usual, some of the fields are mandatory---those shown in the example
  12357. above---while others can be omitted. These are described below.
  12358. @deftp {Data Type} file-system
  12359. Objects of this type represent file systems to be mounted. They
  12360. contain the following members:
  12361. @table @asis
  12362. @item @code{type}
  12363. This is a string specifying the type of the file system---e.g.,
  12364. @code{"ext4"}.
  12365. @item @code{mount-point}
  12366. This designates the place where the file system is to be mounted.
  12367. @item @code{device}
  12368. This names the ``source'' of the file system. It can be one of three
  12369. things: a file system label, a file system UUID, or the name of a
  12370. @file{/dev} node. Labels and UUIDs offer a way to refer to file
  12371. systems without having to hard-code their actual device
  12372. name@footnote{Note that, while it is tempting to use
  12373. @file{/dev/disk/by-uuid} and similar device names to achieve the same
  12374. result, this is not recommended: These special device nodes are created
  12375. by the udev daemon and may be unavailable at the time the device is
  12376. mounted.}.
  12377. @findex file-system-label
  12378. File system labels are created using the @code{file-system-label}
  12379. procedure, UUIDs are created using @code{uuid}, and @file{/dev} node are
  12380. plain strings. Here's an example of a file system referred to by its
  12381. label, as shown by the @command{e2label} command:
  12382. @lisp
  12383. (file-system
  12384. (mount-point "/home")
  12385. (type "ext4")
  12386. (device (file-system-label "my-home")))
  12387. @end lisp
  12388. @findex uuid
  12389. UUIDs are converted from their string representation (as shown by the
  12390. @command{tune2fs -l} command) using the @code{uuid} form@footnote{The
  12391. @code{uuid} form expects 16-byte UUIDs as defined in
  12392. @uref{https://tools.ietf.org/html/rfc4122, RFC@tie{}4122}. This is the
  12393. form of UUID used by the ext2 family of file systems and others, but it
  12394. is different from ``UUIDs'' found in FAT file systems, for instance.},
  12395. like this:
  12396. @lisp
  12397. (file-system
  12398. (mount-point "/home")
  12399. (type "ext4")
  12400. (device (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb")))
  12401. @end lisp
  12402. When the source of a file system is a mapped device (@pxref{Mapped
  12403. Devices}), its @code{device} field @emph{must} refer to the mapped
  12404. device name---e.g., @file{"/dev/mapper/root-partition"}.
  12405. This is required so that
  12406. the system knows that mounting the file system depends on having the
  12407. corresponding device mapping established.
  12408. @item @code{flags} (default: @code{'()})
  12409. This is a list of symbols denoting mount flags. Recognized flags
  12410. include @code{read-only}, @code{bind-mount}, @code{no-dev} (disallow
  12411. access to special files), @code{no-suid} (ignore setuid and setgid
  12412. bits), @code{no-atime} (do not update file access times),
  12413. @code{strict-atime} (update file access time), @code{lazy-time} (only
  12414. update time on the in-memory version of the file inode), and
  12415. @code{no-exec} (disallow program execution).
  12416. @xref{Mount-Unmount-Remount,,, libc, The GNU C Library Reference
  12417. Manual}, for more information on these flags.
  12418. @item @code{options} (default: @code{#f})
  12419. This is either @code{#f}, or a string denoting mount options passed to
  12420. the file system driver. @xref{Mount-Unmount-Remount,,, libc, The GNU C
  12421. Library Reference Manual}, for details and run @command{man 8 mount} for
  12422. options for various file systems. Note that the
  12423. @code{file-system-options->alist} and @code{alist->file-system-options}
  12424. procedures from @code{(gnu system file-systems)} can be used to convert
  12425. file system options given as an association list to the string
  12426. representation, and vice-versa.
  12427. @item @code{mount?} (default: @code{#t})
  12428. This value indicates whether to automatically mount the file system when
  12429. the system is brought up. When set to @code{#f}, the file system gets
  12430. an entry in @file{/etc/fstab} (read by the @command{mount} command) but
  12431. is not automatically mounted.
  12432. @item @code{needed-for-boot?} (default: @code{#f})
  12433. This Boolean value indicates whether the file system is needed when
  12434. booting. If that is true, then the file system is mounted when the
  12435. initial RAM disk (initrd) is loaded. This is always the case, for
  12436. instance, for the root file system.
  12437. @item @code{check?} (default: @code{#t})
  12438. This Boolean indicates whether the file system should be checked for
  12439. errors before being mounted. How and when this happens can be further
  12440. adjusted with the following options.
  12441. @item @code{skip-check-if-clean?} (default: @code{#t})
  12442. When true, this Boolean indicates that a file system check triggered
  12443. by @code{check?} may exit early if the file system is marked as
  12444. ``clean'', meaning that it was previously correctly unmounted and
  12445. should not contain errors.
  12446. Setting this to false will always force a full consistency check when
  12447. @code{check?} is true. This may take a very long time and is not
  12448. recommended on healthy systems---in fact, it may reduce reliability!
  12449. Conversely, some primitive file systems like @code{fat} do not keep
  12450. track of clean shutdowns and will perform a full scan regardless of the
  12451. value of this option.
  12452. @item @code{repair} (default: @code{'preen})
  12453. When @code{check?} finds errors, it can (try to) repair them and
  12454. continue booting. This option controls when and how to do so.
  12455. If false, try not to modify the file system at all. Checking certain
  12456. file systems like @code{jfs} may still write to the device to replay
  12457. the journal. No repairs will be attempted.
  12458. If @code{#t}, try to repair any errors found and assume ``yes'' to
  12459. all questions. This will fix the most errors, but may be risky.
  12460. If @code{'preen}, repair only errors that are safe to fix without
  12461. human interaction. What that means is left up to the developers of
  12462. each file system and may be equivalent to ``none'' or ``all''.
  12463. @item @code{create-mount-point?} (default: @code{#f})
  12464. When true, the mount point is created if it does not exist yet.
  12465. @item @code{mount-may-fail?} (default: @code{#f})
  12466. When true, this indicates that mounting this file system can fail but
  12467. that should not be considered an error. This is useful in unusual
  12468. cases; an example of this is @code{efivarfs}, a file system that can
  12469. only be mounted on EFI/UEFI systems.
  12470. @item @code{dependencies} (default: @code{'()})
  12471. This is a list of @code{<file-system>} or @code{<mapped-device>} objects
  12472. representing file systems that must be mounted or mapped devices that
  12473. must be opened before (and unmounted or closed after) this one.
  12474. As an example, consider a hierarchy of mounts: @file{/sys/fs/cgroup} is
  12475. a dependency of @file{/sys/fs/cgroup/cpu} and
  12476. @file{/sys/fs/cgroup/memory}.
  12477. Another example is a file system that depends on a mapped device, for
  12478. example for an encrypted partition (@pxref{Mapped Devices}).
  12479. @end table
  12480. @end deftp
  12481. @deffn {Scheme Procedure} file-system-label @var{str}
  12482. This procedure returns an opaque file system label from @var{str}, a
  12483. string:
  12484. @lisp
  12485. (file-system-label "home")
  12486. @result{} #<file-system-label "home">
  12487. @end lisp
  12488. File system labels are used to refer to file systems by label rather
  12489. than by device name. See above for examples.
  12490. @end deffn
  12491. The @code{(gnu system file-systems)} exports the following useful
  12492. variables.
  12493. @defvr {Scheme Variable} %base-file-systems
  12494. These are essential file systems that are required on normal systems,
  12495. such as @code{%pseudo-terminal-file-system} and @code{%immutable-store} (see
  12496. below). Operating system declarations should always contain at least
  12497. these.
  12498. @end defvr
  12499. @defvr {Scheme Variable} %pseudo-terminal-file-system
  12500. This is the file system to be mounted as @file{/dev/pts}. It supports
  12501. @dfn{pseudo-terminals} created @i{via} @code{openpty} and similar
  12502. functions (@pxref{Pseudo-Terminals,,, libc, The GNU C Library Reference
  12503. Manual}). Pseudo-terminals are used by terminal emulators such as
  12504. @command{xterm}.
  12505. @end defvr
  12506. @defvr {Scheme Variable} %shared-memory-file-system
  12507. This file system is mounted as @file{/dev/shm} and is used to support
  12508. memory sharing across processes (@pxref{Memory-mapped I/O,
  12509. @code{shm_open},, libc, The GNU C Library Reference Manual}).
  12510. @end defvr
  12511. @defvr {Scheme Variable} %immutable-store
  12512. This file system performs a read-only ``bind mount'' of
  12513. @file{/gnu/store}, making it read-only for all the users including
  12514. @code{root}. This prevents against accidental modification by software
  12515. running as @code{root} or by system administrators.
  12516. The daemon itself is still able to write to the store: it remounts it
  12517. read-write in its own ``name space.''
  12518. @end defvr
  12519. @defvr {Scheme Variable} %binary-format-file-system
  12520. The @code{binfmt_misc} file system, which allows handling of arbitrary
  12521. executable file types to be delegated to user space. This requires the
  12522. @code{binfmt.ko} kernel module to be loaded.
  12523. @end defvr
  12524. @defvr {Scheme Variable} %fuse-control-file-system
  12525. The @code{fusectl} file system, which allows unprivileged users to mount
  12526. and unmount user-space FUSE file systems. This requires the
  12527. @code{fuse.ko} kernel module to be loaded.
  12528. @end defvr
  12529. The @code{(gnu system uuid)} module provides tools to deal with file
  12530. system ``unique identifiers'' (UUIDs).
  12531. @deffn {Scheme Procedure} uuid @var{str} [@var{type}]
  12532. Return an opaque UUID (unique identifier) object of the given @var{type}
  12533. (a symbol) by parsing @var{str} (a string):
  12534. @lisp
  12535. (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb")
  12536. @result{} #<<uuid> type: dce bv: @dots{}>
  12537. (uuid "1234-ABCD" 'fat)
  12538. @result{} #<<uuid> type: fat bv: @dots{}>
  12539. @end lisp
  12540. @var{type} may be one of @code{dce}, @code{iso9660}, @code{fat},
  12541. @code{ntfs}, or one of the commonly found synonyms for these.
  12542. UUIDs are another way to unambiguously refer to file systems in
  12543. operating system configuration. See the examples above.
  12544. @end deffn
  12545. @node Btrfs file system
  12546. @subsection Btrfs file system
  12547. The Btrfs has special features, such as subvolumes, that merit being
  12548. explained in more details. The following section attempts to cover
  12549. basic as well as complex uses of a Btrfs file system with the Guix
  12550. System.
  12551. In its simplest usage, a Btrfs file system can be described, for
  12552. example, by:
  12553. @lisp
  12554. (file-system
  12555. (mount-point "/home")
  12556. (type "btrfs")
  12557. (device (file-system-label "my-home")))
  12558. @end lisp
  12559. The example below is more complex, as it makes use of a Btrfs
  12560. subvolume, named @code{rootfs}. The parent Btrfs file system is labeled
  12561. @code{my-btrfs-pool}, and is located on an encrypted device (hence the
  12562. dependency on @code{mapped-devices}):
  12563. @lisp
  12564. (file-system
  12565. (device (file-system-label "my-btrfs-pool"))
  12566. (mount-point "/")
  12567. (type "btrfs")
  12568. (options "subvol=rootfs")
  12569. (dependencies mapped-devices))
  12570. @end lisp
  12571. Some bootloaders, for example GRUB, only mount a Btrfs partition at its
  12572. top level during the early boot, and rely on their configuration to
  12573. refer to the correct subvolume path within that top level. The
  12574. bootloaders operating in this way typically produce their configuration
  12575. on a running system where the Btrfs partitions are already mounted and
  12576. where the subvolume information is readily available. As an example,
  12577. @command{grub-mkconfig}, the configuration generator command shipped
  12578. with GRUB, reads @file{/proc/self/mountinfo} to determine the top-level
  12579. path of a subvolume.
  12580. The Guix System produces a bootloader configuration using the operating
  12581. system configuration as its sole input; it is therefore necessary to
  12582. extract the subvolume name on which @file{/gnu/store} lives (if any)
  12583. from that operating system configuration. To better illustrate,
  12584. consider a subvolume named 'rootfs' which contains the root file system
  12585. data. In such situation, the GRUB bootloader would only see the top
  12586. level of the root Btrfs partition, e.g.:
  12587. @example
  12588. / (top level)
  12589. ├── rootfs (subvolume directory)
  12590. ├── gnu (normal directory)
  12591. ├── store (normal directory)
  12592. [...]
  12593. @end example
  12594. Thus, the subvolume name must be prepended to the @file{/gnu/store} path
  12595. of the kernel, initrd binaries and any other files referred to in the
  12596. GRUB configuration that must be found during the early boot.
  12597. The next example shows a nested hierarchy of subvolumes and
  12598. directories:
  12599. @example
  12600. / (top level)
  12601. ├── rootfs (subvolume)
  12602. ├── gnu (normal directory)
  12603. ├── store (subvolume)
  12604. [...]
  12605. @end example
  12606. This scenario would work without mounting the 'store' subvolume.
  12607. Mounting 'rootfs' is sufficient, since the subvolume name matches its
  12608. intended mount point in the file system hierarchy. Alternatively, the
  12609. 'store' subvolume could be referred to by setting the @code{subvol}
  12610. option to either @code{/rootfs/gnu/store} or @code{rootfs/gnu/store}.
  12611. Finally, a more contrived example of nested subvolumes:
  12612. @example
  12613. / (top level)
  12614. ├── root-snapshots (subvolume)
  12615. ├── root-current (subvolume)
  12616. ├── guix-store (subvolume)
  12617. [...]
  12618. @end example
  12619. Here, the 'guix-store' subvolume doesn't match its intended mount point,
  12620. so it is necessary to mount it. The subvolume must be fully specified,
  12621. by passing its file name to the @code{subvol} option. To illustrate,
  12622. the 'guix-store' subvolume could be mounted on @file{/gnu/store} by using
  12623. a file system declaration such as:
  12624. @lisp
  12625. (file-system
  12626. (device (file-system-label "btrfs-pool-1"))
  12627. (mount-point "/gnu/store")
  12628. (type "btrfs")
  12629. (options "subvol=root-snapshots/root-current/guix-store,\
  12630. compress-force=zstd,space_cache=v2"))
  12631. @end lisp
  12632. @node Mapped Devices
  12633. @section Mapped Devices
  12634. @cindex device mapping
  12635. @cindex mapped devices
  12636. The Linux kernel has a notion of @dfn{device mapping}: a block device,
  12637. such as a hard disk partition, can be @dfn{mapped} into another device,
  12638. usually in @code{/dev/mapper/},
  12639. with additional processing over the data that flows through
  12640. it@footnote{Note that the GNU@tie{}Hurd makes no difference between the
  12641. concept of a ``mapped device'' and that of a file system: both boil down
  12642. to @emph{translating} input/output operations made on a file to
  12643. operations on its backing store. Thus, the Hurd implements mapped
  12644. devices, like file systems, using the generic @dfn{translator} mechanism
  12645. (@pxref{Translators,,, hurd, The GNU Hurd Reference Manual}).}. A
  12646. typical example is encryption device mapping: all writes to the mapped
  12647. device are encrypted, and all reads are deciphered, transparently.
  12648. Guix extends this notion by considering any device or set of devices that
  12649. are @dfn{transformed} in some way to create a new device; for instance,
  12650. RAID devices are obtained by @dfn{assembling} several other devices, such
  12651. as hard disks or partitions, into a new one that behaves as one partition.
  12652. Mapped devices are declared using the @code{mapped-device} form,
  12653. defined as follows; for examples, see below.
  12654. @deftp {Data Type} mapped-device
  12655. Objects of this type represent device mappings that will be made when
  12656. the system boots up.
  12657. @table @code
  12658. @item source
  12659. This is either a string specifying the name of the block device to be mapped,
  12660. such as @code{"/dev/sda3"}, or a list of such strings when several devices
  12661. need to be assembled for creating a new one. In case of LVM this is a
  12662. string specifying name of the volume group to be mapped.
  12663. @item target
  12664. This string specifies the name of the resulting mapped device. For
  12665. kernel mappers such as encrypted devices of type @code{luks-device-mapping},
  12666. specifying @code{"my-partition"} leads to the creation of
  12667. the @code{"/dev/mapper/my-partition"} device.
  12668. For RAID devices of type @code{raid-device-mapping}, the full device name
  12669. such as @code{"/dev/md0"} needs to be given.
  12670. LVM logical volumes of type @code{lvm-device-mapping} need to
  12671. be specified as @code{"VGNAME-LVNAME"}.
  12672. @item targets
  12673. This list of strings specifies names of the resulting mapped devices in case
  12674. there are several. The format is identical to @var{target}.
  12675. @item type
  12676. This must be a @code{mapped-device-kind} object, which specifies how
  12677. @var{source} is mapped to @var{target}.
  12678. @end table
  12679. @end deftp
  12680. @defvr {Scheme Variable} luks-device-mapping
  12681. This defines LUKS block device encryption using the @command{cryptsetup}
  12682. command from the package with the same name. It relies on the
  12683. @code{dm-crypt} Linux kernel module.
  12684. @end defvr
  12685. @defvr {Scheme Variable} raid-device-mapping
  12686. This defines a RAID device, which is assembled using the @code{mdadm}
  12687. command from the package with the same name. It requires a Linux kernel
  12688. module for the appropriate RAID level to be loaded, such as @code{raid456}
  12689. for RAID-4, RAID-5 or RAID-6, or @code{raid10} for RAID-10.
  12690. @end defvr
  12691. @cindex LVM, logical volume manager
  12692. @defvr {Scheme Variable} lvm-device-mapping
  12693. This defines one or more logical volumes for the Linux
  12694. @uref{https://www.sourceware.org/lvm2/, Logical Volume Manager (LVM)}.
  12695. The volume group is activated by the @command{vgchange} command from the
  12696. @code{lvm2} package.
  12697. @end defvr
  12698. @cindex disk encryption
  12699. @cindex LUKS
  12700. The following example specifies a mapping from @file{/dev/sda3} to
  12701. @file{/dev/mapper/home} using LUKS---the
  12702. @url{https://gitlab.com/cryptsetup/cryptsetup,Linux Unified Key Setup}, a
  12703. standard mechanism for disk encryption.
  12704. The @file{/dev/mapper/home}
  12705. device can then be used as the @code{device} of a @code{file-system}
  12706. declaration (@pxref{File Systems}).
  12707. @lisp
  12708. (mapped-device
  12709. (source "/dev/sda3")
  12710. (target "home")
  12711. (type luks-device-mapping))
  12712. @end lisp
  12713. Alternatively, to become independent of device numbering, one may obtain
  12714. the LUKS UUID (@dfn{unique identifier}) of the source device by a
  12715. command like:
  12716. @example
  12717. cryptsetup luksUUID /dev/sda3
  12718. @end example
  12719. and use it as follows:
  12720. @lisp
  12721. (mapped-device
  12722. (source (uuid "cb67fc72-0d54-4c88-9d4b-b225f30b0f44"))
  12723. (target "home")
  12724. (type luks-device-mapping))
  12725. @end lisp
  12726. @cindex swap encryption
  12727. It is also desirable to encrypt swap space, since swap space may contain
  12728. sensitive data. One way to accomplish that is to use a swap file in a
  12729. file system on a device mapped via LUKS encryption. In this way, the
  12730. swap file is encrypted because the entire device is encrypted.
  12731. @xref{Swap Space}, or @xref{Preparing for Installation,,Disk
  12732. Partitioning}, for an example.
  12733. A RAID device formed of the partitions @file{/dev/sda1} and @file{/dev/sdb1}
  12734. may be declared as follows:
  12735. @lisp
  12736. (mapped-device
  12737. (source (list "/dev/sda1" "/dev/sdb1"))
  12738. (target "/dev/md0")
  12739. (type raid-device-mapping))
  12740. @end lisp
  12741. The @file{/dev/md0} device can then be used as the @code{device} of a
  12742. @code{file-system} declaration (@pxref{File Systems}).
  12743. Note that the RAID level need not be given; it is chosen during the
  12744. initial creation and formatting of the RAID device and is determined
  12745. automatically later.
  12746. LVM logical volumes ``alpha'' and ``beta'' from volume group ``vg0'' can
  12747. be declared as follows:
  12748. @lisp
  12749. (mapped-device
  12750. (source "vg0")
  12751. (targets (list "vg0-alpha" "vg0-beta"))
  12752. (type lvm-device-mapping))
  12753. @end lisp
  12754. Devices @file{/dev/mapper/vg0-alpha} and @file{/dev/mapper/vg0-beta} can
  12755. then be used as the @code{device} of a @code{file-system} declaration
  12756. (@pxref{File Systems}).
  12757. @node Swap Space
  12758. @section Swap Space
  12759. @cindex swap space
  12760. Swap space, as it is commonly called, is a disk area specifically
  12761. designated for paging: the process in charge of memory management
  12762. (the Linux kernel or Hurd's default pager) can decide that some memory
  12763. pages stored in RAM which belong to a running program but are unused
  12764. should be stored on disk instead. It unloads those from the RAM,
  12765. freeing up precious fast memory, and writes them to the swap space. If
  12766. the program tries to access that very page, the memory management
  12767. process loads it back into memory for the program to use.
  12768. A common misconception about swap is that it is only useful when small
  12769. amounts of RAM are available to the system. However, it should be noted
  12770. that kernels often use all available RAM for disk access caching to make
  12771. I/O faster, and thus paging out unused portions of program memory will
  12772. expand the RAM available for such caching.
  12773. For a more detailed description of how memory is managed from the
  12774. viewpoint of a monolithic kernel, @xref{Memory
  12775. Concepts,,, libc, The GNU C Library Reference Manual}.
  12776. The Linux kernel has support for swap partitions and swap files: the
  12777. former uses a whole disk partition for paging, whereas the second uses a
  12778. file on a file system for that (the file system driver needs to support
  12779. it). On a comparable setup, both have the same performance, so one
  12780. should consider ease of use when deciding between them. Partitions are
  12781. ``simpler'' and do not need file system support, but need to be
  12782. allocated at disk formatting time (logical volumes notwithstanding),
  12783. whereas files can be allocated and deallocated at any time.
  12784. Note that swap space is not zeroed on shutdown, so sensitive data (such
  12785. as passwords) may linger on it if it was paged out. As such, you should
  12786. consider having your swap reside on an encrypted device (@pxref{Mapped
  12787. Devices}).
  12788. @deftp {Data Type} swap-space
  12789. Objects of this type represent swap spaces. They contain the following
  12790. members:
  12791. @table @asis
  12792. @item @code{target}
  12793. The device or file to use, either a UUID, a @code{file-system-label} or
  12794. a string, as in the definition of a @code{file-system} (@pxref{File
  12795. Systems}).
  12796. @item @code{dependencies} (default: @code{'()})
  12797. A list of @code{file-system} or @code{mapped-device} objects, upon which
  12798. the availability of the space depends. Note that just like for
  12799. @code{file-system} objects, dependencies which are needed for boot and
  12800. mounted in early userspace are not managed by the Shepherd, and so
  12801. automatically filtered out for you.
  12802. @item @code{priority} (default: @code{#f})
  12803. Only supported by the Linux kernel. Either @code{#f} to disable swap
  12804. priority, or an integer between 0 and 32767. The kernel will first use
  12805. swap spaces of higher priority when paging, and use same priority spaces
  12806. on a round-robin basis. The kernel will use swap spaces without a set
  12807. priority after prioritized spaces, and in the order that they appeared in
  12808. (not round-robin).
  12809. @item @code{discard?} (default: @code{#f})
  12810. Only supported by the Linux kernel. When true, the kernel will notify
  12811. the disk controller of discarded pages, for example with the TRIM
  12812. operation on Solid State Drives.
  12813. @end table
  12814. @end deftp
  12815. Here are some examples:
  12816. @lisp
  12817. (swap-space (target (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb")))
  12818. @end lisp
  12819. Use the swap partition with the given UUID@. You can learn the UUID of a
  12820. Linux swap partition by running @command{swaplabel @var{device}}, where
  12821. @var{device} is the @file{/dev} file name of that partition.
  12822. @lisp
  12823. (swap-space
  12824. (target (file-system-label "swap"))
  12825. (dependencies mapped-devices))
  12826. @end lisp
  12827. Use the partition with label @code{swap}, which can be found after all
  12828. the @var{mapped-devices} mapped devices have been opened. Again, the
  12829. @command{swaplabel} command allows you to view and change the label of a
  12830. Linux swap partition.
  12831. Here's a more involved example with the corresponding @code{file-systems} part
  12832. of an @code{operating-system} declaration.
  12833. @lisp
  12834. (file-systems
  12835. (list (file-system
  12836. (device (file-system-label "root"))
  12837. (mount-point "/")
  12838. (type "ext4"))
  12839. (file-system
  12840. (device (file-system-label "btrfs"))
  12841. (mount-point "/btrfs")
  12842. (type "btrfs"))))
  12843. (swap-devices
  12844. (list
  12845. (swap-space
  12846. (target "/btrfs/swapfile")
  12847. (dependencies (filter (file-system-mount-point-predicate "/btrfs")
  12848. file-systems)))))
  12849. @end lisp
  12850. Use the file @file{/btrfs/swapfile} as swap space, which depends on the
  12851. file system mounted at @file{/btrfs}. Note how we use Guile's filter to
  12852. select the file system in an elegant fashion!
  12853. @node User Accounts
  12854. @section User Accounts
  12855. @cindex users
  12856. @cindex accounts
  12857. @cindex user accounts
  12858. User accounts and groups are entirely managed through the
  12859. @code{operating-system} declaration. They are specified with the
  12860. @code{user-account} and @code{user-group} forms:
  12861. @lisp
  12862. (user-account
  12863. (name "alice")
  12864. (group "users")
  12865. (supplementary-groups '("wheel" ;allow use of sudo, etc.
  12866. "audio" ;sound card
  12867. "video" ;video devices such as webcams
  12868. "cdrom")) ;the good ol' CD-ROM
  12869. (comment "Bob's sister"))
  12870. @end lisp
  12871. Here's a user account that uses a different shell and a custom home
  12872. directory (the default would be @file{"/home/bob"}):
  12873. @lisp
  12874. (user-account
  12875. (name "bob")
  12876. (group "users")
  12877. (comment "Alice's bro")
  12878. (shell (file-append zsh "/bin/zsh"))
  12879. (home-directory "/home/robert"))
  12880. @end lisp
  12881. When booting or upon completion of @command{guix system reconfigure},
  12882. the system ensures that only the user accounts and groups specified in
  12883. the @code{operating-system} declaration exist, and with the specified
  12884. properties. Thus, account or group creations or modifications made by
  12885. directly invoking commands such as @command{useradd} are lost upon
  12886. reconfiguration or reboot. This ensures that the system remains exactly
  12887. as declared.
  12888. @deftp {Data Type} user-account
  12889. Objects of this type represent user accounts. The following members may
  12890. be specified:
  12891. @table @asis
  12892. @item @code{name}
  12893. The name of the user account.
  12894. @item @code{group}
  12895. @cindex groups
  12896. This is the name (a string) or identifier (a number) of the user group
  12897. this account belongs to.
  12898. @item @code{supplementary-groups} (default: @code{'()})
  12899. Optionally, this can be defined as a list of group names that this
  12900. account belongs to.
  12901. @item @code{uid} (default: @code{#f})
  12902. This is the user ID for this account (a number), or @code{#f}. In the
  12903. latter case, a number is automatically chosen by the system when the
  12904. account is created.
  12905. @item @code{comment} (default: @code{""})
  12906. A comment about the account, such as the account owner's full name.
  12907. Note that, for non-system accounts, users are free to change their real
  12908. name as it appears in @file{/etc/passwd} using the @command{chfn}
  12909. command. When they do, their choice prevails over the system
  12910. administrator's choice; reconfiguring does @emph{not} change their name.
  12911. @item @code{home-directory}
  12912. This is the name of the home directory for the account.
  12913. @item @code{create-home-directory?} (default: @code{#t})
  12914. Indicates whether the home directory of this account should be created
  12915. if it does not exist yet.
  12916. @item @code{shell} (default: Bash)
  12917. This is a G-expression denoting the file name of a program to be used as
  12918. the shell (@pxref{G-Expressions}). For example, you would refer to the
  12919. Bash executable like this:
  12920. @lisp
  12921. (file-append bash "/bin/bash")
  12922. @end lisp
  12923. @noindent
  12924. ... and to the Zsh executable like that:
  12925. @lisp
  12926. (file-append zsh "/bin/zsh")
  12927. @end lisp
  12928. @item @code{system?} (default: @code{#f})
  12929. This Boolean value indicates whether the account is a ``system''
  12930. account. System accounts are sometimes treated specially; for instance,
  12931. graphical login managers do not list them.
  12932. @anchor{user-account-password}
  12933. @cindex password, for user accounts
  12934. @item @code{password} (default: @code{#f})
  12935. You would normally leave this field to @code{#f}, initialize user
  12936. passwords as @code{root} with the @command{passwd} command, and then let
  12937. users change it with @command{passwd}. Passwords set with
  12938. @command{passwd} are of course preserved across reboot and
  12939. reconfiguration.
  12940. If you @emph{do} want to set an initial password for an account, then
  12941. this field must contain the encrypted password, as a string. You can use the
  12942. @code{crypt} procedure for this purpose:
  12943. @lisp
  12944. (user-account
  12945. (name "charlie")
  12946. (group "users")
  12947. ;; Specify a SHA-512-hashed initial password.
  12948. (password (crypt "InitialPassword!" "$6$abc")))
  12949. @end lisp
  12950. @quotation Note
  12951. The hash of this initial password will be available in a file in
  12952. @file{/gnu/store}, readable by all the users, so this method must be used with
  12953. care.
  12954. @end quotation
  12955. @xref{Passphrase Storage,,, libc, The GNU C Library Reference Manual}, for
  12956. more information on password encryption, and @ref{Encryption,,, guile, GNU
  12957. Guile Reference Manual}, for information on Guile's @code{crypt} procedure.
  12958. @end table
  12959. @end deftp
  12960. @cindex groups
  12961. User group declarations are even simpler:
  12962. @lisp
  12963. (user-group (name "students"))
  12964. @end lisp
  12965. @deftp {Data Type} user-group
  12966. This type is for, well, user groups. There are just a few fields:
  12967. @table @asis
  12968. @item @code{name}
  12969. The name of the group.
  12970. @item @code{id} (default: @code{#f})
  12971. The group identifier (a number). If @code{#f}, a new number is
  12972. automatically allocated when the group is created.
  12973. @item @code{system?} (default: @code{#f})
  12974. This Boolean value indicates whether the group is a ``system'' group.
  12975. System groups have low numerical IDs.
  12976. @item @code{password} (default: @code{#f})
  12977. What, user groups can have a password? Well, apparently yes. Unless
  12978. @code{#f}, this field specifies the password of the group.
  12979. @end table
  12980. @end deftp
  12981. For convenience, a variable lists all the basic user groups one may
  12982. expect:
  12983. @defvr {Scheme Variable} %base-groups
  12984. This is the list of basic user groups that users and/or packages expect
  12985. to be present on the system. This includes groups such as ``root'',
  12986. ``wheel'', and ``users'', as well as groups used to control access to
  12987. specific devices such as ``audio'', ``disk'', and ``cdrom''.
  12988. @end defvr
  12989. @defvr {Scheme Variable} %base-user-accounts
  12990. This is the list of basic system accounts that programs may expect to
  12991. find on a GNU/Linux system, such as the ``nobody'' account.
  12992. Note that the ``root'' account is not included here. It is a
  12993. special-case and is automatically added whether or not it is specified.
  12994. @end defvr
  12995. @node Keyboard Layout
  12996. @section Keyboard Layout
  12997. @cindex keyboard layout
  12998. @cindex keymap
  12999. To specify what each key of your keyboard does, you need to tell the operating
  13000. system what @dfn{keyboard layout} you want to use. The default, when nothing
  13001. is specified, is the US English QWERTY layout for 105-key PC keyboards.
  13002. However, German speakers will usually prefer the German QWERTZ layout, French
  13003. speakers will want the AZERTY layout, and so on; hackers might prefer Dvorak
  13004. or bépo, and they might even want to further customize the effect of some of
  13005. the keys. This section explains how to get that done.
  13006. @cindex keyboard layout, definition
  13007. There are three components that will want to know about your keyboard layout:
  13008. @itemize
  13009. @item
  13010. The @emph{bootloader} may want to know what keyboard layout you want to use
  13011. (@pxref{Bootloader Configuration, @code{keyboard-layout}}). This is useful if
  13012. you want, for instance, to make sure that you can type the passphrase of your
  13013. encrypted root partition using the right layout.
  13014. @item
  13015. The @emph{operating system kernel}, Linux, will need that so that the console
  13016. is properly configured (@pxref{operating-system Reference,
  13017. @code{keyboard-layout}}).
  13018. @item
  13019. The @emph{graphical display server}, usually Xorg, also has its own idea of
  13020. the keyboard layout (@pxref{X Window, @code{keyboard-layout}}).
  13021. @end itemize
  13022. Guix allows you to configure all three separately but, fortunately, it allows
  13023. you to share the same keyboard layout for all three components.
  13024. @cindex XKB, keyboard layouts
  13025. Keyboard layouts are represented by records created by the
  13026. @code{keyboard-layout} procedure of @code{(gnu system keyboard)}. Following
  13027. the X Keyboard extension (XKB), each layout has four attributes: a name (often
  13028. a language code such as ``fi'' for Finnish or ``jp'' for Japanese), an
  13029. optional variant name, an optional keyboard model name, and a possibly empty
  13030. list of additional options. In most cases the layout name is all you care
  13031. about.
  13032. @deffn {Scheme Procedure} keyboard-layout @var{name} [@var{variant}] @
  13033. [#:model] [#:options '()]
  13034. Return a new keyboard layout with the given @var{name} and @var{variant}.
  13035. @var{name} must be a string such as @code{"fr"}; @var{variant} must be a
  13036. string such as @code{"bepo"} or @code{"nodeadkeys"}. See the
  13037. @code{xkeyboard-config} package for valid options.
  13038. @end deffn
  13039. Here are a few examples:
  13040. @lisp
  13041. ;; The German QWERTZ layout. Here we assume a standard
  13042. ;; "pc105" keyboard model.
  13043. (keyboard-layout "de")
  13044. ;; The bépo variant of the French layout.
  13045. (keyboard-layout "fr" "bepo")
  13046. ;; The Catalan layout.
  13047. (keyboard-layout "es" "cat")
  13048. ;; Arabic layout with "Alt-Shift" to switch to US layout.
  13049. (keyboard-layout "ar,us" #:options '("grp:alt_shift_toggle"))
  13050. ;; The Latin American Spanish layout. In addition, the
  13051. ;; "Caps Lock" key is used as an additional "Ctrl" key,
  13052. ;; and the "Menu" key is used as a "Compose" key to enter
  13053. ;; accented letters.
  13054. (keyboard-layout "latam"
  13055. #:options '("ctrl:nocaps" "compose:menu"))
  13056. ;; The Russian layout for a ThinkPad keyboard.
  13057. (keyboard-layout "ru" #:model "thinkpad")
  13058. ;; The "US international" layout, which is the US layout plus
  13059. ;; dead keys to enter accented characters. This is for an
  13060. ;; Apple MacBook keyboard.
  13061. (keyboard-layout "us" "intl" #:model "macbook78")
  13062. @end lisp
  13063. See the @file{share/X11/xkb} directory of the @code{xkeyboard-config} package
  13064. for a complete list of supported layouts, variants, and models.
  13065. @cindex keyboard layout, configuration
  13066. Let's say you want your system to use the Turkish keyboard layout throughout
  13067. your system---bootloader, console, and Xorg. Here's what your system
  13068. configuration would look like:
  13069. @findex set-xorg-configuration
  13070. @lisp
  13071. ;; Using the Turkish layout for the bootloader, the console,
  13072. ;; and for Xorg.
  13073. (operating-system
  13074. ;; ...
  13075. (keyboard-layout (keyboard-layout "tr")) ;for the console
  13076. (bootloader (bootloader-configuration
  13077. (bootloader grub-efi-bootloader)
  13078. (targets '("/boot/efi"))
  13079. (keyboard-layout keyboard-layout))) ;for GRUB
  13080. (services (cons (set-xorg-configuration
  13081. (xorg-configuration ;for Xorg
  13082. (keyboard-layout keyboard-layout)))
  13083. %desktop-services)))
  13084. @end lisp
  13085. In the example above, for GRUB and for Xorg, we just refer to the
  13086. @code{keyboard-layout} field defined above, but we could just as well refer to
  13087. a different layout. The @code{set-xorg-configuration} procedure communicates
  13088. the desired Xorg configuration to the graphical log-in manager, by default
  13089. GDM.
  13090. We've discussed how to specify the @emph{default} keyboard layout of your
  13091. system when it starts, but you can also adjust it at run time:
  13092. @itemize
  13093. @item
  13094. If you're using GNOME, its settings panel has a ``Region & Language'' entry
  13095. where you can select one or more keyboard layouts.
  13096. @item
  13097. Under Xorg, the @command{setxkbmap} command (from the same-named package)
  13098. allows you to change the current layout. For example, this is how you would
  13099. change the layout to US Dvorak:
  13100. @example
  13101. setxkbmap us dvorak
  13102. @end example
  13103. @item
  13104. The @code{loadkeys} command changes the keyboard layout in effect in the Linux
  13105. console. However, note that @code{loadkeys} does @emph{not} use the XKB
  13106. keyboard layout categorization described above. The command below loads the
  13107. French bépo layout:
  13108. @example
  13109. loadkeys fr-bepo
  13110. @end example
  13111. @end itemize
  13112. @node Locales
  13113. @section Locales
  13114. @cindex locale
  13115. A @dfn{locale} defines cultural conventions for a particular language
  13116. and region of the world (@pxref{Locales,,, libc, The GNU C Library
  13117. Reference Manual}). Each locale has a name that typically has the form
  13118. @code{@var{language}_@var{territory}.@var{codeset}}---e.g.,
  13119. @code{fr_LU.utf8} designates the locale for the French language, with
  13120. cultural conventions from Luxembourg, and using the UTF-8 encoding.
  13121. @cindex locale definition
  13122. Usually, you will want to specify the default locale for the machine
  13123. using the @code{locale} field of the @code{operating-system} declaration
  13124. (@pxref{operating-system Reference, @code{locale}}).
  13125. The selected locale is automatically added to the @dfn{locale
  13126. definitions} known to the system if needed, with its codeset inferred
  13127. from its name---e.g., @code{bo_CN.utf8} will be assumed to use the
  13128. @code{UTF-8} codeset. Additional locale definitions can be specified in
  13129. the @code{locale-definitions} slot of @code{operating-system}---this is
  13130. useful, for instance, if the codeset could not be inferred from the
  13131. locale name. The default set of locale definitions includes some widely
  13132. used locales, but not all the available locales, in order to save space.
  13133. For instance, to add the North Frisian locale for Germany, the value of
  13134. that field may be:
  13135. @lisp
  13136. (cons (locale-definition
  13137. (name "fy_DE.utf8") (source "fy_DE"))
  13138. %default-locale-definitions)
  13139. @end lisp
  13140. Likewise, to save space, one might want @code{locale-definitions} to
  13141. list only the locales that are actually used, as in:
  13142. @lisp
  13143. (list (locale-definition
  13144. (name "ja_JP.eucjp") (source "ja_JP")
  13145. (charset "EUC-JP")))
  13146. @end lisp
  13147. @vindex LOCPATH
  13148. The compiled locale definitions are available at
  13149. @file{/run/current-system/locale/X.Y}, where @code{X.Y} is the libc
  13150. version, which is the default location where the GNU@tie{}libc provided
  13151. by Guix looks for locale data. This can be overridden using the
  13152. @env{LOCPATH} environment variable (@pxref{locales-and-locpath,
  13153. @env{LOCPATH} and locale packages}).
  13154. The @code{locale-definition} form is provided by the @code{(gnu system
  13155. locale)} module. Details are given below.
  13156. @deftp {Data Type} locale-definition
  13157. This is the data type of a locale definition.
  13158. @table @asis
  13159. @item @code{name}
  13160. The name of the locale. @xref{Locale Names,,, libc, The GNU C Library
  13161. Reference Manual}, for more information on locale names.
  13162. @item @code{source}
  13163. The name of the source for that locale. This is typically the
  13164. @code{@var{language}_@var{territory}} part of the locale name.
  13165. @item @code{charset} (default: @code{"UTF-8"})
  13166. The ``character set'' or ``code set'' for that locale,
  13167. @uref{https://www.iana.org/assignments/character-sets, as defined by
  13168. IANA}.
  13169. @end table
  13170. @end deftp
  13171. @defvr {Scheme Variable} %default-locale-definitions
  13172. A list of commonly used UTF-8 locales, used as the default
  13173. value of the @code{locale-definitions} field of @code{operating-system}
  13174. declarations.
  13175. @cindex locale name
  13176. @cindex normalized codeset in locale names
  13177. These locale definitions use the @dfn{normalized codeset} for the part
  13178. that follows the dot in the name (@pxref{Using gettextized software,
  13179. normalized codeset,, libc, The GNU C Library Reference Manual}). So for
  13180. instance it has @code{uk_UA.utf8} but @emph{not}, say,
  13181. @code{uk_UA.UTF-8}.
  13182. @end defvr
  13183. @subsection Locale Data Compatibility Considerations
  13184. @cindex incompatibility, of locale data
  13185. @code{operating-system} declarations provide a @code{locale-libcs} field
  13186. to specify the GNU@tie{}libc packages that are used to compile locale
  13187. declarations (@pxref{operating-system Reference}). ``Why would I
  13188. care?'', you may ask. Well, it turns out that the binary format of
  13189. locale data is occasionally incompatible from one libc version to
  13190. another.
  13191. @c See <https://sourceware.org/ml/libc-alpha/2015-09/msg00575.html>
  13192. @c and <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
  13193. For instance, a program linked against libc version 2.21 is unable to
  13194. read locale data produced with libc 2.22; worse, that program
  13195. @emph{aborts} instead of simply ignoring the incompatible locale
  13196. data@footnote{Versions 2.23 and later of GNU@tie{}libc will simply skip
  13197. the incompatible locale data, which is already an improvement.}.
  13198. Similarly, a program linked against libc 2.22 can read most, but not
  13199. all, of the locale data from libc 2.21 (specifically, @env{LC_COLLATE}
  13200. data is incompatible); thus calls to @code{setlocale} may fail, but
  13201. programs will not abort.
  13202. The ``problem'' with Guix is that users have a lot of freedom: They can
  13203. choose whether and when to upgrade software in their profiles, and might
  13204. be using a libc version different from the one the system administrator
  13205. used to build the system-wide locale data.
  13206. Fortunately, unprivileged users can also install their own locale data
  13207. and define @env{GUIX_LOCPATH} accordingly (@pxref{locales-and-locpath,
  13208. @env{GUIX_LOCPATH} and locale packages}).
  13209. Still, it is best if the system-wide locale data at
  13210. @file{/run/current-system/locale} is built for all the libc versions
  13211. actually in use on the system, so that all the programs can access
  13212. it---this is especially crucial on a multi-user system. To do that, the
  13213. administrator can specify several libc packages in the
  13214. @code{locale-libcs} field of @code{operating-system}:
  13215. @lisp
  13216. (use-package-modules base)
  13217. (operating-system
  13218. ;; @dots{}
  13219. (locale-libcs (list glibc-2.21 (canonical-package glibc))))
  13220. @end lisp
  13221. This example would lead to a system containing locale definitions for
  13222. both libc 2.21 and the current version of libc in
  13223. @file{/run/current-system/locale}.
  13224. @node Services
  13225. @section Services
  13226. @cindex system services
  13227. An important part of preparing an @code{operating-system} declaration is
  13228. listing @dfn{system services} and their configuration (@pxref{Using the
  13229. Configuration System}). System services are typically daemons launched
  13230. when the system boots, or other actions needed at that time---e.g.,
  13231. configuring network access.
  13232. Guix has a broad definition of ``service'' (@pxref{Service
  13233. Composition}), but many services are managed by the GNU@tie{}Shepherd
  13234. (@pxref{Shepherd Services}). On a running system, the @command{herd}
  13235. command allows you to list the available services, show their status,
  13236. start and stop them, or do other specific operations (@pxref{Jump
  13237. Start,,, shepherd, The GNU Shepherd Manual}). For example:
  13238. @example
  13239. # herd status
  13240. @end example
  13241. The above command, run as @code{root}, lists the currently defined
  13242. services. The @command{herd doc} command shows a synopsis of the given
  13243. service and its associated actions:
  13244. @example
  13245. # herd doc nscd
  13246. Run libc's name service cache daemon (nscd).
  13247. # herd doc nscd action invalidate
  13248. invalidate: Invalidate the given cache--e.g., 'hosts' for host name lookups.
  13249. @end example
  13250. The @command{start}, @command{stop}, and @command{restart} sub-commands
  13251. have the effect you would expect. For instance, the commands below stop
  13252. the nscd service and restart the Xorg display server:
  13253. @example
  13254. # herd stop nscd
  13255. Service nscd has been stopped.
  13256. # herd restart xorg-server
  13257. Service xorg-server has been stopped.
  13258. Service xorg-server has been started.
  13259. @end example
  13260. The following sections document the available services, starting with
  13261. the core services, that may be used in an @code{operating-system}
  13262. declaration.
  13263. @menu
  13264. * Base Services:: Essential system services.
  13265. * Scheduled Job Execution:: The mcron service.
  13266. * Log Rotation:: The rottlog service.
  13267. * Networking Setup:: Setting up network interfaces.
  13268. * Networking Services:: Firewall, SSH daemon, etc.
  13269. * Unattended Upgrades:: Automated system upgrades.
  13270. * X Window:: Graphical display.
  13271. * Printing Services:: Local and remote printer support.
  13272. * Desktop Services:: D-Bus and desktop services.
  13273. * Sound Services:: ALSA and Pulseaudio services.
  13274. * Database Services:: SQL databases, key-value stores, etc.
  13275. * Mail Services:: IMAP, POP3, SMTP, and all that.
  13276. * Messaging Services:: Messaging services.
  13277. * Telephony Services:: Telephony services.
  13278. * File-Sharing Services:: File-sharing services.
  13279. * Monitoring Services:: Monitoring services.
  13280. * Kerberos Services:: Kerberos services.
  13281. * LDAP Services:: LDAP services.
  13282. * Web Services:: Web servers.
  13283. * Certificate Services:: TLS certificates via Let's Encrypt.
  13284. * DNS Services:: DNS daemons.
  13285. * VPN Services:: VPN daemons.
  13286. * Network File System:: NFS related services.
  13287. * Continuous Integration:: Cuirass and Laminar services.
  13288. * Power Management Services:: Extending battery life.
  13289. * Audio Services:: The MPD.
  13290. * Virtualization Services:: Virtualization services.
  13291. * Version Control Services:: Providing remote access to Git repositories.
  13292. * Game Services:: Game servers.
  13293. * PAM Mount Service:: Service to mount volumes when logging in.
  13294. * Guix Services:: Services relating specifically to Guix.
  13295. * Linux Services:: Services tied to the Linux kernel.
  13296. * Hurd Services:: Services specific for a Hurd System.
  13297. * Miscellaneous Services:: Other services.
  13298. @end menu
  13299. @node Base Services
  13300. @subsection Base Services
  13301. The @code{(gnu services base)} module provides definitions for the basic
  13302. services that one expects from the system. The services exported by
  13303. this module are listed below.
  13304. @defvr {Scheme Variable} %base-services
  13305. This variable contains a list of basic services (@pxref{Service Types
  13306. and Services}, for more information on service objects) one would
  13307. expect from the system: a login service (mingetty) on each tty, syslogd,
  13308. the libc name service cache daemon (nscd), the udev device manager, and
  13309. more.
  13310. This is the default value of the @code{services} field of
  13311. @code{operating-system} declarations. Usually, when customizing a
  13312. system, you will want to append services to @code{%base-services}, like
  13313. this:
  13314. @lisp
  13315. (append (list (service avahi-service-type)
  13316. (service openssh-service-type))
  13317. %base-services)
  13318. @end lisp
  13319. @end defvr
  13320. @defvr {Scheme Variable} special-files-service-type
  13321. This is the service that sets up ``special files'' such as
  13322. @file{/bin/sh}; an instance of it is part of @code{%base-services}.
  13323. The value associated with @code{special-files-service-type} services
  13324. must be a list of tuples where the first element is the ``special file''
  13325. and the second element is its target. By default it is:
  13326. @cindex @file{/bin/sh}
  13327. @cindex @file{sh}, in @file{/bin}
  13328. @lisp
  13329. `(("/bin/sh" ,(file-append bash "/bin/sh")))
  13330. @end lisp
  13331. @cindex @file{/usr/bin/env}
  13332. @cindex @file{env}, in @file{/usr/bin}
  13333. If you want to add, say, @code{/usr/bin/env} to your system, you can
  13334. change it to:
  13335. @lisp
  13336. `(("/bin/sh" ,(file-append bash "/bin/sh"))
  13337. ("/usr/bin/env" ,(file-append coreutils "/bin/env")))
  13338. @end lisp
  13339. Since this is part of @code{%base-services}, you can use
  13340. @code{modify-services} to customize the set of special files
  13341. (@pxref{Service Reference, @code{modify-services}}). But the simple way
  13342. to add a special file is @i{via} the @code{extra-special-file} procedure
  13343. (see below).
  13344. @end defvr
  13345. @deffn {Scheme Procedure} extra-special-file @var{file} @var{target}
  13346. Use @var{target} as the ``special file'' @var{file}.
  13347. For example, adding the following lines to the @code{services} field of
  13348. your operating system declaration leads to a @file{/usr/bin/env}
  13349. symlink:
  13350. @lisp
  13351. (extra-special-file "/usr/bin/env"
  13352. (file-append coreutils "/bin/env"))
  13353. @end lisp
  13354. @end deffn
  13355. @deffn {Scheme Procedure} host-name-service @var{name}
  13356. Return a service that sets the host name to @var{name}.
  13357. @end deffn
  13358. @defvr {Scheme Variable} console-font-service-type
  13359. Install the given fonts on the specified ttys (fonts are per
  13360. virtual console on the kernel Linux). The value of this service is a list of
  13361. tty/font pairs. The font can be the name of a font provided by the @code{kbd}
  13362. package or any valid argument to @command{setfont}, as in this example:
  13363. @lisp
  13364. `(("tty1" . "LatGrkCyr-8x16")
  13365. ("tty2" . ,(file-append
  13366. font-tamzen
  13367. "/share/kbd/consolefonts/TamzenForPowerline10x20.psf"))
  13368. ("tty3" . ,(file-append
  13369. font-terminus
  13370. "/share/consolefonts/ter-132n"))) ; for HDPI
  13371. @end lisp
  13372. @end defvr
  13373. @deffn {Scheme Procedure} login-service @var{config}
  13374. Return a service to run login according to @var{config}, a
  13375. @code{<login-configuration>} object, which specifies the message of the day,
  13376. among other things.
  13377. @end deffn
  13378. @deftp {Data Type} login-configuration
  13379. This is the data type representing the configuration of login.
  13380. @table @asis
  13381. @item @code{motd}
  13382. @cindex message of the day
  13383. A file-like object containing the ``message of the day''.
  13384. @item @code{allow-empty-passwords?} (default: @code{#t})
  13385. Allow empty passwords by default so that first-time users can log in when
  13386. the 'root' account has just been created.
  13387. @end table
  13388. @end deftp
  13389. @deffn {Scheme Procedure} mingetty-service @var{config}
  13390. Return a service to run mingetty according to @var{config}, a
  13391. @code{<mingetty-configuration>} object, which specifies the tty to run, among
  13392. other things.
  13393. @end deffn
  13394. @deftp {Data Type} mingetty-configuration
  13395. This is the data type representing the configuration of Mingetty, which
  13396. provides the default implementation of virtual console log-in.
  13397. @table @asis
  13398. @item @code{tty}
  13399. The name of the console this Mingetty runs on---e.g., @code{"tty1"}.
  13400. @item @code{auto-login} (default: @code{#f})
  13401. When true, this field must be a string denoting the user name under
  13402. which the system automatically logs in. When it is @code{#f}, a
  13403. user name and password must be entered to log in.
  13404. @item @code{login-program} (default: @code{#f})
  13405. This must be either @code{#f}, in which case the default log-in program
  13406. is used (@command{login} from the Shadow tool suite), or a gexp denoting
  13407. the name of the log-in program.
  13408. @item @code{login-pause?} (default: @code{#f})
  13409. When set to @code{#t} in conjunction with @var{auto-login}, the user
  13410. will have to press a key before the log-in shell is launched.
  13411. @item @code{clear-on-logout?} (default: @code{#t})
  13412. When set to @code{#t}, the screen will be cleared after logout.
  13413. @item @code{mingetty} (default: @var{mingetty})
  13414. The Mingetty package to use.
  13415. @end table
  13416. @end deftp
  13417. @deffn {Scheme Procedure} agetty-service @var{config}
  13418. Return a service to run agetty according to @var{config}, an
  13419. @code{<agetty-configuration>} object, which specifies the tty to run,
  13420. among other things.
  13421. @end deffn
  13422. @deftp {Data Type} agetty-configuration
  13423. This is the data type representing the configuration of agetty, which
  13424. implements virtual and serial console log-in. See the @code{agetty(8)}
  13425. man page for more information.
  13426. @table @asis
  13427. @item @code{tty}
  13428. The name of the console this agetty runs on, as a string---e.g.,
  13429. @code{"ttyS0"}. This argument is optional, it will default to
  13430. a reasonable default serial port used by the kernel Linux.
  13431. For this, if there is a value for an option @code{agetty.tty} in the kernel
  13432. command line, agetty will extract the device name of the serial port
  13433. from it and use that.
  13434. If not and if there is a value for an option @code{console} with a tty in
  13435. the Linux command line, agetty will extract the device name of the
  13436. serial port from it and use that.
  13437. In both cases, agetty will leave the other serial device settings
  13438. (baud rate etc.)@: alone---in the hope that Linux pinned them to the
  13439. correct values.
  13440. @item @code{baud-rate} (default: @code{#f})
  13441. A string containing a comma-separated list of one or more baud rates, in
  13442. descending order.
  13443. @item @code{term} (default: @code{#f})
  13444. A string containing the value used for the @env{TERM} environment
  13445. variable.
  13446. @item @code{eight-bits?} (default: @code{#f})
  13447. When @code{#t}, the tty is assumed to be 8-bit clean, and parity detection is
  13448. disabled.
  13449. @item @code{auto-login} (default: @code{#f})
  13450. When passed a login name, as a string, the specified user will be logged
  13451. in automatically without prompting for their login name or password.
  13452. @item @code{no-reset?} (default: @code{#f})
  13453. When @code{#t}, don't reset terminal cflags (control modes).
  13454. @item @code{host} (default: @code{#f})
  13455. This accepts a string containing the ``login_host'', which will be written
  13456. into the @file{/var/run/utmpx} file.
  13457. @item @code{remote?} (default: @code{#f})
  13458. When set to @code{#t} in conjunction with @var{host}, this will add an
  13459. @code{-r} fakehost option to the command line of the login program
  13460. specified in @var{login-program}.
  13461. @item @code{flow-control?} (default: @code{#f})
  13462. When set to @code{#t}, enable hardware (RTS/CTS) flow control.
  13463. @item @code{no-issue?} (default: @code{#f})
  13464. When set to @code{#t}, the contents of the @file{/etc/issue} file will
  13465. not be displayed before presenting the login prompt.
  13466. @item @code{init-string} (default: @code{#f})
  13467. This accepts a string that will be sent to the tty or modem before
  13468. sending anything else. It can be used to initialize a modem.
  13469. @item @code{no-clear?} (default: @code{#f})
  13470. When set to @code{#t}, agetty will not clear the screen before showing
  13471. the login prompt.
  13472. @item @code{login-program} (default: (file-append shadow "/bin/login"))
  13473. This must be either a gexp denoting the name of a log-in program, or
  13474. unset, in which case the default value is the @command{login} from the
  13475. Shadow tool suite.
  13476. @item @code{local-line} (default: @code{#f})
  13477. Control the CLOCAL line flag. This accepts one of three symbols as
  13478. arguments, @code{'auto}, @code{'always}, or @code{'never}. If @code{#f},
  13479. the default value chosen by agetty is @code{'auto}.
  13480. @item @code{extract-baud?} (default: @code{#f})
  13481. When set to @code{#t}, instruct agetty to try to extract the baud rate
  13482. from the status messages produced by certain types of modems.
  13483. @item @code{skip-login?} (default: @code{#f})
  13484. When set to @code{#t}, do not prompt the user for a login name. This
  13485. can be used with @var{login-program} field to use non-standard login
  13486. systems.
  13487. @item @code{no-newline?} (default: @code{#f})
  13488. When set to @code{#t}, do not print a newline before printing the
  13489. @file{/etc/issue} file.
  13490. @c Is this dangerous only when used with login-program, or always?
  13491. @item @code{login-options} (default: @code{#f})
  13492. This option accepts a string containing options that are passed to the
  13493. login program. When used with the @var{login-program}, be aware that a
  13494. malicious user could try to enter a login name containing embedded
  13495. options that could be parsed by the login program.
  13496. @item @code{login-pause} (default: @code{#f})
  13497. When set to @code{#t}, wait for any key before showing the login prompt.
  13498. This can be used in conjunction with @var{auto-login} to save memory by
  13499. lazily spawning shells.
  13500. @item @code{chroot} (default: @code{#f})
  13501. Change root to the specified directory. This option accepts a directory
  13502. path as a string.
  13503. @item @code{hangup?} (default: @code{#f})
  13504. Use the Linux system call @code{vhangup} to do a virtual hangup of the
  13505. specified terminal.
  13506. @item @code{keep-baud?} (default: @code{#f})
  13507. When set to @code{#t}, try to keep the existing baud rate. The baud
  13508. rates from @var{baud-rate} are used when agetty receives a @key{BREAK}
  13509. character.
  13510. @item @code{timeout} (default: @code{#f})
  13511. When set to an integer value, terminate if no user name could be read
  13512. within @var{timeout} seconds.
  13513. @item @code{detect-case?} (default: @code{#f})
  13514. When set to @code{#t}, turn on support for detecting an uppercase-only
  13515. terminal. This setting will detect a login name containing only
  13516. uppercase letters as indicating an uppercase-only terminal and turn on
  13517. some upper-to-lower case conversions. Note that this will not support
  13518. Unicode characters.
  13519. @item @code{wait-cr?} (default: @code{#f})
  13520. When set to @code{#t}, wait for the user or modem to send a
  13521. carriage-return or linefeed character before displaying
  13522. @file{/etc/issue} or login prompt. This is typically used with the
  13523. @var{init-string} option.
  13524. @item @code{no-hints?} (default: @code{#f})
  13525. When set to @code{#t}, do not print hints about Num, Caps, and Scroll
  13526. locks.
  13527. @item @code{no-hostname?} (default: @code{#f})
  13528. By default, the hostname is printed. When this option is set to
  13529. @code{#t}, no hostname will be shown at all.
  13530. @item @code{long-hostname?} (default: @code{#f})
  13531. By default, the hostname is only printed until the first dot. When this
  13532. option is set to @code{#t}, the fully qualified hostname by
  13533. @code{gethostname} or @code{getaddrinfo} is shown.
  13534. @item @code{erase-characters} (default: @code{#f})
  13535. This option accepts a string of additional characters that should be
  13536. interpreted as backspace when the user types their login name.
  13537. @item @code{kill-characters} (default: @code{#f})
  13538. This option accepts a string that should be interpreted to mean ``ignore
  13539. all previous characters'' (also called a ``kill'' character) when the user
  13540. types their login name.
  13541. @item @code{chdir} (default: @code{#f})
  13542. This option accepts, as a string, a directory path that will be changed
  13543. to before login.
  13544. @item @code{delay} (default: @code{#f})
  13545. This options accepts, as an integer, the number of seconds to sleep
  13546. before opening the tty and displaying the login prompt.
  13547. @item @code{nice} (default: @code{#f})
  13548. This option accepts, as an integer, the nice value with which to run the
  13549. @command{login} program.
  13550. @item @code{extra-options} (default: @code{'()})
  13551. This option provides an ``escape hatch'' for the user to provide arbitrary
  13552. command-line arguments to @command{agetty} as a list of strings.
  13553. @item @code{shepherd-requirement} (default: @code{'()})
  13554. The option can be used to provides extra shepherd requirements (for example
  13555. @code{'syslogd}) to the respective @code{'term-}* shepherd service.
  13556. @end table
  13557. @end deftp
  13558. @deffn {Scheme Procedure} kmscon-service-type @var{config}
  13559. Return a service to run @uref{https://www.freedesktop.org/wiki/Software/kmscon,kmscon}
  13560. according to @var{config}, a @code{<kmscon-configuration>} object, which
  13561. specifies the tty to run, among other things.
  13562. @end deffn
  13563. @deftp {Data Type} kmscon-configuration
  13564. This is the data type representing the configuration of Kmscon, which
  13565. implements virtual console log-in.
  13566. @table @asis
  13567. @item @code{virtual-terminal}
  13568. The name of the console this Kmscon runs on---e.g., @code{"tty1"}.
  13569. @item @code{login-program} (default: @code{#~(string-append #$shadow "/bin/login")})
  13570. A gexp denoting the name of the log-in program. The default log-in program is
  13571. @command{login} from the Shadow tool suite.
  13572. @item @code{login-arguments} (default: @code{'("-p")})
  13573. A list of arguments to pass to @command{login}.
  13574. @item @code{auto-login} (default: @code{#f})
  13575. When passed a login name, as a string, the specified user will be logged
  13576. in automatically without prompting for their login name or password.
  13577. @item @code{hardware-acceleration?} (default: #f)
  13578. Whether to use hardware acceleration.
  13579. @item @code{font-engine} (default: @code{"pango"})
  13580. Font engine used in Kmscon.
  13581. @item @code{font-size} (default: @code{12})
  13582. Font size used in Kmscon.
  13583. @item @code{keyboard-layout} (default: @code{#f})
  13584. If this is @code{#f}, Kmscon uses the default keyboard layout---usually US
  13585. English (``qwerty'') for a 105-key PC keyboard.
  13586. Otherwise this must be a @code{keyboard-layout} object specifying the
  13587. keyboard layout. @xref{Keyboard Layout}, for more information on how to
  13588. specify the keyboard layout.
  13589. @item @code{kmscon} (default: @var{kmscon})
  13590. The Kmscon package to use.
  13591. @end table
  13592. @end deftp
  13593. @cindex name service cache daemon
  13594. @cindex nscd
  13595. @deffn {Scheme Procedure} nscd-service [@var{config}] [#:glibc glibc] @
  13596. [#:name-services '()]
  13597. Return a service that runs the libc name service cache daemon (nscd) with the
  13598. given @var{config}---an @code{<nscd-configuration>} object. @xref{Name
  13599. Service Switch}, for an example.
  13600. For convenience, the Shepherd service for nscd provides the following actions:
  13601. @table @code
  13602. @item invalidate
  13603. @cindex cache invalidation, nscd
  13604. @cindex nscd, cache invalidation
  13605. This invalidate the given cache. For instance, running:
  13606. @example
  13607. herd invalidate nscd hosts
  13608. @end example
  13609. @noindent
  13610. invalidates the host name lookup cache of nscd.
  13611. @item statistics
  13612. Running @command{herd statistics nscd} displays information about nscd usage
  13613. and caches.
  13614. @end table
  13615. @end deffn
  13616. @defvr {Scheme Variable} %nscd-default-configuration
  13617. This is the default @code{<nscd-configuration>} value (see below) used
  13618. by @code{nscd-service}. It uses the caches defined by
  13619. @code{%nscd-default-caches}; see below.
  13620. @end defvr
  13621. @deftp {Data Type} nscd-configuration
  13622. This is the data type representing the name service cache daemon (nscd)
  13623. configuration.
  13624. @table @asis
  13625. @item @code{name-services} (default: @code{'()})
  13626. List of packages denoting @dfn{name services} that must be visible to
  13627. the nscd---e.g., @code{(list @var{nss-mdns})}.
  13628. @item @code{glibc} (default: @var{glibc})
  13629. Package object denoting the GNU C Library providing the @command{nscd}
  13630. command.
  13631. @item @code{log-file} (default: @code{"/var/log/nscd.log"})
  13632. Name of the nscd log file. This is where debugging output goes when
  13633. @code{debug-level} is strictly positive.
  13634. @item @code{debug-level} (default: @code{0})
  13635. Integer denoting the debugging levels. Higher numbers mean that more
  13636. debugging output is logged.
  13637. @item @code{caches} (default: @code{%nscd-default-caches})
  13638. List of @code{<nscd-cache>} objects denoting things to be cached; see
  13639. below.
  13640. @end table
  13641. @end deftp
  13642. @deftp {Data Type} nscd-cache
  13643. Data type representing a cache database of nscd and its parameters.
  13644. @table @asis
  13645. @item @code{database}
  13646. This is a symbol representing the name of the database to be cached.
  13647. Valid values are @code{passwd}, @code{group}, @code{hosts}, and
  13648. @code{services}, which designate the corresponding NSS database
  13649. (@pxref{NSS Basics,,, libc, The GNU C Library Reference Manual}).
  13650. @item @code{positive-time-to-live}
  13651. @itemx @code{negative-time-to-live} (default: @code{20})
  13652. A number representing the number of seconds during which a positive or
  13653. negative lookup result remains in cache.
  13654. @item @code{check-files?} (default: @code{#t})
  13655. Whether to check for updates of the files corresponding to
  13656. @var{database}.
  13657. For instance, when @var{database} is @code{hosts}, setting this flag
  13658. instructs nscd to check for updates in @file{/etc/hosts} and to take
  13659. them into account.
  13660. @item @code{persistent?} (default: @code{#t})
  13661. Whether the cache should be stored persistently on disk.
  13662. @item @code{shared?} (default: @code{#t})
  13663. Whether the cache should be shared among users.
  13664. @item @code{max-database-size} (default: 32@tie{}MiB)
  13665. Maximum size in bytes of the database cache.
  13666. @c XXX: 'suggested-size' and 'auto-propagate?' seem to be expert
  13667. @c settings, so leave them out.
  13668. @end table
  13669. @end deftp
  13670. @defvr {Scheme Variable} %nscd-default-caches
  13671. List of @code{<nscd-cache>} objects used by default by
  13672. @code{nscd-configuration} (see above).
  13673. It enables persistent and aggressive caching of service and host name
  13674. lookups. The latter provides better host name lookup performance,
  13675. resilience in the face of unreliable name servers, and also better
  13676. privacy---often the result of host name lookups is in local cache, so
  13677. external name servers do not even need to be queried.
  13678. @end defvr
  13679. @anchor{syslog-configuration-type}
  13680. @cindex syslog
  13681. @cindex logging
  13682. @deftp {Data Type} syslog-configuration
  13683. This data type represents the configuration of the syslog daemon.
  13684. @table @asis
  13685. @item @code{syslogd} (default: @code{#~(string-append #$inetutils "/libexec/syslogd")})
  13686. The syslog daemon to use.
  13687. @item @code{config-file} (default: @code{%default-syslog.conf})
  13688. The syslog configuration file to use.
  13689. @end table
  13690. @end deftp
  13691. @anchor{syslog-service}
  13692. @cindex syslog
  13693. @deffn {Scheme Procedure} syslog-service @var{config}
  13694. Return a service that runs a syslog daemon according to @var{config}.
  13695. @xref{syslogd invocation,,, inetutils, GNU Inetutils}, for more
  13696. information on the configuration file syntax.
  13697. @end deffn
  13698. @defvr {Scheme Variable} guix-service-type
  13699. This is the type of the service that runs the build daemon,
  13700. @command{guix-daemon} (@pxref{Invoking guix-daemon}). Its value must be a
  13701. @code{guix-configuration} record as described below.
  13702. @end defvr
  13703. @anchor{guix-configuration-type}
  13704. @deftp {Data Type} guix-configuration
  13705. This data type represents the configuration of the Guix build daemon.
  13706. @xref{Invoking guix-daemon}, for more information.
  13707. @table @asis
  13708. @item @code{guix} (default: @var{guix})
  13709. The Guix package to use.
  13710. @item @code{build-group} (default: @code{"guixbuild"})
  13711. Name of the group for build user accounts.
  13712. @item @code{build-accounts} (default: @code{10})
  13713. Number of build user accounts to create.
  13714. @item @code{authorize-key?} (default: @code{#t})
  13715. @cindex substitutes, authorization thereof
  13716. Whether to authorize the substitute keys listed in
  13717. @code{authorized-keys}---by default that of
  13718. @code{@value{SUBSTITUTE-SERVER-1}} and
  13719. @code{@value{SUBSTITUTE-SERVER-2}}
  13720. (@pxref{Substitutes}).
  13721. When @code{authorize-key?} is true, @file{/etc/guix/acl} cannot be
  13722. changed by invoking @command{guix archive --authorize}. You must
  13723. instead adjust @code{guix-configuration} as you wish and reconfigure the
  13724. system. This ensures that your operating system configuration file is
  13725. self-contained.
  13726. @quotation Note
  13727. When booting or reconfiguring to a system where @code{authorize-key?}
  13728. is true, the existing @file{/etc/guix/acl} file is backed up as
  13729. @file{/etc/guix/acl.bak} if it was determined to be a manually modified
  13730. file. This is to facilitate migration from earlier versions, which
  13731. allowed for in-place modifications to @file{/etc/guix/acl}.
  13732. @end quotation
  13733. @vindex %default-authorized-guix-keys
  13734. @item @code{authorized-keys} (default: @code{%default-authorized-guix-keys})
  13735. The list of authorized key files for archive imports, as a list of
  13736. string-valued gexps (@pxref{Invoking guix archive}). By default, it
  13737. contains that of @code{@value{SUBSTITUTE-SERVER-1}} and
  13738. @code{@value{SUBSTITUTE-SERVER-2}} (@pxref{Substitutes}). See
  13739. @code{substitute-urls} below for an example on how to change it.
  13740. @item @code{use-substitutes?} (default: @code{#t})
  13741. Whether to use substitutes.
  13742. @item @code{substitute-urls} (default: @code{%default-substitute-urls})
  13743. The list of URLs where to look for substitutes by default.
  13744. Suppose you would like to fetch substitutes from @code{guix.example.org}
  13745. in addition to @code{@value{SUBSTITUTE-SERVER-1}}. You will need to do
  13746. two things: (1) add @code{guix.example.org} to @code{substitute-urls},
  13747. and (2) authorize its signing key, having done appropriate checks
  13748. (@pxref{Substitute Server Authorization}). The configuration below does
  13749. exactly that:
  13750. @lisp
  13751. (guix-configuration
  13752. (substitute-urls
  13753. (append (list "https://guix.example.org")
  13754. %default-substitute-urls))
  13755. (authorized-keys
  13756. (append (list (local-file "./guix.example.org-key.pub"))
  13757. %default-authorized-guix-keys)))
  13758. @end lisp
  13759. This example assumes that the file @file{./guix.example.org-key.pub}
  13760. contains the public key that @code{guix.example.org} uses to sign
  13761. substitutes.
  13762. @item @code{max-silent-time} (default: @code{0})
  13763. @itemx @code{timeout} (default: @code{0})
  13764. The number of seconds of silence and the number of seconds of activity,
  13765. respectively, after which a build process times out. A value of zero
  13766. disables the timeout.
  13767. @item @code{log-compression} (default: @code{'gzip})
  13768. The type of compression used for build logs---one of @code{gzip},
  13769. @code{bzip2}, or @code{none}.
  13770. @item @code{discover?} (default: @code{#f})
  13771. Whether to discover substitute servers on the local network using mDNS
  13772. and DNS-SD.
  13773. @item @code{extra-options} (default: @code{'()})
  13774. List of extra command-line options for @command{guix-daemon}.
  13775. @item @code{log-file} (default: @code{"/var/log/guix-daemon.log"})
  13776. File where @command{guix-daemon}'s standard output and standard error
  13777. are written.
  13778. @cindex HTTP proxy, for @code{guix-daemon}
  13779. @cindex proxy, for @code{guix-daemon} HTTP access
  13780. @item @code{http-proxy} (default: @code{#f})
  13781. The URL of the HTTP and HTTPS proxy used for downloading fixed-output
  13782. derivations and substitutes.
  13783. It is also possible to change the daemon's proxy at run time through the
  13784. @code{set-http-proxy} action, which restarts it:
  13785. @example
  13786. herd set-http-proxy guix-daemon http://localhost:8118
  13787. @end example
  13788. To clear the proxy settings, run:
  13789. @example
  13790. herd set-http-proxy guix-daemon
  13791. @end example
  13792. @item @code{tmpdir} (default: @code{#f})
  13793. A directory path where the @command{guix-daemon} will perform builds.
  13794. @end table
  13795. @end deftp
  13796. @deffn {Scheme Procedure} udev-service [#:udev @var{eudev} #:rules @code{'()}]
  13797. Run @var{udev}, which populates the @file{/dev} directory dynamically.
  13798. udev rules can be provided as a list of files through the @var{rules}
  13799. variable. The procedures @code{udev-rule}, @code{udev-rules-service}
  13800. and @code{file->udev-rule} from @code{(gnu services base)} simplify the
  13801. creation of such rule files.
  13802. The @command{herd rules udev} command, as root, returns the name of the
  13803. directory containing all the active udev rules.
  13804. @end deffn
  13805. @deffn {Scheme Procedure} udev-rule [@var{file-name} @var{contents}]
  13806. Return a udev-rule file named @var{file-name} containing the rules
  13807. defined by the @var{contents} literal.
  13808. In the following example, a rule for a USB device is defined to be
  13809. stored in the file @file{90-usb-thing.rules}. The rule runs a script
  13810. upon detecting a USB device with a given product identifier.
  13811. @lisp
  13812. (define %example-udev-rule
  13813. (udev-rule
  13814. "90-usb-thing.rules"
  13815. (string-append "ACTION==\"add\", SUBSYSTEM==\"usb\", "
  13816. "ATTR@{product@}==\"Example\", "
  13817. "RUN+=\"/path/to/script\"")))
  13818. @end lisp
  13819. @end deffn
  13820. @deffn {Scheme Procedure} udev-rules-service [@var{name} @var{rules}] @
  13821. [#:groups @var{groups}]
  13822. Return a service that extends @code{udev-service-type } with @var{rules}
  13823. and @code{account-service-type} with @var{groups} as system groups.
  13824. This works by creating a singleton service type
  13825. @code{@var{name}-udev-rules}, of which the returned service is an
  13826. instance.
  13827. Here we show how it can be used to extend @code{udev-service-type} with the
  13828. previously defined rule @code{%example-udev-rule}.
  13829. @lisp
  13830. (operating-system
  13831. ;; @dots{}
  13832. (services
  13833. (cons (udev-rules-service 'usb-thing %example-udev-rule)
  13834. %desktop-services)))
  13835. @end lisp
  13836. @end deffn
  13837. @deffn {Scheme Procedure} file->udev-rule [@var{file-name} @var{file}]
  13838. Return a udev file named @var{file-name} containing the rules defined
  13839. within @var{file}, a file-like object.
  13840. The following example showcases how we can use an existing rule file.
  13841. @lisp
  13842. (use-modules (guix download) ;for url-fetch
  13843. (guix packages) ;for origin
  13844. @dots{})
  13845. (define %android-udev-rules
  13846. (file->udev-rule
  13847. "51-android-udev.rules"
  13848. (let ((version "20170910"))
  13849. (origin
  13850. (method url-fetch)
  13851. (uri (string-append "https://raw.githubusercontent.com/M0Rf30/"
  13852. "android-udev-rules/" version "/51-android.rules"))
  13853. (sha256
  13854. (base32 "0lmmagpyb6xsq6zcr2w1cyx9qmjqmajkvrdbhjx32gqf1d9is003"))))))
  13855. @end lisp
  13856. @end deffn
  13857. Additionally, Guix package definitions can be included in @var{rules} in
  13858. order to extend the udev rules with the definitions found under their
  13859. @file{lib/udev/rules.d} sub-directory. In lieu of the previous
  13860. @var{file->udev-rule} example, we could have used the
  13861. @var{android-udev-rules} package which exists in Guix in the @code{(gnu
  13862. packages android)} module.
  13863. The following example shows how to use the @var{android-udev-rules}
  13864. package so that the Android tool @command{adb} can detect devices
  13865. without root privileges. It also details how to create the
  13866. @code{adbusers} group, which is required for the proper functioning of
  13867. the rules defined within the @code{android-udev-rules} package. To
  13868. create such a group, we must define it both as part of the
  13869. @code{supplementary-groups} of our @code{user-account} declaration, as
  13870. well as in the @var{groups} of the @code{udev-rules-service} procedure.
  13871. @lisp
  13872. (use-modules (gnu packages android) ;for android-udev-rules
  13873. (gnu system shadow) ;for user-group
  13874. @dots{})
  13875. (operating-system
  13876. ;; @dots{}
  13877. (users (cons (user-account
  13878. ;; @dots{}
  13879. (supplementary-groups
  13880. '("adbusers" ;for adb
  13881. "wheel" "netdev" "audio" "video")))))
  13882. ;; @dots{}
  13883. (services
  13884. (cons (udev-rules-service 'android android-udev-rules
  13885. #:groups '("adbusers"))
  13886. %desktop-services)))
  13887. @end lisp
  13888. @defvr {Scheme Variable} urandom-seed-service-type
  13889. Save some entropy in @code{%random-seed-file} to seed @file{/dev/urandom}
  13890. when rebooting. It also tries to seed @file{/dev/urandom} from
  13891. @file{/dev/hwrng} while booting, if @file{/dev/hwrng} exists and is
  13892. readable.
  13893. @end defvr
  13894. @defvr {Scheme Variable} %random-seed-file
  13895. This is the name of the file where some random bytes are saved by
  13896. @var{urandom-seed-service} to seed @file{/dev/urandom} when rebooting.
  13897. It defaults to @file{/var/lib/random-seed}.
  13898. @end defvr
  13899. @cindex mouse
  13900. @cindex gpm
  13901. @defvr {Scheme Variable} gpm-service-type
  13902. This is the type of the service that runs GPM, the @dfn{general-purpose
  13903. mouse daemon}, which provides mouse support to the Linux console. GPM
  13904. allows users to use the mouse in the console, notably to select, copy,
  13905. and paste text.
  13906. The value for services of this type must be a @code{gpm-configuration}
  13907. (see below). This service is not part of @code{%base-services}.
  13908. @end defvr
  13909. @deftp {Data Type} gpm-configuration
  13910. Data type representing the configuration of GPM.
  13911. @table @asis
  13912. @item @code{options} (default: @code{%default-gpm-options})
  13913. Command-line options passed to @command{gpm}. The default set of
  13914. options instruct @command{gpm} to listen to mouse events on
  13915. @file{/dev/input/mice}. @xref{Command Line,,, gpm, gpm manual}, for
  13916. more information.
  13917. @item @code{gpm} (default: @code{gpm})
  13918. The GPM package to use.
  13919. @end table
  13920. @end deftp
  13921. @anchor{guix-publish-service-type}
  13922. @deffn {Scheme Variable} guix-publish-service-type
  13923. This is the service type for @command{guix publish} (@pxref{Invoking
  13924. guix publish}). Its value must be a @code{guix-publish-configuration}
  13925. object, as described below.
  13926. This assumes that @file{/etc/guix} already contains a signing key pair as
  13927. created by @command{guix archive --generate-key} (@pxref{Invoking guix
  13928. archive}). If that is not the case, the service will fail to start.
  13929. @end deffn
  13930. @deftp {Data Type} guix-publish-configuration
  13931. Data type representing the configuration of the @code{guix publish}
  13932. service.
  13933. @table @asis
  13934. @item @code{guix} (default: @code{guix})
  13935. The Guix package to use.
  13936. @item @code{port} (default: @code{80})
  13937. The TCP port to listen for connections.
  13938. @item @code{host} (default: @code{"localhost"})
  13939. The host (and thus, network interface) to listen to. Use
  13940. @code{"0.0.0.0"} to listen on all the network interfaces.
  13941. @item @code{advertise?} (default: @code{#f})
  13942. When true, advertise the service on the local network @i{via} the DNS-SD
  13943. protocol, using Avahi.
  13944. This allows neighboring Guix devices with discovery on (see
  13945. @code{guix-configuration} above) to discover this @command{guix publish}
  13946. instance and to automatically download substitutes from it.
  13947. @item @code{compression} (default: @code{'(("gzip" 3) ("zstd" 3))})
  13948. This is a list of compression method/level tuple used when compressing
  13949. substitutes. For example, to compress all substitutes with @emph{both} lzip
  13950. at level 7 and gzip at level 9, write:
  13951. @lisp
  13952. '(("lzip" 7) ("gzip" 9))
  13953. @end lisp
  13954. Level 9 achieves the best compression ratio at the expense of increased CPU
  13955. usage, whereas level 1 achieves fast compression. @xref{Invoking guix
  13956. publish}, for more information on the available compression methods and
  13957. the tradeoffs involved.
  13958. An empty list disables compression altogether.
  13959. @item @code{nar-path} (default: @code{"nar"})
  13960. The URL path at which ``nars'' can be fetched. @xref{Invoking guix
  13961. publish, @option{--nar-path}}, for details.
  13962. @item @code{cache} (default: @code{#f})
  13963. When it is @code{#f}, disable caching and instead generate archives on
  13964. demand. Otherwise, this should be the name of a directory---e.g.,
  13965. @code{"/var/cache/guix/publish"}---where @command{guix publish} caches
  13966. archives and meta-data ready to be sent. @xref{Invoking guix publish,
  13967. @option{--cache}}, for more information on the tradeoffs involved.
  13968. @item @code{workers} (default: @code{#f})
  13969. When it is an integer, this is the number of worker threads used for
  13970. caching; when @code{#f}, the number of processors is used.
  13971. @xref{Invoking guix publish, @option{--workers}}, for more information.
  13972. @item @code{cache-bypass-threshold} (default: 10 MiB)
  13973. When @code{cache} is true, this is the maximum size in bytes of a store
  13974. item for which @command{guix publish} may bypass its cache in case of a
  13975. cache miss. @xref{Invoking guix publish,
  13976. @option{--cache-bypass-threshold}}, for more information.
  13977. @item @code{ttl} (default: @code{#f})
  13978. When it is an integer, this denotes the @dfn{time-to-live} in seconds
  13979. of the published archives. @xref{Invoking guix publish, @option{--ttl}},
  13980. for more information.
  13981. @item @code{negative-ttl} (default: @code{#f})
  13982. When it is an integer, this denotes the @dfn{time-to-live} in
  13983. seconds for the negative lookups. @xref{Invoking guix publish,
  13984. @option{--negative-ttl}}, for more information.
  13985. @end table
  13986. @end deftp
  13987. @anchor{rngd-service}
  13988. @deffn {Scheme Procedure} rngd-service [#:rng-tools @var{rng-tools}] @
  13989. [#:device "/dev/hwrng"]
  13990. Return a service that runs the @command{rngd} program from @var{rng-tools}
  13991. to add @var{device} to the kernel's entropy pool. The service will fail if
  13992. @var{device} does not exist.
  13993. @end deffn
  13994. @anchor{pam-limits-service}
  13995. @cindex session limits
  13996. @cindex ulimit
  13997. @cindex priority
  13998. @cindex realtime
  13999. @cindex jackd
  14000. @cindex nofile
  14001. @cindex open file descriptors
  14002. @deffn {Scheme Procedure} pam-limits-service [#:limits @code{'()}]
  14003. Return a service that installs a configuration file for the
  14004. @uref{http://linux-pam.org/Linux-PAM-html/sag-pam_limits.html,
  14005. @code{pam_limits} module}. The procedure optionally takes a list of
  14006. @code{pam-limits-entry} values, which can be used to specify
  14007. @code{ulimit} limits and @code{nice} priority limits to user sessions.
  14008. The following limits definition sets two hard and soft limits for all
  14009. login sessions of users in the @code{realtime} group:
  14010. @lisp
  14011. (pam-limits-service
  14012. (list
  14013. (pam-limits-entry "@@realtime" 'both 'rtprio 99)
  14014. (pam-limits-entry "@@realtime" 'both 'memlock 'unlimited)))
  14015. @end lisp
  14016. The first entry increases the maximum realtime priority for
  14017. non-privileged processes; the second entry lifts any restriction of the
  14018. maximum address space that can be locked in memory. These settings are
  14019. commonly used for real-time audio systems.
  14020. Another useful example is raising the maximum number of open file
  14021. descriptors that can be used:
  14022. @lisp
  14023. (pam-limits-service
  14024. (list
  14025. (pam-limits-entry "*" 'both 'nofile 100000)))
  14026. @end lisp
  14027. In the above example, the asterisk means the limit should apply to any
  14028. user. It is important to ensure the chosen value doesn't exceed the
  14029. maximum system value visible in the @file{/proc/sys/fs/file-max} file,
  14030. else the users would be prevented from login in. For more information
  14031. about the Pluggable Authentication Module (PAM) limits, refer to the
  14032. @samp{pam_limits} man page from the @code{linux-pam} package.
  14033. @end deffn
  14034. @node Scheduled Job Execution
  14035. @subsection Scheduled Job Execution
  14036. @cindex cron
  14037. @cindex mcron
  14038. @cindex scheduling jobs
  14039. The @code{(gnu services mcron)} module provides an interface to
  14040. GNU@tie{}mcron, a daemon to run jobs at scheduled times (@pxref{Top,,,
  14041. mcron, GNU@tie{}mcron}). GNU@tie{}mcron is similar to the traditional
  14042. Unix @command{cron} daemon; the main difference is that it is
  14043. implemented in Guile Scheme, which provides a lot of flexibility when
  14044. specifying the scheduling of jobs and their actions.
  14045. The example below defines an operating system that runs the
  14046. @command{updatedb} (@pxref{Invoking updatedb,,, find, Finding Files})
  14047. and the @command{guix gc} commands (@pxref{Invoking guix gc}) daily, as
  14048. well as the @command{mkid} command on behalf of an unprivileged user
  14049. (@pxref{mkid invocation,,, idutils, ID Database Utilities}). It uses
  14050. gexps to introduce job definitions that are passed to mcron
  14051. (@pxref{G-Expressions}).
  14052. @lisp
  14053. (use-modules (guix) (gnu) (gnu services mcron))
  14054. (use-package-modules base idutils)
  14055. (define updatedb-job
  14056. ;; Run 'updatedb' at 3AM every day. Here we write the
  14057. ;; job's action as a Scheme procedure.
  14058. #~(job '(next-hour '(3))
  14059. (lambda ()
  14060. (execl (string-append #$findutils "/bin/updatedb")
  14061. "updatedb"
  14062. "--prunepaths=/tmp /var/tmp /gnu/store"))
  14063. "updatedb"))
  14064. (define garbage-collector-job
  14065. ;; Collect garbage 5 minutes after midnight every day.
  14066. ;; The job's action is a shell command.
  14067. #~(job "5 0 * * *" ;Vixie cron syntax
  14068. "guix gc -F 1G"))
  14069. (define idutils-job
  14070. ;; Update the index database as user "charlie" at 12:15PM
  14071. ;; and 19:15PM. This runs from the user's home directory.
  14072. #~(job '(next-minute-from (next-hour '(12 19)) '(15))
  14073. (string-append #$idutils "/bin/mkid src")
  14074. #:user "charlie"))
  14075. (operating-system
  14076. ;; @dots{}
  14077. ;; %BASE-SERVICES already includes an instance of
  14078. ;; 'mcron-service-type', which we extend with additional
  14079. ;; jobs using 'simple-service'.
  14080. (services (cons (simple-service 'my-cron-jobs
  14081. mcron-service-type
  14082. (list garbage-collector-job
  14083. updatedb-job
  14084. idutils-job))
  14085. %base-services)))
  14086. @end lisp
  14087. @quotation Tip
  14088. When providing the action of a job specification as a procedure, you
  14089. should provide an explicit name for the job via the optional 3rd
  14090. argument as done in the @code{updatedb-job} example above. Otherwise,
  14091. the job would appear as ``Lambda function'' in the output of
  14092. @command{herd schedule mcron}, which is not nearly descriptive enough!
  14093. @end quotation
  14094. For more complex jobs defined in Scheme where you need control over the top
  14095. level, for instance to introduce a @code{use-modules} form, you can move your
  14096. code to a separate program using the @code{program-file} procedure of the
  14097. @code{(guix gexp)} module (@pxref{G-Expressions}). The example below
  14098. illustrates that.
  14099. @lisp
  14100. (define %battery-alert-job
  14101. ;; Beep when the battery percentage falls below %MIN-LEVEL.
  14102. #~(job
  14103. '(next-minute (range 0 60 1))
  14104. #$(program-file
  14105. "battery-alert.scm"
  14106. (with-imported-modules (source-module-closure
  14107. '((guix build utils)))
  14108. #~(begin
  14109. (use-modules (guix build utils)
  14110. (ice-9 popen)
  14111. (ice-9 regex)
  14112. (ice-9 textual-ports)
  14113. (srfi srfi-2))
  14114. (define %min-level 20)
  14115. (setenv "LC_ALL" "C") ;ensure English output
  14116. (and-let* ((input-pipe (open-pipe*
  14117. OPEN_READ
  14118. #$(file-append acpi "/bin/acpi")))
  14119. (output (get-string-all input-pipe))
  14120. (m (string-match "Discharging, ([0-9]+)%" output))
  14121. (level (string->number (match:substring m 1)))
  14122. ((< level %min-level)))
  14123. (format #t "warning: Battery level is low (~a%)~%" level)
  14124. (invoke #$(file-append beep "/bin/beep") "-r5")))))))
  14125. @end lisp
  14126. @xref{Guile Syntax, mcron job specifications,, mcron, GNU@tie{}mcron},
  14127. for more information on mcron job specifications. Below is the
  14128. reference of the mcron service.
  14129. On a running system, you can use the @code{schedule} action of the service to
  14130. visualize the mcron jobs that will be executed next:
  14131. @example
  14132. # herd schedule mcron
  14133. @end example
  14134. @noindent
  14135. The example above lists the next five tasks that will be executed, but you can
  14136. also specify the number of tasks to display:
  14137. @example
  14138. # herd schedule mcron 10
  14139. @end example
  14140. @defvr {Scheme Variable} mcron-service-type
  14141. This is the type of the @code{mcron} service, whose value is an
  14142. @code{mcron-configuration} object.
  14143. This service type can be the target of a service extension that provides
  14144. additional job specifications (@pxref{Service Composition}). In other
  14145. words, it is possible to define services that provide additional mcron
  14146. jobs to run.
  14147. @end defvr
  14148. @deftp {Data Type} mcron-configuration
  14149. Data type representing the configuration of mcron.
  14150. @table @asis
  14151. @item @code{mcron} (default: @var{mcron})
  14152. The mcron package to use.
  14153. @item @code{jobs}
  14154. This is a list of gexps (@pxref{G-Expressions}), where each gexp
  14155. corresponds to an mcron job specification (@pxref{Syntax, mcron job
  14156. specifications,, mcron, GNU@tie{}mcron}).
  14157. @end table
  14158. @end deftp
  14159. @node Log Rotation
  14160. @subsection Log Rotation
  14161. @cindex rottlog
  14162. @cindex log rotation
  14163. @cindex logging
  14164. Log files such as those found in @file{/var/log} tend to grow endlessly,
  14165. so it's a good idea to @dfn{rotate} them once in a while---i.e., archive
  14166. their contents in separate files, possibly compressed. The @code{(gnu
  14167. services admin)} module provides an interface to GNU@tie{}Rot[t]log, a
  14168. log rotation tool (@pxref{Top,,, rottlog, GNU Rot[t]log Manual}).
  14169. This service is part of @code{%base-services}, and thus enabled by
  14170. default, with the default settings, for commonly encountered log files.
  14171. The example below shows how to extend it with an additional
  14172. @dfn{rotation}, should you need to do that (usually, services that
  14173. produce log files already take care of that):
  14174. @lisp
  14175. (use-modules (guix) (gnu))
  14176. (use-service-modules admin)
  14177. (define my-log-files
  14178. ;; Log files that I want to rotate.
  14179. '("/var/log/something.log" "/var/log/another.log"))
  14180. (operating-system
  14181. ;; @dots{}
  14182. (services (cons (simple-service 'rotate-my-stuff
  14183. rottlog-service-type
  14184. (list (log-rotation
  14185. (frequency 'daily)
  14186. (files my-log-files))))
  14187. %base-services)))
  14188. @end lisp
  14189. @defvr {Scheme Variable} rottlog-service-type
  14190. This is the type of the Rottlog service, whose value is a
  14191. @code{rottlog-configuration} object.
  14192. Other services can extend this one with new @code{log-rotation} objects
  14193. (see below), thereby augmenting the set of files to be rotated.
  14194. This service type can define mcron jobs (@pxref{Scheduled Job
  14195. Execution}) to run the rottlog service.
  14196. @end defvr
  14197. @deftp {Data Type} rottlog-configuration
  14198. Data type representing the configuration of rottlog.
  14199. @table @asis
  14200. @item @code{rottlog} (default: @code{rottlog})
  14201. The Rottlog package to use.
  14202. @item @code{rc-file} (default: @code{(file-append rottlog "/etc/rc")})
  14203. The Rottlog configuration file to use (@pxref{Mandatory RC Variables,,,
  14204. rottlog, GNU Rot[t]log Manual}).
  14205. @item @code{rotations} (default: @code{%default-rotations})
  14206. A list of @code{log-rotation} objects as defined below.
  14207. @item @code{jobs}
  14208. This is a list of gexps where each gexp corresponds to an mcron job
  14209. specification (@pxref{Scheduled Job Execution}).
  14210. @end table
  14211. @end deftp
  14212. @deftp {Data Type} log-rotation
  14213. Data type representing the rotation of a group of log files.
  14214. Taking an example from the Rottlog manual (@pxref{Period Related File
  14215. Examples,,, rottlog, GNU Rot[t]log Manual}), a log rotation might be
  14216. defined like this:
  14217. @lisp
  14218. (log-rotation
  14219. (frequency 'daily)
  14220. (files '("/var/log/apache/*"))
  14221. (options '("storedir apache-archives"
  14222. "rotate 6"
  14223. "notifempty"
  14224. "nocompress")))
  14225. @end lisp
  14226. The list of fields is as follows:
  14227. @table @asis
  14228. @item @code{frequency} (default: @code{'weekly})
  14229. The log rotation frequency, a symbol.
  14230. @item @code{files}
  14231. The list of files or file glob patterns to rotate.
  14232. @item @code{options} (default: @code{'()})
  14233. The list of rottlog options for this rotation (@pxref{Configuration
  14234. parameters,,, rottlog, GNU Rot[t]lg Manual}).
  14235. @item @code{post-rotate} (default: @code{#f})
  14236. Either @code{#f} or a gexp to execute once the rotation has completed.
  14237. @end table
  14238. @end deftp
  14239. @defvr {Scheme Variable} %default-rotations
  14240. Specifies weekly rotation of @code{%rotated-files} and of
  14241. @file{/var/log/guix-daemon.log}.
  14242. @end defvr
  14243. @defvr {Scheme Variable} %rotated-files
  14244. The list of syslog-controlled files to be rotated. By default it is:
  14245. @code{'("/var/log/messages" "/var/log/secure" "/var/log/debug" \
  14246. "/var/log/maillog")}.
  14247. @end defvr
  14248. @node Networking Setup
  14249. @subsection Networking Setup
  14250. The @code{(gnu services networking)} module provides services to
  14251. configure network interfaces and set up networking on your machine.
  14252. Those services provide different ways for you to set up your machine: by
  14253. declaring a static network configuration, by running a Dynamic Host
  14254. Configuration Protocol (DHCP) client, or by running daemons such as
  14255. NetworkManager and Connman that automate the whole process,
  14256. automatically adapt to connectivity changes, and provide a high-level
  14257. user interface.
  14258. On a laptop, NetworkManager and Connman are by far the most convenient
  14259. options, which is why the default desktop services include
  14260. NetworkManager (@pxref{Desktop Services, @code{%desktop-services}}).
  14261. For a server, or for a virtual machine or a container, static network
  14262. configuration or a simple DHCP client are often more appropriate.
  14263. This section describes the various network setup services available,
  14264. starting with static network configuration.
  14265. @defvr {Scheme Variable} static-networking-service-type
  14266. This is the type for statically-configured network interfaces. Its
  14267. value must be a list of @code{static-networking} records. Each of them
  14268. declares a set of @dfn{addresses}, @dfn{routes}, and @dfn{links}, as
  14269. show below.
  14270. @cindex network interface controller (NIC)
  14271. @cindex NIC, networking interface controller
  14272. Here is the simplest configuration, with only one network interface
  14273. controller (NIC) and only IPv4 connectivity:
  14274. @lisp
  14275. ;; Static networking for one NIC, IPv4-only.
  14276. (service static-networking-service-type
  14277. (list (static-networking
  14278. (addresses
  14279. (list (network-address
  14280. (device "eno1")
  14281. (value "10.0.2.15/24"))))
  14282. (routes
  14283. (list (network-route
  14284. (destination "default")
  14285. (gateway "10.0.2.2"))))
  14286. (name-servers '("10.0.2.3")))))
  14287. @end lisp
  14288. The snippet above can be added to the @code{services} field of your
  14289. operating system configuration (@pxref{Using the Configuration System}).
  14290. It will configure your machine to have 10.0.2.15 as its IP address, with
  14291. a 24-bit netmask for the local network---meaning that any 10.0.2.@var{x}
  14292. address is on the local area network (LAN). Traffic to addresses
  14293. outside the local network is routed @i{via} 10.0.2.2. Host names are
  14294. resolved by sending domain name system (DNS) queries to 10.0.2.3.
  14295. @end defvr
  14296. @deftp {Data Type} static-networking
  14297. This is the data type representing a static network configuration.
  14298. As an example, here is how you would declare the configuration of a
  14299. machine with a single network interface controller (NIC) available as
  14300. @code{eno1}, and with one IPv4 and one IPv6 address:
  14301. @lisp
  14302. ;; Network configuration for one NIC, IPv4 + IPv6.
  14303. (static-networking
  14304. (addresses (list (network-address
  14305. (device "eno1")
  14306. (value "10.0.2.15/24"))
  14307. (network-address
  14308. (device "eno1")
  14309. (value "2001:123:4567:101::1/64"))))
  14310. (routes (list (network-route
  14311. (destination "default")
  14312. (gateway "10.0.2.2"))
  14313. (network-route
  14314. (destination "default")
  14315. (gateway "2020:321:4567:42::1"))))
  14316. (name-servers '("10.0.2.3")))
  14317. @end lisp
  14318. If you are familiar with the @command{ip} command of the
  14319. @uref{https://wiki.linuxfoundation.org/networking/iproute2,
  14320. @code{iproute2} package} found on Linux-based systems, the declaration
  14321. above is equivalent to typing:
  14322. @example
  14323. ip address add 10.0.2.15/24 dev eno1
  14324. ip address add 2001:123:4567:101::1/64 dev eno1
  14325. ip route add default via inet 10.0.2.2
  14326. ip route add default via inet6 2020:321:4567:42::1
  14327. @end example
  14328. Run @command{man 8 ip} for more info. Venerable GNU/Linux users will
  14329. certainly know how to do it with @command{ifconfig} and @command{route},
  14330. but we'll spare you that.
  14331. The available fields of this data type are as follows:
  14332. @table @asis
  14333. @item @code{addresses}
  14334. @itemx @code{links} (default: @code{'()})
  14335. @itemx @code{routes} (default: @code{'()})
  14336. The list of @code{network-address}, @code{network-link}, and
  14337. @code{network-route} records for this network (see below).
  14338. @item @code{name-servers} (default: @code{'()})
  14339. The list of IP addresses (strings) of domain name servers. These IP
  14340. addresses go to @file{/etc/resolv.conf}.
  14341. @item @code{provision} (default: @code{'(networking)})
  14342. If true, this should be a list of symbols for the Shepherd service
  14343. corresponding to this network configuration.
  14344. @item @code{requirement} (default @code{'()})
  14345. The list of Shepherd services depended on.
  14346. @end table
  14347. @end deftp
  14348. @deftp {Data Type} network-address
  14349. This is the data type representing the IP address of a network
  14350. interface.
  14351. @table @code
  14352. @item device
  14353. The name of the network interface for this address---e.g.,
  14354. @code{"eno1"}.
  14355. @item value
  14356. The actual IP address and network mask, in
  14357. @uref{https://en.wikipedia.org/wiki/CIDR#CIDR_notation, @acronym{CIDR,
  14358. Classless Inter-Domain Routing} notation}, as a string.
  14359. For example, @code{"10.0.2.15/24"} denotes IPv4 address 10.0.2.15 on a
  14360. 24-bit sub-network---all 10.0.2.@var{x} addresses are on the same local
  14361. network.
  14362. @item ipv6?
  14363. Whether @code{value} denotes an IPv6 address. By default this is
  14364. automatically determined.
  14365. @end table
  14366. @end deftp
  14367. @deftp {Data Type} network-route
  14368. This is the data type representing a network route.
  14369. @table @asis
  14370. @item @code{destination}
  14371. The route destination (a string), either an IP address or
  14372. @code{"default"} to denote the default route.
  14373. @item @code{source} (default: @code{#f})
  14374. The route source.
  14375. @item @code{device} (default: @code{#f})
  14376. The device used for this route---e.g., @code{"eno2"}.
  14377. @item @code{ipv6?} (default: auto)
  14378. Whether this is an IPv6 route. By default this is automatically
  14379. determined based on @code{destination} or @code{gateway}.
  14380. @item @code{gateway} (default: @code{#f})
  14381. IP address (a string) through which traffic is routed.
  14382. @end table
  14383. @end deftp
  14384. @deftp {Data Type} network-link
  14385. Data type for a network link (@pxref{Link,,, guile-netlink,
  14386. Guile-Netlink Manual}).
  14387. @table @code
  14388. @item name
  14389. The name of the link---e.g., @code{"v0p0"}.
  14390. @item type
  14391. A symbol denoting the type of the link---e.g., @code{'veth}.
  14392. @item arguments
  14393. List of arguments for this type of link.
  14394. @end table
  14395. @end deftp
  14396. @cindex loopback device
  14397. @defvr {Scheme Variable} %loopback-static-networking
  14398. This is the @code{static-networking} record representing the ``loopback
  14399. device'', @code{lo}, for IP addresses 127.0.0.1 and ::1, and providing
  14400. the @code{loopback} Shepherd service.
  14401. @end defvr
  14402. @cindex networking, with QEMU
  14403. @cindex QEMU, networking
  14404. @defvr {Scheme Variable} %qemu-static-networking
  14405. This is the @code{static-networking} record representing network setup
  14406. when using QEMU's user-mode network stack on @code{eth0} (@pxref{Using
  14407. the user mode network stack,,, QEMU, QEMU Documentation}).
  14408. @end defvr
  14409. @cindex DHCP, networking service
  14410. @defvr {Scheme Variable} dhcp-client-service-type
  14411. This is the type of services that run @var{dhcp}, a Dynamic Host Configuration
  14412. Protocol (DHCP) client, on all the non-loopback network interfaces. Its value
  14413. is the DHCP client package to use, @code{isc-dhcp} by default.
  14414. @end defvr
  14415. @cindex NetworkManager
  14416. @defvr {Scheme Variable} network-manager-service-type
  14417. This is the service type for the
  14418. @uref{https://wiki.gnome.org/Projects/NetworkManager, NetworkManager}
  14419. service. The value for this service type is a
  14420. @code{network-manager-configuration} record.
  14421. This service is part of @code{%desktop-services} (@pxref{Desktop
  14422. Services}).
  14423. @end defvr
  14424. @deftp {Data Type} network-manager-configuration
  14425. Data type representing the configuration of NetworkManager.
  14426. @table @asis
  14427. @item @code{network-manager} (default: @code{network-manager})
  14428. The NetworkManager package to use.
  14429. @item @code{dns} (default: @code{"default"})
  14430. Processing mode for DNS, which affects how NetworkManager uses the
  14431. @code{resolv.conf} configuration file.
  14432. @table @samp
  14433. @item default
  14434. NetworkManager will update @code{resolv.conf} to reflect the nameservers
  14435. provided by currently active connections.
  14436. @item dnsmasq
  14437. NetworkManager will run @code{dnsmasq} as a local caching nameserver, using a
  14438. @dfn{conditional forwarding} configuration if you are connected to a VPN, and
  14439. then update @code{resolv.conf} to point to the local nameserver.
  14440. With this setting, you can share your network connection. For example when
  14441. you want to share your network connection to another laptop @i{via} an
  14442. Ethernet cable, you can open @command{nm-connection-editor} and configure the
  14443. Wired connection's method for IPv4 and IPv6 to be ``Shared to other computers''
  14444. and reestablish the connection (or reboot).
  14445. You can also set up a @dfn{host-to-guest connection} to QEMU VMs
  14446. (@pxref{Installing Guix in a VM}). With a host-to-guest connection, you can
  14447. e.g.@: access a Web server running on the VM (@pxref{Web Services}) from a Web
  14448. browser on your host system, or connect to the VM @i{via} SSH
  14449. (@pxref{Networking Services, @code{openssh-service-type}}). To set up a
  14450. host-to-guest connection, run this command once:
  14451. @example
  14452. nmcli connection add type tun \
  14453. connection.interface-name tap0 \
  14454. tun.mode tap tun.owner $(id -u) \
  14455. ipv4.method shared \
  14456. ipv4.addresses 172.28.112.1/24
  14457. @end example
  14458. Then each time you launch your QEMU VM (@pxref{Running Guix in a VM}), pass
  14459. @option{-nic tap,ifname=tap0,script=no,downscript=no} to
  14460. @command{qemu-system-...}.
  14461. @item none
  14462. NetworkManager will not modify @code{resolv.conf}.
  14463. @end table
  14464. @item @code{vpn-plugins} (default: @code{'()})
  14465. This is the list of available plugins for virtual private networks
  14466. (VPNs). An example of this is the @code{network-manager-openvpn}
  14467. package, which allows NetworkManager to manage VPNs @i{via} OpenVPN.
  14468. @end table
  14469. @end deftp
  14470. @cindex Connman
  14471. @deffn {Scheme Variable} connman-service-type
  14472. This is the service type to run @url{https://01.org/connman,Connman},
  14473. a network connection manager.
  14474. Its value must be an
  14475. @code{connman-configuration} record as in this example:
  14476. @lisp
  14477. (service connman-service-type
  14478. (connman-configuration
  14479. (disable-vpn? #t)))
  14480. @end lisp
  14481. See below for details about @code{connman-configuration}.
  14482. @end deffn
  14483. @deftp {Data Type} connman-configuration
  14484. Data Type representing the configuration of connman.
  14485. @table @asis
  14486. @item @code{connman} (default: @var{connman})
  14487. The connman package to use.
  14488. @item @code{disable-vpn?} (default: @code{#f})
  14489. When true, disable connman's vpn plugin.
  14490. @end table
  14491. @end deftp
  14492. @cindex WPA Supplicant
  14493. @defvr {Scheme Variable} wpa-supplicant-service-type
  14494. This is the service type to run @url{https://w1.fi/wpa_supplicant/,WPA
  14495. supplicant}, an authentication daemon required to authenticate against
  14496. encrypted WiFi or ethernet networks.
  14497. @end defvr
  14498. @deftp {Data Type} wpa-supplicant-configuration
  14499. Data type representing the configuration of WPA Supplicant.
  14500. It takes the following parameters:
  14501. @table @asis
  14502. @item @code{wpa-supplicant} (default: @code{wpa-supplicant})
  14503. The WPA Supplicant package to use.
  14504. @item @code{requirement} (default: @code{'(user-processes loopback syslogd)}
  14505. List of services that should be started before WPA Supplicant starts.
  14506. @item @code{dbus?} (default: @code{#t})
  14507. Whether to listen for requests on D-Bus.
  14508. @item @code{pid-file} (default: @code{"/var/run/wpa_supplicant.pid"})
  14509. Where to store the PID file.
  14510. @item @code{interface} (default: @code{#f})
  14511. If this is set, it must specify the name of a network interface that
  14512. WPA supplicant will control.
  14513. @item @code{config-file} (default: @code{#f})
  14514. Optional configuration file to use.
  14515. @item @code{extra-options} (default: @code{'()})
  14516. List of additional command-line arguments to pass to the daemon.
  14517. @end table
  14518. @end deftp
  14519. @cindex wicd
  14520. @cindex wireless
  14521. @cindex WiFi
  14522. @cindex network management
  14523. @deffn {Scheme Procedure} wicd-service [#:wicd @var{wicd}]
  14524. Return a service that runs @url{https://launchpad.net/wicd,Wicd}, a network
  14525. management daemon that aims to simplify wired and wireless networking.
  14526. This service adds the @var{wicd} package to the global profile, providing
  14527. several commands to interact with the daemon and configure networking:
  14528. @command{wicd-client}, a graphical user interface, and the @command{wicd-cli}
  14529. and @command{wicd-curses} user interfaces.
  14530. @end deffn
  14531. @cindex ModemManager
  14532. Some networking devices such as modems require special care, and this is
  14533. what the services below focus on.
  14534. @defvr {Scheme Variable} modem-manager-service-type
  14535. This is the service type for the
  14536. @uref{https://wiki.gnome.org/Projects/ModemManager, ModemManager}
  14537. service. The value for this service type is a
  14538. @code{modem-manager-configuration} record.
  14539. This service is part of @code{%desktop-services} (@pxref{Desktop
  14540. Services}).
  14541. @end defvr
  14542. @deftp {Data Type} modem-manager-configuration
  14543. Data type representing the configuration of ModemManager.
  14544. @table @asis
  14545. @item @code{modem-manager} (default: @code{modem-manager})
  14546. The ModemManager package to use.
  14547. @end table
  14548. @end deftp
  14549. @cindex USB_ModeSwitch
  14550. @cindex Modeswitching
  14551. @defvr {Scheme Variable} usb-modeswitch-service-type
  14552. This is the service type for the
  14553. @uref{https://www.draisberghof.de/usb_modeswitch/, USB_ModeSwitch}
  14554. service. The value for this service type is
  14555. a @code{usb-modeswitch-configuration} record.
  14556. When plugged in, some USB modems (and other USB devices) initially present
  14557. themselves as a read-only storage medium and not as a modem. They need to be
  14558. @dfn{modeswitched} before they are usable. The USB_ModeSwitch service type
  14559. installs udev rules to automatically modeswitch these devices when they are
  14560. plugged in.
  14561. This service is part of @code{%desktop-services} (@pxref{Desktop
  14562. Services}).
  14563. @end defvr
  14564. @deftp {Data Type} usb-modeswitch-configuration
  14565. Data type representing the configuration of USB_ModeSwitch.
  14566. @table @asis
  14567. @item @code{usb-modeswitch} (default: @code{usb-modeswitch})
  14568. The USB_ModeSwitch package providing the binaries for modeswitching.
  14569. @item @code{usb-modeswitch-data} (default: @code{usb-modeswitch-data})
  14570. The package providing the device data and udev rules file used by
  14571. USB_ModeSwitch.
  14572. @item @code{config-file} (default: @code{#~(string-append #$usb-modeswitch:dispatcher "/etc/usb_modeswitch.conf")})
  14573. Which config file to use for the USB_ModeSwitch dispatcher. By default the
  14574. config file shipped with USB_ModeSwitch is used which disables logging to
  14575. @file{/var/log} among other default settings. If set to @code{#f}, no config
  14576. file is used.
  14577. @end table
  14578. @end deftp
  14579. @node Networking Services
  14580. @subsection Networking Services
  14581. The @code{(gnu services networking)} module discussed in the previous
  14582. section provides services for more advanced setups: providing a DHCP
  14583. service for others to use, filtering packets with iptables or nftables,
  14584. running a WiFi access point with @command{hostapd}, running the
  14585. @command{inetd} ``superdaemon'', and more. This section describes
  14586. those.
  14587. @deffn {Scheme Procedure} dhcpd-service-type
  14588. This type defines a service that runs a DHCP daemon. To create a
  14589. service of this type, you must supply a @code{<dhcpd-configuration>}.
  14590. For example:
  14591. @lisp
  14592. (service dhcpd-service-type
  14593. (dhcpd-configuration
  14594. (config-file (local-file "my-dhcpd.conf"))
  14595. (interfaces '("enp0s25"))))
  14596. @end lisp
  14597. @end deffn
  14598. @deftp {Data Type} dhcpd-configuration
  14599. @table @asis
  14600. @item @code{package} (default: @code{isc-dhcp})
  14601. The package that provides the DHCP daemon. This package is expected to
  14602. provide the daemon at @file{sbin/dhcpd} relative to its output
  14603. directory. The default package is the
  14604. @uref{https://www.isc.org/products/DHCP, ISC's DHCP server}.
  14605. @item @code{config-file} (default: @code{#f})
  14606. The configuration file to use. This is required. It will be passed to
  14607. @code{dhcpd} via its @code{-cf} option. This may be any ``file-like''
  14608. object (@pxref{G-Expressions, file-like objects}). See @code{man
  14609. dhcpd.conf} for details on the configuration file syntax.
  14610. @item @code{version} (default: @code{"4"})
  14611. The DHCP version to use. The ISC DHCP server supports the values ``4'',
  14612. ``6'', and ``4o6''. These correspond to the @code{dhcpd} program
  14613. options @code{-4}, @code{-6}, and @code{-4o6}. See @code{man dhcpd} for
  14614. details.
  14615. @item @code{run-directory} (default: @code{"/run/dhcpd"})
  14616. The run directory to use. At service activation time, this directory
  14617. will be created if it does not exist.
  14618. @item @code{pid-file} (default: @code{"/run/dhcpd/dhcpd.pid"})
  14619. The PID file to use. This corresponds to the @code{-pf} option of
  14620. @code{dhcpd}. See @code{man dhcpd} for details.
  14621. @item @code{interfaces} (default: @code{'()})
  14622. The names of the network interfaces on which dhcpd should listen for
  14623. broadcasts. If this list is not empty, then its elements (which must be
  14624. strings) will be appended to the @code{dhcpd} invocation when starting
  14625. the daemon. It may not be necessary to explicitly specify any
  14626. interfaces here; see @code{man dhcpd} for details.
  14627. @end table
  14628. @end deftp
  14629. @cindex hostapd service, for Wi-Fi access points
  14630. @cindex Wi-Fi access points, hostapd service
  14631. @defvr {Scheme Variable} hostapd-service-type
  14632. This is the service type to run the @uref{https://w1.fi/hostapd/,
  14633. hostapd} daemon to set up WiFi (IEEE 802.11) access points and
  14634. authentication servers. Its associated value must be a
  14635. @code{hostapd-configuration} as shown below:
  14636. @lisp
  14637. ;; Use wlan1 to run the access point for "My Network".
  14638. (service hostapd-service-type
  14639. (hostapd-configuration
  14640. (interface "wlan1")
  14641. (ssid "My Network")
  14642. (channel 12)))
  14643. @end lisp
  14644. @end defvr
  14645. @deftp {Data Type} hostapd-configuration
  14646. This data type represents the configuration of the hostapd service, with
  14647. the following fields:
  14648. @table @asis
  14649. @item @code{package} (default: @code{hostapd})
  14650. The hostapd package to use.
  14651. @item @code{interface} (default: @code{"wlan0"})
  14652. The network interface to run the WiFi access point.
  14653. @item @code{ssid}
  14654. The SSID (@dfn{service set identifier}), a string that identifies this
  14655. network.
  14656. @item @code{broadcast-ssid?} (default: @code{#t})
  14657. Whether to broadcast this SSID.
  14658. @item @code{channel} (default: @code{1})
  14659. The WiFi channel to use.
  14660. @item @code{driver} (default: @code{"nl80211"})
  14661. The driver interface type. @code{"nl80211"} is used with all Linux
  14662. mac80211 drivers. Use @code{"none"} if building hostapd as a standalone
  14663. RADIUS server that does # not control any wireless/wired driver.
  14664. @item @code{extra-settings} (default: @code{""})
  14665. Extra settings to append as-is to the hostapd configuration file. See
  14666. @uref{https://w1.fi/cgit/hostap/plain/hostapd/hostapd.conf} for the
  14667. configuration file reference.
  14668. @end table
  14669. @end deftp
  14670. @defvr {Scheme Variable} simulated-wifi-service-type
  14671. This is the type of a service to simulate WiFi networking, which can be
  14672. useful in virtual machines for testing purposes. The service loads the
  14673. Linux kernel
  14674. @uref{https://www.kernel.org/doc/html/latest/networking/mac80211_hwsim/mac80211_hwsim.html,
  14675. @code{mac80211_hwsim} module} and starts hostapd to create a pseudo WiFi
  14676. network that can be seen on @code{wlan0}, by default.
  14677. The service's value is a @code{hostapd-configuration} record.
  14678. @end defvr
  14679. @cindex iptables
  14680. @defvr {Scheme Variable} iptables-service-type
  14681. This is the service type to set up an iptables configuration. iptables is a
  14682. packet filtering framework supported by the Linux kernel. This service
  14683. supports configuring iptables for both IPv4 and IPv6. A simple example
  14684. configuration rejecting all incoming connections except those to the ssh port
  14685. 22 is shown below.
  14686. @lisp
  14687. (service iptables-service-type
  14688. (iptables-configuration
  14689. (ipv4-rules (plain-file "iptables.rules" "*filter
  14690. :INPUT ACCEPT
  14691. :FORWARD ACCEPT
  14692. :OUTPUT ACCEPT
  14693. -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
  14694. -A INPUT -p tcp --dport 22 -j ACCEPT
  14695. -A INPUT -j REJECT --reject-with icmp-port-unreachable
  14696. COMMIT
  14697. "))
  14698. (ipv6-rules (plain-file "ip6tables.rules" "*filter
  14699. :INPUT ACCEPT
  14700. :FORWARD ACCEPT
  14701. :OUTPUT ACCEPT
  14702. -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
  14703. -A INPUT -p tcp --dport 22 -j ACCEPT
  14704. -A INPUT -j REJECT --reject-with icmp6-port-unreachable
  14705. COMMIT
  14706. "))))
  14707. @end lisp
  14708. @end defvr
  14709. @deftp {Data Type} iptables-configuration
  14710. The data type representing the configuration of iptables.
  14711. @table @asis
  14712. @item @code{iptables} (default: @code{iptables})
  14713. The iptables package that provides @code{iptables-restore} and
  14714. @code{ip6tables-restore}.
  14715. @item @code{ipv4-rules} (default: @code{%iptables-accept-all-rules})
  14716. The iptables rules to use. It will be passed to @code{iptables-restore}.
  14717. This may be any ``file-like'' object (@pxref{G-Expressions, file-like
  14718. objects}).
  14719. @item @code{ipv6-rules} (default: @code{%iptables-accept-all-rules})
  14720. The ip6tables rules to use. It will be passed to @code{ip6tables-restore}.
  14721. This may be any ``file-like'' object (@pxref{G-Expressions, file-like
  14722. objects}).
  14723. @end table
  14724. @end deftp
  14725. @cindex nftables
  14726. @defvr {Scheme Variable} nftables-service-type
  14727. This is the service type to set up a nftables configuration. nftables is a
  14728. netfilter project that aims to replace the existing iptables, ip6tables,
  14729. arptables and ebtables framework. It provides a new packet filtering
  14730. framework, a new user-space utility @command{nft}, and a compatibility layer
  14731. for iptables. This service comes with a default ruleset
  14732. @code{%default-nftables-ruleset} that rejecting all incoming connections
  14733. except those to the ssh port 22. To use it, simply write:
  14734. @lisp
  14735. (service nftables-service-type)
  14736. @end lisp
  14737. @end defvr
  14738. @deftp {Data Type} nftables-configuration
  14739. The data type representing the configuration of nftables.
  14740. @table @asis
  14741. @item @code{package} (default: @code{nftables})
  14742. The nftables package that provides @command{nft}.
  14743. @item @code{ruleset} (default: @code{%default-nftables-ruleset})
  14744. The nftables ruleset to use. This may be any ``file-like'' object
  14745. (@pxref{G-Expressions, file-like objects}).
  14746. @end table
  14747. @end deftp
  14748. @cindex NTP (Network Time Protocol), service
  14749. @cindex ntpd, service for the Network Time Protocol daemon
  14750. @cindex real time clock
  14751. @defvr {Scheme Variable} ntp-service-type
  14752. This is the type of the service running the @uref{https://www.ntp.org,
  14753. Network Time Protocol (NTP)} daemon, @command{ntpd}. The daemon will keep the
  14754. system clock synchronized with that of the specified NTP servers.
  14755. The value of this service is an @code{ntpd-configuration} object, as described
  14756. below.
  14757. @end defvr
  14758. @deftp {Data Type} ntp-configuration
  14759. This is the data type for the NTP service configuration.
  14760. @table @asis
  14761. @item @code{servers} (default: @code{%ntp-servers})
  14762. This is the list of servers (@code{<ntp-server>} records) with which
  14763. @command{ntpd} will be synchronized. See the @code{ntp-server} data type
  14764. definition below.
  14765. @item @code{allow-large-adjustment?} (default: @code{#t})
  14766. This determines whether @command{ntpd} is allowed to make an initial
  14767. adjustment of more than 1,000 seconds.
  14768. @item @code{ntp} (default: @code{ntp})
  14769. The NTP package to use.
  14770. @end table
  14771. @end deftp
  14772. @defvr {Scheme Variable} %ntp-servers
  14773. List of host names used as the default NTP servers. These are servers of the
  14774. @uref{https://www.ntppool.org/en/, NTP Pool Project}.
  14775. @end defvr
  14776. @deftp {Data Type} ntp-server
  14777. The data type representing the configuration of a NTP server.
  14778. @table @asis
  14779. @item @code{type} (default: @code{'server})
  14780. The type of the NTP server, given as a symbol. One of @code{'pool},
  14781. @code{'server}, @code{'peer}, @code{'broadcast} or @code{'manycastclient}.
  14782. @item @code{address}
  14783. The address of the server, as a string.
  14784. @item @code{options}
  14785. NTPD options to use with that specific server, given as a list of option names
  14786. and/or of option names and values tuples. The following example define a server
  14787. to use with the options @option{iburst} and @option{prefer}, as well as
  14788. @option{version} 3 and a @option{maxpoll} time of 16 seconds.
  14789. @example
  14790. (ntp-server
  14791. (type 'server)
  14792. (address "some.ntp.server.org")
  14793. (options `(iburst (version 3) (maxpoll 16) prefer))))
  14794. @end example
  14795. @end table
  14796. @end deftp
  14797. @cindex OpenNTPD
  14798. @deffn {Scheme Procedure} openntpd-service-type
  14799. Run the @command{ntpd}, the Network Time Protocol (NTP) daemon, as implemented
  14800. by @uref{http://www.openntpd.org, OpenNTPD}. The daemon will keep the system
  14801. clock synchronized with that of the given servers.
  14802. @lisp
  14803. (service
  14804. openntpd-service-type
  14805. (openntpd-configuration
  14806. (listen-on '("127.0.0.1" "::1"))
  14807. (sensor '("udcf0 correction 70000"))
  14808. (constraint-from '("www.gnu.org"))
  14809. (constraints-from '("https://www.google.com/"))))
  14810. @end lisp
  14811. @end deffn
  14812. @defvr {Scheme Variable} %openntpd-servers
  14813. This variable is a list of the server addresses defined in
  14814. @code{%ntp-servers}.
  14815. @end defvr
  14816. @deftp {Data Type} openntpd-configuration
  14817. @table @asis
  14818. @item @code{openntpd} (default: @code{(file-append openntpd "/sbin/ntpd")})
  14819. The openntpd executable to use.
  14820. @item @code{listen-on} (default: @code{'("127.0.0.1" "::1")})
  14821. A list of local IP addresses or hostnames the ntpd daemon should listen on.
  14822. @item @code{query-from} (default: @code{'()})
  14823. A list of local IP address the ntpd daemon should use for outgoing queries.
  14824. @item @code{sensor} (default: @code{'()})
  14825. Specify a list of timedelta sensor devices ntpd should use. @code{ntpd}
  14826. will listen to each sensor that actually exists and ignore non-existent ones.
  14827. See @uref{https://man.openbsd.org/ntpd.conf, upstream documentation} for more
  14828. information.
  14829. @item @code{server} (default: @code{'()})
  14830. Specify a list of IP addresses or hostnames of NTP servers to synchronize to.
  14831. @item @code{servers} (default: @code{%openntp-servers})
  14832. Specify a list of IP addresses or hostnames of NTP pools to synchronize to.
  14833. @item @code{constraint-from} (default: @code{'()})
  14834. @code{ntpd} can be configured to query the ‘Date’ from trusted HTTPS servers via TLS.
  14835. This time information is not used for precision but acts as an authenticated
  14836. constraint, thereby reducing the impact of unauthenticated NTP
  14837. man-in-the-middle attacks.
  14838. Specify a list of URLs, IP addresses or hostnames of HTTPS servers to provide
  14839. a constraint.
  14840. @item @code{constraints-from} (default: @code{'()})
  14841. As with constraint from, specify a list of URLs, IP addresses or hostnames of
  14842. HTTPS servers to provide a constraint. Should the hostname resolve to multiple
  14843. IP addresses, @code{ntpd} will calculate a median constraint from all of them.
  14844. @end table
  14845. @end deftp
  14846. @cindex inetd
  14847. @deffn {Scheme variable} inetd-service-type
  14848. This service runs the @command{inetd} (@pxref{inetd invocation,,,
  14849. inetutils, GNU Inetutils}) daemon. @command{inetd} listens for
  14850. connections on internet sockets, and lazily starts the specified server
  14851. program when a connection is made on one of these sockets.
  14852. The value of this service is an @code{inetd-configuration} object. The
  14853. following example configures the @command{inetd} daemon to provide the
  14854. built-in @command{echo} service, as well as an smtp service which
  14855. forwards smtp traffic over ssh to a server @code{smtp-server} behind a
  14856. gateway @code{hostname}:
  14857. @lisp
  14858. (service
  14859. inetd-service-type
  14860. (inetd-configuration
  14861. (entries (list
  14862. (inetd-entry
  14863. (name "echo")
  14864. (socket-type 'stream)
  14865. (protocol "tcp")
  14866. (wait? #f)
  14867. (user "root"))
  14868. (inetd-entry
  14869. (node "127.0.0.1")
  14870. (name "smtp")
  14871. (socket-type 'stream)
  14872. (protocol "tcp")
  14873. (wait? #f)
  14874. (user "root")
  14875. (program (file-append openssh "/bin/ssh"))
  14876. (arguments
  14877. '("ssh" "-qT" "-i" "/path/to/ssh_key"
  14878. "-W" "smtp-server:25" "user@@hostname")))))))
  14879. @end lisp
  14880. See below for more details about @code{inetd-configuration}.
  14881. @end deffn
  14882. @deftp {Data Type} inetd-configuration
  14883. Data type representing the configuration of @command{inetd}.
  14884. @table @asis
  14885. @item @code{program} (default: @code{(file-append inetutils "/libexec/inetd")})
  14886. The @command{inetd} executable to use.
  14887. @item @code{entries} (default: @code{'()})
  14888. A list of @command{inetd} service entries. Each entry should be created
  14889. by the @code{inetd-entry} constructor.
  14890. @end table
  14891. @end deftp
  14892. @deftp {Data Type} inetd-entry
  14893. Data type representing an entry in the @command{inetd} configuration.
  14894. Each entry corresponds to a socket where @command{inetd} will listen for
  14895. requests.
  14896. @table @asis
  14897. @item @code{node} (default: @code{#f})
  14898. Optional string, a comma-separated list of local addresses
  14899. @command{inetd} should use when listening for this service.
  14900. @xref{Configuration file,,, inetutils, GNU Inetutils} for a complete
  14901. description of all options.
  14902. @item @code{name}
  14903. A string, the name must correspond to an entry in @code{/etc/services}.
  14904. @item @code{socket-type}
  14905. One of @code{'stream}, @code{'dgram}, @code{'raw}, @code{'rdm} or
  14906. @code{'seqpacket}.
  14907. @item @code{protocol}
  14908. A string, must correspond to an entry in @code{/etc/protocols}.
  14909. @item @code{wait?} (default: @code{#t})
  14910. Whether @command{inetd} should wait for the server to exit before
  14911. listening to new service requests.
  14912. @item @code{user}
  14913. A string containing the user (and, optionally, group) name of the user
  14914. as whom the server should run. The group name can be specified in a
  14915. suffix, separated by a colon or period, i.e.@: @code{"user"},
  14916. @code{"user:group"} or @code{"user.group"}.
  14917. @item @code{program} (default: @code{"internal"})
  14918. The server program which will serve the requests, or @code{"internal"}
  14919. if @command{inetd} should use a built-in service.
  14920. @item @code{arguments} (default: @code{'()})
  14921. A list strings or file-like objects, which are the server program's
  14922. arguments, starting with the zeroth argument, i.e.@: the name of the
  14923. program itself. For @command{inetd}'s internal services, this entry
  14924. must be @code{'()} or @code{'("internal")}.
  14925. @end table
  14926. @xref{Configuration file,,, inetutils, GNU Inetutils} for a more
  14927. detailed discussion of each configuration field.
  14928. @end deftp
  14929. @cindex opendht, distributed hash table network service
  14930. @cindex dhtproxy, for use with jami
  14931. @defvr {Scheme Variable} opendht-service-type
  14932. This is the type of the service running a @uref{https://opendht.net,
  14933. OpenDHT} node, @command{dhtnode}. The daemon can be used to host your
  14934. own proxy service to the distributed hash table (DHT), for example to
  14935. connect to with Jami, among other applications.
  14936. @quotation Important
  14937. When using the OpenDHT proxy server, the IP addresses it ``sees'' from
  14938. the clients should be addresses reachable from other peers. In practice
  14939. this means that a publicly reachable address is best suited for a proxy
  14940. server, outside of your private network. For example, hosting the proxy
  14941. server on a IPv4 private local network and exposing it via port
  14942. forwarding could work for external peers, but peers local to the proxy
  14943. would have their private addresses shared with the external peers,
  14944. leading to connectivity problems.
  14945. @end quotation
  14946. The value of this service is a @code{opendht-configuration} object, as
  14947. described below.
  14948. @end defvr
  14949. @deftp {Data Type} opendht-configuration
  14950. This is the data type for the OpenDHT service configuration.
  14951. @c The fields documentation has been auto-generated using the
  14952. @c configuration->documentation procedure from
  14953. @c (gnu services configuration).
  14954. Available @code{opendht-configuration} fields are:
  14955. @deftypevr {@code{opendht-configuration} parameter} package opendht
  14956. The @code{opendht} package to use.
  14957. @end deftypevr
  14958. @deftypevr {@code{opendht-configuration} parameter} boolean peer-discovery?
  14959. Whether to enable the multicast local peer discovery mechanism.
  14960. Defaults to @samp{#f}.
  14961. @end deftypevr
  14962. @deftypevr {@code{opendht-configuration} parameter} boolean enable-logging?
  14963. Whether to enable logging messages to syslog. It is disabled by default
  14964. as it is rather verbose.
  14965. Defaults to @samp{#f}.
  14966. @end deftypevr
  14967. @deftypevr {@code{opendht-configuration} parameter} boolean debug?
  14968. Whether to enable debug-level logging messages. This has no effect if
  14969. logging is disabled.
  14970. Defaults to @samp{#f}.
  14971. @end deftypevr
  14972. @deftypevr {@code{opendht-configuration} parameter} maybe-string bootstrap-host
  14973. The node host name that is used to make the first connection to the
  14974. network. A specific port value can be provided by appending the
  14975. @code{:PORT} suffix. By default, it uses the Jami bootstrap nodes, but
  14976. any host can be specified here. It's also possible to disable
  14977. bootsrapping by setting this to the @code{'disabled} symbol.
  14978. Defaults to @samp{"bootstrap.jami.net:4222"}.
  14979. @end deftypevr
  14980. @deftypevr {@code{opendht-configuration} parameter} maybe-number port
  14981. The UDP port to bind to. When set to @code{'disabled}, an available
  14982. port is automatically selected.
  14983. Defaults to @samp{4222}.
  14984. @end deftypevr
  14985. @deftypevr {@code{opendht-configuration} parameter} maybe-number proxy-server-port
  14986. Spawn a proxy server listening on the specified port.
  14987. Defaults to @samp{disabled}.
  14988. @end deftypevr
  14989. @deftypevr {@code{opendht-configuration} parameter} maybe-number proxy-server-port-tls
  14990. Spawn a proxy server listening to TLS connections on the specified port.
  14991. Defaults to @samp{disabled}.
  14992. @end deftypevr
  14993. @end deftp
  14994. @cindex Tor
  14995. @defvr {Scheme Variable} tor-service-type
  14996. This is the type for a service that runs the @uref{https://torproject.org,
  14997. Tor} anonymous networking daemon. The service is configured using a
  14998. @code{<tor-configuration>} record. By default, the Tor daemon runs as the
  14999. @code{tor} unprivileged user, which is a member of the @code{tor} group.
  15000. @end defvr
  15001. @deftp {Data Type} tor-configuration
  15002. @table @asis
  15003. @item @code{tor} (default: @code{tor})
  15004. The package that provides the Tor daemon. This package is expected to provide
  15005. the daemon at @file{bin/tor} relative to its output directory. The default
  15006. package is the @uref{https://www.torproject.org, Tor Project's}
  15007. implementation.
  15008. @item @code{config-file} (default: @code{(plain-file "empty" "")})
  15009. The configuration file to use. It will be appended to a default configuration
  15010. file, and the final configuration file will be passed to @code{tor} via its
  15011. @code{-f} option. This may be any ``file-like'' object (@pxref{G-Expressions,
  15012. file-like objects}). See @code{man tor} for details on the configuration file
  15013. syntax.
  15014. @item @code{hidden-services} (default: @code{'()})
  15015. The list of @code{<hidden-service>} records to use. For any hidden service
  15016. you include in this list, appropriate configuration to enable the hidden
  15017. service will be automatically added to the default configuration file. You
  15018. may conveniently create @code{<hidden-service>} records using the
  15019. @code{tor-hidden-service} procedure described below.
  15020. @item @code{socks-socket-type} (default: @code{'tcp})
  15021. The default socket type that Tor should use for its SOCKS socket. This must
  15022. be either @code{'tcp} or @code{'unix}. If it is @code{'tcp}, then by default
  15023. Tor will listen on TCP port 9050 on the loopback interface (i.e., localhost).
  15024. If it is @code{'unix}, then Tor will listen on the UNIX domain socket
  15025. @file{/var/run/tor/socks-sock}, which will be made writable by members of the
  15026. @code{tor} group.
  15027. If you want to customize the SOCKS socket in more detail, leave
  15028. @code{socks-socket-type} at its default value of @code{'tcp} and use
  15029. @code{config-file} to override the default by providing your own
  15030. @code{SocksPort} option.
  15031. @item @code{control-socket?} (default: @code{#f})
  15032. Whether or not to provide a ``control socket'' by which Tor can be
  15033. controlled to, for instance, dynamically instantiate tor onion services.
  15034. If @code{#t}, Tor will listen for control commands on the UNIX domain socket
  15035. @file{/var/run/tor/control-sock}, which will be made writable by members of the
  15036. @code{tor} group.
  15037. @end table
  15038. @end deftp
  15039. @cindex hidden service
  15040. @deffn {Scheme Procedure} tor-hidden-service @var{name} @var{mapping}
  15041. Define a new Tor @dfn{hidden service} called @var{name} and implementing
  15042. @var{mapping}. @var{mapping} is a list of port/host tuples, such as:
  15043. @example
  15044. '((22 "127.0.0.1:22")
  15045. (80 "127.0.0.1:8080"))
  15046. @end example
  15047. In this example, port 22 of the hidden service is mapped to local port 22, and
  15048. port 80 is mapped to local port 8080.
  15049. This creates a @file{/var/lib/tor/hidden-services/@var{name}} directory, where
  15050. the @file{hostname} file contains the @code{.onion} host name for the hidden
  15051. service.
  15052. See @uref{https://www.torproject.org/docs/tor-hidden-service.html.en, the Tor
  15053. project's documentation} for more information.
  15054. @end deffn
  15055. The @code{(gnu services rsync)} module provides the following services:
  15056. You might want an rsync daemon if you have files that you want available
  15057. so anyone (or just yourself) can download existing files or upload new
  15058. files.
  15059. @deffn {Scheme Variable} rsync-service-type
  15060. This is the service type for the @uref{https://rsync.samba.org, rsync} daemon,
  15061. The value for this service type is a
  15062. @command{rsync-configuration} record as in this example:
  15063. @lisp
  15064. ;; Export two directories over rsync. By default rsync listens on
  15065. ;; all the network interfaces.
  15066. (service rsync-service-type
  15067. (rsync-configuration
  15068. (modules (list (rsync-module
  15069. (name "music")
  15070. (file-name "/srv/zik")
  15071. (read-only? #f))
  15072. (rsync-module
  15073. (name "movies")
  15074. (file-name "/home/charlie/movies"))))))
  15075. @end lisp
  15076. See below for details about @code{rsync-configuration}.
  15077. @end deffn
  15078. @deftp {Data Type} rsync-configuration
  15079. Data type representing the configuration for @code{rsync-service}.
  15080. @table @asis
  15081. @item @code{package} (default: @var{rsync})
  15082. @code{rsync} package to use.
  15083. @item @code{address} (default: @code{#f})
  15084. IP address on which @command{rsync} listens for incoming connections.
  15085. If unspecified, it defaults to listening on all available addresses.
  15086. @item @code{port-number} (default: @code{873})
  15087. TCP port on which @command{rsync} listens for incoming connections. If port
  15088. is less than @code{1024} @command{rsync} needs to be started as the
  15089. @code{root} user and group.
  15090. @item @code{pid-file} (default: @code{"/var/run/rsyncd/rsyncd.pid"})
  15091. Name of the file where @command{rsync} writes its PID.
  15092. @item @code{lock-file} (default: @code{"/var/run/rsyncd/rsyncd.lock"})
  15093. Name of the file where @command{rsync} writes its lock file.
  15094. @item @code{log-file} (default: @code{"/var/log/rsyncd.log"})
  15095. Name of the file where @command{rsync} writes its log file.
  15096. @item @code{user} (default: @code{"root"})
  15097. Owner of the @code{rsync} process.
  15098. @item @code{group} (default: @code{"root"})
  15099. Group of the @code{rsync} process.
  15100. @item @code{uid} (default: @code{"rsyncd"})
  15101. User name or user ID that file transfers to and from that module should take
  15102. place as when the daemon was run as @code{root}.
  15103. @item @code{gid} (default: @code{"rsyncd"})
  15104. Group name or group ID that will be used when accessing the module.
  15105. @item @code{modules} (default: @code{%default-modules})
  15106. List of ``modules''---i.e., directories exported over rsync. Each
  15107. element must be a @code{rsync-module} record, as described below.
  15108. @end table
  15109. @end deftp
  15110. @deftp {Data Type} rsync-module
  15111. This is the data type for rsync ``modules''. A module is a directory
  15112. exported over the rsync protocol. The available fields are as follows:
  15113. @table @asis
  15114. @item @code{name}
  15115. The module name. This is the name that shows up in URLs. For example,
  15116. if the module is called @code{music}, the corresponding URL will be
  15117. @code{rsync://host.example.org/music}.
  15118. @item @code{file-name}
  15119. Name of the directory being exported.
  15120. @item @code{comment} (default: @code{""})
  15121. Comment associated with the module. Client user interfaces may display
  15122. it when they obtain the list of available modules.
  15123. @item @code{read-only?} (default: @code{#t})
  15124. Whether or not client will be able to upload files. If this is false,
  15125. the uploads will be authorized if permissions on the daemon side permit
  15126. it.
  15127. @item @code{chroot?} (default: @code{#t})
  15128. When this is true, the rsync daemon changes root to the module's
  15129. directory before starting file transfers with the client. This improves
  15130. security, but requires rsync to run as root.
  15131. @item @code{timeout} (default: @code{300})
  15132. Idle time in seconds after which the daemon closes a connection with the
  15133. client.
  15134. @end table
  15135. @end deftp
  15136. The @code{(gnu services syncthing)} module provides the following services:
  15137. @cindex syncthing
  15138. You might want a syncthing daemon if you have files between two or more
  15139. computers and want to sync them in real time, safely protected from
  15140. prying eyes.
  15141. @deffn {Scheme Variable} syncthing-service-type
  15142. This is the service type for the @uref{https://syncthing.net/,
  15143. syncthing} daemon, The value for this service type is a
  15144. @command{syncthing-configuration} record as in this example:
  15145. @lisp
  15146. (service syncthing-service-type
  15147. (syncthing-configuration (user "alice")))
  15148. @end lisp
  15149. See below for details about @code{syncthing-configuration}.
  15150. @deftp {Data Type} syncthing-configuration
  15151. Data type representing the configuration for @code{syncthing-service-type}.
  15152. @table @asis
  15153. @item @code{syncthing} (default: @var{syncthing})
  15154. @code{syncthing} package to use.
  15155. @item @code{arguments} (default: @var{'()})
  15156. List of command-line arguments passing to @code{syncthing} binary.
  15157. @item @code{logflags} (default: @var{0})
  15158. Sum of logging flags, see
  15159. @uref{https://docs.syncthing.net/users/syncthing.html#cmdoption-logflags, Syncthing documentation logflags}.
  15160. @item @code{user} (default: @var{#f})
  15161. The user as which the Syncthing service is to be run.
  15162. This assumes that the specified user exists.
  15163. @item @code{group} (default: @var{"users"})
  15164. The group as which the Syncthing service is to be run.
  15165. This assumes that the specified group exists.
  15166. @item @code{home} (default: @var{#f})
  15167. Common configuration and data directory. The default configuration
  15168. directory is @file{$HOME} of the specified Syncthing @code{user}.
  15169. @end table
  15170. @end deftp
  15171. @end deffn
  15172. Furthermore, @code{(gnu services ssh)} provides the following services.
  15173. @cindex SSH
  15174. @cindex SSH server
  15175. @deffn {Scheme Procedure} lsh-service [#:host-key "/etc/lsh/host-key"] @
  15176. [#:daemonic? #t] [#:interfaces '()] [#:port-number 22] @
  15177. [#:allow-empty-passwords? #f] [#:root-login? #f] @
  15178. [#:syslog-output? #t] [#:x11-forwarding? #t] @
  15179. [#:tcp/ip-forwarding? #t] [#:password-authentication? #t] @
  15180. [#:public-key-authentication? #t] [#:initialize? #t]
  15181. Run the @command{lshd} program from @var{lsh} to listen on port @var{port-number}.
  15182. @var{host-key} must designate a file containing the host key, and readable
  15183. only by root.
  15184. When @var{daemonic?} is true, @command{lshd} will detach from the
  15185. controlling terminal and log its output to syslogd, unless one sets
  15186. @var{syslog-output?} to false. Obviously, it also makes lsh-service
  15187. depend on existence of syslogd service. When @var{pid-file?} is true,
  15188. @command{lshd} writes its PID to the file called @var{pid-file}.
  15189. When @var{initialize?} is true, automatically create the seed and host key
  15190. upon service activation if they do not exist yet. This may take long and
  15191. require interaction.
  15192. When @var{initialize?} is false, it is up to the user to initialize the
  15193. randomness generator (@pxref{lsh-make-seed,,, lsh, LSH Manual}), and to create
  15194. a key pair with the private key stored in file @var{host-key} (@pxref{lshd
  15195. basics,,, lsh, LSH Manual}).
  15196. When @var{interfaces} is empty, lshd listens for connections on all the
  15197. network interfaces; otherwise, @var{interfaces} must be a list of host names
  15198. or addresses.
  15199. @var{allow-empty-passwords?} specifies whether to accept log-ins with empty
  15200. passwords, and @var{root-login?} specifies whether to accept log-ins as
  15201. root.
  15202. The other options should be self-descriptive.
  15203. @end deffn
  15204. @cindex SSH
  15205. @cindex SSH server
  15206. @deffn {Scheme Variable} openssh-service-type
  15207. This is the type for the @uref{http://www.openssh.org, OpenSSH} secure
  15208. shell daemon, @command{sshd}. Its value must be an
  15209. @code{openssh-configuration} record as in this example:
  15210. @lisp
  15211. (service openssh-service-type
  15212. (openssh-configuration
  15213. (x11-forwarding? #t)
  15214. (permit-root-login 'prohibit-password)
  15215. (authorized-keys
  15216. `(("alice" ,(local-file "alice.pub"))
  15217. ("bob" ,(local-file "bob.pub"))))))
  15218. @end lisp
  15219. See below for details about @code{openssh-configuration}.
  15220. This service can be extended with extra authorized keys, as in this
  15221. example:
  15222. @lisp
  15223. (service-extension openssh-service-type
  15224. (const `(("charlie"
  15225. ,(local-file "charlie.pub")))))
  15226. @end lisp
  15227. @end deffn
  15228. @deftp {Data Type} openssh-configuration
  15229. This is the configuration record for OpenSSH's @command{sshd}.
  15230. @table @asis
  15231. @item @code{openssh} (default @var{openssh})
  15232. The Openssh package to use.
  15233. @item @code{pid-file} (default: @code{"/var/run/sshd.pid"})
  15234. Name of the file where @command{sshd} writes its PID.
  15235. @item @code{port-number} (default: @code{22})
  15236. TCP port on which @command{sshd} listens for incoming connections.
  15237. @item @code{permit-root-login} (default: @code{#f})
  15238. This field determines whether and when to allow logins as root. If
  15239. @code{#f}, root logins are disallowed; if @code{#t}, they are allowed.
  15240. If it's the symbol @code{'prohibit-password}, then root logins are
  15241. permitted but not with password-based authentication.
  15242. @item @code{allow-empty-passwords?} (default: @code{#f})
  15243. When true, users with empty passwords may log in. When false, they may
  15244. not.
  15245. @item @code{password-authentication?} (default: @code{#t})
  15246. When true, users may log in with their password. When false, they have
  15247. other authentication methods.
  15248. @item @code{public-key-authentication?} (default: @code{#t})
  15249. When true, users may log in using public key authentication. When
  15250. false, users have to use other authentication method.
  15251. Authorized public keys are stored in @file{~/.ssh/authorized_keys}.
  15252. This is used only by protocol version 2.
  15253. @item @code{x11-forwarding?} (default: @code{#f})
  15254. When true, forwarding of X11 graphical client connections is
  15255. enabled---in other words, @command{ssh} options @option{-X} and
  15256. @option{-Y} will work.
  15257. @item @code{allow-agent-forwarding?} (default: @code{#t})
  15258. Whether to allow agent forwarding.
  15259. @item @code{allow-tcp-forwarding?} (default: @code{#t})
  15260. Whether to allow TCP forwarding.
  15261. @item @code{gateway-ports?} (default: @code{#f})
  15262. Whether to allow gateway ports.
  15263. @item @code{challenge-response-authentication?} (default: @code{#f})
  15264. Specifies whether challenge response authentication is allowed (e.g.@: via
  15265. PAM).
  15266. @item @code{use-pam?} (default: @code{#t})
  15267. Enables the Pluggable Authentication Module interface. If set to
  15268. @code{#t}, this will enable PAM authentication using
  15269. @code{challenge-response-authentication?} and
  15270. @code{password-authentication?}, in addition to PAM account and session
  15271. module processing for all authentication types.
  15272. Because PAM challenge response authentication usually serves an
  15273. equivalent role to password authentication, you should disable either
  15274. @code{challenge-response-authentication?} or
  15275. @code{password-authentication?}.
  15276. @item @code{print-last-log?} (default: @code{#t})
  15277. Specifies whether @command{sshd} should print the date and time of the
  15278. last user login when a user logs in interactively.
  15279. @item @code{subsystems} (default: @code{'(("sftp" "internal-sftp"))})
  15280. Configures external subsystems (e.g.@: file transfer daemon).
  15281. This is a list of two-element lists, each of which containing the
  15282. subsystem name and a command (with optional arguments) to execute upon
  15283. subsystem request.
  15284. The command @command{internal-sftp} implements an in-process SFTP
  15285. server. Alternatively, one can specify the @command{sftp-server} command:
  15286. @lisp
  15287. (service openssh-service-type
  15288. (openssh-configuration
  15289. (subsystems
  15290. `(("sftp" ,(file-append openssh "/libexec/sftp-server"))))))
  15291. @end lisp
  15292. @item @code{accepted-environment} (default: @code{'()})
  15293. List of strings describing which environment variables may be exported.
  15294. Each string gets on its own line. See the @code{AcceptEnv} option in
  15295. @code{man sshd_config}.
  15296. This example allows ssh-clients to export the @env{COLORTERM} variable.
  15297. It is set by terminal emulators, which support colors. You can use it in
  15298. your shell's resource file to enable colors for the prompt and commands
  15299. if this variable is set.
  15300. @lisp
  15301. (service openssh-service-type
  15302. (openssh-configuration
  15303. (accepted-environment '("COLORTERM"))))
  15304. @end lisp
  15305. @item @code{authorized-keys} (default: @code{'()})
  15306. @cindex authorized keys, SSH
  15307. @cindex SSH authorized keys
  15308. This is the list of authorized keys. Each element of the list is a user
  15309. name followed by one or more file-like objects that represent SSH public
  15310. keys. For example:
  15311. @lisp
  15312. (openssh-configuration
  15313. (authorized-keys
  15314. `(("rekado" ,(local-file "rekado.pub"))
  15315. ("chris" ,(local-file "chris.pub"))
  15316. ("root" ,(local-file "rekado.pub") ,(local-file "chris.pub")))))
  15317. @end lisp
  15318. @noindent
  15319. registers the specified public keys for user accounts @code{rekado},
  15320. @code{chris}, and @code{root}.
  15321. Additional authorized keys can be specified @i{via}
  15322. @code{service-extension}.
  15323. Note that this does @emph{not} interfere with the use of
  15324. @file{~/.ssh/authorized_keys}.
  15325. @item @code{log-level} (default: @code{'info})
  15326. This is a symbol specifying the logging level: @code{quiet}, @code{fatal},
  15327. @code{error}, @code{info}, @code{verbose}, @code{debug}, etc. See the man
  15328. page for @file{sshd_config} for the full list of level names.
  15329. @item @code{extra-content} (default: @code{""})
  15330. This field can be used to append arbitrary text to the configuration file. It
  15331. is especially useful for elaborate configurations that cannot be expressed
  15332. otherwise. This configuration, for example, would generally disable root
  15333. logins, but permit them from one specific IP address:
  15334. @lisp
  15335. (openssh-configuration
  15336. (extra-content "\
  15337. Match Address 192.168.0.1
  15338. PermitRootLogin yes"))
  15339. @end lisp
  15340. @end table
  15341. @end deftp
  15342. @deffn {Scheme Procedure} dropbear-service [@var{config}]
  15343. Run the @uref{https://matt.ucc.asn.au/dropbear/dropbear.html,Dropbear SSH
  15344. daemon} with the given @var{config}, a @code{<dropbear-configuration>}
  15345. object.
  15346. For example, to specify a Dropbear service listening on port 1234, add
  15347. this call to the operating system's @code{services} field:
  15348. @lisp
  15349. (dropbear-service (dropbear-configuration
  15350. (port-number 1234)))
  15351. @end lisp
  15352. @end deffn
  15353. @deftp {Data Type} dropbear-configuration
  15354. This data type represents the configuration of a Dropbear SSH daemon.
  15355. @table @asis
  15356. @item @code{dropbear} (default: @var{dropbear})
  15357. The Dropbear package to use.
  15358. @item @code{port-number} (default: 22)
  15359. The TCP port where the daemon waits for incoming connections.
  15360. @item @code{syslog-output?} (default: @code{#t})
  15361. Whether to enable syslog output.
  15362. @item @code{pid-file} (default: @code{"/var/run/dropbear.pid"})
  15363. File name of the daemon's PID file.
  15364. @item @code{root-login?} (default: @code{#f})
  15365. Whether to allow @code{root} logins.
  15366. @item @code{allow-empty-passwords?} (default: @code{#f})
  15367. Whether to allow empty passwords.
  15368. @item @code{password-authentication?} (default: @code{#t})
  15369. Whether to enable password-based authentication.
  15370. @end table
  15371. @end deftp
  15372. @cindex AutoSSH
  15373. @deffn {Scheme Variable} autossh-service-type
  15374. This is the type for the @uref{https://www.harding.motd.ca/autossh,
  15375. AutoSSH} program that runs a copy of @command{ssh} and monitors it,
  15376. restarting it as necessary should it die or stop passing traffic.
  15377. AutoSSH can be run manually from the command-line by passing arguments
  15378. to the binary @command{autossh} from the package @code{autossh}, but it
  15379. can also be run as a Guix service. This latter use case is documented
  15380. here.
  15381. AutoSSH can be used to forward local traffic to a remote machine using
  15382. an SSH tunnel, and it respects the @file{~/.ssh/config} of the user it
  15383. is run as.
  15384. For example, to specify a service running autossh as the user
  15385. @code{pino} and forwarding all local connections to port @code{8081} to
  15386. @code{remote:8081} using an SSH tunnel, add this call to the operating
  15387. system's @code{services} field:
  15388. @lisp
  15389. (service autossh-service-type
  15390. (autossh-configuration
  15391. (user "pino")
  15392. (ssh-options (list "-T" "-N" "-L" "8081:localhost:8081" "remote.net"))))
  15393. @end lisp
  15394. @end deffn
  15395. @deftp {Data Type} autossh-configuration
  15396. This data type represents the configuration of an AutoSSH service.
  15397. @table @asis
  15398. @item @code{user} (default @code{"autossh"})
  15399. The user as which the AutoSSH service is to be run.
  15400. This assumes that the specified user exists.
  15401. @item @code{poll} (default @code{600})
  15402. Specifies the connection poll time in seconds.
  15403. @item @code{first-poll} (default @code{#f})
  15404. Specifies how many seconds AutoSSH waits before the first connection
  15405. test. After this first test, polling is resumed at the pace defined in
  15406. @code{poll}. When set to @code{#f}, the first poll is not treated
  15407. specially and will also use the connection poll specified in
  15408. @code{poll}.
  15409. @item @code{gate-time} (default @code{30})
  15410. Specifies how many seconds an SSH connection must be active before it is
  15411. considered successful.
  15412. @item @code{log-level} (default @code{1})
  15413. The log level, corresponding to the levels used by syslog---so @code{0}
  15414. is the most silent while @code{7} is the chattiest.
  15415. @item @code{max-start} (default @code{#f})
  15416. The maximum number of times SSH may be (re)started before AutoSSH exits.
  15417. When set to @code{#f}, no maximum is configured and AutoSSH may restart indefinitely.
  15418. @item @code{message} (default @code{""})
  15419. The message to append to the echo message sent when testing connections.
  15420. @item @code{port} (default @code{"0"})
  15421. The ports used for monitoring the connection. When set to @code{"0"},
  15422. monitoring is disabled. When set to @code{"@var{n}"} where @var{n} is
  15423. a positive integer, ports @var{n} and @var{n}+1 are used for
  15424. monitoring the connection, such that port @var{n} is the base
  15425. monitoring port and @code{n+1} is the echo port. When set to
  15426. @code{"@var{n}:@var{m}"} where @var{n} and @var{m} are positive
  15427. integers, the ports @var{n} and @var{m} are used for monitoring the
  15428. connection, such that port @var{n} is the base monitoring port and
  15429. @var{m} is the echo port.
  15430. @item @code{ssh-options} (default @code{'()})
  15431. The list of command-line arguments to pass to @command{ssh} when it is
  15432. run. Options @option{-f} and @option{-M} are reserved for AutoSSH and
  15433. may cause undefined behaviour.
  15434. @end table
  15435. @end deftp
  15436. @cindex WebSSH
  15437. @deffn {Scheme Variable} webssh-service-type
  15438. This is the type for the @uref{https://webssh.huashengdun.org/, WebSSH}
  15439. program that runs a web SSH client. WebSSH can be run manually from the
  15440. command-line by passing arguments to the binary @command{wssh} from the
  15441. package @code{webssh}, but it can also be run as a Guix service. This
  15442. latter use case is documented here.
  15443. For example, to specify a service running WebSSH on loopback interface
  15444. on port @code{8888} with reject policy with a list of allowed to
  15445. connection hosts, and NGINX as a reverse-proxy to this service listening
  15446. for HTTPS connection, add this call to the operating system's
  15447. @code{services} field:
  15448. @lisp
  15449. (service webssh-service-type
  15450. (webssh-configuration (address "127.0.0.1")
  15451. (port 8888)
  15452. (policy 'reject)
  15453. (known-hosts '("localhost ecdsa-sha2-nistp256 AAAA…"
  15454. "127.0.0.1 ecdsa-sha2-nistp256 AAAA…"))))
  15455. (service nginx-service-type
  15456. (nginx-configuration
  15457. (server-blocks
  15458. (list
  15459. (nginx-server-configuration
  15460. (inherit %webssh-configuration-nginx)
  15461. (server-name '("webssh.example.com"))
  15462. (listen '("443 ssl"))
  15463. (ssl-certificate (letsencrypt-certificate "webssh.example.com"))
  15464. (ssl-certificate-key (letsencrypt-key "webssh.example.com"))
  15465. (locations
  15466. (cons (nginx-location-configuration
  15467. (uri "/.well-known")
  15468. (body '("root /var/www;")))
  15469. (nginx-server-configuration-locations %webssh-configuration-nginx))))))))
  15470. @end lisp
  15471. @end deffn
  15472. @deftp {Data Type} webssh-configuration
  15473. Data type representing the configuration for @code{webssh-service}.
  15474. @table @asis
  15475. @item @code{package} (default: @var{webssh})
  15476. @code{webssh} package to use.
  15477. @item @code{user-name} (default: @var{"webssh"})
  15478. User name or user ID that file transfers to and from that module should take
  15479. place.
  15480. @item @code{group-name} (default: @var{"webssh"})
  15481. Group name or group ID that will be used when accessing the module.
  15482. @item @code{address} (default: @var{#f})
  15483. IP address on which @command{webssh} listens for incoming connections.
  15484. @item @code{port} (default: @var{8888})
  15485. TCP port on which @command{webssh} listens for incoming connections.
  15486. @item @code{policy} (default: @var{#f})
  15487. Connection policy. @var{reject} policy requires to specify @var{known-hosts}.
  15488. @item @code{known-hosts} (default: @var{'()})
  15489. List of hosts which allowed for SSH connection from @command{webssh}.
  15490. @item @code{log-file} (default: @file{"/var/log/webssh.log"})
  15491. Name of the file where @command{webssh} writes its log file.
  15492. @item @code{log-level} (default: @var{#f})
  15493. Logging level.
  15494. @end table
  15495. @end deftp
  15496. @defvr {Scheme Variable} %facebook-host-aliases
  15497. This variable contains a string for use in @file{/etc/hosts}
  15498. (@pxref{Host Names,,, libc, The GNU C Library Reference Manual}). Each
  15499. line contains a entry that maps a known server name of the Facebook
  15500. on-line service---e.g., @code{www.facebook.com}---to the local
  15501. host---@code{127.0.0.1} or its IPv6 equivalent, @code{::1}.
  15502. This variable is typically used in the @code{hosts-file} field of an
  15503. @code{operating-system} declaration (@pxref{operating-system Reference,
  15504. @file{/etc/hosts}}):
  15505. @lisp
  15506. (use-modules (gnu) (guix))
  15507. (operating-system
  15508. (host-name "mymachine")
  15509. ;; ...
  15510. (hosts-file
  15511. ;; Create a /etc/hosts file with aliases for "localhost"
  15512. ;; and "mymachine", as well as for Facebook servers.
  15513. (plain-file "hosts"
  15514. (string-append (local-host-aliases host-name)
  15515. %facebook-host-aliases))))
  15516. @end lisp
  15517. This mechanism can prevent programs running locally, such as Web
  15518. browsers, from accessing Facebook.
  15519. @end defvr
  15520. The @code{(gnu services avahi)} provides the following definition.
  15521. @defvr {Scheme Variable} avahi-service-type
  15522. This is the service that runs @command{avahi-daemon}, a system-wide
  15523. mDNS/DNS-SD responder that allows for service discovery and
  15524. ``zero-configuration'' host name lookups (see @uref{https://avahi.org/}).
  15525. Its value must be an @code{avahi-configuration} record---see below.
  15526. This service extends the name service cache daemon (nscd) so that it can
  15527. resolve @code{.local} host names using
  15528. @uref{https://0pointer.de/lennart/projects/nss-mdns/, nss-mdns}. @xref{Name
  15529. Service Switch}, for information on host name resolution.
  15530. Additionally, add the @var{avahi} package to the system profile so that
  15531. commands such as @command{avahi-browse} are directly usable.
  15532. @end defvr
  15533. @deftp {Data Type} avahi-configuration
  15534. Data type representation the configuration for Avahi.
  15535. @table @asis
  15536. @item @code{host-name} (default: @code{#f})
  15537. If different from @code{#f}, use that as the host name to
  15538. publish for this machine; otherwise, use the machine's actual host name.
  15539. @item @code{publish?} (default: @code{#t})
  15540. When true, allow host names and services to be published (broadcast) over the
  15541. network.
  15542. @item @code{publish-workstation?} (default: @code{#t})
  15543. When true, @command{avahi-daemon} publishes the machine's host name and IP
  15544. address via mDNS on the local network. To view the host names published on
  15545. your local network, you can run:
  15546. @example
  15547. avahi-browse _workstation._tcp
  15548. @end example
  15549. @item @code{wide-area?} (default: @code{#f})
  15550. When true, DNS-SD over unicast DNS is enabled.
  15551. @item @code{ipv4?} (default: @code{#t})
  15552. @itemx @code{ipv6?} (default: @code{#t})
  15553. These fields determine whether to use IPv4/IPv6 sockets.
  15554. @item @code{domains-to-browse} (default: @code{'()})
  15555. This is a list of domains to browse.
  15556. @end table
  15557. @end deftp
  15558. @deffn {Scheme Variable} openvswitch-service-type
  15559. This is the type of the @uref{https://www.openvswitch.org, Open vSwitch}
  15560. service, whose value should be an @code{openvswitch-configuration}
  15561. object.
  15562. @end deffn
  15563. @deftp {Data Type} openvswitch-configuration
  15564. Data type representing the configuration of Open vSwitch, a multilayer
  15565. virtual switch which is designed to enable massive network automation
  15566. through programmatic extension.
  15567. @table @asis
  15568. @item @code{package} (default: @var{openvswitch})
  15569. Package object of the Open vSwitch.
  15570. @end table
  15571. @end deftp
  15572. @defvr {Scheme Variable} pagekite-service-type
  15573. This is the service type for the @uref{https://pagekite.net, PageKite} service,
  15574. a tunneling solution for making localhost servers publicly visible, even from
  15575. behind restrictive firewalls or NAT without forwarded ports. The value for
  15576. this service type is a @code{pagekite-configuration} record.
  15577. Here's an example exposing the local HTTP and SSH daemons:
  15578. @lisp
  15579. (service pagekite-service-type
  15580. (pagekite-configuration
  15581. (kites '("http:@@kitename:localhost:80:@@kitesecret"
  15582. "raw/22:@@kitename:localhost:22:@@kitesecret"))
  15583. (extra-file "/etc/pagekite.rc")))
  15584. @end lisp
  15585. @end defvr
  15586. @deftp {Data Type} pagekite-configuration
  15587. Data type representing the configuration of PageKite.
  15588. @table @asis
  15589. @item @code{package} (default: @var{pagekite})
  15590. Package object of PageKite.
  15591. @item @code{kitename} (default: @code{#f})
  15592. PageKite name for authenticating to the frontend server.
  15593. @item @code{kitesecret} (default: @code{#f})
  15594. Shared secret for authenticating to the frontend server. You should probably
  15595. put this inside @code{extra-file} instead.
  15596. @item @code{frontend} (default: @code{#f})
  15597. Connect to the named PageKite frontend server instead of the
  15598. @uref{https://pagekite.net,,pagekite.net} service.
  15599. @item @code{kites} (default: @code{'("http:@@kitename:localhost:80:@@kitesecret")})
  15600. List of service kites to use. Exposes HTTP on port 80 by default. The format
  15601. is @code{proto:kitename:host:port:secret}.
  15602. @item @code{extra-file} (default: @code{#f})
  15603. Extra configuration file to read, which you are expected to create manually.
  15604. Use this to add additional options and manage shared secrets out-of-band.
  15605. @end table
  15606. @end deftp
  15607. @defvr {Scheme Variable} yggdrasil-service-type
  15608. The service type for connecting to the @uref{https://yggdrasil-network.github.io/,
  15609. Yggdrasil network}, an early-stage implementation of a fully end-to-end
  15610. encrypted IPv6 network.
  15611. @quotation
  15612. Yggdrasil provides name-independent routing with cryptographically generated
  15613. addresses. Static addressing means you can keep the same address as long as
  15614. you want, even if you move to a new location, or generate a new address (by
  15615. generating new keys) whenever you want.
  15616. @uref{https://yggdrasil-network.github.io/2018/07/28/addressing.html}
  15617. @end quotation
  15618. Pass it a value of @code{yggdrasil-configuration} to connect it to public
  15619. peers and/or local peers.
  15620. Here is an example using public peers and a static address. The static
  15621. signing and encryption keys are defined in @file{/etc/yggdrasil-private.conf}
  15622. (the default value for @code{config-file}).
  15623. @lisp
  15624. ;; part of the operating-system declaration
  15625. (service yggdrasil-service-type
  15626. (yggdrasil-configuration
  15627. (autoconf? #f) ;; use only the public peers
  15628. (json-config
  15629. ;; choose one from
  15630. ;; https://github.com/yggdrasil-network/public-peers
  15631. '((peers . #("tcp://1.2.3.4:1337"))))
  15632. ;; /etc/yggdrasil-private.conf is the default value for config-file
  15633. ))
  15634. @end lisp
  15635. @example
  15636. # sample content for /etc/yggdrasil-private.conf
  15637. @{
  15638. # Your public encryption key. Your peers may ask you for this to put
  15639. # into their AllowedEncryptionPublicKeys configuration.
  15640. EncryptionPublicKey: 378dc5...
  15641. # Your private encryption key. DO NOT share this with anyone!
  15642. EncryptionPrivateKey: 0777...
  15643. # Your public signing key. You should not ordinarily need to share
  15644. # this with anyone.
  15645. SigningPublicKey: e1664...
  15646. # Your private signing key. DO NOT share this with anyone!
  15647. SigningPrivateKey: 0589d...
  15648. @}
  15649. @end example
  15650. @end defvr
  15651. @deftp {Data Type} yggdrasil-configuration
  15652. Data type representing the configuration of Yggdrasil.
  15653. @table @asis
  15654. @item @code{package} (default: @code{yggdrasil})
  15655. Package object of Yggdrasil.
  15656. @item @code{json-config} (default: @code{'()})
  15657. Contents of @file{/etc/yggdrasil.conf}. Will be merged with
  15658. @file{/etc/yggdrasil-private.conf}. Note that these settings are stored in
  15659. the Guix store, which is readable to all users. @strong{Do not store your
  15660. private keys in it}. See the output of @code{yggdrasil -genconf} for a
  15661. quick overview of valid keys and their default values.
  15662. @item @code{autoconf?} (default: @code{#f})
  15663. Whether to use automatic mode. Enabling it makes Yggdrasil use adynamic IP
  15664. and peer with IPv6 neighbors.
  15665. @item @code{log-level} (default: @code{'info})
  15666. How much detail to include in logs. Use @code{'debug} for more detail.
  15667. @item @code{log-to} (default: @code{'stdout})
  15668. Where to send logs. By default, the service logs standard output to
  15669. @file{/var/log/yggdrasil.log}. The alternative is @code{'syslog}, which
  15670. sends output to the running syslog service.
  15671. @item @code{config-file} (default: @code{"/etc/yggdrasil-private.conf"})
  15672. What HJSON file to load sensitive data from. This is where private keys
  15673. should be stored, which are necessary to specify if you don't want a
  15674. randomized address after each restart. Use @code{#f} to disable. Options
  15675. defined in this file take precedence over @code{json-config}. Use the output
  15676. of @code{yggdrasil -genconf} as a starting point. To configure a static
  15677. address, delete everything except these options:
  15678. @itemize
  15679. @item @code{EncryptionPublicKey}
  15680. @item @code{EncryptionPrivateKey}
  15681. @item @code{SigningPublicKey}
  15682. @item @code{SigningPrivateKey}
  15683. @end itemize
  15684. @end table
  15685. @end deftp
  15686. @cindex IPFS
  15687. @defvr {Scheme Variable} ipfs-service-type
  15688. The service type for connecting to the @uref{https://ipfs.io,IPFS network},
  15689. a global, versioned, peer-to-peer file system. Pass it a
  15690. @code{ipfs-configuration} to change the ports used for the gateway and API.
  15691. Here's an example configuration, using some non-standard ports:
  15692. @lisp
  15693. (service ipfs-service-type
  15694. (ipfs-configuration
  15695. (gateway "/ip4/127.0.0.1/tcp/8880")
  15696. (api "/ip4/127.0.0.1/tcp/8881")))
  15697. @end lisp
  15698. @end defvr
  15699. @deftp {Data Type} ipfs-configuration
  15700. Data type representing the configuration of IPFS.
  15701. @table @asis
  15702. @item @code{package} (default: @code{go-ipfs})
  15703. Package object of IPFS.
  15704. @item @code{gateway} (default: @code{"/ip4/127.0.0.1/tcp/8082"})
  15705. Address of the gateway, in ‘multiaddress’ format.
  15706. @item @code{api} (default: @code{"/ip4/127.0.0.1/tcp/5001"})
  15707. Address of the API endpoint, in ‘multiaddress’ format.
  15708. @end table
  15709. @end deftp
  15710. @cindex keepalived
  15711. @deffn {Scheme Variable} keepalived-service-type
  15712. This is the type for the @uref{https://www.keepalived.org/, Keepalived}
  15713. routing software, @command{keepalived}. Its value must be an
  15714. @code{keepalived-configuration} record as in this example for master
  15715. machine:
  15716. @lisp
  15717. (service keepalived-service-type
  15718. (keepalived-configuration
  15719. (config-file (local-file "keepalived-master.conf"))))
  15720. @end lisp
  15721. where @file{keepalived-master.conf}:
  15722. @example
  15723. vrrp_instance my-group @{
  15724. state MASTER
  15725. interface enp9s0
  15726. virtual_router_id 100
  15727. priority 100
  15728. unicast_peer @{ 10.0.0.2 @}
  15729. virtual_ipaddress @{
  15730. 10.0.0.4/24
  15731. @}
  15732. @}
  15733. @end example
  15734. and for backup machine:
  15735. @lisp
  15736. (service keepalived-service-type
  15737. (keepalived-configuration
  15738. (config-file (local-file "keepalived-backup.conf"))))
  15739. @end lisp
  15740. where @file{keepalived-backup.conf}:
  15741. @example
  15742. vrrp_instance my-group @{
  15743. state BACKUP
  15744. interface enp9s0
  15745. virtual_router_id 100
  15746. priority 99
  15747. unicast_peer @{ 10.0.0.3 @}
  15748. virtual_ipaddress @{
  15749. 10.0.0.4/24
  15750. @}
  15751. @}
  15752. @end example
  15753. @end deffn
  15754. @node Unattended Upgrades
  15755. @subsection Unattended Upgrades
  15756. @cindex unattended upgrades
  15757. @cindex upgrades, unattended
  15758. Guix provides a service to perform @emph{unattended upgrades}:
  15759. periodically, the system automatically reconfigures itself from the
  15760. latest Guix. Guix System has several properties that make unattended
  15761. upgrades safe:
  15762. @itemize
  15763. @item
  15764. upgrades are transactional (either the upgrade succeeds or it fails, but
  15765. you cannot end up with an ``in-between'' system state);
  15766. @item
  15767. the upgrade log is kept---you can view it with @command{guix system
  15768. list-generations}---and you can roll back to any previous generation,
  15769. should the upgraded system fail to behave as intended;
  15770. @item
  15771. channel code is authenticated so you know you can only run genuine code
  15772. (@pxref{Channels});
  15773. @item
  15774. @command{guix system reconfigure} prevents downgrades, which makes it
  15775. immune to @dfn{downgrade attacks}.
  15776. @end itemize
  15777. To set up unattended upgrades, add an instance of
  15778. @code{unattended-upgrade-service-type} like the one below to the list of
  15779. your operating system services:
  15780. @lisp
  15781. (service unattended-upgrade-service-type)
  15782. @end lisp
  15783. The defaults above set up weekly upgrades: every Sunday at midnight.
  15784. You do not need to provide the operating system configuration file: it
  15785. uses @file{/run/current-system/configuration.scm}, which ensures it
  15786. always uses your latest configuration---@pxref{provenance-service-type},
  15787. for more information about this file.
  15788. There are several things that can be configured, in particular the
  15789. periodicity and services (daemons) to be restarted upon completion.
  15790. When the upgrade is successful, the service takes care of deleting
  15791. system generations older that some threshold, as per @command{guix
  15792. system delete-generations}. See the reference below for details.
  15793. To ensure that upgrades are actually happening, you can run
  15794. @command{guix system describe}. To investigate upgrade failures, visit
  15795. the unattended upgrade log file (see below).
  15796. @defvr {Scheme Variable} unattended-upgrade-service-type
  15797. This is the service type for unattended upgrades. It sets up an mcron
  15798. job (@pxref{Scheduled Job Execution}) that runs @command{guix system
  15799. reconfigure} from the latest version of the specified channels.
  15800. Its value must be a @code{unattended-upgrade-configuration} record (see
  15801. below).
  15802. @end defvr
  15803. @deftp {Data Type} unattended-upgrade-configuration
  15804. This data type represents the configuration of the unattended upgrade
  15805. service. The following fields are available:
  15806. @table @asis
  15807. @item @code{schedule} (default: @code{"30 01 * * 0"})
  15808. This is the schedule of upgrades, expressed as a gexp containing an
  15809. mcron job schedule (@pxref{Guile Syntax, mcron job specifications,,
  15810. mcron, GNU@tie{}mcron}).
  15811. @item @code{channels} (default: @code{#~%default-channels})
  15812. This gexp specifies the channels to use for the upgrade
  15813. (@pxref{Channels}). By default, the tip of the official @code{guix}
  15814. channel is used.
  15815. @item @code{operating-system-file} (default: @code{"/run/current-system/configuration.scm"})
  15816. This field specifies the operating system configuration file to use.
  15817. The default is to reuse the config file of the current configuration.
  15818. There are cases, though, where referring to
  15819. @file{/run/current-system/configuration.scm} is not enough, for instance
  15820. because that file refers to extra files (SSH public keys, extra
  15821. configuration files, etc.) @i{via} @code{local-file} and similar
  15822. constructs. For those cases, we recommend something along these lines:
  15823. @lisp
  15824. (unattended-upgrade-configuration
  15825. (operating-system-file
  15826. (file-append (local-file "." "config-dir" #:recursive? #t)
  15827. "/config.scm")))
  15828. @end lisp
  15829. The effect here is to import all of the current directory into the
  15830. store, and to refer to @file{config.scm} within that directory.
  15831. Therefore, uses of @code{local-file} within @file{config.scm} will work
  15832. as expected. @xref{G-Expressions}, for information about
  15833. @code{local-file} and @code{file-append}.
  15834. @item @code{services-to-restart} (default: @code{'(mcron)})
  15835. This field specifies the Shepherd services to restart when the upgrade
  15836. completes.
  15837. Those services are restarted right away upon completion, as with
  15838. @command{herd restart}, which ensures that the latest version is
  15839. running---remember that by default @command{guix system reconfigure}
  15840. only restarts services that are not currently running, which is
  15841. conservative: it minimizes disruption but leaves outdated services
  15842. running.
  15843. Use @command{herd status} to find out candidates for restarting.
  15844. @xref{Services}, for general information about services. Common
  15845. services to restart would include @code{ntpd} and @code{ssh-daemon}.
  15846. By default, the @code{mcron} service is restarted. This ensures that
  15847. the latest version of the unattended upgrade job will be used next time.
  15848. @item @code{system-expiration} (default: @code{(* 3 30 24 3600)})
  15849. This is the expiration time in seconds for system generations. System
  15850. generations older that this amount of time are deleted with
  15851. @command{guix system delete-generations} when an upgrade completes.
  15852. @quotation Note
  15853. The unattended upgrade service does not run the garbage collector. You
  15854. will probably want to set up your own mcron job to run @command{guix gc}
  15855. periodically.
  15856. @end quotation
  15857. @item @code{maximum-duration} (default: @code{3600})
  15858. Maximum duration in seconds for the upgrade; past that time, the upgrade
  15859. aborts.
  15860. This is primarily useful to ensure the upgrade does not end up
  15861. rebuilding or re-downloading ``the world''.
  15862. @item @code{log-file} (default: @code{"/var/log/unattended-upgrade.log"})
  15863. File where unattended upgrades are logged.
  15864. @end table
  15865. @end deftp
  15866. @node X Window
  15867. @subsection X Window
  15868. @cindex X11
  15869. @cindex X Window System
  15870. @cindex login manager
  15871. Support for the X Window graphical display system---specifically
  15872. Xorg---is provided by the @code{(gnu services xorg)} module. Note that
  15873. there is no @code{xorg-service} procedure. Instead, the X server is
  15874. started by the @dfn{login manager}, by default the GNOME Display Manager (GDM).
  15875. @cindex GDM
  15876. @cindex GNOME, login manager
  15877. GDM of course allows users to log in into window managers and desktop
  15878. environments other than GNOME; for those using GNOME, GDM is required for
  15879. features such as automatic screen locking.
  15880. @cindex window manager
  15881. To use X11, you must install at least one @dfn{window manager}---for
  15882. example the @code{windowmaker} or @code{openbox} packages---preferably
  15883. by adding it to the @code{packages} field of your operating system
  15884. definition (@pxref{operating-system Reference, system-wide packages}).
  15885. @anchor{wayland-gdm}
  15886. GDM also supports Wayland: it can itself use Wayland instead of X11 for
  15887. its user interface, and it can also start Wayland sessions. The former is
  15888. required for the latter, to enable, set @code{wayland?} to @code{#t} in
  15889. @code{gdm-configuration}.
  15890. @defvr {Scheme Variable} gdm-service-type
  15891. This is the type for the @uref{https://wiki.gnome.org/Projects/GDM/, GNOME
  15892. Desktop Manager} (GDM), a program that manages graphical display servers and
  15893. handles graphical user logins. Its value must be a @code{gdm-configuration}
  15894. (see below).
  15895. @cindex session types
  15896. GDM looks for @dfn{session types} described by the @file{.desktop} files in
  15897. @file{/run/current-system/profile/share/xsessions} (for X11 sessions) and
  15898. @file{/run/current-system/profile/share/wayland-sessions} (for Wayland
  15899. sessions) and allows users to choose a session from the log-in screen.
  15900. Packages such as @code{gnome}, @code{xfce}, @code{i3} and @code{sway} provide
  15901. @file{.desktop} files; adding them to the system-wide set of packages
  15902. automatically makes them available at the log-in screen.
  15903. In addition, @file{~/.xsession} files are honored. When available,
  15904. @file{~/.xsession} must be an executable that starts a window manager
  15905. and/or other X clients.
  15906. @end defvr
  15907. @deftp {Data Type} gdm-configuration
  15908. @table @asis
  15909. @item @code{auto-login?} (default: @code{#f})
  15910. @itemx @code{default-user} (default: @code{#f})
  15911. When @code{auto-login?} is false, GDM presents a log-in screen.
  15912. When @code{auto-login?} is true, GDM logs in directly as
  15913. @code{default-user}.
  15914. @item @code{debug?} (default: @code{#f})
  15915. When true, GDM writes debug messages to its log.
  15916. @item @code{gnome-shell-assets} (default: ...)
  15917. List of GNOME Shell assets needed by GDM: icon theme, fonts, etc.
  15918. @item @code{xorg-configuration} (default: @code{(xorg-configuration)})
  15919. Configuration of the Xorg graphical server.
  15920. @item @code{xsession} (default: @code{(xinitrc)})
  15921. Script to run before starting a X session.
  15922. @item @code{dbus-daemon} (default: @code{dbus-daemon-wrapper})
  15923. File name of the @code{dbus-daemon} executable.
  15924. @item @code{gdm} (default: @code{gdm})
  15925. The GDM package to use.
  15926. @item @code{wayland?} (default: @code{#f})
  15927. When true, enables Wayland in GDM, necessary to use Wayland sessions.
  15928. @item @code{wayland-session} (default: @code{gdm-wayland-session-wrapper})
  15929. The Wayland session wrapper to use, needed to setup the
  15930. environment.
  15931. @end table
  15932. @end deftp
  15933. @defvr {Scheme Variable} slim-service-type
  15934. This is the type for the SLiM graphical login manager for X11.
  15935. Like GDM, SLiM looks for session types described by @file{.desktop} files and
  15936. allows users to choose a session from the log-in screen using @kbd{F1}. It
  15937. also honors @file{~/.xsession} files.
  15938. Unlike GDM, SLiM does not spawn the user session on a different VT after
  15939. logging in, which means that you can only start one graphical session. If you
  15940. want to be able to run multiple graphical sessions at the same time you have
  15941. to add multiple SLiM services to your system services. The following example
  15942. shows how to replace the default GDM service with two SLiM services on tty7
  15943. and tty8.
  15944. @lisp
  15945. (use-modules (gnu services)
  15946. (gnu services desktop)
  15947. (gnu services xorg))
  15948. (operating-system
  15949. ;; ...
  15950. (services (cons* (service slim-service-type (slim-configuration
  15951. (display ":0")
  15952. (vt "vt7")))
  15953. (service slim-service-type (slim-configuration
  15954. (display ":1")
  15955. (vt "vt8")))
  15956. (modify-services %desktop-services
  15957. (delete gdm-service-type)))))
  15958. @end lisp
  15959. @end defvr
  15960. @deftp {Data Type} slim-configuration
  15961. Data type representing the configuration of @code{slim-service-type}.
  15962. @table @asis
  15963. @item @code{allow-empty-passwords?} (default: @code{#t})
  15964. Whether to allow logins with empty passwords.
  15965. @item @code{gnupg?} (default: @code{#f})
  15966. If enabled, @code{pam-gnupg} will attempt to automatically unlock the
  15967. user's GPG keys with the login password via @code{gpg-agent}. The
  15968. keygrips of all keys to be unlocked should be written to
  15969. @file{~/.pam-gnupg}, and can be queried with @code{gpg -K
  15970. --with-keygrip}. Presetting passphrases must be enabled by adding
  15971. @code{allow-preset-passphrase} in @file{~/.gnupg/gpg-agent.conf}.
  15972. @item @code{auto-login?} (default: @code{#f})
  15973. @itemx @code{default-user} (default: @code{""})
  15974. When @code{auto-login?} is false, SLiM presents a log-in screen.
  15975. When @code{auto-login?} is true, SLiM logs in directly as
  15976. @code{default-user}.
  15977. @item @code{theme} (default: @code{%default-slim-theme})
  15978. @itemx @code{theme-name} (default: @code{%default-slim-theme-name})
  15979. The graphical theme to use and its name.
  15980. @item @code{auto-login-session} (default: @code{#f})
  15981. If true, this must be the name of the executable to start as the default
  15982. session---e.g., @code{(file-append windowmaker "/bin/windowmaker")}.
  15983. If false, a session described by one of the available @file{.desktop}
  15984. files in @code{/run/current-system/profile} and @code{~/.guix-profile}
  15985. will be used.
  15986. @quotation Note
  15987. You must install at least one window manager in the system profile or in
  15988. your user profile. Failing to do that, if @code{auto-login-session} is
  15989. false, you will be unable to log in.
  15990. @end quotation
  15991. @item @code{xorg-configuration} (default @code{(xorg-configuration)})
  15992. Configuration of the Xorg graphical server.
  15993. @item @code{display} (default @code{":0"})
  15994. The display on which to start the Xorg graphical server.
  15995. @item @code{vt} (default @code{"vt7"})
  15996. The VT on which to start the Xorg graphical server.
  15997. @item @code{xauth} (default: @code{xauth})
  15998. The XAuth package to use.
  15999. @item @code{shepherd} (default: @code{shepherd})
  16000. The Shepherd package used when invoking @command{halt} and
  16001. @command{reboot}.
  16002. @item @code{sessreg} (default: @code{sessreg})
  16003. The sessreg package used in order to register the session.
  16004. @item @code{slim} (default: @code{slim})
  16005. The SLiM package to use.
  16006. @end table
  16007. @end deftp
  16008. @defvr {Scheme Variable} %default-theme
  16009. @defvrx {Scheme Variable} %default-theme-name
  16010. The default SLiM theme and its name.
  16011. @end defvr
  16012. @deftp {Data Type} sddm-configuration
  16013. This is the data type representing the SDDM service configuration.
  16014. @table @asis
  16015. @item @code{display-server} (default: "x11")
  16016. Select display server to use for the greeter. Valid values are
  16017. @samp{"x11"} or @samp{"wayland"}.
  16018. @item @code{numlock} (default: "on")
  16019. Valid values are @samp{"on"}, @samp{"off"} or @samp{"none"}.
  16020. @item @code{halt-command} (default @code{#~(string-apppend #$shepherd "/sbin/halt")})
  16021. Command to run when halting.
  16022. @item @code{reboot-command} (default @code{#~(string-append #$shepherd "/sbin/reboot")})
  16023. Command to run when rebooting.
  16024. @item @code{theme} (default "maldives")
  16025. Theme to use. Default themes provided by SDDM are @samp{"elarun"},
  16026. @samp{"maldives"} or @samp{"maya"}.
  16027. @item @code{themes-directory} (default "/run/current-system/profile/share/sddm/themes")
  16028. Directory to look for themes.
  16029. @item @code{faces-directory} (default "/run/current-system/profile/share/sddm/faces")
  16030. Directory to look for faces.
  16031. @item @code{default-path} (default "/run/current-system/profile/bin")
  16032. Default PATH to use.
  16033. @item @code{minimum-uid} (default: 1000)
  16034. Minimum UID displayed in SDDM and allowed for log-in.
  16035. @item @code{maximum-uid} (default: 2000)
  16036. Maximum UID to display in SDDM.
  16037. @item @code{remember-last-user?} (default #t)
  16038. Remember last user.
  16039. @item @code{remember-last-session?} (default #t)
  16040. Remember last session.
  16041. @item @code{hide-users} (default "")
  16042. Usernames to hide from SDDM greeter.
  16043. @item @code{hide-shells} (default @code{#~(string-append #$shadow "/sbin/nologin")})
  16044. Users with shells listed will be hidden from the SDDM greeter.
  16045. @item @code{session-command} (default @code{#~(string-append #$sddm "/share/sddm/scripts/wayland-session")})
  16046. Script to run before starting a wayland session.
  16047. @item @code{sessions-directory} (default "/run/current-system/profile/share/wayland-sessions")
  16048. Directory to look for desktop files starting wayland sessions.
  16049. @item @code{xorg-configuration} (default @code{(xorg-configuration)})
  16050. Configuration of the Xorg graphical server.
  16051. @item @code{xauth-path} (default @code{#~(string-append #$xauth "/bin/xauth")})
  16052. Path to xauth.
  16053. @item @code{xephyr-path} (default @code{#~(string-append #$xorg-server "/bin/Xephyr")})
  16054. Path to Xephyr.
  16055. @item @code{xdisplay-start} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xsetup")})
  16056. Script to run after starting xorg-server.
  16057. @item @code{xdisplay-stop} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xstop")})
  16058. Script to run before stopping xorg-server.
  16059. @item @code{xsession-command} (default: @code{xinitrc})
  16060. Script to run before starting a X session.
  16061. @item @code{xsessions-directory} (default: "/run/current-system/profile/share/xsessions")
  16062. Directory to look for desktop files starting X sessions.
  16063. @item @code{minimum-vt} (default: 7)
  16064. Minimum VT to use.
  16065. @item @code{auto-login-user} (default "")
  16066. User to use for auto-login.
  16067. @item @code{auto-login-session} (default "")
  16068. Desktop file to use for auto-login.
  16069. @item @code{relogin?} (default #f)
  16070. Relogin after logout.
  16071. @end table
  16072. @end deftp
  16073. @cindex login manager
  16074. @cindex X11 login
  16075. @defvr {Scheme Variable} sddm-service-type
  16076. This is the type of the service to run the
  16077. @uref{https://github.com/sddm/sddm,SDDM display manager}. Its value
  16078. must be a @code{sddm-configuration} record (see below).
  16079. Here's an example use:
  16080. @lisp
  16081. (service sddm-service-type
  16082. (sddm-configuration
  16083. (auto-login-user "alice")
  16084. (auto-login-session "xfce.desktop")))
  16085. @end lisp
  16086. @end defvr
  16087. @deftp {Data Type} sddm-configuration
  16088. This data type represents the configuration of the SDDM login manager.
  16089. The available fields are:
  16090. @table @asis
  16091. @item @code{sddm} (default: @code{sddm})
  16092. The SDDM package to use.
  16093. @item @code{display-server} (default: @code{"x11"})
  16094. This must be either @code{"x11"} or @code{"wayland"}.
  16095. @c FIXME: Add more fields.
  16096. @item @code{auto-login-user} (default: @code{""})
  16097. If non-empty, this is the user account under which to log in
  16098. automatically.
  16099. @item @code{auto-login-session} (default: @code{""})
  16100. If non-empty, this is the @file{.desktop} file name to use as the
  16101. auto-login session.
  16102. @end table
  16103. @end deftp
  16104. @cindex Xorg, configuration
  16105. @deftp {Data Type} xorg-configuration
  16106. This data type represents the configuration of the Xorg graphical display
  16107. server. Note that there is no Xorg service; instead, the X server is started
  16108. by a ``display manager'' such as GDM, SDDM, and SLiM@. Thus, the configuration
  16109. of these display managers aggregates an @code{xorg-configuration} record.
  16110. @table @asis
  16111. @item @code{modules} (default: @code{%default-xorg-modules})
  16112. This is a list of @dfn{module packages} loaded by the Xorg
  16113. server---e.g., @code{xf86-video-vesa}, @code{xf86-input-keyboard}, and so on.
  16114. @item @code{fonts} (default: @code{%default-xorg-fonts})
  16115. This is a list of font directories to add to the server's @dfn{font path}.
  16116. @item @code{drivers} (default: @code{'()})
  16117. This must be either the empty list, in which case Xorg chooses a graphics
  16118. driver automatically, or a list of driver names that will be tried in this
  16119. order---e.g., @code{("modesetting" "vesa")}.
  16120. @item @code{resolutions} (default: @code{'()})
  16121. When @code{resolutions} is the empty list, Xorg chooses an appropriate screen
  16122. resolution. Otherwise, it must be a list of resolutions---e.g., @code{((1024
  16123. 768) (640 480))}.
  16124. @cindex keyboard layout, for Xorg
  16125. @cindex keymap, for Xorg
  16126. @item @code{keyboard-layout} (default: @code{#f})
  16127. If this is @code{#f}, Xorg uses the default keyboard layout---usually US
  16128. English (``qwerty'') for a 105-key PC keyboard.
  16129. Otherwise this must be a @code{keyboard-layout} object specifying the keyboard
  16130. layout in use when Xorg is running. @xref{Keyboard Layout}, for more
  16131. information on how to specify the keyboard layout.
  16132. @item @code{extra-config} (default: @code{'()})
  16133. This is a list of strings or objects appended to the configuration file. It
  16134. is used to pass extra text to be added verbatim to the configuration file.
  16135. @item @code{server} (default: @code{xorg-server})
  16136. This is the package providing the Xorg server.
  16137. @item @code{server-arguments} (default: @code{%default-xorg-server-arguments})
  16138. This is the list of command-line arguments to pass to the X server. The
  16139. default is @code{-nolisten tcp}.
  16140. @end table
  16141. @end deftp
  16142. @deffn {Scheme Procedure} set-xorg-configuration @var{config} @
  16143. [@var{login-manager-service-type}]
  16144. Tell the log-in manager (of type @var{login-manager-service-type}) to use
  16145. @var{config}, an @code{<xorg-configuration>} record.
  16146. Since the Xorg configuration is embedded in the log-in manager's
  16147. configuration---e.g., @code{gdm-configuration}---this procedure provides a
  16148. shorthand to set the Xorg configuration.
  16149. @end deffn
  16150. @deffn {Scheme Procedure} xorg-start-command [@var{config}]
  16151. Return a @code{startx} script in which the modules, fonts, etc. specified
  16152. in @var{config}, are available. The result should be used in place of
  16153. @code{startx}.
  16154. Usually the X server is started by a login manager.
  16155. @end deffn
  16156. @deffn {Scheme Procedure} screen-locker-service @var{package} [@var{program}]
  16157. Add @var{package}, a package for a screen locker or screen saver whose
  16158. command is @var{program}, to the set of setuid programs and add a PAM entry
  16159. for it. For example:
  16160. @lisp
  16161. (screen-locker-service xlockmore "xlock")
  16162. @end lisp
  16163. makes the good ol' XlockMore usable.
  16164. @end deffn
  16165. @node Printing Services
  16166. @subsection Printing Services
  16167. @cindex printer support with CUPS
  16168. The @code{(gnu services cups)} module provides a Guix service definition
  16169. for the CUPS printing service. To add printer support to a Guix
  16170. system, add a @code{cups-service} to the operating system definition:
  16171. @deffn {Scheme Variable} cups-service-type
  16172. The service type for the CUPS print server. Its value should be a valid
  16173. CUPS configuration (see below). To use the default settings, simply
  16174. write:
  16175. @lisp
  16176. (service cups-service-type)
  16177. @end lisp
  16178. @end deffn
  16179. The CUPS configuration controls the basic things about your CUPS
  16180. installation: what interfaces it listens on, what to do if a print job
  16181. fails, how much logging to do, and so on. To actually add a printer,
  16182. you have to visit the @url{http://localhost:631} URL, or use a tool such
  16183. as GNOME's printer configuration services. By default, configuring a
  16184. CUPS service will generate a self-signed certificate if needed, for
  16185. secure connections to the print server.
  16186. Suppose you want to enable the Web interface of CUPS and also add
  16187. support for Epson printers @i{via} the @code{epson-inkjet-printer-escpr}
  16188. package and for HP printers @i{via} the @code{hplip-minimal} package.
  16189. You can do that directly, like this (you need to use the
  16190. @code{(gnu packages cups)} module):
  16191. @lisp
  16192. (service cups-service-type
  16193. (cups-configuration
  16194. (web-interface? #t)
  16195. (extensions
  16196. (list cups-filters epson-inkjet-printer-escpr hplip-minimal))))
  16197. @end lisp
  16198. Note: If you wish to use the Qt5 based GUI which comes with the hplip
  16199. package then it is suggested that you install the @code{hplip} package,
  16200. either in your OS configuration file or as your user.
  16201. The available configuration parameters follow. Each parameter
  16202. definition is preceded by its type; for example, @samp{string-list foo}
  16203. indicates that the @code{foo} parameter should be specified as a list of
  16204. strings. There is also a way to specify the configuration as a string,
  16205. if you have an old @code{cupsd.conf} file that you want to port over
  16206. from some other system; see the end for more details.
  16207. @c The following documentation was initially generated by
  16208. @c (generate-documentation) in (gnu services cups). Manually maintained
  16209. @c documentation is better, so we shouldn't hesitate to edit below as
  16210. @c needed. However if the change you want to make to this documentation
  16211. @c can be done in an automated way, it's probably easier to change
  16212. @c (generate-documentation) than to make it below and have to deal with
  16213. @c the churn as CUPS updates.
  16214. Available @code{cups-configuration} fields are:
  16215. @deftypevr {@code{cups-configuration} parameter} package cups
  16216. The CUPS package.
  16217. @end deftypevr
  16218. @deftypevr {@code{cups-configuration} parameter} package-list extensions (default: @code{(list brlaser cups-filters epson-inkjet-printer-escpr foomatic-filters hplip-minimal splix)})
  16219. Drivers and other extensions to the CUPS package.
  16220. @end deftypevr
  16221. @deftypevr {@code{cups-configuration} parameter} files-configuration files-configuration
  16222. Configuration of where to write logs, what directories to use for print
  16223. spools, and related privileged configuration parameters.
  16224. Available @code{files-configuration} fields are:
  16225. @deftypevr {@code{files-configuration} parameter} log-location access-log
  16226. Defines the access log filename. Specifying a blank filename disables
  16227. access log generation. The value @code{stderr} causes log entries to be
  16228. sent to the standard error file when the scheduler is running in the
  16229. foreground, or to the system log daemon when run in the background. The
  16230. value @code{syslog} causes log entries to be sent to the system log
  16231. daemon. The server name may be included in filenames using the string
  16232. @code{%s}, as in @code{/var/log/cups/%s-access_log}.
  16233. Defaults to @samp{"/var/log/cups/access_log"}.
  16234. @end deftypevr
  16235. @deftypevr {@code{files-configuration} parameter} file-name cache-dir
  16236. Where CUPS should cache data.
  16237. Defaults to @samp{"/var/cache/cups"}.
  16238. @end deftypevr
  16239. @deftypevr {@code{files-configuration} parameter} string config-file-perm
  16240. Specifies the permissions for all configuration files that the scheduler
  16241. writes.
  16242. Note that the permissions for the printers.conf file are currently
  16243. masked to only allow access from the scheduler user (typically root).
  16244. This is done because printer device URIs sometimes contain sensitive
  16245. authentication information that should not be generally known on the
  16246. system. There is no way to disable this security feature.
  16247. Defaults to @samp{"0640"}.
  16248. @end deftypevr
  16249. @deftypevr {@code{files-configuration} parameter} log-location error-log
  16250. Defines the error log filename. Specifying a blank filename disables
  16251. error log generation. The value @code{stderr} causes log entries to be
  16252. sent to the standard error file when the scheduler is running in the
  16253. foreground, or to the system log daemon when run in the background. The
  16254. value @code{syslog} causes log entries to be sent to the system log
  16255. daemon. The server name may be included in filenames using the string
  16256. @code{%s}, as in @code{/var/log/cups/%s-error_log}.
  16257. Defaults to @samp{"/var/log/cups/error_log"}.
  16258. @end deftypevr
  16259. @deftypevr {@code{files-configuration} parameter} string fatal-errors
  16260. Specifies which errors are fatal, causing the scheduler to exit. The
  16261. kind strings are:
  16262. @table @code
  16263. @item none
  16264. No errors are fatal.
  16265. @item all
  16266. All of the errors below are fatal.
  16267. @item browse
  16268. Browsing initialization errors are fatal, for example failed connections
  16269. to the DNS-SD daemon.
  16270. @item config
  16271. Configuration file syntax errors are fatal.
  16272. @item listen
  16273. Listen or Port errors are fatal, except for IPv6 failures on the
  16274. loopback or @code{any} addresses.
  16275. @item log
  16276. Log file creation or write errors are fatal.
  16277. @item permissions
  16278. Bad startup file permissions are fatal, for example shared TLS
  16279. certificate and key files with world-read permissions.
  16280. @end table
  16281. Defaults to @samp{"all -browse"}.
  16282. @end deftypevr
  16283. @deftypevr {@code{files-configuration} parameter} boolean file-device?
  16284. Specifies whether the file pseudo-device can be used for new printer
  16285. queues. The URI @uref{file:///dev/null} is always allowed.
  16286. Defaults to @samp{#f}.
  16287. @end deftypevr
  16288. @deftypevr {@code{files-configuration} parameter} string group
  16289. Specifies the group name or ID that will be used when executing external
  16290. programs.
  16291. Defaults to @samp{"lp"}.
  16292. @end deftypevr
  16293. @deftypevr {@code{files-configuration} parameter} string log-file-group
  16294. Specifies the group name or ID that will be used for log files.
  16295. Defaults to @samp{"lpadmin"}.
  16296. @end deftypevr
  16297. @deftypevr {@code{files-configuration} parameter} string log-file-perm
  16298. Specifies the permissions for all log files that the scheduler writes.
  16299. Defaults to @samp{"0644"}.
  16300. @end deftypevr
  16301. @deftypevr {@code{files-configuration} parameter} log-location page-log
  16302. Defines the page log filename. Specifying a blank filename disables
  16303. page log generation. The value @code{stderr} causes log entries to be
  16304. sent to the standard error file when the scheduler is running in the
  16305. foreground, or to the system log daemon when run in the background. The
  16306. value @code{syslog} causes log entries to be sent to the system log
  16307. daemon. The server name may be included in filenames using the string
  16308. @code{%s}, as in @code{/var/log/cups/%s-page_log}.
  16309. Defaults to @samp{"/var/log/cups/page_log"}.
  16310. @end deftypevr
  16311. @deftypevr {@code{files-configuration} parameter} string remote-root
  16312. Specifies the username that is associated with unauthenticated accesses
  16313. by clients claiming to be the root user. The default is @code{remroot}.
  16314. Defaults to @samp{"remroot"}.
  16315. @end deftypevr
  16316. @deftypevr {@code{files-configuration} parameter} file-name request-root
  16317. Specifies the directory that contains print jobs and other HTTP request
  16318. data.
  16319. Defaults to @samp{"/var/spool/cups"}.
  16320. @end deftypevr
  16321. @deftypevr {@code{files-configuration} parameter} sandboxing sandboxing
  16322. Specifies the level of security sandboxing that is applied to print
  16323. filters, backends, and other child processes of the scheduler; either
  16324. @code{relaxed} or @code{strict}. This directive is currently only
  16325. used/supported on macOS.
  16326. Defaults to @samp{strict}.
  16327. @end deftypevr
  16328. @deftypevr {@code{files-configuration} parameter} file-name server-keychain
  16329. Specifies the location of TLS certificates and private keys. CUPS will
  16330. look for public and private keys in this directory: @file{.crt} files
  16331. for PEM-encoded certificates and corresponding @file{.key} files for
  16332. PEM-encoded private keys.
  16333. Defaults to @samp{"/etc/cups/ssl"}.
  16334. @end deftypevr
  16335. @deftypevr {@code{files-configuration} parameter} file-name server-root
  16336. Specifies the directory containing the server configuration files.
  16337. Defaults to @samp{"/etc/cups"}.
  16338. @end deftypevr
  16339. @deftypevr {@code{files-configuration} parameter} boolean sync-on-close?
  16340. Specifies whether the scheduler calls fsync(2) after writing
  16341. configuration or state files.
  16342. Defaults to @samp{#f}.
  16343. @end deftypevr
  16344. @deftypevr {@code{files-configuration} parameter} space-separated-string-list system-group
  16345. Specifies the group(s) to use for @code{@@SYSTEM} group authentication.
  16346. @end deftypevr
  16347. @deftypevr {@code{files-configuration} parameter} file-name temp-dir
  16348. Specifies the directory where temporary files are stored.
  16349. Defaults to @samp{"/var/spool/cups/tmp"}.
  16350. @end deftypevr
  16351. @deftypevr {@code{files-configuration} parameter} string user
  16352. Specifies the user name or ID that is used when running external
  16353. programs.
  16354. Defaults to @samp{"lp"}.
  16355. @end deftypevr
  16356. @deftypevr {@code{files-configuration} parameter} string set-env
  16357. Set the specified environment variable to be passed to child processes.
  16358. Defaults to @samp{"variable value"}.
  16359. @end deftypevr
  16360. @end deftypevr
  16361. @deftypevr {@code{cups-configuration} parameter} access-log-level access-log-level
  16362. Specifies the logging level for the AccessLog file. The @code{config}
  16363. level logs when printers and classes are added, deleted, or modified and
  16364. when configuration files are accessed or updated. The @code{actions}
  16365. level logs when print jobs are submitted, held, released, modified, or
  16366. canceled, and any of the conditions for @code{config}. The @code{all}
  16367. level logs all requests.
  16368. Defaults to @samp{actions}.
  16369. @end deftypevr
  16370. @deftypevr {@code{cups-configuration} parameter} boolean auto-purge-jobs?
  16371. Specifies whether to purge job history data automatically when it is no
  16372. longer required for quotas.
  16373. Defaults to @samp{#f}.
  16374. @end deftypevr
  16375. @deftypevr {@code{cups-configuration} parameter} comma-separated-string-list browse-dns-sd-sub-types
  16376. Specifies a list of DNS-SD sub-types to advertise for each shared printer.
  16377. For example, @samp{"_cups" "_print"} will tell network clients that both
  16378. CUPS sharing and IPP Everywhere are supported.
  16379. Defaults to @samp{"_cups"}.
  16380. @end deftypevr
  16381. @deftypevr {@code{cups-configuration} parameter} browse-local-protocols browse-local-protocols
  16382. Specifies which protocols to use for local printer sharing.
  16383. Defaults to @samp{dnssd}.
  16384. @end deftypevr
  16385. @deftypevr {@code{cups-configuration} parameter} boolean browse-web-if?
  16386. Specifies whether the CUPS web interface is advertised.
  16387. Defaults to @samp{#f}.
  16388. @end deftypevr
  16389. @deftypevr {@code{cups-configuration} parameter} boolean browsing?
  16390. Specifies whether shared printers are advertised.
  16391. Defaults to @samp{#f}.
  16392. @end deftypevr
  16393. @deftypevr {@code{cups-configuration} parameter} string classification
  16394. Specifies the security classification of the server. Any valid banner
  16395. name can be used, including @samp{"classified"}, @samp{"confidential"},
  16396. @samp{"secret"}, @samp{"topsecret"}, and @samp{"unclassified"}, or the
  16397. banner can be omitted to disable secure printing functions.
  16398. Defaults to @samp{""}.
  16399. @end deftypevr
  16400. @deftypevr {@code{cups-configuration} parameter} boolean classify-override?
  16401. Specifies whether users may override the classification (cover page) of
  16402. individual print jobs using the @code{job-sheets} option.
  16403. Defaults to @samp{#f}.
  16404. @end deftypevr
  16405. @deftypevr {@code{cups-configuration} parameter} default-auth-type default-auth-type
  16406. Specifies the default type of authentication to use.
  16407. Defaults to @samp{Basic}.
  16408. @end deftypevr
  16409. @deftypevr {@code{cups-configuration} parameter} default-encryption default-encryption
  16410. Specifies whether encryption will be used for authenticated requests.
  16411. Defaults to @samp{Required}.
  16412. @end deftypevr
  16413. @deftypevr {@code{cups-configuration} parameter} string default-language
  16414. Specifies the default language to use for text and web content.
  16415. Defaults to @samp{"en"}.
  16416. @end deftypevr
  16417. @deftypevr {@code{cups-configuration} parameter} string default-paper-size
  16418. Specifies the default paper size for new print queues. @samp{"Auto"}
  16419. uses a locale-specific default, while @samp{"None"} specifies there is
  16420. no default paper size. Specific size names are typically
  16421. @samp{"Letter"} or @samp{"A4"}.
  16422. Defaults to @samp{"Auto"}.
  16423. @end deftypevr
  16424. @deftypevr {@code{cups-configuration} parameter} string default-policy
  16425. Specifies the default access policy to use.
  16426. Defaults to @samp{"default"}.
  16427. @end deftypevr
  16428. @deftypevr {@code{cups-configuration} parameter} boolean default-shared?
  16429. Specifies whether local printers are shared by default.
  16430. Defaults to @samp{#t}.
  16431. @end deftypevr
  16432. @deftypevr {@code{cups-configuration} parameter} non-negative-integer dirty-clean-interval
  16433. Specifies the delay for updating of configuration and state files, in
  16434. seconds. A value of 0 causes the update to happen as soon as possible,
  16435. typically within a few milliseconds.
  16436. Defaults to @samp{30}.
  16437. @end deftypevr
  16438. @deftypevr {@code{cups-configuration} parameter} error-policy error-policy
  16439. Specifies what to do when an error occurs. Possible values are
  16440. @code{abort-job}, which will discard the failed print job;
  16441. @code{retry-job}, which will retry the job at a later time;
  16442. @code{retry-current-job}, which retries the failed job immediately; and
  16443. @code{stop-printer}, which stops the printer.
  16444. Defaults to @samp{stop-printer}.
  16445. @end deftypevr
  16446. @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-limit
  16447. Specifies the maximum cost of filters that are run concurrently, which
  16448. can be used to minimize disk, memory, and CPU resource problems. A
  16449. limit of 0 disables filter limiting. An average print to a
  16450. non-PostScript printer needs a filter limit of about 200. A PostScript
  16451. printer needs about half that (100). Setting the limit below these
  16452. thresholds will effectively limit the scheduler to printing a single job
  16453. at any time.
  16454. Defaults to @samp{0}.
  16455. @end deftypevr
  16456. @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-nice
  16457. Specifies the scheduling priority of filters that are run to print a
  16458. job. The nice value ranges from 0, the highest priority, to 19, the
  16459. lowest priority.
  16460. Defaults to @samp{0}.
  16461. @end deftypevr
  16462. @deftypevr {@code{cups-configuration} parameter} host-name-lookups host-name-lookups
  16463. Specifies whether to do reverse lookups on connecting clients. The
  16464. @code{double} setting causes @code{cupsd} to verify that the hostname
  16465. resolved from the address matches one of the addresses returned for that
  16466. hostname. Double lookups also prevent clients with unregistered
  16467. addresses from connecting to your server. Only set this option to
  16468. @code{#t} or @code{double} if absolutely required.
  16469. Defaults to @samp{#f}.
  16470. @end deftypevr
  16471. @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-kill-delay
  16472. Specifies the number of seconds to wait before killing the filters and
  16473. backend associated with a canceled or held job.
  16474. Defaults to @samp{30}.
  16475. @end deftypevr
  16476. @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-interval
  16477. Specifies the interval between retries of jobs in seconds. This is
  16478. typically used for fax queues but can also be used with normal print
  16479. queues whose error policy is @code{retry-job} or
  16480. @code{retry-current-job}.
  16481. Defaults to @samp{30}.
  16482. @end deftypevr
  16483. @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-limit
  16484. Specifies the number of retries that are done for jobs. This is
  16485. typically used for fax queues but can also be used with normal print
  16486. queues whose error policy is @code{retry-job} or
  16487. @code{retry-current-job}.
  16488. Defaults to @samp{5}.
  16489. @end deftypevr
  16490. @deftypevr {@code{cups-configuration} parameter} boolean keep-alive?
  16491. Specifies whether to support HTTP keep-alive connections.
  16492. Defaults to @samp{#t}.
  16493. @end deftypevr
  16494. @deftypevr {@code{cups-configuration} parameter} non-negative-integer limit-request-body
  16495. Specifies the maximum size of print files, IPP requests, and HTML form
  16496. data. A limit of 0 disables the limit check.
  16497. Defaults to @samp{0}.
  16498. @end deftypevr
  16499. @deftypevr {@code{cups-configuration} parameter} multiline-string-list listen
  16500. Listens on the specified interfaces for connections. Valid values are
  16501. of the form @var{address}:@var{port}, where @var{address} is either an
  16502. IPv6 address enclosed in brackets, an IPv4 address, or @code{*} to
  16503. indicate all addresses. Values can also be file names of local UNIX
  16504. domain sockets. The Listen directive is similar to the Port directive
  16505. but allows you to restrict access to specific interfaces or networks.
  16506. @end deftypevr
  16507. @deftypevr {@code{cups-configuration} parameter} non-negative-integer listen-back-log
  16508. Specifies the number of pending connections that will be allowed. This
  16509. normally only affects very busy servers that have reached the MaxClients
  16510. limit, but can also be triggered by large numbers of simultaneous
  16511. connections. When the limit is reached, the operating system will
  16512. refuse additional connections until the scheduler can accept the pending
  16513. ones.
  16514. Defaults to @samp{128}.
  16515. @end deftypevr
  16516. @deftypevr {@code{cups-configuration} parameter} location-access-control-list location-access-controls
  16517. Specifies a set of additional access controls.
  16518. Available @code{location-access-controls} fields are:
  16519. @deftypevr {@code{location-access-controls} parameter} file-name path
  16520. Specifies the URI path to which the access control applies.
  16521. @end deftypevr
  16522. @deftypevr {@code{location-access-controls} parameter} access-control-list access-controls
  16523. Access controls for all access to this path, in the same format as the
  16524. @code{access-controls} of @code{operation-access-control}.
  16525. Defaults to @samp{()}.
  16526. @end deftypevr
  16527. @deftypevr {@code{location-access-controls} parameter} method-access-control-list method-access-controls
  16528. Access controls for method-specific access to this path.
  16529. Defaults to @samp{()}.
  16530. Available @code{method-access-controls} fields are:
  16531. @deftypevr {@code{method-access-controls} parameter} boolean reverse?
  16532. If @code{#t}, apply access controls to all methods except the listed
  16533. methods. Otherwise apply to only the listed methods.
  16534. Defaults to @samp{#f}.
  16535. @end deftypevr
  16536. @deftypevr {@code{method-access-controls} parameter} method-list methods
  16537. Methods to which this access control applies.
  16538. Defaults to @samp{()}.
  16539. @end deftypevr
  16540. @deftypevr {@code{method-access-controls} parameter} access-control-list access-controls
  16541. Access control directives, as a list of strings. Each string should be
  16542. one directive, such as @samp{"Order allow,deny"}.
  16543. Defaults to @samp{()}.
  16544. @end deftypevr
  16545. @end deftypevr
  16546. @end deftypevr
  16547. @deftypevr {@code{cups-configuration} parameter} non-negative-integer log-debug-history
  16548. Specifies the number of debugging messages that are retained for logging
  16549. if an error occurs in a print job. Debug messages are logged regardless
  16550. of the LogLevel setting.
  16551. Defaults to @samp{100}.
  16552. @end deftypevr
  16553. @deftypevr {@code{cups-configuration} parameter} log-level log-level
  16554. Specifies the level of logging for the ErrorLog file. The value
  16555. @code{none} stops all logging while @code{debug2} logs everything.
  16556. Defaults to @samp{info}.
  16557. @end deftypevr
  16558. @deftypevr {@code{cups-configuration} parameter} log-time-format log-time-format
  16559. Specifies the format of the date and time in the log files. The value
  16560. @code{standard} logs whole seconds while @code{usecs} logs microseconds.
  16561. Defaults to @samp{standard}.
  16562. @end deftypevr
  16563. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients
  16564. Specifies the maximum number of simultaneous clients that are allowed by
  16565. the scheduler.
  16566. Defaults to @samp{100}.
  16567. @end deftypevr
  16568. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients-per-host
  16569. Specifies the maximum number of simultaneous clients that are allowed
  16570. from a single address.
  16571. Defaults to @samp{100}.
  16572. @end deftypevr
  16573. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-copies
  16574. Specifies the maximum number of copies that a user can print of each
  16575. job.
  16576. Defaults to @samp{9999}.
  16577. @end deftypevr
  16578. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-hold-time
  16579. Specifies the maximum time a job may remain in the @code{indefinite}
  16580. hold state before it is canceled. A value of 0 disables cancellation of
  16581. held jobs.
  16582. Defaults to @samp{0}.
  16583. @end deftypevr
  16584. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs
  16585. Specifies the maximum number of simultaneous jobs that are allowed. Set
  16586. to 0 to allow an unlimited number of jobs.
  16587. Defaults to @samp{500}.
  16588. @end deftypevr
  16589. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-printer
  16590. Specifies the maximum number of simultaneous jobs that are allowed per
  16591. printer. A value of 0 allows up to MaxJobs jobs per printer.
  16592. Defaults to @samp{0}.
  16593. @end deftypevr
  16594. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-user
  16595. Specifies the maximum number of simultaneous jobs that are allowed per
  16596. user. A value of 0 allows up to MaxJobs jobs per user.
  16597. Defaults to @samp{0}.
  16598. @end deftypevr
  16599. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-job-time
  16600. Specifies the maximum time a job may take to print before it is
  16601. canceled, in seconds. Set to 0 to disable cancellation of ``stuck'' jobs.
  16602. Defaults to @samp{10800}.
  16603. @end deftypevr
  16604. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-log-size
  16605. Specifies the maximum size of the log files before they are rotated, in
  16606. bytes. The value 0 disables log rotation.
  16607. Defaults to @samp{1048576}.
  16608. @end deftypevr
  16609. @deftypevr {@code{cups-configuration} parameter} non-negative-integer multiple-operation-timeout
  16610. Specifies the maximum amount of time to allow between files in a
  16611. multiple file print job, in seconds.
  16612. Defaults to @samp{900}.
  16613. @end deftypevr
  16614. @deftypevr {@code{cups-configuration} parameter} string page-log-format
  16615. Specifies the format of PageLog lines. Sequences beginning with percent
  16616. (@samp{%}) characters are replaced with the corresponding information,
  16617. while all other characters are copied literally. The following percent
  16618. sequences are recognized:
  16619. @table @samp
  16620. @item %%
  16621. insert a single percent character
  16622. @item %@{name@}
  16623. insert the value of the specified IPP attribute
  16624. @item %C
  16625. insert the number of copies for the current page
  16626. @item %P
  16627. insert the current page number
  16628. @item %T
  16629. insert the current date and time in common log format
  16630. @item %j
  16631. insert the job ID
  16632. @item %p
  16633. insert the printer name
  16634. @item %u
  16635. insert the username
  16636. @end table
  16637. A value of the empty string disables page logging. The string @code{%p
  16638. %u %j %T %P %C %@{job-billing@} %@{job-originating-host-name@}
  16639. %@{job-name@} %@{media@} %@{sides@}} creates a page log with the
  16640. standard items.
  16641. Defaults to @samp{""}.
  16642. @end deftypevr
  16643. @deftypevr {@code{cups-configuration} parameter} environment-variables environment-variables
  16644. Passes the specified environment variable(s) to child processes; a list
  16645. of strings.
  16646. Defaults to @samp{()}.
  16647. @end deftypevr
  16648. @deftypevr {@code{cups-configuration} parameter} policy-configuration-list policies
  16649. Specifies named access control policies.
  16650. Available @code{policy-configuration} fields are:
  16651. @deftypevr {@code{policy-configuration} parameter} string name
  16652. Name of the policy.
  16653. @end deftypevr
  16654. @deftypevr {@code{policy-configuration} parameter} string job-private-access
  16655. Specifies an access list for a job's private values. @code{@@ACL} maps
  16656. to the printer's requesting-user-name-allowed or
  16657. requesting-user-name-denied values. @code{@@OWNER} maps to the job's
  16658. owner. @code{@@SYSTEM} maps to the groups listed for the
  16659. @code{system-group} field of the @code{files-configuration},
  16660. which is reified into the @code{cups-files.conf(5)} file. Other
  16661. possible elements of the access list include specific user names, and
  16662. @code{@@@var{group}} to indicate members of a specific group. The
  16663. access list may also be simply @code{all} or @code{default}.
  16664. Defaults to @samp{"@@OWNER @@SYSTEM"}.
  16665. @end deftypevr
  16666. @deftypevr {@code{policy-configuration} parameter} string job-private-values
  16667. Specifies the list of job values to make private, or @code{all},
  16668. @code{default}, or @code{none}.
  16669. Defaults to @samp{"job-name job-originating-host-name
  16670. job-originating-user-name phone"}.
  16671. @end deftypevr
  16672. @deftypevr {@code{policy-configuration} parameter} string subscription-private-access
  16673. Specifies an access list for a subscription's private values.
  16674. @code{@@ACL} maps to the printer's requesting-user-name-allowed or
  16675. requesting-user-name-denied values. @code{@@OWNER} maps to the job's
  16676. owner. @code{@@SYSTEM} maps to the groups listed for the
  16677. @code{system-group} field of the @code{files-configuration},
  16678. which is reified into the @code{cups-files.conf(5)} file. Other
  16679. possible elements of the access list include specific user names, and
  16680. @code{@@@var{group}} to indicate members of a specific group. The
  16681. access list may also be simply @code{all} or @code{default}.
  16682. Defaults to @samp{"@@OWNER @@SYSTEM"}.
  16683. @end deftypevr
  16684. @deftypevr {@code{policy-configuration} parameter} string subscription-private-values
  16685. Specifies the list of job values to make private, or @code{all},
  16686. @code{default}, or @code{none}.
  16687. Defaults to @samp{"notify-events notify-pull-method notify-recipient-uri
  16688. notify-subscriber-user-name notify-user-data"}.
  16689. @end deftypevr
  16690. @deftypevr {@code{policy-configuration} parameter} operation-access-control-list access-controls
  16691. Access control by IPP operation.
  16692. Defaults to @samp{()}.
  16693. @end deftypevr
  16694. @end deftypevr
  16695. @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-files
  16696. Specifies whether job files (documents) are preserved after a job is
  16697. printed. If a numeric value is specified, job files are preserved for
  16698. the indicated number of seconds after printing. Otherwise a boolean
  16699. value applies indefinitely.
  16700. Defaults to @samp{86400}.
  16701. @end deftypevr
  16702. @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-history
  16703. Specifies whether the job history is preserved after a job is printed.
  16704. If a numeric value is specified, the job history is preserved for the
  16705. indicated number of seconds after printing. If @code{#t}, the job
  16706. history is preserved until the MaxJobs limit is reached.
  16707. Defaults to @samp{#t}.
  16708. @end deftypevr
  16709. @deftypevr {@code{cups-configuration} parameter} non-negative-integer reload-timeout
  16710. Specifies the amount of time to wait for job completion before
  16711. restarting the scheduler.
  16712. Defaults to @samp{30}.
  16713. @end deftypevr
  16714. @deftypevr {@code{cups-configuration} parameter} string rip-cache
  16715. Specifies the maximum amount of memory to use when converting documents
  16716. into bitmaps for a printer.
  16717. Defaults to @samp{"128m"}.
  16718. @end deftypevr
  16719. @deftypevr {@code{cups-configuration} parameter} string server-admin
  16720. Specifies the email address of the server administrator.
  16721. Defaults to @samp{"root@@localhost.localdomain"}.
  16722. @end deftypevr
  16723. @deftypevr {@code{cups-configuration} parameter} host-name-list-or-* server-alias
  16724. The ServerAlias directive is used for HTTP Host header validation when
  16725. clients connect to the scheduler from external interfaces. Using the
  16726. special name @code{*} can expose your system to known browser-based DNS
  16727. rebinding attacks, even when accessing sites through a firewall. If the
  16728. auto-discovery of alternate names does not work, we recommend listing
  16729. each alternate name with a ServerAlias directive instead of using
  16730. @code{*}.
  16731. Defaults to @samp{*}.
  16732. @end deftypevr
  16733. @deftypevr {@code{cups-configuration} parameter} string server-name
  16734. Specifies the fully-qualified host name of the server.
  16735. Defaults to @samp{"localhost"}.
  16736. @end deftypevr
  16737. @deftypevr {@code{cups-configuration} parameter} server-tokens server-tokens
  16738. Specifies what information is included in the Server header of HTTP
  16739. responses. @code{None} disables the Server header. @code{ProductOnly}
  16740. reports @code{CUPS}. @code{Major} reports @code{CUPS 2}. @code{Minor}
  16741. reports @code{CUPS 2.0}. @code{Minimal} reports @code{CUPS 2.0.0}.
  16742. @code{OS} reports @code{CUPS 2.0.0 (@var{uname})} where @var{uname} is
  16743. the output of the @code{uname} command. @code{Full} reports @code{CUPS
  16744. 2.0.0 (@var{uname}) IPP/2.0}.
  16745. Defaults to @samp{Minimal}.
  16746. @end deftypevr
  16747. @deftypevr {@code{cups-configuration} parameter} multiline-string-list ssl-listen
  16748. Listens on the specified interfaces for encrypted connections. Valid
  16749. values are of the form @var{address}:@var{port}, where @var{address} is
  16750. either an IPv6 address enclosed in brackets, an IPv4 address, or
  16751. @code{*} to indicate all addresses.
  16752. Defaults to @samp{()}.
  16753. @end deftypevr
  16754. @deftypevr {@code{cups-configuration} parameter} ssl-options ssl-options
  16755. Sets encryption options. By default, CUPS only supports encryption
  16756. using TLS v1.0 or higher using known secure cipher suites. Security is
  16757. reduced when @code{Allow} options are used, and enhanced when @code{Deny}
  16758. options are used. The @code{AllowRC4} option enables the 128-bit RC4 cipher
  16759. suites, which are required for some older clients. The @code{AllowSSL3} option
  16760. enables SSL v3.0, which is required for some older clients that do not support
  16761. TLS v1.0. The @code{DenyCBC} option disables all CBC cipher suites. The
  16762. @code{DenyTLS1.0} option disables TLS v1.0 support - this sets the minimum
  16763. protocol version to TLS v1.1.
  16764. Defaults to @samp{()}.
  16765. @end deftypevr
  16766. @deftypevr {@code{cups-configuration} parameter} boolean strict-conformance?
  16767. Specifies whether the scheduler requires clients to strictly adhere to
  16768. the IPP specifications.
  16769. Defaults to @samp{#f}.
  16770. @end deftypevr
  16771. @deftypevr {@code{cups-configuration} parameter} non-negative-integer timeout
  16772. Specifies the HTTP request timeout, in seconds.
  16773. Defaults to @samp{900}.
  16774. @end deftypevr
  16775. @deftypevr {@code{cups-configuration} parameter} boolean web-interface?
  16776. Specifies whether the web interface is enabled.
  16777. Defaults to @samp{#f}.
  16778. @end deftypevr
  16779. At this point you're probably thinking ``oh dear, Guix manual, I like
  16780. you but you can stop already with the configuration options''. Indeed.
  16781. However, one more point: it could be that you have an existing
  16782. @code{cupsd.conf} that you want to use. In that case, you can pass an
  16783. @code{opaque-cups-configuration} as the configuration of a
  16784. @code{cups-service-type}.
  16785. Available @code{opaque-cups-configuration} fields are:
  16786. @deftypevr {@code{opaque-cups-configuration} parameter} package cups
  16787. The CUPS package.
  16788. @end deftypevr
  16789. @deftypevr {@code{opaque-cups-configuration} parameter} string cupsd.conf
  16790. The contents of the @code{cupsd.conf}, as a string.
  16791. @end deftypevr
  16792. @deftypevr {@code{opaque-cups-configuration} parameter} string cups-files.conf
  16793. The contents of the @code{cups-files.conf} file, as a string.
  16794. @end deftypevr
  16795. For example, if your @code{cupsd.conf} and @code{cups-files.conf} are in
  16796. strings of the same name, you could instantiate a CUPS service like
  16797. this:
  16798. @lisp
  16799. (service cups-service-type
  16800. (opaque-cups-configuration
  16801. (cupsd.conf cupsd.conf)
  16802. (cups-files.conf cups-files.conf)))
  16803. @end lisp
  16804. @node Desktop Services
  16805. @subsection Desktop Services
  16806. The @code{(gnu services desktop)} module provides services that are
  16807. usually useful in the context of a ``desktop'' setup---that is, on a
  16808. machine running a graphical display server, possibly with graphical user
  16809. interfaces, etc. It also defines services that provide specific desktop
  16810. environments like GNOME, Xfce or MATE.
  16811. To simplify things, the module defines a variable containing the set of
  16812. services that users typically expect on a machine with a graphical
  16813. environment and networking:
  16814. @defvr {Scheme Variable} %desktop-services
  16815. This is a list of services that builds upon @code{%base-services} and
  16816. adds or adjusts services for a typical ``desktop'' setup.
  16817. In particular, it adds a graphical login manager (@pxref{X Window,
  16818. @code{gdm-service-type}}), screen lockers, a network management tool
  16819. (@pxref{Networking Services, @code{network-manager-service-type}}) with modem
  16820. support (@pxref{Networking Services, @code{modem-manager-service-type}}),
  16821. energy and color management services, the @code{elogind} login and seat
  16822. manager, the Polkit privilege service, the GeoClue location service, the
  16823. AccountsService daemon that allows authorized users change system passwords,
  16824. an NTP client (@pxref{Networking Services}), the Avahi daemon, and has the
  16825. name service switch service configured to be able to use @code{nss-mdns}
  16826. (@pxref{Name Service Switch, mDNS}).
  16827. @end defvr
  16828. The @code{%desktop-services} variable can be used as the @code{services}
  16829. field of an @code{operating-system} declaration (@pxref{operating-system
  16830. Reference, @code{services}}).
  16831. Additionally, the @code{gnome-desktop-service-type},
  16832. @code{xfce-desktop-service}, @code{mate-desktop-service-type},
  16833. @code{lxqt-desktop-service-type} and @code{enlightenment-desktop-service-type}
  16834. procedures can add GNOME, Xfce, MATE and/or Enlightenment to a system. To
  16835. ``add GNOME'' means that system-level services like the backlight adjustment
  16836. helpers and the power management utilities are added to the system, extending
  16837. @code{polkit} and @code{dbus} appropriately, allowing GNOME to operate with
  16838. elevated privileges on a limited number of special-purpose system interfaces.
  16839. Additionally, adding a service made by @code{gnome-desktop-service-type} adds
  16840. the GNOME metapackage to the system profile. Likewise, adding the Xfce
  16841. service not only adds the @code{xfce} metapackage to the system profile, but
  16842. it also gives the Thunar file manager the ability to open a ``root-mode'' file
  16843. management window, if the user authenticates using the administrator's
  16844. password via the standard polkit graphical interface. To ``add MATE'' means
  16845. that @code{polkit} and @code{dbus} are extended appropriately, allowing MATE
  16846. to operate with elevated privileges on a limited number of special-purpose
  16847. system interfaces. Additionally, adding a service of type
  16848. @code{mate-desktop-service-type} adds the MATE metapackage to the system
  16849. profile. ``Adding Enlightenment'' means that @code{dbus} is extended
  16850. appropriately, and several of Enlightenment's binaries are set as setuid,
  16851. allowing Enlightenment's screen locker and other functionality to work as
  16852. expected.
  16853. The desktop environments in Guix use the Xorg display server by
  16854. default. If you'd like to use the newer display server protocol
  16855. called Wayland, you need to enable Wayland support in GDM
  16856. (@pxref{wayland-gdm}). Another solution is to use the
  16857. @code{sddm-service} instead of GDM as the graphical login manager.
  16858. You should then select the ``GNOME (Wayland)'' session in SDDM@.
  16859. Alternatively you can also try starting GNOME on Wayland manually from a
  16860. TTY with the command ``XDG_SESSION_TYPE=wayland exec dbus-run-session
  16861. gnome-session``. Currently only GNOME has support for Wayland.
  16862. @defvr {Scheme Variable} gnome-desktop-service-type
  16863. This is the type of the service that adds the @uref{https://www.gnome.org,
  16864. GNOME} desktop environment. Its value is a @code{gnome-desktop-configuration}
  16865. object (see below).
  16866. This service adds the @code{gnome} package to the system profile, and extends
  16867. polkit with the actions from @code{gnome-settings-daemon}.
  16868. @end defvr
  16869. @deftp {Data Type} gnome-desktop-configuration
  16870. Configuration record for the GNOME desktop environment.
  16871. @table @asis
  16872. @item @code{gnome} (default: @code{gnome})
  16873. The GNOME package to use.
  16874. @end table
  16875. @end deftp
  16876. @defvr {Scheme Variable} xfce-desktop-service-type
  16877. This is the type of a service to run the @uref{Xfce, https://xfce.org/}
  16878. desktop environment. Its value is an @code{xfce-desktop-configuration} object
  16879. (see below).
  16880. This service adds the @code{xfce} package to the system profile, and
  16881. extends polkit with the ability for @code{thunar} to manipulate the file
  16882. system as root from within a user session, after the user has authenticated
  16883. with the administrator's password.
  16884. Note that @code{xfce4-panel} and its plugin packages should be installed in
  16885. the same profile to ensure compatibility. When using this service, you should
  16886. add extra plugins (@code{xfce4-whiskermenu-plugin},
  16887. @code{xfce4-weather-plugin}, etc.) to the @code{packages} field of your
  16888. @code{operating-system}.
  16889. @end defvr
  16890. @deftp {Data Type} xfce-desktop-configuration
  16891. Configuration record for the Xfce desktop environment.
  16892. @table @asis
  16893. @item @code{xfce} (default: @code{xfce})
  16894. The Xfce package to use.
  16895. @end table
  16896. @end deftp
  16897. @deffn {Scheme Variable} mate-desktop-service-type
  16898. This is the type of the service that runs the @uref{https://mate-desktop.org/,
  16899. MATE desktop environment}. Its value is a @code{mate-desktop-configuration}
  16900. object (see below).
  16901. This service adds the @code{mate} package to the system
  16902. profile, and extends polkit with the actions from
  16903. @code{mate-settings-daemon}.
  16904. @end deffn
  16905. @deftp {Data Type} mate-desktop-configuration
  16906. Configuration record for the MATE desktop environment.
  16907. @table @asis
  16908. @item @code{mate} (default: @code{mate})
  16909. The MATE package to use.
  16910. @end table
  16911. @end deftp
  16912. @deffn {Scheme Variable} lxqt-desktop-service-type
  16913. This is the type of the service that runs the @uref{https://lxqt-project.org,
  16914. LXQt desktop environment}. Its value is a @code{lxqt-desktop-configuration}
  16915. object (see below).
  16916. This service adds the @code{lxqt} package to the system
  16917. profile.
  16918. @end deffn
  16919. @deftp {Data Type} lxqt-desktop-configuration
  16920. Configuration record for the LXQt desktop environment.
  16921. @table @asis
  16922. @item @code{lxqt} (default: @code{lxqt})
  16923. The LXQT package to use.
  16924. @end table
  16925. @end deftp
  16926. @deffn {Scheme Variable} enlightenment-desktop-service-type
  16927. Return a service that adds the @code{enlightenment} package to the system
  16928. profile, and extends dbus with actions from @code{efl}.
  16929. @end deffn
  16930. @deftp {Data Type} enlightenment-desktop-service-configuration
  16931. @table @asis
  16932. @item @code{enlightenment} (default: @code{enlightenment})
  16933. The enlightenment package to use.
  16934. @end table
  16935. @end deftp
  16936. Because the GNOME, Xfce and MATE desktop services pull in so many packages,
  16937. the default @code{%desktop-services} variable doesn't include any of
  16938. them by default. To add GNOME, Xfce or MATE, just @code{cons} them onto
  16939. @code{%desktop-services} in the @code{services} field of your
  16940. @code{operating-system}:
  16941. @lisp
  16942. (use-modules (gnu))
  16943. (use-service-modules desktop)
  16944. (operating-system
  16945. ...
  16946. ;; cons* adds items to the list given as its last argument.
  16947. (services (cons* (service gnome-desktop-service-type)
  16948. (service xfce-desktop-service)
  16949. %desktop-services))
  16950. ...)
  16951. @end lisp
  16952. These desktop environments will then be available as options in the
  16953. graphical login window.
  16954. The actual service definitions included in @code{%desktop-services} and
  16955. provided by @code{(gnu services dbus)} and @code{(gnu services desktop)}
  16956. are described below.
  16957. @deffn {Scheme Procedure} dbus-service [#:dbus @var{dbus}] [#:services '()]
  16958. Return a service that runs the ``system bus'', using @var{dbus}, with
  16959. support for @var{services}.
  16960. @uref{https://dbus.freedesktop.org/, D-Bus} is an inter-process communication
  16961. facility. Its system bus is used to allow system services to communicate
  16962. and to be notified of system-wide events.
  16963. @var{services} must be a list of packages that provide an
  16964. @file{etc/dbus-1/system.d} directory containing additional D-Bus configuration
  16965. and policy files. For example, to allow avahi-daemon to use the system bus,
  16966. @var{services} must be equal to @code{(list avahi)}.
  16967. @end deffn
  16968. @deffn {Scheme Procedure} elogind-service [#:config @var{config}]
  16969. Return a service that runs the @code{elogind} login and
  16970. seat management daemon. @uref{https://github.com/elogind/elogind,
  16971. Elogind} exposes a D-Bus interface that can be used to know which users
  16972. are logged in, know what kind of sessions they have open, suspend the
  16973. system, inhibit system suspend, reboot the system, and other tasks.
  16974. Elogind handles most system-level power events for a computer, for
  16975. example suspending the system when a lid is closed, or shutting it down
  16976. when the power button is pressed.
  16977. The @var{config} keyword argument specifies the configuration for
  16978. elogind, and should be the result of an @code{(elogind-configuration
  16979. (@var{parameter} @var{value})...)} invocation. Available parameters and
  16980. their default values are:
  16981. @table @code
  16982. @item kill-user-processes?
  16983. @code{#f}
  16984. @item kill-only-users
  16985. @code{()}
  16986. @item kill-exclude-users
  16987. @code{("root")}
  16988. @item inhibit-delay-max-seconds
  16989. @code{5}
  16990. @item handle-power-key
  16991. @code{poweroff}
  16992. @item handle-suspend-key
  16993. @code{suspend}
  16994. @item handle-hibernate-key
  16995. @code{hibernate}
  16996. @item handle-lid-switch
  16997. @code{suspend}
  16998. @item handle-lid-switch-docked
  16999. @code{ignore}
  17000. @item handle-lid-switch-external-power
  17001. @code{ignore}
  17002. @item power-key-ignore-inhibited?
  17003. @code{#f}
  17004. @item suspend-key-ignore-inhibited?
  17005. @code{#f}
  17006. @item hibernate-key-ignore-inhibited?
  17007. @code{#f}
  17008. @item lid-switch-ignore-inhibited?
  17009. @code{#t}
  17010. @item holdoff-timeout-seconds
  17011. @code{30}
  17012. @item idle-action
  17013. @code{ignore}
  17014. @item idle-action-seconds
  17015. @code{(* 30 60)}
  17016. @item runtime-directory-size-percent
  17017. @code{10}
  17018. @item runtime-directory-size
  17019. @code{#f}
  17020. @item remove-ipc?
  17021. @code{#t}
  17022. @item suspend-state
  17023. @code{("mem" "standby" "freeze")}
  17024. @item suspend-mode
  17025. @code{()}
  17026. @item hibernate-state
  17027. @code{("disk")}
  17028. @item hibernate-mode
  17029. @code{("platform" "shutdown")}
  17030. @item hybrid-sleep-state
  17031. @code{("disk")}
  17032. @item hybrid-sleep-mode
  17033. @code{("suspend" "platform" "shutdown")}
  17034. @end table
  17035. @end deffn
  17036. @deffn {Scheme Procedure} accountsservice-service @
  17037. [#:accountsservice @var{accountsservice}]
  17038. Return a service that runs AccountsService, a system service that can
  17039. list available accounts, change their passwords, and so on.
  17040. AccountsService integrates with PolicyKit to enable unprivileged users
  17041. to acquire the capability to modify their system configuration.
  17042. @uref{https://www.freedesktop.org/wiki/Software/AccountsService/, the
  17043. accountsservice web site} for more information.
  17044. The @var{accountsservice} keyword argument is the @code{accountsservice}
  17045. package to expose as a service.
  17046. @end deffn
  17047. @deffn {Scheme Procedure} polkit-service @
  17048. [#:polkit @var{polkit}]
  17049. Return a service that runs the
  17050. @uref{https://www.freedesktop.org/wiki/Software/polkit/, Polkit privilege
  17051. management service}, which allows system administrators to grant access to
  17052. privileged operations in a structured way. By querying the Polkit service, a
  17053. privileged system component can know when it should grant additional
  17054. capabilities to ordinary users. For example, an ordinary user can be granted
  17055. the capability to suspend the system if the user is logged in locally.
  17056. @end deffn
  17057. @defvr {Scheme Variable} polkit-wheel-service
  17058. Service that adds the @code{wheel} group as admins to the Polkit
  17059. service. This makes it so that users in the @code{wheel} group are queried
  17060. for their own passwords when performing administrative actions instead of
  17061. @code{root}'s, similar to the behaviour used by @code{sudo}.
  17062. @end defvr
  17063. @defvr {Scheme Variable} upower-service-type
  17064. Service that runs @uref{https://upower.freedesktop.org/, @command{upowerd}}, a
  17065. system-wide monitor for power consumption and battery levels, with the given
  17066. configuration settings.
  17067. It implements the @code{org.freedesktop.UPower} D-Bus interface, and is
  17068. notably used by GNOME.
  17069. @end defvr
  17070. @deftp {Data Type} upower-configuration
  17071. Data type representation the configuration for UPower.
  17072. @table @asis
  17073. @item @code{upower} (default: @var{upower})
  17074. Package to use for @code{upower}.
  17075. @item @code{watts-up-pro?} (default: @code{#f})
  17076. Enable the Watts Up Pro device.
  17077. @item @code{poll-batteries?} (default: @code{#t})
  17078. Enable polling the kernel for battery level changes.
  17079. @item @code{ignore-lid?} (default: @code{#f})
  17080. Ignore the lid state, this can be useful if it's incorrect on a device.
  17081. @item @code{use-percentage-for-policy?} (default: @code{#f})
  17082. Whether battery percentage based policy should be used. The default is to use
  17083. the time left, change to @code{#t} to use the percentage.
  17084. @item @code{percentage-low} (default: @code{10})
  17085. When @code{use-percentage-for-policy?} is @code{#t}, this sets the percentage
  17086. at which the battery is considered low.
  17087. @item @code{percentage-critical} (default: @code{3})
  17088. When @code{use-percentage-for-policy?} is @code{#t}, this sets the percentage
  17089. at which the battery is considered critical.
  17090. @item @code{percentage-action} (default: @code{2})
  17091. When @code{use-percentage-for-policy?} is @code{#t}, this sets the percentage
  17092. at which action will be taken.
  17093. @item @code{time-low} (default: @code{1200})
  17094. When @code{use-time-for-policy?} is @code{#f}, this sets the time remaining in
  17095. seconds at which the battery is considered low.
  17096. @item @code{time-critical} (default: @code{300})
  17097. When @code{use-time-for-policy?} is @code{#f}, this sets the time remaining in
  17098. seconds at which the battery is considered critical.
  17099. @item @code{time-action} (default: @code{120})
  17100. When @code{use-time-for-policy?} is @code{#f}, this sets the time remaining in
  17101. seconds at which action will be taken.
  17102. @item @code{critical-power-action} (default: @code{'hybrid-sleep})
  17103. The action taken when @code{percentage-action} or @code{time-action} is
  17104. reached (depending on the configuration of @code{use-percentage-for-policy?}).
  17105. Possible values are:
  17106. @itemize @bullet
  17107. @item
  17108. @code{'power-off}
  17109. @item
  17110. @code{'hibernate}
  17111. @item
  17112. @code{'hybrid-sleep}.
  17113. @end itemize
  17114. @end table
  17115. @end deftp
  17116. @deffn {Scheme Procedure} udisks-service [#:udisks @var{udisks}]
  17117. Return a service for @uref{https://udisks.freedesktop.org/docs/latest/,
  17118. UDisks}, a @dfn{disk management} daemon that provides user interfaces
  17119. with notifications and ways to mount/unmount disks. Programs that talk
  17120. to UDisks include the @command{udisksctl} command, part of UDisks, and
  17121. GNOME Disks. Note that Udisks relies on the @command{mount} command, so
  17122. it will only be able to use the file-system utilities installed in the
  17123. system profile. For example if you want to be able to mount NTFS
  17124. file-systems in read and write fashion, you'll need to have
  17125. @code{ntfs-3g} installed system-wide.
  17126. @end deffn
  17127. @deffn {Scheme Variable} colord-service-type
  17128. This is the type of the service that runs @command{colord}, a system
  17129. service with a D-Bus
  17130. interface to manage the color profiles of input and output devices such as
  17131. screens and scanners. It is notably used by the GNOME Color Manager graphical
  17132. tool. See @uref{https://www.freedesktop.org/software/colord/, the colord web
  17133. site} for more information.
  17134. @end deffn
  17135. @cindex scanner access
  17136. @defvr {Scheme Variable} sane-service-type
  17137. This service provides access to scanners @i{via}
  17138. @uref{http://www.sane-project.org, SANE} by installing the necessary
  17139. udev rules. It is included in @code{%desktop-services} (@pxref{Desktop
  17140. Services}) and relies by default on @code{sane-backends-minimal} package
  17141. (see below) for hardware support.
  17142. @end defvr
  17143. @defvr {Scheme Variable} sane-backends-minimal
  17144. The default package which the @code{sane-service-type} installs. It
  17145. supports many recent scanners.
  17146. @end defvr
  17147. @defvr {Scheme Variable} sane-backends
  17148. This package includes support for all scanners that
  17149. @code{sane-backends-minimal} supports, plus older Hewlett-Packard
  17150. scanners supported by @code{hplip} package. In order to use this on
  17151. a system which relies on @code{%desktop-services}, you may use
  17152. @code{modify-services} (@pxref{Service Reference,
  17153. @code{modify-services}}) as illustrated below:
  17154. @lisp
  17155. (use-modules (gnu))
  17156. (use-service-modules
  17157. @dots{}
  17158. desktop)
  17159. (use-package-modules
  17160. @dots{}
  17161. scanner)
  17162. (define %my-desktop-services
  17163. ;; List of desktop services that supports a broader range of scanners.
  17164. (modify-services %desktop-services
  17165. (sane-service-type _ => sane-backends)))
  17166. (operating-system
  17167. @dots{}
  17168. (services %my-desktop-services))
  17169. @end lisp
  17170. @end defvr
  17171. @deffn {Scheme Procedure} geoclue-application name [#:allowed? #t] [#:system? #f] [#:users '()]
  17172. Return a configuration allowing an application to access GeoClue
  17173. location data. @var{name} is the Desktop ID of the application, without
  17174. the @code{.desktop} part. If @var{allowed?} is true, the application
  17175. will have access to location information by default. The boolean
  17176. @var{system?} value indicates whether an application is a system component
  17177. or not. Finally @var{users} is a list of UIDs of all users for which
  17178. this application is allowed location info access. An empty users list
  17179. means that all users are allowed.
  17180. @end deffn
  17181. @defvr {Scheme Variable} %standard-geoclue-applications
  17182. The standard list of well-known GeoClue application configurations,
  17183. granting authority to the GNOME date-and-time utility to ask for the
  17184. current location in order to set the time zone, and allowing the
  17185. IceCat and Epiphany web browsers to request location information.
  17186. IceCat and Epiphany both query the user before allowing a web page to
  17187. know the user's location.
  17188. @end defvr
  17189. @deffn {Scheme Procedure} geoclue-service [#:colord @var{colord}] @
  17190. [#:whitelist '()] @
  17191. [#:wifi-geolocation-url "https://location.services.mozilla.com/v1/geolocate?key=geoclue"] @
  17192. [#:submit-data? #f]
  17193. [#:wifi-submission-url "https://location.services.mozilla.com/v1/submit?key=geoclue"] @
  17194. [#:submission-nick "geoclue"] @
  17195. [#:applications %standard-geoclue-applications]
  17196. Return a service that runs the GeoClue location service. This service
  17197. provides a D-Bus interface to allow applications to request access to a
  17198. user's physical location, and optionally to add information to online
  17199. location databases. See
  17200. @uref{https://wiki.freedesktop.org/www/Software/GeoClue/, the GeoClue
  17201. web site} for more information.
  17202. @end deffn
  17203. @deffn {Scheme Procedure} bluetooth-service [#:bluez @var{bluez}] @
  17204. [@w{#:auto-enable? #f}]
  17205. Return a service that runs the @command{bluetoothd} daemon, which
  17206. manages all the Bluetooth devices and provides a number of D-Bus
  17207. interfaces. When AUTO-ENABLE? is true, the bluetooth controller is
  17208. powered automatically at boot, which can be useful when using a
  17209. bluetooth keyboard or mouse.
  17210. Users need to be in the @code{lp} group to access the D-Bus service.
  17211. @end deffn
  17212. @defvr {Scheme Variable} gnome-keyring-service-type
  17213. This is the type of the service that adds the
  17214. @uref{https://wiki.gnome.org/Projects/GnomeKeyring, GNOME Keyring}. Its
  17215. value is a @code{gnome-keyring-configuration} object (see below).
  17216. This service adds the @code{gnome-keyring} package to the system profile
  17217. and extends PAM with entries using @code{pam_gnome_keyring.so}, unlocking
  17218. a user's login keyring when they log in or setting its password with passwd.
  17219. @end defvr
  17220. @deftp {Data Type} gnome-keyring-configuration
  17221. Configuration record for the GNOME Keyring service.
  17222. @table @asis
  17223. @item @code{keyring} (default: @code{gnome-keyring})
  17224. The GNOME keyring package to use.
  17225. @item @code{pam-services}
  17226. A list of @code{(@var{service} . @var{kind})} pairs denoting PAM
  17227. services to extend, where @var{service} is the name of an existing
  17228. service to extend and @var{kind} is one of @code{login} or
  17229. @code{passwd}.
  17230. If @code{login} is given, it adds an optional
  17231. @code{pam_gnome_keyring.so} to the auth block without arguments and to
  17232. the session block with @code{auto_start}. If @code{passwd} is given, it
  17233. adds an optional @code{pam_gnome_keyring.so} to the password block
  17234. without arguments.
  17235. By default, this field contains ``gdm-password'' with the value @code{login}
  17236. and ``passwd'' is with the value @code{passwd}.
  17237. @end table
  17238. @end deftp
  17239. @node Sound Services
  17240. @subsection Sound Services
  17241. @cindex sound support
  17242. @cindex ALSA
  17243. @cindex PulseAudio, sound support
  17244. The @code{(gnu services sound)} module provides a service to configure the
  17245. Advanced Linux Sound Architecture (ALSA) system, which makes PulseAudio the
  17246. preferred ALSA output driver.
  17247. @deffn {Scheme Variable} alsa-service-type
  17248. This is the type for the @uref{https://alsa-project.org/, Advanced Linux Sound
  17249. Architecture} (ALSA) system, which generates the @file{/etc/asound.conf}
  17250. configuration file. The value for this type is a @command{alsa-configuration}
  17251. record as in this example:
  17252. @lisp
  17253. (service alsa-service-type)
  17254. @end lisp
  17255. See below for details about @code{alsa-configuration}.
  17256. @end deffn
  17257. @deftp {Data Type} alsa-configuration
  17258. Data type representing the configuration for @code{alsa-service}.
  17259. @table @asis
  17260. @item @code{alsa-plugins} (default: @var{alsa-plugins})
  17261. @code{alsa-plugins} package to use.
  17262. @item @code{pulseaudio?} (default: @var{#t})
  17263. Whether ALSA applications should transparently be made to use the
  17264. @uref{https://www.pulseaudio.org/, PulseAudio} sound server.
  17265. Using PulseAudio allows you to run several sound-producing applications
  17266. at the same time and to individual control them @i{via}
  17267. @command{pavucontrol}, among other things.
  17268. @item @code{extra-options} (default: @var{""})
  17269. String to append to the @file{/etc/asound.conf} file.
  17270. @end table
  17271. @end deftp
  17272. Individual users who want to override the system configuration of ALSA can do
  17273. it with the @file{~/.asoundrc} file:
  17274. @example
  17275. # In guix, we have to specify the absolute path for plugins.
  17276. pcm_type.jack @{
  17277. lib "/home/alice/.guix-profile/lib/alsa-lib/libasound_module_pcm_jack.so"
  17278. @}
  17279. # Routing ALSA to jack:
  17280. # <http://jackaudio.org/faq/routing_alsa.html>.
  17281. pcm.rawjack @{
  17282. type jack
  17283. playback_ports @{
  17284. 0 system:playback_1
  17285. 1 system:playback_2
  17286. @}
  17287. capture_ports @{
  17288. 0 system:capture_1
  17289. 1 system:capture_2
  17290. @}
  17291. @}
  17292. pcm.!default @{
  17293. type plug
  17294. slave @{
  17295. pcm "rawjack"
  17296. @}
  17297. @}
  17298. @end example
  17299. See @uref{https://www.alsa-project.org/main/index.php/Asoundrc} for the
  17300. details.
  17301. @deffn {Scheme Variable} pulseaudio-service-type
  17302. This is the type for the @uref{https://www.pulseaudio.org/, PulseAudio}
  17303. sound server. It exists to allow system overrides of the default settings
  17304. via @code{pulseaudio-configuration}, see below.
  17305. @quotation Warning
  17306. This service overrides per-user configuration files. If you want
  17307. PulseAudio to honor configuration files in @file{~/.config/pulse} you
  17308. have to unset the environment variables @env{PULSE_CONFIG} and
  17309. @env{PULSE_CLIENTCONFIG} in your @file{~/.bash_profile}.
  17310. @end quotation
  17311. @quotation Warning
  17312. This service on its own does not ensure, that the @code{pulseaudio} package
  17313. exists on your machine. It merely adds configuration files for it, as
  17314. detailed below. In the (admittedly unlikely) case, that you find yourself
  17315. without a @code{pulseaudio} package, consider enabling it through the
  17316. @code{alsa-service-type} above.
  17317. @end quotation
  17318. @end deffn
  17319. @deftp {Data Type} pulseaudio-configuration
  17320. Data type representing the configuration for @code{pulseaudio-service}.
  17321. @table @asis
  17322. @item @code{client-conf} (default: @code{'()})
  17323. List of settings to set in @file{client.conf}.
  17324. Accepts a list of strings or symbol-value pairs. A string will be
  17325. inserted as-is with a newline added. A pair will be formatted as
  17326. ``key = value'', again with a newline added.
  17327. @item @code{daemon-conf} (default: @code{'((flat-volumes . no))})
  17328. List of settings to set in @file{daemon.conf}, formatted just like
  17329. @var{client-conf}.
  17330. @item @code{script-file} (default: @code{(file-append pulseaudio "/etc/pulse/default.pa")})
  17331. Script file to use as @file{default.pa}. In case the
  17332. @code{extra-script-files} field below is used, an @code{.include}
  17333. directive pointing to @file{/etc/pulse/default.pa.d} is appended to the
  17334. provided script.
  17335. @item @code{extra-script-files} (default: @code{'())})
  17336. A list of file-like objects defining extra PulseAudio scripts to run at
  17337. the initialization of the @command{pulseaudio} daemon, after the main
  17338. @code{script-file}. The scripts are deployed to the
  17339. @file{/etc/pulse/default.pa.d} directory; they should have the
  17340. @samp{.pa} file name extension. For a reference of the available
  17341. commands, refer to @command{man pulse-cli-syntax}.
  17342. @item @code{system-script-file} (default: @code{(file-append pulseaudio "/etc/pulse/system.pa")})
  17343. Script file to use as @file{system.pa}.
  17344. @end table
  17345. The example below sets the default PulseAudio card profile, the default
  17346. sink and the default source to use for a old SoundBlaster Audigy sound
  17347. card:
  17348. @lisp
  17349. (pulseaudio-configuration
  17350. (extra-script-files
  17351. (list (plain-file "audigy.pa"
  17352. (string-append "\
  17353. set-card-profile alsa_card.pci-0000_01_01.0 \
  17354. output:analog-surround-40+input:analog-mono
  17355. set-default-source alsa_input.pci-0000_01_01.0.analog-mono
  17356. set-default-sink alsa_output.pci-0000_01_01.0.analog-surround-40\n")))))
  17357. @end lisp
  17358. Note that @code{pulseaudio-service-type} is part of
  17359. @code{%desktop-services}; if your operating system declaration was
  17360. derived from one of the desktop templates, you'll want to adjust the
  17361. above example to modify the existing @code{pulseaudio-service-type} via
  17362. @code{modify-services} (@pxref{Service Reference,
  17363. @code{modify-services}}), instead of defining a new one.
  17364. @end deftp
  17365. @deffn {Scheme Variable} ladspa-service-type
  17366. This service sets the @var{LADSPA_PATH} variable, so that programs, which
  17367. respect it, e.g. PulseAudio, can load LADSPA plugins.
  17368. The following example will setup the service to enable modules from the
  17369. @code{swh-plugins} package:
  17370. @lisp
  17371. (service ladspa-service-type
  17372. (ladspa-configuration (plugins (list swh-plugins))))
  17373. @end lisp
  17374. See @uref{http://plugin.org.uk/ladspa-swh/docs/ladspa-swh.html} for the
  17375. details.
  17376. @end deffn
  17377. @node Database Services
  17378. @subsection Database Services
  17379. @cindex database
  17380. @cindex SQL
  17381. The @code{(gnu services databases)} module provides the following services.
  17382. @subsubheading PostgreSQL
  17383. The following example describes a PostgreSQL service with the default
  17384. configuration.
  17385. @lisp
  17386. (service postgresql-service-type
  17387. (postgresql-configuration
  17388. (postgresql postgresql-10)))
  17389. @end lisp
  17390. If the services fails to start, it may be due to an incompatible
  17391. cluster already present in @var{data-directory}. Adjust it (or, if you
  17392. don't need the cluster anymore, delete @var{data-directory}), then
  17393. restart the service.
  17394. Peer authentication is used by default and the @code{postgres} user
  17395. account has no shell, which prevents the direct execution of @code{psql}
  17396. commands as this user. To use @code{psql}, you can temporarily log in
  17397. as @code{postgres} using a shell, create a PostgreSQL superuser with the
  17398. same name as one of the system users and then create the associated
  17399. database.
  17400. @example
  17401. sudo -u postgres -s /bin/sh
  17402. createuser --interactive
  17403. createdb $MY_USER_LOGIN # Replace appropriately.
  17404. @end example
  17405. @deftp {Data Type} postgresql-configuration
  17406. Data type representing the configuration for the
  17407. @code{postgresql-service-type}.
  17408. @table @asis
  17409. @item @code{postgresql}
  17410. PostgreSQL package to use for the service.
  17411. @item @code{port} (default: @code{5432})
  17412. Port on which PostgreSQL should listen.
  17413. @item @code{locale} (default: @code{"en_US.utf8"})
  17414. Locale to use as the default when creating the database cluster.
  17415. @item @code{config-file} (default: @code{(postgresql-config-file)})
  17416. The configuration file to use when running PostgreSQL@. The default
  17417. behaviour uses the postgresql-config-file record with the default values
  17418. for the fields.
  17419. @item @code{log-directory} (default: @code{"/var/log/postgresql"})
  17420. The directory where @command{pg_ctl} output will be written in a file
  17421. named @code{"pg_ctl.log"}. This file can be useful to debug PostgreSQL
  17422. configuration errors for instance.
  17423. @item @code{data-directory} (default: @code{"/var/lib/postgresql/data"})
  17424. Directory in which to store the data.
  17425. @item @code{extension-packages} (default: @code{'()})
  17426. @cindex postgresql extension-packages
  17427. Additional extensions are loaded from packages listed in
  17428. @var{extension-packages}. Extensions are available at runtime. For instance,
  17429. to create a geographic database using the @code{postgis} extension, a user can
  17430. configure the postgresql-service as in this example:
  17431. @cindex postgis
  17432. @lisp
  17433. (use-package-modules databases geo)
  17434. (operating-system
  17435. ...
  17436. ;; postgresql is required to run `psql' but postgis is not required for
  17437. ;; proper operation.
  17438. (packages (cons* postgresql %base-packages))
  17439. (services
  17440. (cons*
  17441. (service postgresql-service-type
  17442. (postgresql-configuration
  17443. (postgresql postgresql-10)
  17444. (extension-packages (list postgis))))
  17445. %base-services)))
  17446. @end lisp
  17447. Then the extension becomes visible and you can initialise an empty geographic
  17448. database in this way:
  17449. @example
  17450. psql -U postgres
  17451. > create database postgistest;
  17452. > \connect postgistest;
  17453. > create extension postgis;
  17454. > create extension postgis_topology;
  17455. @end example
  17456. There is no need to add this field for contrib extensions such as hstore or
  17457. dblink as they are already loadable by postgresql. This field is only
  17458. required to add extensions provided by other packages.
  17459. @end table
  17460. @end deftp
  17461. @deftp {Data Type} postgresql-config-file
  17462. Data type representing the PostgreSQL configuration file. As shown in
  17463. the following example, this can be used to customize the configuration
  17464. of PostgreSQL@. Note that you can use any G-expression or filename in
  17465. place of this record, if you already have a configuration file you'd
  17466. like to use for example.
  17467. @lisp
  17468. (service postgresql-service-type
  17469. (postgresql-configuration
  17470. (config-file
  17471. (postgresql-config-file
  17472. (log-destination "stderr")
  17473. (hba-file
  17474. (plain-file "pg_hba.conf"
  17475. "
  17476. local all all trust
  17477. host all all 127.0.0.1/32 md5
  17478. host all all ::1/128 md5"))
  17479. (extra-config
  17480. '(("session_preload_libraries" "auto_explain")
  17481. ("random_page_cost" 2)
  17482. ("auto_explain.log_min_duration" "100 ms")
  17483. ("work_mem" "500 MB")
  17484. ("logging_collector" #t)
  17485. ("log_directory" "/var/log/postgresql")))))))
  17486. @end lisp
  17487. @table @asis
  17488. @item @code{log-destination} (default: @code{"syslog"})
  17489. The logging method to use for PostgreSQL@. Multiple values are accepted,
  17490. separated by commas.
  17491. @item @code{hba-file} (default: @code{%default-postgres-hba})
  17492. Filename or G-expression for the host-based authentication
  17493. configuration.
  17494. @item @code{ident-file} (default: @code{%default-postgres-ident})
  17495. Filename or G-expression for the user name mapping configuration.
  17496. @item @code{socket-directory} (default: @code{"/var/run/postgresql"})
  17497. Specifies the directory of the Unix-domain socket(s) on which PostgreSQL
  17498. is to listen for connections from client applications. If set to
  17499. @code{""} PostgreSQL does not listen on any Unix-domain sockets, in
  17500. which case only TCP/IP sockets can be used to connect to the server.
  17501. By default, the @code{#false} value means the PostgreSQL default value
  17502. will be used, which is currently @samp{/tmp}.
  17503. @item @code{extra-config} (default: @code{'()})
  17504. List of additional keys and values to include in the PostgreSQL config
  17505. file. Each entry in the list should be a list where the first element
  17506. is the key, and the remaining elements are the values.
  17507. The values can be numbers, booleans or strings and will be mapped to
  17508. PostgreSQL parameters types @code{Boolean}, @code{String},
  17509. @code{Numeric}, @code{Numeric with Unit} and @code{Enumerated} described
  17510. @uref{https://www.postgresql.org/docs/current/config-setting.html,
  17511. here}.
  17512. @end table
  17513. @end deftp
  17514. @deffn {Scheme Variable} postgresql-role-service-type
  17515. This service allows to create PostgreSQL roles and databases after
  17516. PostgreSQL service start. Here is an example of its use.
  17517. @lisp
  17518. (service postgresql-role-service-type
  17519. (postgresql-role-configuration
  17520. (roles
  17521. (list (postgresql-role
  17522. (name "test")
  17523. (create-database? #t))))))
  17524. @end lisp
  17525. This service can be extended with extra roles, as in this
  17526. example:
  17527. @lisp
  17528. (service-extension postgresql-role-service-type
  17529. (const (postgresql-role
  17530. (name "alice")
  17531. (create-database? #t))))
  17532. @end lisp
  17533. @end deffn
  17534. @deftp {Data Type} postgresql-role
  17535. PostgreSQL manages database access permissions using the concept of
  17536. roles. A role can be thought of as either a database user, or a group
  17537. of database users, depending on how the role is set up. Roles can own
  17538. database objects (for example, tables) and can assign privileges on
  17539. those objects to other roles to control who has access to which objects.
  17540. @table @asis
  17541. @item @code{name}
  17542. The role name.
  17543. @item @code{permissions} (default: @code{'(createdb login)})
  17544. The role permissions list. Supported permissions are @code{bypassrls},
  17545. @code{createdb}, @code{createrole}, @code{login}, @code{replication} and
  17546. @code{superuser}.
  17547. @item @code{create-database?} (default: @code{#f})
  17548. Whether to create a database with the same name as the role.
  17549. @end table
  17550. @end deftp
  17551. @deftp {Data Type} postgresql-role-configuration
  17552. Data type representing the configuration of
  17553. @var{postgresql-role-service-type}.
  17554. @table @asis
  17555. @item @code{host} (default: @code{"/var/run/postgresql"})
  17556. The PostgreSQL host to connect to.
  17557. @item @code{log} (default: @code{"/var/log/postgresql_roles.log"})
  17558. File name of the log file.
  17559. @item @code{roles} (default: @code{'()})
  17560. The initial PostgreSQL roles to create.
  17561. @end table
  17562. @end deftp
  17563. @subsubheading MariaDB/MySQL
  17564. @defvr {Scheme Variable} mysql-service-type
  17565. This is the service type for a MySQL or MariaDB database server. Its value
  17566. is a @code{mysql-configuration} object that specifies which package to use,
  17567. as well as various settings for the @command{mysqld} daemon.
  17568. @end defvr
  17569. @deftp {Data Type} mysql-configuration
  17570. Data type representing the configuration of @var{mysql-service-type}.
  17571. @table @asis
  17572. @item @code{mysql} (default: @var{mariadb})
  17573. Package object of the MySQL database server, can be either @var{mariadb}
  17574. or @var{mysql}.
  17575. For MySQL, a temporary root password will be displayed at activation time.
  17576. For MariaDB, the root password is empty.
  17577. @item @code{bind-address} (default: @code{"127.0.0.1"})
  17578. The IP on which to listen for network connections. Use @code{"0.0.0.0"}
  17579. to bind to all available network interfaces.
  17580. @item @code{port} (default: @code{3306})
  17581. TCP port on which the database server listens for incoming connections.
  17582. @item @code{socket} (default: @code{"/run/mysqld/mysqld.sock"})
  17583. Socket file to use for local (non-network) connections.
  17584. @item @code{extra-content} (default: @code{""})
  17585. Additional settings for the @file{my.cnf} configuration file.
  17586. @item @code{extra-environment} (default: @code{#~'()})
  17587. List of environment variables passed to the @command{mysqld} process.
  17588. @item @code{auto-upgrade?} (default: @code{#t})
  17589. Whether to automatically run @command{mysql_upgrade} after starting the
  17590. service. This is necessary to upgrade the @dfn{system schema} after
  17591. ``major'' updates (such as switching from MariaDB 10.4 to 10.5), but can
  17592. be disabled if you would rather do that manually.
  17593. @end table
  17594. @end deftp
  17595. @subsubheading Memcached
  17596. @defvr {Scheme Variable} memcached-service-type
  17597. This is the service type for the @uref{https://memcached.org/,
  17598. Memcached} service, which provides a distributed in memory cache. The
  17599. value for the service type is a @code{memcached-configuration} object.
  17600. @end defvr
  17601. @lisp
  17602. (service memcached-service-type)
  17603. @end lisp
  17604. @deftp {Data Type} memcached-configuration
  17605. Data type representing the configuration of memcached.
  17606. @table @asis
  17607. @item @code{memcached} (default: @code{memcached})
  17608. The Memcached package to use.
  17609. @item @code{interfaces} (default: @code{'("0.0.0.0")})
  17610. Network interfaces on which to listen.
  17611. @item @code{tcp-port} (default: @code{11211})
  17612. Port on which to accept connections.
  17613. @item @code{udp-port} (default: @code{11211})
  17614. Port on which to accept UDP connections on, a value of 0 will disable
  17615. listening on a UDP socket.
  17616. @item @code{additional-options} (default: @code{'()})
  17617. Additional command line options to pass to @code{memcached}.
  17618. @end table
  17619. @end deftp
  17620. @subsubheading Redis
  17621. @defvr {Scheme Variable} redis-service-type
  17622. This is the service type for the @uref{https://redis.io/, Redis}
  17623. key/value store, whose value is a @code{redis-configuration} object.
  17624. @end defvr
  17625. @deftp {Data Type} redis-configuration
  17626. Data type representing the configuration of redis.
  17627. @table @asis
  17628. @item @code{redis} (default: @code{redis})
  17629. The Redis package to use.
  17630. @item @code{bind} (default: @code{"127.0.0.1"})
  17631. Network interface on which to listen.
  17632. @item @code{port} (default: @code{6379})
  17633. Port on which to accept connections on, a value of 0 will disable
  17634. listening on a TCP socket.
  17635. @item @code{working-directory} (default: @code{"/var/lib/redis"})
  17636. Directory in which to store the database and related files.
  17637. @end table
  17638. @end deftp
  17639. @node Mail Services
  17640. @subsection Mail Services
  17641. @cindex mail
  17642. @cindex email
  17643. The @code{(gnu services mail)} module provides Guix service definitions
  17644. for email services: IMAP, POP3, and LMTP servers, as well as mail
  17645. transport agents (MTAs). Lots of acronyms! These services are detailed
  17646. in the subsections below.
  17647. @subsubheading Dovecot Service
  17648. @deffn {Scheme Procedure} dovecot-service [#:config (dovecot-configuration)]
  17649. Return a service that runs the Dovecot IMAP/POP3/LMTP mail server.
  17650. @end deffn
  17651. By default, Dovecot does not need much configuration; the default
  17652. configuration object created by @code{(dovecot-configuration)} will
  17653. suffice if your mail is delivered to @code{~/Maildir}. A self-signed
  17654. certificate will be generated for TLS-protected connections, though
  17655. Dovecot will also listen on cleartext ports by default. There are a
  17656. number of options, though, which mail administrators might need to change,
  17657. and as is the case with other services, Guix allows the system
  17658. administrator to specify these parameters via a uniform Scheme interface.
  17659. For example, to specify that mail is located at @code{maildir~/.mail},
  17660. one would instantiate the Dovecot service like this:
  17661. @lisp
  17662. (dovecot-service #:config
  17663. (dovecot-configuration
  17664. (mail-location "maildir:~/.mail")))
  17665. @end lisp
  17666. The available configuration parameters follow. Each parameter
  17667. definition is preceded by its type; for example, @samp{string-list foo}
  17668. indicates that the @code{foo} parameter should be specified as a list of
  17669. strings. There is also a way to specify the configuration as a string,
  17670. if you have an old @code{dovecot.conf} file that you want to port over
  17671. from some other system; see the end for more details.
  17672. @c The following documentation was initially generated by
  17673. @c (generate-documentation) in (gnu services mail). Manually maintained
  17674. @c documentation is better, so we shouldn't hesitate to edit below as
  17675. @c needed. However if the change you want to make to this documentation
  17676. @c can be done in an automated way, it's probably easier to change
  17677. @c (generate-documentation) than to make it below and have to deal with
  17678. @c the churn as dovecot updates.
  17679. Available @code{dovecot-configuration} fields are:
  17680. @deftypevr {@code{dovecot-configuration} parameter} package dovecot
  17681. The dovecot package.
  17682. @end deftypevr
  17683. @deftypevr {@code{dovecot-configuration} parameter} comma-separated-string-list listen
  17684. A list of IPs or hosts where to listen for connections. @samp{*}
  17685. listens on all IPv4 interfaces, @samp{::} listens on all IPv6
  17686. interfaces. If you want to specify non-default ports or anything more
  17687. complex, customize the address and port fields of the
  17688. @samp{inet-listener} of the specific services you are interested in.
  17689. @end deftypevr
  17690. @deftypevr {@code{dovecot-configuration} parameter} protocol-configuration-list protocols
  17691. List of protocols we want to serve. Available protocols include
  17692. @samp{imap}, @samp{pop3}, and @samp{lmtp}.
  17693. Available @code{protocol-configuration} fields are:
  17694. @deftypevr {@code{protocol-configuration} parameter} string name
  17695. The name of the protocol.
  17696. @end deftypevr
  17697. @deftypevr {@code{protocol-configuration} parameter} string auth-socket-path
  17698. UNIX socket path to the master authentication server to find users.
  17699. This is used by imap (for shared users) and lda.
  17700. It defaults to @samp{"/var/run/dovecot/auth-userdb"}.
  17701. @end deftypevr
  17702. @deftypevr {@code{protocol-configuration} parameter} boolean imap-metadata?
  17703. Whether to enable the @code{IMAP METADATA} extension as defined in
  17704. @uref{https://tools.ietf.org/html/rfc5464,RFC@tie{}5464}, which provides
  17705. a means for clients to set and retrieve per-mailbox, per-user metadata
  17706. and annotations over IMAP.
  17707. If this is @samp{#t}, you must also specify a dictionary @i{via} the
  17708. @code{mail-attribute-dict} setting.
  17709. Defaults to @samp{#f}.
  17710. @end deftypevr
  17711. @deftypevr {@code{protocol-configuration} parameter} space-separated-string-list managesieve-notify-capabilities
  17712. Which NOTIFY capabilities to report to clients that first connect to
  17713. the ManageSieve service, before authentication. These may differ from the
  17714. capabilities offered to authenticated users. If this field is left empty,
  17715. report what the Sieve interpreter supports by default.
  17716. Defaults to @samp{()}.
  17717. @end deftypevr
  17718. @deftypevr {@code{protocol-configuration} parameter} space-separated-string-list managesieve-sieve-capability
  17719. Which SIEVE capabilities to report to clients that first connect to
  17720. the ManageSieve service, before authentication. These may differ from the
  17721. capabilities offered to authenticated users. If this field is left empty,
  17722. report what the Sieve interpreter supports by default.
  17723. Defaults to @samp{()}.
  17724. @end deftypevr
  17725. @deftypevr {@code{protocol-configuration} parameter} space-separated-string-list mail-plugins
  17726. Space separated list of plugins to load.
  17727. @end deftypevr
  17728. @deftypevr {@code{protocol-configuration} parameter} non-negative-integer mail-max-userip-connections
  17729. Maximum number of IMAP connections allowed for a user from each IP
  17730. address. NOTE: The username is compared case-sensitively.
  17731. Defaults to @samp{10}.
  17732. @end deftypevr
  17733. @end deftypevr
  17734. @deftypevr {@code{dovecot-configuration} parameter} service-configuration-list services
  17735. List of services to enable. Available services include @samp{imap},
  17736. @samp{imap-login}, @samp{pop3}, @samp{pop3-login}, @samp{auth}, and
  17737. @samp{lmtp}.
  17738. Available @code{service-configuration} fields are:
  17739. @deftypevr {@code{service-configuration} parameter} string kind
  17740. The service kind. Valid values include @code{director},
  17741. @code{imap-login}, @code{pop3-login}, @code{lmtp}, @code{imap},
  17742. @code{pop3}, @code{auth}, @code{auth-worker}, @code{dict},
  17743. @code{tcpwrap}, @code{quota-warning}, or anything else.
  17744. @end deftypevr
  17745. @deftypevr {@code{service-configuration} parameter} listener-configuration-list listeners
  17746. Listeners for the service. A listener is either a
  17747. @code{unix-listener-configuration}, a @code{fifo-listener-configuration}, or
  17748. an @code{inet-listener-configuration}.
  17749. Defaults to @samp{()}.
  17750. Available @code{unix-listener-configuration} fields are:
  17751. @deftypevr {@code{unix-listener-configuration} parameter} string path
  17752. Path to the file, relative to @code{base-dir} field. This is also used as
  17753. the section name.
  17754. @end deftypevr
  17755. @deftypevr {@code{unix-listener-configuration} parameter} string mode
  17756. The access mode for the socket.
  17757. Defaults to @samp{"0600"}.
  17758. @end deftypevr
  17759. @deftypevr {@code{unix-listener-configuration} parameter} string user
  17760. The user to own the socket.
  17761. Defaults to @samp{""}.
  17762. @end deftypevr
  17763. @deftypevr {@code{unix-listener-configuration} parameter} string group
  17764. The group to own the socket.
  17765. Defaults to @samp{""}.
  17766. @end deftypevr
  17767. Available @code{fifo-listener-configuration} fields are:
  17768. @deftypevr {@code{fifo-listener-configuration} parameter} string path
  17769. Path to the file, relative to @code{base-dir} field. This is also used as
  17770. the section name.
  17771. @end deftypevr
  17772. @deftypevr {@code{fifo-listener-configuration} parameter} string mode
  17773. The access mode for the socket.
  17774. Defaults to @samp{"0600"}.
  17775. @end deftypevr
  17776. @deftypevr {@code{fifo-listener-configuration} parameter} string user
  17777. The user to own the socket.
  17778. Defaults to @samp{""}.
  17779. @end deftypevr
  17780. @deftypevr {@code{fifo-listener-configuration} parameter} string group
  17781. The group to own the socket.
  17782. Defaults to @samp{""}.
  17783. @end deftypevr
  17784. Available @code{inet-listener-configuration} fields are:
  17785. @deftypevr {@code{inet-listener-configuration} parameter} string protocol
  17786. The protocol to listen for.
  17787. @end deftypevr
  17788. @deftypevr {@code{inet-listener-configuration} parameter} string address
  17789. The address on which to listen, or empty for all addresses.
  17790. Defaults to @samp{""}.
  17791. @end deftypevr
  17792. @deftypevr {@code{inet-listener-configuration} parameter} non-negative-integer port
  17793. The port on which to listen.
  17794. @end deftypevr
  17795. @deftypevr {@code{inet-listener-configuration} parameter} boolean ssl?
  17796. Whether to use SSL for this service; @samp{yes}, @samp{no}, or
  17797. @samp{required}.
  17798. Defaults to @samp{#t}.
  17799. @end deftypevr
  17800. @end deftypevr
  17801. @deftypevr {@code{service-configuration} parameter} non-negative-integer client-limit
  17802. Maximum number of simultaneous client connections per process. Once
  17803. this number of connections is received, the next incoming connection
  17804. will prompt Dovecot to spawn another process. If set to 0,
  17805. @code{default-client-limit} is used instead.
  17806. Defaults to @samp{0}.
  17807. @end deftypevr
  17808. @deftypevr {@code{service-configuration} parameter} non-negative-integer service-count
  17809. Number of connections to handle before starting a new process.
  17810. Typically the only useful values are 0 (unlimited) or 1. 1 is more
  17811. secure, but 0 is faster. <doc/wiki/LoginProcess.txt>.
  17812. Defaults to @samp{1}.
  17813. @end deftypevr
  17814. @deftypevr {@code{service-configuration} parameter} non-negative-integer process-limit
  17815. Maximum number of processes that can exist for this service. If set to
  17816. 0, @code{default-process-limit} is used instead.
  17817. Defaults to @samp{0}.
  17818. @end deftypevr
  17819. @deftypevr {@code{service-configuration} parameter} non-negative-integer process-min-avail
  17820. Number of processes to always keep waiting for more connections.
  17821. Defaults to @samp{0}.
  17822. @end deftypevr
  17823. @deftypevr {@code{service-configuration} parameter} non-negative-integer vsz-limit
  17824. If you set @samp{service-count 0}, you probably need to grow
  17825. this.
  17826. Defaults to @samp{256000000}.
  17827. @end deftypevr
  17828. @end deftypevr
  17829. @deftypevr {@code{dovecot-configuration} parameter} dict-configuration dict
  17830. Dict configuration, as created by the @code{dict-configuration}
  17831. constructor.
  17832. Available @code{dict-configuration} fields are:
  17833. @deftypevr {@code{dict-configuration} parameter} free-form-fields entries
  17834. A list of key-value pairs that this dict should hold.
  17835. Defaults to @samp{()}.
  17836. @end deftypevr
  17837. @end deftypevr
  17838. @deftypevr {@code{dovecot-configuration} parameter} passdb-configuration-list passdbs
  17839. A list of passdb configurations, each one created by the
  17840. @code{passdb-configuration} constructor.
  17841. Available @code{passdb-configuration} fields are:
  17842. @deftypevr {@code{passdb-configuration} parameter} string driver
  17843. The driver that the passdb should use. Valid values include
  17844. @samp{pam}, @samp{passwd}, @samp{shadow}, @samp{bsdauth}, and
  17845. @samp{static}.
  17846. Defaults to @samp{"pam"}.
  17847. @end deftypevr
  17848. @deftypevr {@code{passdb-configuration} parameter} space-separated-string-list args
  17849. Space separated list of arguments to the passdb driver.
  17850. Defaults to @samp{""}.
  17851. @end deftypevr
  17852. @end deftypevr
  17853. @deftypevr {@code{dovecot-configuration} parameter} userdb-configuration-list userdbs
  17854. List of userdb configurations, each one created by the
  17855. @code{userdb-configuration} constructor.
  17856. Available @code{userdb-configuration} fields are:
  17857. @deftypevr {@code{userdb-configuration} parameter} string driver
  17858. The driver that the userdb should use. Valid values include
  17859. @samp{passwd} and @samp{static}.
  17860. Defaults to @samp{"passwd"}.
  17861. @end deftypevr
  17862. @deftypevr {@code{userdb-configuration} parameter} space-separated-string-list args
  17863. Space separated list of arguments to the userdb driver.
  17864. Defaults to @samp{""}.
  17865. @end deftypevr
  17866. @deftypevr {@code{userdb-configuration} parameter} free-form-args override-fields
  17867. Override fields from passwd.
  17868. Defaults to @samp{()}.
  17869. @end deftypevr
  17870. @end deftypevr
  17871. @deftypevr {@code{dovecot-configuration} parameter} plugin-configuration plugin-configuration
  17872. Plug-in configuration, created by the @code{plugin-configuration}
  17873. constructor.
  17874. @end deftypevr
  17875. @deftypevr {@code{dovecot-configuration} parameter} list-of-namespace-configuration namespaces
  17876. List of namespaces. Each item in the list is created by the
  17877. @code{namespace-configuration} constructor.
  17878. Available @code{namespace-configuration} fields are:
  17879. @deftypevr {@code{namespace-configuration} parameter} string name
  17880. Name for this namespace.
  17881. @end deftypevr
  17882. @deftypevr {@code{namespace-configuration} parameter} string type
  17883. Namespace type: @samp{private}, @samp{shared} or @samp{public}.
  17884. Defaults to @samp{"private"}.
  17885. @end deftypevr
  17886. @deftypevr {@code{namespace-configuration} parameter} string separator
  17887. Hierarchy separator to use. You should use the same separator for
  17888. all namespaces or some clients get confused. @samp{/} is usually a good
  17889. one. The default however depends on the underlying mail storage
  17890. format.
  17891. Defaults to @samp{""}.
  17892. @end deftypevr
  17893. @deftypevr {@code{namespace-configuration} parameter} string prefix
  17894. Prefix required to access this namespace. This needs to be
  17895. different for all namespaces. For example @samp{Public/}.
  17896. Defaults to @samp{""}.
  17897. @end deftypevr
  17898. @deftypevr {@code{namespace-configuration} parameter} string location
  17899. Physical location of the mailbox. This is in the same format as
  17900. mail_location, which is also the default for it.
  17901. Defaults to @samp{""}.
  17902. @end deftypevr
  17903. @deftypevr {@code{namespace-configuration} parameter} boolean inbox?
  17904. There can be only one INBOX, and this setting defines which
  17905. namespace has it.
  17906. Defaults to @samp{#f}.
  17907. @end deftypevr
  17908. @deftypevr {@code{namespace-configuration} parameter} boolean hidden?
  17909. If namespace is hidden, it's not advertised to clients via NAMESPACE
  17910. extension. You'll most likely also want to set @samp{list? #f}. This is mostly
  17911. useful when converting from another server with different namespaces
  17912. which you want to deprecate but still keep working. For example you can
  17913. create hidden namespaces with prefixes @samp{~/mail/}, @samp{~%u/mail/}
  17914. and @samp{mail/}.
  17915. Defaults to @samp{#f}.
  17916. @end deftypevr
  17917. @deftypevr {@code{namespace-configuration} parameter} boolean list?
  17918. Show the mailboxes under this namespace with the LIST command. This
  17919. makes the namespace visible for clients that do not support the NAMESPACE
  17920. extension. The special @code{children} value lists child mailboxes, but
  17921. hides the namespace prefix.
  17922. Defaults to @samp{#t}.
  17923. @end deftypevr
  17924. @deftypevr {@code{namespace-configuration} parameter} boolean subscriptions?
  17925. Namespace handles its own subscriptions. If set to @code{#f}, the
  17926. parent namespace handles them. The empty prefix should always have this
  17927. as @code{#t}).
  17928. Defaults to @samp{#t}.
  17929. @end deftypevr
  17930. @deftypevr {@code{namespace-configuration} parameter} mailbox-configuration-list mailboxes
  17931. List of predefined mailboxes in this namespace.
  17932. Defaults to @samp{()}.
  17933. Available @code{mailbox-configuration} fields are:
  17934. @deftypevr {@code{mailbox-configuration} parameter} string name
  17935. Name for this mailbox.
  17936. @end deftypevr
  17937. @deftypevr {@code{mailbox-configuration} parameter} string auto
  17938. @samp{create} will automatically create this mailbox.
  17939. @samp{subscribe} will both create and subscribe to the mailbox.
  17940. Defaults to @samp{"no"}.
  17941. @end deftypevr
  17942. @deftypevr {@code{mailbox-configuration} parameter} space-separated-string-list special-use
  17943. List of IMAP @code{SPECIAL-USE} attributes as specified by RFC 6154.
  17944. Valid values are @code{\All}, @code{\Archive}, @code{\Drafts},
  17945. @code{\Flagged}, @code{\Junk}, @code{\Sent}, and @code{\Trash}.
  17946. Defaults to @samp{()}.
  17947. @end deftypevr
  17948. @end deftypevr
  17949. @end deftypevr
  17950. @deftypevr {@code{dovecot-configuration} parameter} file-name base-dir
  17951. Base directory where to store runtime data.
  17952. Defaults to @samp{"/var/run/dovecot/"}.
  17953. @end deftypevr
  17954. @deftypevr {@code{dovecot-configuration} parameter} string login-greeting
  17955. Greeting message for clients.
  17956. Defaults to @samp{"Dovecot ready."}.
  17957. @end deftypevr
  17958. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-trusted-networks
  17959. List of trusted network ranges. Connections from these IPs are
  17960. allowed to override their IP addresses and ports (for logging and for
  17961. authentication checks). @samp{disable-plaintext-auth} is also ignored
  17962. for these networks. Typically you would specify your IMAP proxy servers
  17963. here.
  17964. Defaults to @samp{()}.
  17965. @end deftypevr
  17966. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-access-sockets
  17967. List of login access check sockets (e.g.@: tcpwrap).
  17968. Defaults to @samp{()}.
  17969. @end deftypevr
  17970. @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-proctitle?
  17971. Show more verbose process titles (in ps). Currently shows user name
  17972. and IP address. Useful for seeing who is actually using the IMAP
  17973. processes (e.g.@: shared mailboxes or if the same uid is used for multiple
  17974. accounts).
  17975. Defaults to @samp{#f}.
  17976. @end deftypevr
  17977. @deftypevr {@code{dovecot-configuration} parameter} boolean shutdown-clients?
  17978. Should all processes be killed when Dovecot master process shuts down.
  17979. Setting this to @code{#f} means that Dovecot can be upgraded without
  17980. forcing existing client connections to close (although that could also
  17981. be a problem if the upgrade is e.g.@: due to a security fix).
  17982. Defaults to @samp{#t}.
  17983. @end deftypevr
  17984. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer doveadm-worker-count
  17985. If non-zero, run mail commands via this many connections to doveadm
  17986. server, instead of running them directly in the same process.
  17987. Defaults to @samp{0}.
  17988. @end deftypevr
  17989. @deftypevr {@code{dovecot-configuration} parameter} string doveadm-socket-path
  17990. UNIX socket or host:port used for connecting to doveadm server.
  17991. Defaults to @samp{"doveadm-server"}.
  17992. @end deftypevr
  17993. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list import-environment
  17994. List of environment variables that are preserved on Dovecot startup
  17995. and passed down to all of its child processes. You can also give
  17996. key=value pairs to always set specific settings.
  17997. @end deftypevr
  17998. @deftypevr {@code{dovecot-configuration} parameter} boolean disable-plaintext-auth?
  17999. Disable LOGIN command and all other plaintext authentications unless
  18000. SSL/TLS is used (LOGINDISABLED capability). Note that if the remote IP
  18001. matches the local IP (i.e.@: you're connecting from the same computer),
  18002. the connection is considered secure and plaintext authentication is
  18003. allowed. See also ssl=required setting.
  18004. Defaults to @samp{#t}.
  18005. @end deftypevr
  18006. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-cache-size
  18007. Authentication cache size (e.g.@: @samp{#e10e6}). 0 means it's disabled.
  18008. Note that bsdauth, PAM and vpopmail require @samp{cache-key} to be set
  18009. for caching to be used.
  18010. Defaults to @samp{0}.
  18011. @end deftypevr
  18012. @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-ttl
  18013. Time to live for cached data. After TTL expires the cached record
  18014. is no longer used, *except* if the main database lookup returns internal
  18015. failure. We also try to handle password changes automatically: If
  18016. user's previous authentication was successful, but this one wasn't, the
  18017. cache isn't used. For now this works only with plaintext
  18018. authentication.
  18019. Defaults to @samp{"1 hour"}.
  18020. @end deftypevr
  18021. @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-negative-ttl
  18022. TTL for negative hits (user not found, password mismatch).
  18023. 0 disables caching them completely.
  18024. Defaults to @samp{"1 hour"}.
  18025. @end deftypevr
  18026. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-realms
  18027. List of realms for SASL authentication mechanisms that need them.
  18028. You can leave it empty if you don't want to support multiple realms.
  18029. Many clients simply use the first one listed here, so keep the default
  18030. realm first.
  18031. Defaults to @samp{()}.
  18032. @end deftypevr
  18033. @deftypevr {@code{dovecot-configuration} parameter} string auth-default-realm
  18034. Default realm/domain to use if none was specified. This is used for
  18035. both SASL realms and appending @@domain to username in plaintext
  18036. logins.
  18037. Defaults to @samp{""}.
  18038. @end deftypevr
  18039. @deftypevr {@code{dovecot-configuration} parameter} string auth-username-chars
  18040. List of allowed characters in username. If the user-given username
  18041. contains a character not listed in here, the login automatically fails.
  18042. This is just an extra check to make sure user can't exploit any
  18043. potential quote escaping vulnerabilities with SQL/LDAP databases. If
  18044. you want to allow all characters, set this value to empty.
  18045. Defaults to @samp{"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@@"}.
  18046. @end deftypevr
  18047. @deftypevr {@code{dovecot-configuration} parameter} string auth-username-translation
  18048. Username character translations before it's looked up from
  18049. databases. The value contains series of from -> to characters. For
  18050. example @samp{#@@/@@} means that @samp{#} and @samp{/} characters are
  18051. translated to @samp{@@}.
  18052. Defaults to @samp{""}.
  18053. @end deftypevr
  18054. @deftypevr {@code{dovecot-configuration} parameter} string auth-username-format
  18055. Username formatting before it's looked up from databases. You can
  18056. use the standard variables here, e.g.@: %Lu would lowercase the username,
  18057. %n would drop away the domain if it was given, or @samp{%n-AT-%d} would
  18058. change the @samp{@@} into @samp{-AT-}. This translation is done after
  18059. @samp{auth-username-translation} changes.
  18060. Defaults to @samp{"%Lu"}.
  18061. @end deftypevr
  18062. @deftypevr {@code{dovecot-configuration} parameter} string auth-master-user-separator
  18063. If you want to allow master users to log in by specifying the master
  18064. username within the normal username string (i.e.@: not using SASL
  18065. mechanism's support for it), you can specify the separator character
  18066. here. The format is then <username><separator><master username>.
  18067. UW-IMAP uses @samp{*} as the separator, so that could be a good
  18068. choice.
  18069. Defaults to @samp{""}.
  18070. @end deftypevr
  18071. @deftypevr {@code{dovecot-configuration} parameter} string auth-anonymous-username
  18072. Username to use for users logging in with ANONYMOUS SASL
  18073. mechanism.
  18074. Defaults to @samp{"anonymous"}.
  18075. @end deftypevr
  18076. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-worker-max-count
  18077. Maximum number of dovecot-auth worker processes. They're used to
  18078. execute blocking passdb and userdb queries (e.g.@: MySQL and PAM).
  18079. They're automatically created and destroyed as needed.
  18080. Defaults to @samp{30}.
  18081. @end deftypevr
  18082. @deftypevr {@code{dovecot-configuration} parameter} string auth-gssapi-hostname
  18083. Host name to use in GSSAPI principal names. The default is to use
  18084. the name returned by gethostname(). Use @samp{$ALL} (with quotes) to
  18085. allow all keytab entries.
  18086. Defaults to @samp{""}.
  18087. @end deftypevr
  18088. @deftypevr {@code{dovecot-configuration} parameter} string auth-krb5-keytab
  18089. Kerberos keytab to use for the GSSAPI mechanism. Will use the
  18090. system default (usually @file{/etc/krb5.keytab}) if not specified. You may
  18091. need to change the auth service to run as root to be able to read this
  18092. file.
  18093. Defaults to @samp{""}.
  18094. @end deftypevr
  18095. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-use-winbind?
  18096. Do NTLM and GSS-SPNEGO authentication using Samba's winbind daemon
  18097. and @samp{ntlm-auth} helper.
  18098. <doc/wiki/Authentication/Mechanisms/Winbind.txt>.
  18099. Defaults to @samp{#f}.
  18100. @end deftypevr
  18101. @deftypevr {@code{dovecot-configuration} parameter} file-name auth-winbind-helper-path
  18102. Path for Samba's @samp{ntlm-auth} helper binary.
  18103. Defaults to @samp{"/usr/bin/ntlm_auth"}.
  18104. @end deftypevr
  18105. @deftypevr {@code{dovecot-configuration} parameter} string auth-failure-delay
  18106. Time to delay before replying to failed authentications.
  18107. Defaults to @samp{"2 secs"}.
  18108. @end deftypevr
  18109. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-require-client-cert?
  18110. Require a valid SSL client certificate or the authentication
  18111. fails.
  18112. Defaults to @samp{#f}.
  18113. @end deftypevr
  18114. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-username-from-cert?
  18115. Take the username from client's SSL certificate, using
  18116. @code{X509_NAME_get_text_by_NID()} which returns the subject's DN's
  18117. CommonName.
  18118. Defaults to @samp{#f}.
  18119. @end deftypevr
  18120. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-mechanisms
  18121. List of wanted authentication mechanisms. Supported mechanisms are:
  18122. @samp{plain}, @samp{login}, @samp{digest-md5}, @samp{cram-md5},
  18123. @samp{ntlm}, @samp{rpa}, @samp{apop}, @samp{anonymous}, @samp{gssapi},
  18124. @samp{otp}, @samp{skey}, and @samp{gss-spnego}. NOTE: See also
  18125. @samp{disable-plaintext-auth} setting.
  18126. @end deftypevr
  18127. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-servers
  18128. List of IPs or hostnames to all director servers, including ourself.
  18129. Ports can be specified as ip:port. The default port is the same as what
  18130. director service's @samp{inet-listener} is using.
  18131. Defaults to @samp{()}.
  18132. @end deftypevr
  18133. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-mail-servers
  18134. List of IPs or hostnames to all backend mail servers. Ranges are
  18135. allowed too, like 10.0.0.10-10.0.0.30.
  18136. Defaults to @samp{()}.
  18137. @end deftypevr
  18138. @deftypevr {@code{dovecot-configuration} parameter} string director-user-expire
  18139. How long to redirect users to a specific server after it no longer
  18140. has any connections.
  18141. Defaults to @samp{"15 min"}.
  18142. @end deftypevr
  18143. @deftypevr {@code{dovecot-configuration} parameter} string director-username-hash
  18144. How the username is translated before being hashed. Useful values
  18145. include %Ln if user can log in with or without @@domain, %Ld if mailboxes
  18146. are shared within domain.
  18147. Defaults to @samp{"%Lu"}.
  18148. @end deftypevr
  18149. @deftypevr {@code{dovecot-configuration} parameter} string log-path
  18150. Log file to use for error messages. @samp{syslog} logs to syslog,
  18151. @samp{/dev/stderr} logs to stderr.
  18152. Defaults to @samp{"syslog"}.
  18153. @end deftypevr
  18154. @deftypevr {@code{dovecot-configuration} parameter} string info-log-path
  18155. Log file to use for informational messages. Defaults to
  18156. @samp{log-path}.
  18157. Defaults to @samp{""}.
  18158. @end deftypevr
  18159. @deftypevr {@code{dovecot-configuration} parameter} string debug-log-path
  18160. Log file to use for debug messages. Defaults to
  18161. @samp{info-log-path}.
  18162. Defaults to @samp{""}.
  18163. @end deftypevr
  18164. @deftypevr {@code{dovecot-configuration} parameter} string syslog-facility
  18165. Syslog facility to use if you're logging to syslog. Usually if you
  18166. don't want to use @samp{mail}, you'll use local0..local7. Also other
  18167. standard facilities are supported.
  18168. Defaults to @samp{"mail"}.
  18169. @end deftypevr
  18170. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-verbose?
  18171. Log unsuccessful authentication attempts and the reasons why they
  18172. failed.
  18173. Defaults to @samp{#f}.
  18174. @end deftypevr
  18175. @deftypevr {@code{dovecot-configuration} parameter} string auth-verbose-passwords
  18176. In case of password mismatches, log the attempted password. Valid
  18177. values are no, plain and sha1. sha1 can be useful for detecting brute
  18178. force password attempts vs. user simply trying the same password over
  18179. and over again. You can also truncate the value to n chars by appending
  18180. ":n" (e.g.@: sha1:6).
  18181. Defaults to @samp{"no"}.
  18182. @end deftypevr
  18183. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug?
  18184. Even more verbose logging for debugging purposes. Shows for example
  18185. SQL queries.
  18186. Defaults to @samp{#f}.
  18187. @end deftypevr
  18188. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug-passwords?
  18189. In case of password mismatches, log the passwords and used scheme so
  18190. the problem can be debugged. Enabling this also enables
  18191. @samp{auth-debug}.
  18192. Defaults to @samp{#f}.
  18193. @end deftypevr
  18194. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-debug?
  18195. Enable mail process debugging. This can help you figure out why
  18196. Dovecot isn't finding your mails.
  18197. Defaults to @samp{#f}.
  18198. @end deftypevr
  18199. @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-ssl?
  18200. Show protocol level SSL errors.
  18201. Defaults to @samp{#f}.
  18202. @end deftypevr
  18203. @deftypevr {@code{dovecot-configuration} parameter} string log-timestamp
  18204. Prefix for each line written to log file. % codes are in
  18205. strftime(3) format.
  18206. Defaults to @samp{"\"%b %d %H:%M:%S \""}.
  18207. @end deftypevr
  18208. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-log-format-elements
  18209. List of elements we want to log. The elements which have a
  18210. non-empty variable value are joined together to form a comma-separated
  18211. string.
  18212. @end deftypevr
  18213. @deftypevr {@code{dovecot-configuration} parameter} string login-log-format
  18214. Login log format. %s contains @samp{login-log-format-elements}
  18215. string, %$ contains the data we want to log.
  18216. Defaults to @samp{"%$: %s"}.
  18217. @end deftypevr
  18218. @deftypevr {@code{dovecot-configuration} parameter} string mail-log-prefix
  18219. Log prefix for mail processes. See doc/wiki/Variables.txt for list
  18220. of possible variables you can use.
  18221. Defaults to @samp{"\"%s(%u)<%@{pid@}><%@{session@}>: \""}.
  18222. @end deftypevr
  18223. @deftypevr {@code{dovecot-configuration} parameter} string deliver-log-format
  18224. Format to use for logging mail deliveries. You can use variables:
  18225. @table @code
  18226. @item %$
  18227. Delivery status message (e.g.@: @samp{saved to INBOX})
  18228. @item %m
  18229. Message-ID
  18230. @item %s
  18231. Subject
  18232. @item %f
  18233. From address
  18234. @item %p
  18235. Physical size
  18236. @item %w
  18237. Virtual size.
  18238. @end table
  18239. Defaults to @samp{"msgid=%m: %$"}.
  18240. @end deftypevr
  18241. @deftypevr {@code{dovecot-configuration} parameter} string mail-location
  18242. Location for users' mailboxes. The default is empty, which means
  18243. that Dovecot tries to find the mailboxes automatically. This won't work
  18244. if the user doesn't yet have any mail, so you should explicitly tell
  18245. Dovecot the full location.
  18246. If you're using mbox, giving a path to the INBOX
  18247. file (e.g.@: @file{/var/mail/%u}) isn't enough. You'll also need to tell Dovecot
  18248. where the other mailboxes are kept. This is called the @emph{root mail
  18249. directory}, and it must be the first path given in the
  18250. @samp{mail-location} setting.
  18251. There are a few special variables you can use, e.g.:
  18252. @table @samp
  18253. @item %u
  18254. username
  18255. @item %n
  18256. user part in user@@domain, same as %u if there's no domain
  18257. @item %d
  18258. domain part in user@@domain, empty if there's no domain
  18259. @item %h
  18260. home director
  18261. @end table
  18262. See doc/wiki/Variables.txt for full list. Some examples:
  18263. @table @samp
  18264. @item maildir:~/Maildir
  18265. @item mbox:~/mail:INBOX=/var/mail/%u
  18266. @item mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/%
  18267. @end table
  18268. Defaults to @samp{""}.
  18269. @end deftypevr
  18270. @deftypevr {@code{dovecot-configuration} parameter} string mail-uid
  18271. System user and group used to access mails. If you use multiple,
  18272. userdb can override these by returning uid or gid fields. You can use
  18273. either numbers or names. <doc/wiki/UserIds.txt>.
  18274. Defaults to @samp{""}.
  18275. @end deftypevr
  18276. @deftypevr {@code{dovecot-configuration} parameter} string mail-gid
  18277. Defaults to @samp{""}.
  18278. @end deftypevr
  18279. @deftypevr {@code{dovecot-configuration} parameter} string mail-privileged-group
  18280. Group to enable temporarily for privileged operations. Currently
  18281. this is used only with INBOX when either its initial creation or
  18282. dotlocking fails. Typically this is set to @samp{"mail"} to give access to
  18283. @file{/var/mail}.
  18284. Defaults to @samp{""}.
  18285. @end deftypevr
  18286. @deftypevr {@code{dovecot-configuration} parameter} string mail-access-groups
  18287. Grant access to these supplementary groups for mail processes.
  18288. Typically these are used to set up access to shared mailboxes. Note
  18289. that it may be dangerous to set these if users can create symlinks
  18290. (e.g.@: if @samp{mail} group is set here, @code{ln -s /var/mail ~/mail/var}
  18291. could allow a user to delete others' mailboxes, or @code{ln -s
  18292. /secret/shared/box ~/mail/mybox} would allow reading it). Defaults to
  18293. @samp{""}.
  18294. @end deftypevr
  18295. @deftypevr {@code{dovecot-configuration} parameter} string mail-attribute-dict
  18296. The location of a dictionary used to store @code{IMAP METADATA}
  18297. as defined by @uref{https://tools.ietf.org/html/rfc5464, RFC@tie{}5464}.
  18298. The IMAP METADATA commands are available only if the ``imap''
  18299. protocol configuration's @code{imap-metadata?} field is @samp{#t}.
  18300. Defaults to @samp{""}.
  18301. @end deftypevr
  18302. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-full-filesystem-access?
  18303. Allow full file system access to clients. There's no access checks
  18304. other than what the operating system does for the active UID/GID@. It
  18305. works with both maildir and mboxes, allowing you to prefix mailboxes
  18306. names with e.g.@: @file{/path/} or @file{~user/}.
  18307. Defaults to @samp{#f}.
  18308. @end deftypevr
  18309. @deftypevr {@code{dovecot-configuration} parameter} boolean mmap-disable?
  18310. Don't use @code{mmap()} at all. This is required if you store indexes to
  18311. shared file systems (NFS or clustered file system).
  18312. Defaults to @samp{#f}.
  18313. @end deftypevr
  18314. @deftypevr {@code{dovecot-configuration} parameter} boolean dotlock-use-excl?
  18315. Rely on @samp{O_EXCL} to work when creating dotlock files. NFS
  18316. supports @samp{O_EXCL} since version 3, so this should be safe to use
  18317. nowadays by default.
  18318. Defaults to @samp{#t}.
  18319. @end deftypevr
  18320. @deftypevr {@code{dovecot-configuration} parameter} string mail-fsync
  18321. When to use fsync() or fdatasync() calls:
  18322. @table @code
  18323. @item optimized
  18324. Whenever necessary to avoid losing important data
  18325. @item always
  18326. Useful with e.g.@: NFS when @code{write()}s are delayed
  18327. @item never
  18328. Never use it (best performance, but crashes can lose data).
  18329. @end table
  18330. Defaults to @samp{"optimized"}.
  18331. @end deftypevr
  18332. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-storage?
  18333. Mail storage exists in NFS@. Set this to yes to make Dovecot flush
  18334. NFS caches whenever needed. If you're using only a single mail server
  18335. this isn't needed.
  18336. Defaults to @samp{#f}.
  18337. @end deftypevr
  18338. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-index?
  18339. Mail index files also exist in NFS@. Setting this to yes requires
  18340. @samp{mmap-disable? #t} and @samp{fsync-disable? #f}.
  18341. Defaults to @samp{#f}.
  18342. @end deftypevr
  18343. @deftypevr {@code{dovecot-configuration} parameter} string lock-method
  18344. Locking method for index files. Alternatives are fcntl, flock and
  18345. dotlock. Dotlocking uses some tricks which may create more disk I/O
  18346. than other locking methods. NFS users: flock doesn't work, remember to
  18347. change @samp{mmap-disable}.
  18348. Defaults to @samp{"fcntl"}.
  18349. @end deftypevr
  18350. @deftypevr {@code{dovecot-configuration} parameter} file-name mail-temp-dir
  18351. Directory in which LDA/LMTP temporarily stores incoming mails >128
  18352. kB.
  18353. Defaults to @samp{"/tmp"}.
  18354. @end deftypevr
  18355. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-uid
  18356. Valid UID range for users. This is mostly to make sure that users can't
  18357. log in as daemons or other system users. Note that denying root logins is
  18358. hardcoded to dovecot binary and can't be done even if @samp{first-valid-uid}
  18359. is set to 0.
  18360. Defaults to @samp{500}.
  18361. @end deftypevr
  18362. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-uid
  18363. Defaults to @samp{0}.
  18364. @end deftypevr
  18365. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-gid
  18366. Valid GID range for users. Users having non-valid GID as primary group ID
  18367. aren't allowed to log in. If user belongs to supplementary groups with
  18368. non-valid GIDs, those groups are not set.
  18369. Defaults to @samp{1}.
  18370. @end deftypevr
  18371. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-gid
  18372. Defaults to @samp{0}.
  18373. @end deftypevr
  18374. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-max-keyword-length
  18375. Maximum allowed length for mail keyword name. It's only forced when
  18376. trying to create new keywords.
  18377. Defaults to @samp{50}.
  18378. @end deftypevr
  18379. @deftypevr {@code{dovecot-configuration} parameter} colon-separated-file-name-list valid-chroot-dirs
  18380. List of directories under which chrooting is allowed for mail
  18381. processes (i.e.@: @file{/var/mail} will allow chrooting to @file{/var/mail/foo/bar}
  18382. too). This setting doesn't affect @samp{login-chroot}
  18383. @samp{mail-chroot} or auth chroot settings. If this setting is empty,
  18384. @samp{/./} in home dirs are ignored. WARNING: Never add directories here
  18385. which local users can modify, that may lead to root exploit. Usually
  18386. this should be done only if you don't allow shell access for users.
  18387. <doc/wiki/Chrooting.txt>.
  18388. Defaults to @samp{()}.
  18389. @end deftypevr
  18390. @deftypevr {@code{dovecot-configuration} parameter} string mail-chroot
  18391. Default chroot directory for mail processes. This can be overridden
  18392. for specific users in user database by giving @samp{/./} in user's home
  18393. directory (e.g.@: @samp{/home/./user} chroots into @file{/home}). Note that usually
  18394. there is no real need to do chrooting, Dovecot doesn't allow users to
  18395. access files outside their mail directory anyway. If your home
  18396. directories are prefixed with the chroot directory, append @samp{/.} to
  18397. @samp{mail-chroot}. <doc/wiki/Chrooting.txt>.
  18398. Defaults to @samp{""}.
  18399. @end deftypevr
  18400. @deftypevr {@code{dovecot-configuration} parameter} file-name auth-socket-path
  18401. UNIX socket path to master authentication server to find users.
  18402. This is used by imap (for shared users) and lda.
  18403. Defaults to @samp{"/var/run/dovecot/auth-userdb"}.
  18404. @end deftypevr
  18405. @deftypevr {@code{dovecot-configuration} parameter} file-name mail-plugin-dir
  18406. Directory where to look up mail plugins.
  18407. Defaults to @samp{"/usr/lib/dovecot"}.
  18408. @end deftypevr
  18409. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mail-plugins
  18410. List of plugins to load for all services. Plugins specific to IMAP,
  18411. LDA, etc.@: are added to this list in their own .conf files.
  18412. Defaults to @samp{()}.
  18413. @end deftypevr
  18414. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-cache-min-mail-count
  18415. The minimum number of mails in a mailbox before updates are done to
  18416. cache file. This allows optimizing Dovecot's behavior to do less disk
  18417. writes at the cost of more disk reads.
  18418. Defaults to @samp{0}.
  18419. @end deftypevr
  18420. @deftypevr {@code{dovecot-configuration} parameter} string mailbox-idle-check-interval
  18421. When IDLE command is running, mailbox is checked once in a while to
  18422. see if there are any new mails or other changes. This setting defines
  18423. the minimum time to wait between those checks. Dovecot can also use
  18424. dnotify, inotify and kqueue to find out immediately when changes
  18425. occur.
  18426. Defaults to @samp{"30 secs"}.
  18427. @end deftypevr
  18428. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-save-crlf?
  18429. Save mails with CR+LF instead of plain LF@. This makes sending those
  18430. mails take less CPU, especially with sendfile() syscall with Linux and
  18431. FreeBSD@. But it also creates a bit more disk I/O which may just make it
  18432. slower. Also note that if other software reads the mboxes/maildirs,
  18433. they may handle the extra CRs wrong and cause problems.
  18434. Defaults to @samp{#f}.
  18435. @end deftypevr
  18436. @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-stat-dirs?
  18437. By default LIST command returns all entries in maildir beginning
  18438. with a dot. Enabling this option makes Dovecot return only entries
  18439. which are directories. This is done by stat()ing each entry, so it
  18440. causes more disk I/O.
  18441. (For systems setting struct @samp{dirent->d_type} this check is free
  18442. and it's done always regardless of this setting).
  18443. Defaults to @samp{#f}.
  18444. @end deftypevr
  18445. @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-copy-with-hardlinks?
  18446. When copying a message, do it with hard links whenever possible.
  18447. This makes the performance much better, and it's unlikely to have any
  18448. side effects.
  18449. Defaults to @samp{#t}.
  18450. @end deftypevr
  18451. @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-very-dirty-syncs?
  18452. Assume Dovecot is the only MUA accessing Maildir: Scan cur/
  18453. directory only when its mtime changes unexpectedly or when we can't find
  18454. the mail otherwise.
  18455. Defaults to @samp{#f}.
  18456. @end deftypevr
  18457. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-read-locks
  18458. Which locking methods to use for locking mbox. There are four
  18459. available:
  18460. @table @code
  18461. @item dotlock
  18462. Create <mailbox>.lock file. This is the oldest and most NFS-safe
  18463. solution. If you want to use /var/mail/ like directory, the users will
  18464. need write access to that directory.
  18465. @item dotlock-try
  18466. Same as dotlock, but if it fails because of permissions or because there
  18467. isn't enough disk space, just skip it.
  18468. @item fcntl
  18469. Use this if possible. Works with NFS too if lockd is used.
  18470. @item flock
  18471. May not exist in all systems. Doesn't work with NFS.
  18472. @item lockf
  18473. May not exist in all systems. Doesn't work with NFS.
  18474. @end table
  18475. You can use multiple locking methods; if you do the order they're declared
  18476. in is important to avoid deadlocks if other MTAs/MUAs are using multiple
  18477. locking methods as well. Some operating systems don't allow using some of
  18478. them simultaneously.
  18479. @end deftypevr
  18480. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-write-locks
  18481. @end deftypevr
  18482. @deftypevr {@code{dovecot-configuration} parameter} string mbox-lock-timeout
  18483. Maximum time to wait for lock (all of them) before aborting.
  18484. Defaults to @samp{"5 mins"}.
  18485. @end deftypevr
  18486. @deftypevr {@code{dovecot-configuration} parameter} string mbox-dotlock-change-timeout
  18487. If dotlock exists but the mailbox isn't modified in any way,
  18488. override the lock file after this much time.
  18489. Defaults to @samp{"2 mins"}.
  18490. @end deftypevr
  18491. @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-dirty-syncs?
  18492. When mbox changes unexpectedly we have to fully read it to find out
  18493. what changed. If the mbox is large this can take a long time. Since
  18494. the change is usually just a newly appended mail, it'd be faster to
  18495. simply read the new mails. If this setting is enabled, Dovecot does
  18496. this but still safely fallbacks to re-reading the whole mbox file
  18497. whenever something in mbox isn't how it's expected to be. The only real
  18498. downside to this setting is that if some other MUA changes message
  18499. flags, Dovecot doesn't notice it immediately. Note that a full sync is
  18500. done with SELECT, EXAMINE, EXPUNGE and CHECK commands.
  18501. Defaults to @samp{#t}.
  18502. @end deftypevr
  18503. @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-very-dirty-syncs?
  18504. Like @samp{mbox-dirty-syncs}, but don't do full syncs even with SELECT,
  18505. EXAMINE, EXPUNGE or CHECK commands. If this is set,
  18506. @samp{mbox-dirty-syncs} is ignored.
  18507. Defaults to @samp{#f}.
  18508. @end deftypevr
  18509. @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-lazy-writes?
  18510. Delay writing mbox headers until doing a full write sync (EXPUNGE
  18511. and CHECK commands and when closing the mailbox). This is especially
  18512. useful for POP3 where clients often delete all mails. The downside is
  18513. that our changes aren't immediately visible to other MUAs.
  18514. Defaults to @samp{#t}.
  18515. @end deftypevr
  18516. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mbox-min-index-size
  18517. If mbox size is smaller than this (e.g.@: 100k), don't write index
  18518. files. If an index file already exists it's still read, just not
  18519. updated.
  18520. Defaults to @samp{0}.
  18521. @end deftypevr
  18522. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mdbox-rotate-size
  18523. Maximum dbox file size until it's rotated.
  18524. Defaults to @samp{10000000}.
  18525. @end deftypevr
  18526. @deftypevr {@code{dovecot-configuration} parameter} string mdbox-rotate-interval
  18527. Maximum dbox file age until it's rotated. Typically in days. Day
  18528. begins from midnight, so 1d = today, 2d = yesterday, etc. 0 = check
  18529. disabled.
  18530. Defaults to @samp{"1d"}.
  18531. @end deftypevr
  18532. @deftypevr {@code{dovecot-configuration} parameter} boolean mdbox-preallocate-space?
  18533. When creating new mdbox files, immediately preallocate their size to
  18534. @samp{mdbox-rotate-size}. This setting currently works only in Linux
  18535. with some file systems (ext4, xfs).
  18536. Defaults to @samp{#f}.
  18537. @end deftypevr
  18538. @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-dir
  18539. sdbox and mdbox support saving mail attachments to external files,
  18540. which also allows single instance storage for them. Other backends
  18541. don't support this for now.
  18542. WARNING: This feature hasn't been tested much yet. Use at your own risk.
  18543. Directory root where to store mail attachments. Disabled, if empty.
  18544. Defaults to @samp{""}.
  18545. @end deftypevr
  18546. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-attachment-min-size
  18547. Attachments smaller than this aren't saved externally. It's also
  18548. possible to write a plugin to disable saving specific attachments
  18549. externally.
  18550. Defaults to @samp{128000}.
  18551. @end deftypevr
  18552. @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-fs
  18553. File system backend to use for saving attachments:
  18554. @table @code
  18555. @item posix
  18556. No SiS done by Dovecot (but this might help FS's own deduplication)
  18557. @item sis posix
  18558. SiS with immediate byte-by-byte comparison during saving
  18559. @item sis-queue posix
  18560. SiS with delayed comparison and deduplication.
  18561. @end table
  18562. Defaults to @samp{"sis posix"}.
  18563. @end deftypevr
  18564. @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-hash
  18565. Hash format to use in attachment filenames. You can add any text and
  18566. variables: @code{%@{md4@}}, @code{%@{md5@}}, @code{%@{sha1@}},
  18567. @code{%@{sha256@}}, @code{%@{sha512@}}, @code{%@{size@}}. Variables can be
  18568. truncated, e.g.@: @code{%@{sha256:80@}} returns only first 80 bits.
  18569. Defaults to @samp{"%@{sha1@}"}.
  18570. @end deftypevr
  18571. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-process-limit
  18572. Defaults to @samp{100}.
  18573. @end deftypevr
  18574. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-client-limit
  18575. Defaults to @samp{1000}.
  18576. @end deftypevr
  18577. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-vsz-limit
  18578. Default VSZ (virtual memory size) limit for service processes.
  18579. This is mainly intended to catch and kill processes that leak memory
  18580. before they eat up everything.
  18581. Defaults to @samp{256000000}.
  18582. @end deftypevr
  18583. @deftypevr {@code{dovecot-configuration} parameter} string default-login-user
  18584. Login user is internally used by login processes. This is the most
  18585. untrusted user in Dovecot system. It shouldn't have access to anything
  18586. at all.
  18587. Defaults to @samp{"dovenull"}.
  18588. @end deftypevr
  18589. @deftypevr {@code{dovecot-configuration} parameter} string default-internal-user
  18590. Internal user is used by unprivileged processes. It should be
  18591. separate from login user, so that login processes can't disturb other
  18592. processes.
  18593. Defaults to @samp{"dovecot"}.
  18594. @end deftypevr
  18595. @deftypevr {@code{dovecot-configuration} parameter} string ssl?
  18596. SSL/TLS support: yes, no, required. <doc/wiki/SSL.txt>.
  18597. Defaults to @samp{"required"}.
  18598. @end deftypevr
  18599. @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert
  18600. PEM encoded X.509 SSL/TLS certificate (public key).
  18601. Defaults to @samp{"</etc/dovecot/default.pem"}.
  18602. @end deftypevr
  18603. @deftypevr {@code{dovecot-configuration} parameter} string ssl-key
  18604. PEM encoded SSL/TLS private key. The key is opened before
  18605. dropping root privileges, so keep the key file unreadable by anyone but
  18606. root.
  18607. Defaults to @samp{"</etc/dovecot/private/default.pem"}.
  18608. @end deftypevr
  18609. @deftypevr {@code{dovecot-configuration} parameter} string ssl-key-password
  18610. If key file is password protected, give the password here.
  18611. Alternatively give it when starting dovecot with -p parameter. Since
  18612. this file is often world-readable, you may want to place this setting
  18613. instead to a different.
  18614. Defaults to @samp{""}.
  18615. @end deftypevr
  18616. @deftypevr {@code{dovecot-configuration} parameter} string ssl-ca
  18617. PEM encoded trusted certificate authority. Set this only if you
  18618. intend to use @samp{ssl-verify-client-cert? #t}. The file should
  18619. contain the CA certificate(s) followed by the matching
  18620. CRL(s). (e.g.@: @samp{ssl-ca </etc/ssl/certs/ca.pem}).
  18621. Defaults to @samp{""}.
  18622. @end deftypevr
  18623. @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-require-crl?
  18624. Require that CRL check succeeds for client certificates.
  18625. Defaults to @samp{#t}.
  18626. @end deftypevr
  18627. @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-verify-client-cert?
  18628. Request client to send a certificate. If you also want to require
  18629. it, set @samp{auth-ssl-require-client-cert? #t} in auth section.
  18630. Defaults to @samp{#f}.
  18631. @end deftypevr
  18632. @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert-username-field
  18633. Which field from certificate to use for username. commonName and
  18634. x500UniqueIdentifier are the usual choices. You'll also need to set
  18635. @samp{auth-ssl-username-from-cert? #t}.
  18636. Defaults to @samp{"commonName"}.
  18637. @end deftypevr
  18638. @deftypevr {@code{dovecot-configuration} parameter} string ssl-min-protocol
  18639. Minimum SSL protocol version to accept.
  18640. Defaults to @samp{"TLSv1"}.
  18641. @end deftypevr
  18642. @deftypevr {@code{dovecot-configuration} parameter} string ssl-cipher-list
  18643. SSL ciphers to use.
  18644. Defaults to @samp{"ALL:!kRSA:!SRP:!kDHd:!DSS:!aNULL:!eNULL:!EXPORT:!DES:!3DES:!MD5:!PSK:!RC4:!ADH:!LOW@@STRENGTH"}.
  18645. @end deftypevr
  18646. @deftypevr {@code{dovecot-configuration} parameter} string ssl-crypto-device
  18647. SSL crypto device to use, for valid values run "openssl engine".
  18648. Defaults to @samp{""}.
  18649. @end deftypevr
  18650. @deftypevr {@code{dovecot-configuration} parameter} string postmaster-address
  18651. Address to use when sending rejection mails.
  18652. %d expands to recipient domain.
  18653. Defaults to @samp{"postmaster@@%d"}.
  18654. @end deftypevr
  18655. @deftypevr {@code{dovecot-configuration} parameter} string hostname
  18656. Hostname to use in various parts of sent mails (e.g.@: in Message-Id)
  18657. and in LMTP replies. Default is the system's real hostname@@domain.
  18658. Defaults to @samp{""}.
  18659. @end deftypevr
  18660. @deftypevr {@code{dovecot-configuration} parameter} boolean quota-full-tempfail?
  18661. If user is over quota, return with temporary failure instead of
  18662. bouncing the mail.
  18663. Defaults to @samp{#f}.
  18664. @end deftypevr
  18665. @deftypevr {@code{dovecot-configuration} parameter} file-name sendmail-path
  18666. Binary to use for sending mails.
  18667. Defaults to @samp{"/usr/sbin/sendmail"}.
  18668. @end deftypevr
  18669. @deftypevr {@code{dovecot-configuration} parameter} string submission-host
  18670. If non-empty, send mails via this SMTP host[:port] instead of
  18671. sendmail.
  18672. Defaults to @samp{""}.
  18673. @end deftypevr
  18674. @deftypevr {@code{dovecot-configuration} parameter} string rejection-subject
  18675. Subject: header to use for rejection mails. You can use the same
  18676. variables as for @samp{rejection-reason} below.
  18677. Defaults to @samp{"Rejected: %s"}.
  18678. @end deftypevr
  18679. @deftypevr {@code{dovecot-configuration} parameter} string rejection-reason
  18680. Human readable error message for rejection mails. You can use
  18681. variables:
  18682. @table @code
  18683. @item %n
  18684. CRLF
  18685. @item %r
  18686. reason
  18687. @item %s
  18688. original subject
  18689. @item %t
  18690. recipient
  18691. @end table
  18692. Defaults to @samp{"Your message to <%t> was automatically rejected:%n%r"}.
  18693. @end deftypevr
  18694. @deftypevr {@code{dovecot-configuration} parameter} string recipient-delimiter
  18695. Delimiter character between local-part and detail in email
  18696. address.
  18697. Defaults to @samp{"+"}.
  18698. @end deftypevr
  18699. @deftypevr {@code{dovecot-configuration} parameter} string lda-original-recipient-header
  18700. Header where the original recipient address (SMTP's RCPT TO:
  18701. address) is taken from if not available elsewhere. With dovecot-lda -a
  18702. parameter overrides this. A commonly used header for this is
  18703. X-Original-To.
  18704. Defaults to @samp{""}.
  18705. @end deftypevr
  18706. @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autocreate?
  18707. Should saving a mail to a nonexistent mailbox automatically create
  18708. it?.
  18709. Defaults to @samp{#f}.
  18710. @end deftypevr
  18711. @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autosubscribe?
  18712. Should automatically created mailboxes be also automatically
  18713. subscribed?.
  18714. Defaults to @samp{#f}.
  18715. @end deftypevr
  18716. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer imap-max-line-length
  18717. Maximum IMAP command line length. Some clients generate very long
  18718. command lines with huge mailboxes, so you may need to raise this if you
  18719. get "Too long argument" or "IMAP command line too large" errors
  18720. often.
  18721. Defaults to @samp{64000}.
  18722. @end deftypevr
  18723. @deftypevr {@code{dovecot-configuration} parameter} string imap-logout-format
  18724. IMAP logout format string:
  18725. @table @code
  18726. @item %i
  18727. total number of bytes read from client
  18728. @item %o
  18729. total number of bytes sent to client.
  18730. @end table
  18731. See @file{doc/wiki/Variables.txt} for a list of all the variables you can use.
  18732. 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@}"}.
  18733. @end deftypevr
  18734. @deftypevr {@code{dovecot-configuration} parameter} string imap-capability
  18735. Override the IMAP CAPABILITY response. If the value begins with '+',
  18736. add the given capabilities on top of the defaults (e.g.@: +XFOO XBAR).
  18737. Defaults to @samp{""}.
  18738. @end deftypevr
  18739. @deftypevr {@code{dovecot-configuration} parameter} string imap-idle-notify-interval
  18740. How long to wait between "OK Still here" notifications when client
  18741. is IDLEing.
  18742. Defaults to @samp{"2 mins"}.
  18743. @end deftypevr
  18744. @deftypevr {@code{dovecot-configuration} parameter} string imap-id-send
  18745. ID field names and values to send to clients. Using * as the value
  18746. makes Dovecot use the default value. The following fields have default
  18747. values currently: name, version, os, os-version, support-url,
  18748. support-email.
  18749. Defaults to @samp{""}.
  18750. @end deftypevr
  18751. @deftypevr {@code{dovecot-configuration} parameter} string imap-id-log
  18752. ID fields sent by client to log. * means everything.
  18753. Defaults to @samp{""}.
  18754. @end deftypevr
  18755. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list imap-client-workarounds
  18756. Workarounds for various client bugs:
  18757. @table @code
  18758. @item delay-newmail
  18759. Send EXISTS/RECENT new mail notifications only when replying to NOOP and
  18760. CHECK commands. Some clients ignore them otherwise, for example OSX
  18761. Mail (<v2.1). Outlook Express breaks more badly though, without this it
  18762. may show user "Message no longer in server" errors. Note that OE6
  18763. still breaks even with this workaround if synchronization is set to
  18764. "Headers Only".
  18765. @item tb-extra-mailbox-sep
  18766. Thunderbird gets somehow confused with LAYOUT=fs (mbox and dbox) and
  18767. adds extra @samp{/} suffixes to mailbox names. This option causes Dovecot to
  18768. ignore the extra @samp{/} instead of treating it as invalid mailbox name.
  18769. @item tb-lsub-flags
  18770. Show \Noselect flags for LSUB replies with LAYOUT=fs (e.g.@: mbox).
  18771. This makes Thunderbird realize they aren't selectable and show them
  18772. greyed out, instead of only later giving "not selectable" popup error.
  18773. @end table
  18774. Defaults to @samp{()}.
  18775. @end deftypevr
  18776. @deftypevr {@code{dovecot-configuration} parameter} string imap-urlauth-host
  18777. Host allowed in URLAUTH URLs sent by client. "*" allows all.
  18778. Defaults to @samp{""}.
  18779. @end deftypevr
  18780. Whew! Lots of configuration options. The nice thing about it though is
  18781. that Guix has a complete interface to Dovecot's configuration
  18782. language. This allows not only a nice way to declare configurations,
  18783. but also offers reflective capabilities as well: users can write code to
  18784. inspect and transform configurations from within Scheme.
  18785. However, it could be that you just want to get a @code{dovecot.conf} up
  18786. and running. In that case, you can pass an
  18787. @code{opaque-dovecot-configuration} as the @code{#:config} parameter to
  18788. @code{dovecot-service}. As its name indicates, an opaque configuration
  18789. does not have easy reflective capabilities.
  18790. Available @code{opaque-dovecot-configuration} fields are:
  18791. @deftypevr {@code{opaque-dovecot-configuration} parameter} package dovecot
  18792. The dovecot package.
  18793. @end deftypevr
  18794. @deftypevr {@code{opaque-dovecot-configuration} parameter} string string
  18795. The contents of the @code{dovecot.conf}, as a string.
  18796. @end deftypevr
  18797. For example, if your @code{dovecot.conf} is just the empty string, you
  18798. could instantiate a dovecot service like this:
  18799. @lisp
  18800. (dovecot-service #:config
  18801. (opaque-dovecot-configuration
  18802. (string "")))
  18803. @end lisp
  18804. @subsubheading OpenSMTPD Service
  18805. @deffn {Scheme Variable} opensmtpd-service-type
  18806. This is the type of the @uref{https://www.opensmtpd.org, OpenSMTPD}
  18807. service, whose value should be an @code{opensmtpd-configuration} object
  18808. as in this example:
  18809. @lisp
  18810. (service opensmtpd-service-type
  18811. (opensmtpd-configuration
  18812. (config-file (local-file "./my-smtpd.conf"))))
  18813. @end lisp
  18814. @end deffn
  18815. @deftp {Data Type} opensmtpd-configuration
  18816. Data type representing the configuration of opensmtpd.
  18817. @table @asis
  18818. @item @code{package} (default: @var{opensmtpd})
  18819. Package object of the OpenSMTPD SMTP server.
  18820. @item @code{config-file} (default: @code{%default-opensmtpd-file})
  18821. File-like object of the OpenSMTPD configuration file to use. By default
  18822. it listens on the loopback network interface, and allows for mail from
  18823. users and daemons on the local machine, as well as permitting email to
  18824. remote servers. Run @command{man smtpd.conf} for more information.
  18825. @end table
  18826. @end deftp
  18827. @subsubheading Exim Service
  18828. @cindex mail transfer agent (MTA)
  18829. @cindex MTA (mail transfer agent)
  18830. @cindex SMTP
  18831. @deffn {Scheme Variable} exim-service-type
  18832. This is the type of the @uref{https://exim.org, Exim} mail transfer
  18833. agent (MTA), whose value should be an @code{exim-configuration} object
  18834. as in this example:
  18835. @lisp
  18836. (service exim-service-type
  18837. (exim-configuration
  18838. (config-file (local-file "./my-exim.conf"))))
  18839. @end lisp
  18840. @end deffn
  18841. In order to use an @code{exim-service-type} service you must also have a
  18842. @code{mail-aliases-service-type} service present in your
  18843. @code{operating-system} (even if it has no aliases).
  18844. @deftp {Data Type} exim-configuration
  18845. Data type representing the configuration of exim.
  18846. @table @asis
  18847. @item @code{package} (default: @var{exim})
  18848. Package object of the Exim server.
  18849. @item @code{config-file} (default: @code{#f})
  18850. File-like object of the Exim configuration file to use. If its value is
  18851. @code{#f} then use the default configuration file from the package
  18852. provided in @code{package}. The resulting configuration file is loaded
  18853. after setting the @code{exim_user} and @code{exim_group} configuration
  18854. variables.
  18855. @end table
  18856. @end deftp
  18857. @subsubheading Getmail service
  18858. @cindex IMAP
  18859. @cindex POP
  18860. @deffn {Scheme Variable} getmail-service-type
  18861. This is the type of the @uref{http://pyropus.ca/software/getmail/, Getmail}
  18862. mail retriever, whose value should be an @code{getmail-configuration}.
  18863. @end deffn
  18864. Available @code{getmail-configuration} fields are:
  18865. @deftypevr {@code{getmail-configuration} parameter} symbol name
  18866. A symbol to identify the getmail service.
  18867. Defaults to @samp{"unset"}.
  18868. @end deftypevr
  18869. @deftypevr {@code{getmail-configuration} parameter} package package
  18870. The getmail package to use.
  18871. @end deftypevr
  18872. @deftypevr {@code{getmail-configuration} parameter} string user
  18873. The user to run getmail as.
  18874. Defaults to @samp{"getmail"}.
  18875. @end deftypevr
  18876. @deftypevr {@code{getmail-configuration} parameter} string group
  18877. The group to run getmail as.
  18878. Defaults to @samp{"getmail"}.
  18879. @end deftypevr
  18880. @deftypevr {@code{getmail-configuration} parameter} string directory
  18881. The getmail directory to use.
  18882. Defaults to @samp{"/var/lib/getmail/default"}.
  18883. @end deftypevr
  18884. @deftypevr {@code{getmail-configuration} parameter} getmail-configuration-file rcfile
  18885. The getmail configuration file to use.
  18886. Available @code{getmail-configuration-file} fields are:
  18887. @deftypevr {@code{getmail-configuration-file} parameter} getmail-retriever-configuration retriever
  18888. What mail account to retrieve mail from, and how to access that account.
  18889. Available @code{getmail-retriever-configuration} fields are:
  18890. @deftypevr {@code{getmail-retriever-configuration} parameter} string type
  18891. The type of mail retriever to use. Valid values include @samp{passwd}
  18892. and @samp{static}.
  18893. Defaults to @samp{"SimpleIMAPSSLRetriever"}.
  18894. @end deftypevr
  18895. @deftypevr {@code{getmail-retriever-configuration} parameter} string server
  18896. Username to login to the mail server with.
  18897. Defaults to @samp{unset}.
  18898. @end deftypevr
  18899. @deftypevr {@code{getmail-retriever-configuration} parameter} string username
  18900. Username to login to the mail server with.
  18901. Defaults to @samp{unset}.
  18902. @end deftypevr
  18903. @deftypevr {@code{getmail-retriever-configuration} parameter} non-negative-integer port
  18904. Port number to connect to.
  18905. Defaults to @samp{#f}.
  18906. @end deftypevr
  18907. @deftypevr {@code{getmail-retriever-configuration} parameter} string password
  18908. Override fields from passwd.
  18909. Defaults to @samp{""}.
  18910. @end deftypevr
  18911. @deftypevr {@code{getmail-retriever-configuration} parameter} list password-command
  18912. Override fields from passwd.
  18913. Defaults to @samp{()}.
  18914. @end deftypevr
  18915. @deftypevr {@code{getmail-retriever-configuration} parameter} string keyfile
  18916. PEM-formatted key file to use for the TLS negotiation.
  18917. Defaults to @samp{""}.
  18918. @end deftypevr
  18919. @deftypevr {@code{getmail-retriever-configuration} parameter} string certfile
  18920. PEM-formatted certificate file to use for the TLS negotiation.
  18921. Defaults to @samp{""}.
  18922. @end deftypevr
  18923. @deftypevr {@code{getmail-retriever-configuration} parameter} string ca-certs
  18924. CA certificates to use.
  18925. Defaults to @samp{""}.
  18926. @end deftypevr
  18927. @deftypevr {@code{getmail-retriever-configuration} parameter} parameter-alist extra-parameters
  18928. Extra retriever parameters.
  18929. Defaults to @samp{()}.
  18930. @end deftypevr
  18931. @end deftypevr
  18932. @deftypevr {@code{getmail-configuration-file} parameter} getmail-destination-configuration destination
  18933. What to do with retrieved messages.
  18934. Available @code{getmail-destination-configuration} fields are:
  18935. @deftypevr {@code{getmail-destination-configuration} parameter} string type
  18936. The type of mail destination. Valid values include @samp{Maildir},
  18937. @samp{Mboxrd} and @samp{MDA_external}.
  18938. Defaults to @samp{unset}.
  18939. @end deftypevr
  18940. @deftypevr {@code{getmail-destination-configuration} parameter} string-or-filelike path
  18941. The path option for the mail destination. The behaviour depends on the
  18942. chosen type.
  18943. Defaults to @samp{""}.
  18944. @end deftypevr
  18945. @deftypevr {@code{getmail-destination-configuration} parameter} parameter-alist extra-parameters
  18946. Extra destination parameters
  18947. Defaults to @samp{()}.
  18948. @end deftypevr
  18949. @end deftypevr
  18950. @deftypevr {@code{getmail-configuration-file} parameter} getmail-options-configuration options
  18951. Configure getmail.
  18952. Available @code{getmail-options-configuration} fields are:
  18953. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer verbose
  18954. If set to @samp{0}, getmail will only print warnings and errors. A
  18955. value of @samp{1} means that messages will be printed about retrieving
  18956. and deleting messages. If set to @samp{2}, getmail will print messages
  18957. about each of its actions.
  18958. Defaults to @samp{1}.
  18959. @end deftypevr
  18960. @deftypevr {@code{getmail-options-configuration} parameter} boolean read-all
  18961. If true, getmail will retrieve all available messages. Otherwise it
  18962. will only retrieve messages it hasn't seen previously.
  18963. Defaults to @samp{#t}.
  18964. @end deftypevr
  18965. @deftypevr {@code{getmail-options-configuration} parameter} boolean delete
  18966. If set to true, messages will be deleted from the server after
  18967. retrieving and successfully delivering them. Otherwise, messages will
  18968. be left on the server.
  18969. Defaults to @samp{#f}.
  18970. @end deftypevr
  18971. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer delete-after
  18972. Getmail will delete messages this number of days after seeing them, if
  18973. they have been delivered. This means messages will be left on the
  18974. server this number of days after delivering them. A value of @samp{0}
  18975. disabled this feature.
  18976. Defaults to @samp{0}.
  18977. @end deftypevr
  18978. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer delete-bigger-than
  18979. Delete messages larger than this of bytes after retrieving them, even if
  18980. the delete and delete-after options are disabled. A value of @samp{0}
  18981. disables this feature.
  18982. Defaults to @samp{0}.
  18983. @end deftypevr
  18984. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer max-bytes-per-session
  18985. Retrieve messages totalling up to this number of bytes before closing
  18986. the session with the server. A value of @samp{0} disables this feature.
  18987. Defaults to @samp{0}.
  18988. @end deftypevr
  18989. @deftypevr {@code{getmail-options-configuration} parameter} non-negative-integer max-message-size
  18990. Don't retrieve messages larger than this number of bytes. A value of
  18991. @samp{0} disables this feature.
  18992. Defaults to @samp{0}.
  18993. @end deftypevr
  18994. @deftypevr {@code{getmail-options-configuration} parameter} boolean delivered-to
  18995. If true, getmail will add a Delivered-To header to messages.
  18996. Defaults to @samp{#t}.
  18997. @end deftypevr
  18998. @deftypevr {@code{getmail-options-configuration} parameter} boolean received
  18999. If set, getmail adds a Received header to the messages.
  19000. Defaults to @samp{#t}.
  19001. @end deftypevr
  19002. @deftypevr {@code{getmail-options-configuration} parameter} string message-log
  19003. Getmail will record a log of its actions to the named file. A value of
  19004. @samp{""} disables this feature.
  19005. Defaults to @samp{""}.
  19006. @end deftypevr
  19007. @deftypevr {@code{getmail-options-configuration} parameter} boolean message-log-syslog
  19008. If true, getmail will record a log of its actions using the system
  19009. logger.
  19010. Defaults to @samp{#f}.
  19011. @end deftypevr
  19012. @deftypevr {@code{getmail-options-configuration} parameter} boolean message-log-verbose
  19013. If true, getmail will log information about messages not retrieved and
  19014. the reason for not retrieving them, as well as starting and ending
  19015. information lines.
  19016. Defaults to @samp{#f}.
  19017. @end deftypevr
  19018. @deftypevr {@code{getmail-options-configuration} parameter} parameter-alist extra-parameters
  19019. Extra options to include.
  19020. Defaults to @samp{()}.
  19021. @end deftypevr
  19022. @end deftypevr
  19023. @end deftypevr
  19024. @deftypevr {@code{getmail-configuration} parameter} list idle
  19025. A list of mailboxes that getmail should wait on the server for new mail
  19026. notifications. This depends on the server supporting the IDLE
  19027. extension.
  19028. Defaults to @samp{()}.
  19029. @end deftypevr
  19030. @deftypevr {@code{getmail-configuration} parameter} list environment-variables
  19031. Environment variables to set for getmail.
  19032. Defaults to @samp{()}.
  19033. @end deftypevr
  19034. @subsubheading Mail Aliases Service
  19035. @cindex email aliases
  19036. @cindex aliases, for email addresses
  19037. @deffn {Scheme Variable} mail-aliases-service-type
  19038. This is the type of the service which provides @code{/etc/aliases},
  19039. specifying how to deliver mail to users on this system.
  19040. @lisp
  19041. (service mail-aliases-service-type
  19042. '(("postmaster" "bob")
  19043. ("bob" "bob@@example.com" "bob@@example2.com")))
  19044. @end lisp
  19045. @end deffn
  19046. The configuration for a @code{mail-aliases-service-type} service is an
  19047. association list denoting how to deliver mail that comes to this
  19048. system. Each entry is of the form @code{(alias addresses ...)}, with
  19049. @code{alias} specifying the local alias and @code{addresses} specifying
  19050. where to deliver this user's mail.
  19051. The aliases aren't required to exist as users on the local system. In
  19052. the above example, there doesn't need to be a @code{postmaster} entry in
  19053. the @code{operating-system}'s @code{user-accounts} in order to deliver
  19054. the @code{postmaster} mail to @code{bob} (which subsequently would
  19055. deliver mail to @code{bob@@example.com} and @code{bob@@example2.com}).
  19056. @subsubheading GNU Mailutils IMAP4 Daemon
  19057. @cindex GNU Mailutils IMAP4 Daemon
  19058. @deffn {Scheme Variable} imap4d-service-type
  19059. This is the type of the GNU Mailutils IMAP4 Daemon (@pxref{imap4d,,,
  19060. mailutils, GNU Mailutils Manual}), whose value should be an
  19061. @code{imap4d-configuration} object as in this example:
  19062. @lisp
  19063. (service imap4d-service-type
  19064. (imap4d-configuration
  19065. (config-file (local-file "imap4d.conf"))))
  19066. @end lisp
  19067. @end deffn
  19068. @deftp {Data Type} imap4d-configuration
  19069. Data type representing the configuration of @command{imap4d}.
  19070. @table @asis
  19071. @item @code{package} (default: @code{mailutils})
  19072. The package that provides @command{imap4d}.
  19073. @item @code{config-file} (default: @code{%default-imap4d-config-file})
  19074. File-like object of the configuration file to use, by default it will listen
  19075. on TCP port 143 of @code{localhost}. @xref{Conf-imap4d,,, mailutils, GNU
  19076. Mailutils Manual}, for details.
  19077. @end table
  19078. @end deftp
  19079. @subsubheading Radicale Service
  19080. @cindex CalDAV
  19081. @cindex CardDAV
  19082. @deffn {Scheme Variable} radicale-service-type
  19083. This is the type of the @uref{https://radicale.org, Radicale} CalDAV/CardDAV
  19084. server whose value should be a @code{radicale-configuration}.
  19085. @end deffn
  19086. @deftp {Data Type} radicale-configuration
  19087. Data type representing the configuration of @command{radicale}.
  19088. @table @asis
  19089. @item @code{package} (default: @code{radicale})
  19090. The package that provides @command{radicale}.
  19091. @item @code{config-file} (default: @code{%default-radicale-config-file})
  19092. File-like object of the configuration file to use, by default it will listen
  19093. on TCP port 5232 of @code{localhost} and use the @code{htpasswd} file at
  19094. @file{/var/lib/radicale/users} with no (@code{plain}) encryption.
  19095. @end table
  19096. @end deftp
  19097. @node Messaging Services
  19098. @subsection Messaging Services
  19099. @cindex messaging
  19100. @cindex jabber
  19101. @cindex XMPP
  19102. The @code{(gnu services messaging)} module provides Guix service
  19103. definitions for messaging services. Currently it provides the following
  19104. services:
  19105. @subsubheading Prosody Service
  19106. @deffn {Scheme Variable} prosody-service-type
  19107. This is the type for the @uref{https://prosody.im, Prosody XMPP
  19108. communication server}. Its value must be a @code{prosody-configuration}
  19109. record as in this example:
  19110. @lisp
  19111. (service prosody-service-type
  19112. (prosody-configuration
  19113. (modules-enabled (cons* "groups" "mam" %default-modules-enabled))
  19114. (int-components
  19115. (list
  19116. (int-component-configuration
  19117. (hostname "conference.example.net")
  19118. (plugin "muc")
  19119. (mod-muc (mod-muc-configuration)))))
  19120. (virtualhosts
  19121. (list
  19122. (virtualhost-configuration
  19123. (domain "example.net"))))))
  19124. @end lisp
  19125. See below for details about @code{prosody-configuration}.
  19126. @end deffn
  19127. By default, Prosody does not need much configuration. Only one
  19128. @code{virtualhosts} field is needed: it specifies the domain you wish
  19129. Prosody to serve.
  19130. You can perform various sanity checks on the generated configuration
  19131. with the @code{prosodyctl check} command.
  19132. Prosodyctl will also help you to import certificates from the
  19133. @code{letsencrypt} directory so that the @code{prosody} user can access
  19134. them. See @url{https://prosody.im/doc/letsencrypt}.
  19135. @example
  19136. prosodyctl --root cert import /etc/letsencrypt/live
  19137. @end example
  19138. The available configuration parameters follow. Each parameter
  19139. definition is preceded by its type; for example, @samp{string-list foo}
  19140. indicates that the @code{foo} parameter should be specified as a list of
  19141. strings. Types starting with @code{maybe-} denote parameters that won't
  19142. show up in @code{prosody.cfg.lua} when their value is @code{'disabled}.
  19143. There is also a way to specify the configuration as a string, if you
  19144. have an old @code{prosody.cfg.lua} file that you want to port over from
  19145. some other system; see the end for more details.
  19146. The @code{file-object} type designates either a file-like object
  19147. (@pxref{G-Expressions, file-like objects}) or a file name.
  19148. @c The following documentation was initially generated by
  19149. @c (generate-documentation) in (gnu services messaging). Manually maintained
  19150. @c documentation is better, so we shouldn't hesitate to edit below as
  19151. @c needed. However if the change you want to make to this documentation
  19152. @c can be done in an automated way, it's probably easier to change
  19153. @c (generate-documentation) than to make it below and have to deal with
  19154. @c the churn as Prosody updates.
  19155. Available @code{prosody-configuration} fields are:
  19156. @deftypevr {@code{prosody-configuration} parameter} package prosody
  19157. The Prosody package.
  19158. @end deftypevr
  19159. @deftypevr {@code{prosody-configuration} parameter} file-name data-path
  19160. Location of the Prosody data storage directory. See
  19161. @url{https://prosody.im/doc/configure}.
  19162. Defaults to @samp{"/var/lib/prosody"}.
  19163. @end deftypevr
  19164. @deftypevr {@code{prosody-configuration} parameter} file-object-list plugin-paths
  19165. Additional plugin directories. They are searched in all the specified
  19166. paths in order. See @url{https://prosody.im/doc/plugins_directory}.
  19167. Defaults to @samp{()}.
  19168. @end deftypevr
  19169. @deftypevr {@code{prosody-configuration} parameter} file-name certificates
  19170. Every virtual host and component needs a certificate so that clients and
  19171. servers can securely verify its identity. Prosody will automatically load
  19172. certificates/keys from the directory specified here.
  19173. Defaults to @samp{"/etc/prosody/certs"}.
  19174. @end deftypevr
  19175. @deftypevr {@code{prosody-configuration} parameter} string-list admins
  19176. This is a list of accounts that are admins for the server. Note that you
  19177. must create the accounts separately. See @url{https://prosody.im/doc/admins} and
  19178. @url{https://prosody.im/doc/creating_accounts}.
  19179. Example: @code{(admins '("user1@@example.com" "user2@@example.net"))}
  19180. Defaults to @samp{()}.
  19181. @end deftypevr
  19182. @deftypevr {@code{prosody-configuration} parameter} boolean use-libevent?
  19183. Enable use of libevent for better performance under high load. See
  19184. @url{https://prosody.im/doc/libevent}.
  19185. Defaults to @samp{#f}.
  19186. @end deftypevr
  19187. @deftypevr {@code{prosody-configuration} parameter} module-list modules-enabled
  19188. This is the list of modules Prosody will load on startup. It looks for
  19189. @code{mod_modulename.lua} in the plugins folder, so make sure that exists too.
  19190. Documentation on modules can be found at:
  19191. @url{https://prosody.im/doc/modules}.
  19192. Defaults to @samp{("roster" "saslauth" "tls" "dialback" "disco" "carbons" "private" "blocklist" "vcard" "version" "uptime" "time" "ping" "pep" "register" "admin_adhoc")}.
  19193. @end deftypevr
  19194. @deftypevr {@code{prosody-configuration} parameter} string-list modules-disabled
  19195. @samp{"offline"}, @samp{"c2s"} and @samp{"s2s"} are auto-loaded, but
  19196. should you want to disable them then add them to this list.
  19197. Defaults to @samp{()}.
  19198. @end deftypevr
  19199. @deftypevr {@code{prosody-configuration} parameter} file-object groups-file
  19200. Path to a text file where the shared groups are defined. If this path is
  19201. empty then @samp{mod_groups} does nothing. See
  19202. @url{https://prosody.im/doc/modules/mod_groups}.
  19203. Defaults to @samp{"/var/lib/prosody/sharedgroups.txt"}.
  19204. @end deftypevr
  19205. @deftypevr {@code{prosody-configuration} parameter} boolean allow-registration?
  19206. Disable account creation by default, for security. See
  19207. @url{https://prosody.im/doc/creating_accounts}.
  19208. Defaults to @samp{#f}.
  19209. @end deftypevr
  19210. @deftypevr {@code{prosody-configuration} parameter} maybe-ssl-configuration ssl
  19211. These are the SSL/TLS-related settings. Most of them are disabled so to
  19212. use Prosody's defaults. If you do not completely understand these options, do
  19213. not add them to your config, it is easy to lower the security of your server
  19214. using them. See @url{https://prosody.im/doc/advanced_ssl_config}.
  19215. Available @code{ssl-configuration} fields are:
  19216. @deftypevr {@code{ssl-configuration} parameter} maybe-string protocol
  19217. This determines what handshake to use.
  19218. @end deftypevr
  19219. @deftypevr {@code{ssl-configuration} parameter} maybe-file-name key
  19220. Path to your private key file.
  19221. @end deftypevr
  19222. @deftypevr {@code{ssl-configuration} parameter} maybe-file-name certificate
  19223. Path to your certificate file.
  19224. @end deftypevr
  19225. @deftypevr {@code{ssl-configuration} parameter} file-object capath
  19226. Path to directory containing root certificates that you wish Prosody to
  19227. trust when verifying the certificates of remote servers.
  19228. Defaults to @samp{"/etc/ssl/certs"}.
  19229. @end deftypevr
  19230. @deftypevr {@code{ssl-configuration} parameter} maybe-file-object cafile
  19231. Path to a file containing root certificates that you wish Prosody to trust.
  19232. Similar to @code{capath} but with all certificates concatenated together.
  19233. @end deftypevr
  19234. @deftypevr {@code{ssl-configuration} parameter} maybe-string-list verify
  19235. A list of verification options (these mostly map to OpenSSL's
  19236. @code{set_verify()} flags).
  19237. @end deftypevr
  19238. @deftypevr {@code{ssl-configuration} parameter} maybe-string-list options
  19239. A list of general options relating to SSL/TLS@. These map to OpenSSL's
  19240. @code{set_options()}. For a full list of options available in LuaSec, see the
  19241. LuaSec source.
  19242. @end deftypevr
  19243. @deftypevr {@code{ssl-configuration} parameter} maybe-non-negative-integer depth
  19244. How long a chain of certificate authorities to check when looking for a
  19245. trusted root certificate.
  19246. @end deftypevr
  19247. @deftypevr {@code{ssl-configuration} parameter} maybe-string ciphers
  19248. An OpenSSL cipher string. This selects what ciphers Prosody will offer to
  19249. clients, and in what order.
  19250. @end deftypevr
  19251. @deftypevr {@code{ssl-configuration} parameter} maybe-file-name dhparam
  19252. A path to a file containing parameters for Diffie-Hellman key exchange. You
  19253. can create such a file with:
  19254. @code{openssl dhparam -out /etc/prosody/certs/dh-2048.pem 2048}
  19255. @end deftypevr
  19256. @deftypevr {@code{ssl-configuration} parameter} maybe-string curve
  19257. Curve for Elliptic curve Diffie-Hellman. Prosody's default is
  19258. @samp{"secp384r1"}.
  19259. @end deftypevr
  19260. @deftypevr {@code{ssl-configuration} parameter} maybe-string-list verifyext
  19261. A list of ``extra'' verification options.
  19262. @end deftypevr
  19263. @deftypevr {@code{ssl-configuration} parameter} maybe-string password
  19264. Password for encrypted private keys.
  19265. @end deftypevr
  19266. @end deftypevr
  19267. @deftypevr {@code{prosody-configuration} parameter} boolean c2s-require-encryption?
  19268. Whether to force all client-to-server connections to be encrypted or not.
  19269. See @url{https://prosody.im/doc/modules/mod_tls}.
  19270. Defaults to @samp{#f}.
  19271. @end deftypevr
  19272. @deftypevr {@code{prosody-configuration} parameter} string-list disable-sasl-mechanisms
  19273. Set of mechanisms that will never be offered. See
  19274. @url{https://prosody.im/doc/modules/mod_saslauth}.
  19275. Defaults to @samp{("DIGEST-MD5")}.
  19276. @end deftypevr
  19277. @deftypevr {@code{prosody-configuration} parameter} boolean s2s-require-encryption?
  19278. Whether to force all server-to-server connections to be encrypted or not.
  19279. See @url{https://prosody.im/doc/modules/mod_tls}.
  19280. Defaults to @samp{#f}.
  19281. @end deftypevr
  19282. @deftypevr {@code{prosody-configuration} parameter} boolean s2s-secure-auth?
  19283. Whether to require encryption and certificate authentication. This
  19284. provides ideal security, but requires servers you communicate with to support
  19285. encryption AND present valid, trusted certificates. See
  19286. @url{https://prosody.im/doc/s2s#security}.
  19287. Defaults to @samp{#f}.
  19288. @end deftypevr
  19289. @deftypevr {@code{prosody-configuration} parameter} string-list s2s-insecure-domains
  19290. Many servers don't support encryption or have invalid or self-signed
  19291. certificates. You can list domains here that will not be required to
  19292. authenticate using certificates. They will be authenticated using DNS@. See
  19293. @url{https://prosody.im/doc/s2s#security}.
  19294. Defaults to @samp{()}.
  19295. @end deftypevr
  19296. @deftypevr {@code{prosody-configuration} parameter} string-list s2s-secure-domains
  19297. Even if you leave @code{s2s-secure-auth?} disabled, you can still require
  19298. valid certificates for some domains by specifying a list here. See
  19299. @url{https://prosody.im/doc/s2s#security}.
  19300. Defaults to @samp{()}.
  19301. @end deftypevr
  19302. @deftypevr {@code{prosody-configuration} parameter} string authentication
  19303. Select the authentication backend to use. The default provider stores
  19304. passwords in plaintext and uses Prosody's configured data storage to store the
  19305. authentication data. If you do not trust your server please see
  19306. @url{https://prosody.im/doc/modules/mod_auth_internal_hashed} for information
  19307. about using the hashed backend. See also
  19308. @url{https://prosody.im/doc/authentication}
  19309. Defaults to @samp{"internal_plain"}.
  19310. @end deftypevr
  19311. @deftypevr {@code{prosody-configuration} parameter} maybe-string log
  19312. Set logging options. Advanced logging configuration is not yet supported
  19313. by the Prosody service. See @url{https://prosody.im/doc/logging}.
  19314. Defaults to @samp{"*syslog"}.
  19315. @end deftypevr
  19316. @deftypevr {@code{prosody-configuration} parameter} file-name pidfile
  19317. File to write pid in. See @url{https://prosody.im/doc/modules/mod_posix}.
  19318. Defaults to @samp{"/var/run/prosody/prosody.pid"}.
  19319. @end deftypevr
  19320. @deftypevr {@code{prosody-configuration} parameter} maybe-non-negative-integer http-max-content-size
  19321. Maximum allowed size of the HTTP body (in bytes).
  19322. @end deftypevr
  19323. @deftypevr {@code{prosody-configuration} parameter} maybe-string http-external-url
  19324. Some modules expose their own URL in various ways. This URL is built
  19325. from the protocol, host and port used. If Prosody sits behind a proxy, the
  19326. public URL will be @code{http-external-url} instead. See
  19327. @url{https://prosody.im/doc/http#external_url}.
  19328. @end deftypevr
  19329. @deftypevr {@code{prosody-configuration} parameter} virtualhost-configuration-list virtualhosts
  19330. A host in Prosody is a domain on which user accounts can be created. For
  19331. example if you want your users to have addresses like
  19332. @samp{"john.smith@@example.com"} then you need to add a host
  19333. @samp{"example.com"}. All options in this list will apply only to this host.
  19334. Note: the name @emph{virtual} host is used in configuration to avoid confusion with
  19335. the actual physical host that Prosody is installed on. A single Prosody
  19336. instance can serve many domains, each one defined as a VirtualHost entry in
  19337. Prosody's configuration. Conversely a server that hosts a single domain would
  19338. have just one VirtualHost entry.
  19339. See @url{https://prosody.im/doc/configure#virtual_host_settings}.
  19340. Available @code{virtualhost-configuration} fields are:
  19341. 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:
  19342. @deftypevr {@code{virtualhost-configuration} parameter} string domain
  19343. Domain you wish Prosody to serve.
  19344. @end deftypevr
  19345. @end deftypevr
  19346. @deftypevr {@code{prosody-configuration} parameter} int-component-configuration-list int-components
  19347. Components are extra services on a server which are available to clients,
  19348. usually on a subdomain of the main server (such as
  19349. @samp{"mycomponent.example.com"}). Example components might be chatroom
  19350. servers, user directories, or gateways to other protocols.
  19351. Internal components are implemented with Prosody-specific plugins. To add an
  19352. internal component, you simply fill the hostname field, and the plugin you wish
  19353. to use for the component.
  19354. See @url{https://prosody.im/doc/components}.
  19355. Defaults to @samp{()}.
  19356. Available @code{int-component-configuration} fields are:
  19357. 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:
  19358. @deftypevr {@code{int-component-configuration} parameter} string hostname
  19359. Hostname of the component.
  19360. @end deftypevr
  19361. @deftypevr {@code{int-component-configuration} parameter} string plugin
  19362. Plugin you wish to use for the component.
  19363. @end deftypevr
  19364. @deftypevr {@code{int-component-configuration} parameter} maybe-mod-muc-configuration mod-muc
  19365. Multi-user chat (MUC) is Prosody's module for allowing you to create
  19366. hosted chatrooms/conferences for XMPP users.
  19367. General information on setting up and using multi-user chatrooms can be found
  19368. in the ``Chatrooms'' documentation (@url{https://prosody.im/doc/chatrooms}),
  19369. which you should read if you are new to XMPP chatrooms.
  19370. See also @url{https://prosody.im/doc/modules/mod_muc}.
  19371. Available @code{mod-muc-configuration} fields are:
  19372. @deftypevr {@code{mod-muc-configuration} parameter} string name
  19373. The name to return in service discovery responses.
  19374. Defaults to @samp{"Prosody Chatrooms"}.
  19375. @end deftypevr
  19376. @deftypevr {@code{mod-muc-configuration} parameter} string-or-boolean restrict-room-creation
  19377. If @samp{#t}, this will only allow admins to create new chatrooms.
  19378. Otherwise anyone can create a room. The value @samp{"local"} restricts room
  19379. creation to users on the service's parent domain. E.g.@: @samp{user@@example.com}
  19380. can create rooms on @samp{rooms.example.com}. The value @samp{"admin"}
  19381. restricts to service administrators only.
  19382. Defaults to @samp{#f}.
  19383. @end deftypevr
  19384. @deftypevr {@code{mod-muc-configuration} parameter} non-negative-integer max-history-messages
  19385. Maximum number of history messages that will be sent to the member that has
  19386. just joined the room.
  19387. Defaults to @samp{20}.
  19388. @end deftypevr
  19389. @end deftypevr
  19390. @end deftypevr
  19391. @deftypevr {@code{prosody-configuration} parameter} ext-component-configuration-list ext-components
  19392. External components use XEP-0114, which most standalone components
  19393. support. To add an external component, you simply fill the hostname field. See
  19394. @url{https://prosody.im/doc/components}.
  19395. Defaults to @samp{()}.
  19396. Available @code{ext-component-configuration} fields are:
  19397. 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:
  19398. @deftypevr {@code{ext-component-configuration} parameter} string component-secret
  19399. Password which the component will use to log in.
  19400. @end deftypevr
  19401. @deftypevr {@code{ext-component-configuration} parameter} string hostname
  19402. Hostname of the component.
  19403. @end deftypevr
  19404. @end deftypevr
  19405. @deftypevr {@code{prosody-configuration} parameter} non-negative-integer-list component-ports
  19406. Port(s) Prosody listens on for component connections.
  19407. Defaults to @samp{(5347)}.
  19408. @end deftypevr
  19409. @deftypevr {@code{prosody-configuration} parameter} string component-interface
  19410. Interface Prosody listens on for component connections.
  19411. Defaults to @samp{"127.0.0.1"}.
  19412. @end deftypevr
  19413. @deftypevr {@code{prosody-configuration} parameter} maybe-raw-content raw-content
  19414. Raw content that will be added to the configuration file.
  19415. @end deftypevr
  19416. It could be that you just want to get a @code{prosody.cfg.lua}
  19417. up and running. In that case, you can pass an
  19418. @code{opaque-prosody-configuration} record as the value of
  19419. @code{prosody-service-type}. As its name indicates, an opaque configuration
  19420. does not have easy reflective capabilities.
  19421. Available @code{opaque-prosody-configuration} fields are:
  19422. @deftypevr {@code{opaque-prosody-configuration} parameter} package prosody
  19423. The prosody package.
  19424. @end deftypevr
  19425. @deftypevr {@code{opaque-prosody-configuration} parameter} string prosody.cfg.lua
  19426. The contents of the @code{prosody.cfg.lua} to use.
  19427. @end deftypevr
  19428. For example, if your @code{prosody.cfg.lua} is just the empty
  19429. string, you could instantiate a prosody service like this:
  19430. @lisp
  19431. (service prosody-service-type
  19432. (opaque-prosody-configuration
  19433. (prosody.cfg.lua "")))
  19434. @end lisp
  19435. @c end of Prosody auto-generated documentation
  19436. @subsubheading BitlBee Service
  19437. @cindex IRC (Internet Relay Chat)
  19438. @cindex IRC gateway
  19439. @url{https://bitlbee.org,BitlBee} is a gateway that provides an IRC
  19440. interface to a variety of messaging protocols such as XMPP.
  19441. @defvr {Scheme Variable} bitlbee-service-type
  19442. This is the service type for the @url{https://bitlbee.org,BitlBee} IRC
  19443. gateway daemon. Its value is a @code{bitlbee-configuration} (see
  19444. below).
  19445. To have BitlBee listen on port 6667 on localhost, add this line to your
  19446. services:
  19447. @lisp
  19448. (service bitlbee-service-type)
  19449. @end lisp
  19450. @end defvr
  19451. @deftp {Data Type} bitlbee-configuration
  19452. This is the configuration for BitlBee, with the following fields:
  19453. @table @asis
  19454. @item @code{interface} (default: @code{"127.0.0.1"})
  19455. @itemx @code{port} (default: @code{6667})
  19456. Listen on the network interface corresponding to the IP address
  19457. specified in @var{interface}, on @var{port}.
  19458. When @var{interface} is @code{127.0.0.1}, only local clients can
  19459. connect; when it is @code{0.0.0.0}, connections can come from any
  19460. networking interface.
  19461. @item @code{bitlbee} (default: @code{bitlbee})
  19462. The BitlBee package to use.
  19463. @item @code{plugins} (default: @code{'()})
  19464. List of plugin packages to use---e.g., @code{bitlbee-discord}.
  19465. @item @code{extra-settings} (default: @code{""})
  19466. Configuration snippet added as-is to the BitlBee configuration file.
  19467. @end table
  19468. @end deftp
  19469. @subsubheading Quassel Service
  19470. @cindex IRC (Internet Relay Chat)
  19471. @url{https://quassel-irc.org/,Quassel} is a distributed IRC client,
  19472. meaning that one or more clients can attach to and detach from the
  19473. central core.
  19474. @defvr {Scheme Variable} quassel-service-type
  19475. This is the service type for the @url{https://quassel-irc.org/,Quassel}
  19476. IRC backend daemon. Its value is a @code{quassel-configuration}
  19477. (see below).
  19478. @end defvr
  19479. @deftp {Data Type} quassel-configuration
  19480. This is the configuration for Quassel, with the following fields:
  19481. @table @asis
  19482. @item @code{quassel} (default: @code{quassel})
  19483. The Quassel package to use.
  19484. @item @code{interface} (default: @code{"::,0.0.0.0"})
  19485. @item @code{port} (default: @code{4242})
  19486. Listen on the network interface(s) corresponding to the IPv4 or IPv6
  19487. interfaces specified in the comma delimited @var{interface}, on
  19488. @var{port}.
  19489. @item @code{loglevel} (default: @code{"Info"})
  19490. The level of logging desired. Accepted values are Debug, Info, Warning
  19491. and Error.
  19492. @end table
  19493. @end deftp
  19494. @node Telephony Services
  19495. @subsection Telephony Services
  19496. @cindex telephony, services
  19497. The @code{(gnu services telephony)} module contains Guix service
  19498. definitions for telephony services. Currently it provides the following
  19499. services:
  19500. @subsubheading Jami
  19501. @cindex jami, service
  19502. This section describes how to configure a Jami server that can be used
  19503. to host video (or audio) conferences, among other uses. The following
  19504. example demonstrates how to specify Jami account archives (backups) to
  19505. be provisioned automatically:
  19506. @lisp
  19507. (service jami-service-type
  19508. (jami-configuration
  19509. (accounts
  19510. (list (jami-account
  19511. (archive "/etc/jami/unencrypted-account-1.gz"))
  19512. (jami-account
  19513. (archive "/etc/jami/unencrypted-account-2.gz"))))))
  19514. @end lisp
  19515. When the accounts field is specified, the Jami account files of the
  19516. service found under @file{/var/lib/jami} are recreated every time the
  19517. service starts.
  19518. Jami accounts and their corresponding backup archives can be generated
  19519. using the @code{jami} or @code{jami-gnome} Jami clients. The accounts
  19520. should not be password-protected, but it is wise to ensure their files
  19521. are only readable by @samp{root}.
  19522. The next example shows how to declare that only some contacts should be
  19523. allowed to communicate with a given account:
  19524. @lisp
  19525. (service jami-service-type
  19526. (jami-configuration
  19527. (accounts
  19528. (list (jami-account
  19529. (archive "/etc/jami/unencrypted-account-1.gz")
  19530. (peer-discovery? #t)
  19531. (rendezvous-point? #t)
  19532. (allowed-contacts
  19533. '("1dbcb0f5f37324228235564b79f2b9737e9a008f"
  19534. "2dbcb0f5f37324228235564b79f2b9737e9a008f")))))))
  19535. @end lisp
  19536. In this mode, only the declared @code{allowed-contacts} can initiate
  19537. communication with the Jami account. This can be used, for example,
  19538. with rendezvous point accounts to create a private video conferencing
  19539. space.
  19540. To put the system administrator in full control of the conferences
  19541. hosted on their system, the Jami service supports the following actions:
  19542. @example sh
  19543. # herd doc jami list-actions
  19544. (list-accounts
  19545. list-account-details
  19546. list-banned-contacts
  19547. list-contacts
  19548. list-moderators
  19549. add-moderator
  19550. ban-contact
  19551. enable-account
  19552. disable-account)
  19553. @end example
  19554. The above actions aim to provide the most valuable actions for
  19555. moderation purposes, not to cover the whole Jami API. Users wanting to
  19556. interact with the Jami daemon from Guile may be interested in
  19557. experimenting with the @code{(gnu build jami-service)} module, which
  19558. powers the above Shepherd actions.
  19559. @c TODO: This should be auto-generated from the doc already defined on
  19560. @c the shepherd-actions themselves in (gnu services telephony).
  19561. The @code{add-moderator} and @code{ban-contact} actions accept a contact
  19562. @emph{fingerprint} (40 characters long hash) as first argument and an
  19563. account fingerprint or username as second argument:
  19564. @example sh
  19565. # herd add-moderator jami 1dbcb0f5f37324228235564b79f2b9737e9a008f \
  19566. f3345f2775ddfe07a4b0d95daea111d15fbc1199
  19567. # herd list-moderators jami
  19568. Moderators for account f3345f2775ddfe07a4b0d95daea111d15fbc1199:
  19569. - 1dbcb0f5f37324228235564b79f2b9737e9a008f
  19570. @end example
  19571. In the case of @code{ban-contact}, the second username argument is
  19572. optional; when omitted, the account is banned from all Jami accounts:
  19573. @example sh
  19574. # herd ban-contact jami 1dbcb0f5f37324228235564b79f2b9737e9a008f
  19575. # herd list-banned-contacts jami
  19576. Banned contacts for account f3345f2775ddfe07a4b0d95daea111d15fbc1199:
  19577. - 1dbcb0f5f37324228235564b79f2b9737e9a008f
  19578. @end example
  19579. Banned contacts are also stripped from their moderation privileges.
  19580. The @code{disable-account} action allows to completely disconnect an
  19581. account from the network, making it unreachable, while
  19582. @code{enable-account} does the inverse. They accept a single account
  19583. username or fingerprint as first argument:
  19584. @example sh
  19585. # herd disable-account jami f3345f2775ddfe07a4b0d95daea111d15fbc1199
  19586. # herd list-accounts jami
  19587. The following Jami accounts are available:
  19588. - f3345f2775ddfe07a4b0d95daea111d15fbc1199 (dummy) [disabled]
  19589. @end example
  19590. The @code{list-account-details} action prints the detailed parameters of
  19591. each accounts in the Recutils format, which means the @command{recsel}
  19592. command can be used to select accounts of interest (@pxref{Selection
  19593. Expressions,,,recutils, GNU recutils manual}). Note that period
  19594. characters (@samp{.}) found in the account parameter keys are mapped to
  19595. underscores (@samp{_}) in the output, to meet the requirements of the
  19596. Recutils format. The following example shows how to print the account
  19597. fingerprints for all accounts operating in the rendezvous point mode:
  19598. @example sh
  19599. # herd list-account-details jami | \
  19600. recsel -p Account.username -e 'Account.rendezVous ~ "true"'
  19601. Account_username: f3345f2775ddfe07a4b0d95daea111d15fbc1199
  19602. @end example
  19603. The remaining actions should be self-explanatory.
  19604. The complete set of available configuration options is detailed below.
  19605. @c TODO: Ideally, the following fragments would be auto-generated at
  19606. @c build time, so that they needn't be manually duplicated.
  19607. @c Auto-generated via (configuration->documentation 'jami-configuration)
  19608. @deftp {Data Type} jami-configuration
  19609. Available @code{jami-configuration} fields are:
  19610. @table @asis
  19611. @item @code{jamid} (default: @code{libjami}) (type: package)
  19612. The Jami daemon package to use.
  19613. @item @code{dbus} (default: @code{dbus}) (type: package)
  19614. The D-Bus package to use to start the required D-Bus session.
  19615. @item @code{nss-certs} (default: @code{nss-certs}) (type: package)
  19616. The nss-certs package to use to provide TLS certificates.
  19617. @item @code{enable-logging?} (default: @code{#t}) (type: boolean)
  19618. Whether to enable logging to syslog.
  19619. @item @code{debug?} (default: @code{#f}) (type: boolean)
  19620. Whether to enable debug level messages.
  19621. @item @code{auto-answer?} (default: @code{#f}) (type: boolean)
  19622. Whether to force automatic answer to incoming calls.
  19623. @item @code{accounts} (default: @code{disabled}) (type: maybe-jami-account-list)
  19624. A list of Jami accounts to be (re-)provisioned every time the Jami
  19625. daemon service starts. When providing this field, the account
  19626. directories under @file{/var/lib/jami/} are recreated every time the
  19627. service starts, ensuring a consistent state.
  19628. @end table
  19629. @end deftp
  19630. @c Auto-generated via (configuration->documentation 'jami-account)
  19631. @deftp {Data Type} jami-account
  19632. Available @code{jami-account} fields are:
  19633. @table @asis
  19634. @item @code{archive} (type: string-or-computed-file)
  19635. The account archive (backup) file name of the account. This is used to
  19636. provision the account when the service starts. The account archive
  19637. should @emph{not} be encrypted. It is highly recommended to make it
  19638. readable only to the @samp{root} user (i.e., not in the store), to guard
  19639. against leaking the secret key material of the Jami account it contains.
  19640. @item @code{allowed-contacts} (default: @code{disabled}) (type: maybe-account-fingerprint-list)
  19641. The list of allowed contacts for the account, entered as their 40
  19642. characters long fingerprint. Messages or calls from accounts not in
  19643. that list will be rejected. When unspecified, the configuration of the
  19644. account archive is used as-is with respect to contacts and public
  19645. inbound calls/messaging allowance, which typically defaults to allow any
  19646. contact to communicate with the account.
  19647. @item @code{moderators} (default: @code{disabled}) (type: maybe-account-fingerprint-list)
  19648. The list of contacts that should have moderation privileges (to ban,
  19649. mute, etc. other users) in rendezvous conferences, entered as their 40
  19650. characters long fingerprint. When unspecified, the configuration of the
  19651. account archive is used as-is with respect to moderation, which
  19652. typically defaults to allow anyone to moderate.
  19653. @item @code{rendezvous-point?} (default: @code{disabled}) (type: maybe-boolean)
  19654. Whether the account should operate in the rendezvous mode. In this
  19655. mode, all the incoming audio/video calls are mixed into a conference.
  19656. When left unspecified, the value from the account archive prevails.
  19657. @item @code{peer-discovery?} (default: @code{disabled}) (type: maybe-boolean)
  19658. Whether peer discovery should be enabled. Peer discovery is used to
  19659. discover other OpenDHT nodes on the local network, which can be useful
  19660. to maintain communication between devices on such network even when the
  19661. connection to the the Internet has been lost. When left unspecified,
  19662. the value from the account archive prevails.
  19663. @item @code{bootstrap-hostnames} (default: @code{disabled}) (type: maybe-string-list)
  19664. A list of hostnames or IPs pointing to OpenDHT nodes, that should be
  19665. used to initially join the OpenDHT network. When left unspecified, the
  19666. value from the account archive prevails.
  19667. @item @code{name-server-uri} (default: @code{disabled}) (type: maybe-string)
  19668. The URI of the name server to use, that can be used to retrieve the
  19669. account fingerprint for a registered username.
  19670. @end table
  19671. @end deftp
  19672. @subsubheading Murmur (VoIP server)
  19673. @cindex Murmur (VoIP server)
  19674. @cindex VoIP server
  19675. This section describes how to set up and run a Murmur server. Murmur is
  19676. the server of the @uref{https://mumble.info, Mumble} voice-over-IP
  19677. (VoIP) suite.
  19678. @deftp {Data Type} murmur-configuration
  19679. The service type for the Murmur server. An example configuration can
  19680. look like this:
  19681. @lisp
  19682. (service murmur-service-type
  19683. (murmur-configuration
  19684. (welcome-text
  19685. "Welcome to this Mumble server running on Guix!")
  19686. (cert-required? #t) ;disallow text password logins
  19687. (ssl-cert "/etc/letsencrypt/live/mumble.example.com/fullchain.pem")
  19688. (ssl-key "/etc/letsencrypt/live/mumble.example.com/privkey.pem")))
  19689. @end lisp
  19690. After reconfiguring your system, you can manually set the murmur @code{SuperUser}
  19691. password with the command that is printed during the activation phase.
  19692. It is recommended to register a normal Mumble user account
  19693. and grant it admin or moderator rights.
  19694. You can use the @code{mumble} client to
  19695. login as new normal user, register yourself, and log out.
  19696. For the next step login with the name @code{SuperUser} use
  19697. the @code{SuperUser} password that you set previously,
  19698. and grant your newly registered mumble user administrator or moderator
  19699. rights and create some channels.
  19700. Available @code{murmur-configuration} fields are:
  19701. @table @asis
  19702. @item @code{package} (default: @code{mumble})
  19703. Package that contains @code{bin/murmurd}.
  19704. @item @code{user} (default: @code{"murmur"})
  19705. User who will run the Murmur server.
  19706. @item @code{group} (default: @code{"murmur"})
  19707. Group of the user who will run the murmur server.
  19708. @item @code{port} (default: @code{64738})
  19709. Port on which the server will listen.
  19710. @item @code{welcome-text} (default: @code{""})
  19711. Welcome text sent to clients when they connect.
  19712. @item @code{server-password} (default: @code{""})
  19713. Password the clients have to enter in order to connect.
  19714. @item @code{max-users} (default: @code{100})
  19715. Maximum of users that can be connected to the server at once.
  19716. @item @code{max-user-bandwidth} (default: @code{#f})
  19717. Maximum voice traffic a user can send per second.
  19718. @item @code{database-file} (default: @code{"/var/lib/murmur/db.sqlite"})
  19719. File name of the sqlite database.
  19720. The service's user will become the owner of the directory.
  19721. @item @code{log-file} (default: @code{"/var/log/murmur/murmur.log"})
  19722. File name of the log file.
  19723. The service's user will become the owner of the directory.
  19724. @item @code{autoban-attempts} (default: @code{10})
  19725. Maximum number of logins a user can make in @code{autoban-timeframe}
  19726. without getting auto banned for @code{autoban-time}.
  19727. @item @code{autoban-timeframe} (default: @code{120})
  19728. Timeframe for autoban in seconds.
  19729. @item @code{autoban-time} (default: @code{300})
  19730. Amount of time in seconds for which a client gets banned
  19731. when violating the autoban limits.
  19732. @item @code{opus-threshold} (default: @code{100})
  19733. Percentage of clients that need to support opus
  19734. before switching over to opus audio codec.
  19735. @item @code{channel-nesting-limit} (default: @code{10})
  19736. How deep channels can be nested at maximum.
  19737. @item @code{channelname-regex} (default: @code{#f})
  19738. A string in form of a Qt regular expression that channel names must conform to.
  19739. @item @code{username-regex} (default: @code{#f})
  19740. A string in form of a Qt regular expression that user names must conform to.
  19741. @item @code{text-message-length} (default: @code{5000})
  19742. Maximum size in bytes that a user can send in one text chat message.
  19743. @item @code{image-message-length} (default: @code{(* 128 1024)})
  19744. Maximum size in bytes that a user can send in one image message.
  19745. @item @code{cert-required?} (default: @code{#f})
  19746. If it is set to @code{#t} clients that use weak password authentication
  19747. will not be accepted. Users must have completed the certificate wizard to join.
  19748. @item @code{remember-channel?} (default: @code{#f})
  19749. Should murmur remember the last channel each user was in when they disconnected
  19750. and put them into the remembered channel when they rejoin.
  19751. @item @code{allow-html?} (default: @code{#f})
  19752. Should html be allowed in text messages, user comments, and channel descriptions.
  19753. @item @code{allow-ping?} (default: @code{#f})
  19754. Setting to true exposes the current user count, the maximum user count, and
  19755. the server's maximum bandwidth per client to unauthenticated users. In the
  19756. Mumble client, this information is shown in the Connect dialog.
  19757. Disabling this setting will prevent public listing of the server.
  19758. @item @code{bonjour?} (default: @code{#f})
  19759. Should the server advertise itself in the local network through the bonjour protocol.
  19760. @item @code{send-version?} (default: @code{#f})
  19761. Should the murmur server version be exposed in ping requests.
  19762. @item @code{log-days} (default: @code{31})
  19763. Murmur also stores logs in the database, which are accessible via RPC.
  19764. The default is 31 days of months, but you can set this setting to 0 to keep logs forever,
  19765. or -1 to disable logging to the database.
  19766. @item @code{obfuscate-ips?} (default: @code{#t})
  19767. Should logged ips be obfuscated to protect the privacy of users.
  19768. @item @code{ssl-cert} (default: @code{#f})
  19769. File name of the SSL/TLS certificate used for encrypted connections.
  19770. @lisp
  19771. (ssl-cert "/etc/letsencrypt/live/example.com/fullchain.pem")
  19772. @end lisp
  19773. @item @code{ssl-key} (default: @code{#f})
  19774. Filepath to the ssl private key used for encrypted connections.
  19775. @lisp
  19776. (ssl-key "/etc/letsencrypt/live/example.com/privkey.pem")
  19777. @end lisp
  19778. @item @code{ssl-dh-params} (default: @code{#f})
  19779. File name of a PEM-encoded file with Diffie-Hellman parameters
  19780. for the SSL/TLS encryption. Alternatively you set it to
  19781. @code{"@@ffdhe2048"}, @code{"@@ffdhe3072"}, @code{"@@ffdhe4096"}, @code{"@@ffdhe6144"}
  19782. or @code{"@@ffdhe8192"} to use bundled parameters from RFC 7919.
  19783. @item @code{ssl-ciphers} (default: @code{#f})
  19784. The @code{ssl-ciphers} option chooses the cipher suites to make available for use
  19785. in SSL/TLS.
  19786. This option is specified using
  19787. @uref{https://www.openssl.org/docs/apps/ciphers.html#CIPHER-LIST-FORMAT,
  19788. OpenSSL cipher list notation}.
  19789. It is recommended that you try your cipher string using 'openssl ciphers <string>'
  19790. before setting it here, to get a feel for which cipher suites you will get.
  19791. After setting this option, it is recommend that you inspect your Murmur log
  19792. to ensure that Murmur is using the cipher suites that you expected it to.
  19793. Note: Changing this option may impact the backwards compatibility of your
  19794. Murmur server, and can remove the ability for older Mumble clients to be able
  19795. to connect to it.
  19796. @item @code{public-registration} (default: @code{#f})
  19797. Must be a @code{<murmur-public-registration-configuration>} record or @code{#f}.
  19798. You can optionally register your server in the public server list that the
  19799. @code{mumble} client shows on startup.
  19800. You cannot register your server if you have set a @code{server-password},
  19801. or set @code{allow-ping} to @code{#f}.
  19802. It might take a few hours until it shows up in the public list.
  19803. @item @code{file} (default: @code{#f})
  19804. Optional alternative override for this configuration.
  19805. @end table
  19806. @end deftp
  19807. @deftp {Data Type} murmur-public-registration-configuration
  19808. Configuration for public registration of a murmur service.
  19809. @table @asis
  19810. @item @code{name}
  19811. This is a display name for your server. Not to be confused with the hostname.
  19812. @item @code{password}
  19813. A password to identify your registration.
  19814. Subsequent updates will need the same password. Don't lose your password.
  19815. @item @code{url}
  19816. This should be a @code{http://} or @code{https://} link to your web
  19817. site.
  19818. @item @code{hostname} (default: @code{#f})
  19819. By default your server will be listed by its IP address.
  19820. If it is set your server will be linked by this host name instead.
  19821. @end table
  19822. @end deftp
  19823. @node File-Sharing Services
  19824. @subsection File-Sharing Services
  19825. The @code{(gnu services file-sharing)} module provides services that
  19826. assist with transferring files over peer-to-peer file-sharing networks.
  19827. @subsubheading Transmission Daemon Service
  19828. @uref{https://transmissionbt.com/, Transmission} is a flexible
  19829. BitTorrent client that offers a variety of graphical and command-line
  19830. interfaces. A @code{transmission-daemon-service-type} service provides
  19831. Transmission's headless variant, @command{transmission-daemon}, as a
  19832. system service, allowing users to share files via BitTorrent even when
  19833. they are not logged in.
  19834. @deffn {Scheme Variable} transmission-daemon-service-type
  19835. The service type for the Transmission Daemon BitTorrent client. Its
  19836. value must be a @code{transmission-daemon-configuration} object as in
  19837. this example:
  19838. @lisp
  19839. (service transmission-daemon-service-type
  19840. (transmission-daemon-configuration
  19841. ;; Restrict access to the RPC ("control") interface
  19842. (rpc-authentication-required? #t)
  19843. (rpc-username "transmission")
  19844. (rpc-password
  19845. (transmission-password-hash
  19846. "transmission" ; desired password
  19847. "uKd1uMs9")) ; arbitrary salt value
  19848. ;; Accept requests from this and other hosts on the
  19849. ;; local network
  19850. (rpc-whitelist-enabled? #t)
  19851. (rpc-whitelist '("::1" "127.0.0.1" "192.168.0.*"))
  19852. ;; Limit bandwidth use during work hours
  19853. (alt-speed-down (* 1024 2)) ; 2 MB/s
  19854. (alt-speed-up 512) ; 512 kB/s
  19855. (alt-speed-time-enabled? #t)
  19856. (alt-speed-time-day 'weekdays)
  19857. (alt-speed-time-begin
  19858. (+ (* 60 8) 30)) ; 8:30 am
  19859. (alt-speed-time-end
  19860. (+ (* 60 (+ 12 5)) 30)))) ; 5:30 pm
  19861. @end lisp
  19862. @end deffn
  19863. Once the service is started, users can interact with the daemon through
  19864. its Web interface (at @code{http://localhost:9091/}) or by using the
  19865. @command{transmission-remote} command-line tool, available in the
  19866. @code{transmission} package. (Emacs users may want to also consider the
  19867. @code{emacs-transmission} package.) Both communicate with the daemon
  19868. through its remote procedure call (RPC) interface, which by default is
  19869. available to all users on the system; you may wish to change this by
  19870. assigning values to the @code{rpc-authentication-required?},
  19871. @code{rpc-username} and @code{rpc-password} settings, as shown in the
  19872. example above and documented further below.
  19873. The value for @code{rpc-password} must be a password hash of the type
  19874. generated and used by Transmission clients. This can be copied verbatim
  19875. from an existing @file{settings.json} file, if another Transmission
  19876. client is already being used. Otherwise, the
  19877. @code{transmission-password-hash} and @code{transmission-random-salt}
  19878. procedures provided by this module can be used to obtain a suitable hash
  19879. value.
  19880. @deffn {Scheme Procedure} transmission-password-hash @var{password} @var{salt}
  19881. Returns a string containing the result of hashing @var{password}
  19882. together with @var{salt}, in the format recognized by Transmission
  19883. clients for their @code{rpc-password} configuration setting.
  19884. @var{salt} must be an eight-character string. The
  19885. @code{transmission-random-salt} procedure can be used to generate a
  19886. suitable salt value at random.
  19887. @end deffn
  19888. @deffn {Scheme Procedure} transmission-random-salt
  19889. Returns a string containing a random, eight-character salt value of the
  19890. type generated and used by Transmission clients, suitable for passing to
  19891. the @code{transmission-password-hash} procedure.
  19892. @end deffn
  19893. These procedures are accessible from within a Guile REPL started with
  19894. the @command{guix repl} command (@pxref{Invoking guix repl}). This is
  19895. useful for obtaining a random salt value to provide as the second
  19896. parameter to `transmission-password-hash`, as in this example session:
  19897. @example
  19898. $ guix repl
  19899. scheme@@(guix-user)> ,use (gnu services file-sharing)
  19900. scheme@@(guix-user)> (transmission-random-salt)
  19901. $1 = "uKd1uMs9"
  19902. @end example
  19903. Alternatively, a complete password hash can generated in a single step:
  19904. @example
  19905. scheme@@(guix-user)> (transmission-password-hash "transmission"
  19906. (transmission-random-salt))
  19907. $2 = "@{c8bbc6d1740cd8dc819a6e25563b67812c1c19c9VtFPfdsX"
  19908. @end example
  19909. The resulting string can be used as-is for the value of
  19910. @code{rpc-password}, allowing the password to be kept hidden even in the
  19911. operating-system configuration.
  19912. Torrent files downloaded by the daemon are directly accessible only to
  19913. users in the ``transmission'' user group, who receive read-only access
  19914. to the directory specified by the @code{download-dir} configuration
  19915. setting (and also the directory specified by @code{incomplete-dir}, if
  19916. @code{incomplete-dir-enabled?} is @code{#t}). Downloaded files can be
  19917. moved to another directory or deleted altogether using
  19918. @command{transmission-remote} with its @code{--move} and
  19919. @code{--remove-and-delete} options.
  19920. If the @code{watch-dir-enabled?} setting is set to @code{#t}, users in
  19921. the ``transmission'' group are able also to place @file{.torrent} files
  19922. in the directory specified by @code{watch-dir} to have the corresponding
  19923. torrents added by the daemon. (The @code{trash-original-torrent-files?}
  19924. setting controls whether the daemon deletes these files after processing
  19925. them.)
  19926. Some of the daemon's configuration settings can be changed temporarily
  19927. by @command{transmission-remote} and similar tools. To undo these
  19928. changes, use the service's @code{reload} action to have the daemon
  19929. reload its settings from disk:
  19930. @example
  19931. # herd reload transmission-daemon
  19932. @end example
  19933. The full set of available configuration settings is defined by the
  19934. @code{transmission-daemon-configuration} data type.
  19935. @deftp {Data Type} transmission-daemon-configuration
  19936. The data type representing configuration settings for Transmission
  19937. Daemon. These correspond directly to the settings recognized by
  19938. Transmission clients in their @file{settings.json} file.
  19939. @end deftp
  19940. @c The following documentation was initially generated by
  19941. @c (generate-transmission-daemon-documentation) in (gnu services
  19942. @c file-sharing). Manually maintained documentation is better, so we
  19943. @c shouldn't hesitate to edit below as needed. However if the change
  19944. @c you want to make to this documentation can be done in an automated
  19945. @c way, it's probably easier to change (generate-documentation) than to
  19946. @c make it below and have to deal with the churn as Transmission Daemon
  19947. @c updates.
  19948. @c %start of fragment
  19949. Available @code{transmission-daemon-configuration} fields are:
  19950. @deftypevr {@code{transmission-daemon-configuration} parameter} package transmission
  19951. The Transmission package to use.
  19952. @end deftypevr
  19953. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer stop-wait-period
  19954. The period, in seconds, to wait when stopping the service for
  19955. @command{transmission-daemon} to exit before killing its process. This
  19956. allows the daemon time to complete its housekeeping and send a final
  19957. update to trackers as it shuts down. On slow hosts, or hosts with a
  19958. slow network connection, this value may need to be increased.
  19959. Defaults to @samp{10}.
  19960. @end deftypevr
  19961. @deftypevr {@code{transmission-daemon-configuration} parameter} string download-dir
  19962. The directory to which torrent files are downloaded.
  19963. Defaults to @samp{"/var/lib/transmission-daemon/downloads"}.
  19964. @end deftypevr
  19965. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean incomplete-dir-enabled?
  19966. If @code{#t}, files will be held in @code{incomplete-dir} while their
  19967. torrent is being downloaded, then moved to @code{download-dir} once the
  19968. torrent is complete. Otherwise, files for all torrents (including those
  19969. still being downloaded) will be placed in @code{download-dir}.
  19970. Defaults to @samp{#f}.
  19971. @end deftypevr
  19972. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-string incomplete-dir
  19973. The directory in which files from incompletely downloaded torrents will
  19974. be held when @code{incomplete-dir-enabled?} is @code{#t}.
  19975. Defaults to @samp{disabled}.
  19976. @end deftypevr
  19977. @deftypevr {@code{transmission-daemon-configuration} parameter} umask umask
  19978. The file mode creation mask used for downloaded files. (See the
  19979. @command{umask} man page for more information.)
  19980. Defaults to @samp{18}.
  19981. @end deftypevr
  19982. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean rename-partial-files?
  19983. When @code{#t}, ``.part'' is appended to the name of partially
  19984. downloaded files.
  19985. Defaults to @samp{#t}.
  19986. @end deftypevr
  19987. @deftypevr {@code{transmission-daemon-configuration} parameter} preallocation-mode preallocation
  19988. The mode by which space should be preallocated for downloaded files, one
  19989. of @code{none}, @code{fast} (or @code{sparse}) and @code{full}.
  19990. Specifying @code{full} will minimize disk fragmentation at a cost to
  19991. file-creation speed.
  19992. Defaults to @samp{fast}.
  19993. @end deftypevr
  19994. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean watch-dir-enabled?
  19995. If @code{#t}, the directory specified by @code{watch-dir} will be
  19996. watched for new @file{.torrent} files and the torrents they describe
  19997. added automatically (and the original files removed, if
  19998. @code{trash-original-torrent-files?} is @code{#t}).
  19999. Defaults to @samp{#f}.
  20000. @end deftypevr
  20001. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-string watch-dir
  20002. The directory to be watched for @file{.torrent} files indicating new
  20003. torrents to be added, when @code{watch-dir-enabled} is @code{#t}.
  20004. Defaults to @samp{disabled}.
  20005. @end deftypevr
  20006. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean trash-original-torrent-files?
  20007. When @code{#t}, @file{.torrent} files will be deleted from the watch
  20008. directory once their torrent has been added (see
  20009. @code{watch-directory-enabled?}).
  20010. Defaults to @samp{#f}.
  20011. @end deftypevr
  20012. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean speed-limit-down-enabled?
  20013. When @code{#t}, the daemon's download speed will be limited to the rate
  20014. specified by @code{speed-limit-down}.
  20015. Defaults to @samp{#f}.
  20016. @end deftypevr
  20017. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer speed-limit-down
  20018. The default global-maximum download speed, in kilobytes per second.
  20019. Defaults to @samp{100}.
  20020. @end deftypevr
  20021. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean speed-limit-up-enabled?
  20022. When @code{#t}, the daemon's upload speed will be limited to the rate
  20023. specified by @code{speed-limit-up}.
  20024. Defaults to @samp{#f}.
  20025. @end deftypevr
  20026. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer speed-limit-up
  20027. The default global-maximum upload speed, in kilobytes per second.
  20028. Defaults to @samp{100}.
  20029. @end deftypevr
  20030. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean alt-speed-enabled?
  20031. When @code{#t}, the alternate speed limits @code{alt-speed-down} and
  20032. @code{alt-speed-up} are used (in place of @code{speed-limit-down} and
  20033. @code{speed-limit-up}, if they are enabled) to constrain the daemon's
  20034. bandwidth usage. This can be scheduled to occur automatically at
  20035. certain times during the week; see @code{alt-speed-time-enabled?}.
  20036. Defaults to @samp{#f}.
  20037. @end deftypevr
  20038. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer alt-speed-down
  20039. The alternate global-maximum download speed, in kilobytes per second.
  20040. Defaults to @samp{50}.
  20041. @end deftypevr
  20042. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer alt-speed-up
  20043. The alternate global-maximum upload speed, in kilobytes per second.
  20044. Defaults to @samp{50}.
  20045. @end deftypevr
  20046. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean alt-speed-time-enabled?
  20047. When @code{#t}, the alternate speed limits @code{alt-speed-down} and
  20048. @code{alt-speed-up} will be enabled automatically during the periods
  20049. specified by @code{alt-speed-time-day}, @code{alt-speed-time-begin} and
  20050. @code{alt-time-speed-end}.
  20051. Defaults to @samp{#f}.
  20052. @end deftypevr
  20053. @deftypevr {@code{transmission-daemon-configuration} parameter} day-list alt-speed-time-day
  20054. The days of the week on which the alternate-speed schedule should be
  20055. used, specified either as a list of days (@code{sunday}, @code{monday},
  20056. and so on) or using one of the symbols @code{weekdays}, @code{weekends}
  20057. or @code{all}.
  20058. Defaults to @samp{all}.
  20059. @end deftypevr
  20060. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer alt-speed-time-begin
  20061. The time of day at which to enable the alternate speed limits, expressed
  20062. as a number of minutes since midnight.
  20063. Defaults to @samp{540}.
  20064. @end deftypevr
  20065. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer alt-speed-time-end
  20066. The time of day at which to disable the alternate speed limits,
  20067. expressed as a number of minutes since midnight.
  20068. Defaults to @samp{1020}.
  20069. @end deftypevr
  20070. @deftypevr {@code{transmission-daemon-configuration} parameter} string bind-address-ipv4
  20071. The IP address at which to listen for peer connections, or ``0.0.0.0''
  20072. to listen at all available IP addresses.
  20073. Defaults to @samp{"0.0.0.0"}.
  20074. @end deftypevr
  20075. @deftypevr {@code{transmission-daemon-configuration} parameter} string bind-address-ipv6
  20076. The IPv6 address at which to listen for peer connections, or ``::'' to
  20077. listen at all available IPv6 addresses.
  20078. Defaults to @samp{"::"}.
  20079. @end deftypevr
  20080. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean peer-port-random-on-start?
  20081. If @code{#t}, when the daemon starts it will select a port at random on
  20082. which to listen for peer connections, from the range specified
  20083. (inclusively) by @code{peer-port-random-low} and
  20084. @code{peer-port-random-high}. Otherwise, it listens on the port
  20085. specified by @code{peer-port}.
  20086. Defaults to @samp{#f}.
  20087. @end deftypevr
  20088. @deftypevr {@code{transmission-daemon-configuration} parameter} port-number peer-port-random-low
  20089. The lowest selectable port number when @code{peer-port-random-on-start?}
  20090. is @code{#t}.
  20091. Defaults to @samp{49152}.
  20092. @end deftypevr
  20093. @deftypevr {@code{transmission-daemon-configuration} parameter} port-number peer-port-random-high
  20094. The highest selectable port number when @code{peer-port-random-on-start}
  20095. is @code{#t}.
  20096. Defaults to @samp{65535}.
  20097. @end deftypevr
  20098. @deftypevr {@code{transmission-daemon-configuration} parameter} port-number peer-port
  20099. The port on which to listen for peer connections when
  20100. @code{peer-port-random-on-start?} is @code{#f}.
  20101. Defaults to @samp{51413}.
  20102. @end deftypevr
  20103. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean port-forwarding-enabled?
  20104. If @code{#t}, the daemon will attempt to configure port-forwarding on an
  20105. upstream gateway automatically using @acronym{UPnP} and
  20106. @acronym{NAT-PMP}.
  20107. Defaults to @samp{#t}.
  20108. @end deftypevr
  20109. @deftypevr {@code{transmission-daemon-configuration} parameter} encryption-mode encryption
  20110. The encryption preference for peer connections, one of
  20111. @code{prefer-unencrypted-connections},
  20112. @code{prefer-encrypted-connections} or
  20113. @code{require-encrypted-connections}.
  20114. Defaults to @samp{prefer-encrypted-connections}.
  20115. @end deftypevr
  20116. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-string peer-congestion-algorithm
  20117. The TCP congestion-control algorithm to use for peer connections,
  20118. specified using a string recognized by the operating system in calls to
  20119. @code{setsockopt} (or set to @code{disabled}, in which case the
  20120. operating-system default is used).
  20121. Note that on GNU/Linux systems, the kernel must be configured to allow
  20122. processes to use a congestion-control algorithm not in the default set;
  20123. otherwise, it will deny these requests with ``Operation not permitted''.
  20124. To see which algorithms are available on your system and which are
  20125. currently permitted for use, look at the contents of the files
  20126. @file{tcp_available_congestion_control} and
  20127. @file{tcp_allowed_congestion_control} in the @file{/proc/sys/net/ipv4}
  20128. directory.
  20129. As an example, to have Transmission Daemon use
  20130. @uref{http://www-ece.rice.edu/networks/TCP-LP/,the TCP Low Priority
  20131. congestion-control algorithm}, you'll need to modify your kernel
  20132. configuration to build in support for the algorithm, then update your
  20133. operating-system configuration to allow its use by adding a
  20134. @code{sysctl-service-type} service (or updating the existing one's
  20135. configuration) with lines like the following:
  20136. @lisp
  20137. (service sysctl-service-type
  20138. (sysctl-configuration
  20139. (settings
  20140. ("net.ipv4.tcp_allowed_congestion_control" .
  20141. "reno cubic lp"))))
  20142. @end lisp
  20143. The Transmission Daemon configuration can then be updated with
  20144. @lisp
  20145. (peer-congestion-algorithm "lp")
  20146. @end lisp
  20147. and the system reconfigured to have the changes take effect.
  20148. Defaults to @samp{disabled}.
  20149. @end deftypevr
  20150. @deftypevr {@code{transmission-daemon-configuration} parameter} tcp-type-of-service peer-socket-tos
  20151. The type of service to request in outgoing @acronym{TCP} packets, one of
  20152. @code{default}, @code{low-cost}, @code{throughput}, @code{low-delay} and
  20153. @code{reliability}.
  20154. Defaults to @samp{default}.
  20155. @end deftypevr
  20156. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer peer-limit-global
  20157. The global limit on the number of connected peers.
  20158. Defaults to @samp{200}.
  20159. @end deftypevr
  20160. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer peer-limit-per-torrent
  20161. The per-torrent limit on the number of connected peers.
  20162. Defaults to @samp{50}.
  20163. @end deftypevr
  20164. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer upload-slots-per-torrent
  20165. The maximum number of peers to which the daemon will upload data
  20166. simultaneously for each torrent.
  20167. Defaults to @samp{14}.
  20168. @end deftypevr
  20169. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer peer-id-ttl-hours
  20170. The maximum lifespan, in hours, of the peer ID associated with each
  20171. public torrent before it is regenerated.
  20172. Defaults to @samp{6}.
  20173. @end deftypevr
  20174. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean blocklist-enabled?
  20175. When @code{#t}, the daemon will ignore peers mentioned in the blocklist
  20176. it has most recently downloaded from @code{blocklist-url}.
  20177. Defaults to @samp{#f}.
  20178. @end deftypevr
  20179. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-string blocklist-url
  20180. The URL of a peer blocklist (in @acronym{P2P}-plaintext or eMule
  20181. @file{.dat} format) to be periodically downloaded and applied when
  20182. @code{blocklist-enabled?} is @code{#t}.
  20183. Defaults to @samp{disabled}.
  20184. @end deftypevr
  20185. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean download-queue-enabled?
  20186. If @code{#t}, the daemon will be limited to downloading at most
  20187. @code{download-queue-size} non-stalled torrents simultaneously.
  20188. Defaults to @samp{#t}.
  20189. @end deftypevr
  20190. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer download-queue-size
  20191. The size of the daemon's download queue, which limits the number of
  20192. non-stalled torrents it will download at any one time when
  20193. @code{download-queue-enabled?} is @code{#t}.
  20194. Defaults to @samp{5}.
  20195. @end deftypevr
  20196. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean seed-queue-enabled?
  20197. If @code{#t}, the daemon will be limited to seeding at most
  20198. @code{seed-queue-size} non-stalled torrents simultaneously.
  20199. Defaults to @samp{#f}.
  20200. @end deftypevr
  20201. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer seed-queue-size
  20202. The size of the daemon's seed queue, which limits the number of
  20203. non-stalled torrents it will seed at any one time when
  20204. @code{seed-queue-enabled?} is @code{#t}.
  20205. Defaults to @samp{10}.
  20206. @end deftypevr
  20207. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean queue-stalled-enabled?
  20208. When @code{#t}, the daemon will consider torrents for which it has not
  20209. shared data in the past @code{queue-stalled-minutes} minutes to be
  20210. stalled and not count them against its @code{download-queue-size} and
  20211. @code{seed-queue-size} limits.
  20212. Defaults to @samp{#t}.
  20213. @end deftypevr
  20214. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer queue-stalled-minutes
  20215. The maximum period, in minutes, a torrent may be idle before it is
  20216. considered to be stalled, when @code{queue-stalled-enabled?} is
  20217. @code{#t}.
  20218. Defaults to @samp{30}.
  20219. @end deftypevr
  20220. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean ratio-limit-enabled?
  20221. When @code{#t}, a torrent being seeded will automatically be paused once
  20222. it reaches the ratio specified by @code{ratio-limit}.
  20223. Defaults to @samp{#f}.
  20224. @end deftypevr
  20225. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-rational ratio-limit
  20226. The ratio at which a torrent being seeded will be paused, when
  20227. @code{ratio-limit-enabled?} is @code{#t}.
  20228. Defaults to @samp{2.0}.
  20229. @end deftypevr
  20230. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean idle-seeding-limit-enabled?
  20231. When @code{#t}, a torrent being seeded will automatically be paused once
  20232. it has been idle for @code{idle-seeding-limit} minutes.
  20233. Defaults to @samp{#f}.
  20234. @end deftypevr
  20235. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer idle-seeding-limit
  20236. The maximum period, in minutes, a torrent being seeded may be idle
  20237. before it is paused, when @code{idle-seeding-limit-enabled?} is
  20238. @code{#t}.
  20239. Defaults to @samp{30}.
  20240. @end deftypevr
  20241. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean dht-enabled?
  20242. Enable @uref{http://bittorrent.org/beps/bep_0005.html,the distributed
  20243. hash table (@acronym{DHT}) protocol}, which supports the use of
  20244. trackerless torrents.
  20245. Defaults to @samp{#t}.
  20246. @end deftypevr
  20247. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean lpd-enabled?
  20248. Enable @uref{https://en.wikipedia.org/wiki/Local_Peer_Discovery,local
  20249. peer discovery} (@acronym{LPD}), which allows the discovery of peers on
  20250. the local network and may reduce the amount of data sent over the public
  20251. Internet.
  20252. Defaults to @samp{#f}.
  20253. @end deftypevr
  20254. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean pex-enabled?
  20255. Enable @uref{https://en.wikipedia.org/wiki/Peer_exchange,peer exchange}
  20256. (@acronym{PEX}), which reduces the daemon's reliance on external
  20257. trackers and may improve its performance.
  20258. Defaults to @samp{#t}.
  20259. @end deftypevr
  20260. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean utp-enabled?
  20261. Enable @uref{http://bittorrent.org/beps/bep_0029.html,the micro
  20262. transport protocol} (@acronym{uTP}), which aims to reduce the impact of
  20263. BitTorrent traffic on other users of the local network while maintaining
  20264. full utilization of the available bandwidth.
  20265. Defaults to @samp{#t}.
  20266. @end deftypevr
  20267. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean rpc-enabled?
  20268. If @code{#t}, enable the remote procedure call (@acronym{RPC})
  20269. interface, which allows remote control of the daemon via its Web
  20270. interface, the @command{transmission-remote} command-line client, and
  20271. similar tools.
  20272. Defaults to @samp{#t}.
  20273. @end deftypevr
  20274. @deftypevr {@code{transmission-daemon-configuration} parameter} string rpc-bind-address
  20275. The IP address at which to listen for @acronym{RPC} connections, or
  20276. ``0.0.0.0'' to listen at all available IP addresses.
  20277. Defaults to @samp{"0.0.0.0"}.
  20278. @end deftypevr
  20279. @deftypevr {@code{transmission-daemon-configuration} parameter} port-number rpc-port
  20280. The port on which to listen for @acronym{RPC} connections.
  20281. Defaults to @samp{9091}.
  20282. @end deftypevr
  20283. @deftypevr {@code{transmission-daemon-configuration} parameter} string rpc-url
  20284. The path prefix to use in the @acronym{RPC}-endpoint @acronym{URL}.
  20285. Defaults to @samp{"/transmission/"}.
  20286. @end deftypevr
  20287. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean rpc-authentication-required?
  20288. When @code{#t}, clients must authenticate (see @code{rpc-username} and
  20289. @code{rpc-password}) when using the @acronym{RPC} interface. Note this
  20290. has the side effect of disabling host-name whitelisting (see
  20291. @code{rpc-host-whitelist-enabled?}.
  20292. Defaults to @samp{#f}.
  20293. @end deftypevr
  20294. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-string rpc-username
  20295. The username required by clients to access the @acronym{RPC} interface
  20296. when @code{rpc-authentication-required?} is @code{#t}.
  20297. Defaults to @samp{disabled}.
  20298. @end deftypevr
  20299. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-transmission-password-hash rpc-password
  20300. The password required by clients to access the @acronym{RPC} interface
  20301. when @code{rpc-authentication-required?} is @code{#t}. This must be
  20302. specified using a password hash in the format recognized by Transmission
  20303. clients, either copied from an existing @file{settings.json} file or
  20304. generated using the @code{transmission-password-hash} procedure.
  20305. Defaults to @samp{disabled}.
  20306. @end deftypevr
  20307. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean rpc-whitelist-enabled?
  20308. When @code{#t}, @acronym{RPC} requests will be accepted only when they
  20309. originate from an address specified in @code{rpc-whitelist}.
  20310. Defaults to @samp{#t}.
  20311. @end deftypevr
  20312. @deftypevr {@code{transmission-daemon-configuration} parameter} string-list rpc-whitelist
  20313. The list of IP and IPv6 addresses from which @acronym{RPC} requests will
  20314. be accepted when @code{rpc-whitelist-enabled?} is @code{#t}. Wildcards
  20315. may be specified using @samp{*}.
  20316. Defaults to @samp{("127.0.0.1" "::1")}.
  20317. @end deftypevr
  20318. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean rpc-host-whitelist-enabled?
  20319. When @code{#t}, @acronym{RPC} requests will be accepted only when they
  20320. are addressed to a host named in @code{rpc-host-whitelist}. Note that
  20321. requests to ``localhost'' or ``localhost.'', or to a numeric address,
  20322. are always accepted regardless of these settings.
  20323. Note also this functionality is disabled when
  20324. @code{rpc-authentication-required?} is @code{#t}.
  20325. Defaults to @samp{#t}.
  20326. @end deftypevr
  20327. @deftypevr {@code{transmission-daemon-configuration} parameter} string-list rpc-host-whitelist
  20328. The list of host names recognized by the @acronym{RPC} server when
  20329. @code{rpc-host-whitelist-enabled?} is @code{#t}.
  20330. Defaults to @samp{()}.
  20331. @end deftypevr
  20332. @deftypevr {@code{transmission-daemon-configuration} parameter} message-level message-level
  20333. The minimum severity level of messages to be logged (to
  20334. @file{/var/log/transmission.log}) by the daemon, one of @code{none} (no
  20335. logging), @code{error}, @code{info} and @code{debug}.
  20336. Defaults to @samp{info}.
  20337. @end deftypevr
  20338. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean start-added-torrents?
  20339. When @code{#t}, torrents are started as soon as they are added;
  20340. otherwise, they are added in ``paused'' state.
  20341. Defaults to @samp{#t}.
  20342. @end deftypevr
  20343. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean script-torrent-done-enabled?
  20344. When @code{#t}, the script specified by
  20345. @code{script-torrent-done-filename} will be invoked each time a torrent
  20346. completes.
  20347. Defaults to @samp{#f}.
  20348. @end deftypevr
  20349. @deftypevr {@code{transmission-daemon-configuration} parameter} maybe-file-object script-torrent-done-filename
  20350. A file name or file-like object specifying a script to run each time a
  20351. torrent completes, when @code{script-torrent-done-enabled?} is
  20352. @code{#t}.
  20353. Defaults to @samp{disabled}.
  20354. @end deftypevr
  20355. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean scrape-paused-torrents-enabled?
  20356. When @code{#t}, the daemon will scrape trackers for a torrent even when
  20357. the torrent is paused.
  20358. Defaults to @samp{#t}.
  20359. @end deftypevr
  20360. @deftypevr {@code{transmission-daemon-configuration} parameter} non-negative-integer cache-size-mb
  20361. The amount of memory, in megabytes, to allocate for the daemon's
  20362. in-memory cache. A larger value may increase performance by reducing
  20363. the frequency of disk I/O.
  20364. Defaults to @samp{4}.
  20365. @end deftypevr
  20366. @deftypevr {@code{transmission-daemon-configuration} parameter} boolean prefetch-enabled?
  20367. When @code{#t}, the daemon will try to improve I/O performance by
  20368. hinting to the operating system which data is likely to be read next
  20369. from disk to satisfy requests from peers.
  20370. Defaults to @samp{#t}.
  20371. @end deftypevr
  20372. @c %end of fragment
  20373. @node Monitoring Services
  20374. @subsection Monitoring Services
  20375. @subsubheading Tailon Service
  20376. @uref{https://tailon.readthedocs.io/, Tailon} is a web application for
  20377. viewing and searching log files.
  20378. The following example will configure the service with default values.
  20379. By default, Tailon can be accessed on port 8080 (@code{http://localhost:8080}).
  20380. @lisp
  20381. (service tailon-service-type)
  20382. @end lisp
  20383. The following example customises more of the Tailon configuration,
  20384. adding @command{sed} to the list of allowed commands.
  20385. @lisp
  20386. (service tailon-service-type
  20387. (tailon-configuration
  20388. (config-file
  20389. (tailon-configuration-file
  20390. (allowed-commands '("tail" "grep" "awk" "sed"))))))
  20391. @end lisp
  20392. @deftp {Data Type} tailon-configuration
  20393. Data type representing the configuration of Tailon.
  20394. This type has the following parameters:
  20395. @table @asis
  20396. @item @code{config-file} (default: @code{(tailon-configuration-file)})
  20397. The configuration file to use for Tailon. This can be set to a
  20398. @dfn{tailon-configuration-file} record value, or any gexp
  20399. (@pxref{G-Expressions}).
  20400. For example, to instead use a local file, the @code{local-file} function
  20401. can be used:
  20402. @lisp
  20403. (service tailon-service-type
  20404. (tailon-configuration
  20405. (config-file (local-file "./my-tailon.conf"))))
  20406. @end lisp
  20407. @item @code{package} (default: @code{tailon})
  20408. The tailon package to use.
  20409. @end table
  20410. @end deftp
  20411. @deftp {Data Type} tailon-configuration-file
  20412. Data type representing the configuration options for Tailon.
  20413. This type has the following parameters:
  20414. @table @asis
  20415. @item @code{files} (default: @code{(list "/var/log")})
  20416. List of files to display. The list can include strings for a single file
  20417. or directory, or a list, where the first item is the name of a
  20418. subsection, and the remaining items are the files or directories in that
  20419. subsection.
  20420. @item @code{bind} (default: @code{"localhost:8080"})
  20421. Address and port to which Tailon should bind on.
  20422. @item @code{relative-root} (default: @code{#f})
  20423. URL path to use for Tailon, set to @code{#f} to not use a path.
  20424. @item @code{allow-transfers?} (default: @code{#t})
  20425. Allow downloading the log files in the web interface.
  20426. @item @code{follow-names?} (default: @code{#t})
  20427. Allow tailing of not-yet existent files.
  20428. @item @code{tail-lines} (default: @code{200})
  20429. Number of lines to read initially from each file.
  20430. @item @code{allowed-commands} (default: @code{(list "tail" "grep" "awk")})
  20431. Commands to allow running. By default, @code{sed} is disabled.
  20432. @item @code{debug?} (default: @code{#f})
  20433. Set @code{debug?} to @code{#t} to show debug messages.
  20434. @item @code{wrap-lines} (default: @code{#t})
  20435. Initial line wrapping state in the web interface. Set to @code{#t} to
  20436. initially wrap lines (the default), or to @code{#f} to initially not
  20437. wrap lines.
  20438. @item @code{http-auth} (default: @code{#f})
  20439. HTTP authentication type to use. Set to @code{#f} to disable
  20440. authentication (the default). Supported values are @code{"digest"} or
  20441. @code{"basic"}.
  20442. @item @code{users} (default: @code{#f})
  20443. If HTTP authentication is enabled (see @code{http-auth}), access will be
  20444. restricted to the credentials provided here. To configure users, use a
  20445. list of pairs, where the first element of the pair is the username, and
  20446. the 2nd element of the pair is the password.
  20447. @lisp
  20448. (tailon-configuration-file
  20449. (http-auth "basic")
  20450. (users '(("user1" . "password1")
  20451. ("user2" . "password2"))))
  20452. @end lisp
  20453. @end table
  20454. @end deftp
  20455. @subsubheading Darkstat Service
  20456. @cindex darkstat
  20457. Darkstat is a packet sniffer that captures network traffic, calculates
  20458. statistics about usage, and serves reports over HTTP.
  20459. @defvar {Scheme Variable} darkstat-service-type
  20460. This is the service type for the
  20461. @uref{https://unix4lyfe.org/darkstat/, darkstat}
  20462. service, its value must be a @code{darkstat-configuration} record as in
  20463. this example:
  20464. @lisp
  20465. (service darkstat-service-type
  20466. (darkstat-configuration
  20467. (interface "eno1")))
  20468. @end lisp
  20469. @end defvar
  20470. @deftp {Data Type} darkstat-configuration
  20471. Data type representing the configuration of @command{darkstat}.
  20472. @table @asis
  20473. @item @code{package} (default: @code{darkstat})
  20474. The darkstat package to use.
  20475. @item @code{interface}
  20476. Capture traffic on the specified network interface.
  20477. @item @code{port} (default: @code{"667"})
  20478. Bind the web interface to the specified port.
  20479. @item @code{bind-address} (default: @code{"127.0.0.1"})
  20480. Bind the web interface to the specified address.
  20481. @item @code{base} (default: @code{"/"})
  20482. Specify the path of the base URL@. This can be useful if
  20483. @command{darkstat} is accessed via a reverse proxy.
  20484. @end table
  20485. @end deftp
  20486. @anchor{prometheus-node-exporter}
  20487. @subsubheading Prometheus Node Exporter Service
  20488. @cindex prometheus-node-exporter
  20489. The Prometheus ``node exporter'' makes hardware and operating system statistics
  20490. provided by the Linux kernel available for the Prometheus monitoring system.
  20491. This service should be deployed on all physical nodes and virtual machines,
  20492. where monitoring these statistics is desirable.
  20493. @defvar {Scheme variable} prometheus-node-exporter-service-type
  20494. This is the service type for the
  20495. @uref{https://github.com/prometheus/node_exporter/, prometheus-node-exporter}
  20496. service, its value must be a @code{prometheus-node-exporter-configuration}.
  20497. @lisp
  20498. (service prometheus-node-exporter-service-type)
  20499. @end lisp
  20500. @end defvar
  20501. @deftp {Data Type} prometheus-node-exporter-configuration
  20502. Data type representing the configuration of @command{node_exporter}.
  20503. @table @asis
  20504. @item @code{package} (default: @code{go-github-com-prometheus-node-exporter})
  20505. The prometheus-node-exporter package to use.
  20506. @item @code{web-listen-address} (default: @code{":9100"})
  20507. Bind the web interface to the specified address.
  20508. @item @code{textfile-directory} (default: @code{"/var/lib/prometheus/node-exporter"})
  20509. This directory can be used to export metrics specific to this machine.
  20510. Files containing metrics in the text format, with the filename ending in
  20511. @code{.prom} should be placed in this directory.
  20512. @item @code{extra-options} (default: @code{'()})
  20513. Extra options to pass to the Prometheus node exporter.
  20514. @end table
  20515. @end deftp
  20516. @subsubheading Zabbix server
  20517. @cindex zabbix zabbix-server
  20518. Zabbix is a high performance monitoring system that can collect data from a
  20519. variety of sources and provide the results in a web-based interface. Alerting
  20520. and reporting is built-in, as well as @dfn{templates} for common operating
  20521. system metrics such as network utilization, CPU load, and disk space consumption.
  20522. This service provides the central Zabbix monitoring service; you also need
  20523. @ref{zabbix-front-end,@code{zabbix-front-end-service-type}} to configure Zabbix
  20524. and display results, and optionally @ref{zabbix-agent,
  20525. @code{zabbix-agent-service-type}} on machines that should be monitored (other
  20526. data sources are supported, such as @ref{prometheus-node-exporter,
  20527. Prometheus Node Exporter}).
  20528. @defvar {Scheme variable} zabbix-server-service-type
  20529. This is the service type for the Zabbix server service. Its value must be a
  20530. @code{zabbix-server-configuration} record, shown below.
  20531. @end defvar
  20532. @c %start of fragment
  20533. @deftp {Data Type} zabbix-server-configuration
  20534. Available @code{zabbix-server-configuration} fields are:
  20535. @table @asis
  20536. @item @code{zabbix-server} (default: @code{zabbix-server}) (type: file-like)
  20537. The zabbix-server package.
  20538. @item @code{user} (default: @code{"zabbix"}) (type: string)
  20539. User who will run the Zabbix server.
  20540. @item @code{group} (default: @code{"zabbix"}) (type: group)
  20541. Group who will run the Zabbix server.
  20542. @item @code{db-host} (default: @code{"127.0.0.1"}) (type: string)
  20543. Database host name.
  20544. @item @code{db-name} (default: @code{"zabbix"}) (type: string)
  20545. Database name.
  20546. @item @code{db-user} (default: @code{"zabbix"}) (type: string)
  20547. Database user.
  20548. @item @code{db-password} (default: @code{""}) (type: string)
  20549. Database password. Please, use @code{include-files} with
  20550. @code{DBPassword=SECRET} inside a specified file instead.
  20551. @item @code{db-port} (default: @code{5432}) (type: number)
  20552. Database port.
  20553. @item @code{log-type} (default: @code{""}) (type: string)
  20554. Specifies where log messages are written to:
  20555. @itemize @bullet
  20556. @item @code{system} - syslog.
  20557. @item @code{file} - file specified with @code{log-file} parameter.
  20558. @item @code{console} - standard output.
  20559. @end itemize
  20560. @item @code{log-file} (default: @code{"/var/log/zabbix/server.log"}) (type: string)
  20561. Log file name for @code{log-type} @code{file} parameter.
  20562. @item @code{pid-file} (default: @code{"/var/run/zabbix/zabbix_server.pid"}) (type: string)
  20563. Name of PID file.
  20564. @item @code{ssl-ca-location} (default: @code{"/etc/ssl/certs/ca-certificates.crt"}) (type: string)
  20565. The location of certificate authority (CA) files for SSL server
  20566. certificate verification.
  20567. @item @code{ssl-cert-location} (default: @code{"/etc/ssl/certs"}) (type: string)
  20568. Location of SSL client certificates.
  20569. @item @code{extra-options} (default: @code{""}) (type: extra-options)
  20570. Extra options will be appended to Zabbix server configuration file.
  20571. @item @code{include-files} (default: @code{()}) (type: include-files)
  20572. You may include individual files or all files in a directory in the
  20573. configuration file.
  20574. @end table
  20575. @end deftp
  20576. @c %end of fragment
  20577. @anchor{zabbix-agent}
  20578. @subsubheading Zabbix agent
  20579. @cindex zabbix zabbix-agent
  20580. The Zabbix agent gathers information about the running system for the Zabbix
  20581. monitoring server. It has a variety of built-in checks, and can be extended
  20582. with custom
  20583. @uref{https://www.zabbix.com/documentation/current/en/manual/config/items/userparameters,
  20584. @dfn{user parameters}}.
  20585. @defvar {Scheme variable} zabbix-agent-service-type
  20586. This is the service type for the Zabbix agent service. Its value must be a
  20587. @code{zabbix-agent-configuration} record, shown below.
  20588. @end defvar
  20589. @c %start of fragment
  20590. @deftp {Data Type} zabbix-agent-configuration
  20591. Available @code{zabbix-agent-configuration} fields are:
  20592. @table @asis
  20593. @item @code{zabbix-agent} (default: @code{zabbix-agentd}) (type: file-like)
  20594. The zabbix-agent package.
  20595. @item @code{user} (default: @code{"zabbix"}) (type: string)
  20596. User who will run the Zabbix agent.
  20597. @item @code{group} (default: @code{"zabbix"}) (type: group)
  20598. Group who will run the Zabbix agent.
  20599. @item @code{hostname} (default: @code{""}) (type: string)
  20600. Unique, case sensitive hostname which is required for active checks and
  20601. must match hostname as configured on the server.
  20602. @item @code{log-type} (default: @code{""}) (type: string)
  20603. Specifies where log messages are written to:
  20604. @itemize @bullet
  20605. @item
  20606. @code{system} - syslog.
  20607. @item @code{file} - file specified with
  20608. @code{log-file} parameter.
  20609. @item @code{console} - standard output.
  20610. @end itemize
  20611. @item @code{log-file} (default: @code{"/var/log/zabbix/agent.log"}) (type: string)
  20612. Log file name for @code{log-type} @code{file} parameter.
  20613. @item @code{pid-file} (default: @code{"/var/run/zabbix/zabbix_agent.pid"}) (type: string)
  20614. Name of PID file.
  20615. @item @code{server} (default: @code{("127.0.0.1")}) (type: list)
  20616. List of IP addresses, optionally in CIDR notation, or hostnames of
  20617. Zabbix servers and Zabbix proxies. Incoming connections will be
  20618. accepted only from the hosts listed here.
  20619. @item @code{server-active} (default: @code{("127.0.0.1")}) (type: list)
  20620. List of IP:port (or hostname:port) pairs of Zabbix servers and Zabbix
  20621. proxies for active checks. If port is not specified, default port is
  20622. used. If this parameter is not specified, active checks are disabled.
  20623. @item @code{extra-options} (default: @code{""}) (type: extra-options)
  20624. Extra options will be appended to Zabbix server configuration file.
  20625. @item @code{include-files} (default: @code{()}) (type: include-files)
  20626. You may include individual files or all files in a directory in the
  20627. configuration file.
  20628. @end table
  20629. @end deftp
  20630. @c %end of fragment
  20631. @anchor{zabbix-front-end}
  20632. @subsubheading Zabbix front-end
  20633. @cindex zabbix zabbix-front-end
  20634. The Zabbix front-end provides a web interface to Zabbix. It does not need
  20635. to run on the same machine as the Zabbix server. This service works by
  20636. extending the @ref{PHP-FPM} and @ref{NGINX} services with the configuration
  20637. necessary for loading the Zabbix user interface.
  20638. @defvar {Scheme variable} zabbix-front-end-service-type
  20639. This is the service type for the Zabbix web frontend. Its value must be a
  20640. @code{zabbix-front-end-configuration} record, shown below.
  20641. @end defvar
  20642. @c %start of fragment
  20643. @deftp {Data Type} zabbix-front-end-configuration
  20644. Available @code{zabbix-front-end-configuration} fields are:
  20645. @table @asis
  20646. @item @code{zabbix-server} (default: @code{zabbix-server}) (type: file-like)
  20647. The Zabbix server package to use.
  20648. @item @code{nginx} (default: @code{()}) (type: list)
  20649. List of @ref{nginx-server-configuration,@code{nginx-server-configuration}}
  20650. blocks for the Zabbix front-end. When empty, a default that listens on
  20651. port 80 is used.
  20652. @item @code{db-host} (default: @code{"localhost"}) (type: string)
  20653. Database host name.
  20654. @item @code{db-port} (default: @code{5432}) (type: number)
  20655. Database port.
  20656. @item @code{db-name} (default: @code{"zabbix"}) (type: string)
  20657. Database name.
  20658. @item @code{db-user} (default: @code{"zabbix"}) (type: string)
  20659. Database user.
  20660. @item @code{db-password} (default: @code{""}) (type: string)
  20661. Database password. Please, use @code{db-secret-file} instead.
  20662. @item @code{db-secret-file} (default: @code{""}) (type: string)
  20663. Secret file which will be appended to @file{zabbix.conf.php} file. This
  20664. file contains credentials for use by Zabbix front-end. You are expected
  20665. to create it manually.
  20666. @item @code{zabbix-host} (default: @code{"localhost"}) (type: string)
  20667. Zabbix server hostname.
  20668. @item @code{zabbix-port} (default: @code{10051}) (type: number)
  20669. Zabbix server port.
  20670. @end table
  20671. @end deftp
  20672. @c %end of fragment
  20673. @node Kerberos Services
  20674. @subsection Kerberos Services
  20675. @cindex Kerberos
  20676. The @code{(gnu services kerberos)} module provides services relating to
  20677. the authentication protocol @dfn{Kerberos}.
  20678. @subsubheading Krb5 Service
  20679. Programs using a Kerberos client library normally
  20680. expect a configuration file in @file{/etc/krb5.conf}.
  20681. This service generates such a file from a definition provided in the
  20682. operating system declaration.
  20683. It does not cause any daemon to be started.
  20684. No ``keytab'' files are provided by this service---you must explicitly create them.
  20685. This service is known to work with the MIT client library, @code{mit-krb5}.
  20686. Other implementations have not been tested.
  20687. @defvr {Scheme Variable} krb5-service-type
  20688. A service type for Kerberos 5 clients.
  20689. @end defvr
  20690. @noindent
  20691. Here is an example of its use:
  20692. @lisp
  20693. (service krb5-service-type
  20694. (krb5-configuration
  20695. (default-realm "EXAMPLE.COM")
  20696. (allow-weak-crypto? #t)
  20697. (realms (list
  20698. (krb5-realm
  20699. (name "EXAMPLE.COM")
  20700. (admin-server "groucho.example.com")
  20701. (kdc "karl.example.com"))
  20702. (krb5-realm
  20703. (name "ARGRX.EDU")
  20704. (admin-server "kerb-admin.argrx.edu")
  20705. (kdc "keys.argrx.edu"))))))
  20706. @end lisp
  20707. @noindent
  20708. This example provides a Kerberos@tie{}5 client configuration which:
  20709. @itemize
  20710. @item Recognizes two realms, @i{viz:} ``EXAMPLE.COM'' and ``ARGRX.EDU'', both
  20711. of which have distinct administration servers and key distribution centers;
  20712. @item Will default to the realm ``EXAMPLE.COM'' if the realm is not explicitly
  20713. specified by clients;
  20714. @item Accepts services which only support encryption types known to be weak.
  20715. @end itemize
  20716. The @code{krb5-realm} and @code{krb5-configuration} types have many fields.
  20717. Only the most commonly used ones are described here.
  20718. For a full list, and more detailed explanation of each, see the MIT
  20719. @uref{https://web.mit.edu/kerberos/krb5-devel/doc/admin/conf_files/krb5_conf.html,,krb5.conf}
  20720. documentation.
  20721. @deftp {Data Type} krb5-realm
  20722. @cindex realm, kerberos
  20723. @table @asis
  20724. @item @code{name}
  20725. This field is a string identifying the name of the realm.
  20726. A common convention is to use the fully qualified DNS name of your organization,
  20727. converted to upper case.
  20728. @item @code{admin-server}
  20729. This field is a string identifying the host where the administration server is
  20730. running.
  20731. @item @code{kdc}
  20732. This field is a string identifying the key distribution center
  20733. for the realm.
  20734. @end table
  20735. @end deftp
  20736. @deftp {Data Type} krb5-configuration
  20737. @table @asis
  20738. @item @code{allow-weak-crypto?} (default: @code{#f})
  20739. If this flag is @code{#t} then services which only offer encryption algorithms
  20740. known to be weak will be accepted.
  20741. @item @code{default-realm} (default: @code{#f})
  20742. This field should be a string identifying the default Kerberos
  20743. realm for the client.
  20744. You should set this field to the name of your Kerberos realm.
  20745. If this value is @code{#f}
  20746. then a realm must be specified with every Kerberos principal when invoking programs
  20747. such as @command{kinit}.
  20748. @item @code{realms}
  20749. This should be a non-empty list of @code{krb5-realm} objects, which clients may
  20750. access.
  20751. Normally, one of them will have a @code{name} field matching the @code{default-realm}
  20752. field.
  20753. @end table
  20754. @end deftp
  20755. @subsubheading PAM krb5 Service
  20756. @cindex pam-krb5
  20757. The @code{pam-krb5} service allows for login authentication and password
  20758. management via Kerberos.
  20759. You will need this service if you want PAM enabled applications to authenticate
  20760. users using Kerberos.
  20761. @defvr {Scheme Variable} pam-krb5-service-type
  20762. A service type for the Kerberos 5 PAM module.
  20763. @end defvr
  20764. @deftp {Data Type} pam-krb5-configuration
  20765. Data type representing the configuration of the Kerberos 5 PAM module.
  20766. This type has the following parameters:
  20767. @table @asis
  20768. @item @code{pam-krb5} (default: @code{pam-krb5})
  20769. The pam-krb5 package to use.
  20770. @item @code{minimum-uid} (default: @code{1000})
  20771. The smallest user ID for which Kerberos authentications should be attempted.
  20772. Local accounts with lower values will silently fail to authenticate.
  20773. @end table
  20774. @end deftp
  20775. @node LDAP Services
  20776. @subsection LDAP Services
  20777. @cindex LDAP
  20778. @cindex nslcd, LDAP service
  20779. The @code{(gnu services authentication)} module provides the
  20780. @code{nslcd-service-type}, which can be used to authenticate against an LDAP
  20781. server. In addition to configuring the service itself, you may want to add
  20782. @code{ldap} as a name service to the Name Service Switch. @xref{Name Service
  20783. Switch} for detailed information.
  20784. Here is a simple operating system declaration with a default configuration of
  20785. the @code{nslcd-service-type} and a Name Service Switch configuration that
  20786. consults the @code{ldap} name service last:
  20787. @lisp
  20788. (use-service-modules authentication)
  20789. (use-modules (gnu system nss))
  20790. ...
  20791. (operating-system
  20792. ...
  20793. (services
  20794. (cons*
  20795. (service nslcd-service-type)
  20796. (service dhcp-client-service-type)
  20797. %base-services))
  20798. (name-service-switch
  20799. (let ((services (list (name-service (name "db"))
  20800. (name-service (name "files"))
  20801. (name-service (name "ldap")))))
  20802. (name-service-switch
  20803. (inherit %mdns-host-lookup-nss)
  20804. (password services)
  20805. (shadow services)
  20806. (group services)
  20807. (netgroup services)
  20808. (gshadow services)))))
  20809. @end lisp
  20810. @c %start of generated documentation for nslcd-configuration
  20811. Available @code{nslcd-configuration} fields are:
  20812. @deftypevr {@code{nslcd-configuration} parameter} package nss-pam-ldapd
  20813. The @code{nss-pam-ldapd} package to use.
  20814. @end deftypevr
  20815. @deftypevr {@code{nslcd-configuration} parameter} maybe-number threads
  20816. The number of threads to start that can handle requests and perform LDAP
  20817. queries. Each thread opens a separate connection to the LDAP server.
  20818. The default is to start 5 threads.
  20819. Defaults to @samp{disabled}.
  20820. @end deftypevr
  20821. @deftypevr {@code{nslcd-configuration} parameter} string uid
  20822. This specifies the user id with which the daemon should be run.
  20823. Defaults to @samp{"nslcd"}.
  20824. @end deftypevr
  20825. @deftypevr {@code{nslcd-configuration} parameter} string gid
  20826. This specifies the group id with which the daemon should be run.
  20827. Defaults to @samp{"nslcd"}.
  20828. @end deftypevr
  20829. @deftypevr {@code{nslcd-configuration} parameter} log-option log
  20830. This option controls the way logging is done via a list containing
  20831. SCHEME and LEVEL@. The SCHEME argument may either be the symbols
  20832. @samp{none} or @samp{syslog}, or an absolute file name. The LEVEL
  20833. argument is optional and specifies the log level. The log level may be
  20834. one of the following symbols: @samp{crit}, @samp{error}, @samp{warning},
  20835. @samp{notice}, @samp{info} or @samp{debug}. All messages with the
  20836. specified log level or higher are logged.
  20837. Defaults to @samp{("/var/log/nslcd" info)}.
  20838. @end deftypevr
  20839. @deftypevr {@code{nslcd-configuration} parameter} list uri
  20840. The list of LDAP server URIs. Normally, only the first server will be
  20841. used with the following servers as fall-back.
  20842. Defaults to @samp{("ldap://localhost:389/")}.
  20843. @end deftypevr
  20844. @deftypevr {@code{nslcd-configuration} parameter} maybe-string ldap-version
  20845. The version of the LDAP protocol to use. The default is to use the
  20846. maximum version supported by the LDAP library.
  20847. Defaults to @samp{disabled}.
  20848. @end deftypevr
  20849. @deftypevr {@code{nslcd-configuration} parameter} maybe-string binddn
  20850. Specifies the distinguished name with which to bind to the directory
  20851. server for lookups. The default is to bind anonymously.
  20852. Defaults to @samp{disabled}.
  20853. @end deftypevr
  20854. @deftypevr {@code{nslcd-configuration} parameter} maybe-string bindpw
  20855. Specifies the credentials with which to bind. This option is only
  20856. applicable when used with binddn.
  20857. Defaults to @samp{disabled}.
  20858. @end deftypevr
  20859. @deftypevr {@code{nslcd-configuration} parameter} maybe-string rootpwmoddn
  20860. Specifies the distinguished name to use when the root user tries to
  20861. modify a user's password using the PAM module.
  20862. Defaults to @samp{disabled}.
  20863. @end deftypevr
  20864. @deftypevr {@code{nslcd-configuration} parameter} maybe-string rootpwmodpw
  20865. Specifies the credentials with which to bind if the root user tries to
  20866. change a user's password. This option is only applicable when used with
  20867. rootpwmoddn
  20868. Defaults to @samp{disabled}.
  20869. @end deftypevr
  20870. @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-mech
  20871. Specifies the SASL mechanism to be used when performing SASL
  20872. authentication.
  20873. Defaults to @samp{disabled}.
  20874. @end deftypevr
  20875. @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-realm
  20876. Specifies the SASL realm to be used when performing SASL authentication.
  20877. Defaults to @samp{disabled}.
  20878. @end deftypevr
  20879. @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-authcid
  20880. Specifies the authentication identity to be used when performing SASL
  20881. authentication.
  20882. Defaults to @samp{disabled}.
  20883. @end deftypevr
  20884. @deftypevr {@code{nslcd-configuration} parameter} maybe-string sasl-authzid
  20885. Specifies the authorization identity to be used when performing SASL
  20886. authentication.
  20887. Defaults to @samp{disabled}.
  20888. @end deftypevr
  20889. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean sasl-canonicalize?
  20890. Determines whether the LDAP server host name should be canonicalised. If
  20891. this is enabled the LDAP library will do a reverse host name lookup. By
  20892. default, it is left up to the LDAP library whether this check is
  20893. performed or not.
  20894. Defaults to @samp{disabled}.
  20895. @end deftypevr
  20896. @deftypevr {@code{nslcd-configuration} parameter} maybe-string krb5-ccname
  20897. Set the name for the GSS-API Kerberos credentials cache.
  20898. Defaults to @samp{disabled}.
  20899. @end deftypevr
  20900. @deftypevr {@code{nslcd-configuration} parameter} string base
  20901. The directory search base.
  20902. Defaults to @samp{"dc=example,dc=com"}.
  20903. @end deftypevr
  20904. @deftypevr {@code{nslcd-configuration} parameter} scope-option scope
  20905. Specifies the search scope (subtree, onelevel, base or children). The
  20906. default scope is subtree; base scope is almost never useful for name
  20907. service lookups; children scope is not supported on all servers.
  20908. Defaults to @samp{(subtree)}.
  20909. @end deftypevr
  20910. @deftypevr {@code{nslcd-configuration} parameter} maybe-deref-option deref
  20911. Specifies the policy for dereferencing aliases. The default policy is
  20912. to never dereference aliases.
  20913. Defaults to @samp{disabled}.
  20914. @end deftypevr
  20915. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean referrals
  20916. Specifies whether automatic referral chasing should be enabled. The
  20917. default behaviour is to chase referrals.
  20918. Defaults to @samp{disabled}.
  20919. @end deftypevr
  20920. @deftypevr {@code{nslcd-configuration} parameter} list-of-map-entries maps
  20921. This option allows for custom attributes to be looked up instead of the
  20922. default RFC 2307 attributes. It is a list of maps, each consisting of
  20923. the name of a map, the RFC 2307 attribute to match and the query
  20924. expression for the attribute as it is available in the directory.
  20925. Defaults to @samp{()}.
  20926. @end deftypevr
  20927. @deftypevr {@code{nslcd-configuration} parameter} list-of-filter-entries filters
  20928. A list of filters consisting of the name of a map to which the filter
  20929. applies and an LDAP search filter expression.
  20930. Defaults to @samp{()}.
  20931. @end deftypevr
  20932. @deftypevr {@code{nslcd-configuration} parameter} maybe-number bind-timelimit
  20933. Specifies the time limit in seconds to use when connecting to the
  20934. directory server. The default value is 10 seconds.
  20935. Defaults to @samp{disabled}.
  20936. @end deftypevr
  20937. @deftypevr {@code{nslcd-configuration} parameter} maybe-number timelimit
  20938. Specifies the time limit (in seconds) to wait for a response from the
  20939. LDAP server. A value of zero, which is the default, is to wait
  20940. indefinitely for searches to be completed.
  20941. Defaults to @samp{disabled}.
  20942. @end deftypevr
  20943. @deftypevr {@code{nslcd-configuration} parameter} maybe-number idle-timelimit
  20944. Specifies the period if inactivity (in seconds) after which the con‐
  20945. nection to the LDAP server will be closed. The default is not to time
  20946. out connections.
  20947. Defaults to @samp{disabled}.
  20948. @end deftypevr
  20949. @deftypevr {@code{nslcd-configuration} parameter} maybe-number reconnect-sleeptime
  20950. Specifies the number of seconds to sleep when connecting to all LDAP
  20951. servers fails. By default one second is waited between the first
  20952. failure and the first retry.
  20953. Defaults to @samp{disabled}.
  20954. @end deftypevr
  20955. @deftypevr {@code{nslcd-configuration} parameter} maybe-number reconnect-retrytime
  20956. Specifies the time after which the LDAP server is considered to be
  20957. permanently unavailable. Once this time is reached retries will be done
  20958. only once per this time period. The default value is 10 seconds.
  20959. Defaults to @samp{disabled}.
  20960. @end deftypevr
  20961. @deftypevr {@code{nslcd-configuration} parameter} maybe-ssl-option ssl
  20962. Specifies whether to use SSL/TLS or not (the default is not to). If
  20963. 'start-tls is specified then StartTLS is used rather than raw LDAP over
  20964. SSL.
  20965. Defaults to @samp{disabled}.
  20966. @end deftypevr
  20967. @deftypevr {@code{nslcd-configuration} parameter} maybe-tls-reqcert-option tls-reqcert
  20968. Specifies what checks to perform on a server-supplied certificate. The
  20969. meaning of the values is described in the ldap.conf(5) manual page.
  20970. Defaults to @samp{disabled}.
  20971. @end deftypevr
  20972. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-cacertdir
  20973. Specifies the directory containing X.509 certificates for peer authen‐
  20974. tication. This parameter is ignored when using GnuTLS.
  20975. Defaults to @samp{disabled}.
  20976. @end deftypevr
  20977. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-cacertfile
  20978. Specifies the path to the X.509 certificate for peer authentication.
  20979. Defaults to @samp{disabled}.
  20980. @end deftypevr
  20981. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-randfile
  20982. Specifies the path to an entropy source. This parameter is ignored when
  20983. using GnuTLS.
  20984. Defaults to @samp{disabled}.
  20985. @end deftypevr
  20986. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-ciphers
  20987. Specifies the ciphers to use for TLS as a string.
  20988. Defaults to @samp{disabled}.
  20989. @end deftypevr
  20990. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-cert
  20991. Specifies the path to the file containing the local certificate for
  20992. client TLS authentication.
  20993. Defaults to @samp{disabled}.
  20994. @end deftypevr
  20995. @deftypevr {@code{nslcd-configuration} parameter} maybe-string tls-key
  20996. Specifies the path to the file containing the private key for client TLS
  20997. authentication.
  20998. Defaults to @samp{disabled}.
  20999. @end deftypevr
  21000. @deftypevr {@code{nslcd-configuration} parameter} maybe-number pagesize
  21001. Set this to a number greater than 0 to request paged results from the
  21002. LDAP server in accordance with RFC2696. The default (0) is to not
  21003. request paged results.
  21004. Defaults to @samp{disabled}.
  21005. @end deftypevr
  21006. @deftypevr {@code{nslcd-configuration} parameter} maybe-ignore-users-option nss-initgroups-ignoreusers
  21007. This option prevents group membership lookups through LDAP for the
  21008. specified users. Alternatively, the value 'all-local may be used. With
  21009. that value nslcd builds a full list of non-LDAP users on startup.
  21010. Defaults to @samp{disabled}.
  21011. @end deftypevr
  21012. @deftypevr {@code{nslcd-configuration} parameter} maybe-number nss-min-uid
  21013. This option ensures that LDAP users with a numeric user id lower than
  21014. the specified value are ignored.
  21015. Defaults to @samp{disabled}.
  21016. @end deftypevr
  21017. @deftypevr {@code{nslcd-configuration} parameter} maybe-number nss-uid-offset
  21018. This option specifies an offset that is added to all LDAP numeric user
  21019. ids. This can be used to avoid user id collisions with local users.
  21020. Defaults to @samp{disabled}.
  21021. @end deftypevr
  21022. @deftypevr {@code{nslcd-configuration} parameter} maybe-number nss-gid-offset
  21023. This option specifies an offset that is added to all LDAP numeric group
  21024. ids. This can be used to avoid user id collisions with local groups.
  21025. Defaults to @samp{disabled}.
  21026. @end deftypevr
  21027. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean nss-nested-groups
  21028. If this option is set, the member attribute of a group may point to
  21029. another group. Members of nested groups are also returned in the higher
  21030. level group and parent groups are returned when finding groups for a
  21031. specific user. The default is not to perform extra searches for nested
  21032. groups.
  21033. Defaults to @samp{disabled}.
  21034. @end deftypevr
  21035. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean nss-getgrent-skipmembers
  21036. If this option is set, the group member list is not retrieved when
  21037. looking up groups. Lookups for finding which groups a user belongs to
  21038. will remain functional so the user will likely still get the correct
  21039. groups assigned on login.
  21040. Defaults to @samp{disabled}.
  21041. @end deftypevr
  21042. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean nss-disable-enumeration
  21043. If this option is set, functions which cause all user/group entries to
  21044. be loaded from the directory will not succeed in doing so. This can
  21045. dramatically reduce LDAP server load in situations where there are a
  21046. great number of users and/or groups. This option is not recommended for
  21047. most configurations.
  21048. Defaults to @samp{disabled}.
  21049. @end deftypevr
  21050. @deftypevr {@code{nslcd-configuration} parameter} maybe-string validnames
  21051. This option can be used to specify how user and group names are verified
  21052. within the system. This pattern is used to check all user and group
  21053. names that are requested and returned from LDAP.
  21054. Defaults to @samp{disabled}.
  21055. @end deftypevr
  21056. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean ignorecase
  21057. This specifies whether or not to perform searches using case-insensitive
  21058. matching. Enabling this could open up the system to authorization
  21059. bypass vulnerabilities and introduce nscd cache poisoning
  21060. vulnerabilities which allow denial of service.
  21061. Defaults to @samp{disabled}.
  21062. @end deftypevr
  21063. @deftypevr {@code{nslcd-configuration} parameter} maybe-boolean pam-authc-ppolicy
  21064. This option specifies whether password policy controls are requested and
  21065. handled from the LDAP server when performing user authentication.
  21066. Defaults to @samp{disabled}.
  21067. @end deftypevr
  21068. @deftypevr {@code{nslcd-configuration} parameter} maybe-string pam-authc-search
  21069. By default nslcd performs an LDAP search with the user's credentials
  21070. after BIND (authentication) to ensure that the BIND operation was
  21071. successful. The default search is a simple check to see if the user's
  21072. DN exists. A search filter can be specified that will be used instead.
  21073. It should return at least one entry.
  21074. Defaults to @samp{disabled}.
  21075. @end deftypevr
  21076. @deftypevr {@code{nslcd-configuration} parameter} maybe-string pam-authz-search
  21077. This option allows flexible fine tuning of the authorisation check that
  21078. should be performed. The search filter specified is executed and if any
  21079. entries match, access is granted, otherwise access is denied.
  21080. Defaults to @samp{disabled}.
  21081. @end deftypevr
  21082. @deftypevr {@code{nslcd-configuration} parameter} maybe-string pam-password-prohibit-message
  21083. If this option is set password modification using pam_ldap will be
  21084. denied and the specified message will be presented to the user instead.
  21085. The message can be used to direct the user to an alternative means of
  21086. changing their password.
  21087. Defaults to @samp{disabled}.
  21088. @end deftypevr
  21089. @deftypevr {@code{nslcd-configuration} parameter} list pam-services
  21090. List of pam service names for which LDAP authentication should suffice.
  21091. Defaults to @samp{()}.
  21092. @end deftypevr
  21093. @c %end of generated documentation for nslcd-configuration
  21094. @node Web Services
  21095. @subsection Web Services
  21096. @cindex web
  21097. @cindex www
  21098. @cindex HTTP
  21099. The @code{(gnu services web)} module provides the Apache HTTP Server,
  21100. the nginx web server, and also a fastcgi wrapper daemon.
  21101. @subsubheading Apache HTTP Server
  21102. @deffn {Scheme Variable} httpd-service-type
  21103. Service type for the @uref{https://httpd.apache.org/,Apache HTTP} server
  21104. (@dfn{httpd}). The value for this service type is a
  21105. @code{httpd-configuration} record.
  21106. A simple example configuration is given below.
  21107. @lisp
  21108. (service httpd-service-type
  21109. (httpd-configuration
  21110. (config
  21111. (httpd-config-file
  21112. (server-name "www.example.com")
  21113. (document-root "/srv/http/www.example.com")))))
  21114. @end lisp
  21115. Other services can also extend the @code{httpd-service-type} to add to
  21116. the configuration.
  21117. @lisp
  21118. (simple-service 'www.example.com-server httpd-service-type
  21119. (list
  21120. (httpd-virtualhost
  21121. "*:80"
  21122. (list (string-join '("ServerName www.example.com"
  21123. "DocumentRoot /srv/http/www.example.com")
  21124. "\n")))))
  21125. @end lisp
  21126. @end deffn
  21127. The details for the @code{httpd-configuration}, @code{httpd-module},
  21128. @code{httpd-config-file} and @code{httpd-virtualhost} record types are
  21129. given below.
  21130. @deffn {Data Type} httpd-configuration
  21131. This data type represents the configuration for the httpd service.
  21132. @table @asis
  21133. @item @code{package} (default: @code{httpd})
  21134. The httpd package to use.
  21135. @item @code{pid-file} (default: @code{"/var/run/httpd"})
  21136. The pid file used by the shepherd-service.
  21137. @item @code{config} (default: @code{(httpd-config-file)})
  21138. The configuration file to use with the httpd service. The default value
  21139. is a @code{httpd-config-file} record, but this can also be a different
  21140. G-expression that generates a file, for example a @code{plain-file}. A
  21141. file outside of the store can also be specified through a string.
  21142. @end table
  21143. @end deffn
  21144. @deffn {Data Type} httpd-module
  21145. This data type represents a module for the httpd service.
  21146. @table @asis
  21147. @item @code{name}
  21148. The name of the module.
  21149. @item @code{file}
  21150. The file for the module. This can be relative to the httpd package being
  21151. used, the absolute location of a file, or a G-expression for a file
  21152. within the store, for example @code{(file-append mod-wsgi
  21153. "/modules/mod_wsgi.so")}.
  21154. @end table
  21155. @end deffn
  21156. @defvr {Scheme Variable} %default-httpd-modules
  21157. A default list of @code{httpd-module} objects.
  21158. @end defvr
  21159. @deffn {Data Type} httpd-config-file
  21160. This data type represents a configuration file for the httpd service.
  21161. @table @asis
  21162. @item @code{modules} (default: @code{%default-httpd-modules})
  21163. The modules to load. Additional modules can be added here, or loaded by
  21164. additional configuration.
  21165. For example, in order to handle requests for PHP files, you can use Apache’s
  21166. @code{mod_proxy_fcgi} module along with @code{php-fpm-service-type}:
  21167. @lisp
  21168. (service httpd-service-type
  21169. (httpd-configuration
  21170. (config
  21171. (httpd-config-file
  21172. (modules (cons*
  21173. (httpd-module
  21174. (name "proxy_module")
  21175. (file "modules/mod_proxy.so"))
  21176. (httpd-module
  21177. (name "proxy_fcgi_module")
  21178. (file "modules/mod_proxy_fcgi.so"))
  21179. %default-httpd-modules))
  21180. (extra-config (list "\
  21181. <FilesMatch \\.php$>
  21182. SetHandler \"proxy:unix:/var/run/php-fpm.sock|fcgi://localhost/\"
  21183. </FilesMatch>"))))))
  21184. (service php-fpm-service-type
  21185. (php-fpm-configuration
  21186. (socket "/var/run/php-fpm.sock")
  21187. (socket-group "httpd")))
  21188. @end lisp
  21189. @item @code{server-root} (default: @code{httpd})
  21190. The @code{ServerRoot} in the configuration file, defaults to the httpd
  21191. package. Directives including @code{Include} and @code{LoadModule} are
  21192. taken as relative to the server root.
  21193. @item @code{server-name} (default: @code{#f})
  21194. The @code{ServerName} in the configuration file, used to specify the
  21195. request scheme, hostname and port that the server uses to identify
  21196. itself.
  21197. This doesn't need to be set in the server config, and can be specified
  21198. in virtual hosts. The default is @code{#f} to not specify a
  21199. @code{ServerName}.
  21200. @item @code{document-root} (default: @code{"/srv/http"})
  21201. The @code{DocumentRoot} from which files will be served.
  21202. @item @code{listen} (default: @code{'("80")})
  21203. The list of values for the @code{Listen} directives in the config
  21204. file. The value should be a list of strings, when each string can
  21205. specify the port number to listen on, and optionally the IP address and
  21206. protocol to use.
  21207. @item @code{pid-file} (default: @code{"/var/run/httpd"})
  21208. The @code{PidFile} to use. This should match the @code{pid-file} set in
  21209. the @code{httpd-configuration} so that the Shepherd service is
  21210. configured correctly.
  21211. @item @code{error-log} (default: @code{"/var/log/httpd/error_log"})
  21212. The @code{ErrorLog} to which the server will log errors.
  21213. @item @code{user} (default: @code{"httpd"})
  21214. The @code{User} which the server will answer requests as.
  21215. @item @code{group} (default: @code{"httpd"})
  21216. The @code{Group} which the server will answer requests as.
  21217. @item @code{extra-config} (default: @code{(list "TypesConfig etc/httpd/mime.types")})
  21218. A flat list of strings and G-expressions which will be added to the end
  21219. of the configuration file.
  21220. Any values which the service is extended with will be appended to this
  21221. list.
  21222. @end table
  21223. @end deffn
  21224. @deffn {Data Type} httpd-virtualhost
  21225. This data type represents a virtualhost configuration block for the httpd service.
  21226. These should be added to the extra-config for the httpd-service.
  21227. @lisp
  21228. (simple-service 'www.example.com-server httpd-service-type
  21229. (list
  21230. (httpd-virtualhost
  21231. "*:80"
  21232. (list (string-join '("ServerName www.example.com"
  21233. "DocumentRoot /srv/http/www.example.com")
  21234. "\n")))))
  21235. @end lisp
  21236. @table @asis
  21237. @item @code{addresses-and-ports}
  21238. The addresses and ports for the @code{VirtualHost} directive.
  21239. @item @code{contents}
  21240. The contents of the @code{VirtualHost} directive, this should be a list
  21241. of strings and G-expressions.
  21242. @end table
  21243. @end deffn
  21244. @anchor{NGINX}
  21245. @subsubheading NGINX
  21246. @deffn {Scheme Variable} nginx-service-type
  21247. Service type for the @uref{https://nginx.org/,NGinx} web server. The
  21248. value for this service type is a @code{<nginx-configuration>} record.
  21249. A simple example configuration is given below.
  21250. @lisp
  21251. (service nginx-service-type
  21252. (nginx-configuration
  21253. (server-blocks
  21254. (list (nginx-server-configuration
  21255. (server-name '("www.example.com"))
  21256. (root "/srv/http/www.example.com"))))))
  21257. @end lisp
  21258. In addition to adding server blocks to the service configuration
  21259. directly, this service can be extended by other services to add server
  21260. blocks, as in this example:
  21261. @lisp
  21262. (simple-service 'my-extra-server nginx-service-type
  21263. (list (nginx-server-configuration
  21264. (root "/srv/http/extra-website")
  21265. (try-files (list "$uri" "$uri/index.html")))))
  21266. @end lisp
  21267. @end deffn
  21268. At startup, @command{nginx} has not yet read its configuration file, so
  21269. it uses a default file to log error messages. If it fails to load its
  21270. configuration file, that is where error messages are logged. After the
  21271. configuration file is loaded, the default error log file changes as per
  21272. configuration. In our case, startup error messages can be found in
  21273. @file{/var/run/nginx/logs/error.log}, and after configuration in
  21274. @file{/var/log/nginx/error.log}. The second location can be changed
  21275. with the @var{log-directory} configuration option.
  21276. @deffn {Data Type} nginx-configuration
  21277. This data type represents the configuration for NGinx. Some
  21278. configuration can be done through this and the other provided record
  21279. types, or alternatively, a config file can be provided.
  21280. @table @asis
  21281. @item @code{nginx} (default: @code{nginx})
  21282. The nginx package to use.
  21283. @item @code{log-directory} (default: @code{"/var/log/nginx"})
  21284. The directory to which NGinx will write log files.
  21285. @item @code{run-directory} (default: @code{"/var/run/nginx"})
  21286. The directory in which NGinx will create a pid file, and write temporary
  21287. files.
  21288. @item @code{server-blocks} (default: @code{'()})
  21289. A list of @dfn{server blocks} to create in the generated configuration
  21290. file, the elements should be of type
  21291. @code{<nginx-server-configuration>}.
  21292. The following example would setup NGinx to serve @code{www.example.com}
  21293. from the @code{/srv/http/www.example.com} directory, without using
  21294. HTTPS.
  21295. @lisp
  21296. (service nginx-service-type
  21297. (nginx-configuration
  21298. (server-blocks
  21299. (list (nginx-server-configuration
  21300. (server-name '("www.example.com"))
  21301. (root "/srv/http/www.example.com"))))))
  21302. @end lisp
  21303. @item @code{upstream-blocks} (default: @code{'()})
  21304. A list of @dfn{upstream blocks} to create in the generated configuration
  21305. file, the elements should be of type
  21306. @code{<nginx-upstream-configuration>}.
  21307. Configuring upstreams through the @code{upstream-blocks} can be useful
  21308. when combined with @code{locations} in the
  21309. @code{<nginx-server-configuration>} records. The following example
  21310. creates a server configuration with one location configuration, that
  21311. will proxy requests to a upstream configuration, which will handle
  21312. requests with two servers.
  21313. @lisp
  21314. (service
  21315. nginx-service-type
  21316. (nginx-configuration
  21317. (server-blocks
  21318. (list (nginx-server-configuration
  21319. (server-name '("www.example.com"))
  21320. (root "/srv/http/www.example.com")
  21321. (locations
  21322. (list
  21323. (nginx-location-configuration
  21324. (uri "/path1")
  21325. (body '("proxy_pass http://server-proxy;"))))))))
  21326. (upstream-blocks
  21327. (list (nginx-upstream-configuration
  21328. (name "server-proxy")
  21329. (servers (list "server1.example.com"
  21330. "server2.example.com")))))))
  21331. @end lisp
  21332. @item @code{file} (default: @code{#f})
  21333. If a configuration @var{file} is provided, this will be used, rather than
  21334. generating a configuration file from the provided @code{log-directory},
  21335. @code{run-directory}, @code{server-blocks} and @code{upstream-blocks}. For
  21336. proper operation, these arguments should match what is in @var{file} to ensure
  21337. that the directories are created when the service is activated.
  21338. This can be useful if you have an existing configuration file, or it's
  21339. not possible to do what is required through the other parts of the
  21340. nginx-configuration record.
  21341. @item @code{server-names-hash-bucket-size} (default: @code{#f})
  21342. Bucket size for the server names hash tables, defaults to @code{#f} to
  21343. use the size of the processors cache line.
  21344. @item @code{server-names-hash-bucket-max-size} (default: @code{#f})
  21345. Maximum bucket size for the server names hash tables.
  21346. @item @code{modules} (default: @code{'()})
  21347. List of nginx dynamic modules to load. This should be a list of file
  21348. names of loadable modules, as in this example:
  21349. @lisp
  21350. (modules
  21351. (list
  21352. (file-append nginx-accept-language-module "\
  21353. /etc/nginx/modules/ngx_http_accept_language_module.so")
  21354. (file-append nginx-lua-module "\
  21355. /etc/nginx/modules/ngx_http_lua_module.so")))
  21356. @end lisp
  21357. @item @code{lua-package-path} (default: @code{'()})
  21358. List of nginx lua packages to load. This should be a list of package
  21359. names of loadable lua modules, as in this example:
  21360. @lisp
  21361. (lua-package-path (list lua-resty-core
  21362. lua-resty-lrucache
  21363. lua-resty-signal
  21364. lua-tablepool
  21365. lua-resty-shell))
  21366. @end lisp
  21367. @item @code{lua-package-cpath} (default: @code{'()})
  21368. List of nginx lua C packages to load. This should be a list of package
  21369. names of loadable lua C modules, as in this example:
  21370. @lisp
  21371. (lua-package-cpath (list lua-resty-signal))
  21372. @end lisp
  21373. @item @code{global-directives} (default: @code{'((events . ()))})
  21374. Association list of global directives for the top level of the nginx
  21375. configuration. Values may themselves be association lists.
  21376. @lisp
  21377. (global-directives
  21378. `((worker_processes . 16)
  21379. (pcre_jit . on)
  21380. (events . ((worker_connections . 1024)))))
  21381. @end lisp
  21382. @item @code{extra-content} (default: @code{""})
  21383. Extra content for the @code{http} block. Should be string or a string
  21384. valued G-expression.
  21385. @end table
  21386. @end deffn
  21387. @anchor{nginx-server-configuration}
  21388. @deftp {Data Type} nginx-server-configuration
  21389. Data type representing the configuration of an nginx server block.
  21390. This type has the following parameters:
  21391. @table @asis
  21392. @item @code{listen} (default: @code{'("80" "443 ssl")})
  21393. Each @code{listen} directive sets the address and port for IP, or the
  21394. path for a UNIX-domain socket on which the server will accept requests.
  21395. Both address and port, or only address or only port can be specified.
  21396. An address may also be a hostname, for example:
  21397. @lisp
  21398. '("127.0.0.1:8000" "127.0.0.1" "8000" "*:8000" "localhost:8000")
  21399. @end lisp
  21400. @item @code{server-name} (default: @code{(list 'default)})
  21401. A list of server names this server represents. @code{'default} represents the
  21402. default server for connections matching no other server.
  21403. @item @code{root} (default: @code{"/srv/http"})
  21404. Root of the website nginx will serve.
  21405. @item @code{locations} (default: @code{'()})
  21406. A list of @dfn{nginx-location-configuration} or
  21407. @dfn{nginx-named-location-configuration} records to use within this
  21408. server block.
  21409. @item @code{index} (default: @code{(list "index.html")})
  21410. Index files to look for when clients ask for a directory. If it cannot be found,
  21411. Nginx will send the list of files in the directory.
  21412. @item @code{try-files} (default: @code{'()})
  21413. A list of files whose existence is checked in the specified order.
  21414. @code{nginx} will use the first file it finds to process the request.
  21415. @item @code{ssl-certificate} (default: @code{#f})
  21416. Where to find the certificate for secure connections. Set it to @code{#f} if
  21417. you don't have a certificate or you don't want to use HTTPS.
  21418. @item @code{ssl-certificate-key} (default: @code{#f})
  21419. Where to find the private key for secure connections. Set it to @code{#f} if
  21420. you don't have a key or you don't want to use HTTPS.
  21421. @item @code{server-tokens?} (default: @code{#f})
  21422. Whether the server should add its configuration to response.
  21423. @item @code{raw-content} (default: @code{'()})
  21424. A list of raw lines added to the server block.
  21425. @end table
  21426. @end deftp
  21427. @deftp {Data Type} nginx-upstream-configuration
  21428. Data type representing the configuration of an nginx @code{upstream}
  21429. block. This type has the following parameters:
  21430. @table @asis
  21431. @item @code{name}
  21432. Name for this group of servers.
  21433. @item @code{servers}
  21434. Specify the addresses of the servers in the group. The address can be
  21435. specified as a IP address (e.g.@: @samp{127.0.0.1}), domain name
  21436. (e.g.@: @samp{backend1.example.com}) or a path to a UNIX socket using the
  21437. prefix @samp{unix:}. For addresses using an IP address or domain name,
  21438. the default port is 80, and a different port can be specified
  21439. explicitly.
  21440. @end table
  21441. @end deftp
  21442. @deftp {Data Type} nginx-location-configuration
  21443. Data type representing the configuration of an nginx @code{location}
  21444. block. This type has the following parameters:
  21445. @table @asis
  21446. @item @code{uri}
  21447. URI which this location block matches.
  21448. @anchor{nginx-location-configuration body}
  21449. @item @code{body}
  21450. Body of the location block, specified as a list of strings. This can contain
  21451. many
  21452. configuration directives. For example, to pass requests to a upstream
  21453. server group defined using an @code{nginx-upstream-configuration} block,
  21454. the following directive would be specified in the body @samp{(list "proxy_pass
  21455. http://upstream-name;")}.
  21456. @end table
  21457. @end deftp
  21458. @deftp {Data Type} nginx-named-location-configuration
  21459. Data type representing the configuration of an nginx named location
  21460. block. Named location blocks are used for request redirection, and not
  21461. used for regular request processing. This type has the following
  21462. parameters:
  21463. @table @asis
  21464. @item @code{name}
  21465. Name to identify this location block.
  21466. @item @code{body}
  21467. @xref{nginx-location-configuration body}, as the body for named location
  21468. blocks can be used in a similar way to the
  21469. @code{nginx-location-configuration body}. One restriction is that the
  21470. body of a named location block cannot contain location blocks.
  21471. @end table
  21472. @end deftp
  21473. @subsubheading Varnish Cache
  21474. @cindex Varnish
  21475. Varnish is a fast cache server that sits in between web applications
  21476. and end users. It proxies requests from clients and caches the
  21477. accessed URLs such that multiple requests for the same resource only
  21478. creates one request to the back-end.
  21479. @defvr {Scheme Variable} varnish-service-type
  21480. Service type for the Varnish daemon.
  21481. @end defvr
  21482. @deftp {Data Type} varnish-configuration
  21483. Data type representing the @code{varnish} service configuration.
  21484. This type has the following parameters:
  21485. @table @asis
  21486. @item @code{package} (default: @code{varnish})
  21487. The Varnish package to use.
  21488. @item @code{name} (default: @code{"default"})
  21489. A name for this Varnish instance. Varnish will create a directory in
  21490. @file{/var/varnish/} with this name and keep temporary files there. If
  21491. the name starts with a forward slash, it is interpreted as an absolute
  21492. directory name.
  21493. Pass the @code{-n} argument to other Varnish programs to connect to the
  21494. named instance, e.g.@: @command{varnishncsa -n default}.
  21495. @item @code{backend} (default: @code{"localhost:8080"})
  21496. The backend to use. This option has no effect if @code{vcl} is set.
  21497. @item @code{vcl} (default: #f)
  21498. The @dfn{VCL} (Varnish Configuration Language) program to run. If this
  21499. is @code{#f}, Varnish will proxy @code{backend} using the default
  21500. configuration. Otherwise this must be a file-like object with valid
  21501. VCL syntax.
  21502. @c Varnish does not support HTTPS, so keep this URL to avoid confusion.
  21503. For example, to mirror @url{https://www.gnu.org,www.gnu.org} with VCL you
  21504. can do something along these lines:
  21505. @lisp
  21506. (define %gnu-mirror
  21507. (plain-file "gnu.vcl"
  21508. "vcl 4.1;
  21509. backend gnu @{ .host = \"www.gnu.org\"; @}"))
  21510. (operating-system
  21511. ;; @dots{}
  21512. (services (cons (service varnish-service-type
  21513. (varnish-configuration
  21514. (listen '(":80"))
  21515. (vcl %gnu-mirror)))
  21516. %base-services)))
  21517. @end lisp
  21518. The configuration of an already running Varnish instance can be inspected
  21519. and changed using the @command{varnishadm} program.
  21520. Consult the @url{https://varnish-cache.org/docs/,Varnish User Guide} and
  21521. @url{https://book.varnish-software.com/4.0/,Varnish Book} for
  21522. comprehensive documentation on Varnish and its configuration language.
  21523. @item @code{listen} (default: @code{'("localhost:80")})
  21524. List of addresses Varnish will listen on.
  21525. @item @code{storage} (default: @code{'("malloc,128m")})
  21526. List of storage backends that will be available in VCL.
  21527. @item @code{parameters} (default: @code{'()})
  21528. List of run-time parameters in the form @code{'(("parameter" . "value"))}.
  21529. @item @code{extra-options} (default: @code{'()})
  21530. Additional arguments to pass to the @command{varnishd} process.
  21531. @end table
  21532. @end deftp
  21533. @subsubheading Patchwork
  21534. @cindex Patchwork
  21535. Patchwork is a patch tracking system. It can collect patches sent to a
  21536. mailing list, and display them in a web interface.
  21537. @defvr {Scheme Variable} patchwork-service-type
  21538. Service type for Patchwork.
  21539. @end defvr
  21540. The following example is an example of a minimal service for Patchwork, for
  21541. the @code{patchwork.example.com} domain.
  21542. @lisp
  21543. (service patchwork-service-type
  21544. (patchwork-configuration
  21545. (domain "patchwork.example.com")
  21546. (settings-module
  21547. (patchwork-settings-module
  21548. (allowed-hosts (list domain))
  21549. (default-from-email "patchwork@@patchwork.example.com")))
  21550. (getmail-retriever-config
  21551. (getmail-retriever-configuration
  21552. (type "SimpleIMAPSSLRetriever")
  21553. (server "imap.example.com")
  21554. (port 993)
  21555. (username "patchwork")
  21556. (password-command
  21557. (list (file-append coreutils "/bin/cat")
  21558. "/etc/getmail-patchwork-imap-password"))
  21559. (extra-parameters
  21560. '((mailboxes . ("Patches"))))))))
  21561. @end lisp
  21562. There are three records for configuring the Patchwork service. The
  21563. @code{<patchwork-configuration>} relates to the configuration for Patchwork
  21564. within the HTTPD service.
  21565. The @code{settings-module} field within the @code{<patchwork-configuration>}
  21566. record can be populated with the @code{<patchwork-settings-module>} record,
  21567. which describes a settings module that is generated within the Guix store.
  21568. For the @code{database-configuration} field within the
  21569. @code{<patchwork-settings-module>}, the
  21570. @code{<patchwork-database-configuration>} must be used.
  21571. @deftp {Data Type} patchwork-configuration
  21572. Data type representing the Patchwork service configuration. This type has the
  21573. following parameters:
  21574. @table @asis
  21575. @item @code{patchwork} (default: @code{patchwork})
  21576. The Patchwork package to use.
  21577. @item @code{domain}
  21578. The domain to use for Patchwork, this is used in the HTTPD service virtual
  21579. host.
  21580. @item @code{settings-module}
  21581. The settings module to use for Patchwork. As a Django application, Patchwork
  21582. is configured with a Python module containing the settings. This can either be
  21583. an instance of the @code{<patchwork-settings-module>} record, any other record
  21584. that represents the settings in the store, or a directory outside of the
  21585. store.
  21586. @item @code{static-path} (default: @code{"/static/"})
  21587. The path under which the HTTPD service should serve the static files.
  21588. @item @code{getmail-retriever-config}
  21589. The getmail-retriever-configuration record value to use with
  21590. Patchwork. Getmail will be configured with this value, the messages will be
  21591. delivered to Patchwork.
  21592. @end table
  21593. @end deftp
  21594. @deftp {Data Type} patchwork-settings-module
  21595. Data type representing a settings module for Patchwork. Some of these
  21596. settings relate directly to Patchwork, but others relate to Django, the web
  21597. framework used by Patchwork, or the Django Rest Framework library. This type
  21598. has the following parameters:
  21599. @table @asis
  21600. @item @code{database-configuration} (default: @code{(patchwork-database-configuration)})
  21601. The database connection settings used for Patchwork. See the
  21602. @code{<patchwork-database-configuration>} record type for more information.
  21603. @item @code{secret-key-file} (default: @code{"/etc/patchwork/django-secret-key"})
  21604. Patchwork, as a Django web application uses a secret key for cryptographically
  21605. signing values. This file should contain a unique unpredictable value.
  21606. If this file does not exist, it will be created and populated with a random
  21607. value by the patchwork-setup shepherd service.
  21608. This setting relates to Django.
  21609. @item @code{allowed-hosts}
  21610. A list of valid hosts for this Patchwork service. This should at least include
  21611. the domain specified in the @code{<patchwork-configuration>} record.
  21612. This is a Django setting.
  21613. @item @code{default-from-email}
  21614. The email address from which Patchwork should send email by default.
  21615. This is a Patchwork setting.
  21616. @item @code{static-url} (default: @code{#f})
  21617. The URL to use when serving static assets. It can be part of a URL, or a full
  21618. URL, but must end in a @code{/}.
  21619. If the default value is used, the @code{static-path} value from the
  21620. @code{<patchwork-configuration>} record will be used.
  21621. This is a Django setting.
  21622. @item @code{admins} (default: @code{'()})
  21623. Email addresses to send the details of errors that occur. Each value should
  21624. be a list containing two elements, the name and then the email address.
  21625. This is a Django setting.
  21626. @item @code{debug?} (default: @code{#f})
  21627. Whether to run Patchwork in debug mode. If set to @code{#t}, detailed error
  21628. messages will be shown.
  21629. This is a Django setting.
  21630. @item @code{enable-rest-api?} (default: @code{#t})
  21631. Whether to enable the Patchwork REST API.
  21632. This is a Patchwork setting.
  21633. @item @code{enable-xmlrpc?} (default: @code{#t})
  21634. Whether to enable the XML RPC API.
  21635. This is a Patchwork setting.
  21636. @item @code{force-https-links?} (default: @code{#t})
  21637. Whether to use HTTPS links on Patchwork pages.
  21638. This is a Patchwork setting.
  21639. @item @code{extra-settings} (default: @code{""})
  21640. Extra code to place at the end of the Patchwork settings module.
  21641. @end table
  21642. @end deftp
  21643. @deftp {Data Type} patchwork-database-configuration
  21644. Data type representing the database configuration for Patchwork.
  21645. @table @asis
  21646. @item @code{engine} (default: @code{"django.db.backends.postgresql_psycopg2"})
  21647. The database engine to use.
  21648. @item @code{name} (default: @code{"patchwork"})
  21649. The name of the database to use.
  21650. @item @code{user} (default: @code{"httpd"})
  21651. The user to connect to the database as.
  21652. @item @code{password} (default: @code{""})
  21653. The password to use when connecting to the database.
  21654. @item @code{host} (default: @code{""})
  21655. The host to make the database connection to.
  21656. @item @code{port} (default: @code{""})
  21657. The port on which to connect to the database.
  21658. @end table
  21659. @end deftp
  21660. @subsubheading Mumi
  21661. @cindex Mumi, Debbugs Web interface
  21662. @cindex Debbugs, Mumi Web interface
  21663. @uref{https://git.elephly.net/gitweb.cgi?p=software/mumi.git, Mumi} is a
  21664. Web interface to the Debbugs bug tracker, by default for
  21665. @uref{https://bugs.gnu.org, the GNU instance}. Mumi is a Web server,
  21666. but it also fetches and indexes mail retrieved from Debbugs.
  21667. @defvr {Scheme Variable} mumi-service-type
  21668. This is the service type for Mumi.
  21669. @end defvr
  21670. @deftp {Data Type} mumi-configuration
  21671. Data type representing the Mumi service configuration. This type has the
  21672. following fields:
  21673. @table @asis
  21674. @item @code{mumi} (default: @code{mumi})
  21675. The Mumi package to use.
  21676. @item @code{mailer?} (default: @code{#true})
  21677. Whether to enable or disable the mailer component.
  21678. @item @code{mumi-configuration-sender}
  21679. The email address used as the sender for comments.
  21680. @item @code{mumi-configuration-smtp}
  21681. A URI to configure the SMTP settings for Mailutils. This could be
  21682. something like @code{sendmail:///path/to/bin/msmtp} or any other URI
  21683. supported by Mailutils. @xref{SMTP Mailboxes, SMTP Mailboxes,,
  21684. mailutils, GNU@tie{}Mailutils}.
  21685. @end table
  21686. @end deftp
  21687. @subsubheading FastCGI
  21688. @cindex fastcgi
  21689. @cindex fcgiwrap
  21690. FastCGI is an interface between the front-end and the back-end of a web
  21691. service. It is a somewhat legacy facility; new web services should
  21692. generally just talk HTTP between the front-end and the back-end.
  21693. However there are a number of back-end services such as PHP or the
  21694. optimized HTTP Git repository access that use FastCGI, so we have
  21695. support for it in Guix.
  21696. To use FastCGI, you configure the front-end web server (e.g., nginx) to
  21697. dispatch some subset of its requests to the fastcgi backend, which
  21698. listens on a local TCP or UNIX socket. There is an intermediary
  21699. @code{fcgiwrap} program that sits between the actual backend process and
  21700. the web server. The front-end indicates which backend program to run,
  21701. passing that information to the @code{fcgiwrap} process.
  21702. @defvr {Scheme Variable} fcgiwrap-service-type
  21703. A service type for the @code{fcgiwrap} FastCGI proxy.
  21704. @end defvr
  21705. @deftp {Data Type} fcgiwrap-configuration
  21706. Data type representing the configuration of the @code{fcgiwrap} service.
  21707. This type has the following parameters:
  21708. @table @asis
  21709. @item @code{package} (default: @code{fcgiwrap})
  21710. The fcgiwrap package to use.
  21711. @item @code{socket} (default: @code{tcp:127.0.0.1:9000})
  21712. The socket on which the @code{fcgiwrap} process should listen, as a
  21713. string. Valid @var{socket} values include
  21714. @code{unix:@var{/path/to/unix/socket}},
  21715. @code{tcp:@var{dot.ted.qu.ad}:@var{port}} and
  21716. @code{tcp6:[@var{ipv6_addr}]:port}.
  21717. @item @code{user} (default: @code{fcgiwrap})
  21718. @itemx @code{group} (default: @code{fcgiwrap})
  21719. The user and group names, as strings, under which to run the
  21720. @code{fcgiwrap} process. The @code{fastcgi} service will ensure that if
  21721. the user asks for the specific user or group names @code{fcgiwrap} that
  21722. the corresponding user and/or group is present on the system.
  21723. It is possible to configure a FastCGI-backed web service to pass HTTP
  21724. authentication information from the front-end to the back-end, and to
  21725. allow @code{fcgiwrap} to run the back-end process as a corresponding
  21726. local user. To enable this capability on the back-end, run
  21727. @code{fcgiwrap} as the @code{root} user and group. Note that this
  21728. capability also has to be configured on the front-end as well.
  21729. @end table
  21730. @end deftp
  21731. @anchor{PHP-FPM}
  21732. @subsubheading PHP-FPM
  21733. @cindex php-fpm
  21734. PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation
  21735. with some additional features useful for sites of any size.
  21736. These features include:
  21737. @itemize @bullet
  21738. @item Adaptive process spawning
  21739. @item Basic statistics (similar to Apache's mod_status)
  21740. @item Advanced process management with graceful stop/start
  21741. @item Ability to start workers with different uid/gid/chroot/environment
  21742. and different php.ini (replaces safe_mode)
  21743. @item Stdout & stderr logging
  21744. @item Emergency restart in case of accidental opcode cache destruction
  21745. @item Accelerated upload support
  21746. @item Support for a "slowlog"
  21747. @item Enhancements to FastCGI, such as fastcgi_finish_request() -
  21748. a special function to finish request & flush all data while continuing to do
  21749. something time-consuming (video converting, stats processing, etc.)
  21750. @end itemize
  21751. ...@: and much more.
  21752. @defvr {Scheme Variable} php-fpm-service-type
  21753. A Service type for @code{php-fpm}.
  21754. @end defvr
  21755. @deftp {Data Type} php-fpm-configuration
  21756. Data Type for php-fpm service configuration.
  21757. @table @asis
  21758. @item @code{php} (default: @code{php})
  21759. The php package to use.
  21760. @item @code{socket} (default: @code{(string-append "/var/run/php" (version-major (package-version php)) "-fpm.sock")})
  21761. The address on which to accept FastCGI requests. Valid syntaxes are:
  21762. @table @asis
  21763. @item @code{"ip.add.re.ss:port"}
  21764. Listen on a TCP socket to a specific address on a specific port.
  21765. @item @code{"port"}
  21766. Listen on a TCP socket to all addresses on a specific port.
  21767. @item @code{"/path/to/unix/socket"}
  21768. Listen on a unix socket.
  21769. @end table
  21770. @item @code{user} (default: @code{php-fpm})
  21771. User who will own the php worker processes.
  21772. @item @code{group} (default: @code{php-fpm})
  21773. Group of the worker processes.
  21774. @item @code{socket-user} (default: @code{php-fpm})
  21775. User who can speak to the php-fpm socket.
  21776. @item @code{socket-group} (default: @code{nginx})
  21777. Group that can speak to the php-fpm socket.
  21778. @item @code{pid-file} (default: @code{(string-append "/var/run/php" (version-major (package-version php)) "-fpm.pid")})
  21779. The process id of the php-fpm process is written to this file
  21780. once the service has started.
  21781. @item @code{log-file} (default: @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.log")})
  21782. Log for the php-fpm master process.
  21783. @item @code{process-manager} (default: @code{(php-fpm-dynamic-process-manager-configuration)})
  21784. Detailed settings for the php-fpm process manager.
  21785. Must be one of:
  21786. @table @asis
  21787. @item @code{<php-fpm-dynamic-process-manager-configuration>}
  21788. @item @code{<php-fpm-static-process-manager-configuration>}
  21789. @item @code{<php-fpm-on-demand-process-manager-configuration>}
  21790. @end table
  21791. @item @code{display-errors} (default @code{#f})
  21792. Determines whether php errors and warning should be sent to clients
  21793. and displayed in their browsers.
  21794. This is useful for local php development, but a security risk for public sites,
  21795. as error messages can reveal passwords and personal data.
  21796. @item @code{timezone} (default @code{#f})
  21797. Specifies @code{php_admin_value[date.timezone]} parameter.
  21798. @item @code{workers-logfile} (default @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.www.log")})
  21799. This file will log the @code{stderr} outputs of php worker processes.
  21800. Can be set to @code{#f} to disable logging.
  21801. @item @code{file} (default @code{#f})
  21802. An optional override of the whole configuration.
  21803. You can use the @code{mixed-text-file} function or an absolute filepath for it.
  21804. @item @code{php-ini-file} (default @code{#f})
  21805. An optional override of the default php settings.
  21806. It may be any ``file-like'' object (@pxref{G-Expressions, file-like objects}).
  21807. You can use the @code{mixed-text-file} function or an absolute filepath for it.
  21808. For local development it is useful to set a higher timeout and memory
  21809. limit for spawned php processes. This be accomplished with the
  21810. following operating system configuration snippet:
  21811. @lisp
  21812. (define %local-php-ini
  21813. (plain-file "php.ini"
  21814. "memory_limit = 2G
  21815. max_execution_time = 1800"))
  21816. (operating-system
  21817. ;; @dots{}
  21818. (services (cons (service php-fpm-service-type
  21819. (php-fpm-configuration
  21820. (php-ini-file %local-php-ini)))
  21821. %base-services)))
  21822. @end lisp
  21823. Consult the @url{https://www.php.net/manual/en/ini.core.php,core php.ini
  21824. directives} for comprehensive documentation on the acceptable
  21825. @file{php.ini} directives.
  21826. @end table
  21827. @end deftp
  21828. @deftp {Data type} php-fpm-dynamic-process-manager-configuration
  21829. Data Type for the @code{dynamic} php-fpm process manager. With the
  21830. @code{dynamic} process manager, spare worker processes are kept around
  21831. based on its configured limits.
  21832. @table @asis
  21833. @item @code{max-children} (default: @code{5})
  21834. Maximum of worker processes.
  21835. @item @code{start-servers} (default: @code{2})
  21836. How many worker processes should be started on start-up.
  21837. @item @code{min-spare-servers} (default: @code{1})
  21838. How many spare worker processes should be kept around at minimum.
  21839. @item @code{max-spare-servers} (default: @code{3})
  21840. How many spare worker processes should be kept around at maximum.
  21841. @end table
  21842. @end deftp
  21843. @deftp {Data type} php-fpm-static-process-manager-configuration
  21844. Data Type for the @code{static} php-fpm process manager. With the
  21845. @code{static} process manager, an unchanging number of worker processes
  21846. are created.
  21847. @table @asis
  21848. @item @code{max-children} (default: @code{5})
  21849. Maximum of worker processes.
  21850. @end table
  21851. @end deftp
  21852. @deftp {Data type} php-fpm-on-demand-process-manager-configuration
  21853. Data Type for the @code{on-demand} php-fpm process manager. With the
  21854. @code{on-demand} process manager, worker processes are only created as
  21855. requests arrive.
  21856. @table @asis
  21857. @item @code{max-children} (default: @code{5})
  21858. Maximum of worker processes.
  21859. @item @code{process-idle-timeout} (default: @code{10})
  21860. The time in seconds after which a process with no requests is killed.
  21861. @end table
  21862. @end deftp
  21863. @deffn {Scheme Procedure} nginx-php-location @
  21864. [#:nginx-package nginx] @
  21865. [socket (string-append "/var/run/php" @
  21866. (version-major (package-version php)) @
  21867. "-fpm.sock")]
  21868. A helper function to quickly add php to an @code{nginx-server-configuration}.
  21869. @end deffn
  21870. A simple services setup for nginx with php can look like this:
  21871. @lisp
  21872. (services (cons* (service dhcp-client-service-type)
  21873. (service php-fpm-service-type)
  21874. (service nginx-service-type
  21875. (nginx-server-configuration
  21876. (server-name '("example.com"))
  21877. (root "/srv/http/")
  21878. (locations
  21879. (list (nginx-php-location)))
  21880. (listen '("80"))
  21881. (ssl-certificate #f)
  21882. (ssl-certificate-key #f)))
  21883. %base-services))
  21884. @end lisp
  21885. @cindex cat-avatar-generator
  21886. The cat avatar generator is a simple service to demonstrate the use of php-fpm
  21887. in @code{Nginx}. It is used to generate cat avatar from a seed, for instance
  21888. the hash of a user's email address.
  21889. @deffn {Scheme Procedure} cat-avatar-generator-service @
  21890. [#:cache-dir "/var/cache/cat-avatar-generator"] @
  21891. [#:package cat-avatar-generator] @
  21892. [#:configuration (nginx-server-configuration)]
  21893. Returns an nginx-server-configuration that inherits @code{configuration}. It
  21894. extends the nginx configuration to add a server block that serves @code{package},
  21895. a version of cat-avatar-generator. During execution, cat-avatar-generator will
  21896. be able to use @code{cache-dir} as its cache directory.
  21897. @end deffn
  21898. A simple setup for cat-avatar-generator can look like this:
  21899. @lisp
  21900. (services (cons* (cat-avatar-generator-service
  21901. #:configuration
  21902. (nginx-server-configuration
  21903. (server-name '("example.com"))))
  21904. ...
  21905. %base-services))
  21906. @end lisp
  21907. @subsubheading Hpcguix-web
  21908. @cindex hpcguix-web
  21909. The @uref{https://github.com/UMCUGenetics/hpcguix-web/, hpcguix-web}
  21910. program is a customizable web interface to browse Guix packages,
  21911. initially designed for users of high-performance computing (HPC)
  21912. clusters.
  21913. @defvr {Scheme Variable} hpcguix-web-service-type
  21914. The service type for @code{hpcguix-web}.
  21915. @end defvr
  21916. @deftp {Data Type} hpcguix-web-configuration
  21917. Data type for the hpcguix-web service configuration.
  21918. @table @asis
  21919. @item @code{specs}
  21920. A gexp (@pxref{G-Expressions}) specifying the hpcguix-web service
  21921. configuration. The main items available in this spec are:
  21922. @table @asis
  21923. @item @code{title-prefix} (default: @code{"hpcguix | "})
  21924. The page title prefix.
  21925. @item @code{guix-command} (default: @code{"guix"})
  21926. The @command{guix} command.
  21927. @item @code{package-filter-proc} (default: @code{(const #t)})
  21928. A procedure specifying how to filter packages that are displayed.
  21929. @item @code{package-page-extension-proc} (default: @code{(const '())})
  21930. Extension package for @code{hpcguix-web}.
  21931. @item @code{menu} (default: @code{'()})
  21932. Additional entry in page @code{menu}.
  21933. @item @code{channels} (default: @code{%default-channels})
  21934. List of channels from which the package list is built (@pxref{Channels}).
  21935. @item @code{package-list-expiration} (default: @code{(* 12 3600)})
  21936. The expiration time, in seconds, after which the package list is rebuilt from
  21937. the latest instances of the given channels.
  21938. @end table
  21939. See the hpcguix-web repository for a
  21940. @uref{https://github.com/UMCUGenetics/hpcguix-web/blob/master/hpcweb-configuration.scm,
  21941. complete example}.
  21942. @item @code{package} (default: @code{hpcguix-web})
  21943. The hpcguix-web package to use.
  21944. @item @code{address} (default: @code{"127.0.0.1"})
  21945. The IP address to listen to.
  21946. @item @code{port} (default: @code{5000})
  21947. The port number to listen to.
  21948. @end table
  21949. @end deftp
  21950. A typical hpcguix-web service declaration looks like this:
  21951. @lisp
  21952. (service hpcguix-web-service-type
  21953. (hpcguix-web-configuration
  21954. (specs
  21955. #~(define site-config
  21956. (hpcweb-configuration
  21957. (title-prefix "Guix-HPC - ")
  21958. (menu '(("/about" "ABOUT"))))))))
  21959. @end lisp
  21960. @quotation Note
  21961. The hpcguix-web service periodically updates the package list it publishes by
  21962. pulling channels from Git. To that end, it needs to access X.509 certificates
  21963. so that it can authenticate Git servers when communicating over HTTPS, and it
  21964. assumes that @file{/etc/ssl/certs} contains those certificates.
  21965. Thus, make sure to add @code{nss-certs} or another certificate package to the
  21966. @code{packages} field of your configuration. @ref{X.509 Certificates}, for
  21967. more information on X.509 certificates.
  21968. @end quotation
  21969. @subsubheading gmnisrv
  21970. @cindex gmnisrv
  21971. The @uref{https://git.sr.ht/~sircmpwn/gmnisrv, gmnisrv} program is a
  21972. simple @uref{https://gemini.circumlunar.space/, Gemini} protocol server.
  21973. @deffn {Scheme Variable} gmnisrv-service-type
  21974. This is the type of the gmnisrv service, whose value should be a
  21975. @code{gmnisrv-configuration} object, as in this example:
  21976. @lisp
  21977. (service gmnisrv-service-type
  21978. (gmnisrv-configuration
  21979. (config-file (local-file "./my-gmnisrv.ini"))))
  21980. @end lisp
  21981. @end deffn
  21982. @deftp {Data Type} gmnisrv-configuration
  21983. Data type representing the configuration of gmnisrv.
  21984. @table @asis
  21985. @item @code{package} (default: @var{gmnisrv})
  21986. Package object of the gmnisrv server.
  21987. @item @code{config-file} (default: @code{%default-gmnisrv-config-file})
  21988. File-like object of the gmnisrv configuration file to use. The default
  21989. configuration listens on port 1965 and serves files from
  21990. @file{/srv/gemini}. Certificates are stored in
  21991. @file{/var/lib/gemini/certs}. For more information, run @command{man
  21992. gmnisrv} and @command{man gmnisrv.ini}.
  21993. @end table
  21994. @end deftp
  21995. @subsubheading Agate
  21996. @cindex agate
  21997. The @uref{gemini://qwertqwefsday.eu/agate.gmi, Agate}
  21998. (@uref{https://github.com/mbrubeck/agate, GitHub page over HTTPS})
  21999. program is a simple @uref{https://gemini.circumlunar.space/, Gemini}
  22000. protocol server written in Rust.
  22001. @deffn {Scheme Variable} agate-service-type
  22002. This is the type of the agate service, whose value should be an
  22003. @code{agate-service-type} object, as in this example:
  22004. @lisp
  22005. (service agate-service-type
  22006. (agate-configuration
  22007. (content "/srv/gemini")
  22008. (cert "/srv/cert.pem")
  22009. (key "/srv/key.rsa")))
  22010. @end lisp
  22011. The example above represents the minimal tweaking necessary to get Agate
  22012. up and running. Specifying the path to the certificate and key is
  22013. always necessary, as the Gemini protocol requires TLS by default.
  22014. To obtain a certificate and a key, you could, for example, use OpenSSL,
  22015. running a command similar to the following example:
  22016. @example
  22017. openssl req -x509 -newkey rsa:4096 -keyout key.rsa -out cert.pem \
  22018. -days 3650 -nodes -subj "/CN=example.com"
  22019. @end example
  22020. Of course, you'll have to replace @i{example.com} with your own domain
  22021. name, and then point the Agate configuration towards the path of the
  22022. generated key and certificate.
  22023. @end deffn
  22024. @deftp {Data Type} agate-configuration
  22025. Data type representing the configuration of Agate.
  22026. @table @asis
  22027. @item @code{package} (default: @code{agate})
  22028. The package object of the Agate server.
  22029. @item @code{content} (default: @file{"/srv/gemini"})
  22030. The directory from which Agate will serve files.
  22031. @item @code{cert} (default: @code{#f})
  22032. The path to the TLS certificate PEM file to be used for encrypted
  22033. connections. Must be filled in with a value from the user.
  22034. @item @code{key} (default: @code{#f})
  22035. The path to the PKCS8 private key file to be used for encrypted
  22036. connections. Must be filled in with a value from the user.
  22037. @item @code{addr} (default: @code{'("0.0.0.0:1965" "[::]:1965")})
  22038. A list of the addresses to listen on.
  22039. @item @code{hostname} (default: @code{#f})
  22040. The domain name of this Gemini server. Optional.
  22041. @item @code{lang} (default: @code{#f})
  22042. RFC 4646 language code(s) for text/gemini documents. Optional.
  22043. @item @code{silent?} (default: @code{#f})
  22044. Set to @code{#t} to disable logging output.
  22045. @item @code{serve-secret?} (default: @code{#f})
  22046. Set to @code{#t} to serve secret files (files/directories starting with
  22047. a dot).
  22048. @item @code{log-ip?} (default: @code{#t})
  22049. Whether or not to output IP addresses when logging.
  22050. @item @code{user} (default: @code{"agate"})
  22051. Owner of the @code{agate} process.
  22052. @item @code{group} (default: @code{"agate"})
  22053. Owner's group of the @code{agate} process.
  22054. @item @code{log-file} (default: @file{"/var/log/agate.log"})
  22055. The file which should store the logging output of Agate.
  22056. @end table
  22057. @end deftp
  22058. @node Certificate Services
  22059. @subsection Certificate Services
  22060. @cindex Web
  22061. @cindex HTTP, HTTPS
  22062. @cindex Let's Encrypt
  22063. @cindex TLS certificates
  22064. The @code{(gnu services certbot)} module provides a service to
  22065. automatically obtain a valid TLS certificate from the Let's Encrypt
  22066. certificate authority. These certificates can then be used to serve
  22067. content securely over HTTPS or other TLS-based protocols, with the
  22068. knowledge that the client will be able to verify the server's
  22069. authenticity.
  22070. @url{https://letsencrypt.org/, Let's Encrypt} provides the
  22071. @code{certbot} tool to automate the certification process. This tool
  22072. first securely generates a key on the server. It then makes a request
  22073. to the Let's Encrypt certificate authority (CA) to sign the key. The CA
  22074. checks that the request originates from the host in question by using a
  22075. challenge-response protocol, requiring the server to provide its
  22076. response over HTTP@. If that protocol completes successfully, the CA
  22077. signs the key, resulting in a certificate. That certificate is valid
  22078. for a limited period of time, and therefore to continue to provide TLS
  22079. services, the server needs to periodically ask the CA to renew its
  22080. signature.
  22081. The certbot service automates this process: the initial key
  22082. generation, the initial certification request to the Let's Encrypt
  22083. service, the web server challenge/response integration, writing the
  22084. certificate to disk, the automated periodic renewals, and the deployment
  22085. tasks associated with the renewal (e.g.@: reloading services, copying keys
  22086. with different permissions).
  22087. Certbot is run twice a day, at a random minute within the hour. It
  22088. won't do anything until your certificates are due for renewal or
  22089. revoked, but running it regularly would give your service a chance of
  22090. staying online in case a Let's Encrypt-initiated revocation happened for
  22091. some reason.
  22092. By using this service, you agree to the ACME Subscriber Agreement, which
  22093. can be found there:
  22094. @url{https://acme-v01.api.letsencrypt.org/directory}.
  22095. @defvr {Scheme Variable} certbot-service-type
  22096. A service type for the @code{certbot} Let's Encrypt client. Its value
  22097. must be a @code{certbot-configuration} record as in this example:
  22098. @lisp
  22099. (define %nginx-deploy-hook
  22100. (program-file
  22101. "nginx-deploy-hook"
  22102. #~(let ((pid (call-with-input-file "/var/run/nginx/pid" read)))
  22103. (kill pid SIGHUP))))
  22104. (service certbot-service-type
  22105. (certbot-configuration
  22106. (email "foo@@example.net")
  22107. (certificates
  22108. (list
  22109. (certificate-configuration
  22110. (domains '("example.net" "www.example.net"))
  22111. (deploy-hook %nginx-deploy-hook))
  22112. (certificate-configuration
  22113. (domains '("bar.example.net")))))))
  22114. @end lisp
  22115. See below for details about @code{certbot-configuration}.
  22116. @end defvr
  22117. @deftp {Data Type} certbot-configuration
  22118. Data type representing the configuration of the @code{certbot} service.
  22119. This type has the following parameters:
  22120. @table @asis
  22121. @item @code{package} (default: @code{certbot})
  22122. The certbot package to use.
  22123. @item @code{webroot} (default: @code{/var/www})
  22124. The directory from which to serve the Let's Encrypt challenge/response
  22125. files.
  22126. @item @code{certificates} (default: @code{()})
  22127. A list of @code{certificates-configuration}s for which to generate
  22128. certificates and request signatures. Each certificate has a @code{name}
  22129. and several @code{domains}.
  22130. @item @code{email} (default: @code{#f})
  22131. Optional email address used for registration and recovery contact.
  22132. Setting this is encouraged as it allows you to receive important
  22133. notifications about the account and issued certificates.
  22134. @item @code{server} (default: @code{#f})
  22135. Optional URL of ACME server. Setting this overrides certbot's default,
  22136. which is the Let's Encrypt server.
  22137. @item @code{rsa-key-size} (default: @code{2048})
  22138. Size of the RSA key.
  22139. @item @code{default-location} (default: @i{see below})
  22140. The default @code{nginx-location-configuration}. Because @code{certbot}
  22141. needs to be able to serve challenges and responses, it needs to be able
  22142. to run a web server. It does so by extending the @code{nginx} web
  22143. service with an @code{nginx-server-configuration} listening on the
  22144. @var{domains} on port 80, and which has a
  22145. @code{nginx-location-configuration} for the @code{/.well-known/} URI
  22146. path subspace used by Let's Encrypt. @xref{Web Services}, for more on
  22147. these nginx configuration data types.
  22148. Requests to other URL paths will be matched by the
  22149. @code{default-location}, which if present is added to all
  22150. @code{nginx-server-configuration}s.
  22151. By default, the @code{default-location} will issue a redirect from
  22152. @code{http://@var{domain}/...} to @code{https://@var{domain}/...}, leaving
  22153. you to define what to serve on your site via @code{https}.
  22154. Pass @code{#f} to not issue a default location.
  22155. @end table
  22156. @end deftp
  22157. @deftp {Data Type} certificate-configuration
  22158. Data type representing the configuration of a certificate.
  22159. This type has the following parameters:
  22160. @table @asis
  22161. @item @code{name} (default: @i{see below})
  22162. This name is used by Certbot for housekeeping and in file paths; it
  22163. doesn't affect the content of the certificate itself. To see
  22164. certificate names, run @code{certbot certificates}.
  22165. Its default is the first provided domain.
  22166. @item @code{domains} (default: @code{()})
  22167. The first domain provided will be the subject CN of the certificate, and
  22168. all domains will be Subject Alternative Names on the certificate.
  22169. @item @code{challenge} (default: @code{#f})
  22170. The challenge type that has to be run by certbot. If @code{#f} is specified,
  22171. default to the HTTP challenge. If a value is specified, defaults to the
  22172. manual plugin (see @code{authentication-hook}, @code{cleanup-hook} and
  22173. the documentation at @url{https://certbot.eff.org/docs/using.html#hooks}),
  22174. and gives Let's Encrypt permission to log the public IP address of the
  22175. requesting machine.
  22176. @item @code{csr} (default: @code{#f})
  22177. File name of Certificate Signing Request (CSR) in DER or PEM format.
  22178. If @code{#f} is specified, this argument will not be passed to certbot.
  22179. If a value is specified, certbot will use it to obtain a certificate, instead of
  22180. using a self-generated CSR.
  22181. The domain-name(s) mentioned in @code{domains}, must be consistent with the
  22182. domain-name(s) mentioned in CSR file.
  22183. @item @code{authentication-hook} (default: @code{#f})
  22184. Command to be run in a shell once for each certificate challenge to be
  22185. answered. For this command, the shell variable @code{$CERTBOT_DOMAIN}
  22186. will contain the domain being authenticated, @code{$CERTBOT_VALIDATION}
  22187. contains the validation string and @code{$CERTBOT_TOKEN} contains the
  22188. file name of the resource requested when performing an HTTP-01 challenge.
  22189. @item @code{cleanup-hook} (default: @code{#f})
  22190. Command to be run in a shell once for each certificate challenge that
  22191. have been answered by the @code{auth-hook}. For this command, the shell
  22192. variables available in the @code{auth-hook} script are still available, and
  22193. additionally @code{$CERTBOT_AUTH_OUTPUT} will contain the standard output
  22194. of the @code{auth-hook} script.
  22195. @item @code{deploy-hook} (default: @code{#f})
  22196. Command to be run in a shell once for each successfully issued
  22197. certificate. For this command, the shell variable
  22198. @code{$RENEWED_LINEAGE} will point to the config live subdirectory (for
  22199. example, @samp{"/etc/letsencrypt/live/example.com"}) containing the new
  22200. certificates and keys; the shell variable @code{$RENEWED_DOMAINS} will
  22201. contain a space-delimited list of renewed certificate domains (for
  22202. example, @samp{"example.com www.example.com"}.
  22203. @end table
  22204. @end deftp
  22205. For each @code{certificate-configuration}, the certificate is saved to
  22206. @code{/etc/letsencrypt/live/@var{name}/fullchain.pem} and the key is
  22207. saved to @code{/etc/letsencrypt/live/@var{name}/privkey.pem}.
  22208. @node DNS Services
  22209. @subsection DNS Services
  22210. @cindex DNS (domain name system)
  22211. @cindex domain name system (DNS)
  22212. The @code{(gnu services dns)} module provides services related to the
  22213. @dfn{domain name system} (DNS). It provides a server service for hosting
  22214. an @emph{authoritative} DNS server for multiple zones, slave or master.
  22215. This service uses @uref{https://www.knot-dns.cz/, Knot DNS}. And also a
  22216. caching and forwarding DNS server for the LAN, which uses
  22217. @uref{http://www.thekelleys.org.uk/dnsmasq/doc.html, dnsmasq}.
  22218. @subsubheading Knot Service
  22219. An example configuration of an authoritative server for two zones, one master
  22220. and one slave, is:
  22221. @lisp
  22222. (define-zone-entries example.org.zone
  22223. ;; Name TTL Class Type Data
  22224. ("@@" "" "IN" "A" "127.0.0.1")
  22225. ("@@" "" "IN" "NS" "ns")
  22226. ("ns" "" "IN" "A" "127.0.0.1"))
  22227. (define master-zone
  22228. (knot-zone-configuration
  22229. (domain "example.org")
  22230. (zone (zone-file
  22231. (origin "example.org")
  22232. (entries example.org.zone)))))
  22233. (define slave-zone
  22234. (knot-zone-configuration
  22235. (domain "plop.org")
  22236. (dnssec-policy "default")
  22237. (master (list "plop-master"))))
  22238. (define plop-master
  22239. (knot-remote-configuration
  22240. (id "plop-master")
  22241. (address (list "208.76.58.171"))))
  22242. (operating-system
  22243. ;; ...
  22244. (services (cons* (service knot-service-type
  22245. (knot-configuration
  22246. (remotes (list plop-master))
  22247. (zones (list master-zone slave-zone))))
  22248. ;; ...
  22249. %base-services)))
  22250. @end lisp
  22251. @deffn {Scheme Variable} knot-service-type
  22252. This is the type for the Knot DNS server.
  22253. Knot DNS is an authoritative DNS server, meaning that it can serve multiple
  22254. zones, that is to say domain names you would buy from a registrar. This server
  22255. is not a resolver, meaning that it can only resolve names for which it is
  22256. authoritative. This server can be configured to serve zones as a master server
  22257. or a slave server as a per-zone basis. Slave zones will get their data from
  22258. masters, and will serve it as an authoritative server. From the point of view
  22259. of a resolver, there is no difference between master and slave.
  22260. The following data types are used to configure the Knot DNS server:
  22261. @end deffn
  22262. @deftp {Data Type} knot-key-configuration
  22263. Data type representing a key.
  22264. This type has the following parameters:
  22265. @table @asis
  22266. @item @code{id} (default: @code{""})
  22267. An identifier for other configuration fields to refer to this key. IDs must
  22268. be unique and must not be empty.
  22269. @item @code{algorithm} (default: @code{#f})
  22270. The algorithm to use. Choose between @code{#f}, @code{'hmac-md5},
  22271. @code{'hmac-sha1}, @code{'hmac-sha224}, @code{'hmac-sha256}, @code{'hmac-sha384}
  22272. and @code{'hmac-sha512}.
  22273. @item @code{secret} (default: @code{""})
  22274. The secret key itself.
  22275. @end table
  22276. @end deftp
  22277. @deftp {Data Type} knot-acl-configuration
  22278. Data type representing an Access Control List (ACL) configuration.
  22279. This type has the following parameters:
  22280. @table @asis
  22281. @item @code{id} (default: @code{""})
  22282. An identifier for other configuration fields to refer to this key. IDs must be
  22283. unique and must not be empty.
  22284. @item @code{address} (default: @code{'()})
  22285. An ordered list of IP addresses, network subnets, or network ranges represented
  22286. with strings. The query must match one of them. Empty value means that
  22287. address match is not required.
  22288. @item @code{key} (default: @code{'()})
  22289. An ordered list of references to keys represented with strings. The string
  22290. must match a key ID defined in a @code{knot-key-configuration}. No key means
  22291. that a key is not require to match that ACL.
  22292. @item @code{action} (default: @code{'()})
  22293. An ordered list of actions that are permitted or forbidden by this ACL@. Possible
  22294. values are lists of zero or more elements from @code{'transfer}, @code{'notify}
  22295. and @code{'update}.
  22296. @item @code{deny?} (default: @code{#f})
  22297. When true, the ACL defines restrictions. Listed actions are forbidden. When
  22298. false, listed actions are allowed.
  22299. @end table
  22300. @end deftp
  22301. @deftp {Data Type} zone-entry
  22302. Data type representing a record entry in a zone file.
  22303. This type has the following parameters:
  22304. @table @asis
  22305. @item @code{name} (default: @code{"@@"})
  22306. The name of the record. @code{"@@"} refers to the origin of the zone. Names
  22307. are relative to the origin of the zone. For example, in the @code{example.org}
  22308. zone, @code{"ns.example.org"} actually refers to @code{ns.example.org.example.org}.
  22309. Names ending with a dot are absolute, which means that @code{"ns.example.org."}
  22310. refers to @code{ns.example.org}.
  22311. @item @code{ttl} (default: @code{""})
  22312. The Time-To-Live (TTL) of this record. If not set, the default TTL is used.
  22313. @item @code{class} (default: @code{"IN"})
  22314. The class of the record. Knot currently supports only @code{"IN"} and
  22315. partially @code{"CH"}.
  22316. @item @code{type} (default: @code{"A"})
  22317. The type of the record. Common types include A (IPv4 address), AAAA (IPv6
  22318. address), NS (Name Server) and MX (Mail eXchange). Many other types are
  22319. defined.
  22320. @item @code{data} (default: @code{""})
  22321. The data contained in the record. For instance an IP address associated with
  22322. an A record, or a domain name associated with an NS record. Remember that
  22323. domain names are relative to the origin unless they end with a dot.
  22324. @end table
  22325. @end deftp
  22326. @deftp {Data Type} zone-file
  22327. Data type representing the content of a zone file.
  22328. This type has the following parameters:
  22329. @table @asis
  22330. @item @code{entries} (default: @code{'()})
  22331. The list of entries. The SOA record is taken care of, so you don't need to
  22332. put it in the list of entries. This list should probably contain an entry
  22333. for your primary authoritative DNS server. Other than using a list of entries
  22334. directly, you can use @code{define-zone-entries} to define a object containing
  22335. the list of entries more easily, that you can later pass to the @code{entries}
  22336. field of the @code{zone-file}.
  22337. @item @code{origin} (default: @code{""})
  22338. The name of your zone. This parameter cannot be empty.
  22339. @item @code{ns} (default: @code{"ns"})
  22340. The domain of your primary authoritative DNS server. The name is relative to
  22341. the origin, unless it ends with a dot. It is mandatory that this primary
  22342. DNS server corresponds to an NS record in the zone and that it is associated
  22343. to an IP address in the list of entries.
  22344. @item @code{mail} (default: @code{"hostmaster"})
  22345. An email address people can contact you at, as the owner of the zone. This
  22346. is translated as @code{<mail>@@<origin>}.
  22347. @item @code{serial} (default: @code{1})
  22348. The serial number of the zone. As this is used to keep track of changes by
  22349. both slaves and resolvers, it is mandatory that it @emph{never} decreases.
  22350. Always increment it when you make a change in your zone.
  22351. @item @code{refresh} (default: @code{(* 2 24 3600)})
  22352. The frequency at which slaves will do a zone transfer. This value is a number
  22353. of seconds. It can be computed by multiplications or with
  22354. @code{(string->duration)}.
  22355. @item @code{retry} (default: @code{(* 15 60)})
  22356. The period after which a slave will retry to contact its master when it fails
  22357. to do so a first time.
  22358. @item @code{expiry} (default: @code{(* 14 24 3600)})
  22359. Default TTL of records. Existing records are considered correct for at most
  22360. this amount of time. After this period, resolvers will invalidate their cache
  22361. and check again that it still exists.
  22362. @item @code{nx} (default: @code{3600})
  22363. Default TTL of inexistent records. This delay is usually short because you want
  22364. your new domains to reach everyone quickly.
  22365. @end table
  22366. @end deftp
  22367. @deftp {Data Type} knot-remote-configuration
  22368. Data type representing a remote configuration.
  22369. This type has the following parameters:
  22370. @table @asis
  22371. @item @code{id} (default: @code{""})
  22372. An identifier for other configuration fields to refer to this remote. IDs must
  22373. be unique and must not be empty.
  22374. @item @code{address} (default: @code{'()})
  22375. An ordered list of destination IP addresses. Addresses are tried in sequence.
  22376. An optional port can be given with the @@ separator. For instance:
  22377. @code{(list "1.2.3.4" "2.3.4.5@@53")}. Default port is 53.
  22378. @item @code{via} (default: @code{'()})
  22379. An ordered list of source IP addresses. An empty list will have Knot choose
  22380. an appropriate source IP@. An optional port can be given with the @@ separator.
  22381. The default is to choose at random.
  22382. @item @code{key} (default: @code{#f})
  22383. A reference to a key, that is a string containing the identifier of a key
  22384. defined in a @code{knot-key-configuration} field.
  22385. @end table
  22386. @end deftp
  22387. @deftp {Data Type} knot-keystore-configuration
  22388. Data type representing a keystore to hold dnssec keys.
  22389. This type has the following parameters:
  22390. @table @asis
  22391. @item @code{id} (default: @code{""})
  22392. The id of the keystore. It must not be empty.
  22393. @item @code{backend} (default: @code{'pem})
  22394. The backend to store the keys in. Can be @code{'pem} or @code{'pkcs11}.
  22395. @item @code{config} (default: @code{"/var/lib/knot/keys/keys"})
  22396. The configuration string of the backend. An example for the PKCS#11 is:
  22397. @code{"pkcs11:token=knot;pin-value=1234 /gnu/store/.../lib/pkcs11/libsofthsm2.so"}.
  22398. For the pem backend, the string represents a path in the file system.
  22399. @end table
  22400. @end deftp
  22401. @deftp {Data Type} knot-policy-configuration
  22402. Data type representing a dnssec policy. Knot DNS is able to automatically
  22403. sign your zones. It can either generate and manage your keys automatically or
  22404. use keys that you generate.
  22405. Dnssec is usually implemented using two keys: a Key Signing Key (KSK) that is
  22406. used to sign the second, and a Zone Signing Key (ZSK) that is used to sign the
  22407. zone. In order to be trusted, the KSK needs to be present in the parent zone
  22408. (usually a top-level domain). If your registrar supports dnssec, you will
  22409. have to send them your KSK's hash so they can add a DS record in their zone.
  22410. This is not automated and need to be done each time you change your KSK.
  22411. The policy also defines the lifetime of keys. Usually, ZSK can be changed
  22412. easily and use weaker cryptographic functions (they use lower parameters) in
  22413. order to sign records quickly, so they are changed often. The KSK however
  22414. requires manual interaction with the registrar, so they are changed less often
  22415. and use stronger parameters because they sign only one record.
  22416. This type has the following parameters:
  22417. @table @asis
  22418. @item @code{id} (default: @code{""})
  22419. The id of the policy. It must not be empty.
  22420. @item @code{keystore} (default: @code{"default"})
  22421. A reference to a keystore, that is a string containing the identifier of a
  22422. keystore defined in a @code{knot-keystore-configuration} field. The
  22423. @code{"default"} identifier means the default keystore (a kasp database that
  22424. was setup by this service).
  22425. @item @code{manual?} (default: @code{#f})
  22426. Whether the key management is manual or automatic.
  22427. @item @code{single-type-signing?} (default: @code{#f})
  22428. When @code{#t}, use the Single-Type Signing Scheme.
  22429. @item @code{algorithm} (default: @code{"ecdsap256sha256"})
  22430. An algorithm of signing keys and issued signatures.
  22431. @item @code{ksk-size} (default: @code{256})
  22432. The length of the KSK@. Note that this value is correct for the default
  22433. algorithm, but would be unsecure for other algorithms.
  22434. @item @code{zsk-size} (default: @code{256})
  22435. The length of the ZSK@. Note that this value is correct for the default
  22436. algorithm, but would be unsecure for other algorithms.
  22437. @item @code{dnskey-ttl} (default: @code{'default})
  22438. The TTL value for DNSKEY records added into zone apex. The special
  22439. @code{'default} value means same as the zone SOA TTL.
  22440. @item @code{zsk-lifetime} (default: @code{(* 30 24 3600)})
  22441. The period between ZSK publication and the next rollover initiation.
  22442. @item @code{propagation-delay} (default: @code{(* 24 3600)})
  22443. An extra delay added for each key rollover step. This value should be high
  22444. enough to cover propagation of data from the master server to all slaves.
  22445. @item @code{rrsig-lifetime} (default: @code{(* 14 24 3600)})
  22446. A validity period of newly issued signatures.
  22447. @item @code{rrsig-refresh} (default: @code{(* 7 24 3600)})
  22448. A period how long before a signature expiration the signature will be refreshed.
  22449. @item @code{nsec3?} (default: @code{#f})
  22450. When @code{#t}, NSEC3 will be used instead of NSEC.
  22451. @item @code{nsec3-iterations} (default: @code{5})
  22452. The number of additional times the hashing is performed.
  22453. @item @code{nsec3-salt-length} (default: @code{8})
  22454. The length of a salt field in octets, which is appended to the original owner
  22455. name before hashing.
  22456. @item @code{nsec3-salt-lifetime} (default: @code{(* 30 24 3600)})
  22457. The validity period of newly issued salt field.
  22458. @end table
  22459. @end deftp
  22460. @deftp {Data Type} knot-zone-configuration
  22461. Data type representing a zone served by Knot.
  22462. This type has the following parameters:
  22463. @table @asis
  22464. @item @code{domain} (default: @code{""})
  22465. The domain served by this configuration. It must not be empty.
  22466. @item @code{file} (default: @code{""})
  22467. The file where this zone is saved. This parameter is ignored by master zones.
  22468. Empty means default location that depends on the domain name.
  22469. @item @code{zone} (default: @code{(zone-file)})
  22470. The content of the zone file. This parameter is ignored by slave zones. It
  22471. must contain a zone-file record.
  22472. @item @code{master} (default: @code{'()})
  22473. A list of master remotes. When empty, this zone is a master. When set, this
  22474. zone is a slave. This is a list of remotes identifiers.
  22475. @item @code{ddns-master} (default: @code{#f})
  22476. The main master. When empty, it defaults to the first master in the list of
  22477. masters.
  22478. @item @code{notify} (default: @code{'()})
  22479. A list of slave remote identifiers.
  22480. @item @code{acl} (default: @code{'()})
  22481. A list of acl identifiers.
  22482. @item @code{semantic-checks?} (default: @code{#f})
  22483. When set, this adds more semantic checks to the zone.
  22484. @item @code{zonefile-sync} (default: @code{0})
  22485. The delay between a modification in memory and on disk. 0 means immediate
  22486. synchronization.
  22487. @item @code{zonefile-load} (default: @code{#f})
  22488. The way the zone file contents are applied during zone load. Possible values
  22489. are:
  22490. @itemize
  22491. @item @code{#f} for using the default value from Knot,
  22492. @item @code{'none} for not using the zone file at all,
  22493. @item @code{'difference} for computing the difference between already available
  22494. contents and zone contents and applying it to the current zone contents,
  22495. @item @code{'difference-no-serial} for the same as @code{'difference}, but
  22496. ignoring the SOA serial in the zone file, while the server takes care of it
  22497. automatically.
  22498. @item @code{'whole} for loading zone contents from the zone file.
  22499. @end itemize
  22500. @item @code{journal-content} (default: @code{#f})
  22501. The way the journal is used to store zone and its changes. Possible values
  22502. are @code{'none} to not use it at all, @code{'changes} to store changes and
  22503. @code{'all} to store contents. @code{#f} does not set this option, so the
  22504. default value from Knot is used.
  22505. @item @code{max-journal-usage} (default: @code{#f})
  22506. The maximum size for the journal on disk. @code{#f} does not set this option,
  22507. so the default value from Knot is used.
  22508. @item @code{max-journal-depth} (default: @code{#f})
  22509. The maximum size of the history. @code{#f} does not set this option, so the
  22510. default value from Knot is used.
  22511. @item @code{max-zone-size} (default: @code{#f})
  22512. The maximum size of the zone file. This limit is enforced for incoming
  22513. transfer and updates. @code{#f} does not set this option, so the default
  22514. value from Knot is used.
  22515. @item @code{dnssec-policy} (default: @code{#f})
  22516. A reference to a @code{knot-policy-configuration} record, or the special
  22517. name @code{"default"}. If the value is @code{#f}, there is no dnssec signing
  22518. on this zone.
  22519. @item @code{serial-policy} (default: @code{'increment})
  22520. A policy between @code{'increment} and @code{'unixtime}.
  22521. @end table
  22522. @end deftp
  22523. @deftp {Data Type} knot-configuration
  22524. Data type representing the Knot configuration.
  22525. This type has the following parameters:
  22526. @table @asis
  22527. @item @code{knot} (default: @code{knot})
  22528. The Knot package.
  22529. @item @code{run-directory} (default: @code{"/var/run/knot"})
  22530. The run directory. This directory will be used for pid file and sockets.
  22531. @item @code{includes} (default: @code{'()})
  22532. A list of strings or file-like objects denoting other files that must be
  22533. included at the top of the configuration file.
  22534. @cindex secrets, Knot service
  22535. This can be used to manage secrets out-of-band. For example, secret
  22536. keys may be stored in an out-of-band file not managed by Guix, and
  22537. thus not visible in @file{/gnu/store}---e.g., you could store secret
  22538. key configuration in @file{/etc/knot/secrets.conf} and add this file
  22539. to the @code{includes} list.
  22540. One can generate a secret tsig key (for nsupdate and zone transfers with the
  22541. keymgr command from the knot package. Note that the package is not automatically
  22542. installed by the service. The following example shows how to generate a new
  22543. tsig key:
  22544. @example
  22545. keymgr -t mysecret > /etc/knot/secrets.conf
  22546. chmod 600 /etc/knot/secrets.conf
  22547. @end example
  22548. Also note that the generated key will be named @var{mysecret}, so it is the
  22549. name that needs to be used in the @var{key} field of the
  22550. @code{knot-acl-configuration} record and in other places that need to refer
  22551. to that key.
  22552. It can also be used to add configuration not supported by this interface.
  22553. @item @code{listen-v4} (default: @code{"0.0.0.0"})
  22554. An ip address on which to listen.
  22555. @item @code{listen-v6} (default: @code{"::"})
  22556. An ip address on which to listen.
  22557. @item @code{listen-port} (default: @code{53})
  22558. A port on which to listen.
  22559. @item @code{keys} (default: @code{'()})
  22560. The list of knot-key-configuration used by this configuration.
  22561. @item @code{acls} (default: @code{'()})
  22562. The list of knot-acl-configuration used by this configuration.
  22563. @item @code{remotes} (default: @code{'()})
  22564. The list of knot-remote-configuration used by this configuration.
  22565. @item @code{zones} (default: @code{'()})
  22566. The list of knot-zone-configuration used by this configuration.
  22567. @end table
  22568. @end deftp
  22569. @subsubheading Knot Resolver Service
  22570. @deffn {Scheme Variable} knot-resolver-service-type
  22571. This is the type of the knot resolver service, whose value should be
  22572. an @code{knot-resolver-configuration} object as in this example:
  22573. @lisp
  22574. (service knot-resolver-service-type
  22575. (knot-resolver-configuration
  22576. (kresd-config-file (plain-file "kresd.conf" "
  22577. net.listen('192.168.0.1', 5353)
  22578. user('knot-resolver', 'knot-resolver')
  22579. modules = @{ 'hints > iterate', 'stats', 'predict' @}
  22580. cache.size = 100 * MB
  22581. "))))
  22582. @end lisp
  22583. For more information, refer its @url{https://knot-resolver.readthedocs.org/en/stable/daemon.html#configuration, manual}.
  22584. @end deffn
  22585. @deftp {Data Type} knot-resolver-configuration
  22586. Data type representing the configuration of knot-resolver.
  22587. @table @asis
  22588. @item @code{package} (default: @var{knot-resolver})
  22589. Package object of the knot DNS resolver.
  22590. @item @code{kresd-config-file} (default: %kresd.conf)
  22591. File-like object of the kresd configuration file to use, by default it
  22592. will listen on @code{127.0.0.1} and @code{::1}.
  22593. @item @code{garbage-collection-interval} (default: 1000)
  22594. Number of milliseconds for @code{kres-cache-gc} to periodically trim the cache.
  22595. @end table
  22596. @end deftp
  22597. @subsubheading Dnsmasq Service
  22598. @deffn {Scheme Variable} dnsmasq-service-type
  22599. This is the type of the dnsmasq service, whose value should be an
  22600. @code{dnsmasq-configuration} object as in this example:
  22601. @lisp
  22602. (service dnsmasq-service-type
  22603. (dnsmasq-configuration
  22604. (no-resolv? #t)
  22605. (servers '("192.168.1.1"))))
  22606. @end lisp
  22607. @end deffn
  22608. @deftp {Data Type} dnsmasq-configuration
  22609. Data type representing the configuration of dnsmasq.
  22610. @table @asis
  22611. @item @code{package} (default: @var{dnsmasq})
  22612. Package object of the dnsmasq server.
  22613. @item @code{no-hosts?} (default: @code{#f})
  22614. When true, don't read the hostnames in /etc/hosts.
  22615. @item @code{port} (default: @code{53})
  22616. The port to listen on. Setting this to zero completely disables DNS
  22617. responses, leaving only DHCP and/or TFTP functions.
  22618. @item @code{local-service?} (default: @code{#t})
  22619. Accept DNS queries only from hosts whose address is on a local subnet,
  22620. ie a subnet for which an interface exists on the server.
  22621. @item @code{listen-addresses} (default: @code{'()})
  22622. Listen on the given IP addresses.
  22623. @item @code{resolv-file} (default: @code{"/etc/resolv.conf"})
  22624. The file to read the IP address of the upstream nameservers from.
  22625. @item @code{no-resolv?} (default: @code{#f})
  22626. When true, don't read @var{resolv-file}.
  22627. @item @code{servers} (default: @code{'()})
  22628. Specify IP address of upstream servers directly.
  22629. @item @code{addresses} (default: @code{'()})
  22630. For each entry, specify an IP address to return for any host in the
  22631. given domains. Queries in the domains are never forwarded and always
  22632. replied to with the specified IP address.
  22633. This is useful for redirecting hosts locally, for example:
  22634. @lisp
  22635. (service dnsmasq-service-type
  22636. (dnsmasq-configuration
  22637. (addresses
  22638. '(; Redirect to a local web-server.
  22639. "/example.org/127.0.0.1"
  22640. ; Redirect subdomain to a specific IP.
  22641. "/subdomain.example.org/192.168.1.42"))))
  22642. @end lisp
  22643. Note that rules in @file{/etc/hosts} take precedence over this.
  22644. @item @code{cache-size} (default: @code{150})
  22645. Set the size of dnsmasq's cache. Setting the cache size to zero
  22646. disables caching.
  22647. @item @code{negative-cache?} (default: @code{#t})
  22648. When false, disable negative caching.
  22649. @item @code{tftp-enable?} (default: @code{#f})
  22650. Whether to enable the built-in TFTP server.
  22651. @item @code{tftp-no-fail?} (default: @code{#f})
  22652. If true, does not fail dnsmasq if the TFTP server could not start up.
  22653. @item @code{tftp-single-port?} (default: @code{#f})
  22654. Whether to use only one single port for TFTP.
  22655. @item @code{tftp-secure?} (default: @code{#f})
  22656. If true, only files owned by the user running the dnsmasq process are accessible.
  22657. If dnsmasq is being run as root, different rules apply:
  22658. @code{tftp-secure?} has no effect, but only files which have the
  22659. world-readable bit set are accessible.
  22660. @item @code{tftp-max} (default: @code{#f})
  22661. If set, sets the maximal number of concurrent connections allowed.
  22662. @item @code{tftp-mtu} (default: @code{#f})
  22663. If set, sets the MTU for TFTP packets to that value.
  22664. @item @code{tftp-no-blocksize?} (default: @code{#f})
  22665. If true, stops the TFTP server from negotiating the blocksize with a client.
  22666. @item @code{tftp-lowercase?} (default: @code{#f})
  22667. Whether to convert all filenames in TFTP requests to lowercase.
  22668. @item @code{tftp-port-range} (default: @code{#f})
  22669. If set, fixes the dynamical ports (one per client) to the given range
  22670. (@code{"<start>,<end>"}).
  22671. @item @code{tftp-root} (default: @code{/var/empty,lo})
  22672. Look for files to transfer using TFTP relative to the given directory.
  22673. When this is set, TFTP paths which include @samp{..} are rejected, to stop clients
  22674. getting outside the specified root. Absolute paths (starting with @samp{/}) are
  22675. allowed, but they must be within the TFTP-root. If the optional interface
  22676. argument is given, the directory is only used for TFTP requests via that
  22677. interface.
  22678. @item @code{tftp-unique-root} (default: @code{#f})
  22679. If set, add the IP or hardware address of the TFTP client as a path component
  22680. on the end of the TFTP-root. Only valid if a TFTP root is set and the
  22681. directory exists. Defaults to adding IP address (in standard dotted-quad
  22682. format).
  22683. For instance, if @option{--tftp-root} is @samp{/tftp} and client
  22684. @samp{1.2.3.4} requests file @file{myfile} then the effective path will
  22685. be @file{/tftp/1.2.3.4/myfile} if @file{/tftp/1.2.3.4} exists or
  22686. @file{/tftp/myfile} otherwise. When @samp{=mac} is specified it will
  22687. append the MAC address instead, using lowercase zero padded digits
  22688. separated by dashes, e.g.: @samp{01-02-03-04-aa-bb}. Note that
  22689. resolving MAC addresses is only possible if the client is in the local
  22690. network or obtained a DHCP lease from dnsmasq.
  22691. @end table
  22692. @end deftp
  22693. @subsubheading ddclient Service
  22694. @cindex ddclient
  22695. The ddclient service described below runs the ddclient daemon, which takes
  22696. care of automatically updating DNS entries for service providers such as
  22697. @uref{https://dyn.com/dns/, Dyn}.
  22698. The following example show instantiates the service with its default
  22699. configuration:
  22700. @lisp
  22701. (service ddclient-service-type)
  22702. @end lisp
  22703. Note that ddclient needs to access credentials that are stored in a
  22704. @dfn{secret file}, by default @file{/etc/ddclient/secrets} (see
  22705. @code{secret-file} below). You are expected to create this file manually, in
  22706. an ``out-of-band'' fashion (you @emph{could} make this file part of the
  22707. service configuration, for instance by using @code{plain-file}, but it will be
  22708. world-readable @i{via} @file{/gnu/store}). See the examples in the
  22709. @file{share/ddclient} directory of the @code{ddclient} package.
  22710. @c %start of fragment
  22711. Available @code{ddclient-configuration} fields are:
  22712. @deftypevr {@code{ddclient-configuration} parameter} package ddclient
  22713. The ddclient package.
  22714. @end deftypevr
  22715. @deftypevr {@code{ddclient-configuration} parameter} integer daemon
  22716. The period after which ddclient will retry to check IP and domain name.
  22717. Defaults to @samp{300}.
  22718. @end deftypevr
  22719. @deftypevr {@code{ddclient-configuration} parameter} boolean syslog
  22720. Use syslog for the output.
  22721. Defaults to @samp{#t}.
  22722. @end deftypevr
  22723. @deftypevr {@code{ddclient-configuration} parameter} string mail
  22724. Mail to user.
  22725. Defaults to @samp{"root"}.
  22726. @end deftypevr
  22727. @deftypevr {@code{ddclient-configuration} parameter} string mail-failure
  22728. Mail failed update to user.
  22729. Defaults to @samp{"root"}.
  22730. @end deftypevr
  22731. @deftypevr {@code{ddclient-configuration} parameter} string pid
  22732. The ddclient PID file.
  22733. Defaults to @samp{"/var/run/ddclient/ddclient.pid"}.
  22734. @end deftypevr
  22735. @deftypevr {@code{ddclient-configuration} parameter} boolean ssl
  22736. Enable SSL support.
  22737. Defaults to @samp{#t}.
  22738. @end deftypevr
  22739. @deftypevr {@code{ddclient-configuration} parameter} string user
  22740. Specifies the user name or ID that is used when running ddclient
  22741. program.
  22742. Defaults to @samp{"ddclient"}.
  22743. @end deftypevr
  22744. @deftypevr {@code{ddclient-configuration} parameter} string group
  22745. Group of the user who will run the ddclient program.
  22746. Defaults to @samp{"ddclient"}.
  22747. @end deftypevr
  22748. @deftypevr {@code{ddclient-configuration} parameter} string secret-file
  22749. Secret file which will be appended to @file{ddclient.conf} file. This
  22750. file contains credentials for use by ddclient. You are expected to
  22751. create it manually.
  22752. Defaults to @samp{"/etc/ddclient/secrets.conf"}.
  22753. @end deftypevr
  22754. @deftypevr {@code{ddclient-configuration} parameter} list extra-options
  22755. Extra options will be appended to @file{ddclient.conf} file.
  22756. Defaults to @samp{()}.
  22757. @end deftypevr
  22758. @c %end of fragment
  22759. @node VPN Services
  22760. @subsection VPN Services
  22761. @cindex VPN (virtual private network)
  22762. @cindex virtual private network (VPN)
  22763. The @code{(gnu services vpn)} module provides services related to
  22764. @dfn{virtual private networks} (VPNs).
  22765. @subsubheading Bitmask
  22766. @defvr {Scheme Variable} bitmask-service-type
  22767. A service type for the @uref{https://bitmask.net, Bitmask} VPN client. It makes
  22768. the client available in the system and loads its polkit policy. Please note that
  22769. the client expects an active polkit-agent, which is either run by your
  22770. desktop-environment or should be run manually.
  22771. @end defvr
  22772. @subsubheading OpenVPN
  22773. It provides a @emph{client} service for your machine to connect to a
  22774. VPN, and a @emph{server} service for your machine to host a VPN@.
  22775. @deffn {Scheme Procedure} openvpn-client-service @
  22776. [#:config (openvpn-client-configuration)]
  22777. Return a service that runs @command{openvpn}, a VPN daemon, as a client.
  22778. @end deffn
  22779. @deffn {Scheme Procedure} openvpn-server-service @
  22780. [#:config (openvpn-server-configuration)]
  22781. Return a service that runs @command{openvpn}, a VPN daemon, as a server.
  22782. Both can be run simultaneously.
  22783. @end deffn
  22784. @c %automatically generated documentation
  22785. Available @code{openvpn-client-configuration} fields are:
  22786. @deftypevr {@code{openvpn-client-configuration} parameter} package openvpn
  22787. The OpenVPN package.
  22788. @end deftypevr
  22789. @deftypevr {@code{openvpn-client-configuration} parameter} string pid-file
  22790. The OpenVPN pid file.
  22791. Defaults to @samp{"/var/run/openvpn/openvpn.pid"}.
  22792. @end deftypevr
  22793. @deftypevr {@code{openvpn-client-configuration} parameter} proto proto
  22794. The protocol (UDP or TCP) used to open a channel between clients and
  22795. servers.
  22796. Defaults to @samp{udp}.
  22797. @end deftypevr
  22798. @deftypevr {@code{openvpn-client-configuration} parameter} dev dev
  22799. The device type used to represent the VPN connection.
  22800. Defaults to @samp{tun}.
  22801. @end deftypevr
  22802. If you do not have some of these files (eg.@: you use a username and
  22803. password), you can disable any of the following three fields by setting
  22804. it to @code{'disabled}.
  22805. @deftypevr {@code{openvpn-client-configuration} parameter} maybe-string ca
  22806. The certificate authority to check connections against.
  22807. Defaults to @samp{"/etc/openvpn/ca.crt"}.
  22808. @end deftypevr
  22809. @deftypevr {@code{openvpn-client-configuration} parameter} maybe-string cert
  22810. The certificate of the machine the daemon is running on. It should be
  22811. signed by the authority given in @code{ca}.
  22812. Defaults to @samp{"/etc/openvpn/client.crt"}.
  22813. @end deftypevr
  22814. @deftypevr {@code{openvpn-client-configuration} parameter} maybe-string key
  22815. The key of the machine the daemon is running on. It must be the key whose
  22816. certificate is @code{cert}.
  22817. Defaults to @samp{"/etc/openvpn/client.key"}.
  22818. @end deftypevr
  22819. @deftypevr {@code{openvpn-client-configuration} parameter} boolean comp-lzo?
  22820. Whether to use the lzo compression algorithm.
  22821. Defaults to @samp{#t}.
  22822. @end deftypevr
  22823. @deftypevr {@code{openvpn-client-configuration} parameter} boolean persist-key?
  22824. Don't re-read key files across SIGUSR1 or --ping-restart.
  22825. Defaults to @samp{#t}.
  22826. @end deftypevr
  22827. @deftypevr {@code{openvpn-client-configuration} parameter} boolean persist-tun?
  22828. Don't close and reopen TUN/TAP device or run up/down scripts across
  22829. SIGUSR1 or --ping-restart restarts.
  22830. Defaults to @samp{#t}.
  22831. @end deftypevr
  22832. @deftypevr {@code{openvpn-client-configuration} parameter} boolean fast-io?
  22833. (Experimental) Optimize TUN/TAP/UDP I/O writes by avoiding a call to
  22834. poll/epoll/select prior to the write operation.
  22835. Defaults to @samp{#f}.
  22836. @end deftypevr
  22837. @deftypevr {@code{openvpn-client-configuration} parameter} number verbosity
  22838. Verbosity level.
  22839. Defaults to @samp{3}.
  22840. @end deftypevr
  22841. @deftypevr {@code{openvpn-client-configuration} parameter} tls-auth-client tls-auth
  22842. Add an additional layer of HMAC authentication on top of the TLS control
  22843. channel to protect against DoS attacks.
  22844. Defaults to @samp{#f}.
  22845. @end deftypevr
  22846. @deftypevr {@code{openvpn-client-configuration} parameter} maybe-string auth-user-pass
  22847. Authenticate with server using username/password. The option is a file
  22848. containing username/password on 2 lines. Do not use a file-like object as it
  22849. would be added to the store and readable by any user.
  22850. Defaults to @samp{'disabled}.
  22851. @end deftypevr
  22852. @deftypevr {@code{openvpn-client-configuration} parameter} key-usage verify-key-usage?
  22853. Whether to check the server certificate has server usage extension.
  22854. Defaults to @samp{#t}.
  22855. @end deftypevr
  22856. @deftypevr {@code{openvpn-client-configuration} parameter} bind bind?
  22857. Bind to a specific local port number.
  22858. Defaults to @samp{#f}.
  22859. @end deftypevr
  22860. @deftypevr {@code{openvpn-client-configuration} parameter} resolv-retry resolv-retry?
  22861. Retry resolving server address.
  22862. Defaults to @samp{#t}.
  22863. @end deftypevr
  22864. @deftypevr {@code{openvpn-client-configuration} parameter} openvpn-remote-list remote
  22865. A list of remote servers to connect to.
  22866. Defaults to @samp{()}.
  22867. Available @code{openvpn-remote-configuration} fields are:
  22868. @deftypevr {@code{openvpn-remote-configuration} parameter} string name
  22869. Server name.
  22870. Defaults to @samp{"my-server"}.
  22871. @end deftypevr
  22872. @deftypevr {@code{openvpn-remote-configuration} parameter} number port
  22873. Port number the server listens to.
  22874. Defaults to @samp{1194}.
  22875. @end deftypevr
  22876. @end deftypevr
  22877. @c %end of automatic openvpn-client documentation
  22878. @c %automatically generated documentation
  22879. Available @code{openvpn-server-configuration} fields are:
  22880. @deftypevr {@code{openvpn-server-configuration} parameter} package openvpn
  22881. The OpenVPN package.
  22882. @end deftypevr
  22883. @deftypevr {@code{openvpn-server-configuration} parameter} string pid-file
  22884. The OpenVPN pid file.
  22885. Defaults to @samp{"/var/run/openvpn/openvpn.pid"}.
  22886. @end deftypevr
  22887. @deftypevr {@code{openvpn-server-configuration} parameter} proto proto
  22888. The protocol (UDP or TCP) used to open a channel between clients and
  22889. servers.
  22890. Defaults to @samp{udp}.
  22891. @end deftypevr
  22892. @deftypevr {@code{openvpn-server-configuration} parameter} dev dev
  22893. The device type used to represent the VPN connection.
  22894. Defaults to @samp{tun}.
  22895. @end deftypevr
  22896. If you do not have some of these files (eg.@: you use a username and
  22897. password), you can disable any of the following three fields by setting
  22898. it to @code{'disabled}.
  22899. @deftypevr {@code{openvpn-server-configuration} parameter} maybe-string ca
  22900. The certificate authority to check connections against.
  22901. Defaults to @samp{"/etc/openvpn/ca.crt"}.
  22902. @end deftypevr
  22903. @deftypevr {@code{openvpn-server-configuration} parameter} maybe-string cert
  22904. The certificate of the machine the daemon is running on. It should be
  22905. signed by the authority given in @code{ca}.
  22906. Defaults to @samp{"/etc/openvpn/client.crt"}.
  22907. @end deftypevr
  22908. @deftypevr {@code{openvpn-server-configuration} parameter} maybe-string key
  22909. The key of the machine the daemon is running on. It must be the key whose
  22910. certificate is @code{cert}.
  22911. Defaults to @samp{"/etc/openvpn/client.key"}.
  22912. @end deftypevr
  22913. @deftypevr {@code{openvpn-server-configuration} parameter} boolean comp-lzo?
  22914. Whether to use the lzo compression algorithm.
  22915. Defaults to @samp{#t}.
  22916. @end deftypevr
  22917. @deftypevr {@code{openvpn-server-configuration} parameter} boolean persist-key?
  22918. Don't re-read key files across SIGUSR1 or --ping-restart.
  22919. Defaults to @samp{#t}.
  22920. @end deftypevr
  22921. @deftypevr {@code{openvpn-server-configuration} parameter} boolean persist-tun?
  22922. Don't close and reopen TUN/TAP device or run up/down scripts across
  22923. SIGUSR1 or --ping-restart restarts.
  22924. Defaults to @samp{#t}.
  22925. @end deftypevr
  22926. @deftypevr {@code{openvpn-server-configuration} parameter} boolean fast-io?
  22927. (Experimental) Optimize TUN/TAP/UDP I/O writes by avoiding a call to
  22928. poll/epoll/select prior to the write operation.
  22929. Defaults to @samp{#f}.
  22930. @end deftypevr
  22931. @deftypevr {@code{openvpn-server-configuration} parameter} number verbosity
  22932. Verbosity level.
  22933. Defaults to @samp{3}.
  22934. @end deftypevr
  22935. @deftypevr {@code{openvpn-server-configuration} parameter} tls-auth-server tls-auth
  22936. Add an additional layer of HMAC authentication on top of the TLS control
  22937. channel to protect against DoS attacks.
  22938. Defaults to @samp{#f}.
  22939. @end deftypevr
  22940. @deftypevr {@code{openvpn-server-configuration} parameter} number port
  22941. Specifies the port number on which the server listens.
  22942. Defaults to @samp{1194}.
  22943. @end deftypevr
  22944. @deftypevr {@code{openvpn-server-configuration} parameter} ip-mask server
  22945. An ip and mask specifying the subnet inside the virtual network.
  22946. Defaults to @samp{"10.8.0.0 255.255.255.0"}.
  22947. @end deftypevr
  22948. @deftypevr {@code{openvpn-server-configuration} parameter} cidr6 server-ipv6
  22949. A CIDR notation specifying the IPv6 subnet inside the virtual network.
  22950. Defaults to @samp{#f}.
  22951. @end deftypevr
  22952. @deftypevr {@code{openvpn-server-configuration} parameter} string dh
  22953. The Diffie-Hellman parameters file.
  22954. Defaults to @samp{"/etc/openvpn/dh2048.pem"}.
  22955. @end deftypevr
  22956. @deftypevr {@code{openvpn-server-configuration} parameter} string ifconfig-pool-persist
  22957. The file that records client IPs.
  22958. Defaults to @samp{"/etc/openvpn/ipp.txt"}.
  22959. @end deftypevr
  22960. @deftypevr {@code{openvpn-server-configuration} parameter} gateway redirect-gateway?
  22961. When true, the server will act as a gateway for its clients.
  22962. Defaults to @samp{#f}.
  22963. @end deftypevr
  22964. @deftypevr {@code{openvpn-server-configuration} parameter} boolean client-to-client?
  22965. When true, clients are allowed to talk to each other inside the VPN.
  22966. Defaults to @samp{#f}.
  22967. @end deftypevr
  22968. @deftypevr {@code{openvpn-server-configuration} parameter} keepalive keepalive
  22969. Causes ping-like messages to be sent back and forth over the link so
  22970. that each side knows when the other side has gone down. @code{keepalive}
  22971. requires a pair. The first element is the period of the ping sending,
  22972. and the second element is the timeout before considering the other side
  22973. down.
  22974. @end deftypevr
  22975. @deftypevr {@code{openvpn-server-configuration} parameter} number max-clients
  22976. The maximum number of clients.
  22977. Defaults to @samp{100}.
  22978. @end deftypevr
  22979. @deftypevr {@code{openvpn-server-configuration} parameter} string status
  22980. The status file. This file shows a small report on current connection.
  22981. It is truncated and rewritten every minute.
  22982. Defaults to @samp{"/var/run/openvpn/status"}.
  22983. @end deftypevr
  22984. @deftypevr {@code{openvpn-server-configuration} parameter} openvpn-ccd-list client-config-dir
  22985. The list of configuration for some clients.
  22986. Defaults to @samp{()}.
  22987. Available @code{openvpn-ccd-configuration} fields are:
  22988. @deftypevr {@code{openvpn-ccd-configuration} parameter} string name
  22989. Client name.
  22990. Defaults to @samp{"client"}.
  22991. @end deftypevr
  22992. @deftypevr {@code{openvpn-ccd-configuration} parameter} ip-mask iroute
  22993. Client own network
  22994. Defaults to @samp{#f}.
  22995. @end deftypevr
  22996. @deftypevr {@code{openvpn-ccd-configuration} parameter} ip-mask ifconfig-push
  22997. Client VPN IP.
  22998. Defaults to @samp{#f}.
  22999. @end deftypevr
  23000. @end deftypevr
  23001. @c %end of automatic openvpn-server documentation
  23002. @subheading strongSwan
  23003. Currently, the strongSwan service only provides legacy-style configuration with
  23004. @file{ipsec.conf} and @file{ipsec.secrets} files.
  23005. @defvr {Scheme Variable} strongswan-service-type
  23006. A service type for configuring strongSwan for IPsec @acronym{VPN,
  23007. Virtual Private Networking}. Its value must be a
  23008. @code{strongswan-configuration} record as in this example:
  23009. @lisp
  23010. (service strongswan-service-type
  23011. (strongswan-configuration
  23012. (ipsec-conf "/etc/ipsec.conf")
  23013. (ipsec-secrets "/etc/ipsec.secrets")))
  23014. @end lisp
  23015. @end defvr
  23016. @deftp {Data Type} strongswan-configuration
  23017. Data type representing the configuration of the StrongSwan service.
  23018. @table @asis
  23019. @item @code{strongswan}
  23020. The strongSwan package to use for this service.
  23021. @item @code{ipsec-conf} (default: @code{#f})
  23022. The file name of your @file{ipsec.conf}. If not @code{#f}, then this and
  23023. @code{ipsec-secrets} must both be strings.
  23024. @item @code{ipsec-secrets} (default @code{#f})
  23025. The file name of your @file{ipsec.secrets}. If not @code{#f}, then this and
  23026. @code{ipsec-conf} must both be strings.
  23027. @end table
  23028. @end deftp
  23029. @subsubheading Wireguard
  23030. @defvr {Scheme Variable} wireguard-service-type
  23031. A service type for a Wireguard tunnel interface. Its value must be a
  23032. @code{wireguard-configuration} record as in this example:
  23033. @lisp
  23034. (service wireguard-service-type
  23035. (wireguard-configuration
  23036. (peers
  23037. (list
  23038. (wireguard-peer
  23039. (name "my-peer")
  23040. (endpoint "my.wireguard.com:51820")
  23041. (public-key "hzpKg9X1yqu1axN6iJp0mWf6BZGo8m1wteKwtTmDGF4=")
  23042. (allowed-ips '("10.0.0.2/32")))))))
  23043. @end lisp
  23044. @end defvr
  23045. @deftp {Data Type} wireguard-configuration
  23046. Data type representing the configuration of the Wireguard service.
  23047. @table @asis
  23048. @item @code{wireguard}
  23049. The wireguard package to use for this service.
  23050. @item @code{interface} (default: @code{"wg0"})
  23051. The interface name for the VPN.
  23052. @item @code{addresses} (default: @code{'("10.0.0.1/32")})
  23053. The IP addresses to be assigned to the above interface.
  23054. @item @code{port} (default: @code{51820})
  23055. The port on which to listen for incoming connections.
  23056. @item @code{dns} (default: @code{#f})
  23057. The DNS server(s) to announce to VPN clients via DHCP.
  23058. @item @code{private-key} (default: @code{"/etc/wireguard/private.key"})
  23059. The private key file for the interface. It is automatically generated if
  23060. the file does not exist.
  23061. @item @code{peers} (default: @code{'()})
  23062. The authorized peers on this interface. This is a list of
  23063. @var{wireguard-peer} records.
  23064. @end table
  23065. @end deftp
  23066. @deftp {Data Type} wireguard-peer
  23067. Data type representing a Wireguard peer attached to a given interface.
  23068. @table @asis
  23069. @item @code{name}
  23070. The peer name.
  23071. @item @code{endpoint} (default: @code{#f})
  23072. The optional endpoint for the peer, such as
  23073. @code{"demo.wireguard.com:51820"}.
  23074. @item @code{public-key}
  23075. The peer public-key represented as a base64 string.
  23076. @item @code{allowed-ips}
  23077. A list of IP addresses from which incoming traffic for this peer is
  23078. allowed and to which incoming traffic for this peer is directed.
  23079. @item @code{keep-alive} (default: @code{#f})
  23080. An optional time interval in seconds. A packet will be sent to the
  23081. server endpoint once per time interval. This helps receiving
  23082. incoming connections from this peer when you are behind a NAT or
  23083. a firewall.
  23084. @end table
  23085. @end deftp
  23086. @node Network File System
  23087. @subsection Network File System
  23088. @cindex NFS
  23089. The @code{(gnu services nfs)} module provides the following services,
  23090. which are most commonly used in relation to mounting or exporting
  23091. directory trees as @dfn{network file systems} (NFS).
  23092. While it is possible to use the individual components that together make
  23093. up a Network File System service, we recommended to configure an NFS
  23094. server with the @code{nfs-service-type}.
  23095. @subsubheading NFS Service
  23096. @cindex NFS, server
  23097. The NFS service takes care of setting up all NFS component services,
  23098. kernel configuration file systems, and installs configuration files in
  23099. the locations that NFS expects.
  23100. @defvr {Scheme Variable} nfs-service-type
  23101. A service type for a complete NFS server.
  23102. @end defvr
  23103. @deftp {Data Type} nfs-configuration
  23104. This data type represents the configuration of the NFS service and all
  23105. of its subsystems.
  23106. It has the following parameters:
  23107. @table @asis
  23108. @item @code{nfs-utils} (default: @code{nfs-utils})
  23109. The nfs-utils package to use.
  23110. @item @code{nfs-versions} (default: @code{'("4.2" "4.1" "4.0")})
  23111. If a list of string values is provided, the @command{rpc.nfsd} daemon
  23112. will be limited to supporting the given versions of the NFS protocol.
  23113. @item @code{exports} (default: @code{'()})
  23114. This is a list of directories the NFS server should export. Each entry
  23115. is a list consisting of two elements: a directory name and a string
  23116. containing all options. This is an example in which the directory
  23117. @file{/export} is served to all NFS clients as a read-only share:
  23118. @lisp
  23119. (nfs-configuration
  23120. (exports
  23121. '(("/export"
  23122. "*(ro,insecure,no_subtree_check,crossmnt,fsid=0)"))))
  23123. @end lisp
  23124. @item @code{rpcmountd-port} (default: @code{#f})
  23125. The network port that the @command{rpc.mountd} daemon should use.
  23126. @item @code{rpcstatd-port} (default: @code{#f})
  23127. The network port that the @command{rpc.statd} daemon should use.
  23128. @item @code{rpcbind} (default: @code{rpcbind})
  23129. The rpcbind package to use.
  23130. @item @code{idmap-domain} (default: @code{"localdomain"})
  23131. The local NFSv4 domain name.
  23132. @item @code{nfsd-port} (default: @code{2049})
  23133. The network port that the @command{nfsd} daemon should use.
  23134. @item @code{nfsd-threads} (default: @code{8})
  23135. The number of threads used by the @command{nfsd} daemon.
  23136. @item @code{nfsd-tcp?} (default: @code{#t})
  23137. Whether the @command{nfsd} daemon should listen on a TCP socket.
  23138. @item @code{nfsd-udp?} (default: @code{#f})
  23139. Whether the @command{nfsd} daemon should listen on a UDP socket.
  23140. @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  23141. The directory where the pipefs file system is mounted.
  23142. @item @code{debug} (default: @code{'()"})
  23143. A list of subsystems for which debugging output should be enabled. This
  23144. is a list of symbols. Any of these symbols are valid: @code{nfsd},
  23145. @code{nfs}, @code{rpc}, @code{idmap}, @code{statd}, or @code{mountd}.
  23146. @end table
  23147. @end deftp
  23148. If you don't need a complete NFS service or prefer to build it yourself
  23149. you can use the individual component services that are documented below.
  23150. @subsubheading RPC Bind Service
  23151. @cindex rpcbind
  23152. The RPC Bind service provides a facility to map program numbers into
  23153. universal addresses.
  23154. Many NFS related services use this facility. Hence it is automatically
  23155. started when a dependent service starts.
  23156. @defvr {Scheme Variable} rpcbind-service-type
  23157. A service type for the RPC portmapper daemon.
  23158. @end defvr
  23159. @deftp {Data Type} rpcbind-configuration
  23160. Data type representing the configuration of the RPC Bind Service.
  23161. This type has the following parameters:
  23162. @table @asis
  23163. @item @code{rpcbind} (default: @code{rpcbind})
  23164. The rpcbind package to use.
  23165. @item @code{warm-start?} (default: @code{#t})
  23166. If this parameter is @code{#t}, then the daemon will read a
  23167. state file on startup thus reloading state information saved by a previous
  23168. instance.
  23169. @end table
  23170. @end deftp
  23171. @subsubheading Pipefs Pseudo File System
  23172. @cindex pipefs
  23173. @cindex rpc_pipefs
  23174. The pipefs file system is used to transfer NFS related data
  23175. between the kernel and user space programs.
  23176. @defvr {Scheme Variable} pipefs-service-type
  23177. A service type for the pipefs pseudo file system.
  23178. @end defvr
  23179. @deftp {Data Type} pipefs-configuration
  23180. Data type representing the configuration of the pipefs pseudo file system service.
  23181. This type has the following parameters:
  23182. @table @asis
  23183. @item @code{mount-point} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  23184. The directory to which the file system is to be attached.
  23185. @end table
  23186. @end deftp
  23187. @subsubheading GSS Daemon Service
  23188. @cindex GSSD
  23189. @cindex GSS
  23190. @cindex global security system
  23191. The @dfn{global security system} (GSS) daemon provides strong security for RPC
  23192. based protocols.
  23193. Before exchanging RPC requests an RPC client must establish a security
  23194. context. Typically this is done using the Kerberos command @command{kinit}
  23195. or automatically at login time using PAM services (@pxref{Kerberos Services}).
  23196. @defvr {Scheme Variable} gss-service-type
  23197. A service type for the Global Security System (GSS) daemon.
  23198. @end defvr
  23199. @deftp {Data Type} gss-configuration
  23200. Data type representing the configuration of the GSS daemon service.
  23201. This type has the following parameters:
  23202. @table @asis
  23203. @item @code{nfs-utils} (default: @code{nfs-utils})
  23204. The package in which the @command{rpc.gssd} command is to be found.
  23205. @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  23206. The directory where the pipefs file system is mounted.
  23207. @end table
  23208. @end deftp
  23209. @subsubheading IDMAP Daemon Service
  23210. @cindex idmapd
  23211. @cindex name mapper
  23212. The idmap daemon service provides mapping between user IDs and user names.
  23213. Typically it is required in order to access file systems mounted via NFSv4.
  23214. @defvr {Scheme Variable} idmap-service-type
  23215. A service type for the Identity Mapper (IDMAP) daemon.
  23216. @end defvr
  23217. @deftp {Data Type} idmap-configuration
  23218. Data type representing the configuration of the IDMAP daemon service.
  23219. This type has the following parameters:
  23220. @table @asis
  23221. @item @code{nfs-utils} (default: @code{nfs-utils})
  23222. The package in which the @command{rpc.idmapd} command is to be found.
  23223. @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  23224. The directory where the pipefs file system is mounted.
  23225. @item @code{domain} (default: @code{#f})
  23226. The local NFSv4 domain name.
  23227. This must be a string or @code{#f}.
  23228. If it is @code{#f} then the daemon will use the host's fully qualified domain name.
  23229. @item @code{verbosity} (default: @code{0})
  23230. The verbosity level of the daemon.
  23231. @end table
  23232. @end deftp
  23233. @node Continuous Integration
  23234. @subsection Continuous Integration
  23235. @cindex continuous integration
  23236. @uref{https://guix.gnu.org/cuirass/, Cuirass} is a continuous
  23237. integration tool for Guix. It can be used both for development and for
  23238. providing substitutes to others (@pxref{Substitutes}).
  23239. The @code{(gnu services cuirass)} module provides the following service.
  23240. @defvr {Scheme Procedure} cuirass-service-type
  23241. The type of the Cuirass service. Its value must be a
  23242. @code{cuirass-configuration} object, as described below.
  23243. @end defvr
  23244. To add build jobs, you have to set the @code{specifications} field of
  23245. the configuration. For instance, the following example will build all
  23246. the packages provided by the @code{my-channel} channel.
  23247. @lisp
  23248. (define %cuirass-specs
  23249. #~(list (specification
  23250. (name "my-channel")
  23251. (build '(channels my-channel))
  23252. (channels
  23253. (cons (channel
  23254. (name 'my-channel)
  23255. (url "https://my-channel.git"))
  23256. %default-channels)))))
  23257. (service cuirass-service-type
  23258. (cuirass-configuration
  23259. (specifications %cuirass-specs)))
  23260. @end lisp
  23261. To build the @code{linux-libre} package defined by the default Guix
  23262. channel, one can use the following configuration.
  23263. @lisp
  23264. (define %cuirass-specs
  23265. #~(list (specification
  23266. (name "my-linux")
  23267. (build '(packages "linux-libre")))))
  23268. (service cuirass-service-type
  23269. (cuirass-configuration
  23270. (specifications %cuirass-specs)))
  23271. @end lisp
  23272. The other configuration possibilities, as well as the specification
  23273. record itself are described in the Cuirass manual
  23274. (@pxref{Specifications,,, cuirass, Cuirass}).
  23275. While information related to build jobs is located directly in the
  23276. specifications, global settings for the @command{cuirass} process are
  23277. accessible in other @code{cuirass-configuration} fields.
  23278. @deftp {Data Type} cuirass-configuration
  23279. Data type representing the configuration of Cuirass.
  23280. @table @asis
  23281. @item @code{cuirass} (default: @code{cuirass})
  23282. The Cuirass package to use.
  23283. @item @code{log-file} (default: @code{"/var/log/cuirass.log"})
  23284. Location of the log file.
  23285. @item @code{web-log-file} (default: @code{"/var/log/cuirass-web.log"})
  23286. Location of the log file used by the web interface.
  23287. @item @code{cache-directory} (default: @code{"/var/cache/cuirass"})
  23288. Location of the repository cache.
  23289. @item @code{user} (default: @code{"cuirass"})
  23290. Owner of the @code{cuirass} process.
  23291. @item @code{group} (default: @code{"cuirass"})
  23292. Owner's group of the @code{cuirass} process.
  23293. @item @code{interval} (default: @code{60})
  23294. Number of seconds between the poll of the repositories followed by the
  23295. Cuirass jobs.
  23296. @item @code{parameters} (default: @code{#f})
  23297. Read parameters from the given @var{parameters} file. The supported
  23298. parameters are described here (@pxref{Parameters,,, cuirass, Cuirass}).
  23299. @item @code{remote-server} (default: @code{#f})
  23300. A @code{cuirass-remote-server-configuration} record to use the build
  23301. remote mechanism or @code{#f} to use the default build mechanism.
  23302. @item @code{database} (default: @code{"dbname=cuirass host=/var/run/postgresql"})
  23303. Use @var{database} as the database containing the jobs and the past
  23304. build results. Since Cuirass uses PostgreSQL as a database engine,
  23305. @var{database} must be a string such as @code{"dbname=cuirass
  23306. host=localhost"}.
  23307. @item @code{port} (default: @code{8081})
  23308. Port number used by the HTTP server.
  23309. @item @code{host} (default: @code{"localhost"})
  23310. Listen on the network interface for @var{host}. The default is to
  23311. accept connections from localhost.
  23312. @item @code{specifications} (default: @code{#~'()})
  23313. A gexp (@pxref{G-Expressions}) that evaluates to a list of
  23314. specifications records. The specification record is described in the
  23315. Cuirass manual (@pxref{Specifications,,, cuirass, Cuirass}).
  23316. @item @code{use-substitutes?} (default: @code{#f})
  23317. This allows using substitutes to avoid building every dependencies of a job
  23318. from source.
  23319. @item @code{one-shot?} (default: @code{#f})
  23320. Only evaluate specifications and build derivations once.
  23321. @item @code{fallback?} (default: @code{#f})
  23322. When substituting a pre-built binary fails, fall back to building
  23323. packages locally.
  23324. @item @code{extra-options} (default: @code{'()})
  23325. Extra options to pass when running the Cuirass processes.
  23326. @end table
  23327. @end deftp
  23328. @cindex remote build
  23329. @subsubheading Cuirass remote building
  23330. Cuirass supports two mechanisms to build derivations.
  23331. @itemize
  23332. @item Using the local Guix daemon.
  23333. This is the default build mechanism. Once the build jobs are
  23334. evaluated, they are sent to the local Guix daemon. Cuirass then
  23335. listens to the Guix daemon output to detect the various build events.
  23336. @item Using the remote build mechanism.
  23337. The build jobs are not submitted to the local Guix daemon. Instead, a
  23338. remote server dispatches build requests to the connect remote workers,
  23339. according to the build priorities.
  23340. @end itemize
  23341. To enable this build mode a @code{cuirass-remote-server-configuration}
  23342. record must be passed as @code{remote-server} argument of the
  23343. @code{cuirass-configuration} record. The
  23344. @code{cuirass-remote-server-configuration} record is described below.
  23345. This build mode scales way better than the default build mode. This is
  23346. the build mode that is used on the GNU Guix build farm at
  23347. @url{https://ci.guix.gnu.org}. It should be preferred when using
  23348. Cuirass to build large amount of packages.
  23349. @deftp {Data Type} cuirass-remote-server-configuration
  23350. Data type representing the configuration of the Cuirass remote-server.
  23351. @table @asis
  23352. @item @code{backend-port} (default: @code{5555})
  23353. The TCP port for communicating with @code{remote-worker} processes
  23354. using ZMQ. It defaults to @code{5555}.
  23355. @item @code{log-port} (default: @code{5556})
  23356. The TCP port of the log server. It defaults to @code{5556}.
  23357. @item @code{publish-port} (default: @code{5557})
  23358. The TCP port of the publish server. It defaults to @code{5557}.
  23359. @item @code{log-file} (default: @code{"/var/log/cuirass-remote-server.log"})
  23360. Location of the log file.
  23361. @item @code{cache} (default: @code{"/var/cache/cuirass/remote"})
  23362. Use @var{cache} directory to cache build log files.
  23363. @item @code{trigger-url} (default: @code{#f})
  23364. Once a substitute is successfully fetched, trigger substitute baking at
  23365. @var{trigger-url}.
  23366. @item @code{publish?} (default: @code{#t})
  23367. If set to false, do not start a publish server and ignore the
  23368. @code{publish-port} argument. This can be useful if there is already a
  23369. standalone publish server standing next to the remote server.
  23370. @item @code{public-key}
  23371. @item @code{private-key}
  23372. Use the specific @var{file}s as the public/private key pair used to sign
  23373. the store items being published.
  23374. @end table
  23375. @end deftp
  23376. At least one remote worker must also be started on any machine of the
  23377. local network to actually perform the builds and report their status.
  23378. @deftp {Data Type} cuirass-remote-worker-configuration
  23379. Data type representing the configuration of the Cuirass remote-worker.
  23380. @table @asis
  23381. @item @code{cuirass} (default: @code{cuirass})
  23382. The Cuirass package to use.
  23383. @item @code{workers} (default: @code{1})
  23384. Start @var{workers} parallel workers.
  23385. @item @code{server} (default: @code{#f})
  23386. Do not use Avahi discovery and connect to the given @code{server} IP
  23387. address instead.
  23388. @item @code{systems} (default: @code{(list (%current-system))})
  23389. Only request builds for the given @var{systems}.
  23390. @item @code{log-file} (default: @code{"/var/log/cuirass-remote-worker.log"})
  23391. Location of the log file.
  23392. @item @code{publish-port} (default: @code{5558})
  23393. The TCP port of the publish server. It defaults to @code{5558}.
  23394. @item @code{substitute-urls} (default: @code{%default-substitute-urls})
  23395. The list of URLs where to look for substitutes by default.
  23396. @item @code{public-key}
  23397. @item @code{private-key}
  23398. Use the specific @var{file}s as the public/private key pair used to sign
  23399. the store items being published.
  23400. @end table
  23401. @end deftp
  23402. @subsubheading Laminar
  23403. @uref{https://laminar.ohwg.net/, Laminar} is a lightweight and modular
  23404. Continuous Integration service. It doesn't have a configuration web UI
  23405. instead uses version-controllable configuration files and scripts.
  23406. Laminar encourages the use of existing tools such as bash and cron
  23407. instead of reinventing them.
  23408. @defvr {Scheme Procedure} laminar-service-type
  23409. The type of the Laminar service. Its value must be a
  23410. @code{laminar-configuration} object, as described below.
  23411. All configuration values have defaults, a minimal configuration to get
  23412. Laminar running is shown below. By default, the web interface is
  23413. available on port 8080.
  23414. @lisp
  23415. (service laminar-service-type)
  23416. @end lisp
  23417. @end defvr
  23418. @deftp {Data Type} laminar-configuration
  23419. Data type representing the configuration of Laminar.
  23420. @table @asis
  23421. @item @code{laminar} (default: @code{laminar})
  23422. The Laminar package to use.
  23423. @item @code{home-directory} (default: @code{"/var/lib/laminar"})
  23424. The directory for job configurations and run directories.
  23425. @item @code{bind-http} (default: @code{"*:8080"})
  23426. The interface/port or unix socket on which laminard should listen for
  23427. incoming connections to the web frontend.
  23428. @item @code{bind-rpc} (default: @code{"unix-abstract:laminar"})
  23429. The interface/port or unix socket on which laminard should listen for
  23430. incoming commands such as build triggers.
  23431. @item @code{title} (default: @code{"Laminar"})
  23432. The page title to show in the web frontend.
  23433. @item @code{keep-rundirs} (default: @code{0})
  23434. Set to an integer defining how many rundirs to keep per job. The
  23435. lowest-numbered ones will be deleted. The default is 0, meaning all run
  23436. dirs will be immediately deleted.
  23437. @item @code{archive-url} (default: @code{#f})
  23438. The web frontend served by laminard will use this URL to form links to
  23439. artefacts archived jobs.
  23440. @item @code{base-url} (default: @code{#f})
  23441. Base URL to use for links to laminar itself.
  23442. @end table
  23443. @end deftp
  23444. @node Power Management Services
  23445. @subsection Power Management Services
  23446. @cindex tlp
  23447. @cindex power management with TLP
  23448. @subsubheading TLP daemon
  23449. The @code{(gnu services pm)} module provides a Guix service definition
  23450. for the Linux power management tool TLP.
  23451. TLP enables various powersaving modes in userspace and kernel.
  23452. Contrary to @code{upower-service}, it is not a passive,
  23453. monitoring tool, as it will apply custom settings each time a new power
  23454. source is detected. More information can be found at
  23455. @uref{https://linrunner.de/en/tlp/tlp.html, TLP home page}.
  23456. @deffn {Scheme Variable} tlp-service-type
  23457. The service type for the TLP tool. The default settings are optimised
  23458. for battery life on most systems, but you can tweak them to your heart's
  23459. content by adding a valid @code{tlp-configuration}:
  23460. @lisp
  23461. (service tlp-service-type
  23462. (tlp-configuration
  23463. (cpu-scaling-governor-on-ac (list "performance"))
  23464. (sched-powersave-on-bat? #t)))
  23465. @end lisp
  23466. @end deffn
  23467. Each parameter definition is preceded by its type; for example,
  23468. @samp{boolean foo} indicates that the @code{foo} parameter
  23469. should be specified as a boolean. Types starting with
  23470. @code{maybe-} denote parameters that won't show up in TLP config file
  23471. when their value is @code{'disabled}.
  23472. @c The following documentation was initially generated by
  23473. @c (generate-tlp-documentation) in (gnu services pm). Manually maintained
  23474. @c documentation is better, so we shouldn't hesitate to edit below as
  23475. @c needed. However if the change you want to make to this documentation
  23476. @c can be done in an automated way, it's probably easier to change
  23477. @c (generate-documentation) than to make it below and have to deal with
  23478. @c the churn as TLP updates.
  23479. Available @code{tlp-configuration} fields are:
  23480. @deftypevr {@code{tlp-configuration} parameter} package tlp
  23481. The TLP package.
  23482. @end deftypevr
  23483. @deftypevr {@code{tlp-configuration} parameter} boolean tlp-enable?
  23484. Set to true if you wish to enable TLP.
  23485. Defaults to @samp{#t}.
  23486. @end deftypevr
  23487. @deftypevr {@code{tlp-configuration} parameter} string tlp-default-mode
  23488. Default mode when no power supply can be detected. Alternatives are AC
  23489. and BAT.
  23490. Defaults to @samp{"AC"}.
  23491. @end deftypevr
  23492. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer disk-idle-secs-on-ac
  23493. Number of seconds Linux kernel has to wait after the disk goes idle,
  23494. before syncing on AC.
  23495. Defaults to @samp{0}.
  23496. @end deftypevr
  23497. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer disk-idle-secs-on-bat
  23498. Same as @code{disk-idle-ac} but on BAT mode.
  23499. Defaults to @samp{2}.
  23500. @end deftypevr
  23501. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer max-lost-work-secs-on-ac
  23502. Dirty pages flushing periodicity, expressed in seconds.
  23503. Defaults to @samp{15}.
  23504. @end deftypevr
  23505. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer max-lost-work-secs-on-bat
  23506. Same as @code{max-lost-work-secs-on-ac} but on BAT mode.
  23507. Defaults to @samp{60}.
  23508. @end deftypevr
  23509. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list cpu-scaling-governor-on-ac
  23510. CPU frequency scaling governor on AC mode. With intel_pstate driver,
  23511. alternatives are powersave and performance. With acpi-cpufreq driver,
  23512. alternatives are ondemand, powersave, performance and conservative.
  23513. Defaults to @samp{disabled}.
  23514. @end deftypevr
  23515. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list cpu-scaling-governor-on-bat
  23516. Same as @code{cpu-scaling-governor-on-ac} but on BAT mode.
  23517. Defaults to @samp{disabled}.
  23518. @end deftypevr
  23519. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-min-freq-on-ac
  23520. Set the min available frequency for the scaling governor on AC.
  23521. Defaults to @samp{disabled}.
  23522. @end deftypevr
  23523. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-max-freq-on-ac
  23524. Set the max available frequency for the scaling governor on AC.
  23525. Defaults to @samp{disabled}.
  23526. @end deftypevr
  23527. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-min-freq-on-bat
  23528. Set the min available frequency for the scaling governor on BAT.
  23529. Defaults to @samp{disabled}.
  23530. @end deftypevr
  23531. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-max-freq-on-bat
  23532. Set the max available frequency for the scaling governor on BAT.
  23533. Defaults to @samp{disabled}.
  23534. @end deftypevr
  23535. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-min-perf-on-ac
  23536. Limit the min P-state to control the power dissipation of the CPU, in AC
  23537. mode. Values are stated as a percentage of the available performance.
  23538. Defaults to @samp{disabled}.
  23539. @end deftypevr
  23540. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-max-perf-on-ac
  23541. Limit the max P-state to control the power dissipation of the CPU, in AC
  23542. mode. Values are stated as a percentage of the available performance.
  23543. Defaults to @samp{disabled}.
  23544. @end deftypevr
  23545. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-min-perf-on-bat
  23546. Same as @code{cpu-min-perf-on-ac} on BAT mode.
  23547. Defaults to @samp{disabled}.
  23548. @end deftypevr
  23549. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-max-perf-on-bat
  23550. Same as @code{cpu-max-perf-on-ac} on BAT mode.
  23551. Defaults to @samp{disabled}.
  23552. @end deftypevr
  23553. @deftypevr {@code{tlp-configuration} parameter} maybe-boolean cpu-boost-on-ac?
  23554. Enable CPU turbo boost feature on AC mode.
  23555. Defaults to @samp{disabled}.
  23556. @end deftypevr
  23557. @deftypevr {@code{tlp-configuration} parameter} maybe-boolean cpu-boost-on-bat?
  23558. Same as @code{cpu-boost-on-ac?} on BAT mode.
  23559. Defaults to @samp{disabled}.
  23560. @end deftypevr
  23561. @deftypevr {@code{tlp-configuration} parameter} boolean sched-powersave-on-ac?
  23562. Allow Linux kernel to minimize the number of CPU cores/hyper-threads
  23563. used under light load conditions.
  23564. Defaults to @samp{#f}.
  23565. @end deftypevr
  23566. @deftypevr {@code{tlp-configuration} parameter} boolean sched-powersave-on-bat?
  23567. Same as @code{sched-powersave-on-ac?} but on BAT mode.
  23568. Defaults to @samp{#t}.
  23569. @end deftypevr
  23570. @deftypevr {@code{tlp-configuration} parameter} boolean nmi-watchdog?
  23571. Enable Linux kernel NMI watchdog.
  23572. Defaults to @samp{#f}.
  23573. @end deftypevr
  23574. @deftypevr {@code{tlp-configuration} parameter} maybe-string phc-controls
  23575. For Linux kernels with PHC patch applied, change CPU voltages. An
  23576. example value would be @samp{"F:V F:V F:V F:V"}.
  23577. Defaults to @samp{disabled}.
  23578. @end deftypevr
  23579. @deftypevr {@code{tlp-configuration} parameter} string energy-perf-policy-on-ac
  23580. Set CPU performance versus energy saving policy on AC@. Alternatives are
  23581. performance, normal, powersave.
  23582. Defaults to @samp{"performance"}.
  23583. @end deftypevr
  23584. @deftypevr {@code{tlp-configuration} parameter} string energy-perf-policy-on-bat
  23585. Same as @code{energy-perf-policy-ac} but on BAT mode.
  23586. Defaults to @samp{"powersave"}.
  23587. @end deftypevr
  23588. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disks-devices
  23589. Hard disk devices.
  23590. @end deftypevr
  23591. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disk-apm-level-on-ac
  23592. Hard disk advanced power management level.
  23593. @end deftypevr
  23594. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disk-apm-level-on-bat
  23595. Same as @code{disk-apm-bat} but on BAT mode.
  23596. @end deftypevr
  23597. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-spindown-timeout-on-ac
  23598. Hard disk spin down timeout. One value has to be specified for each
  23599. declared hard disk.
  23600. Defaults to @samp{disabled}.
  23601. @end deftypevr
  23602. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-spindown-timeout-on-bat
  23603. Same as @code{disk-spindown-timeout-on-ac} but on BAT mode.
  23604. Defaults to @samp{disabled}.
  23605. @end deftypevr
  23606. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-iosched
  23607. Select IO scheduler for disk devices. One value has to be specified for
  23608. each declared hard disk. Example alternatives are cfq, deadline and
  23609. noop.
  23610. Defaults to @samp{disabled}.
  23611. @end deftypevr
  23612. @deftypevr {@code{tlp-configuration} parameter} string sata-linkpwr-on-ac
  23613. SATA aggressive link power management (ALPM) level. Alternatives are
  23614. min_power, medium_power, max_performance.
  23615. Defaults to @samp{"max_performance"}.
  23616. @end deftypevr
  23617. @deftypevr {@code{tlp-configuration} parameter} string sata-linkpwr-on-bat
  23618. Same as @code{sata-linkpwr-ac} but on BAT mode.
  23619. Defaults to @samp{"min_power"}.
  23620. @end deftypevr
  23621. @deftypevr {@code{tlp-configuration} parameter} maybe-string sata-linkpwr-blacklist
  23622. Exclude specified SATA host devices for link power management.
  23623. Defaults to @samp{disabled}.
  23624. @end deftypevr
  23625. @deftypevr {@code{tlp-configuration} parameter} maybe-on-off-boolean ahci-runtime-pm-on-ac?
  23626. Enable Runtime Power Management for AHCI controller and disks on AC
  23627. mode.
  23628. Defaults to @samp{disabled}.
  23629. @end deftypevr
  23630. @deftypevr {@code{tlp-configuration} parameter} maybe-on-off-boolean ahci-runtime-pm-on-bat?
  23631. Same as @code{ahci-runtime-pm-on-ac} on BAT mode.
  23632. Defaults to @samp{disabled}.
  23633. @end deftypevr
  23634. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer ahci-runtime-pm-timeout
  23635. Seconds of inactivity before disk is suspended.
  23636. Defaults to @samp{15}.
  23637. @end deftypevr
  23638. @deftypevr {@code{tlp-configuration} parameter} string pcie-aspm-on-ac
  23639. PCI Express Active State Power Management level. Alternatives are
  23640. default, performance, powersave.
  23641. Defaults to @samp{"performance"}.
  23642. @end deftypevr
  23643. @deftypevr {@code{tlp-configuration} parameter} string pcie-aspm-on-bat
  23644. Same as @code{pcie-aspm-ac} but on BAT mode.
  23645. Defaults to @samp{"powersave"}.
  23646. @end deftypevr
  23647. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer start-charge-thresh-bat0
  23648. Percentage when battery 0 should begin charging. Only supported on some laptops.
  23649. Defaults to @samp{disabled}.
  23650. @end deftypevr
  23651. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer stop-charge-thresh-bat0
  23652. Percentage when battery 0 should stop charging. Only supported on some laptops.
  23653. Defaults to @samp{disabled}.
  23654. @end deftypevr
  23655. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer start-charge-thresh-bat1
  23656. Percentage when battery 1 should begin charging. Only supported on some laptops.
  23657. Defaults to @samp{disabled}.
  23658. @end deftypevr
  23659. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer stop-charge-thresh-bat1
  23660. Percentage when battery 1 should stop charging. Only supported on some laptops.
  23661. Defaults to @samp{disabled}.
  23662. @end deftypevr
  23663. @deftypevr {@code{tlp-configuration} parameter} string radeon-power-profile-on-ac
  23664. Radeon graphics clock speed level. Alternatives are low, mid, high,
  23665. auto, default.
  23666. Defaults to @samp{"high"}.
  23667. @end deftypevr
  23668. @deftypevr {@code{tlp-configuration} parameter} string radeon-power-profile-on-bat
  23669. Same as @code{radeon-power-ac} but on BAT mode.
  23670. Defaults to @samp{"low"}.
  23671. @end deftypevr
  23672. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-state-on-ac
  23673. Radeon dynamic power management method (DPM). Alternatives are battery,
  23674. performance.
  23675. Defaults to @samp{"performance"}.
  23676. @end deftypevr
  23677. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-state-on-bat
  23678. Same as @code{radeon-dpm-state-ac} but on BAT mode.
  23679. Defaults to @samp{"battery"}.
  23680. @end deftypevr
  23681. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-perf-level-on-ac
  23682. Radeon DPM performance level. Alternatives are auto, low, high.
  23683. Defaults to @samp{"auto"}.
  23684. @end deftypevr
  23685. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-perf-level-on-bat
  23686. Same as @code{radeon-dpm-perf-ac} but on BAT mode.
  23687. Defaults to @samp{"auto"}.
  23688. @end deftypevr
  23689. @deftypevr {@code{tlp-configuration} parameter} on-off-boolean wifi-pwr-on-ac?
  23690. Wifi power saving mode.
  23691. Defaults to @samp{#f}.
  23692. @end deftypevr
  23693. @deftypevr {@code{tlp-configuration} parameter} on-off-boolean wifi-pwr-on-bat?
  23694. Same as @code{wifi-power-ac?} but on BAT mode.
  23695. Defaults to @samp{#t}.
  23696. @end deftypevr
  23697. @deftypevr {@code{tlp-configuration} parameter} y-n-boolean wol-disable?
  23698. Disable wake on LAN.
  23699. Defaults to @samp{#t}.
  23700. @end deftypevr
  23701. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer sound-power-save-on-ac
  23702. Timeout duration in seconds before activating audio power saving on
  23703. Intel HDA and AC97 devices. A value of 0 disables power saving.
  23704. Defaults to @samp{0}.
  23705. @end deftypevr
  23706. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer sound-power-save-on-bat
  23707. Same as @code{sound-powersave-ac} but on BAT mode.
  23708. Defaults to @samp{1}.
  23709. @end deftypevr
  23710. @deftypevr {@code{tlp-configuration} parameter} y-n-boolean sound-power-save-controller?
  23711. Disable controller in powersaving mode on Intel HDA devices.
  23712. Defaults to @samp{#t}.
  23713. @end deftypevr
  23714. @deftypevr {@code{tlp-configuration} parameter} boolean bay-poweroff-on-bat?
  23715. Enable optical drive in UltraBay/MediaBay on BAT mode. Drive can be
  23716. powered on again by releasing (and reinserting) the eject lever or by
  23717. pressing the disc eject button on newer models.
  23718. Defaults to @samp{#f}.
  23719. @end deftypevr
  23720. @deftypevr {@code{tlp-configuration} parameter} string bay-device
  23721. Name of the optical drive device to power off.
  23722. Defaults to @samp{"sr0"}.
  23723. @end deftypevr
  23724. @deftypevr {@code{tlp-configuration} parameter} string runtime-pm-on-ac
  23725. Runtime Power Management for PCI(e) bus devices. Alternatives are on
  23726. and auto.
  23727. Defaults to @samp{"on"}.
  23728. @end deftypevr
  23729. @deftypevr {@code{tlp-configuration} parameter} string runtime-pm-on-bat
  23730. Same as @code{runtime-pm-ac} but on BAT mode.
  23731. Defaults to @samp{"auto"}.
  23732. @end deftypevr
  23733. @deftypevr {@code{tlp-configuration} parameter} boolean runtime-pm-all?
  23734. Runtime Power Management for all PCI(e) bus devices, except blacklisted
  23735. ones.
  23736. Defaults to @samp{#t}.
  23737. @end deftypevr
  23738. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list runtime-pm-blacklist
  23739. Exclude specified PCI(e) device addresses from Runtime Power Management.
  23740. Defaults to @samp{disabled}.
  23741. @end deftypevr
  23742. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list runtime-pm-driver-blacklist
  23743. Exclude PCI(e) devices assigned to the specified drivers from Runtime
  23744. Power Management.
  23745. @end deftypevr
  23746. @deftypevr {@code{tlp-configuration} parameter} boolean usb-autosuspend?
  23747. Enable USB autosuspend feature.
  23748. Defaults to @samp{#t}.
  23749. @end deftypevr
  23750. @deftypevr {@code{tlp-configuration} parameter} maybe-string usb-blacklist
  23751. Exclude specified devices from USB autosuspend.
  23752. Defaults to @samp{disabled}.
  23753. @end deftypevr
  23754. @deftypevr {@code{tlp-configuration} parameter} boolean usb-blacklist-wwan?
  23755. Exclude WWAN devices from USB autosuspend.
  23756. Defaults to @samp{#t}.
  23757. @end deftypevr
  23758. @deftypevr {@code{tlp-configuration} parameter} maybe-string usb-whitelist
  23759. Include specified devices into USB autosuspend, even if they are already
  23760. excluded by the driver or via @code{usb-blacklist-wwan?}.
  23761. Defaults to @samp{disabled}.
  23762. @end deftypevr
  23763. @deftypevr {@code{tlp-configuration} parameter} maybe-boolean usb-autosuspend-disable-on-shutdown?
  23764. Enable USB autosuspend before shutdown.
  23765. Defaults to @samp{disabled}.
  23766. @end deftypevr
  23767. @deftypevr {@code{tlp-configuration} parameter} boolean restore-device-state-on-startup?
  23768. Restore radio device state (bluetooth, wifi, wwan) from previous
  23769. shutdown on system startup.
  23770. Defaults to @samp{#f}.
  23771. @end deftypevr
  23772. @cindex thermald
  23773. @cindex CPU frequency scaling with thermald
  23774. @subsubheading Thermald daemon
  23775. The @code{(gnu services pm)} module provides an interface to
  23776. thermald, a CPU frequency scaling service which helps prevent overheating.
  23777. @defvr {Scheme Variable} thermald-service-type
  23778. This is the service type for
  23779. @uref{https://01.org/linux-thermal-daemon/, thermald}, the Linux
  23780. Thermal Daemon, which is responsible for controlling the thermal state
  23781. of processors and preventing overheating.
  23782. @end defvr
  23783. @deftp {Data Type} thermald-configuration
  23784. Data type representing the configuration of @code{thermald-service-type}.
  23785. @table @asis
  23786. @item @code{ignore-cpuid-check?} (default: @code{#f})
  23787. Ignore cpuid check for supported CPU models.
  23788. @item @code{thermald} (default: @var{thermald})
  23789. Package object of thermald.
  23790. @end table
  23791. @end deftp
  23792. @node Audio Services
  23793. @subsection Audio Services
  23794. The @code{(gnu services audio)} module provides a service to start MPD
  23795. (the Music Player Daemon).
  23796. @cindex mpd
  23797. @subsubheading Music Player Daemon
  23798. The Music Player Daemon (MPD) is a service that can play music while
  23799. being controlled from the local machine or over the network by a variety
  23800. of clients.
  23801. The following example shows how one might run @code{mpd} as user
  23802. @code{"bob"} on port @code{6666}. It uses pulseaudio for output.
  23803. @lisp
  23804. (service mpd-service-type
  23805. (mpd-configuration
  23806. (user "bob")
  23807. (port "6666")))
  23808. @end lisp
  23809. @defvr {Scheme Variable} mpd-service-type
  23810. The service type for @command{mpd}
  23811. @end defvr
  23812. @deftp {Data Type} mpd-configuration
  23813. Data type representing the configuration of @command{mpd}.
  23814. @table @asis
  23815. @item @code{user} (default: @code{"mpd"})
  23816. The user to run mpd as.
  23817. @item @code{music-dir} (default: @code{"~/Music"})
  23818. The directory to scan for music files.
  23819. @item @code{playlist-dir} (default: @code{"~/.mpd/playlists"})
  23820. The directory to store playlists.
  23821. @item @code{db-file} (default: @code{"~/.mpd/tag_cache"})
  23822. The location of the music database.
  23823. @item @code{state-file} (default: @code{"~/.mpd/state"})
  23824. The location of the file that stores current MPD's state.
  23825. @item @code{sticker-file} (default: @code{"~/.mpd/sticker.sql"})
  23826. The location of the sticker database.
  23827. @item @code{port} (default: @code{"6600"})
  23828. The port to run mpd on.
  23829. @item @code{address} (default: @code{"any"})
  23830. The address that mpd will bind to. To use a Unix domain socket,
  23831. an absolute path can be specified here.
  23832. @item @code{outputs} (default: @code{"(list (mpd-output))"})
  23833. The audio outputs that MPD can use. By default this is a single output using pulseaudio.
  23834. @end table
  23835. @end deftp
  23836. @deftp {Data Type} mpd-output
  23837. Data type representing an @command{mpd} audio output.
  23838. @table @asis
  23839. @item @code{name} (default: @code{"MPD"})
  23840. The name of the audio output.
  23841. @item @code{type} (default: @code{"pulse"})
  23842. The type of audio output.
  23843. @item @code{enabled?} (default: @code{#t})
  23844. Specifies whether this audio output is enabled when MPD is started. By
  23845. default, all audio outputs are enabled. This is just the default
  23846. setting when there is no state file; with a state file, the previous
  23847. state is restored.
  23848. @item @code{tags?} (default: @code{#t})
  23849. If set to @code{#f}, then MPD will not send tags to this output. This
  23850. is only useful for output plugins that can receive tags, for example the
  23851. @code{httpd} output plugin.
  23852. @item @code{always-on?} (default: @code{#f})
  23853. If set to @code{#t}, then MPD attempts to keep this audio output always
  23854. open. This may be useful for streaming servers, when you don’t want to
  23855. disconnect all listeners even when playback is accidentally stopped.
  23856. @item @code{mixer-type}
  23857. This field accepts a symbol that specifies which mixer should be used
  23858. for this audio output: the @code{hardware} mixer, the @code{software}
  23859. mixer, the @code{null} mixer (allows setting the volume, but with no
  23860. effect; this can be used as a trick to implement an external mixer
  23861. External Mixer) or no mixer (@code{none}).
  23862. @item @code{extra-options} (default: @code{'()})
  23863. An association list of option symbols to string values to be appended to
  23864. the audio output configuration.
  23865. @end table
  23866. @end deftp
  23867. The following example shows a configuration of @code{mpd} that provides
  23868. an HTTP audio streaming output.
  23869. @lisp
  23870. (service mpd-service-type
  23871. (mpd-configuration
  23872. (outputs
  23873. (list (mpd-output
  23874. (name "streaming")
  23875. (type "httpd")
  23876. (mixer-type 'null)
  23877. (extra-options
  23878. `((encoder . "vorbis")
  23879. (port . "8080"))))))))
  23880. @end lisp
  23881. @node Virtualization Services
  23882. @subsection Virtualization Services
  23883. The @code{(gnu services virtualization)} module provides services for
  23884. the libvirt and virtlog daemons, as well as other virtualization-related
  23885. services.
  23886. @subsubheading Libvirt daemon
  23887. @code{libvirtd} is the server side daemon component of the libvirt
  23888. virtualization management system. This daemon runs on host servers
  23889. and performs required management tasks for virtualized guests.
  23890. @deffn {Scheme Variable} libvirt-service-type
  23891. This is the type of the @uref{https://libvirt.org, libvirt daemon}.
  23892. Its value must be a @code{libvirt-configuration}.
  23893. @lisp
  23894. (service libvirt-service-type
  23895. (libvirt-configuration
  23896. (unix-sock-group "libvirt")
  23897. (tls-port "16555")))
  23898. @end lisp
  23899. @end deffn
  23900. @c Auto-generated with (generate-libvirt-documentation)
  23901. Available @code{libvirt-configuration} fields are:
  23902. @deftypevr {@code{libvirt-configuration} parameter} package libvirt
  23903. Libvirt package.
  23904. @end deftypevr
  23905. @deftypevr {@code{libvirt-configuration} parameter} boolean listen-tls?
  23906. Flag listening for secure TLS connections on the public TCP/IP port.
  23907. You must set @code{listen} for this to have any effect.
  23908. It is necessary to setup a CA and issue server certificates before using
  23909. this capability.
  23910. Defaults to @samp{#t}.
  23911. @end deftypevr
  23912. @deftypevr {@code{libvirt-configuration} parameter} boolean listen-tcp?
  23913. Listen for unencrypted TCP connections on the public TCP/IP port. You must
  23914. set @code{listen} for this to have any effect.
  23915. Using the TCP socket requires SASL authentication by default. Only SASL
  23916. mechanisms which support data encryption are allowed. This is
  23917. DIGEST_MD5 and GSSAPI (Kerberos5).
  23918. Defaults to @samp{#f}.
  23919. @end deftypevr
  23920. @deftypevr {@code{libvirt-configuration} parameter} string tls-port
  23921. Port for accepting secure TLS connections. This can be a port number,
  23922. or service name.
  23923. Defaults to @samp{"16514"}.
  23924. @end deftypevr
  23925. @deftypevr {@code{libvirt-configuration} parameter} string tcp-port
  23926. Port for accepting insecure TCP connections. This can be a port number,
  23927. or service name.
  23928. Defaults to @samp{"16509"}.
  23929. @end deftypevr
  23930. @deftypevr {@code{libvirt-configuration} parameter} string listen-addr
  23931. IP address or hostname used for client connections.
  23932. Defaults to @samp{"0.0.0.0"}.
  23933. @end deftypevr
  23934. @deftypevr {@code{libvirt-configuration} parameter} boolean mdns-adv?
  23935. Flag toggling mDNS advertisement of the libvirt service.
  23936. Alternatively can disable for all services on a host by stopping the
  23937. Avahi daemon.
  23938. Defaults to @samp{#f}.
  23939. @end deftypevr
  23940. @deftypevr {@code{libvirt-configuration} parameter} string mdns-name
  23941. Default mDNS advertisement name. This must be unique on the immediate
  23942. broadcast network.
  23943. Defaults to @samp{"Virtualization Host <hostname>"}.
  23944. @end deftypevr
  23945. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-group
  23946. UNIX domain socket group ownership. This can be used to allow a
  23947. 'trusted' set of users access to management capabilities without
  23948. becoming root.
  23949. Defaults to @samp{"root"}.
  23950. @end deftypevr
  23951. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-ro-perms
  23952. UNIX socket permissions for the R/O socket. This is used for monitoring
  23953. VM status only.
  23954. Defaults to @samp{"0777"}.
  23955. @end deftypevr
  23956. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-rw-perms
  23957. UNIX socket permissions for the R/W socket. Default allows only root.
  23958. If PolicyKit is enabled on the socket, the default will change to allow
  23959. everyone (eg, 0777)
  23960. Defaults to @samp{"0770"}.
  23961. @end deftypevr
  23962. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-admin-perms
  23963. UNIX socket permissions for the admin socket. Default allows only owner
  23964. (root), do not change it unless you are sure to whom you are exposing
  23965. the access to.
  23966. Defaults to @samp{"0777"}.
  23967. @end deftypevr
  23968. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-dir
  23969. The directory in which sockets will be found/created.
  23970. Defaults to @samp{"/var/run/libvirt"}.
  23971. @end deftypevr
  23972. @deftypevr {@code{libvirt-configuration} parameter} string auth-unix-ro
  23973. Authentication scheme for UNIX read-only sockets. By default socket
  23974. permissions allow anyone to connect
  23975. Defaults to @samp{"polkit"}.
  23976. @end deftypevr
  23977. @deftypevr {@code{libvirt-configuration} parameter} string auth-unix-rw
  23978. Authentication scheme for UNIX read-write sockets. By default socket
  23979. permissions only allow root. If PolicyKit support was compiled into
  23980. libvirt, the default will be to use 'polkit' auth.
  23981. Defaults to @samp{"polkit"}.
  23982. @end deftypevr
  23983. @deftypevr {@code{libvirt-configuration} parameter} string auth-tcp
  23984. Authentication scheme for TCP sockets. If you don't enable SASL, then
  23985. all TCP traffic is cleartext. Don't do this outside of a dev/test
  23986. scenario.
  23987. Defaults to @samp{"sasl"}.
  23988. @end deftypevr
  23989. @deftypevr {@code{libvirt-configuration} parameter} string auth-tls
  23990. Authentication scheme for TLS sockets. TLS sockets already have
  23991. encryption provided by the TLS layer, and limited authentication is done
  23992. by certificates.
  23993. It is possible to make use of any SASL authentication mechanism as well,
  23994. by using 'sasl' for this option
  23995. Defaults to @samp{"none"}.
  23996. @end deftypevr
  23997. @deftypevr {@code{libvirt-configuration} parameter} optional-list access-drivers
  23998. API access control scheme.
  23999. By default an authenticated user is allowed access to all APIs. Access
  24000. drivers can place restrictions on this.
  24001. Defaults to @samp{()}.
  24002. @end deftypevr
  24003. @deftypevr {@code{libvirt-configuration} parameter} string key-file
  24004. Server key file path. If set to an empty string, then no private key is
  24005. loaded.
  24006. Defaults to @samp{""}.
  24007. @end deftypevr
  24008. @deftypevr {@code{libvirt-configuration} parameter} string cert-file
  24009. Server key file path. If set to an empty string, then no certificate is
  24010. loaded.
  24011. Defaults to @samp{""}.
  24012. @end deftypevr
  24013. @deftypevr {@code{libvirt-configuration} parameter} string ca-file
  24014. Server key file path. If set to an empty string, then no CA certificate
  24015. is loaded.
  24016. Defaults to @samp{""}.
  24017. @end deftypevr
  24018. @deftypevr {@code{libvirt-configuration} parameter} string crl-file
  24019. Certificate revocation list path. If set to an empty string, then no
  24020. CRL is loaded.
  24021. Defaults to @samp{""}.
  24022. @end deftypevr
  24023. @deftypevr {@code{libvirt-configuration} parameter} boolean tls-no-sanity-cert
  24024. Disable verification of our own server certificates.
  24025. When libvirtd starts it performs some sanity checks against its own
  24026. certificates.
  24027. Defaults to @samp{#f}.
  24028. @end deftypevr
  24029. @deftypevr {@code{libvirt-configuration} parameter} boolean tls-no-verify-cert
  24030. Disable verification of client certificates.
  24031. Client certificate verification is the primary authentication mechanism.
  24032. Any client which does not present a certificate signed by the CA will be
  24033. rejected.
  24034. Defaults to @samp{#f}.
  24035. @end deftypevr
  24036. @deftypevr {@code{libvirt-configuration} parameter} optional-list tls-allowed-dn-list
  24037. Whitelist of allowed x509 Distinguished Name.
  24038. Defaults to @samp{()}.
  24039. @end deftypevr
  24040. @deftypevr {@code{libvirt-configuration} parameter} optional-list sasl-allowed-usernames
  24041. Whitelist of allowed SASL usernames. The format for username depends on
  24042. the SASL authentication mechanism.
  24043. Defaults to @samp{()}.
  24044. @end deftypevr
  24045. @deftypevr {@code{libvirt-configuration} parameter} string tls-priority
  24046. Override the compile time default TLS priority string. The default is
  24047. usually @samp{"NORMAL"} unless overridden at build time. Only set this is it
  24048. is desired for libvirt to deviate from the global default settings.
  24049. Defaults to @samp{"NORMAL"}.
  24050. @end deftypevr
  24051. @deftypevr {@code{libvirt-configuration} parameter} integer max-clients
  24052. Maximum number of concurrent client connections to allow over all
  24053. sockets combined.
  24054. Defaults to @samp{5000}.
  24055. @end deftypevr
  24056. @deftypevr {@code{libvirt-configuration} parameter} integer max-queued-clients
  24057. Maximum length of queue of connections waiting to be accepted by the
  24058. daemon. Note, that some protocols supporting retransmission may obey
  24059. this so that a later reattempt at connection succeeds.
  24060. Defaults to @samp{1000}.
  24061. @end deftypevr
  24062. @deftypevr {@code{libvirt-configuration} parameter} integer max-anonymous-clients
  24063. Maximum length of queue of accepted but not yet authenticated clients.
  24064. Set this to zero to turn this feature off
  24065. Defaults to @samp{20}.
  24066. @end deftypevr
  24067. @deftypevr {@code{libvirt-configuration} parameter} integer min-workers
  24068. Number of workers to start up initially.
  24069. Defaults to @samp{5}.
  24070. @end deftypevr
  24071. @deftypevr {@code{libvirt-configuration} parameter} integer max-workers
  24072. Maximum number of worker threads.
  24073. If the number of active clients exceeds @code{min-workers}, then more
  24074. threads are spawned, up to max_workers limit. Typically you'd want
  24075. max_workers to equal maximum number of clients allowed.
  24076. Defaults to @samp{20}.
  24077. @end deftypevr
  24078. @deftypevr {@code{libvirt-configuration} parameter} integer prio-workers
  24079. Number of priority workers. If all workers from above pool are stuck,
  24080. some calls marked as high priority (notably domainDestroy) can be
  24081. executed in this pool.
  24082. Defaults to @samp{5}.
  24083. @end deftypevr
  24084. @deftypevr {@code{libvirt-configuration} parameter} integer max-requests
  24085. Total global limit on concurrent RPC calls.
  24086. Defaults to @samp{20}.
  24087. @end deftypevr
  24088. @deftypevr {@code{libvirt-configuration} parameter} integer max-client-requests
  24089. Limit on concurrent requests from a single client connection. To avoid
  24090. one client monopolizing the server this should be a small fraction of
  24091. the global max_requests and max_workers parameter.
  24092. Defaults to @samp{5}.
  24093. @end deftypevr
  24094. @deftypevr {@code{libvirt-configuration} parameter} integer admin-min-workers
  24095. Same as @code{min-workers} but for the admin interface.
  24096. Defaults to @samp{1}.
  24097. @end deftypevr
  24098. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-workers
  24099. Same as @code{max-workers} but for the admin interface.
  24100. Defaults to @samp{5}.
  24101. @end deftypevr
  24102. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-clients
  24103. Same as @code{max-clients} but for the admin interface.
  24104. Defaults to @samp{5}.
  24105. @end deftypevr
  24106. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-queued-clients
  24107. Same as @code{max-queued-clients} but for the admin interface.
  24108. Defaults to @samp{5}.
  24109. @end deftypevr
  24110. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-client-requests
  24111. Same as @code{max-client-requests} but for the admin interface.
  24112. Defaults to @samp{5}.
  24113. @end deftypevr
  24114. @deftypevr {@code{libvirt-configuration} parameter} integer log-level
  24115. Logging level. 4 errors, 3 warnings, 2 information, 1 debug.
  24116. Defaults to @samp{3}.
  24117. @end deftypevr
  24118. @deftypevr {@code{libvirt-configuration} parameter} string log-filters
  24119. Logging filters.
  24120. A filter allows to select a different logging level for a given category
  24121. of logs. The format for a filter is one of:
  24122. @itemize @bullet
  24123. @item
  24124. x:name
  24125. @item
  24126. x:+name
  24127. @end itemize
  24128. where @code{name} is a string which is matched against the category
  24129. given in the @code{VIR_LOG_INIT()} at the top of each libvirt source
  24130. file, e.g., @samp{"remote"}, @samp{"qemu"}, or @samp{"util.json"} (the
  24131. name in the filter can be a substring of the full category name, in
  24132. order to match multiple similar categories), the optional @samp{"+"}
  24133. prefix tells libvirt to log stack trace for each message matching name,
  24134. and @code{x} is the minimal level where matching messages should be
  24135. logged:
  24136. @itemize @bullet
  24137. @item
  24138. 1: DEBUG
  24139. @item
  24140. 2: INFO
  24141. @item
  24142. 3: WARNING
  24143. @item
  24144. 4: ERROR
  24145. @end itemize
  24146. Multiple filters can be defined in a single filters statement, they just
  24147. need to be separated by spaces.
  24148. Defaults to @samp{"3:remote 4:event"}.
  24149. @end deftypevr
  24150. @deftypevr {@code{libvirt-configuration} parameter} string log-outputs
  24151. Logging outputs.
  24152. An output is one of the places to save logging information. The format
  24153. for an output can be:
  24154. @table @code
  24155. @item x:stderr
  24156. output goes to stderr
  24157. @item x:syslog:name
  24158. use syslog for the output and use the given name as the ident
  24159. @item x:file:file_path
  24160. output to a file, with the given filepath
  24161. @item x:journald
  24162. output to journald logging system
  24163. @end table
  24164. In all case the x prefix is the minimal level, acting as a filter
  24165. @itemize @bullet
  24166. @item
  24167. 1: DEBUG
  24168. @item
  24169. 2: INFO
  24170. @item
  24171. 3: WARNING
  24172. @item
  24173. 4: ERROR
  24174. @end itemize
  24175. Multiple outputs can be defined, they just need to be separated by
  24176. spaces.
  24177. Defaults to @samp{"3:stderr"}.
  24178. @end deftypevr
  24179. @deftypevr {@code{libvirt-configuration} parameter} integer audit-level
  24180. Allows usage of the auditing subsystem to be altered
  24181. @itemize @bullet
  24182. @item
  24183. 0: disable all auditing
  24184. @item
  24185. 1: enable auditing, only if enabled on host
  24186. @item
  24187. 2: enable auditing, and exit if disabled on host.
  24188. @end itemize
  24189. Defaults to @samp{1}.
  24190. @end deftypevr
  24191. @deftypevr {@code{libvirt-configuration} parameter} boolean audit-logging
  24192. Send audit messages via libvirt logging infrastructure.
  24193. Defaults to @samp{#f}.
  24194. @end deftypevr
  24195. @deftypevr {@code{libvirt-configuration} parameter} optional-string host-uuid
  24196. Host UUID@. UUID must not have all digits be the same.
  24197. Defaults to @samp{""}.
  24198. @end deftypevr
  24199. @deftypevr {@code{libvirt-configuration} parameter} string host-uuid-source
  24200. Source to read host UUID.
  24201. @itemize @bullet
  24202. @item
  24203. @code{smbios}: fetch the UUID from @code{dmidecode -s system-uuid}
  24204. @item
  24205. @code{machine-id}: fetch the UUID from @code{/etc/machine-id}
  24206. @end itemize
  24207. If @code{dmidecode} does not provide a valid UUID a temporary UUID will
  24208. be generated.
  24209. Defaults to @samp{"smbios"}.
  24210. @end deftypevr
  24211. @deftypevr {@code{libvirt-configuration} parameter} integer keepalive-interval
  24212. A keepalive message is sent to a client after @code{keepalive_interval}
  24213. seconds of inactivity to check if the client is still responding. If
  24214. set to -1, libvirtd will never send keepalive requests; however clients
  24215. can still send them and the daemon will send responses.
  24216. Defaults to @samp{5}.
  24217. @end deftypevr
  24218. @deftypevr {@code{libvirt-configuration} parameter} integer keepalive-count
  24219. Maximum number of keepalive messages that are allowed to be sent to the
  24220. client without getting any response before the connection is considered
  24221. broken.
  24222. In other words, the connection is automatically closed approximately
  24223. after @code{keepalive_interval * (keepalive_count + 1)} seconds since
  24224. the last message received from the client. When @code{keepalive-count}
  24225. is set to 0, connections will be automatically closed after
  24226. @code{keepalive-interval} seconds of inactivity without sending any
  24227. keepalive messages.
  24228. Defaults to @samp{5}.
  24229. @end deftypevr
  24230. @deftypevr {@code{libvirt-configuration} parameter} integer admin-keepalive-interval
  24231. Same as above but for admin interface.
  24232. Defaults to @samp{5}.
  24233. @end deftypevr
  24234. @deftypevr {@code{libvirt-configuration} parameter} integer admin-keepalive-count
  24235. Same as above but for admin interface.
  24236. Defaults to @samp{5}.
  24237. @end deftypevr
  24238. @deftypevr {@code{libvirt-configuration} parameter} integer ovs-timeout
  24239. Timeout for Open vSwitch calls.
  24240. The @code{ovs-vsctl} utility is used for the configuration and its
  24241. timeout option is set by default to 5 seconds to avoid potential
  24242. infinite waits blocking libvirt.
  24243. Defaults to @samp{5}.
  24244. @end deftypevr
  24245. @c %end of autogenerated docs
  24246. @subsubheading Virtlog daemon
  24247. The virtlogd service is a server side daemon component of libvirt that is
  24248. used to manage logs from virtual machine consoles.
  24249. This daemon is not used directly by libvirt client applications, rather it
  24250. is called on their behalf by @code{libvirtd}. By maintaining the logs in a
  24251. standalone daemon, the main @code{libvirtd} daemon can be restarted without
  24252. risk of losing logs. The @code{virtlogd} daemon has the ability to re-exec()
  24253. itself upon receiving @code{SIGUSR1}, to allow live upgrades without downtime.
  24254. @deffn {Scheme Variable} virtlog-service-type
  24255. This is the type of the virtlog daemon.
  24256. Its value must be a @code{virtlog-configuration}.
  24257. @lisp
  24258. (service virtlog-service-type
  24259. (virtlog-configuration
  24260. (max-clients 1000)))
  24261. @end lisp
  24262. @end deffn
  24263. @deftypevar {@code{libvirt} parameter} package libvirt
  24264. Libvirt package.
  24265. @end deftypevar
  24266. @deftypevr {@code{virtlog-configuration} parameter} integer log-level
  24267. Logging level. 4 errors, 3 warnings, 2 information, 1 debug.
  24268. Defaults to @samp{3}.
  24269. @end deftypevr
  24270. @deftypevr {@code{virtlog-configuration} parameter} string log-filters
  24271. Logging filters.
  24272. A filter allows to select a different logging level for a given category
  24273. of logs The format for a filter is one of:
  24274. @itemize @bullet
  24275. @item
  24276. x:name
  24277. @item
  24278. x:+name
  24279. @end itemize
  24280. where @code{name} is a string which is matched against the category
  24281. given in the @code{VIR_LOG_INIT()} at the top of each libvirt source
  24282. file, e.g., "remote", "qemu", or "util.json" (the name in the filter can
  24283. be a substring of the full category name, in order to match multiple
  24284. similar categories), the optional "+" prefix tells libvirt to log stack
  24285. trace for each message matching name, and @code{x} is the minimal level
  24286. where matching messages should be logged:
  24287. @itemize @bullet
  24288. @item
  24289. 1: DEBUG
  24290. @item
  24291. 2: INFO
  24292. @item
  24293. 3: WARNING
  24294. @item
  24295. 4: ERROR
  24296. @end itemize
  24297. Multiple filters can be defined in a single filters statement, they just
  24298. need to be separated by spaces.
  24299. Defaults to @samp{"3:remote 4:event"}.
  24300. @end deftypevr
  24301. @deftypevr {@code{virtlog-configuration} parameter} string log-outputs
  24302. Logging outputs.
  24303. An output is one of the places to save logging information The format
  24304. for an output can be:
  24305. @table @code
  24306. @item x:stderr
  24307. output goes to stderr
  24308. @item x:syslog:name
  24309. use syslog for the output and use the given name as the ident
  24310. @item x:file:file_path
  24311. output to a file, with the given filepath
  24312. @item x:journald
  24313. output to journald logging system
  24314. @end table
  24315. In all case the x prefix is the minimal level, acting as a filter
  24316. @itemize @bullet
  24317. @item
  24318. 1: DEBUG
  24319. @item
  24320. 2: INFO
  24321. @item
  24322. 3: WARNING
  24323. @item
  24324. 4: ERROR
  24325. @end itemize
  24326. Multiple outputs can be defined, they just need to be separated by
  24327. spaces.
  24328. Defaults to @samp{"3:stderr"}.
  24329. @end deftypevr
  24330. @deftypevr {@code{virtlog-configuration} parameter} integer max-clients
  24331. Maximum number of concurrent client connections to allow over all
  24332. sockets combined.
  24333. Defaults to @samp{1024}.
  24334. @end deftypevr
  24335. @deftypevr {@code{virtlog-configuration} parameter} integer max-size
  24336. Maximum file size before rolling over.
  24337. Defaults to @samp{2MB}
  24338. @end deftypevr
  24339. @deftypevr {@code{virtlog-configuration} parameter} integer max-backups
  24340. Maximum number of backup files to keep.
  24341. Defaults to @samp{3}
  24342. @end deftypevr
  24343. @anchor{transparent-emulation-qemu}
  24344. @subsubheading Transparent Emulation with QEMU
  24345. @cindex emulation
  24346. @cindex @code{binfmt_misc}
  24347. @code{qemu-binfmt-service-type} provides support for transparent
  24348. emulation of program binaries built for different architectures---e.g.,
  24349. it allows you to transparently execute an ARMv7 program on an x86_64
  24350. machine. It achieves this by combining the @uref{https://www.qemu.org,
  24351. QEMU} emulator and the @code{binfmt_misc} feature of the kernel Linux.
  24352. This feature only allows you to emulate GNU/Linux on a different
  24353. architecture, but see below for GNU/Hurd support.
  24354. @defvr {Scheme Variable} qemu-binfmt-service-type
  24355. This is the type of the QEMU/binfmt service for transparent emulation.
  24356. Its value must be a @code{qemu-binfmt-configuration} object, which
  24357. specifies the QEMU package to use as well as the architecture we want to
  24358. emulated:
  24359. @lisp
  24360. (service qemu-binfmt-service-type
  24361. (qemu-binfmt-configuration
  24362. (platforms (lookup-qemu-platforms "arm" "aarch64"))))
  24363. @end lisp
  24364. In this example, we enable transparent emulation for the ARM and aarch64
  24365. platforms. Running @code{herd stop qemu-binfmt} turns it off, and
  24366. running @code{herd start qemu-binfmt} turns it back on (@pxref{Invoking
  24367. herd, the @command{herd} command,, shepherd, The GNU Shepherd Manual}).
  24368. @end defvr
  24369. @deftp {Data Type} qemu-binfmt-configuration
  24370. This is the configuration for the @code{qemu-binfmt} service.
  24371. @table @asis
  24372. @item @code{platforms} (default: @code{'()})
  24373. The list of emulated QEMU platforms. Each item must be a @dfn{platform
  24374. object} as returned by @code{lookup-qemu-platforms} (see below).
  24375. For example, let's suppose you're on an x86_64 machine and you have this
  24376. service:
  24377. @lisp
  24378. (service qemu-binfmt-service-type
  24379. (qemu-binfmt-configuration
  24380. (platforms (lookup-qemu-platforms "arm"))))
  24381. @end lisp
  24382. You can run:
  24383. @example
  24384. guix build -s armhf-linux inkscape
  24385. @end example
  24386. @noindent
  24387. and it will build Inkscape for ARMv7 @emph{as if it were a native
  24388. build}, transparently using QEMU to emulate the ARMv7 CPU@. Pretty handy
  24389. if you'd like to test a package build for an architecture you don't have
  24390. access to!
  24391. @item @code{qemu} (default: @code{qemu})
  24392. The QEMU package to use.
  24393. @end table
  24394. @end deftp
  24395. @deffn {Scheme Procedure} lookup-qemu-platforms @var{platforms}@dots{}
  24396. Return the list of QEMU platform objects corresponding to
  24397. @var{platforms}@dots{}. @var{platforms} must be a list of strings
  24398. corresponding to platform names, such as @code{"arm"}, @code{"sparc"},
  24399. @code{"mips64el"}, and so on.
  24400. @end deffn
  24401. @deffn {Scheme Procedure} qemu-platform? @var{obj}
  24402. Return true if @var{obj} is a platform object.
  24403. @end deffn
  24404. @deffn {Scheme Procedure} qemu-platform-name @var{platform}
  24405. Return the name of @var{platform}---a string such as @code{"arm"}.
  24406. @end deffn
  24407. @subsubheading QEMU Guest Agent
  24408. @cindex emulation
  24409. The QEMU guest agent provides control over the emulated system to the
  24410. host. The @code{qemu-guest-agent} service runs the agent on Guix
  24411. guests. To control the agent from the host, open a socket by invoking
  24412. QEMU with the following arguments:
  24413. @example
  24414. qemu-system-x86_64 \
  24415. -chardev socket,path=/tmp/qga.sock,server=on,wait=off,id=qga0 \
  24416. -device virtio-serial \
  24417. -device virtserialport,chardev=qga0,name=org.qemu.guest_agent.0 \
  24418. ...
  24419. @end example
  24420. This creates a socket at @file{/tmp/qga.sock} on the host. Once the
  24421. guest agent is running, you can issue commands with @code{socat}:
  24422. @example
  24423. $ guix shell socat -- socat unix-connect:/tmp/qga.sock stdio
  24424. @{"execute": "guest-get-host-name"@}
  24425. @{"return": @{"host-name": "guix"@}@}
  24426. @end example
  24427. See @url{https://wiki.qemu.org/Features/GuestAgent,QEMU guest agent
  24428. documentation} for more options and commands.
  24429. @defvr {Scheme Variable} qemu-guest-agent-service-type
  24430. Service type for the QEMU guest agent service.
  24431. @end defvr
  24432. @deftp {Data Type} qemu-guest-agent-configuration
  24433. Configuration for the @code{qemu-guest-agent} service.
  24434. @table @asis
  24435. @item @code{qemu} (default: @code{qemu-minimal})
  24436. The QEMU package to use.
  24437. @item @code{device} (default: @code{""})
  24438. File name of the device or socket the agent uses to communicate with the
  24439. host. If empty, QEMU uses a default file name.
  24440. @end table
  24441. @end deftp
  24442. @subsubheading The Hurd in a Virtual Machine
  24443. @cindex @code{hurd}
  24444. @cindex the Hurd
  24445. @cindex childhurd
  24446. Service @code{hurd-vm} provides support for running GNU/Hurd in a
  24447. virtual machine (VM), a so-called @dfn{childhurd}. This service is meant
  24448. to be used on GNU/Linux and the given GNU/Hurd operating system
  24449. configuration is cross-compiled. The virtual machine is a Shepherd
  24450. service that can be referred to by the names @code{hurd-vm} and
  24451. @code{childhurd} and be controlled with commands such as:
  24452. @example
  24453. herd start hurd-vm
  24454. herd stop childhurd
  24455. @end example
  24456. When the service is running, you can view its console by connecting to
  24457. it with a VNC client, for example with:
  24458. @example
  24459. guix shell tigervnc-client -- vncviewer localhost:5900
  24460. @end example
  24461. The default configuration (see @code{hurd-vm-configuration} below)
  24462. spawns a secure shell (SSH) server in your GNU/Hurd system, which QEMU
  24463. (the virtual machine emulator) redirects to port 10222 on the host.
  24464. Thus, you can connect over SSH to the childhurd with:
  24465. @example
  24466. ssh root@@localhost -p 10022
  24467. @end example
  24468. The childhurd is volatile and stateless: it starts with a fresh root
  24469. file system every time you restart it. By default though, all the files
  24470. under @file{/etc/childhurd} on the host are copied as is to the root
  24471. file system of the childhurd when it boots. This allows you to
  24472. initialize ``secrets'' inside the VM: SSH host keys, authorized
  24473. substitute keys, and so on---see the explanation of @code{secret-root}
  24474. below.
  24475. @defvr {Scheme Variable} hurd-vm-service-type
  24476. This is the type of the Hurd in a Virtual Machine service. Its value
  24477. must be a @code{hurd-vm-configuration} object, which specifies the
  24478. operating system (@pxref{operating-system Reference}) and the disk size
  24479. for the Hurd Virtual Machine, the QEMU package to use as well as the
  24480. options for running it.
  24481. For example:
  24482. @lisp
  24483. (service hurd-vm-service-type
  24484. (hurd-vm-configuration
  24485. (disk-size (* 5000 (expt 2 20))) ;5G
  24486. (memory-size 1024))) ;1024MiB
  24487. @end lisp
  24488. would create a disk image big enough to build GNU@tie{}Hello, with some
  24489. extra memory.
  24490. @end defvr
  24491. @deftp {Data Type} hurd-vm-configuration
  24492. The data type representing the configuration for
  24493. @code{hurd-vm-service-type}.
  24494. @table @asis
  24495. @item @code{os} (default: @var{%hurd-vm-operating-system})
  24496. The operating system to instantiate. This default is bare-bones with a
  24497. permissive OpenSSH secure shell daemon listening on port 2222
  24498. (@pxref{Networking Services, @code{openssh-service-type}}).
  24499. @item @code{qemu} (default: @code{qemu-minimal})
  24500. The QEMU package to use.
  24501. @item @code{image} (default: @var{hurd-vm-disk-image})
  24502. The procedure used to build the disk-image built from this
  24503. configuration.
  24504. @item @code{disk-size} (default: @code{'guess})
  24505. The size of the disk image.
  24506. @item @code{memory-size} (default: @code{512})
  24507. The memory size of the Virtual Machine in mebibytes.
  24508. @item @code{options} (default: @code{'("--snapshot")})
  24509. The extra options for running QEMU.
  24510. @item @code{id} (default: @code{#f})
  24511. If set, a non-zero positive integer used to parameterize Childhurd
  24512. instances. It is appended to the service's name,
  24513. e.g. @code{childhurd1}.
  24514. @item @code{net-options} (default: @var{hurd-vm-net-options})
  24515. The procedure used to produce the list of QEMU networking options.
  24516. By default, it produces
  24517. @lisp
  24518. '("--device" "rtl8139,netdev=net0"
  24519. "--netdev" (string-append
  24520. "user,id=net0,"
  24521. "hostfwd=tcp:127.0.0.1:@var{secrets-port}-:1004,"
  24522. "hostfwd=tcp:127.0.0.1:@var{ssh-port}-:2222,"
  24523. "hostfwd=tcp:127.0.0.1:@var{vnc-port}-:5900"))
  24524. @end lisp
  24525. with forwarded ports:
  24526. @example
  24527. @var{secrets-port}: @code{(+ 11004 (* 1000 @var{ID}))}
  24528. @var{ssh-port}: @code{(+ 10022 (* 1000 @var{ID}))}
  24529. @var{vnc-port}: @code{(+ 15900 (* 1000 @var{ID}))}
  24530. @end example
  24531. @item @code{secret-root} (default: @file{/etc/childhurd})
  24532. The root directory with out-of-band secrets to be installed into the
  24533. childhurd once it runs. Childhurds are volatile which means that on
  24534. every startup, secrets such as the SSH host keys and Guix signing key
  24535. are recreated.
  24536. If the @file{/etc/childhurd} directory does not exist, the
  24537. @code{secret-service} running in the Childhurd will be sent an empty
  24538. list of secrets.
  24539. By default, the service automatically populates @file{/etc/childhurd}
  24540. with the following non-volatile secrets, unless they already exist:
  24541. @example
  24542. /etc/childhurd/etc/guix/acl
  24543. /etc/childhurd/etc/guix/signing-key.pub
  24544. /etc/childhurd/etc/guix/signing-key.sec
  24545. /etc/childhurd/etc/ssh/ssh_host_ed25519_key
  24546. /etc/childhurd/etc/ssh/ssh_host_ecdsa_key
  24547. /etc/childhurd/etc/ssh/ssh_host_ed25519_key.pub
  24548. /etc/childhurd/etc/ssh/ssh_host_ecdsa_key.pub
  24549. @end example
  24550. These files are automatically sent to the guest Hurd VM when it boots,
  24551. including permissions.
  24552. @cindex childhurd, offloading
  24553. @cindex Hurd, offloading
  24554. Having these files in place means that only a couple of things are
  24555. missing to allow the host to offload @code{i586-gnu} builds to the
  24556. childhurd:
  24557. @enumerate
  24558. @item
  24559. Authorizing the childhurd's key on the host so that the host accepts
  24560. build results coming from the childhurd, which can be done like so:
  24561. @example
  24562. guix archive --authorize < \
  24563. /etc/childhurd/etc/guix/signing-key.pub
  24564. @end example
  24565. @item
  24566. Adding the childhurd to @file{/etc/guix/machines.scm} (@pxref{Daemon
  24567. Offload Setup}).
  24568. @end enumerate
  24569. We're working towards making that happen automatically---get in touch
  24570. with us at @email{guix-devel@@gnu.org} to discuss it!
  24571. @end table
  24572. @end deftp
  24573. Note that by default the VM image is volatile, i.e., once stopped the
  24574. contents are lost. If you want a stateful image instead, override the
  24575. configuration's @code{image} and @code{options} without
  24576. the @code{--snapshot} flag using something along these lines:
  24577. @lisp
  24578. (service hurd-vm-service-type
  24579. (hurd-vm-configuration
  24580. (image (const "/out/of/store/writable/hurd.img"))
  24581. (options '())))
  24582. @end lisp
  24583. @subsubheading Ganeti
  24584. @cindex ganeti
  24585. @quotation Note
  24586. This service is considered experimental. Configuration options may be changed
  24587. in a backwards-incompatible manner, and not all features have been thorougly
  24588. tested. Users of this service are encouraged to share their experience at
  24589. @email{guix-devel@@gnu.org}.
  24590. @end quotation
  24591. Ganeti is a virtual machine management system. It is designed to keep virtual
  24592. machines running on a cluster of servers even in the event of hardware failures,
  24593. and to make maintenance and recovery tasks easy. It consists of multiple
  24594. services which are described later in this section. In addition to the Ganeti
  24595. service, you will need the OpenSSH service (@pxref{Networking Services,
  24596. @code{openssh-service-type}}), and update the @file{/etc/hosts} file
  24597. (@pxref{operating-system Reference, @code{hosts-file}}) with the cluster name
  24598. and address (or use a DNS server).
  24599. All nodes participating in a Ganeti cluster should have the same Ganeti and
  24600. @file{/etc/hosts} configuration. Here is an example configuration for a Ganeti
  24601. cluster node that supports multiple storage backends, and installs the
  24602. @code{debootstrap} and @code{guix} @dfn{OS providers}:
  24603. @lisp
  24604. (use-package-modules virtualization)
  24605. (use-service-modules base ganeti networking ssh)
  24606. (operating-system
  24607. ;; @dots{}
  24608. (host-name "node1")
  24609. (hosts-file (plain-file "hosts" (format #f "
  24610. 127.0.0.1 localhost
  24611. ::1 localhost
  24612. 192.168.1.200 ganeti.example.com
  24613. 192.168.1.201 node1.example.com node1
  24614. 192.168.1.202 node2.example.com node2
  24615. ")))
  24616. ;; Install QEMU so we can use KVM-based instances, and LVM, DRBD and Ceph
  24617. ;; in order to use the "plain", "drbd" and "rbd" storage backends.
  24618. (packages (append (map specification->package
  24619. '("qemu" "lvm2" "drbd-utils" "ceph"
  24620. ;; Add the debootstrap and guix OS providers.
  24621. "ganeti-instance-guix" "ganeti-instance-debootstrap"))
  24622. %base-packages))
  24623. (services
  24624. (append (list (service static-networking-service-type
  24625. (list (static-networking
  24626. (addresses
  24627. (list (network-address
  24628. (device "eth0")
  24629. (value "192.168.1.201/24"))))
  24630. (routes
  24631. (list (network-route
  24632. (destination "default")
  24633. (gateway "192.168.1.254"))))
  24634. (name-servers '("192.168.1.252"
  24635. "192.168.1.253")))))
  24636. ;; Ganeti uses SSH to communicate between nodes.
  24637. (service openssh-service-type
  24638. (openssh-configuration
  24639. (permit-root-login 'prohibit-password)))
  24640. (service ganeti-service-type
  24641. (ganeti-configuration
  24642. ;; This list specifies allowed file system paths
  24643. ;; for storing virtual machine images.
  24644. (file-storage-paths '("/srv/ganeti/file-storage"))
  24645. ;; This variable configures a single "variant" for
  24646. ;; both Debootstrap and Guix that works with KVM.
  24647. (os %default-ganeti-os))))
  24648. %base-services)))
  24649. @end lisp
  24650. Users are advised to read the
  24651. @url{http://docs.ganeti.org/ganeti/master/html/admin.html,Ganeti
  24652. administrators guide} to learn about the various cluster options and
  24653. day-to-day operations. There is also a
  24654. @url{https://guix.gnu.org/blog/2020/running-a-ganeti-cluster-on-guix/,blog post}
  24655. describing how to configure and initialize a small cluster.
  24656. @defvr {Scheme Variable} ganeti-service-type
  24657. This is a service type that includes all the various services that Ganeti
  24658. nodes should run.
  24659. Its value is a @code{ganeti-configuration} object that defines the package
  24660. to use for CLI operations, as well as configuration for the various daemons.
  24661. Allowed file storage paths and available guest operating systems are also
  24662. configured through this data type.
  24663. @end defvr
  24664. @deftp {Data Type} ganeti-configuration
  24665. The @code{ganeti} service takes the following configuration options:
  24666. @table @asis
  24667. @item @code{ganeti} (default: @code{ganeti})
  24668. The @code{ganeti} package to use. It will be installed to the system profile
  24669. and make @command{gnt-cluster}, @command{gnt-instance}, etc available. Note
  24670. that the value specified here does not affect the other services as each refer
  24671. to a specific @code{ganeti} package (see below).
  24672. @item @code{noded-configuration} (default: @code{(ganeti-noded-configuration)})
  24673. @itemx @code{confd-configuration} (default: @code{(ganeti-confd-configuration)})
  24674. @itemx @code{wconfd-configuration} (default: @code{(ganeti-wconfd-configuration)})
  24675. @itemx @code{luxid-configuration} (default: @code{(ganeti-luxid-configuration)})
  24676. @itemx @code{rapi-configuration} (default: @code{(ganeti-rapi-configuration)})
  24677. @itemx @code{kvmd-configuration} (default: @code{(ganeti-kvmd-configuration)})
  24678. @itemx @code{mond-configuration} (default: @code{(ganeti-mond-configuration)})
  24679. @itemx @code{metad-configuration} (default: @code{(ganeti-metad-configuration)})
  24680. @itemx @code{watcher-configuration} (default: @code{(ganeti-watcher-configuration)})
  24681. @itemx @code{cleaner-configuration} (default: @code{(ganeti-cleaner-configuration)})
  24682. These options control the various daemons and cron jobs that are distributed
  24683. with Ganeti. The possible values for these are described in detail below.
  24684. To override a setting, you must use the configuration type for that service:
  24685. @lisp
  24686. (service ganeti-service-type
  24687. (ganeti-configuration
  24688. (rapi-configuration
  24689. (ganeti-rapi-configuration
  24690. (interface "eth1"))))
  24691. (watcher-configuration
  24692. (ganeti-watcher-configuration
  24693. (rapi-ip "10.0.0.1"))))
  24694. @end lisp
  24695. @item @code{file-storage-paths} (default: @code{'()})
  24696. List of allowed directories for file storage backend.
  24697. @item @code{os} (default: @code{%default-ganeti-os})
  24698. List of @code{<ganeti-os>} records.
  24699. @end table
  24700. In essence @code{ganeti-service-type} is shorthand for declaring each service
  24701. individually:
  24702. @lisp
  24703. (service ganeti-noded-service-type)
  24704. (service ganeti-confd-service-type)
  24705. (service ganeti-wconfd-service-type)
  24706. (service ganeti-luxid-service-type)
  24707. (service ganeti-kvmd-service-type)
  24708. (service ganeti-mond-service-type)
  24709. (service ganeti-metad-service-type)
  24710. (service ganeti-watcher-service-type)
  24711. (service ganeti-cleaner-service-type)
  24712. @end lisp
  24713. Plus a service extension for @code{etc-service-type} that configures the file
  24714. storage backend and OS variants.
  24715. @end deftp
  24716. @deftp {Data Type} ganeti-os
  24717. This data type is suitable for passing to the @code{os} parameter of
  24718. @code{ganeti-configuration}. It takes the following parameters:
  24719. @table @asis
  24720. @item @code{name}
  24721. The name for this OS provider. It is only used to specify where the
  24722. configuration ends up. Setting it to ``debootstrap'' will create
  24723. @file{/etc/ganeti/instance-debootstrap}.
  24724. @item @code{extension}
  24725. The file extension for variants of this OS type. For example
  24726. @file{.conf} or @file{.scm}.
  24727. @item @code{variants} (default: @code{'()})
  24728. List of @code{ganeti-os-variant} objects for this OS.
  24729. @end table
  24730. @end deftp
  24731. @deftp {Data Type} ganeti-os-variant
  24732. This is the data type for a Ganeti OS variant. It takes the following
  24733. parameters:
  24734. @table @asis
  24735. @item @code{name}
  24736. The name of this variant.
  24737. @item @code{configuration}
  24738. A configuration file for this variant.
  24739. @end table
  24740. @end deftp
  24741. @defvr {Scheme Variable} %default-debootstrap-hooks
  24742. This variable contains hooks to configure networking and the GRUB bootloader.
  24743. @end defvr
  24744. @defvr {Scheme Variable} %default-debootstrap-extra-pkgs
  24745. This variable contains a list of packages suitable for a fully-virtualized guest.
  24746. @end defvr
  24747. @deftp {Data Type} debootstrap-configuration
  24748. This data type creates configuration files suitable for the debootstrap OS provider.
  24749. @table @asis
  24750. @item @code{hooks} (default: @code{%default-debootstrap-hooks})
  24751. When not @code{#f}, this must be a G-expression that specifies a directory with
  24752. scripts that will run when the OS is installed. It can also be a list of
  24753. @code{(name . file-like)} pairs. For example:
  24754. @lisp
  24755. `((99-hello-world . ,(plain-file "#!/bin/sh\necho Hello, World")))
  24756. @end lisp
  24757. That will create a directory with one executable named @code{99-hello-world}
  24758. and run it every time this variant is installed. If set to @code{#f}, hooks
  24759. in @file{/etc/ganeti/instance-debootstrap/hooks} will be used, if any.
  24760. @item @code{proxy} (default: @code{#f})
  24761. Optional HTTP proxy to use.
  24762. @item @code{mirror} (default: @code{#f})
  24763. The Debian mirror. Typically something like @code{http://ftp.no.debian.org/debian}.
  24764. The default varies depending on the distribution.
  24765. @item @code{arch} (default: @code{#f})
  24766. The dpkg architecture. Set to @code{armhf} to debootstrap an ARMv7 instance
  24767. on an AArch64 host. Default is to use the current system architecture.
  24768. @item @code{suite} (default: @code{"stable"})
  24769. When set, this must be a Debian distribution ``suite'' such as @code{buster}
  24770. or @code{focal}. If set to @code{#f}, the default for the OS provider is used.
  24771. @item @code{extra-pkgs} (default: @code{%default-debootstrap-extra-pkgs})
  24772. List of extra packages that will get installed by dpkg in addition
  24773. to the minimal system.
  24774. @item @code{components} (default: @code{#f})
  24775. When set, must be a list of Debian repository ``components''. For example
  24776. @code{'("main" "contrib")}.
  24777. @item @code{generate-cache?} (default: @code{#t})
  24778. Whether to automatically cache the generated debootstrap archive.
  24779. @item @code{clean-cache} (default: @code{14})
  24780. Discard the cache after this amount of days. Use @code{#f} to never
  24781. clear the cache.
  24782. @item @code{partition-style} (default: @code{'msdos})
  24783. The type of partition to create. When set, it must be one of
  24784. @code{'msdos}, @code{'none} or a string.
  24785. @item @code{partition-alignment} (default: @code{2048})
  24786. Alignment of the partition in sectors.
  24787. @end table
  24788. @end deftp
  24789. @deffn {Scheme Procedure} debootstrap-variant @var{name} @var{configuration}
  24790. This is a helper procedure that creates a @code{ganeti-os-variant} record. It
  24791. takes two parameters: a name and a @code{debootstrap-configuration} object.
  24792. @end deffn
  24793. @deffn {Scheme Procedure} debootstrap-os @var{variants}@dots{}
  24794. This is a helper procedure that creates a @code{ganeti-os} record. It takes
  24795. a list of variants created with @code{debootstrap-variant}.
  24796. @end deffn
  24797. @deffn {Scheme Procedure} guix-variant @var{name} @var{configuration}
  24798. This is a helper procedure that creates a @code{ganeti-os-variant} record for
  24799. use with the Guix OS provider. It takes a name and a G-expression that returns
  24800. a ``file-like'' (@pxref{G-Expressions, file-like objects}) object containing a
  24801. Guix System configuration.
  24802. @end deffn
  24803. @deffn {Scheme Procedure} guix-os @var{variants}@dots{}
  24804. This is a helper procedure that creates a @code{ganeti-os} record. It
  24805. takes a list of variants produced by @code{guix-variant}.
  24806. @end deffn
  24807. @defvr {Scheme Variable} %default-debootstrap-variants
  24808. This is a convenience variable to make the debootstrap provider work
  24809. ``out of the box'' without users having to declare variants manually. It
  24810. contains a single debootstrap variant with the default configuration:
  24811. @lisp
  24812. (list (debootstrap-variant
  24813. "default"
  24814. (debootstrap-configuration)))
  24815. @end lisp
  24816. @end defvr
  24817. @defvr {Scheme Variable} %default-guix-variants
  24818. This is a convenience variable to make the Guix OS provider work without
  24819. additional configuration. It creates a virtual machine that has an SSH
  24820. server, a serial console, and authorizes the Ganeti hosts SSH keys.
  24821. @lisp
  24822. (list (guix-variant
  24823. "default"
  24824. (file-append ganeti-instance-guix
  24825. "/share/doc/ganeti-instance-guix/examples/dynamic.scm")))
  24826. @end lisp
  24827. @end defvr
  24828. Users can implement support for OS providers unbeknownst to Guix by extending
  24829. the @code{ganeti-os} and @code{ganeti-os-variant} records appropriately.
  24830. For example:
  24831. @lisp
  24832. (ganeti-os
  24833. (name "custom")
  24834. (extension ".conf")
  24835. (variants
  24836. (list (ganeti-os-variant
  24837. (name "foo")
  24838. (configuration (plain-file "bar" "this is fine"))))))
  24839. @end lisp
  24840. That creates @file{/etc/ganeti/instance-custom/variants/foo.conf} which points
  24841. to a file in the store with contents @code{this is fine}. It also creates
  24842. @file{/etc/ganeti/instance-custom/variants/variants.list} with contents @code{foo}.
  24843. Obviously this may not work for all OS providers out there. If you find the
  24844. interface limiting, please reach out to @email{guix-devel@@gnu.org}.
  24845. The rest of this section documents the various services that are included by
  24846. @code{ganeti-service-type}.
  24847. @defvr {Scheme Variable} ganeti-noded-service-type
  24848. @command{ganeti-noded} is the daemon responsible for node-specific functions
  24849. within the Ganeti system. The value of this service must be a
  24850. @code{ganeti-noded-configuration} object.
  24851. @end defvr
  24852. @deftp {Data Type} ganeti-noded-configuration
  24853. This is the configuration for the @code{ganeti-noded} service.
  24854. @table @asis
  24855. @item @code{ganeti} (default: @code{ganeti})
  24856. The @code{ganeti} package to use for this service.
  24857. @item @code{port} (default: @code{1811})
  24858. The TCP port on which the node daemon listens for network requests.
  24859. @item @code{address} (default: @code{"0.0.0.0"})
  24860. The network address that the daemon will bind to. The default address means
  24861. bind to all available addresses.
  24862. @item @code{interface} (default: @code{#f})
  24863. When this is set, it must be a specific network interface (e.g.@: @code{eth0})
  24864. that the daemon will bind to.
  24865. @item @code{max-clients} (default: @code{20})
  24866. This sets a limit on the maximum number of simultaneous client connections
  24867. that the daemon will handle. Connections above this count are accepted, but
  24868. no responses will be sent until enough connections have closed.
  24869. @item @code{ssl?} (default: @code{#t})
  24870. Whether to use SSL/TLS to encrypt network communications. The certificate
  24871. is automatically provisioned by the cluster and can be rotated with
  24872. @command{gnt-cluster renew-crypto}.
  24873. @item @code{ssl-key} (default: @file{"/var/lib/ganeti/server.pem"})
  24874. This can be used to provide a specific encryption key for TLS communications.
  24875. @item @code{ssl-cert} (default: @file{"/var/lib/ganeti/server.pem"})
  24876. This can be used to provide a specific certificate for TLS communications.
  24877. @item @code{debug?} (default: @code{#f})
  24878. When true, the daemon performs additional logging for debugging purposes.
  24879. Note that this will leak encryption details to the log files, use with caution.
  24880. @end table
  24881. @end deftp
  24882. @defvr {Scheme Variable} ganeti-confd-service-type
  24883. @command{ganeti-confd} answers queries related to the configuration of a
  24884. Ganeti cluster. The purpose of this daemon is to have a highly available
  24885. and fast way to query cluster configuration values. It is automatically
  24886. active on all @dfn{master candidates}. The value of this service must be a
  24887. @code{ganeti-confd-configuration} object.
  24888. @end defvr
  24889. @deftp {Data Type} ganeti-confd-configuration
  24890. This is the configuration for the @code{ganeti-confd} service.
  24891. @table @asis
  24892. @item @code{ganeti} (default: @code{ganeti})
  24893. The @code{ganeti} package to use for this service.
  24894. @item @code{port} (default: @code{1814})
  24895. The UDP port on which to listen for network requests.
  24896. @item @code{address} (default: @code{"0.0.0.0"})
  24897. Network address that the daemon will bind to.
  24898. @item @code{debug?} (default: @code{#f})
  24899. When true, the daemon performs additional logging for debugging purposes.
  24900. @end table
  24901. @end deftp
  24902. @defvr {Scheme Variable} ganeti-wconfd-service-type
  24903. @command{ganeti-wconfd} is the daemon that has authoritative knowledge
  24904. about the cluster configuration and is the only entity that can accept
  24905. changes to it. All jobs that need to modify the configuration will do so
  24906. by sending appropriate requests to this daemon. It only runs on the
  24907. @dfn{master node} and will automatically disable itself on other nodes.
  24908. The value of this service must be a
  24909. @code{ganeti-wconfd-configuration} object.
  24910. @end defvr
  24911. @deftp {Data Type} ganeti-wconfd-configuration
  24912. This is the configuration for the @code{ganeti-wconfd} service.
  24913. @table @asis
  24914. @item @code{ganeti} (default: @code{ganeti})
  24915. The @code{ganeti} package to use for this service.
  24916. @item @code{no-voting?} (default: @code{#f})
  24917. The daemon will refuse to start if the majority of cluster nodes does not
  24918. agree that it is running on the master node. Set to @code{#t} to start
  24919. even if a quorum can not be reached (dangerous, use with caution).
  24920. @item @code{debug?} (default: @code{#f})
  24921. When true, the daemon performs additional logging for debugging purposes.
  24922. @end table
  24923. @end deftp
  24924. @defvr {Scheme Variable} ganeti-luxid-service-type
  24925. @command{ganeti-luxid} is a daemon used to answer queries related to the
  24926. configuration and the current live state of a Ganeti cluster. Additionally,
  24927. it is the authoritative daemon for the Ganeti job queue. Jobs can be
  24928. submitted via this daemon and it schedules and starts them.
  24929. It takes a @code{ganeti-luxid-configuration} object.
  24930. @end defvr
  24931. @deftp {Data Type} ganeti-luxid-configuration
  24932. This is the configuration for the @code{ganeti-luxid} service.
  24933. @table @asis
  24934. @item @code{ganeti} (default: @code{ganeti})
  24935. The @code{ganeti} package to use for this service.
  24936. @item @code{no-voting?} (default: @code{#f})
  24937. The daemon will refuse to start if it cannot verify that the majority of
  24938. cluster nodes believes that it is running on the master node. Set to
  24939. @code{#t} to ignore such checks and start anyway (this can be dangerous).
  24940. @item @code{debug?} (default: @code{#f})
  24941. When true, the daemon performs additional logging for debugging purposes.
  24942. @end table
  24943. @end deftp
  24944. @defvr {Scheme Variable} ganeti-rapi-service-type
  24945. @command{ganeti-rapi} provides a remote API for Ganeti clusters. It runs on
  24946. the master node and can be used to perform cluster actions programmatically
  24947. via a JSON-based RPC protocol.
  24948. Most query operations are allowed without authentication (unless
  24949. @var{require-authentication?} is set), whereas write operations require
  24950. explicit authorization via the @file{/var/lib/ganeti/rapi/users} file. See
  24951. the @url{http://docs.ganeti.org/ganeti/master/html/rapi.html, Ganeti Remote
  24952. API documentation} for more information.
  24953. The value of this service must be a @code{ganeti-rapi-configuration} object.
  24954. @end defvr
  24955. @deftp {Data Type} ganeti-rapi-configuration
  24956. This is the configuration for the @code{ganeti-rapi} service.
  24957. @table @asis
  24958. @item @code{ganeti} (default: @code{ganeti})
  24959. The @code{ganeti} package to use for this service.
  24960. @item @code{require-authentication?} (default: @code{#f})
  24961. Whether to require authentication even for read-only operations.
  24962. @item @code{port} (default: @code{5080})
  24963. The TCP port on which to listen to API requests.
  24964. @item @code{address} (default: @code{"0.0.0.0"})
  24965. The network address that the service will bind to. By default it listens
  24966. on all configured addresses.
  24967. @item @code{interface} (default: @code{#f})
  24968. When set, it must specify a specific network interface such as @code{eth0}
  24969. that the daemon will bind to.
  24970. @item @code{max-clients} (default: @code{20})
  24971. The maximum number of simultaneous client requests to handle. Further
  24972. connections are allowed, but no responses are sent until enough connections
  24973. have closed.
  24974. @item @code{ssl?} (default: @code{#t})
  24975. Whether to use SSL/TLS encryption on the RAPI port.
  24976. @item @code{ssl-key} (default: @file{"/var/lib/ganeti/server.pem"})
  24977. This can be used to provide a specific encryption key for TLS communications.
  24978. @item @code{ssl-cert} (default: @file{"/var/lib/ganeti/server.pem"})
  24979. This can be used to provide a specific certificate for TLS communications.
  24980. @item @code{debug?} (default: @code{#f})
  24981. When true, the daemon performs additional logging for debugging purposes.
  24982. Note that this will leak encryption details to the log files, use with caution.
  24983. @end table
  24984. @end deftp
  24985. @defvr {Scheme Variable} ganeti-kvmd-service-type
  24986. @command{ganeti-kvmd} is responsible for determining whether a given KVM
  24987. instance was shut down by an administrator or a user. Normally Ganeti will
  24988. restart an instance that was not stopped through Ganeti itself. If the
  24989. cluster option @code{user_shutdown} is true, this daemon monitors the
  24990. @code{QMP} socket provided by QEMU and listens for shutdown events, and
  24991. marks the instance as @dfn{USER_down} instead of @dfn{ERROR_down} when
  24992. it shuts down gracefully by itself.
  24993. It takes a @code{ganeti-kvmd-configuration} object.
  24994. @end defvr
  24995. @deftp {Data Type} ganeti-kvmd-configuration
  24996. @table @asis
  24997. @item @code{ganeti} (default: @code{ganeti})
  24998. The @code{ganeti} package to use for this service.
  24999. @item @code{debug?} (default: @code{#f})
  25000. When true, the daemon performs additional logging for debugging purposes.
  25001. @end table
  25002. @end deftp
  25003. @defvr {Scheme Variable} ganeti-mond-service-type
  25004. @command{ganeti-mond} is an optional daemon that provides Ganeti monitoring
  25005. functionality. It is responsible for running data collectors and publish the
  25006. collected information through a HTTP interface.
  25007. It takes a @code{ganeti-mond-configuration} object.
  25008. @end defvr
  25009. @deftp {Data Type} ganeti-mond-configuration
  25010. @table @asis
  25011. @item @code{ganeti} (default: @code{ganeti})
  25012. The @code{ganeti} package to use for this service.
  25013. @item @code{port} (default: @code{1815})
  25014. The port on which the daemon will listen.
  25015. @item @code{address} (default: @code{"0.0.0.0"})
  25016. The network address that the daemon will bind to. By default it binds to all
  25017. available interfaces.
  25018. @item @code{debug?} (default: @code{#f})
  25019. When true, the daemon performs additional logging for debugging purposes.
  25020. @end table
  25021. @end deftp
  25022. @defvr {Scheme Variable} ganeti-metad-service-type
  25023. @command{ganeti-metad} is an optional daemon that can be used to provide
  25024. information about the cluster to instances or OS install scripts.
  25025. It takes a @code{ganeti-metad-configuration} object.
  25026. @end defvr
  25027. @deftp {Data Type} ganeti-metad-configuration
  25028. @table @asis
  25029. @item @code{ganeti} (default: @code{ganeti})
  25030. The @code{ganeti} package to use for this service.
  25031. @item @code{port} (default: @code{80})
  25032. The port on which the daemon will listen.
  25033. @item @code{address} (default: @code{#f})
  25034. If set, the daemon will bind to this address only. If left unset, the behavior
  25035. depends on the cluster configuration.
  25036. @item @code{debug?} (default: @code{#f})
  25037. When true, the daemon performs additional logging for debugging purposes.
  25038. @end table
  25039. @end deftp
  25040. @defvr {Scheme Variable} ganeti-watcher-service-type
  25041. @command{ganeti-watcher} is a script designed to run periodically and ensure
  25042. the health of a cluster. It will automatically restart instances that have
  25043. stopped without Ganeti's consent, and repairs DRBD links in case a node has
  25044. rebooted. It also archives old cluster jobs and restarts Ganeti daemons
  25045. that are not running. If the cluster parameter @code{ensure_node_health}
  25046. is set, the watcher will also shutdown instances and DRBD devices if the
  25047. node it is running on is declared offline by known master candidates.
  25048. It can be paused on all nodes with @command{gnt-cluster watcher pause}.
  25049. The service takes a @code{ganeti-watcher-configuration} object.
  25050. @end defvr
  25051. @deftp {Data Type} ganeti-watcher-configuration
  25052. @table @asis
  25053. @item @code{ganeti} (default: @code{ganeti})
  25054. The @code{ganeti} package to use for this service.
  25055. @item @code{schedule} (default: @code{'(next-second-from (next-minute (range 0 60 5)))})
  25056. How often to run the script. The default is every five minutes.
  25057. @item @code{rapi-ip} (default: @code{#f})
  25058. This option needs to be specified only if the RAPI daemon is configured to use
  25059. a particular interface or address. By default the cluster address is used.
  25060. @item @code{job-age} (default: @code{(* 6 3600)})
  25061. Archive cluster jobs older than this age, specified in seconds. The default
  25062. is 6 hours. This keeps @command{gnt-job list} manageable.
  25063. @item @code{verify-disks?} (default: @code{#t})
  25064. If this is @code{#f}, the watcher will not try to repair broken DRBD links
  25065. automatically. Administrators will need to use @command{gnt-cluster verify-disks}
  25066. manually instead.
  25067. @item @code{debug?} (default: @code{#f})
  25068. When @code{#t}, the script performs additional logging for debugging purposes.
  25069. @end table
  25070. @end deftp
  25071. @defvr {Scheme Variable} ganeti-cleaner-service-type
  25072. @command{ganeti-cleaner} is a script designed to run periodically and remove
  25073. old files from the cluster. This service type controls two @dfn{cron jobs}:
  25074. one intended for the master node that permanently purges old cluster jobs,
  25075. and one intended for every node that removes expired X509 certificates, keys,
  25076. and outdated @command{ganeti-watcher} information. Like all Ganeti services,
  25077. it is safe to include even on non-master nodes as it will disable itself as
  25078. necessary.
  25079. It takes a @code{ganeti-cleaner-configuration} object.
  25080. @end defvr
  25081. @deftp {Data Type} ganeti-cleaner-configuration
  25082. @table @asis
  25083. @item @code{ganeti} (default: @code{ganeti})
  25084. The @code{ganeti} package to use for the @command{gnt-cleaner} command.
  25085. @item @code{master-schedule} (default: @code{"45 1 * * *"})
  25086. How often to run the master cleaning job. The default is once per day, at
  25087. 01:45:00.
  25088. @item @code{node-schedule} (default: @code{"45 2 * * *"})
  25089. How often to run the node cleaning job. The default is once per day, at
  25090. 02:45:00.
  25091. @end table
  25092. @end deftp
  25093. @node Version Control Services
  25094. @subsection Version Control Services
  25095. The @code{(gnu services version-control)} module provides a service to
  25096. allow remote access to local Git repositories. There are three options:
  25097. the @code{git-daemon-service}, which provides access to repositories via
  25098. the @code{git://} unsecured TCP-based protocol, extending the
  25099. @code{nginx} web server to proxy some requests to
  25100. @code{git-http-backend}, or providing a web interface with
  25101. @code{cgit-service-type}.
  25102. @deffn {Scheme Procedure} git-daemon-service [#:config (git-daemon-configuration)]
  25103. Return a service that runs @command{git daemon}, a simple TCP server to
  25104. expose repositories over the Git protocol for anonymous access.
  25105. The optional @var{config} argument should be a
  25106. @code{<git-daemon-configuration>} object, by default it allows read-only
  25107. access to exported@footnote{By creating the magic file
  25108. @file{git-daemon-export-ok} in the repository directory.} repositories under
  25109. @file{/srv/git}.
  25110. @end deffn
  25111. @deftp {Data Type} git-daemon-configuration
  25112. Data type representing the configuration for @code{git-daemon-service}.
  25113. @table @asis
  25114. @item @code{package} (default: @code{git})
  25115. Package object of the Git distributed version control system.
  25116. @item @code{export-all?} (default: @code{#f})
  25117. Whether to allow access for all Git repositories, even if they do not
  25118. have the @file{git-daemon-export-ok} file.
  25119. @item @code{base-path} (default: @file{/srv/git})
  25120. Whether to remap all the path requests as relative to the given path.
  25121. If you run @command{git daemon} with @code{(base-path "/srv/git")} on
  25122. @samp{example.com}, then if you later try to pull
  25123. @indicateurl{git://example.com/hello.git}, git daemon will interpret the
  25124. path as @file{/srv/git/hello.git}.
  25125. @item @code{user-path} (default: @code{#f})
  25126. Whether to allow @code{~user} notation to be used in requests. When
  25127. specified with empty string, requests to
  25128. @indicateurl{git://host/~alice/foo} is taken as a request to access
  25129. @code{foo} repository in the home directory of user @code{alice}. If
  25130. @code{(user-path "@var{path}")} is specified, the same request is taken
  25131. as a request to access @file{@var{path}/foo} repository in the home
  25132. directory of user @code{alice}.
  25133. @item @code{listen} (default: @code{'()})
  25134. Whether to listen on specific IP addresses or hostnames, defaults to
  25135. all.
  25136. @item @code{port} (default: @code{#f})
  25137. Whether to listen on an alternative port, which defaults to 9418.
  25138. @item @code{whitelist} (default: @code{'()})
  25139. If not empty, only allow access to this list of directories.
  25140. @item @code{extra-options} (default: @code{'()})
  25141. Extra options will be passed to @command{git daemon}, please run
  25142. @command{man git-daemon} for more information.
  25143. @end table
  25144. @end deftp
  25145. The @code{git://} protocol lacks authentication. When you pull from a
  25146. repository fetched via @code{git://}, you don't know whether the data you
  25147. receive was modified or is even coming from the specified host, and your
  25148. connection is subject to eavesdropping. It's better to use an authenticated
  25149. and encrypted transport, such as @code{https}. Although Git allows you
  25150. to serve repositories using unsophisticated file-based web servers,
  25151. there is a faster protocol implemented by the @code{git-http-backend}
  25152. program. This program is the back-end of a proper Git web service. It
  25153. is designed to sit behind a FastCGI proxy. @xref{Web Services}, for more
  25154. on running the necessary @code{fcgiwrap} daemon.
  25155. Guix has a separate configuration data type for serving Git repositories
  25156. over HTTP.
  25157. @deftp {Data Type} git-http-configuration
  25158. Data type representing the configuration for a future
  25159. @code{git-http-service-type}; can currently be used to configure Nginx
  25160. through @code{git-http-nginx-location-configuration}.
  25161. @table @asis
  25162. @item @code{package} (default: @var{git})
  25163. Package object of the Git distributed version control system.
  25164. @item @code{git-root} (default: @file{/srv/git})
  25165. Directory containing the Git repositories to expose to the world.
  25166. @item @code{export-all?} (default: @code{#f})
  25167. Whether to expose access for all Git repositories in @var{git-root},
  25168. even if they do not have the @file{git-daemon-export-ok} file.
  25169. @item @code{uri-path} (default: @samp{/git/})
  25170. Path prefix for Git access. With the default @samp{/git/} prefix, this
  25171. will map @indicateurl{http://@var{server}/git/@var{repo}.git} to
  25172. @file{/srv/git/@var{repo}.git}. Requests whose URI paths do not begin
  25173. with this prefix are not passed on to this Git instance.
  25174. @item @code{fcgiwrap-socket} (default: @code{127.0.0.1:9000})
  25175. The socket on which the @code{fcgiwrap} daemon is listening. @xref{Web
  25176. Services}.
  25177. @end table
  25178. @end deftp
  25179. There is no @code{git-http-service-type}, currently; instead you can
  25180. create an @code{nginx-location-configuration} from a
  25181. @code{git-http-configuration} and then add that location to a web
  25182. server.
  25183. @deffn {Scheme Procedure} git-http-nginx-location-configuration @
  25184. [config=(git-http-configuration)]
  25185. Compute an @code{nginx-location-configuration} that corresponds to the
  25186. given Git http configuration. An example nginx service definition to
  25187. serve the default @file{/srv/git} over HTTPS might be:
  25188. @lisp
  25189. (service nginx-service-type
  25190. (nginx-configuration
  25191. (server-blocks
  25192. (list
  25193. (nginx-server-configuration
  25194. (listen '("443 ssl"))
  25195. (server-name "git.my-host.org")
  25196. (ssl-certificate
  25197. "/etc/letsencrypt/live/git.my-host.org/fullchain.pem")
  25198. (ssl-certificate-key
  25199. "/etc/letsencrypt/live/git.my-host.org/privkey.pem")
  25200. (locations
  25201. (list
  25202. (git-http-nginx-location-configuration
  25203. (git-http-configuration (uri-path "/"))))))))))
  25204. @end lisp
  25205. This example assumes that you are using Let's Encrypt to get your TLS
  25206. certificate. @xref{Certificate Services}. The default @code{certbot}
  25207. service will redirect all HTTP traffic on @code{git.my-host.org} to
  25208. HTTPS@. You will also need to add an @code{fcgiwrap} proxy to your
  25209. system services. @xref{Web Services}.
  25210. @end deffn
  25211. @subsubheading Cgit Service
  25212. @cindex Cgit service
  25213. @cindex Git, web interface
  25214. @uref{https://git.zx2c4.com/cgit/, Cgit} is a web frontend for Git
  25215. repositories written in C.
  25216. The following example will configure the service with default values.
  25217. By default, Cgit can be accessed on port 80 (@code{http://localhost:80}).
  25218. @lisp
  25219. (service cgit-service-type)
  25220. @end lisp
  25221. The @code{file-object} type designates either a file-like object
  25222. (@pxref{G-Expressions, file-like objects}) or a string.
  25223. @c %start of fragment
  25224. Available @code{cgit-configuration} fields are:
  25225. @deftypevr {@code{cgit-configuration} parameter} package package
  25226. The CGIT package.
  25227. @end deftypevr
  25228. @deftypevr {@code{cgit-configuration} parameter} nginx-server-configuration-list nginx
  25229. NGINX configuration.
  25230. @end deftypevr
  25231. @deftypevr {@code{cgit-configuration} parameter} file-object about-filter
  25232. Specifies a command which will be invoked to format the content of about
  25233. pages (both top-level and for each repository).
  25234. Defaults to @samp{""}.
  25235. @end deftypevr
  25236. @deftypevr {@code{cgit-configuration} parameter} string agefile
  25237. Specifies a path, relative to each repository path, which can be used to
  25238. specify the date and time of the youngest commit in the repository.
  25239. Defaults to @samp{""}.
  25240. @end deftypevr
  25241. @deftypevr {@code{cgit-configuration} parameter} file-object auth-filter
  25242. Specifies a command that will be invoked for authenticating repository
  25243. access.
  25244. Defaults to @samp{""}.
  25245. @end deftypevr
  25246. @deftypevr {@code{cgit-configuration} parameter} string branch-sort
  25247. Flag which, when set to @samp{age}, enables date ordering in the branch
  25248. ref list, and when set @samp{name} enables ordering by branch name.
  25249. Defaults to @samp{"name"}.
  25250. @end deftypevr
  25251. @deftypevr {@code{cgit-configuration} parameter} string cache-root
  25252. Path used to store the cgit cache entries.
  25253. Defaults to @samp{"/var/cache/cgit"}.
  25254. @end deftypevr
  25255. @deftypevr {@code{cgit-configuration} parameter} integer cache-static-ttl
  25256. Number which specifies the time-to-live, in minutes, for the cached
  25257. version of repository pages accessed with a fixed SHA1.
  25258. Defaults to @samp{-1}.
  25259. @end deftypevr
  25260. @deftypevr {@code{cgit-configuration} parameter} integer cache-dynamic-ttl
  25261. Number which specifies the time-to-live, in minutes, for the cached
  25262. version of repository pages accessed without a fixed SHA1.
  25263. Defaults to @samp{5}.
  25264. @end deftypevr
  25265. @deftypevr {@code{cgit-configuration} parameter} integer cache-repo-ttl
  25266. Number which specifies the time-to-live, in minutes, for the cached
  25267. version of the repository summary page.
  25268. Defaults to @samp{5}.
  25269. @end deftypevr
  25270. @deftypevr {@code{cgit-configuration} parameter} integer cache-root-ttl
  25271. Number which specifies the time-to-live, in minutes, for the cached
  25272. version of the repository index page.
  25273. Defaults to @samp{5}.
  25274. @end deftypevr
  25275. @deftypevr {@code{cgit-configuration} parameter} integer cache-scanrc-ttl
  25276. Number which specifies the time-to-live, in minutes, for the result of
  25277. scanning a path for Git repositories.
  25278. Defaults to @samp{15}.
  25279. @end deftypevr
  25280. @deftypevr {@code{cgit-configuration} parameter} integer cache-about-ttl
  25281. Number which specifies the time-to-live, in minutes, for the cached
  25282. version of the repository about page.
  25283. Defaults to @samp{15}.
  25284. @end deftypevr
  25285. @deftypevr {@code{cgit-configuration} parameter} integer cache-snapshot-ttl
  25286. Number which specifies the time-to-live, in minutes, for the cached
  25287. version of snapshots.
  25288. Defaults to @samp{5}.
  25289. @end deftypevr
  25290. @deftypevr {@code{cgit-configuration} parameter} integer cache-size
  25291. The maximum number of entries in the cgit cache. When set to @samp{0},
  25292. caching is disabled.
  25293. Defaults to @samp{0}.
  25294. @end deftypevr
  25295. @deftypevr {@code{cgit-configuration} parameter} boolean case-sensitive-sort?
  25296. Sort items in the repo list case sensitively.
  25297. Defaults to @samp{#t}.
  25298. @end deftypevr
  25299. @deftypevr {@code{cgit-configuration} parameter} list clone-prefix
  25300. List of common prefixes which, when combined with a repository URL,
  25301. generates valid clone URLs for the repository.
  25302. Defaults to @samp{()}.
  25303. @end deftypevr
  25304. @deftypevr {@code{cgit-configuration} parameter} list clone-url
  25305. List of @code{clone-url} templates.
  25306. Defaults to @samp{()}.
  25307. @end deftypevr
  25308. @deftypevr {@code{cgit-configuration} parameter} file-object commit-filter
  25309. Command which will be invoked to format commit messages.
  25310. Defaults to @samp{""}.
  25311. @end deftypevr
  25312. @deftypevr {@code{cgit-configuration} parameter} string commit-sort
  25313. Flag which, when set to @samp{date}, enables strict date ordering in the
  25314. commit log, and when set to @samp{topo} enables strict topological
  25315. ordering.
  25316. Defaults to @samp{"git log"}.
  25317. @end deftypevr
  25318. @deftypevr {@code{cgit-configuration} parameter} file-object css
  25319. URL which specifies the css document to include in all cgit pages.
  25320. Defaults to @samp{"/share/cgit/cgit.css"}.
  25321. @end deftypevr
  25322. @deftypevr {@code{cgit-configuration} parameter} file-object email-filter
  25323. Specifies a command which will be invoked to format names and email
  25324. address of committers, authors, and taggers, as represented in various
  25325. places throughout the cgit interface.
  25326. Defaults to @samp{""}.
  25327. @end deftypevr
  25328. @deftypevr {@code{cgit-configuration} parameter} boolean embedded?
  25329. Flag which, when set to @samp{#t}, will make cgit generate a HTML
  25330. fragment suitable for embedding in other HTML pages.
  25331. Defaults to @samp{#f}.
  25332. @end deftypevr
  25333. @deftypevr {@code{cgit-configuration} parameter} boolean enable-commit-graph?
  25334. Flag which, when set to @samp{#t}, will make cgit print an ASCII-art
  25335. commit history graph to the left of the commit messages in the
  25336. repository log page.
  25337. Defaults to @samp{#f}.
  25338. @end deftypevr
  25339. @deftypevr {@code{cgit-configuration} parameter} boolean enable-filter-overrides?
  25340. Flag which, when set to @samp{#t}, allows all filter settings to be
  25341. overridden in repository-specific cgitrc files.
  25342. Defaults to @samp{#f}.
  25343. @end deftypevr
  25344. @deftypevr {@code{cgit-configuration} parameter} boolean enable-follow-links?
  25345. Flag which, when set to @samp{#t}, allows users to follow a file in the
  25346. log view.
  25347. Defaults to @samp{#f}.
  25348. @end deftypevr
  25349. @deftypevr {@code{cgit-configuration} parameter} boolean enable-http-clone?
  25350. If set to @samp{#t}, cgit will act as an dumb HTTP endpoint for Git
  25351. clones.
  25352. Defaults to @samp{#t}.
  25353. @end deftypevr
  25354. @deftypevr {@code{cgit-configuration} parameter} boolean enable-index-links?
  25355. Flag which, when set to @samp{#t}, will make cgit generate extra links
  25356. "summary", "commit", "tree" for each repo in the repository index.
  25357. Defaults to @samp{#f}.
  25358. @end deftypevr
  25359. @deftypevr {@code{cgit-configuration} parameter} boolean enable-index-owner?
  25360. Flag which, when set to @samp{#t}, will make cgit display the owner of
  25361. each repo in the repository index.
  25362. Defaults to @samp{#t}.
  25363. @end deftypevr
  25364. @deftypevr {@code{cgit-configuration} parameter} boolean enable-log-filecount?
  25365. Flag which, when set to @samp{#t}, will make cgit print the number of
  25366. modified files for each commit on the repository log page.
  25367. Defaults to @samp{#f}.
  25368. @end deftypevr
  25369. @deftypevr {@code{cgit-configuration} parameter} boolean enable-log-linecount?
  25370. Flag which, when set to @samp{#t}, will make cgit print the number of
  25371. added and removed lines for each commit on the repository log page.
  25372. Defaults to @samp{#f}.
  25373. @end deftypevr
  25374. @deftypevr {@code{cgit-configuration} parameter} boolean enable-remote-branches?
  25375. Flag which, when set to @code{#t}, will make cgit display remote
  25376. branches in the summary and refs views.
  25377. Defaults to @samp{#f}.
  25378. @end deftypevr
  25379. @deftypevr {@code{cgit-configuration} parameter} boolean enable-subject-links?
  25380. Flag which, when set to @code{1}, will make cgit use the subject of the
  25381. parent commit as link text when generating links to parent commits in
  25382. commit view.
  25383. Defaults to @samp{#f}.
  25384. @end deftypevr
  25385. @deftypevr {@code{cgit-configuration} parameter} boolean enable-html-serving?
  25386. Flag which, when set to @samp{#t}, will make cgit use the subject of the
  25387. parent commit as link text when generating links to parent commits in
  25388. commit view.
  25389. Defaults to @samp{#f}.
  25390. @end deftypevr
  25391. @deftypevr {@code{cgit-configuration} parameter} boolean enable-tree-linenumbers?
  25392. Flag which, when set to @samp{#t}, will make cgit generate linenumber
  25393. links for plaintext blobs printed in the tree view.
  25394. Defaults to @samp{#t}.
  25395. @end deftypevr
  25396. @deftypevr {@code{cgit-configuration} parameter} boolean enable-git-config?
  25397. Flag which, when set to @samp{#f}, will allow cgit to use Git config to
  25398. set any repo specific settings.
  25399. Defaults to @samp{#f}.
  25400. @end deftypevr
  25401. @deftypevr {@code{cgit-configuration} parameter} file-object favicon
  25402. URL used as link to a shortcut icon for cgit.
  25403. Defaults to @samp{"/favicon.ico"}.
  25404. @end deftypevr
  25405. @deftypevr {@code{cgit-configuration} parameter} string footer
  25406. The content of the file specified with this option will be included
  25407. verbatim at the bottom of all pages (i.e.@: it replaces the standard
  25408. "generated by..."@: message).
  25409. Defaults to @samp{""}.
  25410. @end deftypevr
  25411. @deftypevr {@code{cgit-configuration} parameter} string head-include
  25412. The content of the file specified with this option will be included
  25413. verbatim in the HTML HEAD section on all pages.
  25414. Defaults to @samp{""}.
  25415. @end deftypevr
  25416. @deftypevr {@code{cgit-configuration} parameter} string header
  25417. The content of the file specified with this option will be included
  25418. verbatim at the top of all pages.
  25419. Defaults to @samp{""}.
  25420. @end deftypevr
  25421. @deftypevr {@code{cgit-configuration} parameter} file-object include
  25422. Name of a configfile to include before the rest of the current config-
  25423. file is parsed.
  25424. Defaults to @samp{""}.
  25425. @end deftypevr
  25426. @deftypevr {@code{cgit-configuration} parameter} string index-header
  25427. The content of the file specified with this option will be included
  25428. verbatim above the repository index.
  25429. Defaults to @samp{""}.
  25430. @end deftypevr
  25431. @deftypevr {@code{cgit-configuration} parameter} string index-info
  25432. The content of the file specified with this option will be included
  25433. verbatim below the heading on the repository index page.
  25434. Defaults to @samp{""}.
  25435. @end deftypevr
  25436. @deftypevr {@code{cgit-configuration} parameter} boolean local-time?
  25437. Flag which, if set to @samp{#t}, makes cgit print commit and tag times
  25438. in the servers timezone.
  25439. Defaults to @samp{#f}.
  25440. @end deftypevr
  25441. @deftypevr {@code{cgit-configuration} parameter} file-object logo
  25442. URL which specifies the source of an image which will be used as a logo
  25443. on all cgit pages.
  25444. Defaults to @samp{"/share/cgit/cgit.png"}.
  25445. @end deftypevr
  25446. @deftypevr {@code{cgit-configuration} parameter} string logo-link
  25447. URL loaded when clicking on the cgit logo image.
  25448. Defaults to @samp{""}.
  25449. @end deftypevr
  25450. @deftypevr {@code{cgit-configuration} parameter} file-object owner-filter
  25451. Command which will be invoked to format the Owner column of the main
  25452. page.
  25453. Defaults to @samp{""}.
  25454. @end deftypevr
  25455. @deftypevr {@code{cgit-configuration} parameter} integer max-atom-items
  25456. Number of items to display in atom feeds view.
  25457. Defaults to @samp{10}.
  25458. @end deftypevr
  25459. @deftypevr {@code{cgit-configuration} parameter} integer max-commit-count
  25460. Number of entries to list per page in "log" view.
  25461. Defaults to @samp{50}.
  25462. @end deftypevr
  25463. @deftypevr {@code{cgit-configuration} parameter} integer max-message-length
  25464. Number of commit message characters to display in "log" view.
  25465. Defaults to @samp{80}.
  25466. @end deftypevr
  25467. @deftypevr {@code{cgit-configuration} parameter} integer max-repo-count
  25468. Specifies the number of entries to list per page on the repository index
  25469. page.
  25470. Defaults to @samp{50}.
  25471. @end deftypevr
  25472. @deftypevr {@code{cgit-configuration} parameter} integer max-repodesc-length
  25473. Specifies the maximum number of repo description characters to display
  25474. on the repository index page.
  25475. Defaults to @samp{80}.
  25476. @end deftypevr
  25477. @deftypevr {@code{cgit-configuration} parameter} integer max-blob-size
  25478. Specifies the maximum size of a blob to display HTML for in KBytes.
  25479. Defaults to @samp{0}.
  25480. @end deftypevr
  25481. @deftypevr {@code{cgit-configuration} parameter} string max-stats
  25482. Maximum statistics period. Valid values are @samp{week},@samp{month},
  25483. @samp{quarter} and @samp{year}.
  25484. Defaults to @samp{""}.
  25485. @end deftypevr
  25486. @deftypevr {@code{cgit-configuration} parameter} mimetype-alist mimetype
  25487. Mimetype for the specified filename extension.
  25488. Defaults to @samp{((gif "image/gif") (html "text/html") (jpg
  25489. "image/jpeg") (jpeg "image/jpeg") (pdf "application/pdf") (png
  25490. "image/png") (svg "image/svg+xml"))}.
  25491. @end deftypevr
  25492. @deftypevr {@code{cgit-configuration} parameter} file-object mimetype-file
  25493. Specifies the file to use for automatic mimetype lookup.
  25494. Defaults to @samp{""}.
  25495. @end deftypevr
  25496. @deftypevr {@code{cgit-configuration} parameter} string module-link
  25497. Text which will be used as the formatstring for a hyperlink when a
  25498. submodule is printed in a directory listing.
  25499. Defaults to @samp{""}.
  25500. @end deftypevr
  25501. @deftypevr {@code{cgit-configuration} parameter} boolean nocache?
  25502. If set to the value @samp{#t} caching will be disabled.
  25503. Defaults to @samp{#f}.
  25504. @end deftypevr
  25505. @deftypevr {@code{cgit-configuration} parameter} boolean noplainemail?
  25506. If set to @samp{#t} showing full author email addresses will be
  25507. disabled.
  25508. Defaults to @samp{#f}.
  25509. @end deftypevr
  25510. @deftypevr {@code{cgit-configuration} parameter} boolean noheader?
  25511. Flag which, when set to @samp{#t}, will make cgit omit the standard
  25512. header on all pages.
  25513. Defaults to @samp{#f}.
  25514. @end deftypevr
  25515. @deftypevr {@code{cgit-configuration} parameter} project-list project-list
  25516. A list of subdirectories inside of @code{repository-directory}, relative
  25517. to it, that should loaded as Git repositories. An empty list means that
  25518. all subdirectories will be loaded.
  25519. Defaults to @samp{()}.
  25520. @end deftypevr
  25521. @deftypevr {@code{cgit-configuration} parameter} file-object readme
  25522. Text which will be used as default value for @code{cgit-repo-readme}.
  25523. Defaults to @samp{""}.
  25524. @end deftypevr
  25525. @deftypevr {@code{cgit-configuration} parameter} boolean remove-suffix?
  25526. If set to @code{#t} and @code{repository-directory} is enabled, if any
  25527. repositories are found with a suffix of @code{.git}, this suffix will be
  25528. removed for the URL and name.
  25529. Defaults to @samp{#f}.
  25530. @end deftypevr
  25531. @deftypevr {@code{cgit-configuration} parameter} integer renamelimit
  25532. Maximum number of files to consider when detecting renames.
  25533. Defaults to @samp{-1}.
  25534. @end deftypevr
  25535. @deftypevr {@code{cgit-configuration} parameter} string repository-sort
  25536. The way in which repositories in each section are sorted.
  25537. Defaults to @samp{""}.
  25538. @end deftypevr
  25539. @deftypevr {@code{cgit-configuration} parameter} robots-list robots
  25540. Text used as content for the @code{robots} meta-tag.
  25541. Defaults to @samp{("noindex" "nofollow")}.
  25542. @end deftypevr
  25543. @deftypevr {@code{cgit-configuration} parameter} string root-desc
  25544. Text printed below the heading on the repository index page.
  25545. Defaults to @samp{"a fast webinterface for the git dscm"}.
  25546. @end deftypevr
  25547. @deftypevr {@code{cgit-configuration} parameter} string root-readme
  25548. The content of the file specified with this option will be included
  25549. verbatim below the ``about'' link on the repository index page.
  25550. Defaults to @samp{""}.
  25551. @end deftypevr
  25552. @deftypevr {@code{cgit-configuration} parameter} string root-title
  25553. Text printed as heading on the repository index page.
  25554. Defaults to @samp{""}.
  25555. @end deftypevr
  25556. @deftypevr {@code{cgit-configuration} parameter} boolean scan-hidden-path
  25557. If set to @samp{#t} and repository-directory is enabled,
  25558. repository-directory will recurse into directories whose name starts
  25559. with a period. Otherwise, repository-directory will stay away from such
  25560. directories, considered as ``hidden''. Note that this does not apply to
  25561. the @file{.git} directory in non-bare repos.
  25562. Defaults to @samp{#f}.
  25563. @end deftypevr
  25564. @deftypevr {@code{cgit-configuration} parameter} list snapshots
  25565. Text which specifies the default set of snapshot formats that cgit
  25566. generates links for.
  25567. Defaults to @samp{()}.
  25568. @end deftypevr
  25569. @deftypevr {@code{cgit-configuration} parameter} repository-directory repository-directory
  25570. Name of the directory to scan for repositories (represents
  25571. @code{scan-path}).
  25572. Defaults to @samp{"/srv/git"}.
  25573. @end deftypevr
  25574. @deftypevr {@code{cgit-configuration} parameter} string section
  25575. The name of the current repository section - all repositories defined
  25576. after this option will inherit the current section name.
  25577. Defaults to @samp{""}.
  25578. @end deftypevr
  25579. @deftypevr {@code{cgit-configuration} parameter} string section-sort
  25580. Flag which, when set to @samp{1}, will sort the sections on the
  25581. repository listing by name.
  25582. Defaults to @samp{""}.
  25583. @end deftypevr
  25584. @deftypevr {@code{cgit-configuration} parameter} integer section-from-path
  25585. A number which, if defined prior to repository-directory, specifies how
  25586. many path elements from each repo path to use as a default section name.
  25587. Defaults to @samp{0}.
  25588. @end deftypevr
  25589. @deftypevr {@code{cgit-configuration} parameter} boolean side-by-side-diffs?
  25590. If set to @samp{#t} shows side-by-side diffs instead of unidiffs per
  25591. default.
  25592. Defaults to @samp{#f}.
  25593. @end deftypevr
  25594. @deftypevr {@code{cgit-configuration} parameter} file-object source-filter
  25595. Specifies a command which will be invoked to format plaintext blobs in
  25596. the tree view.
  25597. Defaults to @samp{""}.
  25598. @end deftypevr
  25599. @deftypevr {@code{cgit-configuration} parameter} integer summary-branches
  25600. Specifies the number of branches to display in the repository ``summary''
  25601. view.
  25602. Defaults to @samp{10}.
  25603. @end deftypevr
  25604. @deftypevr {@code{cgit-configuration} parameter} integer summary-log
  25605. Specifies the number of log entries to display in the repository
  25606. ``summary'' view.
  25607. Defaults to @samp{10}.
  25608. @end deftypevr
  25609. @deftypevr {@code{cgit-configuration} parameter} integer summary-tags
  25610. Specifies the number of tags to display in the repository ``summary''
  25611. view.
  25612. Defaults to @samp{10}.
  25613. @end deftypevr
  25614. @deftypevr {@code{cgit-configuration} parameter} string strict-export
  25615. Filename which, if specified, needs to be present within the repository
  25616. for cgit to allow access to that repository.
  25617. Defaults to @samp{""}.
  25618. @end deftypevr
  25619. @deftypevr {@code{cgit-configuration} parameter} string virtual-root
  25620. URL which, if specified, will be used as root for all cgit links.
  25621. Defaults to @samp{"/"}.
  25622. @end deftypevr
  25623. @deftypevr {@code{cgit-configuration} parameter} repository-cgit-configuration-list repositories
  25624. A list of @dfn{cgit-repo} records to use with config.
  25625. Defaults to @samp{()}.
  25626. Available @code{repository-cgit-configuration} fields are:
  25627. @deftypevr {@code{repository-cgit-configuration} parameter} repo-list snapshots
  25628. A mask of snapshot formats for this repo that cgit generates links for,
  25629. restricted by the global @code{snapshots} setting.
  25630. Defaults to @samp{()}.
  25631. @end deftypevr
  25632. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object source-filter
  25633. Override the default @code{source-filter}.
  25634. Defaults to @samp{""}.
  25635. @end deftypevr
  25636. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string url
  25637. The relative URL used to access the repository.
  25638. Defaults to @samp{""}.
  25639. @end deftypevr
  25640. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object about-filter
  25641. Override the default @code{about-filter}.
  25642. Defaults to @samp{""}.
  25643. @end deftypevr
  25644. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string branch-sort
  25645. Flag which, when set to @samp{age}, enables date ordering in the branch
  25646. ref list, and when set to @samp{name} enables ordering by branch name.
  25647. Defaults to @samp{""}.
  25648. @end deftypevr
  25649. @deftypevr {@code{repository-cgit-configuration} parameter} repo-list clone-url
  25650. A list of URLs which can be used to clone repo.
  25651. Defaults to @samp{()}.
  25652. @end deftypevr
  25653. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object commit-filter
  25654. Override the default @code{commit-filter}.
  25655. Defaults to @samp{""}.
  25656. @end deftypevr
  25657. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string commit-sort
  25658. Flag which, when set to @samp{date}, enables strict date ordering in the
  25659. commit log, and when set to @samp{topo} enables strict topological
  25660. ordering.
  25661. Defaults to @samp{""}.
  25662. @end deftypevr
  25663. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string defbranch
  25664. The name of the default branch for this repository. If no such branch
  25665. exists in the repository, the first branch name (when sorted) is used as
  25666. default instead. By default branch pointed to by HEAD, or ``master'' if
  25667. there is no suitable HEAD.
  25668. Defaults to @samp{""}.
  25669. @end deftypevr
  25670. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string desc
  25671. The value to show as repository description.
  25672. Defaults to @samp{""}.
  25673. @end deftypevr
  25674. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string homepage
  25675. The value to show as repository homepage.
  25676. Defaults to @samp{""}.
  25677. @end deftypevr
  25678. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object email-filter
  25679. Override the default @code{email-filter}.
  25680. Defaults to @samp{""}.
  25681. @end deftypevr
  25682. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-commit-graph?
  25683. A flag which can be used to disable the global setting
  25684. @code{enable-commit-graph?}.
  25685. Defaults to @samp{disabled}.
  25686. @end deftypevr
  25687. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-log-filecount?
  25688. A flag which can be used to disable the global setting
  25689. @code{enable-log-filecount?}.
  25690. Defaults to @samp{disabled}.
  25691. @end deftypevr
  25692. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-log-linecount?
  25693. A flag which can be used to disable the global setting
  25694. @code{enable-log-linecount?}.
  25695. Defaults to @samp{disabled}.
  25696. @end deftypevr
  25697. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-remote-branches?
  25698. Flag which, when set to @code{#t}, will make cgit display remote
  25699. branches in the summary and refs views.
  25700. Defaults to @samp{disabled}.
  25701. @end deftypevr
  25702. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-subject-links?
  25703. A flag which can be used to override the global setting
  25704. @code{enable-subject-links?}.
  25705. Defaults to @samp{disabled}.
  25706. @end deftypevr
  25707. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-html-serving?
  25708. A flag which can be used to override the global setting
  25709. @code{enable-html-serving?}.
  25710. Defaults to @samp{disabled}.
  25711. @end deftypevr
  25712. @deftypevr {@code{repository-cgit-configuration} parameter} repo-boolean hide?
  25713. Flag which, when set to @code{#t}, hides the repository from the
  25714. repository index.
  25715. Defaults to @samp{#f}.
  25716. @end deftypevr
  25717. @deftypevr {@code{repository-cgit-configuration} parameter} repo-boolean ignore?
  25718. Flag which, when set to @samp{#t}, ignores the repository.
  25719. Defaults to @samp{#f}.
  25720. @end deftypevr
  25721. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object logo
  25722. URL which specifies the source of an image which will be used as a logo
  25723. on this repo’s pages.
  25724. Defaults to @samp{""}.
  25725. @end deftypevr
  25726. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string logo-link
  25727. URL loaded when clicking on the cgit logo image.
  25728. Defaults to @samp{""}.
  25729. @end deftypevr
  25730. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object owner-filter
  25731. Override the default @code{owner-filter}.
  25732. Defaults to @samp{""}.
  25733. @end deftypevr
  25734. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string module-link
  25735. Text which will be used as the formatstring for a hyperlink when a
  25736. submodule is printed in a directory listing. The arguments for the
  25737. formatstring are the path and SHA1 of the submodule commit.
  25738. Defaults to @samp{""}.
  25739. @end deftypevr
  25740. @deftypevr {@code{repository-cgit-configuration} parameter} module-link-path module-link-path
  25741. Text which will be used as the formatstring for a hyperlink when a
  25742. submodule with the specified subdirectory path is printed in a directory
  25743. listing.
  25744. Defaults to @samp{()}.
  25745. @end deftypevr
  25746. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string max-stats
  25747. Override the default maximum statistics period.
  25748. Defaults to @samp{""}.
  25749. @end deftypevr
  25750. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string name
  25751. The value to show as repository name.
  25752. Defaults to @samp{""}.
  25753. @end deftypevr
  25754. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string owner
  25755. A value used to identify the owner of the repository.
  25756. Defaults to @samp{""}.
  25757. @end deftypevr
  25758. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string path
  25759. An absolute path to the repository directory.
  25760. Defaults to @samp{""}.
  25761. @end deftypevr
  25762. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string readme
  25763. A path (relative to repo) which specifies a file to include verbatim as
  25764. the ``About'' page for this repo.
  25765. Defaults to @samp{""}.
  25766. @end deftypevr
  25767. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string section
  25768. The name of the current repository section - all repositories defined
  25769. after this option will inherit the current section name.
  25770. Defaults to @samp{""}.
  25771. @end deftypevr
  25772. @deftypevr {@code{repository-cgit-configuration} parameter} repo-list extra-options
  25773. Extra options will be appended to cgitrc file.
  25774. Defaults to @samp{()}.
  25775. @end deftypevr
  25776. @end deftypevr
  25777. @deftypevr {@code{cgit-configuration} parameter} list extra-options
  25778. Extra options will be appended to cgitrc file.
  25779. Defaults to @samp{()}.
  25780. @end deftypevr
  25781. @c %end of fragment
  25782. However, it could be that you just want to get a @code{cgitrc} up and
  25783. running. In that case, you can pass an @code{opaque-cgit-configuration}
  25784. as a record to @code{cgit-service-type}. As its name indicates, an
  25785. opaque configuration does not have easy reflective capabilities.
  25786. Available @code{opaque-cgit-configuration} fields are:
  25787. @deftypevr {@code{opaque-cgit-configuration} parameter} package cgit
  25788. The cgit package.
  25789. @end deftypevr
  25790. @deftypevr {@code{opaque-cgit-configuration} parameter} string string
  25791. The contents of the @code{cgitrc}, as a string.
  25792. @end deftypevr
  25793. For example, if your @code{cgitrc} is just the empty string, you
  25794. could instantiate a cgit service like this:
  25795. @lisp
  25796. (service cgit-service-type
  25797. (opaque-cgit-configuration
  25798. (cgitrc "")))
  25799. @end lisp
  25800. @subsubheading Gitolite Service
  25801. @cindex Gitolite service
  25802. @cindex Git, hosting
  25803. @uref{https://gitolite.com/gitolite/, Gitolite} is a tool for hosting Git
  25804. repositories on a central server.
  25805. Gitolite can handle multiple repositories and users, and supports flexible
  25806. configuration of the permissions for the users on the repositories.
  25807. The following example will configure Gitolite using the default @code{git}
  25808. user, and the provided SSH public key.
  25809. @lisp
  25810. (service gitolite-service-type
  25811. (gitolite-configuration
  25812. (admin-pubkey (plain-file
  25813. "yourname.pub"
  25814. "ssh-rsa AAAA... guix@@example.com"))))
  25815. @end lisp
  25816. Gitolite is configured through a special admin repository which you can clone,
  25817. for example, if you setup Gitolite on @code{example.com}, you would run the
  25818. following command to clone the admin repository.
  25819. @example
  25820. git clone git@@example.com:gitolite-admin
  25821. @end example
  25822. When the Gitolite service is activated, the provided @code{admin-pubkey} will
  25823. be inserted in to the @file{keydir} directory in the gitolite-admin
  25824. repository. If this results in a change in the repository, it will be
  25825. committed using the message ``gitolite setup by GNU Guix''.
  25826. @deftp {Data Type} gitolite-configuration
  25827. Data type representing the configuration for @code{gitolite-service-type}.
  25828. @table @asis
  25829. @item @code{package} (default: @var{gitolite})
  25830. Gitolite package to use.
  25831. @item @code{user} (default: @var{git})
  25832. User to use for Gitolite. This will be user that you use when accessing
  25833. Gitolite over SSH.
  25834. @item @code{group} (default: @var{git})
  25835. Group to use for Gitolite.
  25836. @item @code{home-directory} (default: @var{"/var/lib/gitolite"})
  25837. Directory in which to store the Gitolite configuration and repositories.
  25838. @item @code{rc-file} (default: @var{(gitolite-rc-file)})
  25839. A ``file-like'' object (@pxref{G-Expressions, file-like objects}),
  25840. representing the configuration for Gitolite.
  25841. @item @code{admin-pubkey} (default: @var{#f})
  25842. A ``file-like'' object (@pxref{G-Expressions, file-like objects}) used to
  25843. setup Gitolite. This will be inserted in to the @file{keydir} directory
  25844. within the gitolite-admin repository.
  25845. To specify the SSH key as a string, use the @code{plain-file} function.
  25846. @lisp
  25847. (plain-file "yourname.pub" "ssh-rsa AAAA... guix@@example.com")
  25848. @end lisp
  25849. @end table
  25850. @end deftp
  25851. @deftp {Data Type} gitolite-rc-file
  25852. Data type representing the Gitolite RC file.
  25853. @table @asis
  25854. @item @code{umask} (default: @code{#o0077})
  25855. This controls the permissions Gitolite sets on the repositories and their
  25856. contents.
  25857. A value like @code{#o0027} will give read access to the group used by Gitolite
  25858. (by default: @code{git}). This is necessary when using Gitolite with software
  25859. like cgit or gitweb.
  25860. @item @code{unsafe-pattern} (default: @code{#f})
  25861. An optional Perl regular expression for catching unsafe configurations in
  25862. the configuration file. See
  25863. @uref{https://gitolite.com/gitolite/git-config.html#compensating-for-unsafe_patt,
  25864. Gitolite's documentation} for more information.
  25865. When the value is not @code{#f}, it should be a string containing a Perl
  25866. regular expression, such as @samp{"[`~#\$\&()|;<>]"}, which is the default
  25867. value used by gitolite. It rejects any special character in configuration
  25868. that might be interpreted by a shell, which is useful when sharing the
  25869. administration burden with other people that do not otherwise have shell
  25870. access on the server.
  25871. @item @code{git-config-keys} (default: @code{""})
  25872. Gitolite allows you to set git config values using the @samp{config}
  25873. keyword. This setting allows control over the config keys to accept.
  25874. @item @code{roles} (default: @code{'(("READERS" . 1) ("WRITERS" . ))})
  25875. Set the role names allowed to be used by users running the perms command.
  25876. @item @code{enable} (default: @code{'("help" "desc" "info" "perms" "writable" "ssh-authkeys" "git-config" "daemon" "gitweb")})
  25877. This setting controls the commands and features to enable within Gitolite.
  25878. @end table
  25879. @end deftp
  25880. @subsubheading Gitile Service
  25881. @cindex Gitile service
  25882. @cindex Git, forge
  25883. @uref{https://git.lepiller.eu/gitile, Gitile} is a Git forge for viewing
  25884. public git repository contents from a web browser.
  25885. Gitile works best in collaboration with Gitolite, and will serve the public
  25886. repositories from Gitolite by default. The service should listen only on
  25887. a local port, and a webserver should be configured to serve static resources.
  25888. The gitile service provides an easy way to extend the Nginx service for
  25889. that purpose (@pxref{NGINX}).
  25890. The following example will configure Gitile to serve repositories from a
  25891. custom location, with some default messages for the home page and the
  25892. footers.
  25893. @lisp
  25894. (service gitile-service-type
  25895. (gitile-configuration
  25896. (repositories "/srv/git")
  25897. (base-git-url "https://myweb.site/git")
  25898. (index-title "My git repositories")
  25899. (intro '((p "This is all my public work!")))
  25900. (footer '((p "This is the end")))
  25901. (nginx-server-block
  25902. (nginx-server-configuration
  25903. (ssl-certificate
  25904. "/etc/letsencrypt/live/myweb.site/fullchain.pem")
  25905. (ssl-certificate-key
  25906. "/etc/letsencrypt/live/myweb.site/privkey.pem")
  25907. (listen '("443 ssl http2" "[::]:443 ssl http2"))
  25908. (locations
  25909. (list
  25910. ;; Allow for https anonymous fetch on /git/ urls.
  25911. (git-http-nginx-location-configuration
  25912. (git-http-configuration
  25913. (uri-path "/git/")
  25914. (git-root "/var/lib/gitolite/repositories")))))))))
  25915. @end lisp
  25916. In addition to the configuration record, you should configure your git
  25917. repositories to contain some optional information. First, your public
  25918. repositories need to contain the @file{git-daemon-export-ok} magic file
  25919. that allows Git to export the repository. Gitile uses the presence of this
  25920. file to detect public repositories it should make accessible. To do so with
  25921. Gitolite for instance, modify your @file{conf/gitolite.conf} to include
  25922. this in the repositories you want to make public:
  25923. @example
  25924. repo foo
  25925. R = daemon
  25926. @end example
  25927. In addition, Gitile can read the repository configuration to display more
  25928. information on the repository. Gitile uses the gitweb namespace for its
  25929. configuration. As an example, you can use the following in your
  25930. @file{conf/gitolite.conf}:
  25931. @example
  25932. repo foo
  25933. R = daemon
  25934. desc = A long description, optionally with <i>HTML</i>, shown on the index page
  25935. config gitweb.name = The Foo Project
  25936. config gitweb.synopsis = A short description, shown on the main page of the project
  25937. @end example
  25938. Do not forget to commit and push these changes once you are satisfied. You
  25939. may need to change your gitolite configuration to allow the previous
  25940. configuration options to be set. One way to do that is to add the
  25941. following service definition:
  25942. @lisp
  25943. (service gitolite-service-type
  25944. (gitolite-configuration
  25945. (admin-pubkey (local-file "key.pub"))
  25946. (rc-file
  25947. (gitolite-rc-file
  25948. (umask #o0027)
  25949. ;; Allow to set any configuration key
  25950. (git-config-keys ".*")
  25951. ;; Allow any text as a valid configuration value
  25952. (unsafe-patt "^$")))))
  25953. @end lisp
  25954. @deftp {Data Type} gitile-configuration
  25955. Data type representing the configuration for @code{gitile-service-type}.
  25956. @table @asis
  25957. @item @code{package} (default: @var{gitile})
  25958. Gitile package to use.
  25959. @item @code{host} (default: @code{"localhost"})
  25960. The host on which gitile is listening.
  25961. @item @code{port} (default: @code{8080})
  25962. The port on which gitile is listening.
  25963. @item @code{database} (default: @code{"/var/lib/gitile/gitile-db.sql"})
  25964. The location of the database.
  25965. @item @code{repositories} (default: @code{"/var/lib/gitolite/repositories"})
  25966. The location of the repositories. Note that only public repositories will
  25967. be shown by Gitile. To make a repository public, add an empty
  25968. @file{git-daemon-export-ok} file at the root of that repository.
  25969. @item @code{base-git-url}
  25970. The base git url that will be used to show clone commands.
  25971. @item @code{index-title} (default: @code{"Index"})
  25972. The page title for the index page that lists all the available repositories.
  25973. @item @code{intro} (default: @code{'()})
  25974. The intro content, as a list of sxml expressions. This is shown above the list
  25975. of repositories, on the index page.
  25976. @item @code{footer} (default: @code{'()})
  25977. The footer content, as a list of sxml expressions. This is shown on every
  25978. page served by Gitile.
  25979. @item @code{nginx-server-block}
  25980. An nginx server block that will be extended and used as a reverse proxy by
  25981. Gitile to serve its pages, and as a normal web server to serve its assets.
  25982. You can use this block to add more custom URLs to your domain, such as a
  25983. @code{/git/} URL for anonymous clones, or serving any other files you would
  25984. like to serve.
  25985. @end table
  25986. @end deftp
  25987. @node Game Services
  25988. @subsection Game Services
  25989. @subsubheading The Battle for Wesnoth Service
  25990. @cindex wesnothd
  25991. @uref{https://wesnoth.org, The Battle for Wesnoth} is a fantasy, turn
  25992. based tactical strategy game, with several single player campaigns, and
  25993. multiplayer games (both networked and local).
  25994. @defvar {Scheme Variable} wesnothd-service-type
  25995. Service type for the wesnothd service. Its value must be a
  25996. @code{wesnothd-configuration} object. To run wesnothd in the default
  25997. configuration, instantiate it as:
  25998. @lisp
  25999. (service wesnothd-service-type)
  26000. @end lisp
  26001. @end defvar
  26002. @deftp {Data Type} wesnothd-configuration
  26003. Data type representing the configuration of @command{wesnothd}.
  26004. @table @asis
  26005. @item @code{package} (default: @code{wesnoth-server})
  26006. The wesnoth server package to use.
  26007. @item @code{port} (default: @code{15000})
  26008. The port to bind the server to.
  26009. @end table
  26010. @end deftp
  26011. @node PAM Mount Service
  26012. @subsection PAM Mount Service
  26013. @cindex pam-mount
  26014. The @code{(gnu services pam-mount)} module provides a service allowing
  26015. users to mount volumes when they log in. It should be able to mount any
  26016. volume format supported by the system.
  26017. @defvar {Scheme Variable} pam-mount-service-type
  26018. Service type for PAM Mount support.
  26019. @end defvar
  26020. @deftp {Data Type} pam-mount-configuration
  26021. Data type representing the configuration of PAM Mount.
  26022. It takes the following parameters:
  26023. @table @asis
  26024. @item @code{rules}
  26025. The configuration rules that will be used to generate
  26026. @file{/etc/security/pam_mount.conf.xml}.
  26027. The configuration rules are SXML elements (@pxref{SXML,,, guile, GNU
  26028. Guile Reference Manual}), and the default ones don't mount anything for
  26029. anyone at login:
  26030. @lisp
  26031. `((debug (@@ (enable "0")))
  26032. (mntoptions (@@ (allow ,(string-join
  26033. '("nosuid" "nodev" "loop"
  26034. "encryption" "fsck" "nonempty"
  26035. "allow_root" "allow_other")
  26036. ","))))
  26037. (mntoptions (@@ (require "nosuid,nodev")))
  26038. (logout (@@ (wait "0")
  26039. (hup "0")
  26040. (term "no")
  26041. (kill "no")))
  26042. (mkmountpoint (@@ (enable "1")
  26043. (remove "true"))))
  26044. @end lisp
  26045. Some @code{volume} elements must be added to automatically mount volumes
  26046. at login. Here's an example allowing the user @code{alice} to mount her
  26047. encrypted @env{HOME} directory and allowing the user @code{bob} to mount
  26048. the partition where he stores his data:
  26049. @lisp
  26050. (define pam-mount-rules
  26051. `((debug (@@ (enable "0")))
  26052. (volume (@@ (user "alice")
  26053. (fstype "crypt")
  26054. (path "/dev/sda2")
  26055. (mountpoint "/home/alice")))
  26056. (volume (@@ (user "bob")
  26057. (fstype "auto")
  26058. (path "/dev/sdb3")
  26059. (mountpoint "/home/bob/data")
  26060. (options "defaults,autodefrag,compress")))
  26061. (mntoptions (@@ (allow ,(string-join
  26062. '("nosuid" "nodev" "loop"
  26063. "encryption" "fsck" "nonempty"
  26064. "allow_root" "allow_other")
  26065. ","))))
  26066. (mntoptions (@@ (require "nosuid,nodev")))
  26067. (logout (@@ (wait "0")
  26068. (hup "0")
  26069. (term "no")
  26070. (kill "no")))
  26071. (mkmountpoint (@@ (enable "1")
  26072. (remove "true")))))
  26073. (service pam-mount-service-type
  26074. (pam-mount-configuration
  26075. (rules pam-mount-rules)))
  26076. @end lisp
  26077. The complete list of possible options can be found in the man page for
  26078. @uref{http://pam-mount.sourceforge.net/pam_mount.conf.5.html, pam_mount.conf}.
  26079. @end table
  26080. @end deftp
  26081. @node Guix Services
  26082. @subsection Guix Services
  26083. @subsubheading Guix Build Coordinator
  26084. The @uref{https://git.cbaines.net/guix/build-coordinator/,Guix Build
  26085. Coordinator} aids in distributing derivation builds among machines
  26086. running an @dfn{agent}. The build daemon is still used to build the
  26087. derivations, but the Guix Build Coordinator manages allocating builds
  26088. and working with the results.
  26089. The Guix Build Coordinator consists of one @dfn{coordinator}, and one or
  26090. more connected @dfn{agent} processes. The coordinator process handles
  26091. clients submitting builds, and allocating builds to agents. The agent
  26092. processes talk to a build daemon to actually perform the builds, then
  26093. send the results back to the coordinator.
  26094. There is a script to run the coordinator component of the Guix Build
  26095. Coordinator, but the Guix service uses a custom Guile script instead, to
  26096. provide better integration with G-expressions used in the configuration.
  26097. @defvar {Scheme Variable} guix-build-coordinator-service-type
  26098. Service type for the Guix Build Coordinator. Its value must be a
  26099. @code{guix-build-coordinator-configuration} object.
  26100. @end defvar
  26101. @deftp {Data Type} guix-build-coordinator-configuration
  26102. Data type representing the configuration of the Guix Build Coordinator.
  26103. @table @asis
  26104. @item @code{package} (default: @code{guix-build-coordinator})
  26105. The Guix Build Coordinator package to use.
  26106. @item @code{user} (default: @code{"guix-build-coordinator"})
  26107. The system user to run the service as.
  26108. @item @code{group} (default: @code{"guix-build-coordinator"})
  26109. The system group to run the service as.
  26110. @item @code{database-uri-string} (default: @code{"sqlite:///var/lib/guix-build-coordinator/guix_build_coordinator.db"})
  26111. The URI to use for the database.
  26112. @item @code{agent-communication-uri} (default: @code{"http://0.0.0.0:8745"})
  26113. The URI describing how to listen to requests from agent processes.
  26114. @item @code{client-communication-uri} (default: @code{"http://127.0.0.1:8746"})
  26115. The URI describing how to listen to requests from clients. The client
  26116. API allows submitting builds and currently isn't authenticated, so take
  26117. care when configuring this value.
  26118. @item @code{allocation-strategy} (default: @code{#~basic-build-allocation-strategy})
  26119. A G-expression for the allocation strategy to be used. This is a
  26120. procedure that takes the datastore as an argument and populates the
  26121. allocation plan in the database.
  26122. @item @code{hooks} (default: @var{'()})
  26123. An association list of hooks. These provide a way to execute arbitrary
  26124. code upon certain events, like a build result being processed.
  26125. @item @code{guile} (default: @code{guile-3.0-latest})
  26126. The Guile package with which to run the Guix Build Coordinator.
  26127. @end table
  26128. @end deftp
  26129. @defvar {Scheme Variable} guix-build-coordinator-agent-service-type
  26130. Service type for a Guix Build Coordinator agent. Its value must be a
  26131. @code{guix-build-coordinator-agent-configuration} object.
  26132. @end defvar
  26133. @deftp {Data Type} guix-build-coordinator-agent-configuration
  26134. Data type representing the configuration a Guix Build Coordinator agent.
  26135. @table @asis
  26136. @item @code{package} (default: @code{guix-build-coordinator/agent-only})
  26137. The Guix Build Coordinator package to use.
  26138. @item @code{user} (default: @code{"guix-build-coordinator-agent"})
  26139. The system user to run the service as.
  26140. @item @code{coordinator} (default: @code{"http://localhost:8745"})
  26141. The URI to use when connecting to the coordinator.
  26142. @item @code{authentication}
  26143. Record describing how this agent should authenticate with the
  26144. coordinator. Possible record types are described below.
  26145. @item @code{systems} (default: @code{#f})
  26146. The systems for which this agent should fetch builds. The agent process
  26147. will use the current system it's running on as the default.
  26148. @item @code{max-parallel-builds} (default: @code{1})
  26149. The number of builds to perform in parallel.
  26150. @item @code{max-1min-load-average} (default: @code{#f})
  26151. Load average value to look at when considering starting new builds, if
  26152. the 1 minute load average exceeds this value, the agent will wait before
  26153. starting new builds.
  26154. This will be unspecified if the value is @code{#f}, and the agent will
  26155. use the number of cores reported by the system as the max 1 minute load
  26156. average.
  26157. @item @code{derivation-substitute-urls} (default: @code{#f})
  26158. URLs from which to attempt to fetch substitutes for derivations, if the
  26159. derivations aren't already available.
  26160. @item @code{non-derivation-substitute-urls} (default: @code{#f})
  26161. URLs from which to attempt to fetch substitutes for build inputs, if the
  26162. input store items aren't already available.
  26163. @end table
  26164. @end deftp
  26165. @deftp {Data Type} guix-build-coordinator-agent-password-auth
  26166. Data type representing an agent authenticating with a coordinator via a
  26167. UUID and password.
  26168. @table @asis
  26169. @item @code{uuid}
  26170. The UUID of the agent. This should be generated by the coordinator
  26171. process, stored in the coordinator database, and used by the intended
  26172. agent.
  26173. @item @code{password}
  26174. The password to use when connecting to the coordinator.
  26175. @end table
  26176. @end deftp
  26177. @deftp {Data Type} guix-build-coordinator-agent-password-file-auth
  26178. Data type representing an agent authenticating with a coordinator via a
  26179. UUID and password read from a file.
  26180. @table @asis
  26181. @item @code{uuid}
  26182. The UUID of the agent. This should be generated by the coordinator
  26183. process, stored in the coordinator database, and used by the intended
  26184. agent.
  26185. @item @code{password-file}
  26186. A file containing the password to use when connecting to the
  26187. coordinator.
  26188. @end table
  26189. @end deftp
  26190. @deftp {Data Type} guix-build-coordinator-agent-dynamic-auth
  26191. Data type representing an agent authenticating with a coordinator via a
  26192. dynamic auth token and agent name.
  26193. @table @asis
  26194. @item @code{agent-name}
  26195. Name of an agent, this is used to match up to an existing entry in the
  26196. database if there is one. When no existing entry is found, a new entry
  26197. is automatically added.
  26198. @item @code{token}
  26199. Dynamic auth token, this is created and stored in the coordinator
  26200. database, and is used by the agent to authenticate.
  26201. @end table
  26202. @end deftp
  26203. @deftp {Data Type} guix-build-coordinator-agent-dynamic-auth-with-file
  26204. Data type representing an agent authenticating with a coordinator via a
  26205. dynamic auth token read from a file and agent name.
  26206. @table @asis
  26207. @item @code{agent-name}
  26208. Name of an agent, this is used to match up to an existing entry in the
  26209. database if there is one. When no existing entry is found, a new entry
  26210. is automatically added.
  26211. @item @code{token-file}
  26212. File containing the dynamic auth token, this is created and stored in
  26213. the coordinator database, and is used by the agent to authenticate.
  26214. @end table
  26215. @end deftp
  26216. The Guix Build Coordinator package contains a script to query an
  26217. instance of the Guix Data Service for derivations to build, and then
  26218. submit builds for those derivations to the coordinator. The service
  26219. type below assists in running this script. This is an additional tool
  26220. that may be useful when building derivations contained within an
  26221. instance of the Guix Data Service.
  26222. @defvar {Scheme Variable} guix-build-coordinator-queue-builds-service-type
  26223. Service type for the
  26224. guix-build-coordinator-queue-builds-from-guix-data-service script. Its
  26225. value must be a @code{guix-build-coordinator-queue-builds-configuration}
  26226. object.
  26227. @end defvar
  26228. @deftp {Data Type} guix-build-coordinator-queue-builds-configuration
  26229. Data type representing the options to the queue builds from guix data
  26230. service script.
  26231. @table @asis
  26232. @item @code{package} (default: @code{guix-build-coordinator})
  26233. The Guix Build Coordinator package to use.
  26234. @item @code{user} (default: @code{"guix-build-coordinator-queue-builds"})
  26235. The system user to run the service as.
  26236. @item @code{coordinator} (default: @code{"http://localhost:8746"})
  26237. The URI to use when connecting to the coordinator.
  26238. @item @code{systems} (default: @code{#f})
  26239. The systems for which to fetch derivations to build.
  26240. @item @code{systems-and-targets} (default: @code{#f})
  26241. An association list of system and target pairs for which to fetch
  26242. derivations to build.
  26243. @item @code{guix-data-service} (default: @code{"https://data.guix.gnu.org"})
  26244. The Guix Data Service instance from which to query to find out about
  26245. derivations to build.
  26246. @item @code{processed-commits-file} (default: @code{"/var/cache/guix-build-coordinator-queue-builds/processed-commits"})
  26247. A file to record which commits have been processed, to avoid needlessly
  26248. processing them again if the service is restarted.
  26249. @end table
  26250. @end deftp
  26251. @subsubheading Guix Data Service
  26252. The @uref{http://data.guix.gnu.org,Guix Data Service} processes, stores
  26253. and provides data about GNU Guix. This includes information about
  26254. packages, derivations and lint warnings.
  26255. The data is stored in a PostgreSQL database, and available through a web
  26256. interface.
  26257. @defvar {Scheme Variable} guix-data-service-type
  26258. Service type for the Guix Data Service. Its value must be a
  26259. @code{guix-data-service-configuration} object. The service optionally
  26260. extends the getmail service, as the guix-commits mailing list is used to
  26261. find out about changes in the Guix git repository.
  26262. @end defvar
  26263. @deftp {Data Type} guix-data-service-configuration
  26264. Data type representing the configuration of the Guix Data Service.
  26265. @table @asis
  26266. @item @code{package} (default: @code{guix-data-service})
  26267. The Guix Data Service package to use.
  26268. @item @code{user} (default: @code{"guix-data-service"})
  26269. The system user to run the service as.
  26270. @item @code{group} (default: @code{"guix-data-service"})
  26271. The system group to run the service as.
  26272. @item @code{port} (default: @code{8765})
  26273. The port to bind the web service to.
  26274. @item @code{host} (default: @code{"127.0.0.1"})
  26275. The host to bind the web service to.
  26276. @item @code{getmail-idle-mailboxes} (default: @code{#f})
  26277. If set, this is the list of mailboxes that the getmail service will be
  26278. configured to listen to.
  26279. @item @code{commits-getmail-retriever-configuration} (default: @code{#f})
  26280. If set, this is the @code{getmail-retriever-configuration} object with
  26281. which to configure getmail to fetch mail from the guix-commits mailing
  26282. list.
  26283. @item @code{extra-options} (default: @var{'()})
  26284. Extra command line options for @code{guix-data-service}.
  26285. @item @code{extra-process-jobs-options} (default: @var{'()})
  26286. Extra command line options for @code{guix-data-service-process-jobs}.
  26287. @end table
  26288. @end deftp
  26289. @subsubheading Nar Herder
  26290. The @uref{https://git.cbaines.net/guix/nar-herder/about/,Nar Herder} is
  26291. a utility for managing a collection of nars.
  26292. @defvar {Scheme Variable} nar-herder-type
  26293. Service type for the Guix Data Service. Its value must be a
  26294. @code{nar-herder-configuration} object. The service optionally
  26295. extends the getmail service, as the guix-commits mailing list is used to
  26296. find out about changes in the Guix git repository.
  26297. @end defvar
  26298. @deftp {Data Type} nar-herder-configuration
  26299. Data type representing the configuration of the Guix Data Service.
  26300. @table @asis
  26301. @item @code{package} (default: @code{nar-herder})
  26302. The Nar Herder package to use.
  26303. @item @code{user} (default: @code{"nar-herder"})
  26304. The system user to run the service as.
  26305. @item @code{group} (default: @code{"nar-herder"})
  26306. The system group to run the service as.
  26307. @item @code{port} (default: @code{8734})
  26308. The port to bind the server to.
  26309. @item @code{host} (default: @code{"127.0.0.1"})
  26310. The host to bind the server to.
  26311. @item @code{mirror} (default: @code{#f})
  26312. Optional URL of the other Nar Herder instance which should be mirrored.
  26313. This means that this Nar Herder instance will download it's database,
  26314. and keep it up to date.
  26315. @item @code{database} (default: @code{"/var/lib/nar-herder/nar_herder.db"})
  26316. Location for the database. If this Nar Herder instance is mirroring
  26317. another, the database will be downloaded if it doesn't exist. If this
  26318. Nar Herder instance isn't mirroring another, an empty database will be
  26319. created.
  26320. @item @code{database-dump} (default: @code{"/var/lib/nar-herder/nar_herder_dump.db"})
  26321. Location of the database dump. This is created and regularly updated by
  26322. taking a copy of the database. This is the version of the database that
  26323. is available to download.
  26324. @item @code{storage} (default: @code{#f})
  26325. Optional location in which to store nars.
  26326. @item @code{storage-limit} (default: @code{"none"})
  26327. Limit in bytes for the nars stored in the storage location. This can
  26328. also be set to ``none'' so that there is no limit.
  26329. When the storage location exceeds this size, nars are removed according
  26330. to the nar removal criteria.
  26331. @item @code{storage-nar-removal-criteria} (default: @code{'()})
  26332. Criteria used to remove nars from the storage location. These are used
  26333. in conjunction with the storage limit.
  26334. When the storage location exceeds the storage limit size, nars will be
  26335. checked against the nar removal criteria and if any of the criteria
  26336. match, they will be removed. This will continue until the storage
  26337. location is below the storage limit size.
  26338. Each criteria is specified by a string, then an equals sign, then
  26339. another string. Currently, only one criteria is supported, checking if a
  26340. nar is stored on another Nar Herder instance.
  26341. @item @code{ttl} (default: @code{#f})
  26342. Produce @code{Cache-Control} HTTP headers that advertise a time-to-live
  26343. (TTL) of @var{ttl}. @var{ttl} must denote a duration: @code{5d} means 5
  26344. days, @code{1m} means 1 month, and so on.
  26345. This allows the user's Guix to keep substitute information in cache for
  26346. @var{ttl}.
  26347. @item @code{negative-ttl} (default: @code{#f})
  26348. Similarly produce @code{Cache-Control} HTTP headers to advertise the
  26349. time-to-live (TTL) of @emph{negative} lookups---missing store items, for
  26350. which the HTTP 404 code is returned. By default, no negative TTL is
  26351. advertised.
  26352. @end table
  26353. @end deftp
  26354. @node Linux Services
  26355. @subsection Linux Services
  26356. @cindex oom
  26357. @cindex out of memory killer
  26358. @cindex earlyoom
  26359. @cindex early out of memory daemon
  26360. @subsubheading Early OOM Service
  26361. @uref{https://github.com/rfjakob/earlyoom,Early OOM}, also known as
  26362. Earlyoom, is a minimalist out of memory (OOM) daemon that runs in user
  26363. space and provides a more responsive and configurable alternative to the
  26364. in-kernel OOM killer. It is useful to prevent the system from becoming
  26365. unresponsive when it runs out of memory.
  26366. @deffn {Scheme Variable} earlyoom-service-type
  26367. The service type for running @command{earlyoom}, the Early OOM daemon.
  26368. Its value must be a @code{earlyoom-configuration} object, described
  26369. below. The service can be instantiated in its default configuration
  26370. with:
  26371. @lisp
  26372. (service earlyoom-service-type)
  26373. @end lisp
  26374. @end deffn
  26375. @deftp {Data Type} earlyoom-configuration
  26376. This is the configuration record for the @code{earlyoom-service-type}.
  26377. @table @asis
  26378. @item @code{earlyoom} (default: @var{earlyoom})
  26379. The Earlyoom package to use.
  26380. @item @code{minimum-available-memory} (default: @code{10})
  26381. The threshold for the minimum @emph{available} memory, in percentages.
  26382. @item @code{minimum-free-swap} (default: @code{10})
  26383. The threshold for the minimum free swap memory, in percentages.
  26384. @item @code{prefer-regexp} (default: @code{#f})
  26385. A regular expression (as a string) to match the names of the processes
  26386. that should be preferably killed.
  26387. @item @code{avoid-regexp} (default: @code{#f})
  26388. A regular expression (as a string) to match the names of the processes
  26389. that should @emph{not} be killed.
  26390. @item @code{memory-report-interval} (default: @code{0})
  26391. The interval in seconds at which a memory report is printed. It is
  26392. disabled by default.
  26393. @item @code{ignore-positive-oom-score-adj?} (default: @code{#f})
  26394. A boolean indicating whether the positive adjustments set in
  26395. @file{/proc/*/oom_score_adj} should be ignored.
  26396. @item @code{show-debug-messages?} (default: @code{#f})
  26397. A boolean indicating whether debug messages should be printed. The logs
  26398. are saved at @file{/var/log/earlyoom.log}.
  26399. @item @code{send-notification-command} (default: @code{#f})
  26400. This can be used to provide a custom command used for sending
  26401. notifications.
  26402. @end table
  26403. @end deftp
  26404. @cindex modprobe
  26405. @cindex kernel module loader
  26406. @subsubheading Kernel Module Loader Service
  26407. The kernel module loader service allows one to load loadable kernel
  26408. modules at boot. This is especially useful for modules that don't
  26409. autoload and need to be manually loaded, as is the case with
  26410. @code{ddcci}.
  26411. @deffn {Scheme Variable} kernel-module-loader-service-type
  26412. The service type for loading loadable kernel modules at boot with
  26413. @command{modprobe}. Its value must be a list of strings representing
  26414. module names. For example loading the drivers provided by
  26415. @code{ddcci-driver-linux}, in debugging mode by passing some module
  26416. parameters, can be done as follow:
  26417. @lisp
  26418. (use-modules (gnu) (gnu services))
  26419. (use-package-modules linux)
  26420. (use-service-modules linux)
  26421. (define ddcci-config
  26422. (plain-file "ddcci.conf"
  26423. "options ddcci dyndbg delay=120"))
  26424. (operating-system
  26425. ...
  26426. (services (cons* (service kernel-module-loader-service-type
  26427. '("ddcci" "ddcci_backlight"))
  26428. (simple-service 'ddcci-config etc-service-type
  26429. (list `("modprobe.d/ddcci.conf"
  26430. ,ddcci-config)))
  26431. %base-services))
  26432. (kernel-loadable-modules (list ddcci-driver-linux)))
  26433. @end lisp
  26434. @end deffn
  26435. @cindex rasdaemon
  26436. @cindex Platform Reliability, Availability and Serviceability daemon
  26437. @subsubheading Rasdaemon Service
  26438. The Rasdaemon service provides a daemon which monitors platform
  26439. @acronym{RAS, Reliability@comma{} Availability@comma{} and Serviceability} reports from
  26440. Linux kernel trace events, logging them to syslogd.
  26441. Reliability, Availability and Serviceability is a concept used on servers meant
  26442. to measure their robustness.
  26443. @strong{Relability} is the probability that a system will produce correct
  26444. outputs:
  26445. @itemize @bullet
  26446. @item Generally measured as Mean Time Between Failures (MTBF), and
  26447. @item Enhanced by features that help to avoid, detect and repair hardware
  26448. faults
  26449. @end itemize
  26450. @strong{Availability} is the probability that a system is operational at a
  26451. given time:
  26452. @itemize @bullet
  26453. @item Generally measured as a percentage of downtime per a period of time, and
  26454. @item Often uses mechanisms to detect and correct hardware faults in runtime.
  26455. @end itemize
  26456. @strong{Serviceability} is the simplicity and speed with which a system can be
  26457. repaired or maintained:
  26458. @itemize @bullet
  26459. @item Generally measured on Mean Time Between Repair (MTBR).
  26460. @end itemize
  26461. Among the monitoring measures, the most usual ones include:
  26462. @itemize @bullet
  26463. @item CPU – detect errors at instruction execution and at L1/L2/L3 caches;
  26464. @item Memory – add error correction logic (ECC) to detect and correct errors;
  26465. @item I/O – add CRC checksums for transferred data;
  26466. @item Storage – RAID, journal file systems, checksums, Self-Monitoring,
  26467. Analysis and Reporting Technology (SMART).
  26468. @end itemize
  26469. By monitoring the number of occurrences of error detections, it is possible to
  26470. identify if the probability of hardware errors is increasing, and, on such
  26471. case, do a preventive maintenance to replace a degraded component while those
  26472. errors are correctable.
  26473. For detailed information about the types of error events gathered and how to
  26474. make sense of them, see the kernel administrator's guide at
  26475. @url{https://www.kernel.org/doc/html/latest/admin-guide/ras.html}.
  26476. @defvr {Scheme Variable} rasdaemon-service-type
  26477. Service type for the @command{rasdaemon} service. It accepts a
  26478. @code{rasdaemon-configuration} object. Instantiating like
  26479. @lisp
  26480. (service rasdaemon-service-type)
  26481. @end lisp
  26482. will load with a default configuration, which monitors all events and logs to
  26483. syslogd.
  26484. @end defvr
  26485. @deftp {Data Type} rasdaemon-configuration
  26486. The data type representing the configuration of @command{rasdaemon}.
  26487. @table @asis
  26488. @item @code{record?} (default: @code{#f})
  26489. A boolean indicating whether to record the events in an SQLite database. This
  26490. provides a more structured access to the information contained in the log file.
  26491. The database location is hard-coded to @file{/var/lib/rasdaemon/ras-mc_event.db}.
  26492. @end table
  26493. @end deftp
  26494. @cindex zram
  26495. @cindex compressed swap
  26496. @cindex Compressed RAM-based block devices
  26497. @subsubheading Zram Device Service
  26498. The Zram device service provides a compressed swap device in system
  26499. memory. The Linux Kernel documentation has more information about
  26500. @uref{https://www.kernel.org/doc/html/latest/admin-guide/blockdev/zram.html,zram}
  26501. devices.
  26502. @deffn {Scheme Variable} zram-device-service-type
  26503. This service creates the zram block device, formats it as swap and
  26504. enables it as a swap device. The service's value is a
  26505. @code{zram-device-configuration} record.
  26506. @deftp {Data Type} zram-device-configuration
  26507. This is the data type representing the configuration for the zram-device
  26508. service.
  26509. @table @asis
  26510. @item @code{size} (default @code{"1G"})
  26511. This is the amount of space you wish to provide for the zram device. It
  26512. accepts a string and can be a number of bytes or use a suffix, eg.:
  26513. @code{"512M"} or @code{1024000}.
  26514. @item @code{compression-algorithm} (default @code{'lzo})
  26515. This is the compression algorithm you wish to use. It is difficult to
  26516. list all the possible compression options, but common ones supported by
  26517. Guix's Linux Libre Kernel include @code{'lzo}, @code{'lz4} and @code{'zstd}.
  26518. @item @code{memory-limit} (default @code{0})
  26519. This is the maximum amount of memory which the zram device can use.
  26520. Setting it to '0' disables the limit. While it is generally expected
  26521. that compression will be 2:1, it is possible that uncompressable data
  26522. can be written to swap and this is a method to limit how much memory can
  26523. be used. It accepts a string and can be a number of bytes or use a
  26524. suffix, eg.: @code{"2G"}.
  26525. @item @code{priority} (default @code{-1})
  26526. This is the priority of the swap device created from the zram device.
  26527. @code{swapon} accepts values between -1 and 32767, with higher values
  26528. indicating higher priority. Higher priority swap will generally be used
  26529. first.
  26530. @end table
  26531. @end deftp
  26532. @end deffn
  26533. @node Hurd Services
  26534. @subsection Hurd Services
  26535. @defvr {Scheme Variable} hurd-console-service-type
  26536. This service starts the fancy @code{VGA} console client on the Hurd.
  26537. The service's value is a @code{hurd-console-configuration} record.
  26538. @end defvr
  26539. @deftp {Data Type} hurd-console-configuration
  26540. This is the data type representing the configuration for the
  26541. hurd-console-service.
  26542. @table @asis
  26543. @item @code{hurd} (default: @var{hurd})
  26544. The Hurd package to use.
  26545. @end table
  26546. @end deftp
  26547. @defvr {Scheme Variable} hurd-getty-service-type
  26548. This service starts a tty using the Hurd @code{getty} program.
  26549. The service's value is a @code{hurd-getty-configuration} record.
  26550. @end defvr
  26551. @deftp {Data Type} hurd-getty-configuration
  26552. This is the data type representing the configuration for the
  26553. hurd-getty-service.
  26554. @table @asis
  26555. @item @code{hurd} (default: @var{hurd})
  26556. The Hurd package to use.
  26557. @item @code{tty}
  26558. The name of the console this Getty runs on---e.g., @code{"tty1"}.
  26559. @item @code{baud-rate} (default: @code{38400})
  26560. An integer specifying the baud rate of the tty.
  26561. @end table
  26562. @end deftp
  26563. @node Miscellaneous Services
  26564. @subsection Miscellaneous Services
  26565. @cindex fingerprint
  26566. @subsubheading Fingerprint Service
  26567. The @code{(gnu services authentication)} module provides a DBus service to
  26568. read and identify fingerprints via a fingerprint sensor.
  26569. @defvr {Scheme Variable} fprintd-service-type
  26570. The service type for @command{fprintd}, which provides the fingerprint
  26571. reading capability.
  26572. @lisp
  26573. (service fprintd-service-type)
  26574. @end lisp
  26575. @end defvr
  26576. @cindex sysctl
  26577. @subsubheading System Control Service
  26578. The @code{(gnu services sysctl)} provides a service to configure kernel
  26579. parameters at boot.
  26580. @defvr {Scheme Variable} sysctl-service-type
  26581. The service type for @command{sysctl}, which modifies kernel parameters
  26582. under @file{/proc/sys/}. To enable IPv4 forwarding, it can be
  26583. instantiated as:
  26584. @lisp
  26585. (service sysctl-service-type
  26586. (sysctl-configuration
  26587. (settings '(("net.ipv4.ip_forward" . "1")))))
  26588. @end lisp
  26589. Since @code{sysctl-service-type} is used in the default lists of
  26590. services, @code{%base-services} and @code{%desktop-services}, you can
  26591. use @code{modify-services} to change its configuration and add the
  26592. kernel parameters that you want (@pxref{Service Reference,
  26593. @code{modify-services}}).
  26594. @lisp
  26595. (modify-services %base-services
  26596. (sysctl-service-type config =>
  26597. (sysctl-configuration
  26598. (settings (append '(("net.ipv4.ip_forward" . "1"))
  26599. %default-sysctl-settings)))))
  26600. @end lisp
  26601. @end defvr
  26602. @deftp {Data Type} sysctl-configuration
  26603. The data type representing the configuration of @command{sysctl}.
  26604. @table @asis
  26605. @item @code{sysctl} (default: @code{(file-append procps "/sbin/sysctl"})
  26606. The @command{sysctl} executable to use.
  26607. @item @code{settings} (default: @code{%default-sysctl-settings})
  26608. An association list specifies kernel parameters and their values.
  26609. @end table
  26610. @end deftp
  26611. @defvr {Scheme Variable} %default-sysctl-settings
  26612. An association list specifying the default @command{sysctl} parameters
  26613. on Guix System.
  26614. @end defvr
  26615. @cindex pcscd
  26616. @subsubheading PC/SC Smart Card Daemon Service
  26617. The @code{(gnu services security-token)} module provides the following service
  26618. to run @command{pcscd}, the PC/SC Smart Card Daemon. @command{pcscd} is the
  26619. daemon program for pcsc-lite and the MuscleCard framework. It is a resource
  26620. manager that coordinates communications with smart card readers, smart cards
  26621. and cryptographic tokens that are connected to the system.
  26622. @defvr {Scheme Variable} pcscd-service-type
  26623. Service type for the @command{pcscd} service. Its value must be a
  26624. @code{pcscd-configuration} object. To run pcscd in the default
  26625. configuration, instantiate it as:
  26626. @lisp
  26627. (service pcscd-service-type)
  26628. @end lisp
  26629. @end defvr
  26630. @deftp {Data Type} pcscd-configuration
  26631. The data type representing the configuration of @command{pcscd}.
  26632. @table @asis
  26633. @item @code{pcsc-lite} (default: @code{pcsc-lite})
  26634. The pcsc-lite package that provides pcscd.
  26635. @item @code{usb-drivers} (default: @code{(list ccid)})
  26636. List of packages that provide USB drivers to pcscd. Drivers are expected to be
  26637. under @file{pcsc/drivers} in the store directory of the package.
  26638. @end table
  26639. @end deftp
  26640. @cindex lirc
  26641. @subsubheading Lirc Service
  26642. The @code{(gnu services lirc)} module provides the following service.
  26643. @deffn {Scheme Procedure} lirc-service [#:lirc lirc] @
  26644. [#:device #f] [#:driver #f] [#:config-file #f] @
  26645. [#:extra-options '()]
  26646. Return a service that runs @url{http://www.lirc.org,LIRC}, a daemon that
  26647. decodes infrared signals from remote controls.
  26648. Optionally, @var{device}, @var{driver} and @var{config-file}
  26649. (configuration file name) may be specified. See @command{lircd} manual
  26650. for details.
  26651. Finally, @var{extra-options} is a list of additional command-line options
  26652. passed to @command{lircd}.
  26653. @end deffn
  26654. @cindex spice
  26655. @subsubheading Spice Service
  26656. The @code{(gnu services spice)} module provides the following service.
  26657. @deffn {Scheme Procedure} spice-vdagent-service [#:spice-vdagent]
  26658. Returns a service that runs @url{https://www.spice-space.org,VDAGENT}, a daemon
  26659. that enables sharing the clipboard with a vm and setting the guest display
  26660. resolution when the graphical console window resizes.
  26661. @end deffn
  26662. @cindex inputattach
  26663. @subsubheading inputattach Service
  26664. @cindex tablet input, for Xorg
  26665. @cindex touchscreen input, for Xorg
  26666. The @uref{https://linuxwacom.github.io/, inputattach} service allows you to
  26667. use input devices such as Wacom tablets, touchscreens, or joysticks with the
  26668. Xorg display server.
  26669. @deffn {Scheme Variable} inputattach-service-type
  26670. Type of a service that runs @command{inputattach} on a device and
  26671. dispatches events from it.
  26672. @end deffn
  26673. @deftp {Data Type} inputattach-configuration
  26674. @table @asis
  26675. @item @code{device-type} (default: @code{"wacom"})
  26676. The type of device to connect to. Run @command{inputattach --help}, from the
  26677. @code{inputattach} package, to see the list of supported device types.
  26678. @item @code{device} (default: @code{"/dev/ttyS0"})
  26679. The device file to connect to the device.
  26680. @item @code{baud-rate} (default: @code{#f})
  26681. Baud rate to use for the serial connection.
  26682. Should be a number or @code{#f}.
  26683. @item @code{log-file} (default: @code{#f})
  26684. If true, this must be the name of a file to log messages to.
  26685. @end table
  26686. @end deftp
  26687. @subsubheading Dictionary Service
  26688. @cindex dictionary
  26689. The @code{(gnu services dict)} module provides the following service:
  26690. @defvr {Scheme Variable} dicod-service-type
  26691. This is the type of the service that runs the @command{dicod} daemon, an
  26692. implementation of DICT server (@pxref{Dicod,,, dico, GNU Dico Manual}).
  26693. @end defvr
  26694. @deffn {Scheme Procedure} dicod-service [#:config (dicod-configuration)]
  26695. Return a service that runs the @command{dicod} daemon, an implementation
  26696. of DICT server (@pxref{Dicod,,, dico, GNU Dico Manual}).
  26697. The optional @var{config} argument specifies the configuration for
  26698. @command{dicod}, which should be a @code{<dicod-configuration>} object, by
  26699. default it serves the GNU Collaborative International Dictionary of English.
  26700. You can add @command{open localhost} to your @file{~/.dico} file to make
  26701. @code{localhost} the default server for @command{dico} client
  26702. (@pxref{Initialization File,,, dico, GNU Dico Manual}).
  26703. @end deffn
  26704. @deftp {Data Type} dicod-configuration
  26705. Data type representing the configuration of dicod.
  26706. @table @asis
  26707. @item @code{dico} (default: @var{dico})
  26708. Package object of the GNU Dico dictionary server.
  26709. @item @code{interfaces} (default: @var{'("localhost")})
  26710. This is the list of IP addresses and ports and possibly socket file
  26711. names to listen to (@pxref{Server Settings, @code{listen} directive,,
  26712. dico, GNU Dico Manual}).
  26713. @item @code{handlers} (default: @var{'()})
  26714. List of @code{<dicod-handler>} objects denoting handlers (module instances).
  26715. @item @code{databases} (default: @var{(list %dicod-database:gcide)})
  26716. List of @code{<dicod-database>} objects denoting dictionaries to be served.
  26717. @end table
  26718. @end deftp
  26719. @deftp {Data Type} dicod-handler
  26720. Data type representing a dictionary handler (module instance).
  26721. @table @asis
  26722. @item @code{name}
  26723. Name of the handler (module instance).
  26724. @item @code{module} (default: @var{#f})
  26725. Name of the dicod module of the handler (instance). If it is @code{#f},
  26726. the module has the same name as the handler.
  26727. (@pxref{Modules,,, dico, GNU Dico Manual}).
  26728. @item @code{options}
  26729. List of strings or gexps representing the arguments for the module handler
  26730. @end table
  26731. @end deftp
  26732. @deftp {Data Type} dicod-database
  26733. Data type representing a dictionary database.
  26734. @table @asis
  26735. @item @code{name}
  26736. Name of the database, will be used in DICT commands.
  26737. @item @code{handler}
  26738. Name of the dicod handler (module instance) used by this database
  26739. (@pxref{Handlers,,, dico, GNU Dico Manual}).
  26740. @item @code{complex?} (default: @var{#f})
  26741. Whether the database configuration complex. The complex configuration
  26742. will need a corresponding @code{<dicod-handler>} object, otherwise not.
  26743. @item @code{options}
  26744. List of strings or gexps representing the arguments for the database
  26745. (@pxref{Databases,,, dico, GNU Dico Manual}).
  26746. @end table
  26747. @end deftp
  26748. @defvr {Scheme Variable} %dicod-database:gcide
  26749. A @code{<dicod-database>} object serving the GNU Collaborative International
  26750. Dictionary of English using the @code{gcide} package.
  26751. @end defvr
  26752. The following is an example @code{dicod-service} configuration.
  26753. @lisp
  26754. (dicod-service #:config
  26755. (dicod-configuration
  26756. (handlers (list (dicod-handler
  26757. (name "wordnet")
  26758. (module "dictorg")
  26759. (options
  26760. (list #~(string-append "dbdir=" #$wordnet))))))
  26761. (databases (list (dicod-database
  26762. (name "wordnet")
  26763. (complex? #t)
  26764. (handler "wordnet")
  26765. (options '("database=wn")))
  26766. %dicod-database:gcide))))
  26767. @end lisp
  26768. @cindex Docker
  26769. @subsubheading Docker Service
  26770. The @code{(gnu services docker)} module provides the following services.
  26771. @defvr {Scheme Variable} docker-service-type
  26772. This is the type of the service that runs @url{https://www.docker.com,Docker},
  26773. a daemon that can execute application bundles (sometimes referred to as
  26774. ``containers'') in isolated environments.
  26775. @end defvr
  26776. @deftp {Data Type} docker-configuration
  26777. This is the data type representing the configuration of Docker and Containerd.
  26778. @table @asis
  26779. @item @code{docker} (default: @code{docker})
  26780. The Docker daemon package to use.
  26781. @item @code{docker-cli} (default: @code{docker-cli})
  26782. The Docker client package to use.
  26783. @item @code{containerd} (default: @var{containerd})
  26784. The Containerd package to use.
  26785. @item @code{proxy} (default @var{docker-libnetwork-cmd-proxy})
  26786. The Docker user-land networking proxy package to use.
  26787. @item @code{enable-proxy?} (default @code{#t})
  26788. Enable or disable the use of the Docker user-land networking proxy.
  26789. @item @code{debug?} (default @code{#f})
  26790. Enable or disable debug output.
  26791. @item @code{enable-iptables?} (default @code{#t})
  26792. Enable or disable the addition of iptables rules.
  26793. @item @code{environment-variables} (default: @code{()})
  26794. List of environment variables to set for @command{dockerd}.
  26795. This must be a list of strings where each string has the form
  26796. @samp{@var{key}=@var{value}} as in this example:
  26797. @lisp
  26798. (list "LANGUAGE=eo:ca:eu"
  26799. "TMPDIR=/tmp/dockerd")
  26800. @end lisp
  26801. @end table
  26802. @end deftp
  26803. @cindex Singularity, container service
  26804. @defvr {Scheme Variable} singularity-service-type
  26805. This is the type of the service that allows you to run
  26806. @url{https://www.sylabs.io/singularity/, Singularity}, a Docker-style tool to
  26807. create and run application bundles (aka. ``containers''). The value for this
  26808. service is the Singularity package to use.
  26809. The service does not install a daemon; instead, it installs helper programs as
  26810. setuid-root (@pxref{Setuid Programs}) such that unprivileged users can invoke
  26811. @command{singularity run} and similar commands.
  26812. @end defvr
  26813. @cindex Audit
  26814. @subsubheading Auditd Service
  26815. The @code{(gnu services auditd)} module provides the following service.
  26816. @defvr {Scheme Variable} auditd-service-type
  26817. This is the type of the service that runs
  26818. @url{https://people.redhat.com/sgrubb/audit/,auditd},
  26819. a daemon that tracks security-relevant information on your system.
  26820. Examples of things that can be tracked:
  26821. @enumerate
  26822. @item
  26823. File accesses
  26824. @item
  26825. System calls
  26826. @item
  26827. Invoked commands
  26828. @item
  26829. Failed login attempts
  26830. @item
  26831. Firewall filtering
  26832. @item
  26833. Network access
  26834. @end enumerate
  26835. @command{auditctl} from the @code{audit} package can be used in order
  26836. to add or remove events to be tracked (until the next reboot).
  26837. In order to permanently track events, put the command line arguments
  26838. of auditctl into a file called @code{audit.rules} in the configuration
  26839. directory (see below).
  26840. @command{aureport} from the @code{audit} package can be used in order
  26841. to view a report of all recorded events.
  26842. The audit daemon by default logs into the file
  26843. @file{/var/log/audit.log}.
  26844. @end defvr
  26845. @deftp {Data Type} auditd-configuration
  26846. This is the data type representing the configuration of auditd.
  26847. @table @asis
  26848. @item @code{audit} (default: @code{audit})
  26849. The audit package to use.
  26850. @item @code{configuration-directory} (default: @code{%default-auditd-configuration-directory})
  26851. The directory containing the configuration file for the audit package, which
  26852. must be named @code{auditd.conf}, and optionally some audit rules to
  26853. instantiate on startup.
  26854. @end table
  26855. @end deftp
  26856. @cindex rshiny
  26857. @subsubheading R-Shiny service
  26858. The @code{(gnu services science)} module provides the following service.
  26859. @defvr {Scheme Variable} rshiny-service-type
  26860. This is a type of service which is used to run a webapp created with
  26861. @code{r-shiny}. This service sets the @env{R_LIBS_USER} environment
  26862. variable and runs the provided script to call @code{runApp}.
  26863. @deftp {Data Type} rshiny-configuration
  26864. This is the data type representing the configuration of rshiny.
  26865. @table @asis
  26866. @item @code{package} (default: @code{r-shiny})
  26867. The package to use.
  26868. @item @code{binary} (defaunlt @code{"rshiny"})
  26869. The name of the binary or shell script located at @code{package/bin/} to
  26870. run when the service is run.
  26871. The common way to create this file is as follows:
  26872. @lisp
  26873. @dots{}
  26874. (let* ((out (assoc-ref %outputs "out"))
  26875. (targetdir (string-append out "/share/" ,name))
  26876. (app (string-append out "/bin/" ,name))
  26877. (Rbin (search-input-file %build-inputs "/bin/Rscript")))
  26878. ;; @dots{}
  26879. (mkdir-p (string-append out "/bin"))
  26880. (call-with-output-file app
  26881. (lambda (port)
  26882. (format port
  26883. "#!~a
  26884. library(shiny)
  26885. setwd(\"~a\")
  26886. runApp(launch.browser=0, port=4202)~%\n"
  26887. Rbin targetdir))))
  26888. @end lisp
  26889. @end table
  26890. @end deftp
  26891. @end defvr
  26892. @cindex Nix
  26893. @subsubheading Nix service
  26894. The @code{(gnu services nix)} module provides the following service.
  26895. @defvr {Scheme Variable} nix-service-type
  26896. This is the type of the service that runs build daemon of the
  26897. @url{https://nixos.org/nix/, Nix} package manager. Here is an example showing
  26898. how to use it:
  26899. @lisp
  26900. (use-modules (gnu))
  26901. (use-service-modules nix)
  26902. (use-package-modules package-management)
  26903. (operating-system
  26904. ;; @dots{}
  26905. (packages (append (list nix)
  26906. %base-packages))
  26907. (services (append (list (service nix-service-type))
  26908. %base-services)))
  26909. @end lisp
  26910. After @command{guix system reconfigure} configure Nix for your user:
  26911. @itemize
  26912. @item Add a Nix channel and update it. See
  26913. @url{https://nixos.org/nix/manual/, Nix Package Manager Guide}.
  26914. @item Create a symlink to your profile and activate Nix profile:
  26915. @end itemize
  26916. @example
  26917. $ ln -s "/nix/var/nix/profiles/per-user/$USER/profile" ~/.nix-profile
  26918. $ source /run/current-system/profile/etc/profile.d/nix.sh
  26919. @end example
  26920. @end defvr
  26921. @deftp {Data Type} nix-configuration
  26922. This data type represents the configuration of the Nix daemon.
  26923. @table @asis
  26924. @item @code{nix} (default: @code{nix})
  26925. The Nix package to use.
  26926. @item @code{sandbox} (default: @code{#t})
  26927. Specifies whether builds are sandboxed by default.
  26928. @item @code{build-sandbox-items} (default: @code{'()})
  26929. This is a list of strings or objects appended to the
  26930. @code{build-sandbox-items} field of the configuration file.
  26931. @item @code{extra-config} (default: @code{'()})
  26932. This is a list of strings or objects appended to the configuration file.
  26933. It is used to pass extra text to be added verbatim to the configuration
  26934. file.
  26935. @item @code{extra-options} (default: @code{'()})
  26936. Extra command line options for @code{nix-service-type}.
  26937. @end table
  26938. @end deftp
  26939. @node Setuid Programs
  26940. @section Setuid Programs
  26941. @cindex setuid programs
  26942. Some programs need to run with ``root'' privileges, even when they are
  26943. launched by unprivileged users. A notorious example is the
  26944. @command{passwd} program, which users can run to change their
  26945. password, and which needs to access the @file{/etc/passwd} and
  26946. @file{/etc/shadow} files---something normally restricted to root, for
  26947. obvious security reasons. To address that, these executables are
  26948. @dfn{setuid-root}, meaning that they always run with root privileges
  26949. (@pxref{How Change Persona,,, libc, The GNU C Library Reference Manual},
  26950. for more info about the setuid mechanism).
  26951. The store itself @emph{cannot} contain setuid programs: that would be a
  26952. security issue since any user on the system can write derivations that
  26953. populate the store (@pxref{The Store}). Thus, a different mechanism is
  26954. used: instead of changing the setuid bit directly on files that are in
  26955. the store, we let the system administrator @emph{declare} which programs
  26956. should be setuid root.
  26957. The @code{setuid-programs} field of an @code{operating-system}
  26958. declaration contains a list of @code{<setuid-program>} denoting the
  26959. names of programs to have a setuid or setgid bit set (@pxref{Using the
  26960. Configuration System}). For instance, the @command{mount.nfs} program,
  26961. which is part of the nfs-utils package, with a setuid root can be
  26962. designated like this:
  26963. @lisp
  26964. (setuid-program
  26965. (program (file-append nfs-utils "/sbin/mount.nfs")))
  26966. @end lisp
  26967. And then, to make @command{mount.nfs} setuid on your system, add the
  26968. previous example to your operating system declaration by appending it to
  26969. @code{%setuid-programs} like this:
  26970. @lisp
  26971. (operating-system
  26972. ;; Some fields omitted...
  26973. (setuid-programs
  26974. (append (list (setuid-program
  26975. (program (file-append nfs-utils "/sbin/mount.nfs"))))
  26976. %setuid-programs)))
  26977. @end lisp
  26978. @deftp {Data Type} setuid-program
  26979. This data type represents a program with a setuid or setgid bit set.
  26980. @table @asis
  26981. @item @code{program}
  26982. A file-like object having its setuid and/or setgid bit set.
  26983. @item @code{setuid?} (default: @code{#t})
  26984. Whether to set user setuid bit.
  26985. @item @code{setgid?} (default: @code{#f})
  26986. Whether to set group setgid bit.
  26987. @item @code{user} (default: @code{0})
  26988. UID (integer) or user name (string) for the user owner of the program,
  26989. defaults to root.
  26990. @item @code{group} (default: @code{0})
  26991. GID (integer) goup name (string) for the group owner of the program,
  26992. defaults to root.
  26993. @end table
  26994. @end deftp
  26995. A default set of setuid programs is defined by the
  26996. @code{%setuid-programs} variable of the @code{(gnu system)} module.
  26997. @defvr {Scheme Variable} %setuid-programs
  26998. A list of @code{<setuid-program>} denoting common programs that are
  26999. setuid-root.
  27000. The list includes commands such as @command{passwd}, @command{ping},
  27001. @command{su}, and @command{sudo}.
  27002. @end defvr
  27003. Under the hood, the actual setuid programs are created in the
  27004. @file{/run/setuid-programs} directory at system activation time. The
  27005. files in this directory refer to the ``real'' binaries, which are in the
  27006. store.
  27007. @node X.509 Certificates
  27008. @section X.509 Certificates
  27009. @cindex HTTPS, certificates
  27010. @cindex X.509 certificates
  27011. @cindex TLS
  27012. Web servers available over HTTPS (that is, HTTP over the transport-layer
  27013. security mechanism, TLS) send client programs an @dfn{X.509 certificate}
  27014. that the client can then use to @emph{authenticate} the server. To do
  27015. that, clients verify that the server's certificate is signed by a
  27016. so-called @dfn{certificate authority} (CA). But to verify the CA's
  27017. signature, clients must have first acquired the CA's certificate.
  27018. Web browsers such as GNU@tie{}IceCat include their own set of CA
  27019. certificates, such that they are able to verify CA signatures
  27020. out-of-the-box.
  27021. However, most other programs that can talk HTTPS---@command{wget},
  27022. @command{git}, @command{w3m}, etc.---need to be told where CA
  27023. certificates can be found.
  27024. @cindex @code{nss-certs}
  27025. In Guix, this is done by adding a package that provides certificates
  27026. to the @code{packages} field of the @code{operating-system} declaration
  27027. (@pxref{operating-system Reference}). Guix includes one such package,
  27028. @code{nss-certs}, which is a set of CA certificates provided as part of
  27029. Mozilla's Network Security Services.
  27030. Note that it is @emph{not} part of @code{%base-packages}, so you need to
  27031. explicitly add it. The @file{/etc/ssl/certs} directory, which is where
  27032. most applications and libraries look for certificates by default, points
  27033. to the certificates installed globally.
  27034. Unprivileged users, including users of Guix on a foreign distro,
  27035. can also install their own certificate package in
  27036. their profile. A number of environment variables need to be defined so
  27037. that applications and libraries know where to find them. Namely, the
  27038. OpenSSL library honors the @env{SSL_CERT_DIR} and @env{SSL_CERT_FILE}
  27039. variables. Some applications add their own environment variables; for
  27040. instance, the Git version control system honors the certificate bundle
  27041. pointed to by the @env{GIT_SSL_CAINFO} environment variable. Thus, you
  27042. would typically run something like:
  27043. @example
  27044. guix install nss-certs
  27045. export SSL_CERT_DIR="$HOME/.guix-profile/etc/ssl/certs"
  27046. export SSL_CERT_FILE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt"
  27047. export GIT_SSL_CAINFO="$SSL_CERT_FILE"
  27048. @end example
  27049. As another example, R requires the @env{CURL_CA_BUNDLE} environment
  27050. variable to point to a certificate bundle, so you would have to run
  27051. something like this:
  27052. @example
  27053. guix install nss-certs
  27054. export CURL_CA_BUNDLE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt"
  27055. @end example
  27056. For other applications you may want to look up the required environment
  27057. variable in the relevant documentation.
  27058. @node Name Service Switch
  27059. @section Name Service Switch
  27060. @cindex name service switch
  27061. @cindex NSS
  27062. The @code{(gnu system nss)} module provides bindings to the
  27063. configuration file of the libc @dfn{name service switch} or @dfn{NSS}
  27064. (@pxref{NSS Configuration File,,, libc, The GNU C Library Reference
  27065. Manual}). In a nutshell, the NSS is a mechanism that allows libc to be
  27066. extended with new ``name'' lookup methods for system databases, which
  27067. includes host names, service names, user accounts, and more (@pxref{Name
  27068. Service Switch, System Databases and Name Service Switch,, libc, The GNU
  27069. C Library Reference Manual}).
  27070. The NSS configuration specifies, for each system database, which lookup
  27071. method is to be used, and how the various methods are chained
  27072. together---for instance, under which circumstances NSS should try the
  27073. next method in the list. The NSS configuration is given in the
  27074. @code{name-service-switch} field of @code{operating-system} declarations
  27075. (@pxref{operating-system Reference, @code{name-service-switch}}).
  27076. @cindex nss-mdns
  27077. @cindex .local, host name lookup
  27078. As an example, the declaration below configures the NSS to use the
  27079. @uref{https://0pointer.de/lennart/projects/nss-mdns/, @code{nss-mdns}
  27080. back-end}, which supports host name lookups over multicast DNS (mDNS)
  27081. for host names ending in @code{.local}:
  27082. @lisp
  27083. (name-service-switch
  27084. (hosts (list %files ;first, check /etc/hosts
  27085. ;; If the above did not succeed, try
  27086. ;; with 'mdns_minimal'.
  27087. (name-service
  27088. (name "mdns_minimal")
  27089. ;; 'mdns_minimal' is authoritative for
  27090. ;; '.local'. When it returns "not found",
  27091. ;; no need to try the next methods.
  27092. (reaction (lookup-specification
  27093. (not-found => return))))
  27094. ;; Then fall back to DNS.
  27095. (name-service
  27096. (name "dns"))
  27097. ;; Finally, try with the "full" 'mdns'.
  27098. (name-service
  27099. (name "mdns")))))
  27100. @end lisp
  27101. Do not worry: the @code{%mdns-host-lookup-nss} variable (see below)
  27102. contains this configuration, so you will not have to type it if all you
  27103. want is to have @code{.local} host lookup working.
  27104. Note that, in this case, in addition to setting the
  27105. @code{name-service-switch} of the @code{operating-system} declaration,
  27106. you also need to use @code{avahi-service-type} (@pxref{Networking Services,
  27107. @code{avahi-service-type}}), or @code{%desktop-services}, which includes it
  27108. (@pxref{Desktop Services}). Doing this makes @code{nss-mdns} accessible
  27109. to the name service cache daemon (@pxref{Base Services,
  27110. @code{nscd-service}}).
  27111. For convenience, the following variables provide typical NSS
  27112. configurations.
  27113. @defvr {Scheme Variable} %default-nss
  27114. This is the default name service switch configuration, a
  27115. @code{name-service-switch} object.
  27116. @end defvr
  27117. @defvr {Scheme Variable} %mdns-host-lookup-nss
  27118. This is the name service switch configuration with support for host name
  27119. lookup over multicast DNS (mDNS) for host names ending in @code{.local}.
  27120. @end defvr
  27121. The reference for name service switch configuration is given below. It
  27122. is a direct mapping of the configuration file format of the C library , so
  27123. please refer to the C library manual for more information (@pxref{NSS
  27124. Configuration File,,, libc, The GNU C Library Reference Manual}).
  27125. Compared to the configuration file format of libc NSS, it has the advantage
  27126. not only of adding this warm parenthetic feel that we like, but also
  27127. static checks: you will know about syntax errors and typos as soon as you
  27128. run @command{guix system}.
  27129. @deftp {Data Type} name-service-switch
  27130. This is the data type representation the configuration of libc's name
  27131. service switch (NSS). Each field below represents one of the supported
  27132. system databases.
  27133. @table @code
  27134. @item aliases
  27135. @itemx ethers
  27136. @itemx group
  27137. @itemx gshadow
  27138. @itemx hosts
  27139. @itemx initgroups
  27140. @itemx netgroup
  27141. @itemx networks
  27142. @itemx password
  27143. @itemx public-key
  27144. @itemx rpc
  27145. @itemx services
  27146. @itemx shadow
  27147. The system databases handled by the NSS@. Each of these fields must be a
  27148. list of @code{<name-service>} objects (see below).
  27149. @end table
  27150. @end deftp
  27151. @deftp {Data Type} name-service
  27152. This is the data type representing an actual name service and the
  27153. associated lookup action.
  27154. @table @code
  27155. @item name
  27156. A string denoting the name service (@pxref{Services in the NSS
  27157. configuration,,, libc, The GNU C Library Reference Manual}).
  27158. Note that name services listed here must be visible to nscd. This is
  27159. achieved by passing the @code{#:name-services} argument to
  27160. @code{nscd-service} the list of packages providing the needed name
  27161. services (@pxref{Base Services, @code{nscd-service}}).
  27162. @item reaction
  27163. An action specified using the @code{lookup-specification} macro
  27164. (@pxref{Actions in the NSS configuration,,, libc, The GNU C Library
  27165. Reference Manual}). For example:
  27166. @lisp
  27167. (lookup-specification (unavailable => continue)
  27168. (success => return))
  27169. @end lisp
  27170. @end table
  27171. @end deftp
  27172. @node Initial RAM Disk
  27173. @section Initial RAM Disk
  27174. @cindex initrd
  27175. @cindex initial RAM disk
  27176. For bootstrapping purposes, the Linux-Libre kernel is passed an
  27177. @dfn{initial RAM disk}, or @dfn{initrd}. An initrd contains a temporary
  27178. root file system as well as an initialization script. The latter is
  27179. responsible for mounting the real root file system, and for loading any
  27180. kernel modules that may be needed to achieve that.
  27181. The @code{initrd-modules} field of an @code{operating-system}
  27182. declaration allows you to specify Linux-libre kernel modules that must
  27183. be available in the initrd. In particular, this is where you would list
  27184. modules needed to actually drive the hard disk where your root partition
  27185. is---although the default value of @code{initrd-modules} should cover
  27186. most use cases. For example, assuming you need the @code{megaraid_sas}
  27187. module in addition to the default modules to be able to access your root
  27188. file system, you would write:
  27189. @lisp
  27190. (operating-system
  27191. ;; @dots{}
  27192. (initrd-modules (cons "megaraid_sas" %base-initrd-modules)))
  27193. @end lisp
  27194. @defvr {Scheme Variable} %base-initrd-modules
  27195. This is the list of kernel modules included in the initrd by default.
  27196. @end defvr
  27197. Furthermore, if you need lower-level customization, the @code{initrd}
  27198. field of an @code{operating-system} declaration allows
  27199. you to specify which initrd you would like to use. The @code{(gnu
  27200. system linux-initrd)} module provides three ways to build an initrd: the
  27201. high-level @code{base-initrd} procedure and the low-level
  27202. @code{raw-initrd} and @code{expression->initrd} procedures.
  27203. The @code{base-initrd} procedure is intended to cover most common uses.
  27204. For example, if you want to add a bunch of kernel modules to be loaded
  27205. at boot time, you can define the @code{initrd} field of the operating
  27206. system declaration like this:
  27207. @lisp
  27208. (initrd (lambda (file-systems . rest)
  27209. ;; Create a standard initrd but set up networking
  27210. ;; with the parameters QEMU expects by default.
  27211. (apply base-initrd file-systems
  27212. #:qemu-networking? #t
  27213. rest)))
  27214. @end lisp
  27215. The @code{base-initrd} procedure also handles common use cases that
  27216. involves using the system as a QEMU guest, or as a ``live'' system with
  27217. volatile root file system.
  27218. The @code{base-initrd} procedure is built from @code{raw-initrd} procedure.
  27219. Unlike @code{base-initrd}, @code{raw-initrd} doesn't do anything high-level,
  27220. such as trying to guess which kernel modules and packages should be included
  27221. to the initrd. An example use of @code{raw-initrd} is when a user has
  27222. a custom Linux kernel configuration and default kernel modules included by
  27223. @code{base-initrd} are not available.
  27224. The initial RAM disk produced by @code{base-initrd} or @code{raw-initrd}
  27225. honors several options passed on the Linux kernel command line
  27226. (that is, arguments passed @i{via} the @code{linux} command of GRUB, or the
  27227. @code{-append} option of QEMU), notably:
  27228. @table @code
  27229. @item gnu.load=@var{boot}
  27230. Tell the initial RAM disk to load @var{boot}, a file containing a Scheme
  27231. program, once it has mounted the root file system.
  27232. Guix uses this option to yield control to a boot program that runs the
  27233. service activation programs and then spawns the GNU@tie{}Shepherd, the
  27234. initialization system.
  27235. @item root=@var{root}
  27236. Mount @var{root} as the root file system. @var{root} can be a device
  27237. name like @code{/dev/sda1}, a file system label, or a file system UUID.
  27238. When unspecified, the device name from the root file system of the
  27239. operating system declaration is used.
  27240. @item rootfstype=@var{type}
  27241. Set the type of the root file system. It overrides the @code{type}
  27242. field of the root file system specified via the @code{operating-system}
  27243. declaration, if any.
  27244. @item rootflags=@var{options}
  27245. Set the mount @emph{options} of the root file system. It overrides the
  27246. @code{options} field of the root file system specified via the
  27247. @code{operating-system} declaration, if any.
  27248. @item fsck.mode=@var{mode}
  27249. Whether to check the @var{root} file system for errors before mounting
  27250. it. @var{mode} is one of @code{skip} (never check), @code{force} (always
  27251. check), or @code{auto} to respect the root file-system object's 'check?'
  27252. setting (@pxref{File Systems}) and run a full scan only if the file system
  27253. was not cleanly shut down.
  27254. @code{auto} is the default if this option is not present or if @var{mode}
  27255. is not one of the above.
  27256. @item fsck.repair=@var{level}
  27257. The level of repairs to perform automatically if errors are found in the
  27258. @var{root} file system. @var{level} is one of @code{no} (do not write to
  27259. @var{root} at all if possible), @code{yes} (repair as much as possible),
  27260. or @code{preen} to repair problems considered safe to repair automatically.
  27261. @code{preen} is the default if this option is not present or if @var{level}
  27262. is not one of the above.
  27263. @item gnu.system=@var{system}
  27264. Have @file{/run/booted-system} and @file{/run/current-system} point to
  27265. @var{system}.
  27266. @item modprobe.blacklist=@var{modules}@dots{}
  27267. @cindex module, black-listing
  27268. @cindex black list, of kernel modules
  27269. Instruct the initial RAM disk as well as the @command{modprobe} command
  27270. (from the kmod package) to refuse to load @var{modules}. @var{modules}
  27271. must be a comma-separated list of module names---e.g.,
  27272. @code{usbkbd,9pnet}.
  27273. @item gnu.repl
  27274. Start a read-eval-print loop (REPL) from the initial RAM disk before it
  27275. tries to load kernel modules and to mount the root file system. Our
  27276. marketing team calls it @dfn{boot-to-Guile}. The Schemer in you will
  27277. love it. @xref{Using Guile Interactively,,, guile, GNU Guile Reference
  27278. Manual}, for more information on Guile's REPL.
  27279. @end table
  27280. Now that you know all the features that initial RAM disks produced by
  27281. @code{base-initrd} and @code{raw-initrd} provide,
  27282. here is how to use it and customize it further.
  27283. @cindex initrd
  27284. @cindex initial RAM disk
  27285. @deffn {Scheme Procedure} raw-initrd @var{file-systems} @
  27286. [#:linux-modules '()] [#:mapped-devices '()] @
  27287. [#:keyboard-layout #f] @
  27288. [#:helper-packages '()] [#:qemu-networking? #f] [#:volatile-root? #f]
  27289. Return a derivation that builds a raw initrd. @var{file-systems} is
  27290. a list of file systems to be mounted by the initrd, possibly in addition to
  27291. the root file system specified on the kernel command line via @option{root}.
  27292. @var{linux-modules} is a list of kernel modules to be loaded at boot time.
  27293. @var{mapped-devices} is a list of device mappings to realize before
  27294. @var{file-systems} are mounted (@pxref{Mapped Devices}).
  27295. @var{helper-packages} is a list of packages to be copied in the initrd.
  27296. It may
  27297. include @code{e2fsck/static} or other packages needed by the initrd to check
  27298. the root file system.
  27299. When true, @var{keyboard-layout} is a @code{<keyboard-layout>} record denoting
  27300. the desired console keyboard layout. This is done before @var{mapped-devices}
  27301. are set up and before @var{file-systems} are mounted such that, should the
  27302. user need to enter a passphrase or use the REPL, this happens using the
  27303. intended keyboard layout.
  27304. When @var{qemu-networking?} is true, set up networking with the standard QEMU
  27305. parameters. When @var{virtio?} is true, load additional modules so that the
  27306. initrd can be used as a QEMU guest with para-virtualized I/O drivers.
  27307. When @var{volatile-root?} is true, the root file system is writable but any changes
  27308. to it are lost.
  27309. @end deffn
  27310. @deffn {Scheme Procedure} base-initrd @var{file-systems} @
  27311. [#:mapped-devices '()] [#:keyboard-layout #f] @
  27312. [#:qemu-networking? #f] [#:volatile-root? #f] @
  27313. [#:linux-modules '()]
  27314. Return as a file-like object a generic initrd, with kernel
  27315. modules taken from @var{linux}. @var{file-systems} is a list of file-systems to be
  27316. mounted by the initrd, possibly in addition to the root file system specified
  27317. on the kernel command line via @option{root}. @var{mapped-devices} is a list of device
  27318. mappings to realize before @var{file-systems} are mounted.
  27319. When true, @var{keyboard-layout} is a @code{<keyboard-layout>} record denoting
  27320. the desired console keyboard layout. This is done before @var{mapped-devices}
  27321. are set up and before @var{file-systems} are mounted such that, should the
  27322. user need to enter a passphrase or use the REPL, this happens using the
  27323. intended keyboard layout.
  27324. @var{qemu-networking?} and @var{volatile-root?} behaves as in @code{raw-initrd}.
  27325. The initrd is automatically populated with all the kernel modules necessary
  27326. for @var{file-systems} and for the given options. Additional kernel
  27327. modules can be listed in @var{linux-modules}. They will be added to the initrd, and
  27328. loaded at boot time in the order in which they appear.
  27329. @end deffn
  27330. Needless to say, the initrds we produce and use embed a
  27331. statically-linked Guile, and the initialization program is a Guile
  27332. program. That gives a lot of flexibility. The
  27333. @code{expression->initrd} procedure builds such an initrd, given the
  27334. program to run in that initrd.
  27335. @deffn {Scheme Procedure} expression->initrd @var{exp} @
  27336. [#:guile %guile-static-stripped] [#:name "guile-initrd"]
  27337. Return as a file-like object a Linux initrd (a gzipped cpio archive)
  27338. containing @var{guile} and that evaluates @var{exp}, a G-expression,
  27339. upon booting. All the derivations referenced by @var{exp} are
  27340. automatically copied to the initrd.
  27341. @end deffn
  27342. @node Bootloader Configuration
  27343. @section Bootloader Configuration
  27344. @cindex bootloader
  27345. @cindex boot loader
  27346. The operating system supports multiple bootloaders. The bootloader is
  27347. configured using @code{bootloader-configuration} declaration. All the
  27348. fields of this structure are bootloader agnostic except for one field,
  27349. @code{bootloader} that indicates the bootloader to be configured and
  27350. installed.
  27351. Some of the bootloaders do not honor every field of
  27352. @code{bootloader-configuration}. For instance, the extlinux
  27353. bootloader does not support themes and thus ignores the @code{theme}
  27354. field.
  27355. @deftp {Data Type} bootloader-configuration
  27356. The type of a bootloader configuration declaration.
  27357. @table @asis
  27358. @item @code{bootloader}
  27359. @cindex EFI, bootloader
  27360. @cindex UEFI, bootloader
  27361. @cindex BIOS, bootloader
  27362. The bootloader to use, as a @code{bootloader} object. For now
  27363. @code{grub-bootloader}, @code{grub-efi-bootloader},
  27364. @code{grub-efi-netboot-bootloader}, @code{extlinux-bootloader} and
  27365. @code{u-boot-bootloader} are supported.
  27366. @cindex ARM, bootloaders
  27367. @cindex AArch64, bootloaders
  27368. Available bootloaders are described in @code{(gnu bootloader @dots{})}
  27369. modules. In particular, @code{(gnu bootloader u-boot)} contains definitions
  27370. of bootloaders for a wide range of ARM and AArch64 systems, using the
  27371. @uref{https://www.denx.de/wiki/U-Boot/, U-Boot bootloader}.
  27372. @vindex grub-efi-bootloader
  27373. @code{grub-efi-bootloader} allows to boot on modern systems using the
  27374. @dfn{Unified Extensible Firmware Interface} (UEFI). This is what you should
  27375. use if the installation image contains a @file{/sys/firmware/efi} directory
  27376. when you boot it on your system.
  27377. @vindex grub-bootloader
  27378. @code{grub-bootloader} allows you to boot in particular Intel-based machines
  27379. in ``legacy'' BIOS mode.
  27380. @vindex grub-efi-netboot-bootloader
  27381. @code{grub-efi-netboot-bootloader} allows you to boot your system over network
  27382. through TFTP@. In combination with an NFS root file system this allows you to
  27383. build a diskless Guix system.
  27384. The installation of the @code{grub-efi-netboot-bootloader} generates the
  27385. content of the TFTP root directory at @code{targets} (@pxref{Bootloader
  27386. Configuration, @code{targets}}), to be served by a TFTP server. You may
  27387. want to mount your TFTP server directories onto the @code{targets} to
  27388. move the required files to the TFTP server automatically.
  27389. If you plan to use an NFS root file system as well (actually if you mount the
  27390. store from an NFS share), then the TFTP server needs to serve the file
  27391. @file{/boot/grub/grub.cfg} and other files from the store (like GRUBs background
  27392. image, the kernel (@pxref{operating-system Reference, @code{kernel}}) and the
  27393. initrd (@pxref{operating-system Reference, @code{initrd}})), too. All these
  27394. files from the store will be accessed by GRUB through TFTP with their normal
  27395. store path, for example as
  27396. @file{tftp://tftp-server/gnu/store/…-initrd/initrd.cpio.gz}.
  27397. Two symlinks are created to make this possible. For each target in the
  27398. @code{targets} field, the first symlink is
  27399. @samp{target}@file{/efi/Guix/boot/grub/grub.cfg} pointing to
  27400. @file{../../../boot/grub/grub.cfg}, where @samp{target} may be
  27401. @file{/boot}. In this case the link is not leaving the served TFTP root
  27402. directory, but otherwise it does. The second link is
  27403. @samp{target}@file{/gnu/store} and points to @file{../gnu/store}. This
  27404. link is leaving the served TFTP root directory.
  27405. The assumption behind all this is that you have an NFS server exporting
  27406. the root file system for your Guix system, and additionally a TFTP
  27407. server exporting your @code{targets} directories—usually a single
  27408. @file{/boot}—from that same root file system for your Guix system. In
  27409. this constellation the symlinks will work.
  27410. For other constellations you will have to program your own bootloader
  27411. installer, which then takes care to make necessary files from the store
  27412. accessible through TFTP, for example by copying them into the TFTP root
  27413. directory to your @code{targets}.
  27414. It is important to note that symlinks pointing outside the TFTP root directory
  27415. may need to be allowed in the configuration of your TFTP server. Further the
  27416. store link exposes the whole store through TFTP@. Both points need to be
  27417. considered carefully for security aspects.
  27418. Beside the @code{grub-efi-netboot-bootloader}, the already mentioned TFTP and
  27419. NFS servers, you also need a properly configured DHCP server to make the booting
  27420. over netboot possible. For all this we can currently only recommend you to look
  27421. for instructions about @acronym{PXE, Preboot eXecution Environment}.
  27422. @item @code{targets}
  27423. This is a list of strings denoting the targets onto which to install the
  27424. bootloader.
  27425. The interpretation of targets depends on the bootloader in question.
  27426. For @code{grub-bootloader}, for example, they should be device names
  27427. understood by the bootloader @command{installer} command, such as
  27428. @code{/dev/sda} or @code{(hd0)} (@pxref{Invoking grub-install,,, grub,
  27429. GNU GRUB Manual}). For @code{grub-efi-bootloader}, they should be mount
  27430. points of the EFI file system, usually @file{/boot/efi}. For
  27431. @code{grub-efi-netboot-bootloader}, @code{targets} should be the mount
  27432. points corresponding to TFTP root directories served by your TFTP
  27433. server.
  27434. @item @code{menu-entries} (default: @code{()})
  27435. A possibly empty list of @code{menu-entry} objects (see below), denoting
  27436. entries to appear in the bootloader menu, in addition to the current
  27437. system entry and the entry pointing to previous system generations.
  27438. @item @code{default-entry} (default: @code{0})
  27439. The index of the default boot menu entry. Index 0 is for the entry of the
  27440. current system.
  27441. @item @code{timeout} (default: @code{5})
  27442. The number of seconds to wait for keyboard input before booting. Set to
  27443. 0 to boot immediately, and to -1 to wait indefinitely.
  27444. @cindex keyboard layout, for the bootloader
  27445. @item @code{keyboard-layout} (default: @code{#f})
  27446. If this is @code{#f}, the bootloader's menu (if any) uses the default keyboard
  27447. layout, usually US@tie{}English (``qwerty'').
  27448. Otherwise, this must be a @code{keyboard-layout} object (@pxref{Keyboard
  27449. Layout}).
  27450. @quotation Note
  27451. This option is currently ignored by bootloaders other than @code{grub} and
  27452. @code{grub-efi}.
  27453. @end quotation
  27454. @item @code{theme} (default: @var{#f})
  27455. The bootloader theme object describing the theme to use. If no theme
  27456. is provided, some bootloaders might use a default theme, that's true
  27457. for GRUB.
  27458. @item @code{terminal-outputs} (default: @code{'(gfxterm)})
  27459. The output terminals used for the bootloader boot menu, as a list of
  27460. symbols. GRUB accepts the values: @code{console}, @code{serial},
  27461. @code{serial_@{0-3@}}, @code{gfxterm}, @code{vga_text},
  27462. @code{mda_text}, @code{morse}, and @code{pkmodem}. This field
  27463. corresponds to the GRUB variable @code{GRUB_TERMINAL_OUTPUT} (@pxref{Simple
  27464. configuration,,, grub,GNU GRUB manual}).
  27465. @item @code{terminal-inputs} (default: @code{'()})
  27466. The input terminals used for the bootloader boot menu, as a list of
  27467. symbols. For GRUB, the default is the native platform terminal as
  27468. determined at run-time. GRUB accepts the values: @code{console},
  27469. @code{serial}, @code{serial_@{0-3@}}, @code{at_keyboard}, and
  27470. @code{usb_keyboard}. This field corresponds to the GRUB variable
  27471. @code{GRUB_TERMINAL_INPUT} (@pxref{Simple configuration,,, grub,GNU GRUB
  27472. manual}).
  27473. @item @code{serial-unit} (default: @code{#f})
  27474. The serial unit used by the bootloader, as an integer from 0 to 3.
  27475. For GRUB, it is chosen at run-time; currently GRUB chooses 0, which
  27476. corresponds to COM1 (@pxref{Serial terminal,,, grub,GNU GRUB manual}).
  27477. @item @code{serial-speed} (default: @code{#f})
  27478. The speed of the serial interface, as an integer. For GRUB, the
  27479. default value is chosen at run-time; currently GRUB chooses
  27480. 9600@tie{}bps (@pxref{Serial terminal,,, grub,GNU GRUB manual}).
  27481. @end table
  27482. @end deftp
  27483. @cindex dual boot
  27484. @cindex boot menu
  27485. Should you want to list additional boot menu entries @i{via} the
  27486. @code{menu-entries} field above, you will need to create them with the
  27487. @code{menu-entry} form. For example, imagine you want to be able to
  27488. boot another distro (hard to imagine!), you can define a menu entry
  27489. along these lines:
  27490. @lisp
  27491. (menu-entry
  27492. (label "The Other Distro")
  27493. (linux "/boot/old/vmlinux-2.6.32")
  27494. (linux-arguments '("root=/dev/sda2"))
  27495. (initrd "/boot/old/initrd"))
  27496. @end lisp
  27497. Details below.
  27498. @deftp {Data Type} menu-entry
  27499. The type of an entry in the bootloader menu.
  27500. @table @asis
  27501. @item @code{label}
  27502. The label to show in the menu---e.g., @code{"GNU"}.
  27503. @item @code{linux} (default: @code{#f})
  27504. The Linux kernel image to boot, for example:
  27505. @lisp
  27506. (file-append linux-libre "/bzImage")
  27507. @end lisp
  27508. For GRUB, it is also possible to specify a device explicitly in the
  27509. file path using GRUB's device naming convention (@pxref{Naming
  27510. convention,,, grub, GNU GRUB manual}), for example:
  27511. @example
  27512. "(hd0,msdos1)/boot/vmlinuz"
  27513. @end example
  27514. If the device is specified explicitly as above, then the @code{device}
  27515. field is ignored entirely.
  27516. @item @code{linux-arguments} (default: @code{()})
  27517. The list of extra Linux kernel command-line arguments---e.g.,
  27518. @code{("console=ttyS0")}.
  27519. @item @code{initrd} (default: @code{#f})
  27520. A G-Expression or string denoting the file name of the initial RAM disk
  27521. to use (@pxref{G-Expressions}).
  27522. @item @code{device} (default: @code{#f})
  27523. The device where the kernel and initrd are to be found---i.e., for GRUB,
  27524. @dfn{root} for this menu entry (@pxref{root,,, grub, GNU GRUB manual}).
  27525. This may be a file system label (a string), a file system UUID (a
  27526. bytevector, @pxref{File Systems}), or @code{#f}, in which case
  27527. the bootloader will search the device containing the file specified by
  27528. the @code{linux} field (@pxref{search,,, grub, GNU GRUB manual}). It
  27529. must @emph{not} be an OS device name such as @file{/dev/sda1}.
  27530. @item @code{multiboot-kernel} (default: @code{#f})
  27531. The kernel to boot in Multiboot-mode (@pxref{multiboot,,, grub, GNU GRUB
  27532. manual}). When this field is set, a Multiboot menu-entry is generated.
  27533. For example:
  27534. @lisp
  27535. (file-append mach "/boot/gnumach")
  27536. @end lisp
  27537. @item @code{multiboot-arguments} (default: @code{()})
  27538. The list of extra command-line arguments for the multiboot-kernel.
  27539. @item @code{multiboot-modules} (default: @code{()})
  27540. The list of commands for loading Multiboot modules. For example:
  27541. @lisp
  27542. (list (list (file-append hurd "/hurd/ext2fs.static") "ext2fs"
  27543. @dots{})
  27544. (list (file-append libc "/lib/ld.so.1") "exec"
  27545. @dots{}))
  27546. @end lisp
  27547. @end table
  27548. @end deftp
  27549. @cindex HDPI
  27550. @cindex HiDPI
  27551. @cindex resolution
  27552. @c FIXME: Write documentation once it's stable.
  27553. For now only GRUB has theme support. GRUB themes are created using
  27554. the @code{grub-theme} form, which is not fully documented yet.
  27555. @deftp {Data Type} grub-theme
  27556. Data type representing the configuration of the GRUB theme.
  27557. @table @asis
  27558. @item @code{gfxmode} (default: @code{'("auto")})
  27559. The GRUB @code{gfxmode} to set (a list of screen resolution strings,
  27560. @pxref{gfxmode,,, grub, GNU GRUB manual}).
  27561. @end table
  27562. @end deftp
  27563. @deffn {Scheme Procedure} grub-theme
  27564. Return the default GRUB theme used by the operating system if no
  27565. @code{theme} field is specified in @code{bootloader-configuration}
  27566. record.
  27567. It comes with a fancy background image displaying the GNU and Guix
  27568. logos.
  27569. @end deffn
  27570. For example, to override the default resolution, you may use something
  27571. like
  27572. @lisp
  27573. (bootloader
  27574. (bootloader-configuration
  27575. ;; @dots{}
  27576. (theme (grub-theme
  27577. (inherit (grub-theme))
  27578. (gfxmode '("1024x786x32" "auto"))))))
  27579. @end lisp
  27580. @node Invoking guix system
  27581. @section Invoking @code{guix system}
  27582. Once you have written an operating system declaration as seen in the
  27583. previous section, it can be @dfn{instantiated} using the @command{guix
  27584. system} command. The synopsis is:
  27585. @example
  27586. guix system @var{options}@dots{} @var{action} @var{file}
  27587. @end example
  27588. @var{file} must be the name of a file containing an
  27589. @code{operating-system} declaration. @var{action} specifies how the
  27590. operating system is instantiated. Currently the following values are
  27591. supported:
  27592. @table @code
  27593. @item search
  27594. Display available service type definitions that match the given regular
  27595. expressions, sorted by relevance:
  27596. @cindex HDPI
  27597. @cindex HiDPI
  27598. @cindex resolution
  27599. @example
  27600. $ guix system search console
  27601. name: console-fonts
  27602. location: gnu/services/base.scm:806:2
  27603. extends: shepherd-root
  27604. description: Install the given fonts on the specified ttys (fonts are per
  27605. + virtual console on GNU/Linux). The value of this service is a list of
  27606. + tty/font pairs. The font can be the name of a font provided by the `kbd'
  27607. + package or any valid argument to `setfont', as in this example:
  27608. +
  27609. + '(("tty1" . "LatGrkCyr-8x16")
  27610. + ("tty2" . (file-append
  27611. + font-tamzen
  27612. + "/share/kbd/consolefonts/TamzenForPowerline10x20.psf"))
  27613. + ("tty3" . (file-append
  27614. + font-terminus
  27615. + "/share/consolefonts/ter-132n"))) ; for HDPI
  27616. relevance: 9
  27617. name: mingetty
  27618. location: gnu/services/base.scm:1190:2
  27619. extends: shepherd-root
  27620. description: Provide console login using the `mingetty' program.
  27621. relevance: 2
  27622. name: login
  27623. location: gnu/services/base.scm:860:2
  27624. extends: pam
  27625. description: Provide a console log-in service as specified by its
  27626. + configuration value, a `login-configuration' object.
  27627. relevance: 2
  27628. @dots{}
  27629. @end example
  27630. As for @command{guix package --search}, the result is written in
  27631. @code{recutils} format, which makes it easy to filter the output
  27632. (@pxref{Top, GNU recutils databases,, recutils, GNU recutils manual}).
  27633. @item reconfigure
  27634. Build the operating system described in @var{file}, activate it, and
  27635. switch to it@footnote{This action (and the related actions
  27636. @code{switch-generation} and @code{roll-back}) are usable only on
  27637. systems already running Guix System.}.
  27638. @quotation Note
  27639. @c The paragraph below refers to the problem discussed at
  27640. @c <https://lists.gnu.org/archive/html/guix-devel/2014-08/msg00057.html>.
  27641. It is highly recommended to run @command{guix pull} once before you run
  27642. @command{guix system reconfigure} for the first time (@pxref{Invoking
  27643. guix pull}). Failing to do that you would see an older version of Guix
  27644. once @command{reconfigure} has completed.
  27645. @end quotation
  27646. This effects all the configuration specified in @var{file}: user
  27647. accounts, system services, global package list, setuid programs, etc.
  27648. The command starts system services specified in @var{file} that are not
  27649. currently running; if a service is currently running this command will
  27650. arrange for it to be upgraded the next time it is stopped (e.g.@: by
  27651. @code{herd stop X} or @code{herd restart X}).
  27652. This command creates a new generation whose number is one greater than
  27653. the current generation (as reported by @command{guix system
  27654. list-generations}). If that generation already exists, it will be
  27655. overwritten. This behavior mirrors that of @command{guix package}
  27656. (@pxref{Invoking guix package}).
  27657. It also adds a bootloader menu entry for the new OS configuration,
  27658. ---unless @option{--no-bootloader} is passed. For GRUB, it moves
  27659. entries for older configurations to a submenu, allowing you to choose
  27660. an older system generation at boot time should you need it.
  27661. @cindex provenance tracking, of the operating system
  27662. Upon completion, the new system is deployed under
  27663. @file{/run/current-system}. This directory contains @dfn{provenance
  27664. meta-data}: the list of channels in use (@pxref{Channels}) and
  27665. @var{file} itself, when available. You can view it by running:
  27666. @example
  27667. guix system describe
  27668. @end example
  27669. This information is useful should you later want to inspect how this
  27670. particular generation was built. In fact, assuming @var{file} is
  27671. self-contained, you can later rebuild generation @var{n} of your
  27672. operating system with:
  27673. @example
  27674. guix time-machine \
  27675. -C /var/guix/profiles/system-@var{n}-link/channels.scm -- \
  27676. system reconfigure \
  27677. /var/guix/profiles/system-@var{n}-link/configuration.scm
  27678. @end example
  27679. You can think of it as some sort of built-in version control! Your
  27680. system is not just a binary artifact: @emph{it carries its own source}.
  27681. @xref{Service Reference, @code{provenance-service-type}}, for more
  27682. information on provenance tracking.
  27683. By default, @command{reconfigure} @emph{prevents you from downgrading
  27684. your system}, which could (re)introduce security vulnerabilities and
  27685. also cause problems with ``stateful'' services such as database
  27686. management systems. You can override that behavior by passing
  27687. @option{--allow-downgrades}.
  27688. @item switch-generation
  27689. @cindex generations
  27690. Switch to an existing system generation. This action atomically
  27691. switches the system profile to the specified system generation. It
  27692. also rearranges the system's existing bootloader menu entries. It
  27693. makes the menu entry for the specified system generation the default,
  27694. and it moves the entries for the other generations to a submenu, if
  27695. supported by the bootloader being used. The next time the system
  27696. boots, it will use the specified system generation.
  27697. The bootloader itself is not being reinstalled when using this
  27698. command. Thus, the installed bootloader is used with an updated
  27699. configuration file.
  27700. The target generation can be specified explicitly by its generation
  27701. number. For example, the following invocation would switch to system
  27702. generation 7:
  27703. @example
  27704. guix system switch-generation 7
  27705. @end example
  27706. The target generation can also be specified relative to the current
  27707. generation with the form @code{+N} or @code{-N}, where @code{+3} means
  27708. ``3 generations ahead of the current generation,'' and @code{-1} means
  27709. ``1 generation prior to the current generation.'' When specifying a
  27710. negative value such as @code{-1}, you must precede it with @code{--} to
  27711. prevent it from being parsed as an option. For example:
  27712. @example
  27713. guix system switch-generation -- -1
  27714. @end example
  27715. Currently, the effect of invoking this action is @emph{only} to switch
  27716. the system profile to an existing generation and rearrange the
  27717. bootloader menu entries. To actually start using the target system
  27718. generation, you must reboot after running this action. In the future,
  27719. it will be updated to do the same things as @command{reconfigure},
  27720. like activating and deactivating services.
  27721. This action will fail if the specified generation does not exist.
  27722. @item roll-back
  27723. @cindex rolling back
  27724. Switch to the preceding system generation. The next time the system
  27725. boots, it will use the preceding system generation. This is the inverse
  27726. of @command{reconfigure}, and it is exactly the same as invoking
  27727. @command{switch-generation} with an argument of @code{-1}.
  27728. Currently, as with @command{switch-generation}, you must reboot after
  27729. running this action to actually start using the preceding system
  27730. generation.
  27731. @item delete-generations
  27732. @cindex deleting system generations
  27733. @cindex saving space
  27734. Delete system generations, making them candidates for garbage collection
  27735. (@pxref{Invoking guix gc}, for information on how to run the ``garbage
  27736. collector'').
  27737. This works in the same way as @samp{guix package --delete-generations}
  27738. (@pxref{Invoking guix package, @option{--delete-generations}}). With no
  27739. arguments, all system generations but the current one are deleted:
  27740. @example
  27741. guix system delete-generations
  27742. @end example
  27743. You can also select the generations you want to delete. The example below
  27744. deletes all the system generations that are more than two months old:
  27745. @example
  27746. guix system delete-generations 2m
  27747. @end example
  27748. Running this command automatically reinstalls the bootloader with an updated
  27749. list of menu entries---e.g., the ``old generations'' sub-menu in GRUB no
  27750. longer lists the generations that have been deleted.
  27751. @item build
  27752. Build the derivation of the operating system, which includes all the
  27753. configuration files and programs needed to boot and run the system.
  27754. This action does not actually install anything.
  27755. @item init
  27756. Populate the given directory with all the files necessary to run the
  27757. operating system specified in @var{file}. This is useful for first-time
  27758. installations of Guix System. For instance:
  27759. @example
  27760. guix system init my-os-config.scm /mnt
  27761. @end example
  27762. copies to @file{/mnt} all the store items required by the configuration
  27763. specified in @file{my-os-config.scm}. This includes configuration
  27764. files, packages, and so on. It also creates other essential files
  27765. needed for the system to operate correctly---e.g., the @file{/etc},
  27766. @file{/var}, and @file{/run} directories, and the @file{/bin/sh} file.
  27767. This command also installs bootloader on the targets specified in
  27768. @file{my-os-config}, unless the @option{--no-bootloader} option was
  27769. passed.
  27770. @item vm
  27771. @cindex virtual machine
  27772. @cindex VM
  27773. @anchor{guix system vm}
  27774. Build a virtual machine (VM) that contains the operating system declared
  27775. in @var{file}, and return a script to run that VM.
  27776. @quotation Note
  27777. The @code{vm} action and others below
  27778. can use KVM support in the Linux-libre kernel. Specifically, if the
  27779. machine has hardware virtualization support, the corresponding
  27780. KVM kernel module should be loaded, and the @file{/dev/kvm} device node
  27781. must exist and be readable and writable by the user and by the
  27782. build users of the daemon (@pxref{Build Environment Setup}).
  27783. @end quotation
  27784. Arguments given to the script are passed to QEMU as in the example
  27785. below, which enables networking and requests 1@tie{}GiB of RAM for the
  27786. emulated machine:
  27787. @example
  27788. $ /gnu/store/@dots{}-run-vm.sh -m 1024 -smp 2 -nic user,model=virtio-net-pci
  27789. @end example
  27790. It's possible to combine the two steps into one:
  27791. @example
  27792. $ $(guix system vm my-config.scm) -m 1024 -smp 2 -nic user,model=virtio-net-pci
  27793. @end example
  27794. The VM shares its store with the host system.
  27795. By default, the root file system of the VM is mounted volatile; the
  27796. @option{--persistent} option can be provided to make it persistent
  27797. instead. In that case, the VM disk-image file will be copied from the
  27798. store to the @env{TMPDIR} directory to make it writable.
  27799. Additional file systems can be shared between the host and the VM using
  27800. the @option{--share} and @option{--expose} command-line options: the former
  27801. specifies a directory to be shared with write access, while the latter
  27802. provides read-only access to the shared directory.
  27803. The example below creates a VM in which the user's home directory is
  27804. accessible read-only, and where the @file{/exchange} directory is a
  27805. read-write mapping of @file{$HOME/tmp} on the host:
  27806. @example
  27807. guix system vm my-config.scm \
  27808. --expose=$HOME --share=$HOME/tmp=/exchange
  27809. @end example
  27810. On GNU/Linux, the default is to boot directly to the kernel; this has
  27811. the advantage of requiring only a very tiny root disk image since the
  27812. store of the host can then be mounted.
  27813. The @option{--full-boot} option forces a complete boot sequence, starting
  27814. with the bootloader. This requires more disk space since a root image
  27815. containing at least the kernel, initrd, and bootloader data files must
  27816. be created.
  27817. The @option{--image-size} option can be used to specify the size of the
  27818. image.
  27819. The @option{--no-graphic} option will instruct @command{guix system} to
  27820. spawn a headless VM that will use the invoking tty for IO. Among other
  27821. things, this enables copy-pasting, and scrollback. Use the @kbd{ctrl-a}
  27822. prefix to issue QEMU commands; e.g. @kbd{ctrl-a h} prints a help,
  27823. @kbd{ctrl-a x} quits the VM, and @kbd{ctrl-a c} switches between the
  27824. QEMU monitor and the VM.
  27825. @cindex System images, creation in various formats
  27826. @cindex Creating system images in various formats
  27827. @item image
  27828. @cindex image, creating disk images
  27829. The @code{image} command can produce various image types. The image
  27830. type can be selected using the @option{--image-type} option. It
  27831. defaults to @code{efi-raw}. When its value is @code{iso9660}, the
  27832. @option{--label} option can be used to specify a volume ID with
  27833. @code{image}. By default, the root file system of a disk image is
  27834. mounted non-volatile; the @option{--volatile} option can be provided to
  27835. make it volatile instead. When using @code{image}, the bootloader
  27836. installed on the generated image is taken from the provided
  27837. @code{operating-system} definition. The following example demonstrates
  27838. how to generate an image that uses the @code{grub-efi-bootloader}
  27839. bootloader and boot it with QEMU:
  27840. @example
  27841. image=$(guix system image --image-type=qcow2 \
  27842. gnu/system/examples/lightweight-desktop.tmpl)
  27843. cp $image /tmp/my-image.qcow2
  27844. chmod +w /tmp/my-image.qcow2
  27845. qemu-system-x86_64 -enable-kvm -hda /tmp/my-image.qcow2 -m 1000 \
  27846. -bios $(guix build ovmf)/share/firmware/ovmf_x64.bin
  27847. @end example
  27848. When using the @code{efi-raw} image type, a raw disk image is produced;
  27849. it can be copied as is to a USB stick, for instance. Assuming
  27850. @code{/dev/sdc} is the device corresponding to a USB stick, one can copy
  27851. the image to it using the following command:
  27852. @example
  27853. # dd if=$(guix system image my-os.scm) of=/dev/sdc status=progress
  27854. @end example
  27855. The @code{--list-image-types} command lists all the available image
  27856. types.
  27857. @cindex creating virtual machine images
  27858. When using the @code{qcow2} image type, the returned image is in qcow2
  27859. format, which the QEMU emulator can efficiently use. @xref{Running Guix
  27860. in a VM}, for more information on how to run the image in a virtual
  27861. machine. The @code{grub-bootloader} bootloader is always used
  27862. independently of what is declared in the @code{operating-system} file
  27863. passed as argument. This is to make it easier to work with QEMU, which
  27864. uses the SeaBIOS BIOS by default, expecting a bootloader to be installed
  27865. in the Master Boot Record (MBR).
  27866. @cindex docker-image, creating docker images
  27867. When using the @code{docker} image type, a Docker image is produced.
  27868. Guix builds the image from scratch, not from a pre-existing Docker base
  27869. image. As a result, it contains @emph{exactly} what you define in the
  27870. operating system configuration file. You can then load the image and
  27871. launch a Docker container using commands like the following:
  27872. @example
  27873. image_id="$(docker load < guix-system-docker-image.tar.gz)"
  27874. container_id="$(docker create $image_id)"
  27875. docker start $container_id
  27876. @end example
  27877. This command starts a new Docker container from the specified image. It
  27878. will boot the Guix system in the usual manner, which means it will
  27879. start any services you have defined in the operating system
  27880. configuration. You can get an interactive shell running in the container
  27881. using @command{docker exec}:
  27882. @example
  27883. docker exec -ti $container_id /run/current-system/profile/bin/bash --login
  27884. @end example
  27885. Depending on what you run in the Docker container, it
  27886. may be necessary to give the container additional permissions. For
  27887. example, if you intend to build software using Guix inside of the Docker
  27888. container, you may need to pass the @option{--privileged} option to
  27889. @code{docker create}.
  27890. Last, the @option{--network} option applies to @command{guix system
  27891. docker-image}: it produces an image where network is supposedly shared
  27892. with the host, and thus without services like nscd or NetworkManager.
  27893. @item container
  27894. Return a script to run the operating system declared in @var{file}
  27895. within a container. Containers are a set of lightweight isolation
  27896. mechanisms provided by the kernel Linux-libre. Containers are
  27897. substantially less resource-demanding than full virtual machines since
  27898. the kernel, shared objects, and other resources can be shared with the
  27899. host system; this also means they provide thinner isolation.
  27900. Currently, the script must be run as root in order to support more than
  27901. a single user and group. The container shares its store with the host
  27902. system.
  27903. As with the @code{vm} action (@pxref{guix system vm}), additional file
  27904. systems to be shared between the host and container can be specified
  27905. using the @option{--share} and @option{--expose} options:
  27906. @example
  27907. guix system container my-config.scm \
  27908. --expose=$HOME --share=$HOME/tmp=/exchange
  27909. @end example
  27910. @quotation Note
  27911. This option requires Linux-libre 3.19 or newer.
  27912. @end quotation
  27913. @end table
  27914. @var{options} can contain any of the common build options (@pxref{Common
  27915. Build Options}). In addition, @var{options} can contain one of the
  27916. following:
  27917. @table @option
  27918. @item --expression=@var{expr}
  27919. @itemx -e @var{expr}
  27920. Consider the operating-system @var{expr} evaluates to.
  27921. This is an alternative to specifying a file which evaluates to an
  27922. operating system.
  27923. This is used to generate the Guix system installer @pxref{Building the
  27924. Installation Image}).
  27925. @item --system=@var{system}
  27926. @itemx -s @var{system}
  27927. Attempt to build for @var{system} instead of the host system type.
  27928. This works as per @command{guix build} (@pxref{Invoking guix build}).
  27929. @item --derivation
  27930. @itemx -d
  27931. Return the derivation file name of the given operating system without
  27932. building anything.
  27933. @cindex provenance tracking, of the operating system
  27934. @item --save-provenance
  27935. As discussed above, @command{guix system init} and @command{guix system
  27936. reconfigure} always save provenance information @i{via} a dedicated
  27937. service (@pxref{Service Reference, @code{provenance-service-type}}).
  27938. However, other commands don't do that by default. If you wish to, say,
  27939. create a virtual machine image that contains provenance information, you
  27940. can run:
  27941. @example
  27942. guix system image -t qcow2 --save-provenance config.scm
  27943. @end example
  27944. That way, the resulting image will effectively ``embed its own source''
  27945. in the form of meta-data in @file{/run/current-system}. With that
  27946. information, one can rebuild the image to make sure it really contains
  27947. what it pretends to contain; or they could use that to derive a variant
  27948. of the image.
  27949. @item --image-type=@var{type}
  27950. @itemx -t @var{type}
  27951. For the @code{image} action, create an image with given @var{type}.
  27952. When this option is omitted, @command{guix system} uses the
  27953. @code{efi-raw} image type.
  27954. @cindex ISO-9660 format
  27955. @cindex CD image format
  27956. @cindex DVD image format
  27957. @option{--image-type=iso9660} produces an ISO-9660 image, suitable
  27958. for burning on CDs and DVDs.
  27959. @item --image-size=@var{size}
  27960. For the @code{image} action, create an image of the given @var{size}.
  27961. @var{size} may be a number of bytes, or it may include a unit as a
  27962. suffix (@pxref{Block size, size specifications,, coreutils, GNU
  27963. Coreutils}).
  27964. When this option is omitted, @command{guix system} computes an estimate
  27965. of the image size as a function of the size of the system declared in
  27966. @var{file}.
  27967. @item --network
  27968. @itemx -N
  27969. For the @code{container} action, allow containers to access the host network,
  27970. that is, do not create a network namespace.
  27971. @item --root=@var{file}
  27972. @itemx -r @var{file}
  27973. Make @var{file} a symlink to the result, and register it as a garbage
  27974. collector root.
  27975. @item --skip-checks
  27976. Skip pre-installation safety checks.
  27977. By default, @command{guix system init} and @command{guix system
  27978. reconfigure} perform safety checks: they make sure the file systems that
  27979. appear in the @code{operating-system} declaration actually exist
  27980. (@pxref{File Systems}), and that any Linux kernel modules that may be
  27981. needed at boot time are listed in @code{initrd-modules} (@pxref{Initial
  27982. RAM Disk}). Passing this option skips these tests altogether.
  27983. @item --allow-downgrades
  27984. Instruct @command{guix system reconfigure} to allow system downgrades.
  27985. By default, @command{reconfigure} prevents you from downgrading your
  27986. system. It achieves that by comparing the provenance info of your
  27987. system (shown by @command{guix system describe}) with that of your
  27988. @command{guix} command (shown by @command{guix describe}). If the
  27989. commits for @command{guix} are not descendants of those used for your
  27990. system, @command{guix system reconfigure} errors out. Passing
  27991. @option{--allow-downgrades} allows you to bypass these checks.
  27992. @quotation Note
  27993. Make sure you understand its security implications before using
  27994. @option{--allow-downgrades}.
  27995. @end quotation
  27996. @cindex on-error
  27997. @cindex on-error strategy
  27998. @cindex error strategy
  27999. @item --on-error=@var{strategy}
  28000. Apply @var{strategy} when an error occurs when reading @var{file}.
  28001. @var{strategy} may be one of the following:
  28002. @table @code
  28003. @item nothing-special
  28004. Report the error concisely and exit. This is the default strategy.
  28005. @item backtrace
  28006. Likewise, but also display a backtrace.
  28007. @item debug
  28008. Report the error and enter Guile's debugger. From there, you can run
  28009. commands such as @code{,bt} to get a backtrace, @code{,locals} to
  28010. display local variable values, and more generally inspect the state of the
  28011. program. @xref{Debug Commands,,, guile, GNU Guile Reference Manual}, for
  28012. a list of available debugging commands.
  28013. @end table
  28014. @end table
  28015. Once you have built, configured, re-configured, and re-re-configured
  28016. your Guix installation, you may find it useful to list the operating
  28017. system generations available on disk---and that you can choose from the
  28018. bootloader boot menu:
  28019. @table @code
  28020. @item describe
  28021. Describe the running system generation: its file name, the kernel and
  28022. bootloader used, etc., as well as provenance information when available.
  28023. @quotation Note
  28024. The @emph{running} system generation---referred to by
  28025. @file{/run/current-system}---is not necessarily the @emph{current}
  28026. system generation---referred to by @file{/var/guix/profiles/system}: it
  28027. differs when, for instance, you chose from the bootloader menu to boot
  28028. an older generation.
  28029. It can also differ from the @emph{booted} system generation---referred
  28030. to by @file{/run/booted-system}---for instance because you reconfigured
  28031. the system in the meantime.
  28032. @end quotation
  28033. @item list-generations
  28034. List a summary of each generation of the operating system available on
  28035. disk, in a human-readable way. This is similar to the
  28036. @option{--list-generations} option of @command{guix package}
  28037. (@pxref{Invoking guix package}).
  28038. Optionally, one can specify a pattern, with the same syntax that is used
  28039. in @command{guix package --list-generations}, to restrict the list of
  28040. generations displayed. For instance, the following command displays
  28041. generations that are up to 10 days old:
  28042. @example
  28043. $ guix system list-generations 10d
  28044. @end example
  28045. @end table
  28046. The @command{guix system} command has even more to offer! The following
  28047. sub-commands allow you to visualize how your system services relate to
  28048. each other:
  28049. @anchor{system-extension-graph}
  28050. @table @code
  28051. @item extension-graph
  28052. Emit to standard output the @dfn{service
  28053. extension graph} of the operating system defined in @var{file}
  28054. (@pxref{Service Composition}, for more information on service
  28055. extensions). By default the output is in Dot/Graphviz format, but you
  28056. can choose a different format with @option{--graph-backend}, as with
  28057. @command{guix graph} (@pxref{Invoking guix graph, @option{--backend}}):
  28058. The command:
  28059. @example
  28060. $ guix system extension-graph @var{file} | xdot -
  28061. @end example
  28062. shows the extension relations among services.
  28063. @anchor{system-shepherd-graph}
  28064. @item shepherd-graph
  28065. Emit to standard output the @dfn{dependency
  28066. graph} of shepherd services of the operating system defined in
  28067. @var{file}. @xref{Shepherd Services}, for more information and for an
  28068. example graph.
  28069. Again, the default output format is Dot/Graphviz, but you can pass
  28070. @option{--graph-backend} to select a different one.
  28071. @end table
  28072. @node Invoking guix deploy
  28073. @section Invoking @code{guix deploy}
  28074. We've already seen @code{operating-system} declarations used to manage a
  28075. machine's configuration locally. Suppose you need to configure multiple
  28076. machines, though---perhaps you're managing a service on the web that's
  28077. comprised of several servers. @command{guix deploy} enables you to use those
  28078. same @code{operating-system} declarations to manage multiple remote hosts at
  28079. once as a logical ``deployment''.
  28080. @quotation Note
  28081. The functionality described in this section is still under development
  28082. and is subject to change. Get in touch with us on
  28083. @email{guix-devel@@gnu.org}!
  28084. @end quotation
  28085. @example
  28086. guix deploy @var{file}
  28087. @end example
  28088. Such an invocation will deploy the machines that the code within @var{file}
  28089. evaluates to. As an example, @var{file} might contain a definition like this:
  28090. @lisp
  28091. ;; This is a Guix deployment of a "bare bones" setup, with
  28092. ;; no X11 display server, to a machine with an SSH daemon
  28093. ;; listening on localhost:2222. A configuration such as this
  28094. ;; may be appropriate for virtual machine with ports
  28095. ;; forwarded to the host's loopback interface.
  28096. (use-service-modules networking ssh)
  28097. (use-package-modules bootloaders)
  28098. (define %system
  28099. (operating-system
  28100. (host-name "gnu-deployed")
  28101. (timezone "Etc/UTC")
  28102. (bootloader (bootloader-configuration
  28103. (bootloader grub-bootloader)
  28104. (targets '("/dev/vda"))
  28105. (terminal-outputs '(console))))
  28106. (file-systems (cons (file-system
  28107. (mount-point "/")
  28108. (device "/dev/vda1")
  28109. (type "ext4"))
  28110. %base-file-systems))
  28111. (services
  28112. (append (list (service dhcp-client-service-type)
  28113. (service openssh-service-type
  28114. (openssh-configuration
  28115. (permit-root-login #t)
  28116. (allow-empty-passwords? #t))))
  28117. %base-services))))
  28118. (list (machine
  28119. (operating-system %system)
  28120. (environment managed-host-environment-type)
  28121. (configuration (machine-ssh-configuration
  28122. (host-name "localhost")
  28123. (system "x86_64-linux")
  28124. (user "alice")
  28125. (identity "./id_rsa")
  28126. (port 2222)))))
  28127. @end lisp
  28128. The file should evaluate to a list of @var{machine} objects. This example,
  28129. upon being deployed, will create a new generation on the remote system
  28130. realizing the @code{operating-system} declaration @code{%system}.
  28131. @code{environment} and @code{configuration} specify how the machine should be
  28132. provisioned---that is, how the computing resources should be created and
  28133. managed. The above example does not create any resources, as a
  28134. @code{'managed-host} is a machine that is already running the Guix system and
  28135. available over the network. This is a particularly simple case; a more
  28136. complex deployment may involve, for example, starting virtual machines through
  28137. a Virtual Private Server (VPS) provider. In such a case, a different
  28138. @var{environment} type would be used.
  28139. Do note that you first need to generate a key pair on the coordinator machine
  28140. to allow the daemon to export signed archives of files from the store
  28141. (@pxref{Invoking guix archive}), though this step is automatic on Guix
  28142. System:
  28143. @example
  28144. # guix archive --generate-key
  28145. @end example
  28146. @noindent
  28147. Each target machine must authorize the key of the master machine so that it
  28148. accepts store items it receives from the coordinator:
  28149. @example
  28150. # guix archive --authorize < coordinator-public-key.txt
  28151. @end example
  28152. @code{user}, in this example, specifies the name of the user account to log in
  28153. as to perform the deployment. Its default value is @code{root}, but root
  28154. login over SSH may be forbidden in some cases. To work around this,
  28155. @command{guix deploy} can log in as an unprivileged user and employ
  28156. @code{sudo} to escalate privileges. This will only work if @code{sudo} is
  28157. currently installed on the remote and can be invoked non-interactively as
  28158. @code{user}. That is, the line in @code{sudoers} granting @code{user} the
  28159. ability to use @code{sudo} must contain the @code{NOPASSWD} tag. This can
  28160. be accomplished with the following operating system configuration snippet:
  28161. @lisp
  28162. (use-modules ...
  28163. (gnu system)) ;for %sudoers-specification
  28164. (define %user "username")
  28165. (operating-system
  28166. ...
  28167. (sudoers-file
  28168. (plain-file "sudoers"
  28169. (string-append (plain-file-content %sudoers-specification)
  28170. (format #f "~a ALL = NOPASSWD: ALL~%"
  28171. %user)))))
  28172. @end lisp
  28173. For more information regarding the format of the @file{sudoers} file,
  28174. consult @command{man sudoers}.
  28175. Once you've deployed a system on a set of machines, you may find it
  28176. useful to run a command on all of them. The @option{--execute} or
  28177. @option{-x} option lets you do that; the example below runs
  28178. @command{uname -a} on all the machines listed in the deployment file:
  28179. @example
  28180. guix deploy @var{file} -x -- uname -a
  28181. @end example
  28182. One thing you may often need to do after deployment is restart specific
  28183. services on all the machines, which you can do like so:
  28184. @example
  28185. guix deploy @var{file} -x -- herd restart @var{service}
  28186. @end example
  28187. The @command{guix deploy -x} command returns zero if and only if the
  28188. command succeeded on all the machines.
  28189. @c FIXME/TODO: Separate the API doc from the CLI doc.
  28190. Below are the data types you need to know about when writing a
  28191. deployment file.
  28192. @deftp {Data Type} machine
  28193. This is the data type representing a single machine in a heterogeneous Guix
  28194. deployment.
  28195. @table @asis
  28196. @item @code{operating-system}
  28197. The object of the operating system configuration to deploy.
  28198. @item @code{environment}
  28199. An @code{environment-type} describing how the machine should be provisioned.
  28200. @item @code{configuration} (default: @code{#f})
  28201. An object describing the configuration for the machine's @code{environment}.
  28202. If the @code{environment} has a default configuration, @code{#f} may be used.
  28203. If @code{#f} is used for an environment with no default configuration,
  28204. however, an error will be thrown.
  28205. @end table
  28206. @end deftp
  28207. @deftp {Data Type} machine-ssh-configuration
  28208. This is the data type representing the SSH client parameters for a machine
  28209. with an @code{environment} of @code{managed-host-environment-type}.
  28210. @table @asis
  28211. @item @code{host-name}
  28212. @item @code{build-locally?} (default: @code{#t})
  28213. If false, system derivations will be built on the machine being deployed to.
  28214. @item @code{system}
  28215. The system type describing the architecture of the machine being deployed
  28216. to---e.g., @code{"x86_64-linux"}.
  28217. @item @code{authorize?} (default: @code{#t})
  28218. If true, the coordinator's signing key will be added to the remote's ACL
  28219. keyring.
  28220. @item @code{port} (default: @code{22})
  28221. @item @code{user} (default: @code{"root"})
  28222. @item @code{identity} (default: @code{#f})
  28223. If specified, the path to the SSH private key to use to authenticate with the
  28224. remote host.
  28225. @item @code{host-key} (default: @code{#f})
  28226. This should be the SSH host key of the machine, which looks like this:
  28227. @example
  28228. ssh-ed25519 AAAAC3Nz@dots{} root@@example.org
  28229. @end example
  28230. When @code{host-key} is @code{#f}, the server is authenticated against
  28231. the @file{~/.ssh/known_hosts} file, just like the OpenSSH @command{ssh}
  28232. client does.
  28233. @item @code{allow-downgrades?} (default: @code{#f})
  28234. Whether to allow potential downgrades.
  28235. Like @command{guix system reconfigure}, @command{guix deploy} compares
  28236. the channel commits currently deployed on the remote host (as returned
  28237. by @command{guix system describe}) to those currently in use (as
  28238. returned by @command{guix describe}) to determine whether commits
  28239. currently in use are descendants of those deployed. When this is not
  28240. the case and @code{allow-downgrades?} is false, it raises an error.
  28241. This ensures you do not accidentally downgrade remote machines.
  28242. @item @code{safety-checks?} (default: @code{#t})
  28243. Whether to perform ``safety checks'' before deployment. This includes
  28244. verifying that devices and file systems referred to in the operating
  28245. system configuration actually exist on the target machine, and making
  28246. sure that Linux modules required to access storage devices at boot time
  28247. are listed in the @code{initrd-modules} field of the operating system.
  28248. These safety checks ensure that you do not inadvertently deploy a system
  28249. that would fail to boot. Be careful before turning them off!
  28250. @end table
  28251. @end deftp
  28252. @deftp {Data Type} digital-ocean-configuration
  28253. This is the data type describing the Droplet that should be created for a
  28254. machine with an @code{environment} of @code{digital-ocean-environment-type}.
  28255. @table @asis
  28256. @item @code{ssh-key}
  28257. The path to the SSH private key to use to authenticate with the remote
  28258. host. In the future, this field may not exist.
  28259. @item @code{tags}
  28260. A list of string ``tags'' that uniquely identify the machine. Must be given
  28261. such that no two machines in the deployment have the same set of tags.
  28262. @item @code{region}
  28263. A Digital Ocean region slug, such as @code{"nyc3"}.
  28264. @item @code{size}
  28265. A Digital Ocean size slug, such as @code{"s-1vcpu-1gb"}
  28266. @item @code{enable-ipv6?}
  28267. Whether or not the droplet should be created with IPv6 networking.
  28268. @end table
  28269. @end deftp
  28270. @node Running Guix in a VM
  28271. @section Running Guix in a Virtual Machine
  28272. @cindex virtual machine
  28273. To run Guix in a virtual machine (VM), one can use the pre-built Guix VM
  28274. image distributed at
  28275. @url{@value{BASE-URL}/guix-system-vm-image-@value{VERSION}.x86_64-linux.qcow2}.
  28276. This image is a compressed image in QCOW format. You can pass it to an
  28277. emulator such as @uref{https://qemu.org/, QEMU} (see below for details).
  28278. This image boots the Xfce graphical environment and it contains some
  28279. commonly used tools. You can install more software in the image by running
  28280. @command{guix package} in a terminal (@pxref{Invoking guix package}). You can
  28281. also reconfigure the system based on its initial configuration file available
  28282. as @file{/run/current-system/configuration.scm} (@pxref{Using the
  28283. Configuration System}).
  28284. Instead of using this pre-built image, one can also build their own
  28285. image using @command{guix system image} (@pxref{Invoking guix system}).
  28286. @cindex QEMU
  28287. If you built your own image, you must copy it out of the store
  28288. (@pxref{The Store}) and give yourself permission to write to the copy
  28289. before you can use it. When invoking QEMU, you must choose a system
  28290. emulator that is suitable for your hardware platform. Here is a minimal
  28291. QEMU invocation that will boot the result of @command{guix system
  28292. image -t qcow2} on x86_64 hardware:
  28293. @example
  28294. $ qemu-system-x86_64 \
  28295. -nic user,model=virtio-net-pci \
  28296. -enable-kvm -m 1024 \
  28297. -device virtio-blk,drive=myhd \
  28298. -drive if=none,file=/tmp/qemu-image,id=myhd
  28299. @end example
  28300. Here is what each of these options means:
  28301. @table @code
  28302. @item qemu-system-x86_64
  28303. This specifies the hardware platform to emulate. This should match the
  28304. host.
  28305. @item -nic user,model=virtio-net-pci
  28306. Enable the unprivileged user-mode network stack. The guest OS can
  28307. access the host but not vice versa. This is the simplest way to get the
  28308. guest OS online. @code{model} specifies which network device to emulate:
  28309. @code{virtio-net-pci} is a special device made for virtualized operating
  28310. systems and recommended for most uses. Assuming your hardware platform is
  28311. x86_64, you can get a list of available NIC models by running
  28312. @command{qemu-system-x86_64 -nic model=help}.
  28313. @item -enable-kvm
  28314. If your system has hardware virtualization extensions, enabling the
  28315. virtual machine support (KVM) of the Linux kernel will make things run
  28316. faster.
  28317. @c To run Xfce + 'guix pull', we need at least 1G of RAM.
  28318. @item -m 1024
  28319. RAM available to the guest OS, in mebibytes. Defaults to 128@tie{}MiB,
  28320. which may be insufficient for some operations.
  28321. @item -device virtio-blk,drive=myhd
  28322. Create a @code{virtio-blk} drive called ``myhd''. @code{virtio-blk} is a
  28323. ``paravirtualization'' mechanism for block devices that allows QEMU to achieve
  28324. better performance than if it were emulating a complete disk drive. See the
  28325. QEMU and KVM documentation for more info.
  28326. @item -drive if=none,file=/tmp/qemu-image,id=myhd
  28327. Use our QCOW image, the @file{/tmp/qemu-image} file, as the backing
  28328. store of the ``myhd'' drive.
  28329. @end table
  28330. The default @command{run-vm.sh} script that is returned by an invocation of
  28331. @command{guix system vm} does not add a @command{-nic user} flag by default.
  28332. To get network access from within the vm add the @code{(dhcp-client-service)}
  28333. to your system definition and start the VM using
  28334. @command{$(guix system vm config.scm) -nic user}. An important caveat of using
  28335. @command{-nic user} for networking is that @command{ping} will not work, because
  28336. it uses the ICMP protocol. You'll have to use a different command to check for
  28337. network connectivity, for example @command{guix download}.
  28338. @subsection Connecting Through SSH
  28339. @cindex SSH
  28340. @cindex SSH server
  28341. To enable SSH inside a VM you need to add an SSH server like
  28342. @code{openssh-service-type} to your VM (@pxref{Networking Services,
  28343. @code{openssh-service-type}}). In addition you need to forward the SSH port,
  28344. 22 by default, to the host. You can do this with
  28345. @example
  28346. $(guix system vm config.scm) -nic user,model=virtio-net-pci,hostfwd=tcp::10022-:22
  28347. @end example
  28348. To connect to the VM you can run
  28349. @example
  28350. ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 10022 localhost
  28351. @end example
  28352. The @command{-p} tells @command{ssh} the port you want to connect to.
  28353. @command{-o UserKnownHostsFile=/dev/null} prevents @command{ssh} from complaining
  28354. every time you modify your @command{config.scm} file and the
  28355. @command{-o StrictHostKeyChecking=no} prevents you from having to allow a
  28356. connection to an unknown host every time you connect.
  28357. @quotation Note
  28358. If you find the above @samp{hostfwd} example not to be working (e.g.,
  28359. your SSH client hangs attempting to connect to the mapped port of your
  28360. VM), make sure that your Guix System VM has networking support, such as
  28361. by using the @code{dhcp-client-service-type} service type.
  28362. @end quotation
  28363. @subsection Using @command{virt-viewer} with Spice
  28364. As an alternative to the default @command{qemu} graphical client you can
  28365. use the @command{remote-viewer} from the @command{virt-viewer} package. To
  28366. connect pass the @command{-spice port=5930,disable-ticketing} flag to
  28367. @command{qemu}. See previous section for further information on how to do this.
  28368. Spice also allows you to do some nice stuff like share your clipboard with your
  28369. VM@. To enable that you'll also have to pass the following flags to @command{qemu}:
  28370. @example
  28371. -device virtio-serial-pci,id=virtio-serial0,max_ports=16,bus=pci.0,addr=0x5
  28372. -chardev spicevmc,name=vdagent,id=vdagent
  28373. -device virtserialport,nr=1,bus=virtio-serial0.0,chardev=vdagent,\
  28374. name=com.redhat.spice.0
  28375. @end example
  28376. You'll also need to add the @code{(spice-vdagent-service)} to your
  28377. system definition (@pxref{Miscellaneous Services, Spice service}).
  28378. @node Defining Services
  28379. @section Defining Services
  28380. The previous sections show the available services and how one can combine
  28381. them in an @code{operating-system} declaration. But how do we define
  28382. them in the first place? And what is a service anyway?
  28383. @menu
  28384. * Service Composition:: The model for composing services.
  28385. * Service Types and Services:: Types and services.
  28386. * Service Reference:: API reference.
  28387. * Shepherd Services:: A particular type of service.
  28388. * Complex Configurations:: Defining bindings for complex configurations.
  28389. @end menu
  28390. @node Service Composition
  28391. @subsection Service Composition
  28392. @cindex services
  28393. @cindex daemons
  28394. Here we define a @dfn{service} as, broadly, something that extends the
  28395. functionality of the operating system. Often a service is a process---a
  28396. @dfn{daemon}---started when the system boots: a secure shell server, a
  28397. Web server, the Guix build daemon, etc. Sometimes a service is a daemon
  28398. whose execution can be triggered by another daemon---e.g., an FTP server
  28399. started by @command{inetd} or a D-Bus service activated by
  28400. @command{dbus-daemon}. Occasionally, a service does not map to a
  28401. daemon. For instance, the ``account'' service collects user accounts
  28402. and makes sure they exist when the system runs; the ``udev'' service
  28403. collects device management rules and makes them available to the eudev
  28404. daemon; the @file{/etc} service populates the @file{/etc} directory
  28405. of the system.
  28406. @cindex service extensions
  28407. Guix system services are connected by @dfn{extensions}. For instance, the
  28408. secure shell service @emph{extends} the Shepherd---the
  28409. initialization system, running as PID@tie{}1---by giving it the command
  28410. lines to start and stop the secure shell daemon (@pxref{Networking
  28411. Services, @code{openssh-service-type}}); the UPower service extends the D-Bus
  28412. service by passing it its @file{.service} specification, and extends the
  28413. udev service by passing it device management rules (@pxref{Desktop
  28414. Services, @code{upower-service}}); the Guix daemon service extends the
  28415. Shepherd by passing it the command lines to start and stop the daemon,
  28416. and extends the account service by passing it a list of required build
  28417. user accounts (@pxref{Base Services}).
  28418. All in all, services and their ``extends'' relations form a directed
  28419. acyclic graph (DAG). If we represent services as boxes and extensions
  28420. as arrows, a typical system might provide something like this:
  28421. @image{images/service-graph,,5in,Typical service extension graph.}
  28422. @cindex system service
  28423. At the bottom, we see the @dfn{system service}, which produces the
  28424. directory containing everything to run and boot the system, as returned
  28425. by the @command{guix system build} command. @xref{Service Reference},
  28426. to learn about the other service types shown here.
  28427. @xref{system-extension-graph, the @command{guix system extension-graph}
  28428. command}, for information on how to generate this representation for a
  28429. particular operating system definition.
  28430. @cindex service types
  28431. Technically, developers can define @dfn{service types} to express these
  28432. relations. There can be any number of services of a given type on the
  28433. system---for instance, a system running two instances of the GNU secure
  28434. shell server (lsh) has two instances of @code{lsh-service-type}, with
  28435. different parameters.
  28436. The following section describes the programming interface for service
  28437. types and services.
  28438. @node Service Types and Services
  28439. @subsection Service Types and Services
  28440. A @dfn{service type} is a node in the DAG described above. Let us start
  28441. with a simple example, the service type for the Guix build daemon
  28442. (@pxref{Invoking guix-daemon}):
  28443. @lisp
  28444. (define guix-service-type
  28445. (service-type
  28446. (name 'guix)
  28447. (extensions
  28448. (list (service-extension shepherd-root-service-type guix-shepherd-service)
  28449. (service-extension account-service-type guix-accounts)
  28450. (service-extension activation-service-type guix-activation)))
  28451. (default-value (guix-configuration))))
  28452. @end lisp
  28453. @noindent
  28454. It defines three things:
  28455. @enumerate
  28456. @item
  28457. A name, whose sole purpose is to make inspection and debugging easier.
  28458. @item
  28459. A list of @dfn{service extensions}, where each extension designates the
  28460. target service type and a procedure that, given the parameters of the
  28461. service, returns a list of objects to extend the service of that type.
  28462. Every service type has at least one service extension. The only
  28463. exception is the @dfn{boot service type}, which is the ultimate service.
  28464. @item
  28465. Optionally, a default value for instances of this type.
  28466. @end enumerate
  28467. In this example, @code{guix-service-type} extends three services:
  28468. @table @code
  28469. @item shepherd-root-service-type
  28470. The @code{guix-shepherd-service} procedure defines how the Shepherd
  28471. service is extended. Namely, it returns a @code{<shepherd-service>}
  28472. object that defines how @command{guix-daemon} is started and stopped
  28473. (@pxref{Shepherd Services}).
  28474. @item account-service-type
  28475. This extension for this service is computed by @code{guix-accounts},
  28476. which returns a list of @code{user-group} and @code{user-account}
  28477. objects representing the build user accounts (@pxref{Invoking
  28478. guix-daemon}).
  28479. @item activation-service-type
  28480. Here @code{guix-activation} is a procedure that returns a gexp, which is
  28481. a code snippet to run at ``activation time''---e.g., when the service is
  28482. booted.
  28483. @end table
  28484. A service of this type is instantiated like this:
  28485. @lisp
  28486. (service guix-service-type
  28487. (guix-configuration
  28488. (build-accounts 5)
  28489. (extra-options '("--gc-keep-derivations"))))
  28490. @end lisp
  28491. The second argument to the @code{service} form is a value representing
  28492. the parameters of this specific service instance.
  28493. @xref{guix-configuration-type, @code{guix-configuration}}, for
  28494. information about the @code{guix-configuration} data type. When the
  28495. value is omitted, the default value specified by
  28496. @code{guix-service-type} is used:
  28497. @lisp
  28498. (service guix-service-type)
  28499. @end lisp
  28500. @code{guix-service-type} is quite simple because it extends other
  28501. services but is not extensible itself.
  28502. @c @subsubsubsection Extensible Service Types
  28503. The service type for an @emph{extensible} service looks like this:
  28504. @lisp
  28505. (define udev-service-type
  28506. (service-type (name 'udev)
  28507. (extensions
  28508. (list (service-extension shepherd-root-service-type
  28509. udev-shepherd-service)))
  28510. (compose concatenate) ;concatenate the list of rules
  28511. (extend (lambda (config rules)
  28512. (match config
  28513. (($ <udev-configuration> udev initial-rules)
  28514. (udev-configuration
  28515. (udev udev) ;the udev package to use
  28516. (rules (append initial-rules rules)))))))))
  28517. @end lisp
  28518. This is the service type for the
  28519. @uref{https://wiki.gentoo.org/wiki/Project:Eudev, eudev device
  28520. management daemon}. Compared to the previous example, in addition to an
  28521. extension of @code{shepherd-root-service-type}, we see two new fields:
  28522. @table @code
  28523. @item compose
  28524. This is the procedure to @dfn{compose} the list of extensions to
  28525. services of this type.
  28526. Services can extend the udev service by passing it lists of rules; we
  28527. compose those extensions simply by concatenating them.
  28528. @item extend
  28529. This procedure defines how the value of the service is @dfn{extended} with
  28530. the composition of the extensions.
  28531. Udev extensions are composed into a list of rules, but the udev service
  28532. value is itself a @code{<udev-configuration>} record. So here, we
  28533. extend that record by appending the list of rules it contains to the
  28534. list of contributed rules.
  28535. @item description
  28536. This is a string giving an overview of the service type. The string can
  28537. contain Texinfo markup (@pxref{Overview,,, texinfo, GNU Texinfo}). The
  28538. @command{guix system search} command searches these strings and displays
  28539. them (@pxref{Invoking guix system}).
  28540. @end table
  28541. There can be only one instance of an extensible service type such as
  28542. @code{udev-service-type}. If there were more, the
  28543. @code{service-extension} specifications would be ambiguous.
  28544. Still here? The next section provides a reference of the programming
  28545. interface for services.
  28546. @node Service Reference
  28547. @subsection Service Reference
  28548. We have seen an overview of service types (@pxref{Service Types and
  28549. Services}). This section provides a reference on how to manipulate
  28550. services and service types. This interface is provided by the
  28551. @code{(gnu services)} module.
  28552. @deffn {Scheme Procedure} service @var{type} [@var{value}]
  28553. Return a new service of @var{type}, a @code{<service-type>} object (see
  28554. below). @var{value} can be any object; it represents the parameters of
  28555. this particular service instance.
  28556. When @var{value} is omitted, the default value specified by @var{type}
  28557. is used; if @var{type} does not specify a default value, an error is
  28558. raised.
  28559. For instance, this:
  28560. @lisp
  28561. (service openssh-service-type)
  28562. @end lisp
  28563. @noindent
  28564. is equivalent to this:
  28565. @lisp
  28566. (service openssh-service-type
  28567. (openssh-configuration))
  28568. @end lisp
  28569. In both cases the result is an instance of @code{openssh-service-type}
  28570. with the default configuration.
  28571. @end deffn
  28572. @deffn {Scheme Procedure} service? @var{obj}
  28573. Return true if @var{obj} is a service.
  28574. @end deffn
  28575. @deffn {Scheme Procedure} service-kind @var{service}
  28576. Return the type of @var{service}---i.e., a @code{<service-type>} object.
  28577. @end deffn
  28578. @deffn {Scheme Procedure} service-value @var{service}
  28579. Return the value associated with @var{service}. It represents its
  28580. parameters.
  28581. @end deffn
  28582. Here is an example of how a service is created and manipulated:
  28583. @lisp
  28584. (define s
  28585. (service nginx-service-type
  28586. (nginx-configuration
  28587. (nginx nginx)
  28588. (log-directory log-directory)
  28589. (run-directory run-directory)
  28590. (file config-file))))
  28591. (service? s)
  28592. @result{} #t
  28593. (eq? (service-kind s) nginx-service-type)
  28594. @result{} #t
  28595. @end lisp
  28596. The @code{modify-services} form provides a handy way to change the
  28597. parameters of some of the services of a list such as
  28598. @code{%base-services} (@pxref{Base Services, @code{%base-services}}). It
  28599. evaluates to a list of services. Of course, you could always use
  28600. standard list combinators such as @code{map} and @code{fold} to do that
  28601. (@pxref{SRFI-1, List Library,, guile, GNU Guile Reference Manual});
  28602. @code{modify-services} simply provides a more concise form for this
  28603. common pattern.
  28604. @deffn {Scheme Syntax} modify-services @var{services} @
  28605. (@var{type} @var{variable} => @var{body}) @dots{}
  28606. Modify the services listed in @var{services} according to the given
  28607. clauses. Each clause has the form:
  28608. @example
  28609. (@var{type} @var{variable} => @var{body})
  28610. @end example
  28611. where @var{type} is a service type---e.g.,
  28612. @code{guix-service-type}---and @var{variable} is an identifier that is
  28613. bound within the @var{body} to the service parameters---e.g., a
  28614. @code{guix-configuration} instance---of the original service of that
  28615. @var{type}.
  28616. The @var{body} should evaluate to the new service parameters, which will
  28617. be used to configure the new service. This new service will replace the
  28618. original in the resulting list. Because a service's service parameters
  28619. are created using @code{define-record-type*}, you can write a succinct
  28620. @var{body} that evaluates to the new service parameters by using the
  28621. @code{inherit} feature that @code{define-record-type*} provides.
  28622. Clauses can also have the following form:
  28623. @lisp
  28624. (delete @var{type})
  28625. @end lisp
  28626. Such a clause removes all services of the given @var{type} from
  28627. @var{services}.
  28628. @xref{Using the Configuration System}, for example usage.
  28629. @end deffn
  28630. Next comes the programming interface for service types. This is
  28631. something you want to know when writing new service definitions, but not
  28632. necessarily when simply looking for ways to customize your
  28633. @code{operating-system} declaration.
  28634. @deftp {Data Type} service-type
  28635. @cindex service type
  28636. This is the representation of a @dfn{service type} (@pxref{Service Types
  28637. and Services}).
  28638. @table @asis
  28639. @item @code{name}
  28640. This is a symbol, used only to simplify inspection and debugging.
  28641. @item @code{extensions}
  28642. A non-empty list of @code{<service-extension>} objects (see below).
  28643. @item @code{compose} (default: @code{#f})
  28644. If this is @code{#f}, then the service type denotes services that cannot
  28645. be extended---i.e., services that do not receive ``values'' from other
  28646. services.
  28647. Otherwise, it must be a one-argument procedure. The procedure is called
  28648. by @code{fold-services} and is passed a list of values collected from
  28649. extensions. It may return any single value.
  28650. @item @code{extend} (default: @code{#f})
  28651. If this is @code{#f}, services of this type cannot be extended.
  28652. Otherwise, it must be a two-argument procedure: @code{fold-services}
  28653. calls it, passing it the initial value of the service as the first
  28654. argument and the result of applying @code{compose} to the extension
  28655. values as the second argument. It must return a value that is a valid
  28656. parameter value for the service instance.
  28657. @item @code{description}
  28658. This is a string, possibly using Texinfo markup, describing in a couple
  28659. of sentences what the service is about. This string allows users to
  28660. find about the service through @command{guix system search}
  28661. (@pxref{Invoking guix system}).
  28662. @item @code{default-value} (default: @code{&no-default-value})
  28663. The default value associated for instances of this service type. This
  28664. allows users to use the @code{service} form without its second argument:
  28665. @lisp
  28666. (service @var{type})
  28667. @end lisp
  28668. The returned service in this case has the default value specified by
  28669. @var{type}.
  28670. @end table
  28671. @xref{Service Types and Services}, for examples.
  28672. @end deftp
  28673. @deffn {Scheme Procedure} service-extension @var{target-type} @
  28674. @var{compute}
  28675. Return a new extension for services of type @var{target-type}.
  28676. @var{compute} must be a one-argument procedure: @code{fold-services}
  28677. calls it, passing it the value associated with the service that provides
  28678. the extension; it must return a valid value for the target service.
  28679. @end deffn
  28680. @deffn {Scheme Procedure} service-extension? @var{obj}
  28681. Return true if @var{obj} is a service extension.
  28682. @end deffn
  28683. Occasionally, you might want to simply extend an existing service. This
  28684. involves creating a new service type and specifying the extension of
  28685. interest, which can be verbose; the @code{simple-service} procedure
  28686. provides a shorthand for this.
  28687. @deffn {Scheme Procedure} simple-service @var{name} @var{target} @var{value}
  28688. Return a service that extends @var{target} with @var{value}. This works
  28689. by creating a singleton service type @var{name}, of which the returned
  28690. service is an instance.
  28691. For example, this extends mcron (@pxref{Scheduled Job Execution}) with
  28692. an additional job:
  28693. @lisp
  28694. (simple-service 'my-mcron-job mcron-service-type
  28695. #~(job '(next-hour (3)) "guix gc -F 2G"))
  28696. @end lisp
  28697. @end deffn
  28698. At the core of the service abstraction lies the @code{fold-services}
  28699. procedure, which is responsible for ``compiling'' a list of services
  28700. down to a single directory that contains everything needed to boot and
  28701. run the system---the directory shown by the @command{guix system build}
  28702. command (@pxref{Invoking guix system}). In essence, it propagates
  28703. service extensions down the service graph, updating each node parameters
  28704. on the way, until it reaches the root node.
  28705. @deffn {Scheme Procedure} fold-services @var{services} @
  28706. [#:target-type @var{system-service-type}]
  28707. Fold @var{services} by propagating their extensions down to the root of
  28708. type @var{target-type}; return the root service adjusted accordingly.
  28709. @end deffn
  28710. Lastly, the @code{(gnu services)} module also defines several essential
  28711. service types, some of which are listed below.
  28712. @defvr {Scheme Variable} system-service-type
  28713. This is the root of the service graph. It produces the system directory
  28714. as returned by the @command{guix system build} command.
  28715. @end defvr
  28716. @defvr {Scheme Variable} boot-service-type
  28717. The type of the ``boot service'', which produces the @dfn{boot script}.
  28718. The boot script is what the initial RAM disk runs when booting.
  28719. @end defvr
  28720. @defvr {Scheme Variable} etc-service-type
  28721. The type of the @file{/etc} service. This service is used to create
  28722. files under @file{/etc} and can be extended by
  28723. passing it name/file tuples such as:
  28724. @lisp
  28725. (list `("issue" ,(plain-file "issue" "Welcome!\n")))
  28726. @end lisp
  28727. In this example, the effect would be to add an @file{/etc/issue} file
  28728. pointing to the given file.
  28729. @end defvr
  28730. @defvr {Scheme Variable} setuid-program-service-type
  28731. Type for the ``setuid-program service''. This service collects lists of
  28732. executable file names, passed as gexps, and adds them to the set of
  28733. setuid-root programs on the system (@pxref{Setuid Programs}).
  28734. @end defvr
  28735. @defvr {Scheme Variable} profile-service-type
  28736. Type of the service that populates the @dfn{system profile}---i.e., the
  28737. programs under @file{/run/current-system/profile}. Other services can
  28738. extend it by passing it lists of packages to add to the system profile.
  28739. @end defvr
  28740. @cindex provenance tracking, of the operating system
  28741. @anchor{provenance-service-type}
  28742. @defvr {Scheme Variable} provenance-service-type
  28743. This is the type of the service that records @dfn{provenance meta-data}
  28744. in the system itself. It creates several files under
  28745. @file{/run/current-system}:
  28746. @table @file
  28747. @item channels.scm
  28748. This is a ``channel file'' that can be passed to @command{guix pull -C}
  28749. or @command{guix time-machine -C}, and which describes the channels used
  28750. to build the system, if that information was available
  28751. (@pxref{Channels}).
  28752. @item configuration.scm
  28753. This is the file that was passed as the value for this
  28754. @code{provenance-service-type} service. By default, @command{guix
  28755. system reconfigure} automatically passes the OS configuration file it
  28756. received on the command line.
  28757. @item provenance
  28758. This contains the same information as the two other files but in a
  28759. format that is more readily processable.
  28760. @end table
  28761. In general, these two pieces of information (channels and configuration
  28762. file) are enough to reproduce the operating system ``from source''.
  28763. @quotation Caveats
  28764. This information is necessary to rebuild your operating system, but it
  28765. is not always sufficient. In particular, @file{configuration.scm}
  28766. itself is insufficient if it is not self-contained---if it refers to
  28767. external Guile modules or to extra files. If you want
  28768. @file{configuration.scm} to be self-contained, we recommend that modules
  28769. or files it refers to be part of a channel.
  28770. Besides, provenance meta-data is ``silent'' in the sense that it does
  28771. not change the bits contained in your system, @emph{except for the
  28772. meta-data bits themselves}. Two different OS configurations or sets of
  28773. channels can lead to the same system, bit-for-bit; when
  28774. @code{provenance-service-type} is used, these two systems will have
  28775. different meta-data and thus different store file names, which makes
  28776. comparison less trivial.
  28777. @end quotation
  28778. This service is automatically added to your operating system
  28779. configuration when you use @command{guix system reconfigure},
  28780. @command{guix system init}, or @command{guix deploy}.
  28781. @end defvr
  28782. @defvr {Scheme Variable} linux-loadable-module-service-type
  28783. Type of the service that collects lists of packages containing
  28784. kernel-loadable modules, and adds them to the set of kernel-loadable
  28785. modules.
  28786. This service type is intended to be extended by other service types,
  28787. such as below:
  28788. @lisp
  28789. (simple-service 'installing-module
  28790. linux-loadable-module-service-type
  28791. (list module-to-install-1
  28792. module-to-install-2))
  28793. @end lisp
  28794. This does not actually load modules at bootup, only adds it to the
  28795. kernel profile so that it @emph{can} be loaded by other means.
  28796. @end defvr
  28797. @node Shepherd Services
  28798. @subsection Shepherd Services
  28799. @cindex shepherd services
  28800. @cindex PID 1
  28801. @cindex init system
  28802. The @code{(gnu services shepherd)} module provides a way to define
  28803. services managed by the GNU@tie{}Shepherd, which is the
  28804. initialization system---the first process that is started when the
  28805. system boots, also known as PID@tie{}1
  28806. (@pxref{Introduction,,, shepherd, The GNU Shepherd Manual}).
  28807. Services in the Shepherd can depend on each other. For instance, the
  28808. SSH daemon may need to be started after the syslog daemon has been
  28809. started, which in turn can only happen once all the file systems have
  28810. been mounted. The simple operating system defined earlier (@pxref{Using
  28811. the Configuration System}) results in a service graph like this:
  28812. @image{images/shepherd-graph,,5in,Typical shepherd service graph.}
  28813. You can actually generate such a graph for any operating system
  28814. definition using the @command{guix system shepherd-graph} command
  28815. (@pxref{system-shepherd-graph, @command{guix system shepherd-graph}}).
  28816. The @code{%shepherd-root-service} is a service object representing
  28817. PID@tie{}1, of type @code{shepherd-root-service-type}; it can be extended
  28818. by passing it lists of @code{<shepherd-service>} objects.
  28819. @deftp {Data Type} shepherd-service
  28820. The data type representing a service managed by the Shepherd.
  28821. @table @asis
  28822. @item @code{provision}
  28823. This is a list of symbols denoting what the service provides.
  28824. These are the names that may be passed to @command{herd start},
  28825. @command{herd status}, and similar commands (@pxref{Invoking herd,,,
  28826. shepherd, The GNU Shepherd Manual}). @xref{Slots of services, the
  28827. @code{provides} slot,, shepherd, The GNU Shepherd Manual}, for details.
  28828. @item @code{requirement} (default: @code{'()})
  28829. List of symbols denoting the Shepherd services this one depends on.
  28830. @cindex one-shot services, for the Shepherd
  28831. @item @code{one-shot?} (default: @code{#f})
  28832. Whether this service is @dfn{one-shot}. One-shot services stop immediately
  28833. after their @code{start} action has completed. @xref{Slots of services,,,
  28834. shepherd, The GNU Shepherd Manual}, for more info.
  28835. @item @code{respawn?} (default: @code{#t})
  28836. Whether to restart the service when it stops, for instance when the
  28837. underlying process dies.
  28838. @item @code{start}
  28839. @itemx @code{stop} (default: @code{#~(const #f)})
  28840. The @code{start} and @code{stop} fields refer to the Shepherd's
  28841. facilities to start and stop processes (@pxref{Service De- and
  28842. Constructors,,, shepherd, The GNU Shepherd Manual}). They are given as
  28843. G-expressions that get expanded in the Shepherd configuration file
  28844. (@pxref{G-Expressions}).
  28845. @item @code{actions} (default: @code{'()})
  28846. @cindex actions, of Shepherd services
  28847. This is a list of @code{shepherd-action} objects (see below) defining
  28848. @dfn{actions} supported by the service, in addition to the standard
  28849. @code{start} and @code{stop} actions. Actions listed here become available as
  28850. @command{herd} sub-commands:
  28851. @example
  28852. herd @var{action} @var{service} [@var{arguments}@dots{}]
  28853. @end example
  28854. @item @code{auto-start?} (default: @code{#t})
  28855. Whether this service should be started automatically by the Shepherd. If it
  28856. is @code{#f} the service has to be started manually with @code{herd start}.
  28857. @item @code{documentation}
  28858. A documentation string, as shown when running:
  28859. @example
  28860. herd doc @var{service-name}
  28861. @end example
  28862. where @var{service-name} is one of the symbols in @code{provision}
  28863. (@pxref{Invoking herd,,, shepherd, The GNU Shepherd Manual}).
  28864. @item @code{modules} (default: @code{%default-modules})
  28865. This is the list of modules that must be in scope when @code{start} and
  28866. @code{stop} are evaluated.
  28867. @end table
  28868. @end deftp
  28869. The example below defines a Shepherd service that spawns
  28870. @command{syslogd}, the system logger from the GNU Networking Utilities
  28871. (@pxref{syslogd invocation, @command{syslogd},, inetutils, GNU
  28872. Inetutils}):
  28873. @example
  28874. (let ((config (plain-file "syslogd.conf" "@dots{}")))
  28875. (shepherd-service
  28876. (documentation "Run the syslog daemon (syslogd).")
  28877. (provision '(syslogd))
  28878. (requirement '(user-processes))
  28879. (start #~(make-forkexec-constructor
  28880. (list #$(file-append inetutils "/libexec/syslogd")
  28881. "--rcfile" #$config)
  28882. #:pid-file "/var/run/syslog.pid"))
  28883. (stop #~(make-kill-destructor))))
  28884. @end example
  28885. Key elements in this example are the @code{start} and @code{stop}
  28886. fields: they are @dfn{staged} code snippets that use the
  28887. @code{make-forkexec-constructor} procedure provided by the Shepherd and
  28888. its dual, @code{make-kill-destructor} (@pxref{Service De- and
  28889. Constructors,,, shepherd, The GNU Shepherd Manual}). The @code{start}
  28890. field will have @command{shepherd} spawn @command{syslogd} with the
  28891. given option; note that we pass @code{config} after @option{--rcfile},
  28892. which is a configuration file declared above (contents of this file are
  28893. omitted). Likewise, the @code{stop} field tells how this service is to
  28894. be stopped; in this case, it is stopped by making the @code{kill} system
  28895. call on its PID@. Code staging is achieved using G-expressions:
  28896. @code{#~} stages code, while @code{#$} ``escapes'' back to host code
  28897. (@pxref{G-Expressions}).
  28898. @deftp {Data Type} shepherd-action
  28899. This is the data type that defines additional actions implemented by a
  28900. Shepherd service (see above).
  28901. @table @code
  28902. @item name
  28903. Symbol naming the action.
  28904. @item documentation
  28905. This is a documentation string for the action. It can be viewed by running:
  28906. @example
  28907. herd doc @var{service} action @var{action}
  28908. @end example
  28909. @item procedure
  28910. This should be a gexp that evaluates to a procedure of at least one argument,
  28911. which is the ``running value'' of the service (@pxref{Slots of services,,,
  28912. shepherd, The GNU Shepherd Manual}).
  28913. @end table
  28914. The following example defines an action called @code{say-hello} that kindly
  28915. greets the user:
  28916. @lisp
  28917. (shepherd-action
  28918. (name 'say-hello)
  28919. (documentation "Say hi!")
  28920. (procedure #~(lambda (running . args)
  28921. (format #t "Hello, friend! arguments: ~s\n"
  28922. args)
  28923. #t)))
  28924. @end lisp
  28925. Assuming this action is added to the @code{example} service, then you can do:
  28926. @example
  28927. # herd say-hello example
  28928. Hello, friend! arguments: ()
  28929. # herd say-hello example a b c
  28930. Hello, friend! arguments: ("a" "b" "c")
  28931. @end example
  28932. This, as you can see, is a fairly sophisticated way to say hello.
  28933. @xref{Service Convenience,,, shepherd, The GNU Shepherd Manual}, for more
  28934. info on actions.
  28935. @end deftp
  28936. @defvr {Scheme Variable} shepherd-root-service-type
  28937. The service type for the Shepherd ``root service''---i.e., PID@tie{}1.
  28938. This is the service type that extensions target when they want to create
  28939. shepherd services (@pxref{Service Types and Services}, for an example).
  28940. Each extension must pass a list of @code{<shepherd-service>}. Its
  28941. value must be a @code{shepherd-configuration}, as described below.
  28942. @end defvr
  28943. @deftp {Data Type} shepherd-configuration
  28944. This data type represents the Shepherd's configuration.
  28945. @table @code
  28946. @item shepherd (default: @code{shepherd})
  28947. The Shepherd package to use.
  28948. @item services (default: @code{'()})
  28949. A list of @code{<shepherd-service>} to start.
  28950. You should probably use the service extension
  28951. mechanism instead (@pxref{Shepherd Services}).
  28952. @end table
  28953. @end deftp
  28954. The following example specifies the Shepherd package for the operating
  28955. system:
  28956. @lisp
  28957. (operating-system
  28958. ;; ...
  28959. (services (append (list openssh-service-type))
  28960. ;; ...
  28961. %desktop-services)
  28962. ;; ...
  28963. ;; Use own Shepherd package.
  28964. (essential-services
  28965. (modify-services (operating-system-default-essential-services
  28966. this-operating-system)
  28967. (shepherd-root-service-type config => (shepherd-configuration
  28968. (inherit config)
  28969. (shepherd my-shepherd))))))
  28970. @end lisp
  28971. @defvr {Scheme Variable} %shepherd-root-service
  28972. This service represents PID@tie{}1.
  28973. @end defvr
  28974. @node Complex Configurations
  28975. @subsection Complex Configurations
  28976. @cindex complex configurations
  28977. Some programs might have rather complex configuration files or formats,
  28978. and to make it easier to create Scheme bindings for these configuration
  28979. files, you can use the utilities defined in the @code{(gnu services
  28980. configuration)} module.
  28981. The main utility is the @code{define-configuration} macro, which you
  28982. will use to define a Scheme record type (@pxref{Record Overview,,,
  28983. guile, GNU Guile Reference Manual}). The Scheme record will be
  28984. serialized to a configuration file by using @dfn{serializers}, which are
  28985. procedures that take some kind of Scheme value and returns a
  28986. G-expression (@pxref{G-Expressions}), which should, once serialized to
  28987. the disk, return a string. More details are listed below.
  28988. @deffn {Scheme Syntax} define-configuration @var{name} @var{clause1} @
  28989. @var{clause2} ...
  28990. Create a record type named @code{@var{name}} that contains the
  28991. fields found in the clauses.
  28992. A clause can have one of the following forms:
  28993. @example
  28994. (@var{field-name}
  28995. (@var{type} @var{default-value})
  28996. @var{documentation})
  28997. (@var{field-name}
  28998. (@var{type} @var{default-value})
  28999. @var{documentation}
  29000. @var{serializer})
  29001. (@var{field-name}
  29002. (@var{type})
  29003. @var{documentation})
  29004. (@var{field-name}
  29005. (@var{type})
  29006. @var{documentation}
  29007. @var{serializer})
  29008. @end example
  29009. @var{field-name} is an identifier that denotes the name of the field in
  29010. the generated record.
  29011. @var{type} is the type of the value corresponding to @var{field-name};
  29012. since Guile is untyped, a predicate
  29013. procedure---@code{@var{type}?}---will be called on the value
  29014. corresponding to the field to ensure that the value is of the correct
  29015. type. This means that if say, @var{type} is @code{package}, then a
  29016. procedure named @code{package?} will be applied on the value to make
  29017. sure that it is indeed a @code{<package>} object.
  29018. @var{default-value} is the default value corresponding to the field; if
  29019. none is specified, the user is forced to provide a value when creating
  29020. an object of the record type.
  29021. @c XXX: Should these be full sentences or are they allow to be very
  29022. @c short like package synopses?
  29023. @var{documentation} is a string formatted with Texinfo syntax which
  29024. should provide a description of what setting this field does.
  29025. @var{serializer} is the name of a procedure which takes two arguments,
  29026. the first is the name of the field, and the second is the value
  29027. corresponding to the field. The procedure should return a string or
  29028. G-expression (@pxref{G-Expressions}) that represents the content that
  29029. will be serialized to the configuration file. If none is specified, a
  29030. procedure of the name @code{serialize-@var{type}} will be used.
  29031. A simple serializer procedure could look like this:
  29032. @lisp
  29033. (define (serialize-boolean field-name value)
  29034. (let ((value (if value "true" "false")))
  29035. #~(string-append #$field-name #$value)))
  29036. @end lisp
  29037. In some cases multiple different configuration records might be defined
  29038. in the same file, but their serializers for the same type might have to
  29039. be different, because they have different configuration formats. For
  29040. example, the @code{serialize-boolean} procedure for the Getmail service
  29041. would have to be different for the one for the Transmission service. To
  29042. make it easier to deal with this situation, one can specify a serializer
  29043. prefix by using the @code{prefix} literal in the
  29044. @code{define-configuration} form. This means that one doesn't have to
  29045. manually specify a custom @var{serializer} for every field.
  29046. @lisp
  29047. (define (foo-serialize-string field-name value)
  29048. @dots{})
  29049. (define (bar-serialize-string field-name value)
  29050. @dots{})
  29051. (define-configuration foo-configuration
  29052. (label
  29053. (string)
  29054. "The name of label.")
  29055. (prefix foo-))
  29056. (define-configuration bar-configuration
  29057. (ip-address
  29058. (string)
  29059. "The IPv4 address for this device.")
  29060. (prefix bar-))
  29061. @end lisp
  29062. However, in some cases you might not want to serialize any of the values
  29063. of the record, to do this, you can use the @code{no-serialization}
  29064. literal. There is also the @code{define-configuration/no-serialization}
  29065. macro which is a shorthand of this.
  29066. @lisp
  29067. ;; Nothing will be serialized to disk.
  29068. (define-configuration foo-configuration
  29069. (field
  29070. (string "test")
  29071. "Some documentation.")
  29072. (no-serialization))
  29073. ;; The same thing as above.
  29074. (define-configuration/no-serialization bar-configuration
  29075. (field
  29076. (string "test")
  29077. "Some documentation."))
  29078. @end lisp
  29079. @end deffn
  29080. @deffn {Scheme Syntax} define-maybe @var{type}
  29081. Sometimes a field should not be serialized if the user doesn’t specify a
  29082. value. To achieve this, you can use the @code{define-maybe} macro to
  29083. define a ``maybe type''; if the value of a maybe type is set to the
  29084. @code{disabled}, it will not be serialized.
  29085. When defining a ``maybe type'', the corresponding serializer for the
  29086. regular type will be used by default. For example, a field of type
  29087. @code{maybe-string} will be serialized using the @code{serialize-string}
  29088. procedure by default, you can of course change this by specifying a
  29089. custom serializer procedure. Likewise, the type of the value would have
  29090. to be a string, unless it is set to the @code{disabled} symbol.
  29091. @lisp
  29092. (define-maybe string)
  29093. (define (serialize-string field-name value)
  29094. @dots{})
  29095. (define-configuration baz-configuration
  29096. (name
  29097. ;; Nothing will be serialized by default. If set to a string, the
  29098. ;; `serialize-string' procedure will be used to serialize the string.
  29099. (maybe-string 'disabled)
  29100. "The name of this module."))
  29101. @end lisp
  29102. Like with @code{define-configuration}, one can set a prefix for the
  29103. serializer name by using the @code{prefix} literal.
  29104. @lisp
  29105. (define-maybe integer
  29106. (prefix baz-))
  29107. (define (baz-serialize-interger field-name value)
  29108. @dots{})
  29109. @end lisp
  29110. There is also the @code{no-serialization} literal, which when set means
  29111. that no serializer will be defined for the ``maybe type'', regardless of
  29112. its value is @code{disabled} or not.
  29113. @code{define-maybe/no-serialization} is a shorthand for specifying the
  29114. @code{no-serialization} literal.
  29115. @lisp
  29116. (define-maybe/no-serialization symbol)
  29117. (define-configuration/no-serialization test-configuration
  29118. (mode
  29119. (maybe-symbol 'disabled)
  29120. "Docstring."))
  29121. @end lisp
  29122. @end deffn
  29123. @deffn {Scheme Procedure} serialize-configuration @var{configuration} @
  29124. @var{fields}
  29125. Return a G-expression that contains the values corresponding to the
  29126. @var{fields} of @var{configuration}, a record that has been generated by
  29127. @code{define-configuration}. The G-expression can then be serialized to
  29128. disk by using something like @code{mixed-text-file}.
  29129. @end deffn
  29130. @deffn {Scheme Procedure} validate-configuration @var{configuration}
  29131. @var{fields}
  29132. Type-check @var{fields}, a list of field names of @var{configuration}, a
  29133. configuration record created by @code{define-configuration}.
  29134. @end deffn
  29135. @deffn {Scheme Procedure} empty-serializer @var{field-name} @var{value}
  29136. A serializer that just returns an empty string. The
  29137. @code{serialize-package} procedure is an alias for this.
  29138. @end deffn
  29139. Once you have defined a configuration record, you will most likely also
  29140. want to document it so that other people know to use it. To help with
  29141. that, there are two procedures, both of which are documented below.
  29142. @deffn {Scheme Procedure} generate-documentation @var{documentation} @
  29143. @var{documentation-name}
  29144. Generate a Texinfo fragment from the docstrings in @var{documentation},
  29145. a list of @code{(@var{label} @var{fields} @var{sub-documentation} ...)}.
  29146. @var{label} should be a symbol and should be the name of the
  29147. configuration record. @var{fields} should be a list of all the fields
  29148. available for the configuration record.
  29149. @var{sub-documentation} is a @code{(@var{field-name}
  29150. @var{configuration-name})} tuple. @var{field-name} is the name of the
  29151. field which takes another configuration record as its value, and
  29152. @var{configuration-name} is the name of that configuration record.
  29153. @var{sub-documentation} is only needed if there are nested configuration
  29154. records. For example, the @code{getmail-configuration} record
  29155. (@pxref{Mail Services}) accepts a @code{getmail-configuration-file}
  29156. record in one of its @code{rcfile} field, therefore documentation for
  29157. @code{getmail-configuration-file} is nested in
  29158. @code{getmail-configuration}.
  29159. @lisp
  29160. (generate-documentation
  29161. `((getmail-configuration ,getmail-configuration-fields
  29162. (rcfile getmail-configuration-file))
  29163. @dots{})
  29164. 'getmail-configuration)
  29165. @end lisp
  29166. @var{documentation-name} should be a symbol and should be the name of
  29167. the configuration record.
  29168. @end deffn
  29169. @deffn {Scheme Procedure} configuration->documentation
  29170. @var{configuration-symbol}
  29171. Take @var{configuration-symbol}, the symbol corresponding to the name
  29172. used when defining a configuration record with
  29173. @code{define-configuration}, and print the Texinfo documentation of its
  29174. fields. This is useful if there aren’t any nested configuration records
  29175. since it only prints the documentation for the top-level fields.
  29176. @end deffn
  29177. As of right now, there is no automated way to generate documentation for
  29178. configuration records and put them in the manual. Instead, every
  29179. time you make a change to the docstrings of a configuration record, you
  29180. have to manually call @code{generate-documentation} or
  29181. @code{configuration->documentation}, and paste the output into the
  29182. @file{doc/guix.texi} file.
  29183. @c TODO: Actually test this
  29184. Below is an example of a record type created using
  29185. @code{define-configuration} and friends.
  29186. @lisp
  29187. (use-modules (gnu services)
  29188. (guix gexp)
  29189. (gnu services configuration)
  29190. (srfi srfi-26)
  29191. (srfi srfi-1))
  29192. ;; Turn field names, which are Scheme symbols into strings
  29193. (define (uglify-field-name field-name)
  29194. (let ((str (symbol->string field-name)))
  29195. ;; field? -> is-field
  29196. (if (string-suffix? "?" str)
  29197. (string-append "is-" (string-drop-right str 1))
  29198. str)))
  29199. (define (serialize-string field-name value)
  29200. #~(string-append #$(uglify-field-name field-name) " = " #$value "\n"))
  29201. (define (serialize-integer field-name value)
  29202. (serialize-string field-name (number->string value)))
  29203. (define (serialize-boolean field-name value)
  29204. (serialize-string field-name (if value "true" "false")))
  29205. (define (serialize-contact-name field-name value)
  29206. #~(string-append "\n[" #$value "]\n"))
  29207. (define (list-of-contact-configurations? lst)
  29208. (every contact-configuration? lst))
  29209. (define (serialize-list-of-contact-configurations field-name value)
  29210. #~(string-append #$@@(map (cut serialize-configuration <>
  29211. contact-configuration-fields)
  29212. value)))
  29213. (define (serialize-contacts-list-configuration configuration)
  29214. (mixed-text-file
  29215. "contactrc"
  29216. #~(string-append "[Owner]\n"
  29217. #$(serialize-configuration
  29218. configuration contacts-list-configuration-fields))))
  29219. (define-maybe integer)
  29220. (define-maybe string)
  29221. (define-configuration contact-configuration
  29222. (name
  29223. (string)
  29224. "The name of the contact."
  29225. serialize-contact-name)
  29226. (phone-number
  29227. (maybe-integer 'disabled)
  29228. "The person's phone number.")
  29229. (email
  29230. (maybe-string 'disabled)
  29231. "The person's email address.")
  29232. (married?
  29233. (boolean)
  29234. "Whether the person is married."))
  29235. (define-configuration contacts-list-configuration
  29236. (name
  29237. (string)
  29238. "The name of the owner of this contact list.")
  29239. (email
  29240. (string)
  29241. "The owner's email address.")
  29242. (contacts
  29243. (list-of-contact-configurations '())
  29244. "A list of @@code@{contact-configuation@} records which contain
  29245. information about all your contacts."))
  29246. @end lisp
  29247. A contacts list configuration could then be created like this:
  29248. @lisp
  29249. (define my-contacts
  29250. (contacts-list-configuration
  29251. (name "Alice")
  29252. (email "alice@@example.org")
  29253. (contacts
  29254. (list (contact-configuration
  29255. (name "Bob")
  29256. (phone-number 1234)
  29257. (email "bob@@gnu.org")
  29258. (married? #f))
  29259. (contact-configuration
  29260. (name "Charlie")
  29261. (phone-number 0000)
  29262. (married? #t))))))
  29263. @end lisp
  29264. After serializing the configuration to disk, the resulting file would
  29265. look like this:
  29266. @example
  29267. [owner]
  29268. name = Alice
  29269. email = alice@@example.org
  29270. [Bob]
  29271. phone-number = 1234
  29272. email = bob@@gnu.org
  29273. is-married = false
  29274. [Charlie]
  29275. phone-number = 0
  29276. is-married = true
  29277. @end example
  29278. @node Home Configuration
  29279. @chapter Home Configuration
  29280. @cindex home configuration
  29281. Guix supports declarative configuration of @dfn{home environments} by
  29282. utilizing the configuration mechanism described in the previous chapter
  29283. (@pxref{Defining Services}), but for user's dotfiles and packages. It
  29284. works both on Guix System and foreign distros and allows users to
  29285. declare all the packages and services that should be installed and
  29286. configured for the user. Once a user has written a file containing
  29287. @code{home-environment} record, such a configuration can be
  29288. @dfn{instantiated} by an unprivileged user with the @command{guix home}
  29289. command (@pxref{Invoking guix home}).
  29290. @c Maybe later, it will be possible to make home configuration a part of
  29291. @c system configuration to make everything managed by guix system.
  29292. @quotation Note
  29293. The functionality described in this section is still under development
  29294. and is subject to change. Get in touch with us on
  29295. @email{guix-devel@@gnu.org}!
  29296. @end quotation
  29297. The user's home environment usually consists of three basic parts:
  29298. software, configuration, and state. Software in mainstream distros are
  29299. usually installed system-wide, but with GNU Guix most software packages
  29300. can be installed on a per-user basis without needing root privileges,
  29301. and are thus considered part of the user’s @dfn{home environment}.
  29302. Packages on their own not very useful in many cases, because often they
  29303. require some additional configuration, usually config files that reside
  29304. in @env{XDG_CONFIG_HOME} (@file{~/.config} by default) or other
  29305. directories. Everything else can be considered state, like media files,
  29306. application databases, and logs.
  29307. Using Guix for managing home environments provides a number of
  29308. advantages:
  29309. @itemize
  29310. @item All software can be configured in one language (Guile Scheme),
  29311. this gives users the ability to share values between configurations of
  29312. different programs.
  29313. @item A well-defined home environment is self-contained and can be
  29314. created in a declarative and reproducible way---there is no need to grab
  29315. external binaries or manually edit some configuration file.
  29316. @item After every @command{guix home reconfigure} invocation, a new home
  29317. environment generation will be created. This means that users can
  29318. rollback to a previous home environment generation so they don’t have to
  29319. worry about breaking their configuration.
  29320. @item It is possible to manage stateful data with Guix Home, this
  29321. includes the ability to automatically clone Git repositories on the
  29322. initial setup of the machine, and periodically running commands like
  29323. @command{rsync} to sync data with another host. This functionality is
  29324. still in an experimental stage, though.
  29325. @end itemize
  29326. @menu
  29327. * Declaring the Home Environment:: Customizing your Home.
  29328. * Configuring the Shell:: Enabling home environment.
  29329. * Home Services:: Specifying home services.
  29330. * Invoking guix home:: Instantiating a home configuration.
  29331. @end menu
  29332. @node Declaring the Home Environment
  29333. @section Declaring the Home Environment
  29334. The home environment is configured by providing a
  29335. @code{home-environment} declaration in a file that can be passed to the
  29336. @command{guix home} command (@pxref{Invoking guix home}). The easiest
  29337. way to get started is by generating an initial configuration with
  29338. @command{guix home import}:
  29339. @example
  29340. guix home import ~/src/guix-config
  29341. @end example
  29342. The @command{guix home import} command reads some of the ``dot files''
  29343. such as @file{~/.bashrc} found in your home directory and copies them to
  29344. the given directory, @file{~/src/guix-config} in this case; it also
  29345. reads the contents of your profile, @file{~/.guix-profile}, and, based
  29346. on that, it populates @file{~/src/guix-config/home-configuration.scm}
  29347. with a Home configuration that resembles your current configuration.
  29348. A simple setup can include Bash and a custom text configuration, like in
  29349. the example below. Don't be afraid to declare home environment parts,
  29350. which overlaps with your current dot files: before installing any
  29351. configuration files, Guix Home will back up existing config files to a
  29352. separate place in the home directory.
  29353. @quotation Note
  29354. It is highly recommended that you manage your shell or shells with Guix
  29355. Home, because it will make sure that all the necessary scripts are
  29356. sourced by the shell configuration file. Otherwise you will need to do
  29357. it manually. (@pxref{Configuring the Shell}).
  29358. @end quotation
  29359. @findex home-environment
  29360. @lisp
  29361. @include he-config-bare-bones.scm
  29362. @end lisp
  29363. The @code{packages} field should be self-explanatory, it will install
  29364. the list of packages into the user's profile. The most important field
  29365. is @code{services}, it contains a list of @dfn{home services}, which are
  29366. the basic building blocks of a home environment.
  29367. There is no daemon (at least not necessarily) related to a home service,
  29368. a home service is just an element that is used to declare part of home
  29369. environment and extend other parts of it. The extension mechanism
  29370. discussed in the previous chapter (@pxref{Defining Services}) should not
  29371. be confused with Shepherd services (@pxref{Shepherd Services}). Using this extension
  29372. mechanism and some Scheme code that glues things together gives the user
  29373. the freedom to declare their own, very custom, home environments.
  29374. Once you have a configuration file that suits your needs, you can
  29375. reconfigure your home by running:
  29376. @example
  29377. guix home reconfigure config.scm
  29378. @end example
  29379. This ``builds'' your home environment and creates @file{~/.guix-home}
  29380. pointing to it. Voilà!
  29381. @quotation Note
  29382. Make sure the operating system has elogind, systemd, or a similar
  29383. mechanism to create the XDG run-time directory and has the
  29384. @env{XDG_RUNTIME_DIR} variable set. Failing that, the
  29385. @file{on-first-login} script will not execute anything, and processes
  29386. like user Shepherd and its descendants will not start.
  29387. @end quotation
  29388. @node Configuring the Shell
  29389. @section Configuring the Shell
  29390. This section is safe to skip if your shell or shells are managed by
  29391. Guix Home. Otherwise, read it carefully.
  29392. There are a few scripts that must be evaluated by a login shell to
  29393. activate the home environment. The shell startup files only read by
  29394. login shells often have @code{profile} suffix. For more information
  29395. about login shells see @ref{Invoking Bash,,, bash, The GNU Bash
  29396. Reference Manual} and see @ref{Bash Startup Files,,, bash, The GNU Bash
  29397. Reference Manual}.
  29398. The first script that needs to be sourced is @file{setup-environment},
  29399. which sets all the necessary environment variables (including variables
  29400. declared by the user) and the second one is @file{on-first-login}, which
  29401. starts Shepherd for the current user and performs actions declared by
  29402. other home services that extends
  29403. @code{home-run-on-first-login-service-type}.
  29404. Guix Home will always create @file{~/.profile}, which contains the
  29405. following lines:
  29406. @example
  29407. HOME_ENVIRONMENT=$HOME/.guix-home
  29408. . $HOME_ENVIRONMENT/setup-environment
  29409. $HOME_ENVIRONMENT/on-first-login
  29410. @end example
  29411. This makes POSIX compliant login shells activate the home environment.
  29412. However, in most cases this file won't be read by most modern shells,
  29413. because they are run in non POSIX mode by default and have their own
  29414. @file{*profile} startup files. For example Bash will prefer
  29415. @file{~/.bash_profile} in case it exists and only if it doesn't will it
  29416. fallback to @file{~/.profile}. Zsh (if no additional options are
  29417. specified) will ignore @file{~/.profile}, even if @file{~/.zprofile}
  29418. doesn't exist.
  29419. To make your shell respect @file{~/.profile}, add @code{. ~/.profile} or
  29420. @code{source ~/profile} to the startup file for the login shell. In
  29421. case of Bash, it is @file{~/.bash_profile}, and in case of Zsh, it is
  29422. @file{~/.zprofile}.
  29423. @quotation Note
  29424. This step is only required if your shell is NOT managed by Guix Home.
  29425. Otherwise, everything will be done automatically.
  29426. @end quotation
  29427. @node Home Services
  29428. @section Home Services
  29429. @cindex home services
  29430. A @dfn{home service} is not necessarily something that has a daemon and
  29431. is managed by Shepherd (@pxref{Jump Start,,, shepherd, The GNU Shepherd
  29432. Manual}), in most cases it doesn't. It's a simple building block of the
  29433. home environment, often declaring a set of packages to be installed in
  29434. the home environment profile, a set of config files to be symlinked into
  29435. @env{XDG_CONFIG_HOME} (@file{~/.config} by default), and environment
  29436. variables to be set by a login shell.
  29437. There is a service extension mechanism (@pxref{Service Composition})
  29438. which allows home services to extend other home services and utilize
  29439. capabilities they provide; for example: declare mcron jobs
  29440. (@pxref{Top,,, mcron, GNU@tie{}Mcron}) by extending @ref{Mcron Home
  29441. Service}; declare daemons by extending @ref{Shepherd Home Service}; add
  29442. commands, which will be invoked on by the Bash by extending
  29443. @ref{Shells Home Services, @code{home-bash-service-type}}.
  29444. A good way to discover available home services is using the
  29445. @command{guix home search} command (@pxref{Invoking guix home}). After
  29446. the required home services are found, include its module with the
  29447. @code{use-modules} form (@pxref{use-modules,, Using Guile Modules,
  29448. guile, The GNU Guile Reference Manual}), or the @code{#:use-modules}
  29449. directive (@pxref{define-module,, Creating Guile Modules, guile, The GNU
  29450. Guile Reference Manual}) and declare a home service using the
  29451. @code{service} function, or extend a service type by declaring a new
  29452. service with the @code{simple-service} procedure from @code{(gnu
  29453. services)}.
  29454. @menu
  29455. * Essential Home Services:: Environment variables, packages, on-* scripts.
  29456. * Shells: Shells Home Services. POSIX shells, Bash, Zsh.
  29457. * Mcron: Mcron Home Service. Scheduled User's Job Execution.
  29458. * Shepherd: Shepherd Home Service. Managing User's Daemons.
  29459. * Desktop: Desktop Home Services. Services for graphical environments.
  29460. @end menu
  29461. @c In addition to that Home Services can provide
  29462. @node Essential Home Services
  29463. @subsection Essential Home Services
  29464. There are a few essential home services defined in
  29465. @code{(gnu services)}, they are mostly for internal use and are required
  29466. to build a home environment, but some of them will be useful for the end
  29467. user.
  29468. @cindex environment variables
  29469. @defvr {Scheme Variable} home-environment-variables-service-type
  29470. The service of this type will be instantiated by every home environment
  29471. automatically by default, there is no need to define it, but someone may
  29472. want to extend it with a list of pairs to set some environment
  29473. variables.
  29474. @lisp
  29475. (list ("ENV_VAR1" . "value1")
  29476. ("ENV_VAR2" . "value2"))
  29477. @end lisp
  29478. The easiest way to extend a service type, without defining new service
  29479. type is to use the @code{simple-service} helper from @code{(gnu
  29480. services)}.
  29481. @lisp
  29482. (simple-service 'some-useful-env-vars-service
  29483. home-environment-variables-service-type
  29484. `(("LESSHISTFILE" . "$XDG_CACHE_HOME/.lesshst")
  29485. ("SHELL" . ,(file-append zsh "/bin/zsh"))
  29486. ("USELESS_VAR" . #f)
  29487. ("_JAVA_AWT_WM_NONREPARENTING" . #t)))
  29488. @end lisp
  29489. If you include such a service in you home environment definition, it
  29490. will add the following content to the @file{setup-environment} script
  29491. (which is expected to be sourced by the login shell):
  29492. @example
  29493. export LESSHISTFILE=$XDG_CACHE_HOME/.lesshst
  29494. export SHELL=/gnu/store/2hsg15n644f0glrcbkb1kqknmmqdar03-zsh-5.8/bin/zsh
  29495. export _JAVA_AWT_WM_NONREPARENTING
  29496. @end example
  29497. @quotation Note
  29498. Make sure that module @code{(gnu packages shells)} is imported with
  29499. @code{use-modules} or any other way, this namespace contains the
  29500. definition of the @code{zsh} packages, which is used in the example
  29501. above.
  29502. @end quotation
  29503. The association list (@pxref{Association Lists, alists, Association
  29504. Lists, guile, The GNU Guile Reference manual}) is a data structure
  29505. containing key-value pairs, for
  29506. @code{home-environment-variables-service-type} the key is always a
  29507. string, the value can be a string, string-valued gexp
  29508. (@pxref{G-Expressions}), file-like object (@pxref{G-Expressions,
  29509. file-like object}) or boolean. For gexps, the variable will be set to
  29510. the value of the gexp; for file-like objects, it will be set to the path
  29511. of the file in the store (@pxref{The Store}); for @code{#t}, it will
  29512. export the variable without any value; and for @code{#f}, it will omit
  29513. variable.
  29514. @end defvr
  29515. @defvr {Scheme Variable} home-profile-service-type
  29516. The service of this type will be instantiated by every home environment
  29517. automatically, there is no need to define it, but you may want to extend
  29518. it with a list of packages if you want to install additional packages
  29519. into your profile. Other services, which need to make some programs
  29520. available to the user will also extend this service type.
  29521. The extension value is just a list of packages:
  29522. @lisp
  29523. (list htop vim emacs)
  29524. @end lisp
  29525. The same approach as @code{simple-service} (@pxref{Service Reference,
  29526. simple-service}) for @code{home-environment-variables-service-type} can
  29527. be used here, too. Make sure that modules containing the specified
  29528. packages are imported with @code{use-modules}. To find a package or
  29529. information about its module use @command{guix search} (@pxref{Invoking
  29530. guix package}). Alternatively, @code{specification->package} can be
  29531. used to get the package record from string without importing related
  29532. module.
  29533. @end defvr
  29534. There are few more essential services, but users are not expected to
  29535. extend them.
  29536. @defvr {Scheme Variable} home-service-type
  29537. The root of home services DAG, it generates a folder, which later will be
  29538. symlinked to @file{~/.guix-home}, it contains configurations,
  29539. profile with binaries and libraries, and some necessary scripts to glue
  29540. things together.
  29541. @end defvr
  29542. @defvr {Scheme Variable} home-run-on-first-login-service-type
  29543. The service of this type generates a Guile script, which is expected to
  29544. be executed by the login shell. It is only executed if the special flag
  29545. file inside @env{XDG_RUNTIME_DIR} hasn't been created, this prevents
  29546. redundant executions of the script if multiple login shells are spawned.
  29547. It can be extended with a gexp. However, to autostart an application,
  29548. users @emph{should not} use this service, in most cases it's better to extend
  29549. @code{home-shepherd-service-type} with a Shepherd service
  29550. (@pxref{Shepherd Services}), or extend the shell's startup file with
  29551. the required command using the appropriate service type.
  29552. @end defvr
  29553. @defvr {Scheme Variable} home-activation-service-type
  29554. The service of this type generates a guile script, which runs on every
  29555. @command{guix home reconfigure} invocation or any other action, which
  29556. leads to the activation of the home environment.
  29557. @end defvr
  29558. @node Shells Home Services
  29559. @subsection Shells
  29560. @cindex shell
  29561. @cindex login shell
  29562. @cindex interactive shell
  29563. @cindex bash
  29564. @cindex zsh
  29565. Shells play a quite important role in the environment initialization
  29566. process, you can configure them manually as described in section
  29567. @ref{Configuring the Shell}, but the recommended way is to use home services
  29568. listed below. It's both easier and more reliable.
  29569. Each home environment instantiates
  29570. @code{home-shell-profile-service-type}, which creates a
  29571. @file{~/.profile} startup file for all POSIX-compatible shells. This
  29572. file contains all the necessary steps to properly initialize the
  29573. environment, but many modern shells like Bash or Zsh prefer their own
  29574. startup files, that's why the respective home services
  29575. (@code{home-bash-service-type} and @code{home-zsh-service-type}) ensure
  29576. that @file{~/.profile} is sourced by @file{~/.bash_profile} and
  29577. @file{~/.zprofile}, respectively.
  29578. @subsubheading Shell Profile Service
  29579. @deftp {Data Type} home-shell-profile-configuration
  29580. Available @code{home-shell-profile-configuration} fields are:
  29581. @table @asis
  29582. @item @code{profile} (default: @code{()}) (type: text-config)
  29583. @code{home-shell-profile} is instantiated automatically by
  29584. @code{home-environment}, DO NOT create this service manually, it can
  29585. only be extended. @code{profile} is a list of file-like objects, which
  29586. will go to @file{~/.profile}. By default @file{~/.profile} contains the
  29587. initialization code which must be evaluated by the login shell to make
  29588. home-environment's profile available to the user, but other commands can
  29589. be added to the file if it is really necessary. In most cases shell's
  29590. configuration files are preferred places for user's customizations.
  29591. Extend home-shell-profile service only if you really know what you do.
  29592. @end table
  29593. @end deftp
  29594. @subsubheading Bash Home Service
  29595. @anchor{home-bash-configuration}
  29596. @deftp {Data Type} home-bash-configuration
  29597. Available @code{home-bash-configuration} fields are:
  29598. @table @asis
  29599. @item @code{package} (default: @code{bash}) (type: package)
  29600. The Bash package to use.
  29601. @item @code{guix-defaults?} (default: @code{#t}) (type: boolean)
  29602. Add sane defaults like reading @file{/etc/bashrc} and coloring the output of
  29603. @command{ls} to the end of the @file{.bashrc} file.
  29604. @item @code{environment-variables} (default: @code{()}) (type: alist)
  29605. Association list of environment variables to set for the Bash session. The
  29606. rules for the @code{home-environment-variables-service-type} apply
  29607. here (@pxref{Essential Home Services}). The contents of this field will be
  29608. added after the contents of the @code{bash-profile} field.
  29609. @item @code{aliases} (default: @code{()}) (type: alist)
  29610. Association list of aliases to set for the Bash session. The aliases
  29611. will be defined after the contents of the @code{bashrc} field has been
  29612. put in the @file{.bashrc} file. The alias will automatically be quoted,
  29613. so something line this:
  29614. @lisp
  29615. '((\"ls\" . \"ls -alF\"))
  29616. @end lisp
  29617. turns into
  29618. @example
  29619. alias ls=\"ls -alF\"
  29620. @end example
  29621. @item @code{bash-profile} (default: @code{()}) (type: text-config)
  29622. List of file-like objects, which will be added to @file{.bash_profile}.
  29623. Used for executing user's commands at start of login shell (In most
  29624. cases the shell started on tty just after login). @file{.bash_login}
  29625. won't be ever read, because @file{.bash_profile} always present.
  29626. @item @code{bashrc} (default: @code{()}) (type: text-config)
  29627. List of file-like objects, which will be added to @file{.bashrc}. Used
  29628. for executing user's commands at start of interactive shell (The shell
  29629. for interactive usage started by typing @code{bash} or by terminal app
  29630. or any other program).
  29631. @item @code{bash-logout} (default: @code{()}) (type: text-config)
  29632. List of file-like objects, which will be added to @file{.bash_logout}.
  29633. Used for executing user's commands at the exit of login shell. It won't
  29634. be read in some cases (if the shell terminates by exec'ing another
  29635. process for example).
  29636. @end table
  29637. @end deftp
  29638. You can extend the Bash service by using the @code{home-bash-extension}
  29639. configuration record, whose fields most mirror that of
  29640. @code{home-bash-configuration} (@pxref{home-bash-configuration}). The
  29641. contents of the extensions will be added to the end of the corresponding
  29642. Bash configuration files (@pxref{Bash Startup Files,,, bash, The GNU
  29643. Bash Reference Manual}.
  29644. @deftp {Data Type} home-bash-extension
  29645. Available @code{home-bash-extension} fields are:
  29646. @table @asis
  29647. @item @code{environment-variables} (default: @code{()}) (type: alist)
  29648. Additional environment variables to set. These will be combined with the
  29649. environment variables from other extensions and the base service to form one
  29650. coherent block of environment variables.
  29651. @item @code{aliases} (default: @code{()}) (type: alist)
  29652. Additional aliases to set. These will be combined with the aliases from
  29653. other extensions and the base service.
  29654. @item @code{bash-profile} (default: @code{()}) (type: text-config)
  29655. Additional text blocks to add to @file{.bash_profile}, which will be combined
  29656. with text blocks from other extensions and the base service.
  29657. @item @code{bashrc} (default: @code{()}) (type: text-config)
  29658. Additional text blocks to add to @file{.bashrc}, which will be combined
  29659. with text blocks from other extensions and the base service.
  29660. @item @code{bash-logout} (default: @code{()}) (type: text-config)
  29661. Additional text blocks to add to @file{.bash_logout}, which will be combined
  29662. with text blocks from other extensions and the base service.
  29663. @end table
  29664. @end deftp
  29665. @subsubheading Zsh Home Service
  29666. @deftp {Data Type} home-zsh-configuration
  29667. Available @code{home-zsh-configuration} fields are:
  29668. @table @asis
  29669. @item @code{package} (default: @code{zsh}) (type: package)
  29670. The Zsh package to use.
  29671. @item @code{xdg-flavor?} (default: @code{#t}) (type: boolean)
  29672. Place all the configs to @file{$XDG_CONFIG_HOME/zsh}. Makes
  29673. @file{~/.zshenv} to set @env{ZDOTDIR} to @file{$XDG_CONFIG_HOME/zsh}.
  29674. Shell startup process will continue with
  29675. @file{$XDG_CONFIG_HOME/zsh/.zshenv}.
  29676. @item @code{environment-variables} (default: @code{()}) (type: alist)
  29677. Association list of environment variables to set for the Zsh session.
  29678. @item @code{zshenv} (default: @code{()}) (type: text-config)
  29679. List of file-like objects, which will be added to @file{.zshenv}. Used
  29680. for setting user's shell environment variables. Must not contain
  29681. commands assuming the presence of tty or producing output. Will be read
  29682. always. Will be read before any other file in @env{ZDOTDIR}.
  29683. @item @code{zprofile} (default: @code{()}) (type: text-config)
  29684. List of file-like objects, which will be added to @file{.zprofile}. Used
  29685. for executing user's commands at start of login shell (In most cases the
  29686. shell started on tty just after login). Will be read before
  29687. @file{.zlogin}.
  29688. @item @code{zshrc} (default: @code{()}) (type: text-config)
  29689. List of file-like objects, which will be added to @file{.zshrc}. Used
  29690. for executing user's commands at start of interactive shell (The shell
  29691. for interactive usage started by typing @code{zsh} or by terminal app or
  29692. any other program).
  29693. @item @code{zlogin} (default: @code{()}) (type: text-config)
  29694. List of file-like objects, which will be added to @file{.zlogin}. Used
  29695. for executing user's commands at the end of starting process of login
  29696. shell.
  29697. @item @code{zlogout} (default: @code{()}) (type: text-config)
  29698. List of file-like objects, which will be added to @file{.zlogout}. Used
  29699. for executing user's commands at the exit of login shell. It won't be
  29700. read in some cases (if the shell terminates by exec'ing another process
  29701. for example).
  29702. @end table
  29703. @end deftp
  29704. @node Mcron Home Service
  29705. @subsection Scheduled User's Job Execution
  29706. @cindex cron
  29707. @cindex mcron
  29708. @cindex scheduling jobs
  29709. The @code{(gnu home services mcron)} module provides an interface to
  29710. GNU@tie{}mcron, a daemon to run jobs at scheduled times (@pxref{Top,,,
  29711. mcron, GNU@tie{}mcron}). The information about system's mcron is
  29712. applicable here (@pxref{Scheduled Job Execution}), the only difference
  29713. for home services is that they have to be declared in a
  29714. @code{home-envirnoment} record instead of an @code{operating-system}
  29715. record.
  29716. @defvr {Scheme Variable} home-mcron-service-type
  29717. This is the type of the @code{mcron} home service, whose value is an
  29718. @code{home-mcron-configuration} object. It allows to manage scheduled
  29719. tasks.
  29720. This service type can be the target of a service extension that provides
  29721. additional job specifications (@pxref{Service Composition}). In other
  29722. words, it is possible to define services that provide additional mcron
  29723. jobs to run.
  29724. @end defvr
  29725. @deftp {Data Type} home-mcron-configuration
  29726. Data type representing the configuration of mcron.
  29727. @table @asis
  29728. @item @code{mcron} (default: @var{mcron})
  29729. The mcron package to use.
  29730. @item @code{jobs}
  29731. This is a list of gexps (@pxref{G-Expressions}), where each gexp
  29732. corresponds to an mcron job specification (@pxref{Syntax, mcron job
  29733. specifications,, mcron, GNU@tie{}mcron}).
  29734. @end table
  29735. @end deftp
  29736. @node Shepherd Home Service
  29737. @subsection Managing User Daemons
  29738. @cindex shepherd services, for users
  29739. The @code{(gnu home services shepherd)} module supports the definitions
  29740. of per-user Shepherd services (@pxref{Introduction,,, shepherd, The GNU
  29741. Shepherd Manual}). You extend @code{home-shepherd-service-type} with
  29742. new services; Guix Home then takes care of starting the @code{shepherd}
  29743. daemon for you when you log in, which in turns starts the services you
  29744. asked for.
  29745. @defvr {Scheme Variable} home-shepherd-service-type
  29746. The service type for the userland Shepherd, which allows one to manage
  29747. long-running processes or one-shot tasks. User's Shepherd is not an
  29748. init process (PID 1), but almost all other information described in
  29749. (@pxref{Shepherd Services}) is applicable here too.
  29750. This is the service type that extensions target when they want to create
  29751. shepherd services (@pxref{Service Types and Services}, for an example).
  29752. Each extension must pass a list of @code{<shepherd-service>}. Its
  29753. value must be a @code{home-shepherd-configuration}, as described below.
  29754. @end defvr
  29755. @deftp {Data Type} home-shepherd-configuration
  29756. This data type represents the Shepherd's configuration.
  29757. @table @code
  29758. @item shepherd (default: @code{shepherd})
  29759. The Shepherd package to use.
  29760. @item auto-start? (default: @code{#t})
  29761. Whether or not to start Shepherd on first login.
  29762. @item services (default: @code{'()})
  29763. A list of @code{<shepherd-service>} to start.
  29764. You should probably use the service extension
  29765. mechanism instead (@pxref{Shepherd Services}).
  29766. @end table
  29767. @end deftp
  29768. @node Desktop Home Services
  29769. @subsection Desktop Home Services
  29770. The @code{(gnu home services desktop)} module provides services that you
  29771. may find useful on ``desktop'' systems running a graphical user
  29772. environment such as Xorg.
  29773. @defvr {Scheme Variable} home-redshift-service-type
  29774. This is the service type for @uref{https://github.com/jonls/redshift,
  29775. Redshift}, a program that adjusts the display color temperature
  29776. according to the time of day. Its associated value must be a
  29777. @code{home-redshift-configuration} record, as shown below.
  29778. A typical configuration, where we manually specify the latitude and
  29779. longitude, might look like this:
  29780. @lisp
  29781. (service home-redshift-service-type
  29782. (home-redshift-configuration
  29783. (location-provider 'manual)
  29784. (latitude 35.81) ;northern hemisphere
  29785. (longitude -0.80))) ;west of Greenwich
  29786. @end lisp
  29787. @end defvr
  29788. @deftp {Data Type} home-redshift-configuration
  29789. Available @code{home-redshift-configuration} fields are:
  29790. @table @asis
  29791. @item @code{redshift} (default: @code{redshift}) (type: file-like)
  29792. Redshift package to use.
  29793. @item @code{location-provider} (default: @code{geoclue2}) (type: symbol)
  29794. Geolocation provider---@code{'manual} or @code{'geoclue2}. In the
  29795. former case, you must also specify the @code{latitude} and
  29796. @code{longitude} fields so Redshift can determine daytime at your place.
  29797. In the latter case, the Geoclue system service must be running; it will
  29798. be queried for location information.
  29799. @item @code{adjustment-method} (default: @code{randr}) (type: symbol)
  29800. Color adjustment method.
  29801. @item @code{daytime-temperature} (default: @code{6500}) (type: integer)
  29802. Daytime color temperature (kelvins).
  29803. @item @code{nighttime-temperature} (default: @code{4500}) (type: integer)
  29804. Nighttime color temperature (kelvins).
  29805. @item @code{daytime-brightness} (default: @code{disabled}) (type: maybe-inexact-number)
  29806. Daytime screen brightness, between 0.1 and 1.0.
  29807. @item @code{nighttime-brightness} (default: @code{disabled}) (type: maybe-inexact-number)
  29808. Nighttime screen brightness, between 0.1 and 1.0.
  29809. @item @code{latitude} (default: @code{disabled}) (type: maybe-inexact-number)
  29810. Latitude, when @code{location-provider} is @code{'manual}.
  29811. @item @code{longitude} (default: @code{disabled}) (type: maybe-inexact-number)
  29812. Longitude, when @code{location-provider} is @code{'manual}.
  29813. @item @code{dawn-time} (default: @code{disabled}) (type: maybe-string)
  29814. Custom time for the transition from night to day in the
  29815. morning---@code{"HH:MM"} format. When specified, solar elevation is not
  29816. used to determine the daytime/nighttime period.
  29817. @item @code{dusk-time} (default: @code{disabled}) (type: maybe-string)
  29818. Likewise, custom time for the transition from day to night in the
  29819. evening.
  29820. @item @code{extra-content} (default: @code{""}) (type: raw-configuration-string)
  29821. Extra content appended as-is to the Redshift configuration file. Run
  29822. @command{man redshift} for more information about the configuration file
  29823. format.
  29824. @end table
  29825. @end deftp
  29826. @node Invoking guix home
  29827. @section Invoking @code{guix home}
  29828. Once you have written a home environment declaration (@pxref{Declaring
  29829. the Home Environment,,,,}, it can be @dfn{instantiated} using the
  29830. @command{guix home} command. The synopsis is:
  29831. @example
  29832. guix home @var{options}@dots{} @var{action} @var{file}
  29833. @end example
  29834. @var{file} must be the name of a file containing a
  29835. @code{home-environment} declaration. @var{action} specifies how the
  29836. home environment is instantiated, but there are few auxiliary actions
  29837. which don't instantiate it. Currently the following values are
  29838. supported:
  29839. @table @code
  29840. @item search
  29841. Display available home service type definitions that match the given
  29842. regular expressions, sorted by relevance:
  29843. @cindex shell
  29844. @cindex shell-profile
  29845. @cindex bash
  29846. @cindex zsh
  29847. @example
  29848. $ guix home search shell
  29849. name: home-shell-profile
  29850. location: gnu/home/services/shells.scm:100:2
  29851. extends: home-files
  29852. description: Create `~/.profile', which is used for environment initialization of POSIX compliant login shells.
  29853. + This service type can be extended with a list of file-like objects.
  29854. relevance: 6
  29855. name: home-fish
  29856. location: gnu/home/services/shells.scm:640:2
  29857. extends: home-files home-profile
  29858. description: Install and configure Fish, the friendly interactive shell.
  29859. relevance: 3
  29860. name: home-zsh
  29861. location: gnu/home/services/shells.scm:290:2
  29862. extends: home-files home-profile
  29863. description: Install and configure Zsh.
  29864. relevance: 1
  29865. name: home-bash
  29866. location: gnu/home/services/shells.scm:508:2
  29867. extends: home-files home-profile
  29868. description: Install and configure GNU Bash.
  29869. relevance: 1
  29870. @dots{}
  29871. @end example
  29872. As for @command{guix search}, the result is written in
  29873. @code{recutils} format, which makes it easy to filter the output
  29874. (@pxref{Top, GNU recutils databases,, recutils, GNU recutils manual}).
  29875. @item reconfigure
  29876. Build the home environment described in @var{file}, and switch to it.
  29877. Switching means that the activation script will be evaluated and (in
  29878. basic scenario) symlinks to configuration files generated from
  29879. @code{home-environment} declaration will be created in @file{~}. If the
  29880. file with the same path already exists in home folder it will be moved
  29881. to @file{~/@var{timestamp}-guix-home-legacy-configs-backup}, where @var{timestamp}
  29882. is a current UNIX epoch time.
  29883. @quotation Note
  29884. It is highly recommended to run @command{guix pull} once before you run
  29885. @command{guix home reconfigure} for the first time (@pxref{Invoking guix
  29886. pull}).
  29887. @end quotation
  29888. This effects all the configuration specified in @var{file}. The command
  29889. starts Shepherd services specified in @var{file} that are not currently
  29890. running; if a service is currently running, this command will arrange
  29891. for it to be upgraded the next time it is stopped (e.g.@: by @code{herd
  29892. stop @var{service}} or @code{herd restart @var{service}}).
  29893. This command creates a new generation whose number is one greater than
  29894. the current generation (as reported by @command{guix home
  29895. list-generations}). If that generation already exists, it will be
  29896. overwritten. This behavior mirrors that of @command{guix package}
  29897. (@pxref{Invoking guix package}).
  29898. @cindex provenance tracking, of the home environment
  29899. Upon completion, the new home is deployed under @file{~/.guix-home}.
  29900. This directory contains @dfn{provenance meta-data}: the list of channels
  29901. in use (@pxref{Channels}) and @var{file} itself, when available. You
  29902. can view the provenance information by running:
  29903. @example
  29904. guix home describe
  29905. @end example
  29906. This information is useful should you later want to inspect how this
  29907. particular generation was built. In fact, assuming @var{file} is
  29908. self-contained, you can later rebuild generation @var{n} of your
  29909. home environment with:
  29910. @example
  29911. guix time-machine \
  29912. -C /var/guix/profiles/per-user/@var{USER}/guix-home-@var{n}-link/channels.scm -- \
  29913. home reconfigure \
  29914. /var/guix/profiles/per-user/@var{USER}/guix-home-@var{n}-link/configuration.scm
  29915. @end example
  29916. You can think of it as some sort of built-in version control! Your
  29917. home is not just a binary artifact: @emph{it carries its own source}.
  29918. @c @xref{Service Reference, @code{provenance-service-type}}, for more
  29919. @c information on provenance tracking.
  29920. @c @footnote{This action (and the related actions
  29921. @c @code{switch-generation} and @code{roll-back}) are usable after the
  29922. @c home environment is initialized.}.
  29923. @item switch-generation
  29924. @cindex home generations
  29925. Switch to an existing home generation. This action atomically switches
  29926. the home profile to the specified home generation.
  29927. The target generation can be specified explicitly by its generation
  29928. number. For example, the following invocation would switch to home
  29929. generation 7:
  29930. @example
  29931. guix home switch-generation 7
  29932. @end example
  29933. The target generation can also be specified relative to the current
  29934. generation with the form @code{+N} or @code{-N}, where @code{+3} means
  29935. ``3 generations ahead of the current generation,'' and @code{-1} means
  29936. ``1 generation prior to the current generation.'' When specifying a
  29937. negative value such as @code{-1}, you must precede it with @code{--} to
  29938. prevent it from being parsed as an option. For example:
  29939. @example
  29940. guix home switch-generation -- -1
  29941. @end example
  29942. This action will fail if the specified generation does not exist.
  29943. @item roll-back
  29944. @cindex rolling back
  29945. Switch to the preceding home generation. This is the inverse
  29946. of @command{reconfigure}, and it is exactly the same as invoking
  29947. @command{switch-generation} with an argument of @code{-1}.
  29948. @item delete-generations
  29949. @cindex deleting home generations
  29950. @cindex saving space
  29951. Delete home generations, making them candidates for garbage collection
  29952. (@pxref{Invoking guix gc}, for information on how to run the ``garbage
  29953. collector'').
  29954. This works in the same way as @samp{guix package --delete-generations}
  29955. (@pxref{Invoking guix package, @option{--delete-generations}}). With no
  29956. arguments, all home generations but the current one are deleted:
  29957. @example
  29958. guix home delete-generations
  29959. @end example
  29960. You can also select the generations you want to delete. The example below
  29961. deletes all the home generations that are more than two months old:
  29962. @example
  29963. guix home delete-generations 2m
  29964. @end example
  29965. @item build
  29966. Build the derivation of the home environment, which includes all the
  29967. configuration files and programs needed. This action does not actually
  29968. install anything.
  29969. @item describe
  29970. Describe the current home generation: its file name, as well as
  29971. provenance information when available.
  29972. @item list-generations
  29973. List a summary of each generation of the home environment available on
  29974. disk, in a human-readable way. This is similar to the
  29975. @option{--list-generations} option of @command{guix package}
  29976. (@pxref{Invoking guix package}).
  29977. Optionally, one can specify a pattern, with the same syntax that is used
  29978. in @command{guix package --list-generations}, to restrict the list of
  29979. generations displayed. For instance, the following command displays
  29980. generations that are up to 10 days old:
  29981. @example
  29982. $ guix home list-generations 10d
  29983. @end example
  29984. @item import
  29985. Generate a @dfn{home environment} from the packages in the default
  29986. profile and configuration files found in the user's home directory. The
  29987. configuration files will be copied to the specified directory, and a
  29988. @file{home-configuration.scm} will be populated with the home
  29989. environment. Note that not every home service that exists is supported
  29990. (@pxref{Home Services}).
  29991. @example
  29992. $ guix home import ~/guix-config
  29993. guix home: '/home/alice/guix-config' populated with all the Home configuration files
  29994. @end example
  29995. @end table
  29996. @var{options} can contain any of the common build options (@pxref{Common
  29997. Build Options}). In addition, @var{options} can contain one of the
  29998. following:
  29999. @table @option
  30000. @item --expression=@var{expr}
  30001. @itemx -e @var{expr}
  30002. Consider the home-environment @var{expr} evaluates to.
  30003. This is an alternative to specifying a file which evaluates to a home
  30004. environment.
  30005. @item --allow-downgrades
  30006. Instruct @command{guix home reconfigure} to allow system downgrades.
  30007. Just like @command{guix system}, @command{guix home reconfigure}, by
  30008. default, prevents you from downgrading your home to older or unrelated
  30009. revisions compared to the channel revisions that were used to deploy
  30010. it---those shown by @command{guix home describe}. Using
  30011. @option{--allow-downgrades} allows you to bypass that check, at the risk
  30012. of downgrading your home---be careful!
  30013. @end table
  30014. @node Documentation
  30015. @chapter Documentation
  30016. @cindex documentation, searching for
  30017. @cindex searching for documentation
  30018. @cindex Info, documentation format
  30019. @cindex man pages
  30020. @cindex manual pages
  30021. In most cases packages installed with Guix come with documentation.
  30022. There are two main documentation formats: ``Info'', a browsable
  30023. hypertext format used for GNU software, and ``manual pages'' (or ``man
  30024. pages''), the linear documentation format traditionally found on Unix.
  30025. Info manuals are accessed with the @command{info} command or with Emacs,
  30026. and man pages are accessed using @command{man}.
  30027. You can look for documentation of software installed on your system by
  30028. keyword. For example, the following command searches for information
  30029. about ``TLS'' in Info manuals:
  30030. @example
  30031. $ info -k TLS
  30032. "(emacs)Network Security" -- STARTTLS
  30033. "(emacs)Network Security" -- TLS
  30034. "(gnutls)Core TLS API" -- gnutls_certificate_set_verify_flags
  30035. "(gnutls)Core TLS API" -- gnutls_certificate_set_verify_function
  30036. @dots{}
  30037. @end example
  30038. @noindent
  30039. The command below searches for the same keyword in man
  30040. pages@footnote{The database searched by @command{man -k} is only created
  30041. in profiles that contain the @code{man-db} package.}:
  30042. @example
  30043. $ man -k TLS
  30044. SSL (7) - OpenSSL SSL/TLS library
  30045. certtool (1) - GnuTLS certificate tool
  30046. @dots {}
  30047. @end example
  30048. These searches are purely local to your computer so you have the
  30049. guarantee that documentation you find corresponds to what you have
  30050. actually installed, you can access it off-line, and your privacy is
  30051. respected.
  30052. Once you have these results, you can view the relevant documentation by
  30053. running, say:
  30054. @example
  30055. $ info "(gnutls)Core TLS API"
  30056. @end example
  30057. @noindent
  30058. or:
  30059. @example
  30060. $ man certtool
  30061. @end example
  30062. Info manuals contain sections and indices as well as hyperlinks like
  30063. those found in Web pages. The @command{info} reader (@pxref{Top, Info
  30064. reader,, info-stnd, Stand-alone GNU Info}) and its Emacs counterpart
  30065. (@pxref{Misc Help,,, emacs, The GNU Emacs Manual}) provide intuitive key
  30066. bindings to navigate manuals. @xref{Getting Started,,, info, Info: An
  30067. Introduction}, for an introduction to Info navigation.
  30068. @node Installing Debugging Files
  30069. @chapter Installing Debugging Files
  30070. @cindex debugging files
  30071. Program binaries, as produced by the GCC compilers for instance, are
  30072. typically written in the ELF format, with a section containing
  30073. @dfn{debugging information}. Debugging information is what allows the
  30074. debugger, GDB, to map binary code to source code; it is required to
  30075. debug a compiled program in good conditions.
  30076. This chapter explains how to use separate debug info when packages
  30077. provide it, and how to rebuild packages with debug info when it's
  30078. missing.
  30079. @menu
  30080. * Separate Debug Info:: Installing 'debug' outputs.
  30081. * Rebuilding Debug Info:: Building missing debug info.
  30082. @end menu
  30083. @node Separate Debug Info
  30084. @section Separate Debug Info
  30085. The problem with debugging information is that is takes up a fair amount
  30086. of disk space. For example, debugging information for the GNU C Library
  30087. weighs in at more than 60 MiB@. Thus, as a user, keeping all the
  30088. debugging info of all the installed programs is usually not an option.
  30089. Yet, space savings should not come at the cost of an impediment to
  30090. debugging---especially in the GNU system, which should make it easier
  30091. for users to exert their computing freedom (@pxref{GNU Distribution}).
  30092. Thankfully, the GNU Binary Utilities (Binutils) and GDB provide a
  30093. mechanism that allows users to get the best of both worlds: debugging
  30094. information can be stripped from the binaries and stored in separate
  30095. files. GDB is then able to load debugging information from those files,
  30096. when they are available (@pxref{Separate Debug Files,,, gdb, Debugging
  30097. with GDB}).
  30098. The GNU distribution takes advantage of this by storing debugging
  30099. information in the @code{lib/debug} sub-directory of a separate package
  30100. output unimaginatively called @code{debug} (@pxref{Packages with
  30101. Multiple Outputs}). Users can choose to install the @code{debug} output
  30102. of a package when they need it. For instance, the following command
  30103. installs the debugging information for the GNU C Library and for GNU
  30104. Guile:
  30105. @example
  30106. guix install glibc:debug guile:debug
  30107. @end example
  30108. GDB must then be told to look for debug files in the user's profile, by
  30109. setting the @code{debug-file-directory} variable (consider setting it
  30110. from the @file{~/.gdbinit} file, @pxref{Startup,,, gdb, Debugging with
  30111. GDB}):
  30112. @example
  30113. (gdb) set debug-file-directory ~/.guix-profile/lib/debug
  30114. @end example
  30115. From there on, GDB will pick up debugging information from the
  30116. @file{.debug} files under @file{~/.guix-profile/lib/debug}.
  30117. Below is an alternative GDB script which is useful when working with
  30118. other profiles. It takes advantage of the optional Guile integration in
  30119. GDB. This snippet is included by default on Guix System in the
  30120. @file{~/.gdbinit} file.
  30121. @example
  30122. guile
  30123. (use-modules (gdb))
  30124. (execute (string-append "set debug-file-directory "
  30125. (or (getenv "GDB_DEBUG_FILE_DIRECTORY")
  30126. "~/.guix-profile/lib/debug")))
  30127. end
  30128. @end example
  30129. In addition, you will most likely want GDB to be able to show the source
  30130. code being debugged. To do that, you will have to unpack the source
  30131. code of the package of interest (obtained with @code{guix build
  30132. --source}, @pxref{Invoking guix build}), and to point GDB to that source
  30133. directory using the @code{directory} command (@pxref{Source Path,
  30134. @code{directory},, gdb, Debugging with GDB}).
  30135. @c XXX: keep me up-to-date
  30136. The @code{debug} output mechanism in Guix is implemented by the
  30137. @code{gnu-build-system} (@pxref{Build Systems}). Currently, it is
  30138. opt-in---debugging information is available only for the packages with
  30139. definitions explicitly declaring a @code{debug} output. To check
  30140. whether a package has a @code{debug} output, use @command{guix package
  30141. --list-available} (@pxref{Invoking guix package}).
  30142. Read on for how to deal with packages lacking a @code{debug} output.
  30143. @node Rebuilding Debug Info
  30144. @section Rebuilding Debug Info
  30145. @cindex debugging info, rebuilding
  30146. As we saw above, some packages, but not all, provide debugging info in a
  30147. @code{debug} output. What can you do when debugging info is missing?
  30148. The @option{--with-debug-info} option provides a solution to that: it
  30149. allows you to rebuild the package(s) for which debugging info is
  30150. missing---and only those---and to graft those onto the application
  30151. you're debugging. Thus, while it's not as fast as installing a
  30152. @code{debug} output, it is relatively inexpensive.
  30153. Let's illustrate that. Suppose you're experiencing a bug in Inkscape
  30154. and would like to see what's going on in GLib, a library that's deep
  30155. down in its dependency graph. As it turns out, GLib does not have a
  30156. @code{debug} output and the backtrace GDB shows is all sadness:
  30157. @example
  30158. (gdb) bt
  30159. #0 0x00007ffff5f92190 in g_getenv ()
  30160. from /gnu/store/@dots{}-glib-2.62.6/lib/libglib-2.0.so.0
  30161. #1 0x00007ffff608a7d6 in gobject_init_ctor ()
  30162. from /gnu/store/@dots{}-glib-2.62.6/lib/libgobject-2.0.so.0
  30163. #2 0x00007ffff7fe275a in call_init (l=<optimized out>, argc=argc@@entry=1, argv=argv@@entry=0x7fffffffcfd8,
  30164. env=env@@entry=0x7fffffffcfe8) at dl-init.c:72
  30165. #3 0x00007ffff7fe2866 in call_init (env=0x7fffffffcfe8, argv=0x7fffffffcfd8, argc=1, l=<optimized out>)
  30166. at dl-init.c:118
  30167. @end example
  30168. To address that, you install Inkscape linked against a variant GLib that
  30169. contains debug info:
  30170. @example
  30171. guix install inkscape --with-debug-info=glib
  30172. @end example
  30173. This time, debugging will be a whole lot nicer:
  30174. @example
  30175. $ gdb --args sh -c 'exec inkscape'
  30176. @dots{}
  30177. (gdb) b g_getenv
  30178. Function "g_getenv" not defined.
  30179. Make breakpoint pending on future shared library load? (y or [n]) y
  30180. Breakpoint 1 (g_getenv) pending.
  30181. (gdb) r
  30182. Starting program: /gnu/store/@dots{}-profile/bin/sh -c exec\ inkscape
  30183. @dots{}
  30184. (gdb) bt
  30185. #0 g_getenv (variable=variable@@entry=0x7ffff60c7a2e "GOBJECT_DEBUG") at ../glib-2.62.6/glib/genviron.c:252
  30186. #1 0x00007ffff608a7d6 in gobject_init () at ../glib-2.62.6/gobject/gtype.c:4380
  30187. #2 gobject_init_ctor () at ../glib-2.62.6/gobject/gtype.c:4493
  30188. #3 0x00007ffff7fe275a in call_init (l=<optimized out>, argc=argc@@entry=3, argv=argv@@entry=0x7fffffffd088,
  30189. env=env@@entry=0x7fffffffd0a8) at dl-init.c:72
  30190. @dots{}
  30191. @end example
  30192. Much better!
  30193. Note that there can be packages for which @option{--with-debug-info}
  30194. will not have the desired effect. @xref{Package Transformation Options,
  30195. @option{--with-debug-info}}, for more information.
  30196. @node Security Updates
  30197. @chapter Security Updates
  30198. @cindex security updates
  30199. @cindex security vulnerabilities
  30200. Occasionally, important security vulnerabilities are discovered in software
  30201. packages and must be patched. Guix developers try hard to keep track of
  30202. known vulnerabilities and to apply fixes as soon as possible in the
  30203. @code{master} branch of Guix (we do not yet provide a ``stable'' branch
  30204. containing only security updates). The @command{guix lint} tool helps
  30205. developers find out about vulnerable versions of software packages in the
  30206. distribution:
  30207. @smallexample
  30208. $ guix lint -c cve
  30209. gnu/packages/base.scm:652:2: glibc@@2.21: probably vulnerable to CVE-2015-1781, CVE-2015-7547
  30210. gnu/packages/gcc.scm:334:2: gcc@@4.9.3: probably vulnerable to CVE-2015-5276
  30211. gnu/packages/image.scm:312:2: openjpeg@@2.1.0: probably vulnerable to CVE-2016-1923, CVE-2016-1924
  30212. @dots{}
  30213. @end smallexample
  30214. @xref{Invoking guix lint}, for more information.
  30215. Guix follows a functional
  30216. package management discipline (@pxref{Introduction}), which implies
  30217. that, when a package is changed, @emph{every package that depends on it}
  30218. must be rebuilt. This can significantly slow down the deployment of
  30219. fixes in core packages such as libc or Bash, since basically the whole
  30220. distribution would need to be rebuilt. Using pre-built binaries helps
  30221. (@pxref{Substitutes}), but deployment may still take more time than
  30222. desired.
  30223. @cindex grafts
  30224. To address this, Guix implements @dfn{grafts}, a mechanism that allows
  30225. for fast deployment of critical updates without the costs associated
  30226. with a whole-distribution rebuild. The idea is to rebuild only the
  30227. package that needs to be patched, and then to ``graft'' it onto packages
  30228. explicitly installed by the user and that were previously referring to
  30229. the original package. The cost of grafting is typically very low, and
  30230. order of magnitudes lower than a full rebuild of the dependency chain.
  30231. @cindex replacements of packages, for grafts
  30232. For instance, suppose a security update needs to be applied to Bash.
  30233. Guix developers will provide a package definition for the ``fixed''
  30234. Bash, say @code{bash-fixed}, in the usual way (@pxref{Defining
  30235. Packages}). Then, the original package definition is augmented with a
  30236. @code{replacement} field pointing to the package containing the bug fix:
  30237. @lisp
  30238. (define bash
  30239. (package
  30240. (name "bash")
  30241. ;; @dots{}
  30242. (replacement bash-fixed)))
  30243. @end lisp
  30244. From there on, any package depending directly or indirectly on Bash---as
  30245. reported by @command{guix gc --requisites} (@pxref{Invoking guix
  30246. gc})---that is installed is automatically ``rewritten'' to refer to
  30247. @code{bash-fixed} instead of @code{bash}. This grafting process takes
  30248. time proportional to the size of the package, usually less than a
  30249. minute for an ``average'' package on a recent machine. Grafting is
  30250. recursive: when an indirect dependency requires grafting, then grafting
  30251. ``propagates'' up to the package that the user is installing.
  30252. Currently, the length of the name and version of the graft and that of
  30253. the package it replaces (@code{bash-fixed} and @code{bash} in the example
  30254. above) must be equal. This restriction mostly comes from the fact that
  30255. grafting works by patching files, including binary files, directly.
  30256. Other restrictions may apply: for instance, when adding a graft to a
  30257. package providing a shared library, the original shared library and its
  30258. replacement must have the same @code{SONAME} and be binary-compatible.
  30259. The @option{--no-grafts} command-line option allows you to forcefully
  30260. avoid grafting (@pxref{Common Build Options, @option{--no-grafts}}).
  30261. Thus, the command:
  30262. @example
  30263. guix build bash --no-grafts
  30264. @end example
  30265. @noindent
  30266. returns the store file name of the original Bash, whereas:
  30267. @example
  30268. guix build bash
  30269. @end example
  30270. @noindent
  30271. returns the store file name of the ``fixed'', replacement Bash. This
  30272. allows you to distinguish between the two variants of Bash.
  30273. To verify which Bash your whole profile refers to, you can run
  30274. (@pxref{Invoking guix gc}):
  30275. @example
  30276. guix gc -R $(readlink -f ~/.guix-profile) | grep bash
  30277. @end example
  30278. @noindent
  30279. @dots{} and compare the store file names that you get with those above.
  30280. Likewise for a complete Guix system generation:
  30281. @example
  30282. guix gc -R $(guix system build my-config.scm) | grep bash
  30283. @end example
  30284. Lastly, to check which Bash running processes are using, you can use the
  30285. @command{lsof} command:
  30286. @example
  30287. lsof | grep /gnu/store/.*bash
  30288. @end example
  30289. @node Bootstrapping
  30290. @chapter Bootstrapping
  30291. @c Adapted from the ELS 2013 paper.
  30292. @cindex bootstrapping
  30293. Bootstrapping in our context refers to how the distribution gets built
  30294. ``from nothing''. Remember that the build environment of a derivation
  30295. contains nothing but its declared inputs (@pxref{Introduction}). So
  30296. there's an obvious chicken-and-egg problem: how does the first package
  30297. get built? How does the first compiler get compiled?
  30298. It is tempting to think of this question as one that only die-hard
  30299. hackers may care about. However, while the answer to that question is
  30300. technical in nature, its implications are wide-ranging. How the
  30301. distribution is bootstrapped defines the extent to which we, as
  30302. individuals and as a collective of users and hackers, can trust the
  30303. software we run. It is a central concern from the standpoint of
  30304. @emph{security} and from a @emph{user freedom} viewpoint.
  30305. @cindex bootstrap binaries
  30306. The GNU system is primarily made of C code, with libc at its core. The
  30307. GNU build system itself assumes the availability of a Bourne shell and
  30308. command-line tools provided by GNU Coreutils, Awk, Findutils, `sed', and
  30309. `grep'. Furthermore, build programs---programs that run
  30310. @code{./configure}, @code{make}, etc.---are written in Guile Scheme
  30311. (@pxref{Derivations}). Consequently, to be able to build anything at
  30312. all, from scratch, Guix relies on pre-built binaries of Guile, GCC,
  30313. Binutils, libc, and the other packages mentioned above---the
  30314. @dfn{bootstrap binaries}.
  30315. These bootstrap binaries are ``taken for granted'', though we can also
  30316. re-create them if needed (@pxref{Preparing to Use the Bootstrap
  30317. Binaries}).
  30318. @menu
  30319. * Reduced Binary Seed Bootstrap:: A Bootstrap worthy of GNU.
  30320. * Preparing to Use the Bootstrap Binaries:: Building that what matters most.
  30321. @end menu
  30322. @node Reduced Binary Seed Bootstrap
  30323. @section The Reduced Binary Seed Bootstrap
  30324. Guix---like other GNU/Linux distributions---is traditionally bootstrapped from
  30325. a set of bootstrap binaries: Bourne shell, command-line tools provided by GNU
  30326. Coreutils, Awk, Findutils, `sed', and `grep' and Guile, GCC, Binutils, and the
  30327. GNU C Library (@pxref{Bootstrapping}). Usually, these bootstrap binaries are
  30328. ``taken for granted.''
  30329. Taking the bootstrap binaries for granted means that we consider them to
  30330. be a correct and trustworthy ``seed'' for building the complete system.
  30331. Therein lies a problem: the combined size of these bootstrap binaries is
  30332. about 250MB (@pxref{Bootstrappable Builds,,, mes, GNU Mes}). Auditing
  30333. or even inspecting these is next to impossible.
  30334. For @code{i686-linux} and @code{x86_64-linux}, Guix now features a
  30335. ``Reduced Binary Seed'' bootstrap @footnote{We would like to say: ``Full
  30336. Source Bootstrap'' and while we are working towards that goal it would
  30337. be hyperbole to use that term for what we do now.}.
  30338. The Reduced Binary Seed bootstrap removes the most critical tools---from a
  30339. trust perspective---from the bootstrap binaries: GCC, Binutils and the GNU C
  30340. Library are replaced by: @code{bootstrap-mescc-tools} (a tiny assembler and
  30341. linker) and @code{bootstrap-mes} (a small Scheme Interpreter and a C compiler
  30342. written in Scheme and the Mes C Library, built for TinyCC and for GCC).
  30343. Using these new binary seeds the ``missing'' Binutils, GCC, and the GNU
  30344. C Library are built from source. From here on the more traditional
  30345. bootstrap process resumes. This approach has reduced the bootstrap
  30346. binaries in size to about 145MB in Guix v1.1.
  30347. The next step that Guix has taken is to replace the shell and all its
  30348. utilities with implementations in Guile Scheme, the @emph{Scheme-only
  30349. bootstrap}. Gash (@pxref{Gash,,, gash, The Gash manual}) is a
  30350. POSIX-compatible shell that replaces Bash, and it comes with Gash Utils
  30351. which has minimalist replacements for Awk, the GNU Core Utilities, Grep,
  30352. Gzip, Sed, and Tar. The rest of the bootstrap binary seeds that were
  30353. removed are now built from source.
  30354. Building the GNU System from source is currently only possible by adding
  30355. some historical GNU packages as intermediate steps@footnote{Packages
  30356. such as @code{gcc-2.95.3}, @code{binutils-2.14}, @code{glibc-2.2.5},
  30357. @code{gzip-1.2.4}, @code{tar-1.22}, and some others. For details, see
  30358. @file{gnu/packages/commencement.scm}.}. As Gash and Gash Utils mature,
  30359. and GNU packages become more bootstrappable again (e.g., new releases of
  30360. GNU Sed will also ship as gzipped tarballs again, as alternative to the
  30361. hard to bootstrap @code{xz}-compression), this set of added packages can
  30362. hopefully be reduced again.
  30363. The graph below shows the resulting dependency graph for
  30364. @code{gcc-core-mesboot0}, the bootstrap compiler used for the
  30365. traditional bootstrap of the rest of the Guix System.
  30366. @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
  30367. @image{images/gcc-core-mesboot0-graph,6in,,Dependency graph of gcc-core-mesboot0}
  30368. The only significant binary bootstrap seeds that remain@footnote{
  30369. Ignoring the 68KB @code{mescc-tools}; that will be removed later,
  30370. together with @code{mes}.} are a Scheme interpreter and a Scheme
  30371. compiler: GNU Mes and GNU Guile@footnote{Not shown in this graph are the
  30372. static binaries for @file{bash}, @code{tar}, and @code{xz} that are used
  30373. to get Guile running.}.
  30374. This further reduction has brought down the size of the binary seed to
  30375. about 60MB for @code{i686-linux} and @code{x86_64-linux}.
  30376. Work is ongoing to remove all binary blobs from our free software
  30377. bootstrap stack, working towards a Full Source Bootstrap. Also ongoing
  30378. is work to bring these bootstraps to the @code{arm-linux} and
  30379. @code{aarch64-linux} architectures and to the Hurd.
  30380. If you are interested, join us on @samp{#bootstrappable} on the Freenode
  30381. IRC network or discuss on @email{bug-mes@@gnu.org} or
  30382. @email{gash-devel@@nongnu.org}.
  30383. @node Preparing to Use the Bootstrap Binaries
  30384. @section Preparing to Use the Bootstrap Binaries
  30385. @c As of Emacs 24.3, Info-mode displays the image, but since it's a
  30386. @c large image, it's hard to scroll. Oh well.
  30387. @image{images/bootstrap-graph,6in,,Dependency graph of the early bootstrap derivations}
  30388. The figure above shows the very beginning of the dependency graph of the
  30389. distribution, corresponding to the package definitions of the @code{(gnu
  30390. packages bootstrap)} module. A similar figure can be generated with
  30391. @command{guix graph} (@pxref{Invoking guix graph}), along the lines of:
  30392. @example
  30393. guix graph -t derivation \
  30394. -e '(@@@@ (gnu packages bootstrap) %bootstrap-gcc)' \
  30395. | dot -Tps > gcc.ps
  30396. @end example
  30397. or, for the further Reduced Binary Seed bootstrap
  30398. @example
  30399. guix graph -t derivation \
  30400. -e '(@@@@ (gnu packages bootstrap) %bootstrap-mes)' \
  30401. | dot -Tps > mes.ps
  30402. @end example
  30403. At this level of detail, things are
  30404. slightly complex. First, Guile itself consists of an ELF executable,
  30405. along with many source and compiled Scheme files that are dynamically
  30406. loaded when it runs. This gets stored in the @file{guile-2.0.7.tar.xz}
  30407. tarball shown in this graph. This tarball is part of Guix's ``source''
  30408. distribution, and gets inserted into the store with @code{add-to-store}
  30409. (@pxref{The Store}).
  30410. But how do we write a derivation that unpacks this tarball and adds it
  30411. to the store? To solve this problem, the @code{guile-bootstrap-2.0.drv}
  30412. derivation---the first one that gets built---uses @code{bash} as its
  30413. builder, which runs @code{build-bootstrap-guile.sh}, which in turn calls
  30414. @code{tar} to unpack the tarball. Thus, @file{bash}, @file{tar},
  30415. @file{xz}, and @file{mkdir} are statically-linked binaries, also part of
  30416. the Guix source distribution, whose sole purpose is to allow the Guile
  30417. tarball to be unpacked.
  30418. Once @code{guile-bootstrap-2.0.drv} is built, we have a functioning
  30419. Guile that can be used to run subsequent build programs. Its first task
  30420. is to download tarballs containing the other pre-built binaries---this
  30421. is what the @file{.tar.xz.drv} derivations do. Guix modules such as
  30422. @code{ftp-client.scm} are used for this purpose. The
  30423. @code{module-import.drv} derivations import those modules in a directory
  30424. in the store, using the original layout. The
  30425. @code{module-import-compiled.drv} derivations compile those modules, and
  30426. write them in an output directory with the right layout. This
  30427. corresponds to the @code{#:modules} argument of
  30428. @code{build-expression->derivation} (@pxref{Derivations}).
  30429. Finally, the various tarballs are unpacked by the derivations
  30430. @code{gcc-bootstrap-0.drv}, @code{glibc-bootstrap-0.drv}, or
  30431. @code{bootstrap-mes-0.drv} and @code{bootstrap-mescc-tools-0.drv}, at which
  30432. point we have a working C tool chain.
  30433. @unnumberedsec Building the Build Tools
  30434. Bootstrapping is complete when we have a full tool chain that does not
  30435. depend on the pre-built bootstrap tools discussed above. This
  30436. no-dependency requirement is verified by checking whether the files of
  30437. the final tool chain contain references to the @file{/gnu/store}
  30438. directories of the bootstrap inputs. The process that leads to this
  30439. ``final'' tool chain is described by the package definitions found in
  30440. the @code{(gnu packages commencement)} module.
  30441. The @command{guix graph} command allows us to ``zoom out'' compared to
  30442. the graph above, by looking at the level of package objects instead of
  30443. individual derivations---remember that a package may translate to
  30444. several derivations, typically one derivation to download its source,
  30445. one to build the Guile modules it needs, and one to actually build the
  30446. package from source. The command:
  30447. @example
  30448. guix graph -t bag \
  30449. -e '(@@@@ (gnu packages commencement)
  30450. glibc-final-with-bootstrap-bash)' | xdot -
  30451. @end example
  30452. @noindent
  30453. displays the dependency graph leading to the ``final'' C
  30454. library@footnote{You may notice the @code{glibc-intermediate} label,
  30455. suggesting that it is not @emph{quite} final, but as a good
  30456. approximation, we will consider it final.}, depicted below.
  30457. @image{images/bootstrap-packages,6in,,Dependency graph of the early packages}
  30458. @c See <https://lists.gnu.org/archive/html/gnu-system-discuss/2012-10/msg00000.html>.
  30459. The first tool that gets built with the bootstrap binaries is
  30460. GNU@tie{}Make---noted @code{make-boot0} above---which is a prerequisite
  30461. for all the following packages. From there Findutils and Diffutils get
  30462. built.
  30463. Then come the first-stage Binutils and GCC, built as pseudo cross
  30464. tools---i.e., with @option{--target} equal to @option{--host}. They are
  30465. used to build libc. Thanks to this cross-build trick, this libc is
  30466. guaranteed not to hold any reference to the initial tool chain.
  30467. From there the final Binutils and GCC (not shown above) are built. GCC
  30468. uses @command{ld} from the final Binutils, and links programs against
  30469. the just-built libc. This tool chain is used to build the other
  30470. packages used by Guix and by the GNU Build System: Guile, Bash,
  30471. Coreutils, etc.
  30472. And voilà! At this point we have the complete set of build tools that
  30473. the GNU Build System expects. These are in the @code{%final-inputs}
  30474. variable of the @code{(gnu packages commencement)} module, and are
  30475. implicitly used by any package that uses @code{gnu-build-system}
  30476. (@pxref{Build Systems, @code{gnu-build-system}}).
  30477. @unnumberedsec Building the Bootstrap Binaries
  30478. @cindex bootstrap binaries
  30479. Because the final tool chain does not depend on the bootstrap binaries,
  30480. those rarely need to be updated. Nevertheless, it is useful to have an
  30481. automated way to produce them, should an update occur, and this is what
  30482. the @code{(gnu packages make-bootstrap)} module provides.
  30483. The following command builds the tarballs containing the bootstrap binaries
  30484. (Binutils, GCC, glibc, for the traditional bootstrap and linux-libre-headers,
  30485. bootstrap-mescc-tools, bootstrap-mes for the Reduced Binary Seed bootstrap,
  30486. and Guile, and a tarball containing a mixture of Coreutils and other basic
  30487. command-line tools):
  30488. @example
  30489. guix build bootstrap-tarballs
  30490. @end example
  30491. The generated tarballs are those that should be referred to in the
  30492. @code{(gnu packages bootstrap)} module mentioned at the beginning of
  30493. this section.
  30494. Still here? Then perhaps by now you've started to wonder: when do we
  30495. reach a fixed point? That is an interesting question! The answer is
  30496. unknown, but if you would like to investigate further (and have
  30497. significant computational and storage resources to do so), then let us
  30498. know.
  30499. @unnumberedsec Reducing the Set of Bootstrap Binaries
  30500. Our traditional bootstrap includes GCC, GNU Libc, Guile, etc. That's a lot of
  30501. binary code! Why is that a problem? It's a problem because these big chunks
  30502. of binary code are practically non-auditable, which makes it hard to establish
  30503. what source code produced them. Every unauditable binary also leaves us
  30504. vulnerable to compiler backdoors as described by Ken Thompson in the 1984
  30505. paper @emph{Reflections on Trusting Trust}.
  30506. This is mitigated by the fact that our bootstrap binaries were generated
  30507. from an earlier Guix revision. Nevertheless it lacks the level of
  30508. transparency that we get in the rest of the package dependency graph,
  30509. where Guix always gives us a source-to-binary mapping. Thus, our goal
  30510. is to reduce the set of bootstrap binaries to the bare minimum.
  30511. The @uref{https://bootstrappable.org, Bootstrappable.org web site} lists
  30512. on-going projects to do that. One of these is about replacing the
  30513. bootstrap GCC with a sequence of assemblers, interpreters, and compilers
  30514. of increasing complexity, which could be built from source starting from
  30515. a simple and auditable assembler.
  30516. Our first major achievement is the replacement of of GCC, the GNU C Library
  30517. and Binutils by MesCC-Tools (a simple hex linker and macro assembler) and Mes
  30518. (@pxref{Top, GNU Mes Reference Manual,, mes, GNU Mes}, a Scheme interpreter
  30519. and C compiler in Scheme). Neither MesCC-Tools nor Mes can be fully
  30520. bootstrapped yet and thus we inject them as binary seeds. We call this the
  30521. Reduced Binary Seed bootstrap, as it has halved the size of our bootstrap
  30522. binaries! Also, it has eliminated the C compiler binary; i686-linux and
  30523. x86_64-linux Guix packages are now bootstrapped without any binary C compiler.
  30524. Work is ongoing to make MesCC-Tools and Mes fully bootstrappable and we are
  30525. also looking at any other bootstrap binaries. Your help is welcome!
  30526. @node Porting
  30527. @chapter Porting to a New Platform
  30528. As discussed above, the GNU distribution is self-contained, and
  30529. self-containment is achieved by relying on pre-built ``bootstrap
  30530. binaries'' (@pxref{Bootstrapping}). These binaries are specific to an
  30531. operating system kernel, CPU architecture, and application binary
  30532. interface (ABI). Thus, to port the distribution to a platform that is
  30533. not yet supported, one must build those bootstrap binaries, and update
  30534. the @code{(gnu packages bootstrap)} module to use them on that platform.
  30535. Fortunately, Guix can @emph{cross compile} those bootstrap binaries.
  30536. When everything goes well, and assuming the GNU tool chain supports the
  30537. target platform, this can be as simple as running a command like this
  30538. one:
  30539. @example
  30540. guix build --target=armv5tel-linux-gnueabi bootstrap-tarballs
  30541. @end example
  30542. For this to work, the @code{glibc-dynamic-linker} procedure in
  30543. @code{(gnu packages bootstrap)} must be augmented to return the right
  30544. file name for libc's dynamic linker on that platform; likewise,
  30545. @code{system->linux-architecture} in @code{(gnu packages linux)} must be
  30546. taught about the new platform.
  30547. Once these are built, the @code{(gnu packages bootstrap)} module needs
  30548. to be updated to refer to these binaries on the target platform. That
  30549. is, the hashes and URLs of the bootstrap tarballs for the new platform
  30550. must be added alongside those of the currently supported platforms. The
  30551. bootstrap Guile tarball is treated specially: it is expected to be
  30552. available locally, and @file{gnu/local.mk} has rules to download it for
  30553. the supported architectures; a rule for the new platform must be added
  30554. as well.
  30555. In practice, there may be some complications. First, it may be that the
  30556. extended GNU triplet that specifies an ABI (like the @code{eabi} suffix
  30557. above) is not recognized by all the GNU tools. Typically, glibc
  30558. recognizes some of these, whereas GCC uses an extra @option{--with-abi}
  30559. configure flag (see @code{gcc.scm} for examples of how to handle this).
  30560. Second, some of the required packages could fail to build for that
  30561. platform. Lastly, the generated binaries could be broken for some
  30562. reason.
  30563. @c *********************************************************************
  30564. @include contributing.texi
  30565. @c *********************************************************************
  30566. @node Acknowledgments
  30567. @chapter Acknowledgments
  30568. Guix is based on the @uref{https://nixos.org/nix/, Nix package manager},
  30569. which was designed and
  30570. implemented by Eelco Dolstra, with contributions from other people (see
  30571. the @file{nix/AUTHORS} file in Guix). Nix pioneered functional package
  30572. management, and promoted unprecedented features, such as transactional
  30573. package upgrades and rollbacks, per-user profiles, and referentially
  30574. transparent build processes. Without this work, Guix would not exist.
  30575. The Nix-based software distributions, Nixpkgs and NixOS, have also been
  30576. an inspiration for Guix.
  30577. GNU@tie{}Guix itself is a collective work with contributions from a
  30578. number of people. See the @file{AUTHORS} file in Guix for more
  30579. information on these fine people. The @file{THANKS} file lists people
  30580. who have helped by reporting bugs, taking care of the infrastructure,
  30581. providing artwork and themes, making suggestions, and more---thank you!
  30582. @c *********************************************************************
  30583. @node GNU Free Documentation License
  30584. @appendix GNU Free Documentation License
  30585. @cindex license, GNU Free Documentation License
  30586. @include fdl-1.3.texi
  30587. @c *********************************************************************
  30588. @node Concept Index
  30589. @unnumbered Concept Index
  30590. @printindex cp
  30591. @node Programming Index
  30592. @unnumbered Programming Index
  30593. @syncodeindex tp fn
  30594. @syncodeindex vr fn
  30595. @printindex fn
  30596. @bye
  30597. @c Local Variables:
  30598. @c ispell-local-dictionary: "american";
  30599. @c End: