guix.texi 885 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439
  1. \input texinfo
  2. @c -*-texinfo-*-
  3. @c %**start of header
  4. @setfilename guix.info
  5. @documentencoding UTF-8
  6. @settitle GNU Guix Reference Manual
  7. @c %**end of header
  8. @include version.texi
  9. @c Identifier of the OpenPGP key used to sign tarballs and such.
  10. @set OPENPGP-SIGNING-KEY-ID 3CE464558A84FDC69DB40CFB090B11993D9AEBB5
  11. @set KEY-SERVER pool.sks-keyservers.net
  12. @c The official substitute server used by default.
  13. @set SUBSTITUTE-SERVER ci.guix.info
  14. @copying
  15. Copyright @copyright{} 2012, 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès@*
  16. Copyright @copyright{} 2013, 2014, 2016 Andreas Enge@*
  17. Copyright @copyright{} 2013 Nikita Karetnikov@*
  18. Copyright @copyright{} 2014, 2015, 2016 Alex Kost@*
  19. Copyright @copyright{} 2015, 2016 Mathieu Lirzin@*
  20. Copyright @copyright{} 2014 Pierre-Antoine Rault@*
  21. Copyright @copyright{} 2015 Taylan Ulrich Bayırlı/Kammer@*
  22. Copyright @copyright{} 2015, 2016, 2017 Leo Famulari@*
  23. Copyright @copyright{} 2015, 2016, 2017, 2018 Ricardo Wurmus@*
  24. Copyright @copyright{} 2016 Ben Woodcroft@*
  25. Copyright @copyright{} 2016, 2017, 2018 Chris Marusich@*
  26. Copyright @copyright{} 2016, 2017, 2018 Efraim Flashner@*
  27. Copyright @copyright{} 2016 John Darrington@*
  28. Copyright @copyright{} 2016, 2017 Nils Gillmann@*
  29. Copyright @copyright{} 2016, 2017, 2018 Jan Nieuwenhuizen@*
  30. Copyright @copyright{} 2016 Julien Lepiller@*
  31. Copyright @copyright{} 2016 Alex ter Weele@*
  32. Copyright @copyright{} 2017, 2018 Clément Lassieur@*
  33. Copyright @copyright{} 2017, 2018 Mathieu Othacehe@*
  34. Copyright @copyright{} 2017 Federico Beffa@*
  35. Copyright @copyright{} 2017, 2018 Carlo Zancanaro@*
  36. Copyright @copyright{} 2017 Thomas Danckaert@*
  37. Copyright @copyright{} 2017 humanitiesNerd@*
  38. Copyright @copyright{} 2017 Christopher Allan Webber@*
  39. Copyright @copyright{} 2017, 2018 Marius Bakke@*
  40. Copyright @copyright{} 2017 Hartmut Goebel@*
  41. Copyright @copyright{} 2017 Maxim Cournoyer@*
  42. Copyright @copyright{} 2017, 2018 Tobias Geerinckx-Rice@*
  43. Copyright @copyright{} 2017 George Clemmer@*
  44. Copyright @copyright{} 2017 Andy Wingo@*
  45. Copyright @copyright{} 2017, 2018 Arun Isaac@*
  46. Copyright @copyright{} 2017 nee@*
  47. Copyright @copyright{} 2018 Rutger Helling@*
  48. Copyright @copyright{} 2018 Oleg Pykhalov@*
  49. Copyright @copyright{} 2018 Mike Gerwitz@*
  50. Copyright @copyright{} 2018 Pierre-Antoine Rouby@*
  51. Copyright @copyright{} 2018 Gábor Boskovits@*
  52. Copyright @copyright{} 2018 Florian Pelz@*
  53. Copyright @copyright{} 2018 Laura Lazzati@*
  54. Copyright @copyright{} 2018 Alex Vong@*
  55. Permission is granted to copy, distribute and/or modify this document
  56. under the terms of the GNU Free Documentation License, Version 1.3 or
  57. any later version published by the Free Software Foundation; with no
  58. Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
  59. copy of the license is included in the section entitled ``GNU Free
  60. Documentation License''.
  61. @end copying
  62. @dircategory System administration
  63. @direntry
  64. * Guix: (guix). Manage installed software and system configuration.
  65. * guix package: (guix)Invoking guix package. Installing, removing, and upgrading packages.
  66. * guix gc: (guix)Invoking guix gc. Reclaiming unused disk space.
  67. * guix pull: (guix)Invoking guix pull. Update the list of available packages.
  68. * guix system: (guix)Invoking guix system. Manage the operating system configuration.
  69. @end direntry
  70. @dircategory Software development
  71. @direntry
  72. * guix environment: (guix)Invoking guix environment. Building development environments with Guix.
  73. * guix build: (guix)Invoking guix build. Building packages.
  74. * guix pack: (guix)Invoking guix pack. Creating binary bundles.
  75. @end direntry
  76. @titlepage
  77. @title GNU Guix Reference Manual
  78. @subtitle Using the GNU Guix Functional Package Manager
  79. @author The GNU Guix Developers
  80. @page
  81. @vskip 0pt plus 1filll
  82. Edition @value{EDITION} @*
  83. @value{UPDATED} @*
  84. @insertcopying
  85. @end titlepage
  86. @contents
  87. @c *********************************************************************
  88. @node Top
  89. @top GNU Guix
  90. This document describes GNU Guix version @value{VERSION}, a functional
  91. package management tool written for the GNU system.
  92. @c TRANSLATORS: You can replace the following paragraph with information on
  93. @c how to join your own translation team and how to report issues with the
  94. @c translation.
  95. This manual is also available in French (@pxref{Top,,, guix.fr, Manuel de
  96. référence de GNU Guix}) and German (@pxref{Top,,, guix.de, Referenzhandbuch
  97. zu GNU Guix}). If you would like to translate it in your native language,
  98. consider joining the
  99. @uref{https://translationproject.org/domain/guix-manual.html, Translation
  100. Project}.
  101. @menu
  102. * Introduction:: What is Guix about?
  103. * Installation:: Installing Guix.
  104. * Package Management:: Package installation, upgrade, etc.
  105. * Programming Interface:: Using Guix in Scheme.
  106. * Utilities:: Package management commands.
  107. * GNU Distribution:: Software for your friendly GNU system.
  108. * Contributing:: Your help needed!
  109. * Acknowledgments:: Thanks!
  110. * GNU Free Documentation License:: The license of this manual.
  111. * Concept Index:: Concepts.
  112. * Programming Index:: Data types, functions, and variables.
  113. @detailmenu
  114. --- The Detailed Node Listing ---
  115. Installation
  116. * Binary Installation:: Getting Guix running in no time!
  117. * Requirements:: Software needed to build and run Guix.
  118. * Running the Test Suite:: Testing Guix.
  119. * Setting Up the Daemon:: Preparing the build daemon's environment.
  120. * Invoking guix-daemon:: Running the build daemon.
  121. * Application Setup:: Application-specific setup.
  122. Setting Up the Daemon
  123. * Build Environment Setup:: Preparing the isolated build environment.
  124. * Daemon Offload Setup:: Offloading builds to remote machines.
  125. * SELinux Support:: Using an SELinux policy for the daemon.
  126. Package Management
  127. * Features:: How Guix will make your life brighter.
  128. * Invoking guix package:: Package installation, removal, etc.
  129. * Substitutes:: Downloading pre-built binaries.
  130. * Packages with Multiple Outputs:: Single source package, multiple outputs.
  131. * Invoking guix gc:: Running the garbage collector.
  132. * Invoking guix pull:: Fetching the latest Guix and distribution.
  133. * Channels:: Customizing the package collection.
  134. * Inferiors:: Interacting with another revision of Guix.
  135. * Invoking guix describe:: Display information about your Guix revision.
  136. * Invoking guix pack:: Creating software bundles.
  137. * Invoking guix archive:: Exporting and importing store files.
  138. Substitutes
  139. * Official Substitute Server:: One particular source of substitutes.
  140. * Substitute Server Authorization:: How to enable or disable substitutes.
  141. * Substitute Authentication:: How Guix verifies substitutes.
  142. * Proxy Settings:: How to get substitutes via proxy.
  143. * Substitution Failure:: What happens when substitution fails.
  144. * On Trusting Binaries:: How can you trust that binary blob?
  145. Programming Interface
  146. * Defining Packages:: Defining new packages.
  147. * Build Systems:: Specifying how packages are built.
  148. * The Store:: Manipulating the package store.
  149. * Derivations:: Low-level interface to package derivations.
  150. * The Store Monad:: Purely functional interface to the store.
  151. * G-Expressions:: Manipulating build expressions.
  152. * Invoking guix repl:: Fiddling with Guix interactively.
  153. Defining Packages
  154. * package Reference:: The package data type.
  155. * origin Reference:: The origin data type.
  156. Utilities
  157. * Invoking guix build:: Building packages from the command line.
  158. * Invoking guix edit:: Editing package definitions.
  159. * Invoking guix download:: Downloading a file and printing its hash.
  160. * Invoking guix hash:: Computing the cryptographic hash of a file.
  161. * Invoking guix import:: Importing package definitions.
  162. * Invoking guix refresh:: Updating package definitions.
  163. * Invoking guix lint:: Finding errors in package definitions.
  164. * Invoking guix size:: Profiling disk usage.
  165. * Invoking guix graph:: Visualizing the graph of packages.
  166. * Invoking guix environment:: Setting up development environments.
  167. * Invoking guix publish:: Sharing substitutes.
  168. * Invoking guix challenge:: Challenging substitute servers.
  169. * Invoking guix copy:: Copying to and from a remote store.
  170. * Invoking guix container:: Process isolation.
  171. * Invoking guix weather:: Assessing substitute availability.
  172. * Invoking guix processes:: Listing client processes.
  173. Invoking @command{guix build}
  174. * Common Build Options:: Build options for most commands.
  175. * Package Transformation Options:: Creating variants of packages.
  176. * Additional Build Options:: Options specific to 'guix build'.
  177. * Debugging Build Failures:: Real life packaging experience.
  178. GNU Distribution
  179. * System Installation:: Installing the whole operating system.
  180. * System Configuration:: Configuring the operating system.
  181. * Documentation:: Browsing software user manuals.
  182. * Installing Debugging Files:: Feeding the debugger.
  183. * Security Updates:: Deploying security fixes quickly.
  184. * Package Modules:: Packages from the programmer's viewpoint.
  185. * Packaging Guidelines:: Growing the distribution.
  186. * Bootstrapping:: GNU/Linux built from scratch.
  187. * Porting:: Targeting another platform or kernel.
  188. System Installation
  189. * Limitations:: What you can expect.
  190. * Hardware Considerations:: Supported hardware.
  191. * USB Stick and DVD Installation:: Preparing the installation medium.
  192. * Preparing for Installation:: Networking, partitioning, etc.
  193. * Proceeding with the Installation:: The real thing.
  194. * Installing GuixSD in a VM:: GuixSD playground.
  195. * Building the Installation Image:: How this comes to be.
  196. System Configuration
  197. * Using the Configuration System:: Customizing your GNU system.
  198. * operating-system Reference:: Detail of operating-system declarations.
  199. * File Systems:: Configuring file system mounts.
  200. * Mapped Devices:: Block device extra processing.
  201. * User Accounts:: Specifying user accounts.
  202. * Locales:: Language and cultural convention settings.
  203. * Services:: Specifying system services.
  204. * Setuid Programs:: Programs running with root privileges.
  205. * X.509 Certificates:: Authenticating HTTPS servers.
  206. * Name Service Switch:: Configuring libc's name service switch.
  207. * Initial RAM Disk:: Linux-Libre bootstrapping.
  208. * Bootloader Configuration:: Configuring the boot loader.
  209. * Invoking guix system:: Instantiating a system configuration.
  210. * Running GuixSD in a VM:: How to run GuixSD in a virtual machine.
  211. * Defining Services:: Adding new service definitions.
  212. Services
  213. * Base Services:: Essential system services.
  214. * Scheduled Job Execution:: The mcron service.
  215. * Log Rotation:: The rottlog service.
  216. * Networking Services:: Network setup, SSH daemon, etc.
  217. * X Window:: Graphical display.
  218. * Printing Services:: Local and remote printer support.
  219. * Desktop Services:: D-Bus and desktop services.
  220. * Sound Services:: ALSA and Pulseaudio services.
  221. * Database Services:: SQL databases, key-value stores, etc.
  222. * Mail Services:: IMAP, POP3, SMTP, and all that.
  223. * Messaging Services:: Messaging services.
  224. * Telephony Services:: Telephony services.
  225. * Monitoring Services:: Monitoring services.
  226. * Kerberos Services:: Kerberos services.
  227. * Web Services:: Web servers.
  228. * Certificate Services:: TLS certificates via Let's Encrypt.
  229. * DNS Services:: DNS daemons.
  230. * VPN Services:: VPN daemons.
  231. * Network File System:: NFS related services.
  232. * Continuous Integration:: The Cuirass service.
  233. * Power Management Services:: Extending battery life.
  234. * Audio Services:: The MPD.
  235. * Virtualization Services:: Virtualization services.
  236. * Version Control Services:: Providing remote access to Git repositories.
  237. * Game Services:: Game servers.
  238. * Miscellaneous Services:: Other services.
  239. Defining Services
  240. * Service Composition:: The model for composing services.
  241. * Service Types and Services:: Types and services.
  242. * Service Reference:: API reference.
  243. * Shepherd Services:: A particular type of service.
  244. Packaging Guidelines
  245. * Software Freedom:: What may go into the distribution.
  246. * Package Naming:: What's in a name?
  247. * Version Numbers:: When the name is not enough.
  248. * Synopses and Descriptions:: Helping users find the right package.
  249. * Python Modules:: A touch of British comedy.
  250. * Perl Modules:: Little pearls.
  251. * Java Packages:: Coffee break.
  252. * Fonts:: Fond of fonts.
  253. Contributing
  254. * Building from Git:: The latest and greatest.
  255. * Running Guix Before It Is Installed:: Hacker tricks.
  256. * The Perfect Setup:: The right tools.
  257. * Coding Style:: Hygiene of the contributor.
  258. * Submitting Patches:: Share your work.
  259. Coding Style
  260. * Programming Paradigm:: How to compose your elements.
  261. * Modules:: Where to store your code?
  262. * Data Types and Pattern Matching:: Implementing data structures.
  263. * Formatting Code:: Writing conventions.
  264. @end detailmenu
  265. @end menu
  266. @c *********************************************************************
  267. @node Introduction
  268. @chapter Introduction
  269. @cindex purpose
  270. GNU Guix@footnote{``Guix'' is pronounced like ``geeks'', or ``ɡiːks''
  271. using the international phonetic alphabet (IPA).} is a package
  272. management tool for the GNU system. Guix makes it easy for unprivileged
  273. users to install, upgrade, or remove packages, to roll back to a
  274. previous package set, to build packages from source, and generally
  275. assists with the creation and maintenance of software environments.
  276. @cindex user interfaces
  277. Guix provides a command-line package management interface
  278. (@pxref{Invoking guix package}), a set of command-line utilities
  279. (@pxref{Utilities}), as well as Scheme programming interfaces
  280. (@pxref{Programming Interface}).
  281. @cindex build daemon
  282. Its @dfn{build daemon} is responsible for building packages on behalf of
  283. users (@pxref{Setting Up the Daemon}) and for downloading pre-built
  284. binaries from authorized sources (@pxref{Substitutes}).
  285. @cindex extensibility of the distribution
  286. @cindex customization, of packages
  287. Guix includes package definitions for many GNU and non-GNU packages, all
  288. of which @uref{https://www.gnu.org/philosophy/free-sw.html, respect the
  289. user's computing freedom}. It is @emph{extensible}: users can write
  290. their own package definitions (@pxref{Defining Packages}) and make them
  291. available as independent package modules (@pxref{Package Modules}). It
  292. is also @emph{customizable}: users can @emph{derive} specialized package
  293. definitions from existing ones, including from the command line
  294. (@pxref{Package Transformation Options}).
  295. @cindex Guix System Distribution
  296. @cindex GuixSD
  297. You can install GNU@tie{}Guix on top of an existing GNU/Linux system
  298. where it complements the available tools without interference
  299. (@pxref{Installation}), or you can use it as part of the standalone
  300. @dfn{Guix System Distribution} or GuixSD (@pxref{GNU Distribution}).
  301. With GNU@tie{}GuixSD, you @emph{declare} all aspects of the operating
  302. system configuration and Guix takes care of instantiating the
  303. configuration in a transactional, reproducible, and stateless fashion
  304. (@pxref{System Configuration}).
  305. @cindex functional package management
  306. @cindex isolation
  307. Under the hood, Guix implements the @dfn{functional package management}
  308. discipline pioneered by Nix (@pxref{Acknowledgments}).
  309. In Guix, the package build and installation process is seen
  310. as a @emph{function}, in the mathematical sense. That function takes inputs,
  311. such as build scripts, a compiler, and libraries, and
  312. returns an installed package. As a pure function, its result depends
  313. solely on its inputs---for instance, it cannot refer to software or
  314. scripts that were not explicitly passed as inputs. A build function
  315. always produces the same result when passed a given set of inputs. It
  316. cannot alter the environment of the running system in
  317. any way; for instance, it cannot create, modify, or delete files outside
  318. of its build and installation directories. This is achieved by running
  319. build processes in isolated environments (or @dfn{containers}), where only their
  320. explicit inputs are visible.
  321. @cindex store
  322. The result of package build functions is @dfn{cached} in the file
  323. system, in a special directory called @dfn{the store} (@pxref{The
  324. Store}). Each package is installed in a directory of its own in the
  325. store---by default under @file{/gnu/store}. The directory name contains
  326. a hash of all the inputs used to build that package; thus, changing an
  327. input yields a different directory name.
  328. This approach is the foundation for the salient features of Guix: support
  329. for transactional package upgrade and rollback, per-user installation, and
  330. garbage collection of packages (@pxref{Features}).
  331. @c *********************************************************************
  332. @node Installation
  333. @chapter Installation
  334. @cindex installing Guix
  335. @cindex official website
  336. GNU Guix is available for download from its website at
  337. @url{http://www.gnu.org/software/guix/}. This section describes the
  338. software requirements of Guix, as well as how to install it and get
  339. ready to use it.
  340. Note that this section is concerned with the installation of the package
  341. manager, which can be done on top of a running GNU/Linux system. If,
  342. instead, you want to install the complete GNU operating system,
  343. @pxref{System Installation}.
  344. @cindex foreign distro
  345. @cindex directories related to foreign distro
  346. When installed on a running GNU/Linux system---thereafter called a
  347. @dfn{foreign distro}---GNU@tie{}Guix complements the available tools
  348. without interference. Its data lives exclusively in two directories,
  349. usually @file{/gnu/store} and @file{/var/guix}; other files on your
  350. system, such as @file{/etc}, are left untouched.
  351. Once installed, Guix can be updated by running @command{guix pull}
  352. (@pxref{Invoking guix pull}).
  353. @menu
  354. * Binary Installation:: Getting Guix running in no time!
  355. * Requirements:: Software needed to build and run Guix.
  356. * Running the Test Suite:: Testing Guix.
  357. * Setting Up the Daemon:: Preparing the build daemon's environment.
  358. * Invoking guix-daemon:: Running the build daemon.
  359. * Application Setup:: Application-specific setup.
  360. @end menu
  361. @node Binary Installation
  362. @section Binary Installation
  363. @cindex installing Guix from binaries
  364. @cindex installer script
  365. This section describes how to install Guix on an arbitrary system from a
  366. self-contained tarball providing binaries for Guix and for all its
  367. dependencies. This is often quicker than installing from source, which
  368. is described in the next sections. The only requirement is to have
  369. GNU@tie{}tar and Xz.
  370. We provide a
  371. @uref{https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh,
  372. shell installer script}, which automates the download, installation, and
  373. initial configuration of Guix. It should be run as the root user.
  374. Installing goes along these lines:
  375. @enumerate
  376. @item
  377. @cindex downloading Guix binary
  378. Download the binary tarball from
  379. @indicateurl{https://alpha.gnu.org/gnu/guix/guix-binary-@value{VERSION}.@var{system}.tar.xz},
  380. where @var{system} is @code{x86_64-linux} for an @code{x86_64} machine
  381. already running the kernel Linux, and so on.
  382. @c The following is somewhat duplicated in ``System Installation''.
  383. Make sure to download the associated @file{.sig} file and to verify the
  384. authenticity of the tarball against it, along these lines:
  385. @example
  386. $ wget https://alpha.gnu.org/gnu/guix/guix-binary-@value{VERSION}.@var{system}.tar.xz.sig
  387. $ gpg --verify guix-binary-@value{VERSION}.@var{system}.tar.xz.sig
  388. @end example
  389. If that command fails because you do not have the required public key,
  390. then run this command to import it:
  391. @example
  392. $ gpg --keyserver @value{KEY-SERVER} \
  393. --recv-keys @value{OPENPGP-SIGNING-KEY-ID}
  394. @end example
  395. @noindent
  396. and rerun the @code{gpg --verify} command.
  397. @c end authentication part
  398. @item
  399. Now, you need to become the @code{root} user. Depending on your distribution,
  400. you may have to run @code{su -} or @code{sudo -i}. As @code{root}, run:
  401. @example
  402. # cd /tmp
  403. # tar --warning=no-timestamp -xf \
  404. guix-binary-@value{VERSION}.@var{system}.tar.xz
  405. # mv var/guix /var/ && mv gnu /
  406. @end example
  407. This creates @file{/gnu/store} (@pxref{The Store}) and @file{/var/guix}.
  408. The latter contains a ready-to-use profile for @code{root} (see next
  409. step.)
  410. Do @emph{not} unpack the tarball on a working Guix system since that
  411. would overwrite its own essential files.
  412. The @code{--warning=no-timestamp} option makes sure GNU@tie{}tar does
  413. not emit warnings about ``implausibly old time stamps'' (such
  414. warnings were triggered by GNU@tie{}tar 1.26 and older; recent
  415. versions are fine.)
  416. They stem from the fact that all the
  417. files in the archive have their modification time set to zero (which
  418. means January 1st, 1970.) This is done on purpose to make sure the
  419. archive content is independent of its creation time, thus making it
  420. reproducible.
  421. @item
  422. Make the profile available under @file{~root/.config/guix/current}, which is
  423. where @command{guix pull} will install updates (@pxref{Invoking guix pull}):
  424. @example
  425. # mkdir -p ~root/.config/guix
  426. # ln -sf /var/guix/profiles/per-user/root/current-guix \
  427. ~root/.config/guix/current
  428. @end example
  429. Source @file{etc/profile} to augment @code{PATH} and other relevant
  430. environment variables:
  431. @example
  432. # GUIX_PROFILE="`echo ~root`/.config/guix/current" ; \
  433. source $GUIX_PROFILE/etc/profile
  434. @end example
  435. @item
  436. Create the group and user accounts for build users as explained below
  437. (@pxref{Build Environment Setup}).
  438. @item
  439. Run the daemon, and set it to automatically start on boot.
  440. If your host distro uses the systemd init system, this can be achieved
  441. with these commands:
  442. @c Versions of systemd that supported symlinked service files are not
  443. @c yet widely deployed, so we should suggest that users copy the service
  444. @c files into place.
  445. @c
  446. @c See this thread for more information:
  447. @c http://lists.gnu.org/archive/html/guix-devel/2017-01/msg01199.html
  448. @example
  449. # cp ~root/.config/guix/current/lib/systemd/system/guix-daemon.service \
  450. /etc/systemd/system/
  451. # systemctl start guix-daemon && systemctl enable guix-daemon
  452. @end example
  453. If your host distro uses the Upstart init system:
  454. @example
  455. # initctl reload-configuration
  456. # cp ~root/.config/guix/current/lib/upstart/system/guix-daemon.conf \
  457. /etc/init/
  458. # start guix-daemon
  459. @end example
  460. Otherwise, you can still start the daemon manually with:
  461. @example
  462. # ~root/.config/guix/current/bin/guix-daemon \
  463. --build-users-group=guixbuild
  464. @end example
  465. @item
  466. Make the @command{guix} command available to other users on the machine,
  467. for instance with:
  468. @example
  469. # mkdir -p /usr/local/bin
  470. # cd /usr/local/bin
  471. # ln -s /var/guix/profiles/per-user/root/current-guix/bin/guix
  472. @end example
  473. It is also a good idea to make the Info version of this manual available
  474. there:
  475. @example
  476. # mkdir -p /usr/local/share/info
  477. # cd /usr/local/share/info
  478. # for i in /var/guix/profiles/per-user/root/current-guix/share/info/* ;
  479. do ln -s $i ; done
  480. @end example
  481. That way, assuming @file{/usr/local/share/info} is in the search path,
  482. running @command{info guix} will open this manual (@pxref{Other Info
  483. Directories,,, texinfo, GNU Texinfo}, for more details on changing the
  484. Info search path.)
  485. @item
  486. @cindex substitutes, authorization thereof
  487. To use substitutes from @code{hydra.gnu.org} or one of its mirrors
  488. (@pxref{Substitutes}), authorize them:
  489. @example
  490. # guix archive --authorize < \
  491. ~root/.config/guix/current/share/guix/hydra.gnu.org.pub
  492. @end example
  493. @item
  494. Each user may need to perform a few additional steps to make their Guix
  495. environment ready for use, @pxref{Application Setup}.
  496. @end enumerate
  497. Voilà, the installation is complete!
  498. You can confirm that Guix is working by installing a sample package into
  499. the root profile:
  500. @example
  501. # guix package -i hello
  502. @end example
  503. The @code{guix} package must remain available in @code{root}'s profile,
  504. or it would become subject to garbage collection---in which case you
  505. would find yourself badly handicapped by the lack of the @command{guix}
  506. command. In other words, do not remove @code{guix} by running
  507. @code{guix package -r guix}.
  508. The binary installation tarball can be (re)produced and verified simply
  509. by running the following command in the Guix source tree:
  510. @example
  511. make guix-binary.@var{system}.tar.xz
  512. @end example
  513. @noindent
  514. ...@: which, in turn, runs:
  515. @example
  516. guix pack -s @var{system} --localstatedir \
  517. --profile-name=current-guix guix
  518. @end example
  519. @xref{Invoking guix pack}, for more info on this handy tool.
  520. @node Requirements
  521. @section Requirements
  522. This section lists requirements when building Guix from source. The
  523. build procedure for Guix is the same as for other GNU software, and is
  524. not covered here. Please see the files @file{README} and @file{INSTALL}
  525. in the Guix source tree for additional details.
  526. GNU Guix depends on the following packages:
  527. @itemize
  528. @item @url{http://gnu.org/software/guile/, GNU Guile}, version 2.0.13 or
  529. later, including 2.2.x;
  530. @item @url{https://notabug.org/cwebber/guile-gcrypt, Guile-Gcrypt}, version
  531. 0.1.0 or later;
  532. @item
  533. @uref{http://gnutls.org/, GnuTLS}, specifically its Guile bindings
  534. (@pxref{Guile Preparations, how to install the GnuTLS bindings for
  535. Guile,, gnutls-guile, GnuTLS-Guile});
  536. @item
  537. @uref{https://notabug.org/guile-sqlite3/guile-sqlite3, Guile-SQLite3}, version 0.1.0
  538. or later;
  539. @item
  540. @c FIXME: Specify a version number once a release has been made.
  541. @uref{https://gitlab.com/guile-git/guile-git, Guile-Git}, from August
  542. 2017 or later;
  543. @item @uref{https://savannah.nongnu.org/projects/guile-json/, Guile-JSON};
  544. @item @url{http://zlib.net, zlib};
  545. @item @url{http://www.gnu.org/software/make/, GNU Make}.
  546. @end itemize
  547. The following dependencies are optional:
  548. @itemize
  549. @item
  550. @c Note: We need at least 0.10.2 for 'channel-send-eof'.
  551. Support for build offloading (@pxref{Daemon Offload Setup}) and
  552. @command{guix copy} (@pxref{Invoking guix copy}) depends on
  553. @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH},
  554. version 0.10.2 or later.
  555. @item
  556. When @url{http://www.bzip.org, libbz2} is available,
  557. @command{guix-daemon} can use it to compress build logs.
  558. @end itemize
  559. Unless @code{--disable-daemon} was passed to @command{configure}, the
  560. following packages are also needed:
  561. @itemize
  562. @item @url{http://gnupg.org/, GNU libgcrypt};
  563. @item @url{http://sqlite.org, SQLite 3};
  564. @item @url{http://gcc.gnu.org, GCC's g++}, with support for the
  565. C++11 standard.
  566. @end itemize
  567. @cindex state directory
  568. When configuring Guix on a system that already has a Guix installation,
  569. be sure to specify the same state directory as the existing installation
  570. using the @code{--localstatedir} option of the @command{configure}
  571. script (@pxref{Directory Variables, @code{localstatedir},, standards,
  572. GNU Coding Standards}). The @command{configure} script protects against
  573. unintended misconfiguration of @var{localstatedir} so you do not
  574. inadvertently corrupt your store (@pxref{The Store}).
  575. @cindex Nix, compatibility
  576. When a working installation of @url{http://nixos.org/nix/, the Nix package
  577. manager} is available, you
  578. can instead configure Guix with @code{--disable-daemon}. In that case,
  579. Nix replaces the three dependencies above.
  580. Guix is compatible with Nix, so it is possible to share the same store
  581. between both. To do so, you must pass @command{configure} not only the
  582. same @code{--with-store-dir} value, but also the same
  583. @code{--localstatedir} value. The latter is essential because it
  584. specifies where the database that stores metadata about the store is
  585. located, among other things. The default values for Nix are
  586. @code{--with-store-dir=/nix/store} and @code{--localstatedir=/nix/var}.
  587. Note that @code{--disable-daemon} is not required if
  588. your goal is to share the store with Nix.
  589. @node Running the Test Suite
  590. @section Running the Test Suite
  591. @cindex test suite
  592. After a successful @command{configure} and @code{make} run, it is a good
  593. idea to run the test suite. It can help catch issues with the setup or
  594. environment, or bugs in Guix itself---and really, reporting test
  595. failures is a good way to help improve the software. To run the test
  596. suite, type:
  597. @example
  598. make check
  599. @end example
  600. Test cases can run in parallel: you can use the @code{-j} option of
  601. GNU@tie{}make to speed things up. The first run may take a few minutes
  602. on a recent machine; subsequent runs will be faster because the store
  603. that is created for test purposes will already have various things in
  604. cache.
  605. It is also possible to run a subset of the tests by defining the
  606. @code{TESTS} makefile variable as in this example:
  607. @example
  608. make check TESTS="tests/store.scm tests/cpio.scm"
  609. @end example
  610. By default, tests results are displayed at a file level. In order to
  611. see the details of every individual test cases, it is possible to define
  612. the @code{SCM_LOG_DRIVER_FLAGS} makefile variable as in this example:
  613. @example
  614. make check TESTS="tests/base64.scm" SCM_LOG_DRIVER_FLAGS="--brief=no"
  615. @end example
  616. Upon failure, please email @email{bug-guix@@gnu.org} and attach the
  617. @file{test-suite.log} file. Please specify the Guix version being used
  618. as well as version numbers of the dependencies (@pxref{Requirements}) in
  619. your message.
  620. Guix also comes with a whole-system test suite that tests complete
  621. GuixSD operating system instances. It can only run on systems where
  622. Guix is already installed, using:
  623. @example
  624. make check-system
  625. @end example
  626. @noindent
  627. or, again, by defining @code{TESTS} to select a subset of tests to run:
  628. @example
  629. make check-system TESTS="basic mcron"
  630. @end example
  631. These system tests are defined in the @code{(gnu tests @dots{})}
  632. modules. They work by running the operating systems under test with
  633. lightweight instrumentation in a virtual machine (VM). They can be
  634. computationally intensive or rather cheap, depending on whether
  635. substitutes are available for their dependencies (@pxref{Substitutes}).
  636. Some of them require a lot of storage space to hold VM images.
  637. Again in case of test failures, please send @email{bug-guix@@gnu.org}
  638. all the details.
  639. @node Setting Up the Daemon
  640. @section Setting Up the Daemon
  641. @cindex daemon
  642. Operations such as building a package or running the garbage collector
  643. are all performed by a specialized process, the @dfn{build daemon}, on
  644. behalf of clients. Only the daemon may access the store and its
  645. associated database. Thus, any operation that manipulates the store
  646. goes through the daemon. For instance, command-line tools such as
  647. @command{guix package} and @command{guix build} communicate with the
  648. daemon (@i{via} remote procedure calls) to instruct it what to do.
  649. The following sections explain how to prepare the build daemon's
  650. environment. See also @ref{Substitutes}, for information on how to allow
  651. the daemon to download pre-built binaries.
  652. @menu
  653. * Build Environment Setup:: Preparing the isolated build environment.
  654. * Daemon Offload Setup:: Offloading builds to remote machines.
  655. * SELinux Support:: Using an SELinux policy for the daemon.
  656. @end menu
  657. @node Build Environment Setup
  658. @subsection Build Environment Setup
  659. @cindex build environment
  660. In a standard multi-user setup, Guix and its daemon---the
  661. @command{guix-daemon} program---are installed by the system
  662. administrator; @file{/gnu/store} is owned by @code{root} and
  663. @command{guix-daemon} runs as @code{root}. Unprivileged users may use
  664. Guix tools to build packages or otherwise access the store, and the
  665. daemon will do it on their behalf, ensuring that the store is kept in a
  666. consistent state, and allowing built packages to be shared among users.
  667. @cindex build users
  668. When @command{guix-daemon} runs as @code{root}, you may not want package
  669. build processes themselves to run as @code{root} too, for obvious
  670. security reasons. To avoid that, a special pool of @dfn{build users}
  671. should be created for use by build processes started by the daemon.
  672. These build users need not have a shell and a home directory: they will
  673. just be used when the daemon drops @code{root} privileges in build
  674. processes. Having several such users allows the daemon to launch
  675. distinct build processes under separate UIDs, which guarantees that they
  676. do not interfere with each other---an essential feature since builds are
  677. regarded as pure functions (@pxref{Introduction}).
  678. On a GNU/Linux system, a build user pool may be created like this (using
  679. Bash syntax and the @code{shadow} commands):
  680. @c See http://lists.gnu.org/archive/html/bug-guix/2013-01/msg00239.html
  681. @c for why `-G' is needed.
  682. @example
  683. # groupadd --system guixbuild
  684. # for i in `seq -w 1 10`;
  685. do
  686. useradd -g guixbuild -G guixbuild \
  687. -d /var/empty -s `which nologin` \
  688. -c "Guix build user $i" --system \
  689. guixbuilder$i;
  690. done
  691. @end example
  692. @noindent
  693. The number of build users determines how many build jobs may run in
  694. parallel, as specified by the @option{--max-jobs} option
  695. (@pxref{Invoking guix-daemon, @option{--max-jobs}}). To use
  696. @command{guix system vm} and related commands, you may need to add the
  697. build users to the @code{kvm} group so they can access @file{/dev/kvm},
  698. using @code{-G guixbuild,kvm} instead of @code{-G guixbuild}
  699. (@pxref{Invoking guix system}).
  700. The @code{guix-daemon} program may then be run as @code{root} with the
  701. following command@footnote{If your machine uses the systemd init system,
  702. dropping the @file{@var{prefix}/lib/systemd/system/guix-daemon.service}
  703. file in @file{/etc/systemd/system} will ensure that
  704. @command{guix-daemon} is automatically started. Similarly, if your
  705. machine uses the Upstart init system, drop the
  706. @file{@var{prefix}/lib/upstart/system/guix-daemon.conf}
  707. file in @file{/etc/init}.}:
  708. @example
  709. # guix-daemon --build-users-group=guixbuild
  710. @end example
  711. @cindex chroot
  712. @noindent
  713. This way, the daemon starts build processes in a chroot, under one of
  714. the @code{guixbuilder} users. On GNU/Linux, by default, the chroot
  715. environment contains nothing but:
  716. @c Keep this list in sync with libstore/build.cc! -----------------------
  717. @itemize
  718. @item
  719. a minimal @code{/dev} directory, created mostly independently from the
  720. host @code{/dev}@footnote{``Mostly'', because while the set of files
  721. that appear in the chroot's @code{/dev} is fixed, most of these files
  722. can only be created if the host has them.};
  723. @item
  724. the @code{/proc} directory; it only shows the processes of the container
  725. since a separate PID name space is used;
  726. @item
  727. @file{/etc/passwd} with an entry for the current user and an entry for
  728. user @file{nobody};
  729. @item
  730. @file{/etc/group} with an entry for the user's group;
  731. @item
  732. @file{/etc/hosts} with an entry that maps @code{localhost} to
  733. @code{127.0.0.1};
  734. @item
  735. a writable @file{/tmp} directory.
  736. @end itemize
  737. You can influence the directory where the daemon stores build trees
  738. @i{via} the @code{TMPDIR} environment variable. However, the build tree
  739. within the chroot is always called @file{/tmp/guix-build-@var{name}.drv-0},
  740. where @var{name} is the derivation name---e.g., @code{coreutils-8.24}.
  741. This way, the value of @code{TMPDIR} does not leak inside build
  742. environments, which avoids discrepancies in cases where build processes
  743. capture the name of their build tree.
  744. @vindex http_proxy
  745. The daemon also honors the @code{http_proxy} environment variable for
  746. HTTP downloads it performs, be it for fixed-output derivations
  747. (@pxref{Derivations}) or for substitutes (@pxref{Substitutes}).
  748. If you are installing Guix as an unprivileged user, it is still possible
  749. to run @command{guix-daemon} provided you pass @code{--disable-chroot}.
  750. However, build processes will not be isolated from one another, and not
  751. from the rest of the system. Thus, build processes may interfere with
  752. each other, and may access programs, libraries, and other files
  753. available on the system---making it much harder to view them as
  754. @emph{pure} functions.
  755. @node Daemon Offload Setup
  756. @subsection Using the Offload Facility
  757. @cindex offloading
  758. @cindex build hook
  759. When desired, the build daemon can @dfn{offload} derivation builds to
  760. other machines running Guix, using the @code{offload} @dfn{build
  761. hook}@footnote{This feature is available only when
  762. @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH} is
  763. present.}. When that
  764. feature is enabled, a list of user-specified build machines is read from
  765. @file{/etc/guix/machines.scm}; every time a build is requested, for
  766. instance via @code{guix build}, the daemon attempts to offload it to one
  767. of the machines that satisfy the constraints of the derivation, in
  768. particular its system type---e.g., @file{x86_64-linux}. Missing
  769. prerequisites for the build are copied over SSH to the target machine,
  770. which then proceeds with the build; upon success the output(s) of the
  771. build are copied back to the initial machine.
  772. The @file{/etc/guix/machines.scm} file typically looks like this:
  773. @example
  774. (list (build-machine
  775. (name "eightysix.example.org")
  776. (system "x86_64-linux")
  777. (host-key "ssh-ed25519 AAAAC3Nza@dots{}")
  778. (user "bob")
  779. (speed 2.)) ;incredibly fast!
  780. (build-machine
  781. (name "meeps.example.org")
  782. (system "mips64el-linux")
  783. (host-key "ssh-rsa AAAAB3Nza@dots{}")
  784. (user "alice")
  785. (private-key
  786. (string-append (getenv "HOME")
  787. "/.ssh/identity-for-guix"))))
  788. @end example
  789. @noindent
  790. In the example above we specify a list of two build machines, one for
  791. the @code{x86_64} architecture and one for the @code{mips64el}
  792. architecture.
  793. In fact, this file is---not surprisingly!---a Scheme file that is
  794. evaluated when the @code{offload} hook is started. Its return value
  795. must be a list of @code{build-machine} objects. While this example
  796. shows a fixed list of build machines, one could imagine, say, using
  797. DNS-SD to return a list of potential build machines discovered in the
  798. local network (@pxref{Introduction, Guile-Avahi,, guile-avahi, Using
  799. Avahi in Guile Scheme Programs}). The @code{build-machine} data type is
  800. detailed below.
  801. @deftp {Data Type} build-machine
  802. This data type represents build machines to which the daemon may offload
  803. builds. The important fields are:
  804. @table @code
  805. @item name
  806. The host name of the remote machine.
  807. @item system
  808. The system type of the remote machine---e.g., @code{"x86_64-linux"}.
  809. @item user
  810. The user account to use when connecting to the remote machine over SSH.
  811. Note that the SSH key pair must @emph{not} be passphrase-protected, to
  812. allow non-interactive logins.
  813. @item host-key
  814. This must be the machine's SSH @dfn{public host key} in OpenSSH format.
  815. This is used to authenticate the machine when we connect to it. It is a
  816. long string that looks like this:
  817. @example
  818. ssh-ed25519 AAAAC3NzaC@dots{}mde+UhL hint@@example.org
  819. @end example
  820. If the machine is running the OpenSSH daemon, @command{sshd}, the host
  821. key can be found in a file such as
  822. @file{/etc/ssh/ssh_host_ed25519_key.pub}.
  823. If the machine is running the SSH daemon of GNU@tie{}lsh,
  824. @command{lshd}, the host key is in @file{/etc/lsh/host-key.pub} or a
  825. similar file. It can be converted to the OpenSSH format using
  826. @command{lsh-export-key} (@pxref{Converting keys,,, lsh, LSH Manual}):
  827. @example
  828. $ lsh-export-key --openssh < /etc/lsh/host-key.pub
  829. ssh-rsa AAAAB3NzaC1yc2EAAAAEOp8FoQAAAQEAs1eB46LV@dots{}
  830. @end example
  831. @end table
  832. A number of optional fields may be specified:
  833. @table @asis
  834. @item @code{port} (default: @code{22})
  835. Port number of SSH server on the machine.
  836. @item @code{private-key} (default: @file{~root/.ssh/id_rsa})
  837. The SSH private key file to use when connecting to the machine, in
  838. OpenSSH format. This key must not be protected with a passphrase.
  839. Note that the default value is the private key @emph{of the root
  840. account}. Make sure it exists if you use the default.
  841. @item @code{compression} (default: @code{"zlib@@openssh.com,zlib"})
  842. @itemx @code{compression-level} (default: @code{3})
  843. The SSH-level compression methods and compression level requested.
  844. Note that offloading relies on SSH compression to reduce bandwidth usage
  845. when transferring files to and from build machines.
  846. @item @code{daemon-socket} (default: @code{"/var/guix/daemon-socket/socket"})
  847. File name of the Unix-domain socket @command{guix-daemon} is listening
  848. to on that machine.
  849. @item @code{parallel-builds} (default: @code{1})
  850. The number of builds that may run in parallel on the machine.
  851. @item @code{speed} (default: @code{1.0})
  852. A ``relative speed factor''. The offload scheduler will tend to prefer
  853. machines with a higher speed factor.
  854. @item @code{features} (default: @code{'()})
  855. A list of strings denoting specific features supported by the machine.
  856. An example is @code{"kvm"} for machines that have the KVM Linux modules
  857. and corresponding hardware support. Derivations can request features by
  858. name, and they will be scheduled on matching build machines.
  859. @end table
  860. @end deftp
  861. The @code{guile} command must be in the search path on the build
  862. machines. In addition, the Guix modules must be in
  863. @code{$GUILE_LOAD_PATH} on the build machine---you can check whether
  864. this is the case by running:
  865. @example
  866. ssh build-machine guile -c "'(use-modules (guix config))'"
  867. @end example
  868. There is one last thing to do once @file{machines.scm} is in place. As
  869. explained above, when offloading, files are transferred back and forth
  870. between the machine stores. For this to work, you first need to
  871. generate a key pair on each machine to allow the daemon to export signed
  872. archives of files from the store (@pxref{Invoking guix archive}):
  873. @example
  874. # guix archive --generate-key
  875. @end example
  876. @noindent
  877. Each build machine must authorize the key of the master machine so that
  878. it accepts store items it receives from the master:
  879. @example
  880. # guix archive --authorize < master-public-key.txt
  881. @end example
  882. @noindent
  883. Likewise, the master machine must authorize the key of each build machine.
  884. All the fuss with keys is here to express pairwise mutual trust
  885. relations between the master and the build machines. Concretely, when
  886. the master receives files from a build machine (and @i{vice versa}), its
  887. build daemon can make sure they are genuine, have not been tampered
  888. with, and that they are signed by an authorized key.
  889. @cindex offload test
  890. To test whether your setup is operational, run this command on the
  891. master node:
  892. @example
  893. # guix offload test
  894. @end example
  895. This will attempt to connect to each of the build machines specified in
  896. @file{/etc/guix/machines.scm}, make sure Guile and the Guix modules are
  897. available on each machine, attempt to export to the machine and import
  898. from it, and report any error in the process.
  899. If you want to test a different machine file, just specify it on the
  900. command line:
  901. @example
  902. # guix offload test machines-qualif.scm
  903. @end example
  904. Last, you can test the subset of the machines whose name matches a
  905. regular expression like this:
  906. @example
  907. # guix offload test machines.scm '\.gnu\.org$'
  908. @end example
  909. @cindex offload status
  910. To display the current load of all build hosts, run this command on the
  911. main node:
  912. @example
  913. # guix offload status
  914. @end example
  915. @node SELinux Support
  916. @subsection SELinux Support
  917. @cindex SELinux, daemon policy
  918. @cindex mandatory access control, SELinux
  919. @cindex security, guix-daemon
  920. Guix includes an SELinux policy file at @file{etc/guix-daemon.cil} that
  921. can be installed on a system where SELinux is enabled, in order to label
  922. Guix files and to specify the expected behavior of the daemon. Since
  923. GuixSD does not provide an SELinux base policy, the daemon policy cannot
  924. be used on GuixSD.
  925. @subsubsection Installing the SELinux policy
  926. @cindex SELinux, policy installation
  927. To install the policy run this command as root:
  928. @example
  929. semodule -i etc/guix-daemon.cil
  930. @end example
  931. Then relabel the file system with @code{restorecon} or by a different
  932. mechanism provided by your system.
  933. Once the policy is installed, the file system has been relabeled, and
  934. the daemon has been restarted, it should be running in the
  935. @code{guix_daemon_t} context. You can confirm this with the following
  936. command:
  937. @example
  938. ps -Zax | grep guix-daemon
  939. @end example
  940. Monitor the SELinux log files as you run a command like @code{guix build
  941. hello} to convince yourself that SELinux permits all necessary
  942. operations.
  943. @subsubsection Limitations
  944. @cindex SELinux, limitations
  945. This policy is not perfect. Here is a list of limitations or quirks
  946. that should be considered when deploying the provided SELinux policy for
  947. the Guix daemon.
  948. @enumerate
  949. @item
  950. @code{guix_daemon_socket_t} isn’t actually used. None of the socket
  951. operations involve contexts that have anything to do with
  952. @code{guix_daemon_socket_t}. It doesn’t hurt to have this unused label,
  953. but it would be preferrable to define socket rules for only this label.
  954. @item
  955. @code{guix gc} cannot access arbitrary links to profiles. By design,
  956. the file label of the destination of a symlink is independent of the
  957. file label of the link itself. Although all profiles under
  958. $localstatedir are labelled, the links to these profiles inherit the
  959. label of the directory they are in. For links in the user’s home
  960. directory this will be @code{user_home_t}. But for links from the root
  961. user’s home directory, or @file{/tmp}, or the HTTP server’s working
  962. directory, etc, this won’t work. @code{guix gc} would be prevented from
  963. reading and following these links.
  964. @item
  965. The daemon’s feature to listen for TCP connections might no longer work.
  966. This might require extra rules, because SELinux treats network sockets
  967. differently from files.
  968. @item
  969. Currently all files with a name matching the regular expression
  970. @code{/gnu/store/.+-(guix-.+|profile)/bin/guix-daemon} are assigned the
  971. label @code{guix_daemon_exec_t}; this means that @emph{any} file with
  972. that name in any profile would be permitted to run in the
  973. @code{guix_daemon_t} domain. This is not ideal. An attacker could
  974. build a package that provides this executable and convince a user to
  975. install and run it, which lifts it into the @code{guix_daemon_t} domain.
  976. At that point SELinux could not prevent it from accessing files that are
  977. allowed for processes in that domain.
  978. We could generate a much more restrictive policy at installation time,
  979. so that only the @emph{exact} file name of the currently installed
  980. @code{guix-daemon} executable would be labelled with
  981. @code{guix_daemon_exec_t}, instead of using a broad regular expression.
  982. The downside is that root would have to install or upgrade the policy at
  983. installation time whenever the Guix package that provides the
  984. effectively running @code{guix-daemon} executable is upgraded.
  985. @end enumerate
  986. @node Invoking guix-daemon
  987. @section Invoking @command{guix-daemon}
  988. The @command{guix-daemon} program implements all the functionality to
  989. access the store. This includes launching build processes, running the
  990. garbage collector, querying the availability of a build result, etc. It
  991. is normally run as @code{root} like this:
  992. @example
  993. # guix-daemon --build-users-group=guixbuild
  994. @end example
  995. @noindent
  996. For details on how to set it up, @pxref{Setting Up the Daemon}.
  997. @cindex chroot
  998. @cindex container, build environment
  999. @cindex build environment
  1000. @cindex reproducible builds
  1001. By default, @command{guix-daemon} launches build processes under
  1002. different UIDs, taken from the build group specified with
  1003. @code{--build-users-group}. In addition, each build process is run in a
  1004. chroot environment that only contains the subset of the store that the
  1005. build process depends on, as specified by its derivation
  1006. (@pxref{Programming Interface, derivation}), plus a set of specific
  1007. system directories. By default, the latter contains @file{/dev} and
  1008. @file{/dev/pts}. Furthermore, on GNU/Linux, the build environment is a
  1009. @dfn{container}: in addition to having its own file system tree, it has
  1010. a separate mount name space, its own PID name space, network name space,
  1011. etc. This helps achieve reproducible builds (@pxref{Features}).
  1012. When the daemon performs a build on behalf of the user, it creates a
  1013. build directory under @file{/tmp} or under the directory specified by
  1014. its @code{TMPDIR} environment variable. This directory is shared with
  1015. the container for the duration of the build, though within the container,
  1016. the build tree is always called @file{/tmp/guix-build-@var{name}.drv-0}.
  1017. The build directory is automatically deleted upon completion, unless the
  1018. build failed and the client specified @option{--keep-failed}
  1019. (@pxref{Invoking guix build, @option{--keep-failed}}).
  1020. The daemon listens for connections and spawns one sub-process for each session
  1021. started by a client (one of the @command{guix} sub-commands.) The
  1022. @command{guix processes} command allows you to get an overview of the activity
  1023. on your system by viewing each of the active sessions and clients.
  1024. @xref{Invoking guix processes}, for more information.
  1025. The following command-line options are supported:
  1026. @table @code
  1027. @item --build-users-group=@var{group}
  1028. Take users from @var{group} to run build processes (@pxref{Setting Up
  1029. the Daemon, build users}).
  1030. @item --no-substitutes
  1031. @cindex substitutes
  1032. Do not use substitutes for build products. That is, always build things
  1033. locally instead of allowing downloads of pre-built binaries
  1034. (@pxref{Substitutes}).
  1035. When the daemon runs with @code{--no-substitutes}, clients can still
  1036. explicitly enable substitution @i{via} the @code{set-build-options}
  1037. remote procedure call (@pxref{The Store}).
  1038. @item --substitute-urls=@var{urls}
  1039. @anchor{daemon-substitute-urls}
  1040. Consider @var{urls} the default whitespace-separated list of substitute
  1041. source URLs. When this option is omitted,
  1042. @indicateurl{https://@value{SUBSTITUTE-SERVER}} is used.
  1043. This means that substitutes may be downloaded from @var{urls}, as long
  1044. as they are signed by a trusted signature (@pxref{Substitutes}).
  1045. @cindex build hook
  1046. @item --no-build-hook
  1047. Do not use the @dfn{build hook}.
  1048. The build hook is a helper program that the daemon can start and to
  1049. which it submits build requests. This mechanism is used to offload
  1050. builds to other machines (@pxref{Daemon Offload Setup}).
  1051. @item --cache-failures
  1052. Cache build failures. By default, only successful builds are cached.
  1053. When this option is used, @command{guix gc --list-failures} can be used
  1054. to query the set of store items marked as failed; @command{guix gc
  1055. --clear-failures} removes store items from the set of cached failures.
  1056. @xref{Invoking guix gc}.
  1057. @item --cores=@var{n}
  1058. @itemx -c @var{n}
  1059. Use @var{n} CPU cores to build each derivation; @code{0} means as many
  1060. as available.
  1061. The default value is @code{0}, but it may be overridden by clients, such
  1062. as the @code{--cores} option of @command{guix build} (@pxref{Invoking
  1063. guix build}).
  1064. The effect is to define the @code{NIX_BUILD_CORES} environment variable
  1065. in the build process, which can then use it to exploit internal
  1066. parallelism---for instance, by running @code{make -j$NIX_BUILD_CORES}.
  1067. @item --max-jobs=@var{n}
  1068. @itemx -M @var{n}
  1069. Allow at most @var{n} build jobs in parallel. The default value is
  1070. @code{1}. Setting it to @code{0} means that no builds will be performed
  1071. locally; instead, the daemon will offload builds (@pxref{Daemon Offload
  1072. Setup}), or simply fail.
  1073. @item --max-silent-time=@var{seconds}
  1074. When the build or substitution process remains silent for more than
  1075. @var{seconds}, terminate it and report a build failure.
  1076. The default value is @code{0}, which disables the timeout.
  1077. The value specified here can be overridden by clients (@pxref{Common
  1078. Build Options, @code{--max-silent-time}}).
  1079. @item --timeout=@var{seconds}
  1080. Likewise, when the build or substitution process lasts for more than
  1081. @var{seconds}, terminate it and report a build failure.
  1082. The default value is @code{0}, which disables the timeout.
  1083. The value specified here can be overridden by clients (@pxref{Common
  1084. Build Options, @code{--timeout}}).
  1085. @item --rounds=@var{N}
  1086. Build each derivation @var{n} times in a row, and raise an error if
  1087. consecutive build results are not bit-for-bit identical. Note that this
  1088. setting can be overridden by clients such as @command{guix build}
  1089. (@pxref{Invoking guix build}).
  1090. When used in conjunction with @option{--keep-failed}, the differing
  1091. output is kept in the store, under @file{/gnu/store/@dots{}-check}.
  1092. This makes it easy to look for differences between the two results.
  1093. @item --debug
  1094. Produce debugging output.
  1095. This is useful to debug daemon start-up issues, but then it may be
  1096. overridden by clients, for example the @code{--verbosity} option of
  1097. @command{guix build} (@pxref{Invoking guix build}).
  1098. @item --chroot-directory=@var{dir}
  1099. Add @var{dir} to the build chroot.
  1100. Doing this may change the result of build processes---for instance if
  1101. they use optional dependencies found in @var{dir} when it is available,
  1102. and not otherwise. For that reason, it is not recommended to do so.
  1103. Instead, make sure that each derivation declares all the inputs that it
  1104. needs.
  1105. @item --disable-chroot
  1106. Disable chroot builds.
  1107. Using this option is not recommended since, again, it would allow build
  1108. processes to gain access to undeclared dependencies. It is necessary,
  1109. though, when @command{guix-daemon} is running under an unprivileged user
  1110. account.
  1111. @item --log-compression=@var{type}
  1112. Compress build logs according to @var{type}, one of @code{gzip},
  1113. @code{bzip2}, or @code{none}.
  1114. Unless @code{--lose-logs} is used, all the build logs are kept in the
  1115. @var{localstatedir}. To save space, the daemon automatically compresses
  1116. them with bzip2 by default.
  1117. @item --disable-deduplication
  1118. @cindex deduplication
  1119. Disable automatic file ``deduplication'' in the store.
  1120. By default, files added to the store are automatically ``deduplicated'':
  1121. if a newly added file is identical to another one found in the store,
  1122. the daemon makes the new file a hard link to the other file. This can
  1123. noticeably reduce disk usage, at the expense of slightly increased
  1124. input/output load at the end of a build process. This option disables
  1125. this optimization.
  1126. @item --gc-keep-outputs[=yes|no]
  1127. Tell whether the garbage collector (GC) must keep outputs of live
  1128. derivations.
  1129. @cindex GC roots
  1130. @cindex garbage collector roots
  1131. When set to ``yes'', the GC will keep the outputs of any live derivation
  1132. available in the store---the @code{.drv} files. The default is ``no'',
  1133. meaning that derivation outputs are kept only if they are reachable from a GC
  1134. root. @xref{Invoking guix gc}, for more on GC roots.
  1135. @item --gc-keep-derivations[=yes|no]
  1136. Tell whether the garbage collector (GC) must keep derivations
  1137. corresponding to live outputs.
  1138. When set to ``yes'', as is the case by default, the GC keeps
  1139. derivations---i.e., @code{.drv} files---as long as at least one of their
  1140. outputs is live. This allows users to keep track of the origins of
  1141. items in their store. Setting it to ``no'' saves a bit of disk space.
  1142. In this way, setting @code{--gc-keep-derivations} to ``yes'' causes liveness
  1143. to flow from outputs to derivations, and setting @code{--gc-keep-outputs} to
  1144. ``yes'' causes liveness to flow from derivations to outputs. When both are
  1145. set to ``yes'', the effect is to keep all the build prerequisites (the
  1146. sources, compiler, libraries, and other build-time tools) of live objects in
  1147. the store, regardless of whether these prerequisites are reachable from a GC
  1148. root. This is convenient for developers since it saves rebuilds or downloads.
  1149. @item --impersonate-linux-2.6
  1150. On Linux-based systems, impersonate Linux 2.6. This means that the
  1151. kernel's @code{uname} system call will report 2.6 as the release number.
  1152. This might be helpful to build programs that (usually wrongfully) depend
  1153. on the kernel version number.
  1154. @item --lose-logs
  1155. Do not keep build logs. By default they are kept under
  1156. @code{@var{localstatedir}/guix/log}.
  1157. @item --system=@var{system}
  1158. Assume @var{system} as the current system type. By default it is the
  1159. architecture/kernel pair found at configure time, such as
  1160. @code{x86_64-linux}.
  1161. @item --listen=@var{endpoint}
  1162. Listen for connections on @var{endpoint}. @var{endpoint} is interpreted
  1163. as the file name of a Unix-domain socket if it starts with
  1164. @code{/} (slash sign). Otherwise, @var{endpoint} is interpreted as a
  1165. host name or host name and port to listen to. Here are a few examples:
  1166. @table @code
  1167. @item --listen=/gnu/var/daemon
  1168. Listen for connections on the @file{/gnu/var/daemon} Unix-domain socket,
  1169. creating it if needed.
  1170. @item --listen=localhost
  1171. @cindex daemon, remote access
  1172. @cindex remote access to the daemon
  1173. @cindex daemon, cluster setup
  1174. @cindex clusters, daemon setup
  1175. Listen for TCP connections on the network interface corresponding to
  1176. @code{localhost}, on port 44146.
  1177. @item --listen=128.0.0.42:1234
  1178. Listen for TCP connections on the network interface corresponding to
  1179. @code{128.0.0.42}, on port 1234.
  1180. @end table
  1181. This option can be repeated multiple times, in which case
  1182. @command{guix-daemon} accepts connections on all the specified
  1183. endpoints. Users can tell client commands what endpoint to connect to
  1184. by setting the @code{GUIX_DAEMON_SOCKET} environment variable
  1185. (@pxref{The Store, @code{GUIX_DAEMON_SOCKET}}).
  1186. @quotation Note
  1187. The daemon protocol is @emph{unauthenticated and unencrypted}. Using
  1188. @code{--listen=@var{host}} is suitable on local networks, such as
  1189. clusters, where only trusted nodes may connect to the build daemon. In
  1190. other cases where remote access to the daemon is needed, we recommend
  1191. using Unix-domain sockets along with SSH.
  1192. @end quotation
  1193. When @code{--listen} is omitted, @command{guix-daemon} listens for
  1194. connections on the Unix-domain socket located at
  1195. @file{@var{localstatedir}/guix/daemon-socket/socket}.
  1196. @end table
  1197. @node Application Setup
  1198. @section Application Setup
  1199. @cindex foreign distro
  1200. When using Guix on top of GNU/Linux distribution other than GuixSD---a
  1201. so-called @dfn{foreign distro}---a few additional steps are needed to
  1202. get everything in place. Here are some of them.
  1203. @subsection Locales
  1204. @anchor{locales-and-locpath}
  1205. @cindex locales, when not on GuixSD
  1206. @vindex LOCPATH
  1207. @vindex GUIX_LOCPATH
  1208. Packages installed @i{via} Guix will not use the locale data of the
  1209. host system. Instead, you must first install one of the locale packages
  1210. available with Guix and then define the @code{GUIX_LOCPATH} environment
  1211. variable:
  1212. @example
  1213. $ guix package -i glibc-locales
  1214. $ export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale
  1215. @end example
  1216. Note that the @code{glibc-locales} package contains data for all the
  1217. locales supported by the GNU@tie{}libc and weighs in at around
  1218. 110@tie{}MiB. Alternatively, the @code{glibc-utf8-locales} is smaller but
  1219. limited to a few UTF-8 locales.
  1220. The @code{GUIX_LOCPATH} variable plays a role similar to @code{LOCPATH}
  1221. (@pxref{Locale Names, @code{LOCPATH},, libc, The GNU C Library Reference
  1222. Manual}). There are two important differences though:
  1223. @enumerate
  1224. @item
  1225. @code{GUIX_LOCPATH} is honored only by the libc in Guix, and not by the libc
  1226. provided by foreign distros. Thus, using @code{GUIX_LOCPATH} allows you
  1227. to make sure the programs of the foreign distro will not end up loading
  1228. incompatible locale data.
  1229. @item
  1230. libc suffixes each entry of @code{GUIX_LOCPATH} with @code{/X.Y}, where
  1231. @code{X.Y} is the libc version---e.g., @code{2.22}. This means that,
  1232. should your Guix profile contain a mixture of programs linked against
  1233. different libc version, each libc version will only try to load locale
  1234. data in the right format.
  1235. @end enumerate
  1236. This is important because the locale data format used by different libc
  1237. versions may be incompatible.
  1238. @subsection Name Service Switch
  1239. @cindex name service switch, glibc
  1240. @cindex NSS (name service switch), glibc
  1241. @cindex nscd (name service caching daemon)
  1242. @cindex name service caching daemon (nscd)
  1243. When using Guix on a foreign distro, we @emph{strongly recommend} that
  1244. the system run the GNU C library's @dfn{name service cache daemon},
  1245. @command{nscd}, which should be listening on the
  1246. @file{/var/run/nscd/socket} socket. Failing to do that, applications
  1247. installed with Guix may fail to look up host names or user accounts, or
  1248. may even crash. The next paragraphs explain why.
  1249. @cindex @file{nsswitch.conf}
  1250. The GNU C library implements a @dfn{name service switch} (NSS), which is
  1251. an extensible mechanism for ``name lookups'' in general: host name
  1252. resolution, user accounts, and more (@pxref{Name Service Switch,,, libc,
  1253. The GNU C Library Reference Manual}).
  1254. @cindex Network information service (NIS)
  1255. @cindex NIS (Network information service)
  1256. Being extensible, the NSS supports @dfn{plugins}, which provide new name
  1257. lookup implementations: for example, the @code{nss-mdns} plugin allow
  1258. resolution of @code{.local} host names, the @code{nis} plugin allows
  1259. user account lookup using the Network information service (NIS), and so
  1260. on. These extra ``lookup services'' are configured system-wide in
  1261. @file{/etc/nsswitch.conf}, and all the programs running on the system
  1262. honor those settings (@pxref{NSS Configuration File,,, libc, The GNU C
  1263. Reference Manual}).
  1264. When they perform a name lookup---for instance by calling the
  1265. @code{getaddrinfo} function in C---applications first try to connect to
  1266. the nscd; on success, nscd performs name lookups on their behalf. If
  1267. the nscd is not running, then they perform the name lookup by
  1268. themselves, by loading the name lookup services into their own address
  1269. space and running it. These name lookup services---the
  1270. @file{libnss_*.so} files---are @code{dlopen}'d, but they may come from
  1271. the host system's C library, rather than from the C library the
  1272. application is linked against (the C library coming from Guix).
  1273. And this is where the problem is: if your application is linked against
  1274. Guix's C library (say, glibc 2.24) and tries to load NSS plugins from
  1275. another C library (say, @code{libnss_mdns.so} for glibc 2.22), it will
  1276. likely crash or have its name lookups fail unexpectedly.
  1277. Running @command{nscd} on the system, among other advantages, eliminates
  1278. this binary incompatibility problem because those @code{libnss_*.so}
  1279. files are loaded in the @command{nscd} process, not in applications
  1280. themselves.
  1281. @subsection X11 Fonts
  1282. @cindex fonts
  1283. The majority of graphical applications use Fontconfig to locate and
  1284. load fonts and perform X11-client-side rendering. The @code{fontconfig}
  1285. package in Guix looks for fonts in @file{$HOME/.guix-profile}
  1286. by default. Thus, to allow graphical applications installed with Guix
  1287. to display fonts, you have to install fonts with Guix as well.
  1288. Essential font packages include @code{gs-fonts}, @code{font-dejavu}, and
  1289. @code{font-gnu-freefont-ttf}.
  1290. To display text written in Chinese languages, Japanese, or Korean in
  1291. graphical applications, consider installing
  1292. @code{font-adobe-source-han-sans} or @code{font-wqy-zenhei}. The former
  1293. has multiple outputs, one per language family (@pxref{Packages with
  1294. Multiple Outputs}). For instance, the following command installs fonts
  1295. for Chinese languages:
  1296. @example
  1297. guix package -i font-adobe-source-han-sans:cn
  1298. @end example
  1299. @cindex @code{xterm}
  1300. Older programs such as @command{xterm} do not use Fontconfig and instead
  1301. rely on server-side font rendering. Such programs require to specify a
  1302. full name of a font using XLFD (X Logical Font Description), like this:
  1303. @example
  1304. -*-dejavu sans-medium-r-normal-*-*-100-*-*-*-*-*-1
  1305. @end example
  1306. To be able to use such full names for the TrueType fonts installed in
  1307. your Guix profile, you need to extend the font path of the X server:
  1308. @c Note: 'xset' does not accept symlinks so the trick below arranges to
  1309. @c get at the real directory. See <https://bugs.gnu.org/30655>.
  1310. @example
  1311. xset +fp $(dirname $(readlink -f ~/.guix-profile/share/fonts/truetype/fonts.dir))
  1312. @end example
  1313. @cindex @code{xlsfonts}
  1314. After that, you can run @code{xlsfonts} (from @code{xlsfonts} package)
  1315. to make sure your TrueType fonts are listed there.
  1316. @cindex @code{fc-cache}
  1317. @cindex font cache
  1318. After installing fonts you may have to refresh the font cache to use
  1319. them in applications. The same applies when applications installed via
  1320. Guix do not seem to find fonts. To force rebuilding of the font cache
  1321. run @code{fc-cache -f}. The @code{fc-cache} command is provided by the
  1322. @code{fontconfig} package.
  1323. @subsection X.509 Certificates
  1324. @cindex @code{nss-certs}
  1325. The @code{nss-certs} package provides X.509 certificates, which allow
  1326. programs to authenticate Web servers accessed over HTTPS.
  1327. When using Guix on a foreign distro, you can install this package and
  1328. define the relevant environment variables so that packages know where to
  1329. look for certificates. @xref{X.509 Certificates}, for detailed
  1330. information.
  1331. @subsection Emacs Packages
  1332. @cindex @code{emacs}
  1333. When you install Emacs packages with Guix, the elisp files may be placed
  1334. either in @file{$HOME/.guix-profile/share/emacs/site-lisp/} or in
  1335. sub-directories of
  1336. @file{$HOME/.guix-profile/share/emacs/site-lisp/guix.d/}. The latter
  1337. directory exists because potentially there may exist thousands of Emacs
  1338. packages and storing all their files in a single directory may not be
  1339. reliable (because of name conflicts). So we think using a separate
  1340. directory for each package is a good idea. It is very similar to how
  1341. the Emacs package system organizes the file structure (@pxref{Package
  1342. Files,,, emacs, The GNU Emacs Manual}).
  1343. By default, Emacs (installed with Guix) ``knows'' where these packages
  1344. are placed, so you do not need to perform any configuration. If, for
  1345. some reason, you want to avoid auto-loading Emacs packages installed
  1346. with Guix, you can do so by running Emacs with @code{--no-site-file}
  1347. option (@pxref{Init File,,, emacs, The GNU Emacs Manual}).
  1348. @subsection The GCC toolchain
  1349. @cindex GCC
  1350. @cindex ld-wrapper
  1351. Guix offers individual compiler packages such as @code{gcc} but if you
  1352. are in need of a complete toolchain for compiling and linking source
  1353. code what you really want is the @code{gcc-toolchain} package. This
  1354. package provides a complete GCC toolchain for C/C++ development,
  1355. including GCC itself, the GNU C Library (headers and binaries, plus
  1356. debugging symbols in the @code{debug} output), Binutils, and a linker
  1357. wrapper.
  1358. @cindex attempt to use impure library, error message
  1359. The wrapper's purpose is to inspect the @code{-L} and @code{-l} switches
  1360. passed to the linker, add corresponding @code{-rpath} arguments, and
  1361. invoke the actual linker with this new set of arguments. By default,
  1362. the linker wrapper refuses to link to libraries outside the store to
  1363. ensure ``purity''. This can be annoying when using the toolchain to
  1364. link with local libraries. To allow references to libraries outside the
  1365. store you need to define the environment variable
  1366. @code{GUIX_LD_WRAPPER_ALLOW_IMPURITIES}.
  1367. @c TODO What else?
  1368. @c *********************************************************************
  1369. @node Package Management
  1370. @chapter Package Management
  1371. @cindex packages
  1372. The purpose of GNU Guix is to allow users to easily install, upgrade, and
  1373. remove software packages, without having to know about their build
  1374. procedures or dependencies. Guix also goes beyond this obvious set of
  1375. features.
  1376. This chapter describes the main features of Guix, as well as the
  1377. package management tools it provides. Along with the command-line
  1378. interface described below (@pxref{Invoking guix package, @code{guix
  1379. package}}), you may also use the Emacs-Guix interface (@pxref{Top,,,
  1380. emacs-guix, The Emacs-Guix Reference Manual}), after installing
  1381. @code{emacs-guix} package (run @kbd{M-x guix-help} command to start
  1382. with it):
  1383. @example
  1384. guix package -i emacs-guix
  1385. @end example
  1386. @menu
  1387. * Features:: How Guix will make your life brighter.
  1388. * Invoking guix package:: Package installation, removal, etc.
  1389. * Substitutes:: Downloading pre-built binaries.
  1390. * Packages with Multiple Outputs:: Single source package, multiple outputs.
  1391. * Invoking guix gc:: Running the garbage collector.
  1392. * Invoking guix pull:: Fetching the latest Guix and distribution.
  1393. * Channels:: Customizing the package collection.
  1394. * Inferiors:: Interacting with another revision of Guix.
  1395. * Invoking guix describe:: Display information about your Guix revision.
  1396. * Invoking guix pack:: Creating software bundles.
  1397. * Invoking guix archive:: Exporting and importing store files.
  1398. @end menu
  1399. @node Features
  1400. @section Features
  1401. When using Guix, each package ends up in the @dfn{package store}, in its
  1402. own directory---something that resembles
  1403. @file{/gnu/store/xxx-package-1.2}, where @code{xxx} is a base32 string.
  1404. Instead of referring to these directories, users have their own
  1405. @dfn{profile}, which points to the packages that they actually want to
  1406. use. These profiles are stored within each user's home directory, at
  1407. @code{$HOME/.guix-profile}.
  1408. For example, @code{alice} installs GCC 4.7.2. As a result,
  1409. @file{/home/alice/.guix-profile/bin/gcc} points to
  1410. @file{/gnu/store/@dots{}-gcc-4.7.2/bin/gcc}. Now, on the same machine,
  1411. @code{bob} had already installed GCC 4.8.0. The profile of @code{bob}
  1412. simply continues to point to
  1413. @file{/gnu/store/@dots{}-gcc-4.8.0/bin/gcc}---i.e., both versions of GCC
  1414. coexist on the same system without any interference.
  1415. The @command{guix package} command is the central tool to manage
  1416. packages (@pxref{Invoking guix package}). It operates on the per-user
  1417. profiles, and can be used @emph{with normal user privileges}.
  1418. @cindex transactions
  1419. The command provides the obvious install, remove, and upgrade
  1420. operations. Each invocation is actually a @emph{transaction}: either
  1421. the specified operation succeeds, or nothing happens. Thus, if the
  1422. @command{guix package} process is terminated during the transaction,
  1423. or if a power outage occurs during the transaction, then the user's
  1424. profile remains in its previous state, and remains usable.
  1425. In addition, any package transaction may be @emph{rolled back}. So, if,
  1426. for example, an upgrade installs a new version of a package that turns
  1427. out to have a serious bug, users may roll back to the previous instance
  1428. of their profile, which was known to work well. Similarly, the global
  1429. system configuration on GuixSD is subject to
  1430. transactional upgrades and roll-back
  1431. (@pxref{Using the Configuration System}).
  1432. All packages in the package store may be @emph{garbage-collected}.
  1433. Guix can determine which packages are still referenced by user
  1434. profiles, and remove those that are provably no longer referenced
  1435. (@pxref{Invoking guix gc}). Users may also explicitly remove old
  1436. generations of their profile so that the packages they refer to can be
  1437. collected.
  1438. @cindex reproducibility
  1439. @cindex reproducible builds
  1440. Guix takes a @dfn{purely functional} approach to package
  1441. management, as described in the introduction (@pxref{Introduction}).
  1442. Each @file{/gnu/store} package directory name contains a hash of all the
  1443. inputs that were used to build that package---compiler, libraries, build
  1444. scripts, etc. This direct correspondence allows users to make sure a
  1445. given package installation matches the current state of their
  1446. distribution. It also helps maximize @dfn{build reproducibility}:
  1447. thanks to the isolated build environments that are used, a given build
  1448. is likely to yield bit-identical files when performed on different
  1449. machines (@pxref{Invoking guix-daemon, container}).
  1450. @cindex substitutes
  1451. This foundation allows Guix to support @dfn{transparent binary/source
  1452. deployment}. When a pre-built binary for a @file{/gnu/store} item is
  1453. available from an external source---a @dfn{substitute}, Guix just
  1454. downloads it and unpacks it;
  1455. otherwise, it builds the package from source, locally
  1456. (@pxref{Substitutes}). Because build results are usually bit-for-bit
  1457. reproducible, users do not have to trust servers that provide
  1458. substitutes: they can force a local build and @emph{challenge} providers
  1459. (@pxref{Invoking guix challenge}).
  1460. Control over the build environment is a feature that is also useful for
  1461. developers. The @command{guix environment} command allows developers of
  1462. a package to quickly set up the right development environment for their
  1463. package, without having to manually install the dependencies of the
  1464. package into their profile (@pxref{Invoking guix environment}).
  1465. @cindex replication, of software environments
  1466. @cindex provenance tracking, of software artifacts
  1467. All of Guix and its package definitions is version-controlled, and
  1468. @command{guix pull} allows you to ``travel in time'' on the history of Guix
  1469. itself (@pxref{Invoking guix pull}). This makes it possible to replicate a
  1470. Guix instance on a different machine or at a later point in time, which in
  1471. turn allows you to @emph{replicate complete software environments}, while
  1472. retaining precise @dfn{provenance tracking} of the software.
  1473. @node Invoking guix package
  1474. @section Invoking @command{guix package}
  1475. @cindex installing packages
  1476. @cindex removing packages
  1477. @cindex package installation
  1478. @cindex package removal
  1479. The @command{guix package} command is the tool that allows users to
  1480. install, upgrade, and remove packages, as well as rolling back to
  1481. previous configurations. It operates only on the user's own profile,
  1482. and works with normal user privileges (@pxref{Features}). Its syntax
  1483. is:
  1484. @example
  1485. guix package @var{options}
  1486. @end example
  1487. @cindex transactions
  1488. Primarily, @var{options} specifies the operations to be performed during
  1489. the transaction. Upon completion, a new profile is created, but
  1490. previous @dfn{generations} of the profile remain available, should the user
  1491. want to roll back.
  1492. For example, to remove @code{lua} and install @code{guile} and
  1493. @code{guile-cairo} in a single transaction:
  1494. @example
  1495. guix package -r lua -i guile guile-cairo
  1496. @end example
  1497. @command{guix package} also supports a @dfn{declarative approach}
  1498. whereby the user specifies the exact set of packages to be available and
  1499. passes it @i{via} the @option{--manifest} option
  1500. (@pxref{profile-manifest, @option{--manifest}}).
  1501. @cindex profile
  1502. For each user, a symlink to the user's default profile is automatically
  1503. created in @file{$HOME/.guix-profile}. This symlink always points to the
  1504. current generation of the user's default profile. Thus, users can add
  1505. @file{$HOME/.guix-profile/bin} to their @code{PATH} environment
  1506. variable, and so on.
  1507. @cindex search paths
  1508. If you are not using the Guix System Distribution, consider adding the
  1509. following lines to your @file{~/.bash_profile} (@pxref{Bash Startup
  1510. Files,,, bash, The GNU Bash Reference Manual}) so that newly-spawned
  1511. shells get all the right environment variable definitions:
  1512. @example
  1513. GUIX_PROFILE="$HOME/.guix-profile" ; \
  1514. source "$HOME/.guix-profile/etc/profile"
  1515. @end example
  1516. In a multi-user setup, user profiles are stored in a place registered as
  1517. a @dfn{garbage-collector root}, which @file{$HOME/.guix-profile} points
  1518. to (@pxref{Invoking guix gc}). That directory is normally
  1519. @code{@var{localstatedir}/guix/profiles/per-user/@var{user}}, where
  1520. @var{localstatedir} is the value passed to @code{configure} as
  1521. @code{--localstatedir}, and @var{user} is the user name. The
  1522. @file{per-user} directory is created when @command{guix-daemon} is
  1523. started, and the @var{user} sub-directory is created by @command{guix
  1524. package}.
  1525. The @var{options} can be among the following:
  1526. @table @code
  1527. @item --install=@var{package} @dots{}
  1528. @itemx -i @var{package} @dots{}
  1529. Install the specified @var{package}s.
  1530. Each @var{package} may specify either a simple package name, such as
  1531. @code{guile}, or a package name followed by an at-sign and version number,
  1532. such as @code{guile@@1.8.8} or simply @code{guile@@1.8} (in the latter
  1533. case, the newest version prefixed by @code{1.8} is selected.)
  1534. If no version number is specified, the
  1535. newest available version will be selected. In addition, @var{package}
  1536. may contain a colon, followed by the name of one of the outputs of the
  1537. package, as in @code{gcc:doc} or @code{binutils@@2.22:lib}
  1538. (@pxref{Packages with Multiple Outputs}). Packages with a corresponding
  1539. name (and optionally version) are searched for among the GNU
  1540. distribution modules (@pxref{Package Modules}).
  1541. @cindex propagated inputs
  1542. Sometimes packages have @dfn{propagated inputs}: these are dependencies
  1543. that automatically get installed along with the required package
  1544. (@pxref{package-propagated-inputs, @code{propagated-inputs} in
  1545. @code{package} objects}, for information about propagated inputs in
  1546. package definitions).
  1547. @anchor{package-cmd-propagated-inputs}
  1548. An example is the GNU MPC library: its C header files refer to those of
  1549. the GNU MPFR library, which in turn refer to those of the GMP library.
  1550. Thus, when installing MPC, the MPFR and GMP libraries also get installed
  1551. in the profile; removing MPC also removes MPFR and GMP---unless they had
  1552. also been explicitly installed by the user.
  1553. Besides, packages sometimes rely on the definition of environment
  1554. variables for their search paths (see explanation of
  1555. @code{--search-paths} below). Any missing or possibly incorrect
  1556. environment variable definitions are reported here.
  1557. @item --install-from-expression=@var{exp}
  1558. @itemx -e @var{exp}
  1559. Install the package @var{exp} evaluates to.
  1560. @var{exp} must be a Scheme expression that evaluates to a
  1561. @code{<package>} object. This option is notably useful to disambiguate
  1562. between same-named variants of a package, with expressions such as
  1563. @code{(@@ (gnu packages base) guile-final)}.
  1564. Note that this option installs the first output of the specified
  1565. package, which may be insufficient when needing a specific output of a
  1566. multiple-output package.
  1567. @item --install-from-file=@var{file}
  1568. @itemx -f @var{file}
  1569. Install the package that the code within @var{file} evaluates to.
  1570. As an example, @var{file} might contain a definition like this
  1571. (@pxref{Defining Packages}):
  1572. @example
  1573. @verbatiminclude package-hello.scm
  1574. @end example
  1575. Developers may find it useful to include such a @file{guix.scm} file
  1576. in the root of their project source tree that can be used to test
  1577. development snapshots and create reproducible development environments
  1578. (@pxref{Invoking guix environment}).
  1579. @item --remove=@var{package} @dots{}
  1580. @itemx -r @var{package} @dots{}
  1581. Remove the specified @var{package}s.
  1582. As for @code{--install}, each @var{package} may specify a version number
  1583. and/or output name in addition to the package name. For instance,
  1584. @code{-r glibc:debug} would remove the @code{debug} output of
  1585. @code{glibc}.
  1586. @item --upgrade[=@var{regexp} @dots{}]
  1587. @itemx -u [@var{regexp} @dots{}]
  1588. @cindex upgrading packages
  1589. Upgrade all the installed packages. If one or more @var{regexp}s are
  1590. specified, upgrade only installed packages whose name matches a
  1591. @var{regexp}. Also see the @code{--do-not-upgrade} option below.
  1592. Note that this upgrades package to the latest version of packages found
  1593. in the distribution currently installed. To update your distribution,
  1594. you should regularly run @command{guix pull} (@pxref{Invoking guix
  1595. pull}).
  1596. @item --do-not-upgrade[=@var{regexp} @dots{}]
  1597. When used together with the @code{--upgrade} option, do @emph{not}
  1598. upgrade any packages whose name matches a @var{regexp}. For example, to
  1599. upgrade all packages in the current profile except those containing the
  1600. substring ``emacs'':
  1601. @example
  1602. $ guix package --upgrade . --do-not-upgrade emacs
  1603. @end example
  1604. @item @anchor{profile-manifest}--manifest=@var{file}
  1605. @itemx -m @var{file}
  1606. @cindex profile declaration
  1607. @cindex profile manifest
  1608. Create a new generation of the profile from the manifest object
  1609. returned by the Scheme code in @var{file}.
  1610. This allows you to @emph{declare} the profile's contents rather than
  1611. constructing it through a sequence of @code{--install} and similar
  1612. commands. The advantage is that @var{file} can be put under version
  1613. control, copied to different machines to reproduce the same profile, and
  1614. so on.
  1615. @c FIXME: Add reference to (guix profile) documentation when available.
  1616. @var{file} must return a @dfn{manifest} object, which is roughly a list
  1617. of packages:
  1618. @findex packages->manifest
  1619. @example
  1620. (use-package-modules guile emacs)
  1621. (packages->manifest
  1622. (list emacs
  1623. guile-2.0
  1624. ;; Use a specific package output.
  1625. (list guile-2.0 "debug")))
  1626. @end example
  1627. @findex specifications->manifest
  1628. In this example we have to know which modules define the @code{emacs}
  1629. and @code{guile-2.0} variables to provide the right
  1630. @code{use-package-modules} line, which can be cumbersome. We can
  1631. instead provide regular package specifications and let
  1632. @code{specifications->manifest} look up the corresponding package
  1633. objects, like this:
  1634. @example
  1635. (specifications->manifest
  1636. '("emacs" "guile@@2.2" "guile@@2.2:debug"))
  1637. @end example
  1638. @item --roll-back
  1639. @cindex rolling back
  1640. @cindex undoing transactions
  1641. @cindex transactions, undoing
  1642. Roll back to the previous @dfn{generation} of the profile---i.e., undo
  1643. the last transaction.
  1644. When combined with options such as @code{--install}, roll back occurs
  1645. before any other actions.
  1646. When rolling back from the first generation that actually contains
  1647. installed packages, the profile is made to point to the @dfn{zeroth
  1648. generation}, which contains no files apart from its own metadata.
  1649. After having rolled back, installing, removing, or upgrading packages
  1650. overwrites previous future generations. Thus, the history of the
  1651. generations in a profile is always linear.
  1652. @item --switch-generation=@var{pattern}
  1653. @itemx -S @var{pattern}
  1654. @cindex generations
  1655. Switch to a particular generation defined by @var{pattern}.
  1656. @var{pattern} may be either a generation number or a number prefixed
  1657. with ``+'' or ``-''. The latter means: move forward/backward by a
  1658. specified number of generations. For example, if you want to return to
  1659. the latest generation after @code{--roll-back}, use
  1660. @code{--switch-generation=+1}.
  1661. The difference between @code{--roll-back} and
  1662. @code{--switch-generation=-1} is that @code{--switch-generation} will
  1663. not make a zeroth generation, so if a specified generation does not
  1664. exist, the current generation will not be changed.
  1665. @item --search-paths[=@var{kind}]
  1666. @cindex search paths
  1667. Report environment variable definitions, in Bash syntax, that may be
  1668. needed in order to use the set of installed packages. These environment
  1669. variables are used to specify @dfn{search paths} for files used by some
  1670. of the installed packages.
  1671. For example, GCC needs the @code{CPATH} and @code{LIBRARY_PATH}
  1672. environment variables to be defined so it can look for headers and
  1673. libraries in the user's profile (@pxref{Environment Variables,,, gcc,
  1674. Using the GNU Compiler Collection (GCC)}). If GCC and, say, the C
  1675. library are installed in the profile, then @code{--search-paths} will
  1676. suggest setting these variables to @code{@var{profile}/include} and
  1677. @code{@var{profile}/lib}, respectively.
  1678. The typical use case is to define these environment variables in the
  1679. shell:
  1680. @example
  1681. $ eval `guix package --search-paths`
  1682. @end example
  1683. @var{kind} may be one of @code{exact}, @code{prefix}, or @code{suffix},
  1684. meaning that the returned environment variable definitions will either
  1685. be exact settings, or prefixes or suffixes of the current value of these
  1686. variables. When omitted, @var{kind} defaults to @code{exact}.
  1687. This option can also be used to compute the @emph{combined} search paths
  1688. of several profiles. Consider this example:
  1689. @example
  1690. $ guix package -p foo -i guile
  1691. $ guix package -p bar -i guile-json
  1692. $ guix package -p foo -p bar --search-paths
  1693. @end example
  1694. The last command above reports about the @code{GUILE_LOAD_PATH}
  1695. variable, even though, taken individually, neither @file{foo} nor
  1696. @file{bar} would lead to that recommendation.
  1697. @item --profile=@var{profile}
  1698. @itemx -p @var{profile}
  1699. Use @var{profile} instead of the user's default profile.
  1700. @cindex collisions, in a profile
  1701. @cindex colliding packages in profiles
  1702. @cindex profile collisions
  1703. @item --allow-collisions
  1704. Allow colliding packages in the new profile. Use at your own risk!
  1705. By default, @command{guix package} reports as an error @dfn{collisions}
  1706. in the profile. Collisions happen when two or more different versions
  1707. or variants of a given package end up in the profile.
  1708. @item --verbose
  1709. Produce verbose output. In particular, emit the build log of the
  1710. environment on the standard error port.
  1711. @item --bootstrap
  1712. Use the bootstrap Guile to build the profile. This option is only
  1713. useful to distribution developers.
  1714. @end table
  1715. In addition to these actions, @command{guix package} supports the
  1716. following options to query the current state of a profile, or the
  1717. availability of packages:
  1718. @table @option
  1719. @item --search=@var{regexp}
  1720. @itemx -s @var{regexp}
  1721. @cindex searching for packages
  1722. List the available packages whose name, synopsis, or description matches
  1723. @var{regexp}, sorted by relevance. Print all the metadata of matching packages in
  1724. @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils,
  1725. GNU recutils manual}).
  1726. This allows specific fields to be extracted using the @command{recsel}
  1727. command, for instance:
  1728. @example
  1729. $ guix package -s malloc | recsel -p name,version,relevance
  1730. name: jemalloc
  1731. version: 4.5.0
  1732. relevance: 6
  1733. name: glibc
  1734. version: 2.25
  1735. relevance: 1
  1736. name: libgc
  1737. version: 7.6.0
  1738. relevance: 1
  1739. @end example
  1740. Similarly, to show the name of all the packages available under the
  1741. terms of the GNU@tie{}LGPL version 3:
  1742. @example
  1743. $ guix package -s "" | recsel -p name -e 'license ~ "LGPL 3"'
  1744. name: elfutils
  1745. name: gmp
  1746. @dots{}
  1747. @end example
  1748. It is also possible to refine search results using several @code{-s}
  1749. flags. For example, the following command returns a list of board
  1750. games:
  1751. @example
  1752. $ guix package -s '\<board\>' -s game | recsel -p name
  1753. name: gnubg
  1754. @dots{}
  1755. @end example
  1756. If we were to omit @code{-s game}, we would also get software packages
  1757. that deal with printed circuit boards; removing the angle brackets
  1758. around @code{board} would further add packages that have to do with
  1759. keyboards.
  1760. And now for a more elaborate example. The following command searches
  1761. for cryptographic libraries, filters out Haskell, Perl, Python, and Ruby
  1762. libraries, and prints the name and synopsis of the matching packages:
  1763. @example
  1764. $ guix package -s crypto -s library | \
  1765. recsel -e '! (name ~ "^(ghc|perl|python|ruby)")' -p name,synopsis
  1766. @end example
  1767. @noindent
  1768. @xref{Selection Expressions,,, recutils, GNU recutils manual}, for more
  1769. information on @dfn{selection expressions} for @code{recsel -e}.
  1770. @item --show=@var{package}
  1771. Show details about @var{package}, taken from the list of available packages, in
  1772. @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils, GNU
  1773. recutils manual}).
  1774. @example
  1775. $ guix package --show=python | recsel -p name,version
  1776. name: python
  1777. version: 2.7.6
  1778. name: python
  1779. version: 3.3.5
  1780. @end example
  1781. You may also specify the full name of a package to only get details about a
  1782. specific version of it:
  1783. @example
  1784. $ guix package --show=python@@3.4 | recsel -p name,version
  1785. name: python
  1786. version: 3.4.3
  1787. @end example
  1788. @item --list-installed[=@var{regexp}]
  1789. @itemx -I [@var{regexp}]
  1790. List the currently installed packages in the specified profile, with the
  1791. most recently installed packages shown last. When @var{regexp} is
  1792. specified, list only installed packages whose name matches @var{regexp}.
  1793. For each installed package, print the following items, separated by
  1794. tabs: the package name, its version string, the part of the package that
  1795. is installed (for instance, @code{out} for the default output,
  1796. @code{include} for its headers, etc.), and the path of this package in
  1797. the store.
  1798. @item --list-available[=@var{regexp}]
  1799. @itemx -A [@var{regexp}]
  1800. List packages currently available in the distribution for this system
  1801. (@pxref{GNU Distribution}). When @var{regexp} is specified, list only
  1802. installed packages whose name matches @var{regexp}.
  1803. For each package, print the following items separated by tabs: its name,
  1804. its version string, the parts of the package (@pxref{Packages with
  1805. Multiple Outputs}), and the source location of its definition.
  1806. @item --list-generations[=@var{pattern}]
  1807. @itemx -l [@var{pattern}]
  1808. @cindex generations
  1809. Return a list of generations along with their creation dates; for each
  1810. generation, show the installed packages, with the most recently
  1811. installed packages shown last. Note that the zeroth generation is never
  1812. shown.
  1813. For each installed package, print the following items, separated by
  1814. tabs: the name of a package, its version string, the part of the package
  1815. that is installed (@pxref{Packages with Multiple Outputs}), and the
  1816. location of this package in the store.
  1817. When @var{pattern} is used, the command returns only matching
  1818. generations. Valid patterns include:
  1819. @itemize
  1820. @item @emph{Integers and comma-separated integers}. Both patterns denote
  1821. generation numbers. For instance, @code{--list-generations=1} returns
  1822. the first one.
  1823. And @code{--list-generations=1,8,2} outputs three generations in the
  1824. specified order. Neither spaces nor trailing commas are allowed.
  1825. @item @emph{Ranges}. @code{--list-generations=2..9} prints the
  1826. specified generations and everything in between. Note that the start of
  1827. a range must be smaller than its end.
  1828. It is also possible to omit the endpoint. For example,
  1829. @code{--list-generations=2..}, returns all generations starting from the
  1830. second one.
  1831. @item @emph{Durations}. You can also get the last @emph{N}@tie{}days, weeks,
  1832. or months by passing an integer along with the first letter of the
  1833. duration. For example, @code{--list-generations=20d} lists generations
  1834. that are up to 20 days old.
  1835. @end itemize
  1836. @item --delete-generations[=@var{pattern}]
  1837. @itemx -d [@var{pattern}]
  1838. When @var{pattern} is omitted, delete all generations except the current
  1839. one.
  1840. This command accepts the same patterns as @option{--list-generations}.
  1841. When @var{pattern} is specified, delete the matching generations. When
  1842. @var{pattern} specifies a duration, generations @emph{older} than the
  1843. specified duration match. For instance, @code{--delete-generations=1m}
  1844. deletes generations that are more than one month old.
  1845. If the current generation matches, it is @emph{not} deleted. Also, the
  1846. zeroth generation is never deleted.
  1847. Note that deleting generations prevents rolling back to them.
  1848. Consequently, this command must be used with care.
  1849. @end table
  1850. Finally, since @command{guix package} may actually start build
  1851. processes, it supports all the common build options (@pxref{Common Build
  1852. Options}). It also supports package transformation options, such as
  1853. @option{--with-source} (@pxref{Package Transformation Options}).
  1854. However, note that package transformations are lost when upgrading; to
  1855. preserve transformations across upgrades, you should define your own
  1856. package variant in a Guile module and add it to @code{GUIX_PACKAGE_PATH}
  1857. (@pxref{Defining Packages}).
  1858. @node Substitutes
  1859. @section Substitutes
  1860. @cindex substitutes
  1861. @cindex pre-built binaries
  1862. Guix supports transparent source/binary deployment, which means that it
  1863. can either build things locally, or download pre-built items from a
  1864. server, or both. We call these pre-built items @dfn{substitutes}---they
  1865. are substitutes for local build results. In many cases, downloading a
  1866. substitute is much faster than building things locally.
  1867. Substitutes can be anything resulting from a derivation build
  1868. (@pxref{Derivations}). Of course, in the common case, they are
  1869. pre-built package binaries, but source tarballs, for instance, which
  1870. also result from derivation builds, can be available as substitutes.
  1871. @menu
  1872. * Official Substitute Server:: One particular source of substitutes.
  1873. * Substitute Server Authorization:: How to enable or disable substitutes.
  1874. * Substitute Authentication:: How Guix verifies substitutes.
  1875. * Proxy Settings:: How to get substitutes via proxy.
  1876. * Substitution Failure:: What happens when substitution fails.
  1877. * On Trusting Binaries:: How can you trust that binary blob?
  1878. @end menu
  1879. @node Official Substitute Server
  1880. @subsection Official Substitute Server
  1881. @cindex hydra
  1882. @cindex build farm
  1883. The @code{@value{SUBSTITUTE-SERVER}} server is a front-end to an official build farm
  1884. that builds packages from Guix continuously for some
  1885. architectures, and makes them available as substitutes. This is the
  1886. default source of substitutes; it can be overridden by passing the
  1887. @option{--substitute-urls} option either to @command{guix-daemon}
  1888. (@pxref{daemon-substitute-urls,, @code{guix-daemon --substitute-urls}})
  1889. or to client tools such as @command{guix package}
  1890. (@pxref{client-substitute-urls,, client @option{--substitute-urls}
  1891. option}).
  1892. Substitute URLs can be either HTTP or HTTPS.
  1893. HTTPS is recommended because communications are encrypted; conversely,
  1894. using HTTP makes all communications visible to an eavesdropper, who
  1895. could use the information gathered to determine, for instance, whether
  1896. your system has unpatched security vulnerabilities.
  1897. Substitutes from the official build farm are enabled by default when
  1898. using the Guix System Distribution (@pxref{GNU Distribution}). However,
  1899. they are disabled by default when using Guix on a foreign distribution,
  1900. unless you have explicitly enabled them via one of the recommended
  1901. installation steps (@pxref{Installation}). The following paragraphs
  1902. describe how to enable or disable substitutes for the official build
  1903. farm; the same procedure can also be used to enable substitutes for any
  1904. other substitute server.
  1905. @node Substitute Server Authorization
  1906. @subsection Substitute Server Authorization
  1907. @cindex security
  1908. @cindex substitutes, authorization thereof
  1909. @cindex access control list (ACL), for substitutes
  1910. @cindex ACL (access control list), for substitutes
  1911. To allow Guix to download substitutes from @code{@value{SUBSTITUTE-SERVER}} or a
  1912. mirror thereof, you
  1913. must add its public key to the access control list (ACL) of archive
  1914. imports, using the @command{guix archive} command (@pxref{Invoking guix
  1915. archive}). Doing so implies that you trust @code{@value{SUBSTITUTE-SERVER}} to not
  1916. be compromised and to serve genuine substitutes.
  1917. The public key for @code{@value{SUBSTITUTE-SERVER}} is installed along with Guix, in
  1918. @code{@var{prefix}/share/guix/@value{SUBSTITUTE-SERVER}.pub}, where @var{prefix} is
  1919. the installation prefix of Guix. If you installed Guix from source,
  1920. make sure you checked the GPG signature of
  1921. @file{guix-@value{VERSION}.tar.gz}, which contains this public key file.
  1922. Then, you can run something like this:
  1923. @example
  1924. # guix archive --authorize < @var{prefix}/share/guix/@value{SUBSTITUTE-SERVER}.pub
  1925. @end example
  1926. @quotation Note
  1927. Similarly, the @file{hydra.gnu.org.pub} file contains the public key
  1928. of an independent build farm also run by the project, reachable at
  1929. @indicateurl{https://mirror.hydra.gnu.org}.
  1930. @end quotation
  1931. Once this is in place, the output of a command like @code{guix build}
  1932. should change from something like:
  1933. @example
  1934. $ guix build emacs --dry-run
  1935. The following derivations would be built:
  1936. /gnu/store/yr7bnx8xwcayd6j95r2clmkdl1qh688w-emacs-24.3.drv
  1937. /gnu/store/x8qsh1hlhgjx6cwsjyvybnfv2i37z23w-dbus-1.6.4.tar.gz.drv
  1938. /gnu/store/1ixwp12fl950d15h2cj11c73733jay0z-alsa-lib-1.0.27.1.tar.bz2.drv
  1939. /gnu/store/nlma1pw0p603fpfiqy7kn4zm105r5dmw-util-linux-2.21.drv
  1940. @dots{}
  1941. @end example
  1942. @noindent
  1943. to something like:
  1944. @example
  1945. $ guix build emacs --dry-run
  1946. 112.3 MB would be downloaded:
  1947. /gnu/store/pk3n22lbq6ydamyymqkkz7i69wiwjiwi-emacs-24.3
  1948. /gnu/store/2ygn4ncnhrpr61rssa6z0d9x22si0va3-libjpeg-8d
  1949. /gnu/store/71yz6lgx4dazma9dwn2mcjxaah9w77jq-cairo-1.12.16
  1950. /gnu/store/7zdhgp0n1518lvfn8mb96sxqfmvqrl7v-libxrender-0.9.7
  1951. @dots{}
  1952. @end example
  1953. @noindent
  1954. This indicates that substitutes from @code{@value{SUBSTITUTE-SERVER}} are usable and
  1955. will be downloaded, when possible, for future builds.
  1956. @cindex substitutes, how to disable
  1957. The substitute mechanism can be disabled globally by running
  1958. @code{guix-daemon} with @code{--no-substitutes} (@pxref{Invoking
  1959. guix-daemon}). It can also be disabled temporarily by passing the
  1960. @code{--no-substitutes} option to @command{guix package}, @command{guix
  1961. build}, and other command-line tools.
  1962. @node Substitute Authentication
  1963. @subsection Substitute Authentication
  1964. @cindex digital signatures
  1965. Guix detects and raises an error when attempting to use a substitute
  1966. that has been tampered with. Likewise, it ignores substitutes that are
  1967. not signed, or that are not signed by one of the keys listed in the ACL.
  1968. There is one exception though: if an unauthorized server provides
  1969. substitutes that are @emph{bit-for-bit identical} to those provided by
  1970. an authorized server, then the unauthorized server becomes eligible for
  1971. downloads. For example, assume we have chosen two substitute servers
  1972. with this option:
  1973. @example
  1974. --substitute-urls="https://a.example.org https://b.example.org"
  1975. @end example
  1976. @noindent
  1977. @cindex reproducible builds
  1978. If the ACL contains only the key for @code{b.example.org}, and if
  1979. @code{a.example.org} happens to serve the @emph{exact same} substitutes,
  1980. then Guix will download substitutes from @code{a.example.org} because it
  1981. comes first in the list and can be considered a mirror of
  1982. @code{b.example.org}. In practice, independent build machines usually
  1983. produce the same binaries, thanks to bit-reproducible builds (see
  1984. below).
  1985. When using HTTPS, the server's X.509 certificate is @emph{not} validated
  1986. (in other words, the server is not authenticated), contrary to what
  1987. HTTPS clients such as Web browsers usually do. This is because Guix
  1988. authenticates substitute information itself, as explained above, which
  1989. is what we care about (whereas X.509 certificates are about
  1990. authenticating bindings between domain names and public keys.)
  1991. @node Proxy Settings
  1992. @subsection Proxy Settings
  1993. @vindex http_proxy
  1994. Substitutes are downloaded over HTTP or HTTPS.
  1995. The @code{http_proxy} environment
  1996. variable can be set in the environment of @command{guix-daemon} and is
  1997. honored for downloads of substitutes. Note that the value of
  1998. @code{http_proxy} in the environment where @command{guix build},
  1999. @command{guix package}, and other client commands are run has
  2000. @emph{absolutely no effect}.
  2001. @node Substitution Failure
  2002. @subsection Substitution Failure
  2003. Even when a substitute for a derivation is available, sometimes the
  2004. substitution attempt will fail. This can happen for a variety of
  2005. reasons: the substitute server might be offline, the substitute may
  2006. recently have been deleted, the connection might have been interrupted,
  2007. etc.
  2008. When substitutes are enabled and a substitute for a derivation is
  2009. available, but the substitution attempt fails, Guix will attempt to
  2010. build the derivation locally depending on whether or not
  2011. @code{--fallback} was given (@pxref{fallback-option,, common build
  2012. option @code{--fallback}}). Specifically, if @code{--fallback} was
  2013. omitted, then no local build will be performed, and the derivation is
  2014. considered to have failed. However, if @code{--fallback} was given,
  2015. then Guix will attempt to build the derivation locally, and the success
  2016. or failure of the derivation depends on the success or failure of the
  2017. local build. Note that when substitutes are disabled or no substitute
  2018. is available for the derivation in question, a local build will
  2019. @emph{always} be performed, regardless of whether or not
  2020. @code{--fallback} was given.
  2021. To get an idea of how many substitutes are available right now, you can
  2022. try running the @command{guix weather} command (@pxref{Invoking guix
  2023. weather}). This command provides statistics on the substitutes provided
  2024. by a server.
  2025. @node On Trusting Binaries
  2026. @subsection On Trusting Binaries
  2027. @cindex trust, of pre-built binaries
  2028. Today, each individual's control over their own computing is at the
  2029. mercy of institutions, corporations, and groups with enough power and
  2030. determination to subvert the computing infrastructure and exploit its
  2031. weaknesses. While using @code{@value{SUBSTITUTE-SERVER}} substitutes can be
  2032. convenient, we encourage users to also build on their own, or even run
  2033. their own build farm, such that @code{@value{SUBSTITUTE-SERVER}} is less of an
  2034. interesting target. One way to help is by publishing the software you
  2035. build using @command{guix publish} so that others have one more choice
  2036. of server to download substitutes from (@pxref{Invoking guix publish}).
  2037. Guix has the foundations to maximize build reproducibility
  2038. (@pxref{Features}). In most cases, independent builds of a given
  2039. package or derivation should yield bit-identical results. Thus, through
  2040. a diverse set of independent package builds, we can strengthen the
  2041. integrity of our systems. The @command{guix challenge} command aims to
  2042. help users assess substitute servers, and to assist developers in
  2043. finding out about non-deterministic package builds (@pxref{Invoking guix
  2044. challenge}). Similarly, the @option{--check} option of @command{guix
  2045. build} allows users to check whether previously-installed substitutes
  2046. are genuine by rebuilding them locally (@pxref{build-check,
  2047. @command{guix build --check}}).
  2048. In the future, we want Guix to have support to publish and retrieve
  2049. binaries to/from other users, in a peer-to-peer fashion. If you would
  2050. like to discuss this project, join us on @email{guix-devel@@gnu.org}.
  2051. @node Packages with Multiple Outputs
  2052. @section Packages with Multiple Outputs
  2053. @cindex multiple-output packages
  2054. @cindex package outputs
  2055. @cindex outputs
  2056. Often, packages defined in Guix have a single @dfn{output}---i.e., the
  2057. source package leads to exactly one directory in the store. When running
  2058. @command{guix package -i glibc}, one installs the default output of the
  2059. GNU libc package; the default output is called @code{out}, but its name
  2060. can be omitted as shown in this command. In this particular case, the
  2061. default output of @code{glibc} contains all the C header files, shared
  2062. libraries, static libraries, Info documentation, and other supporting
  2063. files.
  2064. Sometimes it is more appropriate to separate the various types of files
  2065. produced from a single source package into separate outputs. For
  2066. instance, the GLib C library (used by GTK+ and related packages)
  2067. installs more than 20 MiB of reference documentation as HTML pages.
  2068. To save space for users who do not need it, the documentation goes to a
  2069. separate output, called @code{doc}. To install the main GLib output,
  2070. which contains everything but the documentation, one would run:
  2071. @example
  2072. guix package -i glib
  2073. @end example
  2074. @cindex documentation
  2075. The command to install its documentation is:
  2076. @example
  2077. guix package -i glib:doc
  2078. @end example
  2079. Some packages install programs with different ``dependency footprints''.
  2080. For instance, the WordNet package installs both command-line tools and
  2081. graphical user interfaces (GUIs). The former depend solely on the C
  2082. library, whereas the latter depend on Tcl/Tk and the underlying X
  2083. libraries. In this case, we leave the command-line tools in the default
  2084. output, whereas the GUIs are in a separate output. This allows users
  2085. who do not need the GUIs to save space. The @command{guix size} command
  2086. can help find out about such situations (@pxref{Invoking guix size}).
  2087. @command{guix graph} can also be helpful (@pxref{Invoking guix graph}).
  2088. There are several such multiple-output packages in the GNU distribution.
  2089. Other conventional output names include @code{lib} for libraries and
  2090. possibly header files, @code{bin} for stand-alone programs, and
  2091. @code{debug} for debugging information (@pxref{Installing Debugging
  2092. Files}). The outputs of a packages are listed in the third column of
  2093. the output of @command{guix package --list-available} (@pxref{Invoking
  2094. guix package}).
  2095. @node Invoking guix gc
  2096. @section Invoking @command{guix gc}
  2097. @cindex garbage collector
  2098. @cindex disk space
  2099. Packages that are installed, but not used, may be @dfn{garbage-collected}.
  2100. The @command{guix gc} command allows users to explicitly run the garbage
  2101. collector to reclaim space from the @file{/gnu/store} directory. It is
  2102. the @emph{only} way to remove files from @file{/gnu/store}---removing
  2103. files or directories manually may break it beyond repair!
  2104. @cindex GC roots
  2105. @cindex garbage collector roots
  2106. The garbage collector has a set of known @dfn{roots}: any file under
  2107. @file{/gnu/store} reachable from a root is considered @dfn{live} and
  2108. cannot be deleted; any other file is considered @dfn{dead} and may be
  2109. deleted. The set of garbage collector roots (``GC roots'' for short)
  2110. includes default user profiles; by default, the symlinks under
  2111. @file{/var/guix/gcroots} represent these GC roots. New GC roots can be
  2112. added with @command{guix build --root}, for example (@pxref{Invoking
  2113. guix build}).
  2114. Prior to running @code{guix gc --collect-garbage} to make space, it is
  2115. often useful to remove old generations from user profiles; that way, old
  2116. package builds referenced by those generations can be reclaimed. This
  2117. is achieved by running @code{guix package --delete-generations}
  2118. (@pxref{Invoking guix package}).
  2119. Our recommendation is to run a garbage collection periodically, or when
  2120. you are short on disk space. For instance, to guarantee that at least
  2121. 5@tie{}GB are available on your disk, simply run:
  2122. @example
  2123. guix gc -F 5G
  2124. @end example
  2125. It is perfectly safe to run as a non-interactive periodic job
  2126. (@pxref{Scheduled Job Execution}, for how to set up such a job on
  2127. GuixSD). Running @command{guix gc} with no arguments will collect as
  2128. much garbage as it can, but that is often inconvenient: you may find
  2129. yourself having to rebuild or re-download software that is ``dead'' from
  2130. the GC viewpoint but that is necessary to build other pieces of
  2131. software---e.g., the compiler tool chain.
  2132. The @command{guix gc} command has three modes of operation: it can be
  2133. used to garbage-collect any dead files (the default), to delete specific
  2134. files (the @code{--delete} option), to print garbage-collector
  2135. information, or for more advanced queries. The garbage collection
  2136. options are as follows:
  2137. @table @code
  2138. @item --collect-garbage[=@var{min}]
  2139. @itemx -C [@var{min}]
  2140. Collect garbage---i.e., unreachable @file{/gnu/store} files and
  2141. sub-directories. This is the default operation when no option is
  2142. specified.
  2143. When @var{min} is given, stop once @var{min} bytes have been collected.
  2144. @var{min} may be a number of bytes, or it may include a unit as a
  2145. suffix, such as @code{MiB} for mebibytes and @code{GB} for gigabytes
  2146. (@pxref{Block size, size specifications,, coreutils, GNU Coreutils}).
  2147. When @var{min} is omitted, collect all the garbage.
  2148. @item --free-space=@var{free}
  2149. @itemx -F @var{free}
  2150. Collect garbage until @var{free} space is available under
  2151. @file{/gnu/store}, if possible; @var{free} denotes storage space, such
  2152. as @code{500MiB}, as described above.
  2153. When @var{free} or more is already available in @file{/gnu/store}, do
  2154. nothing and exit immediately.
  2155. @item --delete
  2156. @itemx -d
  2157. Attempt to delete all the store files and directories specified as
  2158. arguments. This fails if some of the files are not in the store, or if
  2159. they are still live.
  2160. @item --list-failures
  2161. List store items corresponding to cached build failures.
  2162. This prints nothing unless the daemon was started with
  2163. @option{--cache-failures} (@pxref{Invoking guix-daemon,
  2164. @option{--cache-failures}}).
  2165. @item --clear-failures
  2166. Remove the specified store items from the failed-build cache.
  2167. Again, this option only makes sense when the daemon is started with
  2168. @option{--cache-failures}. Otherwise, it does nothing.
  2169. @item --list-dead
  2170. Show the list of dead files and directories still present in the
  2171. store---i.e., files and directories no longer reachable from any root.
  2172. @item --list-live
  2173. Show the list of live store files and directories.
  2174. @end table
  2175. In addition, the references among existing store files can be queried:
  2176. @table @code
  2177. @item --references
  2178. @itemx --referrers
  2179. @cindex package dependencies
  2180. List the references (respectively, the referrers) of store files given
  2181. as arguments.
  2182. @item --requisites
  2183. @itemx -R
  2184. @cindex closure
  2185. List the requisites of the store files passed as arguments. Requisites
  2186. include the store files themselves, their references, and the references
  2187. of these, recursively. In other words, the returned list is the
  2188. @dfn{transitive closure} of the store files.
  2189. @xref{Invoking guix size}, for a tool to profile the size of the closure
  2190. of an element. @xref{Invoking guix graph}, for a tool to visualize
  2191. the graph of references.
  2192. @item --derivers
  2193. @cindex derivation
  2194. Return the derivation(s) leading to the given store items
  2195. (@pxref{Derivations}).
  2196. For example, this command:
  2197. @example
  2198. guix gc --derivers `guix package -I ^emacs$ | cut -f4`
  2199. @end example
  2200. @noindent
  2201. returns the @file{.drv} file(s) leading to the @code{emacs} package
  2202. installed in your profile.
  2203. Note that there may be zero matching @file{.drv} files, for instance
  2204. because these files have been garbage-collected. There can also be more
  2205. than one matching @file{.drv} due to fixed-output derivations.
  2206. @end table
  2207. Lastly, the following options allow you to check the integrity of the
  2208. store and to control disk usage.
  2209. @table @option
  2210. @item --verify[=@var{options}]
  2211. @cindex integrity, of the store
  2212. @cindex integrity checking
  2213. Verify the integrity of the store.
  2214. By default, make sure that all the store items marked as valid in the
  2215. database of the daemon actually exist in @file{/gnu/store}.
  2216. When provided, @var{options} must be a comma-separated list containing one
  2217. or more of @code{contents} and @code{repair}.
  2218. When passing @option{--verify=contents}, the daemon computes the
  2219. content hash of each store item and compares it against its hash in the
  2220. database. Hash mismatches are reported as data corruptions. Because it
  2221. traverses @emph{all the files in the store}, this command can take a
  2222. long time, especially on systems with a slow disk drive.
  2223. @cindex repairing the store
  2224. @cindex corruption, recovering from
  2225. Using @option{--verify=repair} or @option{--verify=contents,repair}
  2226. causes the daemon to try to repair corrupt store items by fetching
  2227. substitutes for them (@pxref{Substitutes}). Because repairing is not
  2228. atomic, and thus potentially dangerous, it is available only to the
  2229. system administrator. A lightweight alternative, when you know exactly
  2230. which items in the store are corrupt, is @command{guix build --repair}
  2231. (@pxref{Invoking guix build}).
  2232. @item --optimize
  2233. @cindex deduplication
  2234. Optimize the store by hard-linking identical files---this is
  2235. @dfn{deduplication}.
  2236. The daemon performs deduplication after each successful build or archive
  2237. import, unless it was started with @code{--disable-deduplication}
  2238. (@pxref{Invoking guix-daemon, @code{--disable-deduplication}}). Thus,
  2239. this option is primarily useful when the daemon was running with
  2240. @code{--disable-deduplication}.
  2241. @end table
  2242. @node Invoking guix pull
  2243. @section Invoking @command{guix pull}
  2244. @cindex upgrading Guix
  2245. @cindex updating Guix
  2246. @cindex @command{guix pull}
  2247. @cindex pull
  2248. Packages are installed or upgraded to the latest version available in
  2249. the distribution currently available on your local machine. To update
  2250. that distribution, along with the Guix tools, you must run @command{guix
  2251. pull}: the command downloads the latest Guix source code and package
  2252. descriptions, and deploys it. Source code is downloaded from a
  2253. @uref{https://git-scm.com, Git} repository, by default the official
  2254. GNU@tie{}Guix repository, though this can be customized.
  2255. On completion, @command{guix package} will use packages and package
  2256. versions from this just-retrieved copy of Guix. Not only that, but all
  2257. the Guix commands and Scheme modules will also be taken from that latest
  2258. version. New @command{guix} sub-commands added by the update also
  2259. become available.
  2260. Any user can update their Guix copy using @command{guix pull}, and the
  2261. effect is limited to the user who run @command{guix pull}. For
  2262. instance, when user @code{root} runs @command{guix pull}, this has no
  2263. effect on the version of Guix that user @code{alice} sees, and vice
  2264. versa.
  2265. The result of running @command{guix pull} is a @dfn{profile} available
  2266. under @file{~/.config/guix/current} containing the latest Guix. Thus,
  2267. make sure to add it to the beginning of your search path so that you use
  2268. the latest version, and similarly for the Info manual
  2269. (@pxref{Documentation}):
  2270. @example
  2271. export PATH="$HOME/.config/guix/current/bin:$PATH"
  2272. export INFOPATH="$HOME/.config/guix/current/share/info:$INFOPATH"
  2273. @end example
  2274. The @code{--list-generations} or @code{-l} option lists past generations
  2275. produced by @command{guix pull}, along with details about their provenance:
  2276. @example
  2277. $ guix pull -l
  2278. Generation 1 Jun 10 2018 00:18:18
  2279. guix 65956ad
  2280. repository URL: https://git.savannah.gnu.org/git/guix.git
  2281. branch: origin/master
  2282. commit: 65956ad3526ba09e1f7a40722c96c6ef7c0936fe
  2283. Generation 2 Jun 11 2018 11:02:49
  2284. guix e0cc7f6
  2285. repository URL: https://git.savannah.gnu.org/git/guix.git
  2286. branch: origin/master
  2287. commit: e0cc7f669bec22c37481dd03a7941c7d11a64f1d
  2288. 2 new packages: keepalived, libnfnetlink
  2289. 6 packages upgraded: emacs-nix-mode@@2.0.4,
  2290. guile2.0-guix@@0.14.0-12.77a1aac, guix@@0.14.0-12.77a1aac,
  2291. heimdal@@7.5.0, milkytracker@@1.02.00, nix@@2.0.4
  2292. Generation 3 Jun 13 2018 23:31:07 (current)
  2293. guix 844cc1c
  2294. repository URL: https://git.savannah.gnu.org/git/guix.git
  2295. branch: origin/master
  2296. commit: 844cc1c8f394f03b404c5bb3aee086922373490c
  2297. 28 new packages: emacs-helm-ls-git, emacs-helm-mu, @dots{}
  2298. 69 packages upgraded: borg@@1.1.6, cheese@@3.28.0, @dots{}
  2299. @end example
  2300. @ref{Invoking guix describe, @command{guix describe}}, for other ways to
  2301. describe the current status of Guix.
  2302. This @code{~/.config/guix/current} profile works like any other profile
  2303. created by @command{guix package} (@pxref{Invoking guix package}). That
  2304. is, you can list generations, roll back to the previous
  2305. generation---i.e., the previous Guix---and so on:
  2306. @example
  2307. $ guix package -p ~/.config/guix/current --roll-back
  2308. switched from generation 3 to 2
  2309. $ guix package -p ~/.config/guix/current --delete-generations=1
  2310. deleting /var/guix/profiles/per-user/charlie/current-guix-1-link
  2311. @end example
  2312. The @command{guix pull} command is usually invoked with no arguments,
  2313. but it supports the following options:
  2314. @table @code
  2315. @item --url=@var{url}
  2316. @itemx --commit=@var{commit}
  2317. @itemx --branch=@var{branch}
  2318. Download code from the specified @var{url}, at the given @var{commit} (a valid
  2319. Git commit ID represented as a hexadecimal string), or @var{branch}.
  2320. @cindex @file{channels.scm}, configuration file
  2321. @cindex configuration file for channels
  2322. These options are provided for convenience, but you can also specify your
  2323. configuration in the @file{~/.config/guix/channels.scm} file or using the
  2324. @option{--channels} option (see below).
  2325. @item --channels=@var{file}
  2326. @itemx -C @var{file}
  2327. Read the list of channels from @var{file} instead of
  2328. @file{~/.config/guix/channels.scm}. @var{file} must contain Scheme code that
  2329. evaluates to a list of channel objects. @xref{Channels}, for more
  2330. information.
  2331. @item --list-generations[=@var{pattern}]
  2332. @itemx -l [@var{pattern}]
  2333. List all the generations of @file{~/.config/guix/current} or, if @var{pattern}
  2334. is provided, the subset of generations that match @var{pattern}.
  2335. The syntax of @var{pattern} is the same as with @code{guix package
  2336. --list-generations} (@pxref{Invoking guix package}).
  2337. @ref{Invoking guix describe}, for a way to display information about the
  2338. current generation only.
  2339. @item --profile=@var{profile}
  2340. @itemx -p @var{profile}
  2341. Use @var{profile} instead of @file{~/.config/guix/current}.
  2342. @item --dry-run
  2343. @itemx -n
  2344. Show which channel commit(s) would be used and what would be built or
  2345. substituted but do not actually do it.
  2346. @item --verbose
  2347. Produce verbose output, writing build logs to the standard error output.
  2348. @item --bootstrap
  2349. Use the bootstrap Guile to build the latest Guix. This option is only
  2350. useful to Guix developers.
  2351. @end table
  2352. The @dfn{channel} mechanism allows you to instruct @command{guix pull} which
  2353. repository and branch to pull from, as well as @emph{additional} repositories
  2354. containing package modules that should be deployed. @xref{Channels}, for more
  2355. information.
  2356. In addition, @command{guix pull} supports all the common build options
  2357. (@pxref{Common Build Options}).
  2358. @node Channels
  2359. @section Channels
  2360. @cindex channels
  2361. @cindex @file{channels.scm}, configuration file
  2362. @cindex configuration file for channels
  2363. @cindex @command{guix pull}, configuration file
  2364. @cindex configuration of @command{guix pull}
  2365. Guix and its package collection are updated by running @command{guix pull}
  2366. (@pxref{Invoking guix pull}). By default @command{guix pull} downloads and
  2367. deploys Guix itself from the official GNU@tie{}Guix repository. This can be
  2368. customized by defining @dfn{channels} in the
  2369. @file{~/.config/guix/channels.scm} file. A channel specifies a URL and branch
  2370. of a Git repository to be deployed, and @command{guix pull} can be instructed
  2371. to pull from one or more channels. In other words, channels can be used to
  2372. @emph{customize} and to @emph{extend} Guix, as we will see below.
  2373. @subsection Using a Custom Guix Channel
  2374. The channel called @code{guix} specifies where Guix itself---its command-line
  2375. tools as well as its package collection---should be downloaded. For instance,
  2376. suppose you want to update from your own copy of the Guix repository at
  2377. @code{example.org}, and specifically the @code{super-hacks} branch, you can
  2378. write in @code{~/.config/guix/channels.scm} this specification:
  2379. @lisp
  2380. ;; Tell 'guix pull' to use my own repo.
  2381. (list (channel
  2382. (name 'guix)
  2383. (url "https://example.org/my-guix.git")
  2384. (branch "super-hacks")))
  2385. @end lisp
  2386. @noindent
  2387. From there on, @command{guix pull} will fetch code from the @code{super-hacks}
  2388. branch of the repository at @code{example.org}.
  2389. @subsection Specifying Additional Channels
  2390. @cindex extending the package collection (channels)
  2391. @cindex personal packages (channels)
  2392. @cindex channels, for personal packages
  2393. You can also specify @emph{additional channels} to pull from. Let's say you
  2394. have a bunch of custom package variants or personal packages that you think
  2395. would make little sense to contribute to the Guix project, but would like to
  2396. have these packages transparently available to you at the command line. You
  2397. would first write modules containing those package definitions (@pxref{Package
  2398. Modules}), maintain them in a Git repository, and then you and anyone else can
  2399. use it as an additional channel to get packages from. Neat, no?
  2400. @c What follows stems from discussions at
  2401. @c <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=22629#134> as well as
  2402. @c earlier discussions on guix-devel@gnu.org.
  2403. @quotation Warning
  2404. Before you, dear user, shout---``woow this is @emph{soooo coool}!''---and
  2405. publish your personal channel to the world, we would like to share a few words
  2406. of caution:
  2407. @itemize
  2408. @item
  2409. Before publishing a channel, please consider contributing your package
  2410. definitions to Guix proper (@pxref{Contributing}). Guix as a project is open
  2411. to free software of all sorts, and packages in Guix proper are readily
  2412. available to all Guix users and benefit from the project's quality assurance
  2413. process.
  2414. @item
  2415. When you maintain package definitions outside Guix, we, Guix developers,
  2416. consider that @emph{the compatibility burden is on you}. Remember that
  2417. package modules and package definitions are just Scheme code that uses various
  2418. programming interfaces (APIs). We want to remain free to change these APIs to
  2419. keep improving Guix, possibly in ways that break your channel. We never
  2420. change APIs gratuitously, but we will @emph{not} commit to freezing APIs
  2421. either.
  2422. @item
  2423. Corollary: if you're using an external channel and that channel breaks, please
  2424. @emph{report the issue to the channel authors}, not to the Guix project.
  2425. @end itemize
  2426. You've been warned! Having said this, we believe external channels are a
  2427. practical way to exert your freedom to augment Guix' package collection and to
  2428. share your improvements, which are basic tenets of
  2429. @uref{https://www.gnu.org/philosophy/free-sw.html, free software}. Please
  2430. email us at @email{guix-devel@@gnu.org} if you'd like to discuss this.
  2431. @end quotation
  2432. Once you have a Git repository containing your own package modules, you can
  2433. write @code{~/.config/guix/channels.scm} to instruct @command{guix pull} to
  2434. pull from your personal channel @emph{in addition} to the default Guix
  2435. channel(s):
  2436. @vindex %default-channels
  2437. @lisp
  2438. ;; Add my personal packages to those Guix provides.
  2439. (cons (channel
  2440. (name 'my-personal-packages)
  2441. (url "https://example.org/personal-packages.git"))
  2442. %default-channels)
  2443. @end lisp
  2444. @noindent
  2445. Note that the snippet above is (as always!)@: Scheme code; we use @code{cons} to
  2446. add a channel the list of channels that the variable @code{%default-channels}
  2447. is bound to (@pxref{Pairs, @code{cons} and lists,, guile, GNU Guile Reference
  2448. Manual}). With this file in place, @command{guix pull} builds not only Guix
  2449. but also the package modules from your own repository. The result in
  2450. @file{~/.config/guix/current} is the union of Guix with your own package
  2451. modules:
  2452. @example
  2453. $ guix pull --list-generations
  2454. @dots{}
  2455. Generation 19 Aug 27 2018 16:20:48
  2456. guix d894ab8
  2457. repository URL: https://git.savannah.gnu.org/git/guix.git
  2458. branch: master
  2459. commit: d894ab8e9bfabcefa6c49d9ba2e834dd5a73a300
  2460. my-personal-packages dd3df5e
  2461. repository URL: https://example.org/personal-packages.git
  2462. branch: master
  2463. commit: dd3df5e2c8818760a8fc0bd699e55d3b69fef2bb
  2464. 11 new packages: my-gimp, my-emacs-with-cool-features, @dots{}
  2465. 4 packages upgraded: emacs-racket-mode@@0.0.2-2.1b78827, @dots{}
  2466. @end example
  2467. @noindent
  2468. The output of @command{guix pull} above shows that Generation@tie{}19 includes
  2469. both Guix and packages from the @code{my-personal-packages} channel. Among
  2470. the new and upgraded packages that are listed, some like @code{my-gimp} and
  2471. @code{my-emacs-with-cool-features} might come from
  2472. @code{my-personal-packages}, while others come from the Guix default channel.
  2473. @cindex dependencies, channels
  2474. @cindex meta-data, channels
  2475. @subsection Declaring Channel Dependencies
  2476. Channel authors may decide to augment a package collection provided by other
  2477. channels. They can declare their channel to be dependent on other channels in
  2478. a meta-data file @file{.guix-channel}, which is to be placed in the root of
  2479. the channel repository.
  2480. The meta-data file should contain a simple S-expression like this:
  2481. @lisp
  2482. (channel
  2483. (version 0)
  2484. (dependencies
  2485. (channel
  2486. (name 'some-collection)
  2487. (url "https://example.org/first-collection.git"))
  2488. (channel
  2489. (name 'some-other-collection)
  2490. (url "https://example.org/second-collection.git")
  2491. (branch "testing"))))
  2492. @end lisp
  2493. In the above example this channel is declared to depend on two other channels,
  2494. which will both be fetched automatically. The modules provided by the channel
  2495. will be compiled in an environment where the modules of all these declared
  2496. channels are available.
  2497. For the sake of reliability and maintainability, you should avoid dependencies
  2498. on channels that you don't control, and you should aim to keep the number of
  2499. dependencies to a minimum.
  2500. @subsection Replicating Guix
  2501. @cindex pinning, channels
  2502. @cindex replicating Guix
  2503. @cindex reproducibility, of Guix
  2504. The @command{guix pull --list-generations} output above shows precisely which
  2505. commits were used to build this instance of Guix. We can thus replicate it,
  2506. say, on another machine, by providing a channel specification in
  2507. @file{~/.config/guix/channels.scm} that is ``pinned'' to these commits:
  2508. @lisp
  2509. ;; Deploy specific commits of my channels of interest.
  2510. (list (channel
  2511. (name 'guix)
  2512. (url "https://git.savannah.gnu.org/git/guix.git")
  2513. (commit "d894ab8e9bfabcefa6c49d9ba2e834dd5a73a300"))
  2514. (channel
  2515. (name 'my-personal-packages)
  2516. (url "https://example.org/personal-packages.git")
  2517. (branch "dd3df5e2c8818760a8fc0bd699e55d3b69fef2bb")))
  2518. @end lisp
  2519. The @command{guix describe --format=channels} command can even generate this
  2520. list of channels directly (@pxref{Invoking guix describe}).
  2521. At this point the two machines run the @emph{exact same Guix}, with access to
  2522. the @emph{exact same packages}. The output of @command{guix build gimp} on
  2523. one machine will be exactly the same, bit for bit, as the output of the same
  2524. command on the other machine. It also means both machines have access to all
  2525. the source code of Guix and, transitively, to all the source code of every
  2526. package it defines.
  2527. This gives you super powers, allowing you to track the provenance of binary
  2528. artifacts with very fine grain, and to reproduce software environments at
  2529. will---some sort of ``meta reproducibility'' capabilities, if you will.
  2530. @xref{Inferiors}, for another way to take advantage of these super powers.
  2531. @node Inferiors
  2532. @section Inferiors
  2533. @c TODO: Remove this once we're more confident about API stability.
  2534. @quotation Note
  2535. The functionality described here is a ``technology preview'' as of version
  2536. @value{VERSION}. As such, the interface is subject to change.
  2537. @end quotation
  2538. @cindex inferiors
  2539. @cindex composition of Guix revisions
  2540. Sometimes you might need to mix packages from the revision of Guix you're
  2541. currently running with packages available in a different revision of Guix.
  2542. Guix @dfn{inferiors} allow you to achieve that by composing different Guix
  2543. revisions in arbitrary ways.
  2544. @cindex inferior packages
  2545. Technically, an ``inferior'' is essentially a separate Guix process connected
  2546. to your main Guix process through a REPL (@pxref{Invoking guix repl}). The
  2547. @code{(guix inferior)} module allows you to create inferiors and to
  2548. communicate with them. It also provides a high-level interface to browse and
  2549. manipulate the packages that an inferior provides---@dfn{inferior packages}.
  2550. When combined with channels (@pxref{Channels}), inferiors provide a simple way
  2551. to interact with a separate revision of Guix. For example, let's assume you
  2552. want to install in your profile the current @code{guile} package, along with
  2553. the @code{guile-json} as it existed in an older revision of Guix---perhaps
  2554. because the newer @code{guile-json} has an incompatible API and you want to
  2555. run your code against the old API@. To do that, you could write a manifest for
  2556. use by @code{guix package --manifest} (@pxref{Invoking guix package}); in that
  2557. manifest, you would create an inferior for that old Guix revision you care
  2558. about, and you would look up the @code{guile-json} package in the inferior:
  2559. @lisp
  2560. (use-modules (guix inferior) (guix channels)
  2561. (srfi srfi-1)) ;for 'first'
  2562. (define channels
  2563. ;; This is the old revision from which we want to
  2564. ;; extract guile-json.
  2565. (list (channel
  2566. (name 'guix)
  2567. (url "https://git.savannah.gnu.org/git/guix.git")
  2568. (commit
  2569. "65956ad3526ba09e1f7a40722c96c6ef7c0936fe"))))
  2570. (define inferior
  2571. ;; An inferior representing the above revision.
  2572. (inferior-for-channels channels))
  2573. ;; Now create a manifest with the current "guile" package
  2574. ;; and the old "guile-json" package.
  2575. (packages->manifest
  2576. (list (first (lookup-inferior-packages inferior "guile-json"))
  2577. (specification->package "guile")))
  2578. @end lisp
  2579. On its first run, @command{guix package --manifest} might have to build the
  2580. channel you specified before it can create the inferior; subsequent runs will
  2581. be much faster because the Guix revision will be cached.
  2582. The @code{(guix inferior)} module provides the following procedures to open an
  2583. inferior:
  2584. @deffn {Scheme Procedure} inferior-for-channels @var{channels} @
  2585. [#:cache-directory] [#:ttl]
  2586. Return an inferior for @var{channels}, a list of channels. Use the cache at
  2587. @var{cache-directory}, where entries can be reclaimed after @var{ttl} seconds.
  2588. This procedure opens a new connection to the build daemon.
  2589. As a side effect, this procedure may build or substitute binaries for
  2590. @var{channels}, which can take time.
  2591. @end deffn
  2592. @deffn {Scheme Procedure} open-inferior @var{directory} @
  2593. [#:command "bin/guix"]
  2594. Open the inferior Guix in @var{directory}, running
  2595. @code{@var{directory}/@var{command} repl} or equivalent. Return @code{#f} if
  2596. the inferior could not be launched.
  2597. @end deffn
  2598. @cindex inferior packages
  2599. The procedures listed below allow you to obtain and manipulate inferior
  2600. packages.
  2601. @deffn {Scheme Procedure} inferior-packages @var{inferior}
  2602. Return the list of packages known to @var{inferior}.
  2603. @end deffn
  2604. @deffn {Scheme Procedure} lookup-inferior-packages @var{inferior} @var{name} @
  2605. [@var{version}]
  2606. Return the sorted list of inferior packages matching @var{name} in
  2607. @var{inferior}, with highest version numbers first. If @var{version} is true,
  2608. return only packages with a version number prefixed by @var{version}.
  2609. @end deffn
  2610. @deffn {Scheme Procedure} inferior-package? @var{obj}
  2611. Return true if @var{obj} is an inferior package.
  2612. @end deffn
  2613. @deffn {Scheme Procedure} inferior-package-name @var{package}
  2614. @deffnx {Scheme Procedure} inferior-package-version @var{package}
  2615. @deffnx {Scheme Procedure} inferior-package-synopsis @var{package}
  2616. @deffnx {Scheme Procedure} inferior-package-description @var{package}
  2617. @deffnx {Scheme Procedure} inferior-package-home-page @var{package}
  2618. @deffnx {Scheme Procedure} inferior-package-location @var{package}
  2619. @deffnx {Scheme Procedure} inferior-package-inputs @var{package}
  2620. @deffnx {Scheme Procedure} inferior-package-native-inputs @var{package}
  2621. @deffnx {Scheme Procedure} inferior-package-propagated-inputs @var{package}
  2622. @deffnx {Scheme Procedure} inferior-package-transitive-propagated-inputs @var{package}
  2623. @deffnx {Scheme Procedure} inferior-package-native-search-paths @var{package}
  2624. @deffnx {Scheme Procedure} inferior-package-transitive-native-search-paths @var{package}
  2625. @deffnx {Scheme Procedure} inferior-package-search-paths @var{package}
  2626. These procedures are the counterpart of package record accessors
  2627. (@pxref{package Reference}). Most of them work by querying the inferior
  2628. @var{package} comes from, so the inferior must still be live when you call
  2629. these procedures.
  2630. @end deffn
  2631. Inferior packages can be used transparently like any other package or
  2632. file-like object in G-expressions (@pxref{G-Expressions}). They are also
  2633. transparently handled by the @code{packages->manifest} procedure, which is
  2634. commonly use in manifests (@pxref{Invoking guix package, the
  2635. @option{--manifest} option of @command{guix package}}). Thus you can insert
  2636. an inferior package pretty much anywhere you would insert a regular package:
  2637. in manifests, in the @code{packages} field of your @code{operating-system}
  2638. declaration, and so on.
  2639. @node Invoking guix describe
  2640. @section Invoking @command{guix describe}
  2641. @cindex reproducibility
  2642. @cindex replicating Guix
  2643. Often you may want to answer questions like: ``Which revision of Guix am I
  2644. using?'' or ``Which channels am I using?'' This is useful information in many
  2645. situations: if you want to @emph{replicate} an environment on a different
  2646. machine or user account, if you want to report a bug or to determine what
  2647. change in the channels you are using caused it, or if you want to record your
  2648. system state for reproducibility purposes. The @command{guix describe}
  2649. command answers these questions.
  2650. When run from a @command{guix pull}ed @command{guix}, @command{guix describe}
  2651. displays the channel(s) that it was built from, including their repository URL
  2652. and commit IDs (@pxref{Channels}):
  2653. @example
  2654. $ guix describe
  2655. Generation 10 Sep 03 2018 17:32:44 (current)
  2656. guix e0fa68c
  2657. repository URL: https://git.savannah.gnu.org/git/guix.git
  2658. branch: master
  2659. commit: e0fa68c7718fffd33d81af415279d6ddb518f727
  2660. @end example
  2661. If you're familiar with the Git version control system, this is similar in
  2662. spirit to @command{git describe}; the output is also similar to that of
  2663. @command{guix pull --list-generations}, but limited to the current generation
  2664. (@pxref{Invoking guix pull, the @option{--list-generations} option}). Because
  2665. the Git commit ID shown above unambiguously refers to a snapshot of Guix, this
  2666. information is all it takes to describe the revision of Guix you're using, and
  2667. also to replicate it.
  2668. To make it easier to replicate Guix, @command{guix describe} can also be asked
  2669. to return a list of channels instead of the human-readable description above:
  2670. @example
  2671. $ guix describe -f channels
  2672. (list (channel
  2673. (name 'guix)
  2674. (url "https://git.savannah.gnu.org/git/guix.git")
  2675. (commit
  2676. "e0fa68c7718fffd33d81af415279d6ddb518f727")))
  2677. @end example
  2678. @noindent
  2679. You can save this to a file and feed it to @command{guix pull -C} on some
  2680. other machine or at a later point in time, which will instantiate @emph{this
  2681. exact Guix revision} (@pxref{Invoking guix pull, the @option{-C} option}).
  2682. From there on, since you're able to deploy the same revision of Guix, you can
  2683. just as well @emph{replicate a complete software environment}. We humbly
  2684. think that this is @emph{awesome}, and we hope you'll like it too!
  2685. The details of the options supported by @command{guix describe} are as
  2686. follows:
  2687. @table @code
  2688. @item --format=@var{format}
  2689. @itemx -f @var{format}
  2690. Produce output in the specified @var{format}, one of:
  2691. @table @code
  2692. @item human
  2693. produce human-readable output;
  2694. @item channels
  2695. produce a list of channel specifications that can be passed to @command{guix
  2696. pull -C} or installed as @file{~/.config/guix/channels.scm} (@pxref{Invoking
  2697. guix pull});
  2698. @item json
  2699. @cindex JSON
  2700. produce a list of channel specifications in JSON format;
  2701. @item recutils
  2702. produce a list of channel specifications in Recutils format.
  2703. @end table
  2704. @item --profile=@var{profile}
  2705. @itemx -p @var{profile}
  2706. Display information about @var{profile}.
  2707. @end table
  2708. @node Invoking guix pack
  2709. @section Invoking @command{guix pack}
  2710. Occasionally you want to pass software to people who are not (yet!)
  2711. lucky enough to be using Guix. You'd tell them to run @command{guix
  2712. package -i @var{something}}, but that's not possible in this case. This
  2713. is where @command{guix pack} comes in.
  2714. @quotation Note
  2715. If you are looking for ways to exchange binaries among machines that
  2716. already run Guix, @pxref{Invoking guix copy}, @ref{Invoking guix
  2717. publish}, and @ref{Invoking guix archive}.
  2718. @end quotation
  2719. @cindex pack
  2720. @cindex bundle
  2721. @cindex application bundle
  2722. @cindex software bundle
  2723. The @command{guix pack} command creates a shrink-wrapped @dfn{pack} or
  2724. @dfn{software bundle}: it creates a tarball or some other archive
  2725. containing the binaries of the software you're interested in, and all
  2726. its dependencies. The resulting archive can be used on any machine that
  2727. does not have Guix, and people can run the exact same binaries as those
  2728. you have with Guix. The pack itself is created in a bit-reproducible
  2729. fashion, so anyone can verify that it really contains the build results
  2730. that you pretend to be shipping.
  2731. For example, to create a bundle containing Guile, Emacs, Geiser, and all
  2732. their dependencies, you can run:
  2733. @example
  2734. $ guix pack guile emacs geiser
  2735. @dots{}
  2736. /gnu/store/@dots{}-pack.tar.gz
  2737. @end example
  2738. The result here is a tarball containing a @file{/gnu/store} directory
  2739. with all the relevant packages. The resulting tarball contains a
  2740. @dfn{profile} with the three packages of interest; the profile is the
  2741. same as would be created by @command{guix package -i}. It is this
  2742. mechanism that is used to create Guix's own standalone binary tarball
  2743. (@pxref{Binary Installation}).
  2744. Users of this pack would have to run
  2745. @file{/gnu/store/@dots{}-profile/bin/guile} to run Guile, which you may
  2746. find inconvenient. To work around it, you can create, say, a
  2747. @file{/opt/gnu/bin} symlink to the profile:
  2748. @example
  2749. guix pack -S /opt/gnu/bin=bin guile emacs geiser
  2750. @end example
  2751. @noindent
  2752. That way, users can happily type @file{/opt/gnu/bin/guile} and enjoy.
  2753. @cindex relocatable binaries, with @command{guix pack}
  2754. What if the recipient of your pack does not have root privileges on
  2755. their machine, and thus cannot unpack it in the root file system? In
  2756. that case, you will want to use the @code{--relocatable} option (see
  2757. below). This option produces @dfn{relocatable binaries}, meaning they
  2758. they can be placed anywhere in the file system hierarchy: in the example
  2759. above, users can unpack your tarball in their home directory and
  2760. directly run @file{./opt/gnu/bin/guile}.
  2761. @cindex Docker, build an image with guix pack
  2762. Alternatively, you can produce a pack in the Docker image format using
  2763. the following command:
  2764. @example
  2765. guix pack -f docker guile emacs geiser
  2766. @end example
  2767. @noindent
  2768. The result is a tarball that can be passed to the @command{docker load}
  2769. command. See the
  2770. @uref{https://docs.docker.com/engine/reference/commandline/load/, Docker
  2771. documentation} for more information.
  2772. @cindex Singularity, build an image with guix pack
  2773. @cindex SquashFS, build an image with guix pack
  2774. Yet another option is to produce a SquashFS image with the following
  2775. command:
  2776. @example
  2777. guix pack -f squashfs guile emacs geiser
  2778. @end example
  2779. @noindent
  2780. The result is a SquashFS file system image that can either be mounted or
  2781. directly be used as a file system container image with the
  2782. @uref{http://singularity.lbl.gov, Singularity container execution
  2783. environment}, using commands like @command{singularity shell} or
  2784. @command{singularity exec}.
  2785. Several command-line options allow you to customize your pack:
  2786. @table @code
  2787. @item --format=@var{format}
  2788. @itemx -f @var{format}
  2789. Produce a pack in the given @var{format}.
  2790. The available formats are:
  2791. @table @code
  2792. @item tarball
  2793. This is the default format. It produces a tarball containing all the
  2794. specified binaries and symlinks.
  2795. @item docker
  2796. This produces a tarball that follows the
  2797. @uref{https://github.com/docker/docker/blob/master/image/spec/v1.2.md,
  2798. Docker Image Specification}.
  2799. @item squashfs
  2800. This produces a SquashFS image containing all the specified binaries and
  2801. symlinks, as well as empty mount points for virtual file systems like
  2802. procfs.
  2803. @end table
  2804. @item --relocatable
  2805. @itemx -R
  2806. Produce @dfn{relocatable binaries}---i.e., binaries that can be placed
  2807. anywhere in the file system hierarchy and run from there. For example,
  2808. if you create a pack containing Bash with:
  2809. @example
  2810. guix pack -R -S /mybin=bin bash
  2811. @end example
  2812. @noindent
  2813. ...@: you can copy that pack to a machine that lacks Guix, and from your
  2814. home directory as a normal user, run:
  2815. @example
  2816. tar xf pack.tar.gz
  2817. ./mybin/sh
  2818. @end example
  2819. @noindent
  2820. In that shell, if you type @code{ls /gnu/store}, you'll notice that
  2821. @file{/gnu/store} shows up and contains all the dependencies of
  2822. @code{bash}, even though the machine actually lacks @file{/gnu/store}
  2823. altogether! That is probably the simplest way to deploy Guix-built
  2824. software on a non-Guix machine.
  2825. There's a gotcha though: this technique relies on the @dfn{user
  2826. namespace} feature of the kernel Linux, which allows unprivileged users
  2827. to mount or change root. Old versions of Linux did not support it, and
  2828. some GNU/Linux distributions turn it off; on these systems, programs
  2829. from the pack @emph{will fail to run}, unless they are unpacked in the
  2830. root file system.
  2831. @item --expression=@var{expr}
  2832. @itemx -e @var{expr}
  2833. Consider the package @var{expr} evaluates to.
  2834. This has the same purpose as the same-named option in @command{guix
  2835. build} (@pxref{Additional Build Options, @code{--expression} in
  2836. @command{guix build}}).
  2837. @item --manifest=@var{file}
  2838. @itemx -m @var{file}
  2839. Use the packages contained in the manifest object returned by the Scheme
  2840. code in @var{file}.
  2841. This has a similar purpose as the same-named option in @command{guix
  2842. package} (@pxref{profile-manifest, @option{--manifest}}) and uses the
  2843. same manifest files. It allows you to define a collection of packages
  2844. once and use it both for creating profiles and for creating archives
  2845. for use on machines that do not have Guix installed. Note that you can
  2846. specify @emph{either} a manifest file @emph{or} a list of packages,
  2847. but not both.
  2848. @item --system=@var{system}
  2849. @itemx -s @var{system}
  2850. Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
  2851. the system type of the build host.
  2852. @item --target=@var{triplet}
  2853. @cindex cross-compilation
  2854. Cross-build for @var{triplet}, which must be a valid GNU triplet, such
  2855. as @code{"mips64el-linux-gnu"} (@pxref{Specifying target triplets, GNU
  2856. configuration triplets,, autoconf, Autoconf}).
  2857. @item --compression=@var{tool}
  2858. @itemx -C @var{tool}
  2859. Compress the resulting tarball using @var{tool}---one of @code{gzip},
  2860. @code{bzip2}, @code{xz}, @code{lzip}, or @code{none} for no compression.
  2861. @item --symlink=@var{spec}
  2862. @itemx -S @var{spec}
  2863. Add the symlinks specified by @var{spec} to the pack. This option can
  2864. appear several times.
  2865. @var{spec} has the form @code{@var{source}=@var{target}}, where
  2866. @var{source} is the symlink that will be created and @var{target} is the
  2867. symlink target.
  2868. For instance, @code{-S /opt/gnu/bin=bin} creates a @file{/opt/gnu/bin}
  2869. symlink pointing to the @file{bin} sub-directory of the profile.
  2870. @item --localstatedir
  2871. @itemx --profile-name=@var{name}
  2872. Include the ``local state directory'', @file{/var/guix}, in the resulting
  2873. pack, and notably the @file{/var/guix/profiles/per-user/root/@var{name}}
  2874. profile---by default @var{name} is @code{guix-profile}, which corresponds to
  2875. @file{~root/.guix-profile}.
  2876. @file{/var/guix} contains the store database (@pxref{The Store}) as well
  2877. as garbage-collector roots (@pxref{Invoking guix gc}). Providing it in
  2878. the pack means that the store is ``complete'' and manageable by Guix;
  2879. not providing it pack means that the store is ``dead'': items cannot be
  2880. added to it or removed from it after extraction of the pack.
  2881. One use case for this is the Guix self-contained binary tarball
  2882. (@pxref{Binary Installation}).
  2883. @item --bootstrap
  2884. Use the bootstrap binaries to build the pack. This option is only
  2885. useful to Guix developers.
  2886. @end table
  2887. In addition, @command{guix pack} supports all the common build options
  2888. (@pxref{Common Build Options}) and all the package transformation
  2889. options (@pxref{Package Transformation Options}).
  2890. @node Invoking guix archive
  2891. @section Invoking @command{guix archive}
  2892. @cindex @command{guix archive}
  2893. @cindex archive
  2894. The @command{guix archive} command allows users to @dfn{export} files
  2895. from the store into a single archive, and to later @dfn{import} them on
  2896. a machine that runs Guix.
  2897. In particular, it allows store files to be transferred from one machine
  2898. to the store on another machine.
  2899. @quotation Note
  2900. If you're looking for a way to produce archives in a format suitable for
  2901. tools other than Guix, @pxref{Invoking guix pack}.
  2902. @end quotation
  2903. @cindex exporting store items
  2904. To export store files as an archive to standard output, run:
  2905. @example
  2906. guix archive --export @var{options} @var{specifications}...
  2907. @end example
  2908. @var{specifications} may be either store file names or package
  2909. specifications, as for @command{guix package} (@pxref{Invoking guix
  2910. package}). For instance, the following command creates an archive
  2911. containing the @code{gui} output of the @code{git} package and the main
  2912. output of @code{emacs}:
  2913. @example
  2914. guix archive --export git:gui /gnu/store/...-emacs-24.3 > great.nar
  2915. @end example
  2916. If the specified packages are not built yet, @command{guix archive}
  2917. automatically builds them. The build process may be controlled with the
  2918. common build options (@pxref{Common Build Options}).
  2919. To transfer the @code{emacs} package to a machine connected over SSH,
  2920. one would run:
  2921. @example
  2922. guix archive --export -r emacs | ssh the-machine guix archive --import
  2923. @end example
  2924. @noindent
  2925. Similarly, a complete user profile may be transferred from one machine
  2926. to another like this:
  2927. @example
  2928. guix archive --export -r $(readlink -f ~/.guix-profile) | \
  2929. ssh the-machine guix-archive --import
  2930. @end example
  2931. @noindent
  2932. However, note that, in both examples, all of @code{emacs} and the
  2933. profile as well as all of their dependencies are transferred (due to
  2934. @code{-r}), regardless of what is already available in the store on the
  2935. target machine. The @code{--missing} option can help figure out which
  2936. items are missing from the target store. The @command{guix copy}
  2937. command simplifies and optimizes this whole process, so this is probably
  2938. what you should use in this case (@pxref{Invoking guix copy}).
  2939. @cindex nar, archive format
  2940. @cindex normalized archive (nar)
  2941. Archives are stored in the ``normalized archive'' or ``nar'' format, which is
  2942. comparable in spirit to `tar', but with differences
  2943. that make it more appropriate for our purposes. First, rather than
  2944. recording all Unix metadata for each file, the nar format only mentions
  2945. the file type (regular, directory, or symbolic link); Unix permissions
  2946. and owner/group are dismissed. Second, the order in which directory
  2947. entries are stored always follows the order of file names according to
  2948. the C locale collation order. This makes archive production fully
  2949. deterministic.
  2950. When exporting, the daemon digitally signs the contents of the archive,
  2951. and that digital signature is appended. When importing, the daemon
  2952. verifies the signature and rejects the import in case of an invalid
  2953. signature or if the signing key is not authorized.
  2954. @c FIXME: Add xref to daemon doc about signatures.
  2955. The main options are:
  2956. @table @code
  2957. @item --export
  2958. Export the specified store files or packages (see below.) Write the
  2959. resulting archive to the standard output.
  2960. Dependencies are @emph{not} included in the output, unless
  2961. @code{--recursive} is passed.
  2962. @item -r
  2963. @itemx --recursive
  2964. When combined with @code{--export}, this instructs @command{guix
  2965. archive} to include dependencies of the given items in the archive.
  2966. Thus, the resulting archive is self-contained: it contains the closure
  2967. of the exported store items.
  2968. @item --import
  2969. Read an archive from the standard input, and import the files listed
  2970. therein into the store. Abort if the archive has an invalid digital
  2971. signature, or if it is signed by a public key not among the authorized
  2972. keys (see @code{--authorize} below.)
  2973. @item --missing
  2974. Read a list of store file names from the standard input, one per line,
  2975. and write on the standard output the subset of these files missing from
  2976. the store.
  2977. @item --generate-key[=@var{parameters}]
  2978. @cindex signing, archives
  2979. Generate a new key pair for the daemon. This is a prerequisite before
  2980. archives can be exported with @code{--export}. Note that this operation
  2981. usually takes time, because it needs to gather enough entropy to
  2982. generate the key pair.
  2983. The generated key pair is typically stored under @file{/etc/guix}, in
  2984. @file{signing-key.pub} (public key) and @file{signing-key.sec} (private
  2985. key, which must be kept secret.) When @var{parameters} is omitted,
  2986. an ECDSA key using the Ed25519 curve is generated, or, for Libgcrypt
  2987. versions before 1.6.0, it is a 4096-bit RSA key.
  2988. Alternatively, @var{parameters} can specify
  2989. @code{genkey} parameters suitable for Libgcrypt (@pxref{General
  2990. public-key related Functions, @code{gcry_pk_genkey},, gcrypt, The
  2991. Libgcrypt Reference Manual}).
  2992. @item --authorize
  2993. @cindex authorizing, archives
  2994. Authorize imports signed by the public key passed on standard input.
  2995. The public key must be in ``s-expression advanced format''---i.e., the
  2996. same format as the @file{signing-key.pub} file.
  2997. The list of authorized keys is kept in the human-editable file
  2998. @file{/etc/guix/acl}. The file contains
  2999. @url{http://people.csail.mit.edu/rivest/Sexp.txt, ``advanced-format
  3000. s-expressions''} and is structured as an access-control list in the
  3001. @url{http://theworld.com/~cme/spki.txt, Simple Public-Key Infrastructure
  3002. (SPKI)}.
  3003. @item --extract=@var{directory}
  3004. @itemx -x @var{directory}
  3005. Read a single-item archive as served by substitute servers
  3006. (@pxref{Substitutes}) and extract it to @var{directory}. This is a
  3007. low-level operation needed in only very narrow use cases; see below.
  3008. For example, the following command extracts the substitute for Emacs
  3009. served by @code{@value{SUBSTITUTE-SERVER}} to @file{/tmp/emacs}:
  3010. @example
  3011. $ wget -O - \
  3012. https://@value{SUBSTITUTE-SERVER}/nar/@dots{}-emacs-24.5 \
  3013. | bunzip2 | guix archive -x /tmp/emacs
  3014. @end example
  3015. Single-item archives are different from multiple-item archives produced
  3016. by @command{guix archive --export}; they contain a single store item,
  3017. and they do @emph{not} embed a signature. Thus this operation does
  3018. @emph{no} signature verification and its output should be considered
  3019. unsafe.
  3020. The primary purpose of this operation is to facilitate inspection of
  3021. archive contents coming from possibly untrusted substitute servers.
  3022. @end table
  3023. @c *********************************************************************
  3024. @node Programming Interface
  3025. @chapter Programming Interface
  3026. GNU Guix provides several Scheme programming interfaces (APIs) to
  3027. define, build, and query packages. The first interface allows users to
  3028. write high-level package definitions. These definitions refer to
  3029. familiar packaging concepts, such as the name and version of a package,
  3030. its build system, and its dependencies. These definitions can then be
  3031. turned into concrete build actions.
  3032. Build actions are performed by the Guix daemon, on behalf of users. In a
  3033. standard setup, the daemon has write access to the store---the
  3034. @file{/gnu/store} directory---whereas users do not. The recommended
  3035. setup also has the daemon perform builds in chroots, under a specific
  3036. build users, to minimize interference with the rest of the system.
  3037. @cindex derivation
  3038. Lower-level APIs are available to interact with the daemon and the
  3039. store. To instruct the daemon to perform a build action, users actually
  3040. provide it with a @dfn{derivation}. A derivation is a low-level
  3041. representation of the build actions to be taken, and the environment in
  3042. which they should occur---derivations are to package definitions what
  3043. assembly is to C programs. The term ``derivation'' comes from the fact
  3044. that build results @emph{derive} from them.
  3045. This chapter describes all these APIs in turn, starting from high-level
  3046. package definitions.
  3047. @menu
  3048. * Defining Packages:: Defining new packages.
  3049. * Build Systems:: Specifying how packages are built.
  3050. * The Store:: Manipulating the package store.
  3051. * Derivations:: Low-level interface to package derivations.
  3052. * The Store Monad:: Purely functional interface to the store.
  3053. * G-Expressions:: Manipulating build expressions.
  3054. * Invoking guix repl:: Fiddling with Guix interactively.
  3055. @end menu
  3056. @node Defining Packages
  3057. @section Defining Packages
  3058. The high-level interface to package definitions is implemented in the
  3059. @code{(guix packages)} and @code{(guix build-system)} modules. As an
  3060. example, the package definition, or @dfn{recipe}, for the GNU Hello
  3061. package looks like this:
  3062. @example
  3063. (define-module (gnu packages hello)
  3064. #:use-module (guix packages)
  3065. #:use-module (guix download)
  3066. #:use-module (guix build-system gnu)
  3067. #:use-module (guix licenses)
  3068. #:use-module (gnu packages gawk))
  3069. (define-public hello
  3070. (package
  3071. (name "hello")
  3072. (version "2.10")
  3073. (source (origin
  3074. (method url-fetch)
  3075. (uri (string-append "mirror://gnu/hello/hello-" version
  3076. ".tar.gz"))
  3077. (sha256
  3078. (base32
  3079. "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
  3080. (build-system gnu-build-system)
  3081. (arguments '(#:configure-flags '("--enable-silent-rules")))
  3082. (inputs `(("gawk" ,gawk)))
  3083. (synopsis "Hello, GNU world: An example GNU package")
  3084. (description "Guess what GNU Hello prints!")
  3085. (home-page "http://www.gnu.org/software/hello/")
  3086. (license gpl3+)))
  3087. @end example
  3088. @noindent
  3089. Without being a Scheme expert, the reader may have guessed the meaning
  3090. of the various fields here. This expression binds the variable
  3091. @code{hello} to a @code{<package>} object, which is essentially a record
  3092. (@pxref{SRFI-9, Scheme records,, guile, GNU Guile Reference Manual}).
  3093. This package object can be inspected using procedures found in the
  3094. @code{(guix packages)} module; for instance, @code{(package-name hello)}
  3095. returns---surprise!---@code{"hello"}.
  3096. With luck, you may be able to import part or all of the definition of
  3097. the package you are interested in from another repository, using the
  3098. @code{guix import} command (@pxref{Invoking guix import}).
  3099. In the example above, @var{hello} is defined in a module of its own,
  3100. @code{(gnu packages hello)}. Technically, this is not strictly
  3101. necessary, but it is convenient to do so: all the packages defined in
  3102. modules under @code{(gnu packages @dots{})} are automatically known to
  3103. the command-line tools (@pxref{Package Modules}).
  3104. There are a few points worth noting in the above package definition:
  3105. @itemize
  3106. @item
  3107. The @code{source} field of the package is an @code{<origin>} object
  3108. (@pxref{origin Reference}, for the complete reference).
  3109. Here, the @code{url-fetch} method from @code{(guix download)} is used,
  3110. meaning that the source is a file to be downloaded over FTP or HTTP.
  3111. The @code{mirror://gnu} prefix instructs @code{url-fetch} to use one of
  3112. the GNU mirrors defined in @code{(guix download)}.
  3113. The @code{sha256} field specifies the expected SHA256 hash of the file
  3114. being downloaded. It is mandatory, and allows Guix to check the
  3115. integrity of the file. The @code{(base32 @dots{})} form introduces the
  3116. base32 representation of the hash. You can obtain this information with
  3117. @code{guix download} (@pxref{Invoking guix download}) and @code{guix
  3118. hash} (@pxref{Invoking guix hash}).
  3119. @cindex patches
  3120. When needed, the @code{origin} form can also have a @code{patches} field
  3121. listing patches to be applied, and a @code{snippet} field giving a
  3122. Scheme expression to modify the source code.
  3123. @item
  3124. @cindex GNU Build System
  3125. The @code{build-system} field specifies the procedure to build the
  3126. package (@pxref{Build Systems}). Here, @var{gnu-build-system}
  3127. represents the familiar GNU Build System, where packages may be
  3128. configured, built, and installed with the usual @code{./configure &&
  3129. make && make check && make install} command sequence.
  3130. @item
  3131. The @code{arguments} field specifies options for the build system
  3132. (@pxref{Build Systems}). Here it is interpreted by
  3133. @var{gnu-build-system} as a request run @file{configure} with the
  3134. @code{--enable-silent-rules} flag.
  3135. @cindex quote
  3136. @cindex quoting
  3137. @findex '
  3138. @findex quote
  3139. What about these quote (@code{'}) characters? They are Scheme syntax to
  3140. introduce a literal list; @code{'} is synonymous with @code{quote}.
  3141. @xref{Expression Syntax, quoting,, guile, GNU Guile Reference Manual},
  3142. for details. Here the value of the @code{arguments} field is a list of
  3143. arguments passed to the build system down the road, as with @code{apply}
  3144. (@pxref{Fly Evaluation, @code{apply},, guile, GNU Guile Reference
  3145. Manual}).
  3146. The hash-colon (@code{#:}) sequence defines a Scheme @dfn{keyword}
  3147. (@pxref{Keywords,,, guile, GNU Guile Reference Manual}), and
  3148. @code{#:configure-flags} is a keyword used to pass a keyword argument
  3149. to the build system (@pxref{Coding With Keywords,,, guile, GNU Guile
  3150. Reference Manual}).
  3151. @item
  3152. The @code{inputs} field specifies inputs to the build process---i.e.,
  3153. build-time or run-time dependencies of the package. Here, we define an
  3154. input called @code{"gawk"} whose value is that of the @var{gawk}
  3155. variable; @var{gawk} is itself bound to a @code{<package>} object.
  3156. @cindex backquote (quasiquote)
  3157. @findex `
  3158. @findex quasiquote
  3159. @cindex comma (unquote)
  3160. @findex ,
  3161. @findex unquote
  3162. @findex ,@@
  3163. @findex unquote-splicing
  3164. Again, @code{`} (a backquote, synonymous with @code{quasiquote}) allows
  3165. us to introduce a literal list in the @code{inputs} field, while
  3166. @code{,} (a comma, synonymous with @code{unquote}) allows us to insert a
  3167. value in that list (@pxref{Expression Syntax, unquote,, guile, GNU Guile
  3168. Reference Manual}).
  3169. Note that GCC, Coreutils, Bash, and other essential tools do not need to
  3170. be specified as inputs here. Instead, @var{gnu-build-system} takes care
  3171. of ensuring that they are present (@pxref{Build Systems}).
  3172. However, any other dependencies need to be specified in the
  3173. @code{inputs} field. Any dependency not specified here will simply be
  3174. unavailable to the build process, possibly leading to a build failure.
  3175. @end itemize
  3176. @xref{package Reference}, for a full description of possible fields.
  3177. Once a package definition is in place, the
  3178. package may actually be built using the @code{guix build} command-line
  3179. tool (@pxref{Invoking guix build}), troubleshooting any build failures
  3180. you encounter (@pxref{Debugging Build Failures}). You can easily jump back to the
  3181. package definition using the @command{guix edit} command
  3182. (@pxref{Invoking guix edit}).
  3183. @xref{Packaging Guidelines}, for
  3184. more information on how to test package definitions, and
  3185. @ref{Invoking guix lint}, for information on how to check a definition
  3186. for style conformance.
  3187. @vindex GUIX_PACKAGE_PATH
  3188. Lastly, @pxref{Channels}, for information
  3189. on how to extend the distribution by adding your own package definitions
  3190. in a ``channel''.
  3191. Finally, updating the package definition to a new upstream version
  3192. can be partly automated by the @command{guix refresh} command
  3193. (@pxref{Invoking guix refresh}).
  3194. Behind the scenes, a derivation corresponding to the @code{<package>}
  3195. object is first computed by the @code{package-derivation} procedure.
  3196. That derivation is stored in a @code{.drv} file under @file{/gnu/store}.
  3197. The build actions it prescribes may then be realized by using the
  3198. @code{build-derivations} procedure (@pxref{The Store}).
  3199. @deffn {Scheme Procedure} package-derivation @var{store} @var{package} [@var{system}]
  3200. Return the @code{<derivation>} object of @var{package} for @var{system}
  3201. (@pxref{Derivations}).
  3202. @var{package} must be a valid @code{<package>} object, and @var{system}
  3203. must be a string denoting the target system type---e.g.,
  3204. @code{"x86_64-linux"} for an x86_64 Linux-based GNU system. @var{store}
  3205. must be a connection to the daemon, which operates on the store
  3206. (@pxref{The Store}).
  3207. @end deffn
  3208. @noindent
  3209. @cindex cross-compilation
  3210. Similarly, it is possible to compute a derivation that cross-builds a
  3211. package for some other system:
  3212. @deffn {Scheme Procedure} package-cross-derivation @var{store} @
  3213. @var{package} @var{target} [@var{system}]
  3214. Return the @code{<derivation>} object of @var{package} cross-built from
  3215. @var{system} to @var{target}.
  3216. @var{target} must be a valid GNU triplet denoting the target hardware
  3217. and operating system, such as @code{"mips64el-linux-gnu"}
  3218. (@pxref{Configuration Names, GNU configuration triplets,, configure, GNU
  3219. Configure and Build System}).
  3220. @end deffn
  3221. @cindex package transformations
  3222. @cindex input rewriting
  3223. @cindex dependency tree rewriting
  3224. Packages can be manipulated in arbitrary ways. An example of a useful
  3225. transformation is @dfn{input rewriting}, whereby the dependency tree of
  3226. a package is rewritten by replacing specific inputs by others:
  3227. @deffn {Scheme Procedure} package-input-rewriting @var{replacements} @
  3228. [@var{rewrite-name}]
  3229. Return a procedure that, when passed a package, replaces its direct and
  3230. indirect dependencies (but not its implicit inputs) according to
  3231. @var{replacements}. @var{replacements} is a list of package pairs; the
  3232. first element of each pair is the package to replace, and the second one
  3233. is the replacement.
  3234. Optionally, @var{rewrite-name} is a one-argument procedure that takes
  3235. the name of a package and returns its new name after rewrite.
  3236. @end deffn
  3237. @noindent
  3238. Consider this example:
  3239. @example
  3240. (define libressl-instead-of-openssl
  3241. ;; This is a procedure to replace OPENSSL by LIBRESSL,
  3242. ;; recursively.
  3243. (package-input-rewriting `((,openssl . ,libressl))))
  3244. (define git-with-libressl
  3245. (libressl-instead-of-openssl git))
  3246. @end example
  3247. @noindent
  3248. Here we first define a rewriting procedure that replaces @var{openssl}
  3249. with @var{libressl}. Then we use it to define a @dfn{variant} of the
  3250. @var{git} package that uses @var{libressl} instead of @var{openssl}.
  3251. This is exactly what the @option{--with-input} command-line option does
  3252. (@pxref{Package Transformation Options, @option{--with-input}}).
  3253. A more generic procedure to rewrite a package dependency graph is
  3254. @code{package-mapping}: it supports arbitrary changes to nodes in the
  3255. graph.
  3256. @deffn {Scheme Procedure} package-mapping @var{proc} [@var{cut?}]
  3257. Return a procedure that, given a package, applies @var{proc} to all the packages
  3258. depended on and returns the resulting package. The procedure stops recursion
  3259. when @var{cut?} returns true for a given package.
  3260. @end deffn
  3261. @menu
  3262. * package Reference:: The package data type.
  3263. * origin Reference:: The origin data type.
  3264. @end menu
  3265. @node package Reference
  3266. @subsection @code{package} Reference
  3267. This section summarizes all the options available in @code{package}
  3268. declarations (@pxref{Defining Packages}).
  3269. @deftp {Data Type} package
  3270. This is the data type representing a package recipe.
  3271. @table @asis
  3272. @item @code{name}
  3273. The name of the package, as a string.
  3274. @item @code{version}
  3275. The version of the package, as a string.
  3276. @item @code{source}
  3277. An object telling how the source code for the package should be
  3278. acquired. Most of the time, this is an @code{origin} object, which
  3279. denotes a file fetched from the Internet (@pxref{origin Reference}). It
  3280. can also be any other ``file-like'' object such as a @code{local-file},
  3281. which denotes a file from the local file system (@pxref{G-Expressions,
  3282. @code{local-file}}).
  3283. @item @code{build-system}
  3284. The build system that should be used to build the package (@pxref{Build
  3285. Systems}).
  3286. @item @code{arguments} (default: @code{'()})
  3287. The arguments that should be passed to the build system. This is a
  3288. list, typically containing sequential keyword-value pairs.
  3289. @item @code{inputs} (default: @code{'()})
  3290. @itemx @code{native-inputs} (default: @code{'()})
  3291. @itemx @code{propagated-inputs} (default: @code{'()})
  3292. @cindex inputs, of packages
  3293. These fields list dependencies of the package. Each one is a list of
  3294. tuples, where each tuple has a label for the input (a string) as its
  3295. first element, a package, origin, or derivation as its second element,
  3296. and optionally the name of the output thereof that should be used, which
  3297. defaults to @code{"out"} (@pxref{Packages with Multiple Outputs}, for
  3298. more on package outputs). For example, the list below specifies three
  3299. inputs:
  3300. @example
  3301. `(("libffi" ,libffi)
  3302. ("libunistring" ,libunistring)
  3303. ("glib:bin" ,glib "bin")) ;the "bin" output of Glib
  3304. @end example
  3305. @cindex cross compilation, package dependencies
  3306. The distinction between @code{native-inputs} and @code{inputs} is
  3307. necessary when considering cross-compilation. When cross-compiling,
  3308. dependencies listed in @code{inputs} are built for the @emph{target}
  3309. architecture; conversely, dependencies listed in @code{native-inputs}
  3310. are built for the architecture of the @emph{build} machine.
  3311. @code{native-inputs} is typically used to list tools needed at
  3312. build time, but not at run time, such as Autoconf, Automake, pkg-config,
  3313. Gettext, or Bison. @command{guix lint} can report likely mistakes in
  3314. this area (@pxref{Invoking guix lint}).
  3315. @anchor{package-propagated-inputs}
  3316. Lastly, @code{propagated-inputs} is similar to @code{inputs}, but the
  3317. specified packages will be automatically installed alongside the package
  3318. they belong to (@pxref{package-cmd-propagated-inputs, @command{guix
  3319. package}}, for information on how @command{guix package} deals with
  3320. propagated inputs.)
  3321. For example this is necessary when a C/C++ library needs headers of
  3322. another library to compile, or when a pkg-config file refers to another
  3323. one @i{via} its @code{Requires} field.
  3324. Another example where @code{propagated-inputs} is useful is for languages
  3325. that lack a facility to record the run-time search path akin to the
  3326. @code{RUNPATH} of ELF files; this includes Guile, Python, Perl, and
  3327. more. To ensure that libraries written in those languages can find
  3328. library code they depend on at run time, run-time dependencies must be
  3329. listed in @code{propagated-inputs} rather than @code{inputs}.
  3330. @item @code{self-native-input?} (default: @code{#f})
  3331. This is a Boolean field telling whether the package should use itself as
  3332. a native input when cross-compiling.
  3333. @item @code{outputs} (default: @code{'("out")})
  3334. The list of output names of the package. @xref{Packages with Multiple
  3335. Outputs}, for typical uses of additional outputs.
  3336. @item @code{native-search-paths} (default: @code{'()})
  3337. @itemx @code{search-paths} (default: @code{'()})
  3338. A list of @code{search-path-specification} objects describing
  3339. search-path environment variables honored by the package.
  3340. @item @code{replacement} (default: @code{#f})
  3341. This must be either @code{#f} or a package object that will be used as a
  3342. @dfn{replacement} for this package. @xref{Security Updates, grafts},
  3343. for details.
  3344. @item @code{synopsis}
  3345. A one-line description of the package.
  3346. @item @code{description}
  3347. A more elaborate description of the package.
  3348. @item @code{license}
  3349. @cindex license, of packages
  3350. The license of the package; a value from @code{(guix licenses)},
  3351. or a list of such values.
  3352. @item @code{home-page}
  3353. The URL to the home-page of the package, as a string.
  3354. @item @code{supported-systems} (default: @var{%supported-systems})
  3355. The list of systems supported by the package, as strings of the form
  3356. @code{architecture-kernel}, for example @code{"x86_64-linux"}.
  3357. @item @code{maintainers} (default: @code{'()})
  3358. The list of maintainers of the package, as @code{maintainer} objects.
  3359. @item @code{location} (default: source location of the @code{package} form)
  3360. The source location of the package. It is useful to override this when
  3361. inheriting from another package, in which case this field is not
  3362. automatically corrected.
  3363. @end table
  3364. @end deftp
  3365. @node origin Reference
  3366. @subsection @code{origin} Reference
  3367. This section summarizes all the options available in @code{origin}
  3368. declarations (@pxref{Defining Packages}).
  3369. @deftp {Data Type} origin
  3370. This is the data type representing a source code origin.
  3371. @table @asis
  3372. @item @code{uri}
  3373. An object containing the URI of the source. The object type depends on
  3374. the @code{method} (see below). For example, when using the
  3375. @var{url-fetch} method of @code{(guix download)}, the valid @code{uri}
  3376. values are: a URL represented as a string, or a list thereof.
  3377. @item @code{method}
  3378. A procedure that handles the URI.
  3379. Examples include:
  3380. @table @asis
  3381. @item @var{url-fetch} from @code{(guix download)}
  3382. download a file from the HTTP, HTTPS, or FTP URL specified in the
  3383. @code{uri} field;
  3384. @vindex git-fetch
  3385. @item @var{git-fetch} from @code{(guix git-download)}
  3386. clone the Git version control repository, and check out the revision
  3387. specified in the @code{uri} field as a @code{git-reference} object; a
  3388. @code{git-reference} looks like this:
  3389. @example
  3390. (git-reference
  3391. (url "git://git.debian.org/git/pkg-shadow/shadow")
  3392. (commit "v4.1.5.1"))
  3393. @end example
  3394. @end table
  3395. @item @code{sha256}
  3396. A bytevector containing the SHA-256 hash of the source. Typically the
  3397. @code{base32} form is used here to generate the bytevector from a
  3398. base-32 string.
  3399. You can obtain this information using @code{guix download}
  3400. (@pxref{Invoking guix download}) or @code{guix hash} (@pxref{Invoking
  3401. guix hash}).
  3402. @item @code{file-name} (default: @code{#f})
  3403. The file name under which the source code should be saved. When this is
  3404. @code{#f}, a sensible default value will be used in most cases. In case
  3405. the source is fetched from a URL, the file name from the URL will be
  3406. used. For version control checkouts, it is recommended to provide the
  3407. file name explicitly because the default is not very descriptive.
  3408. @item @code{patches} (default: @code{'()})
  3409. A list of file names, origins, or file-like objects (@pxref{G-Expressions,
  3410. file-like objects}) pointing to patches to be applied to the source.
  3411. This list of patches must be unconditional. In particular, it cannot
  3412. depend on the value of @code{%current-system} or
  3413. @code{%current-target-system}.
  3414. @item @code{snippet} (default: @code{#f})
  3415. A G-expression (@pxref{G-Expressions}) or S-expression that will be run
  3416. in the source directory. This is a convenient way to modify the source,
  3417. sometimes more convenient than a patch.
  3418. @item @code{patch-flags} (default: @code{'("-p1")})
  3419. A list of command-line flags that should be passed to the @code{patch}
  3420. command.
  3421. @item @code{patch-inputs} (default: @code{#f})
  3422. Input packages or derivations to the patching process. When this is
  3423. @code{#f}, the usual set of inputs necessary for patching are provided,
  3424. such as GNU@tie{}Patch.
  3425. @item @code{modules} (default: @code{'()})
  3426. A list of Guile modules that should be loaded during the patching
  3427. process and while running the code in the @code{snippet} field.
  3428. @item @code{patch-guile} (default: @code{#f})
  3429. The Guile package that should be used in the patching process. When
  3430. this is @code{#f}, a sensible default is used.
  3431. @end table
  3432. @end deftp
  3433. @node Build Systems
  3434. @section Build Systems
  3435. @cindex build system
  3436. Each package definition specifies a @dfn{build system} and arguments for
  3437. that build system (@pxref{Defining Packages}). This @code{build-system}
  3438. field represents the build procedure of the package, as well as implicit
  3439. dependencies of that build procedure.
  3440. Build systems are @code{<build-system>} objects. The interface to
  3441. create and manipulate them is provided by the @code{(guix build-system)}
  3442. module, and actual build systems are exported by specific modules.
  3443. @cindex bag (low-level package representation)
  3444. Under the hood, build systems first compile package objects to
  3445. @dfn{bags}. A @dfn{bag} is like a package, but with less
  3446. ornamentation---in other words, a bag is a lower-level representation of
  3447. a package, which includes all the inputs of that package, including some
  3448. that were implicitly added by the build system. This intermediate
  3449. representation is then compiled to a derivation (@pxref{Derivations}).
  3450. Build systems accept an optional list of @dfn{arguments}. In package
  3451. definitions, these are passed @i{via} the @code{arguments} field
  3452. (@pxref{Defining Packages}). They are typically keyword arguments
  3453. (@pxref{Optional Arguments, keyword arguments in Guile,, guile, GNU
  3454. Guile Reference Manual}). The value of these arguments is usually
  3455. evaluated in the @dfn{build stratum}---i.e., by a Guile process launched
  3456. by the daemon (@pxref{Derivations}).
  3457. The main build system is @var{gnu-build-system}, which implements the
  3458. standard build procedure for GNU and many other packages. It
  3459. is provided by the @code{(guix build-system gnu)} module.
  3460. @defvr {Scheme Variable} gnu-build-system
  3461. @var{gnu-build-system} represents the GNU Build System, and variants
  3462. thereof (@pxref{Configuration, configuration and makefile conventions,,
  3463. standards, GNU Coding Standards}).
  3464. @cindex build phases
  3465. In a nutshell, packages using it are configured, built, and installed with
  3466. the usual @code{./configure && make && make check && make install}
  3467. command sequence. In practice, a few additional steps are often needed.
  3468. All these steps are split up in separate @dfn{phases},
  3469. notably@footnote{Please see the @code{(guix build gnu-build-system)}
  3470. modules for more details about the build phases.}:
  3471. @table @code
  3472. @item unpack
  3473. Unpack the source tarball, and change the current directory to the
  3474. extracted source tree. If the source is actually a directory, copy it
  3475. to the build tree, and enter that directory.
  3476. @item patch-source-shebangs
  3477. Patch shebangs encountered in source files so they refer to the right
  3478. store file names. For instance, this changes @code{#!/bin/sh} to
  3479. @code{#!/gnu/store/@dots{}-bash-4.3/bin/sh}.
  3480. @item configure
  3481. Run the @file{configure} script with a number of default options, such
  3482. as @code{--prefix=/gnu/store/@dots{}}, as well as the options specified
  3483. by the @code{#:configure-flags} argument.
  3484. @item build
  3485. Run @code{make} with the list of flags specified with
  3486. @code{#:make-flags}. If the @code{#:parallel-build?} argument is true
  3487. (the default), build with @code{make -j}.
  3488. @item check
  3489. Run @code{make check}, or some other target specified with
  3490. @code{#:test-target}, unless @code{#:tests? #f} is passed. If the
  3491. @code{#:parallel-tests?} argument is true (the default), run @code{make
  3492. check -j}.
  3493. @item install
  3494. Run @code{make install} with the flags listed in @code{#:make-flags}.
  3495. @item patch-shebangs
  3496. Patch shebangs on the installed executable files.
  3497. @item strip
  3498. Strip debugging symbols from ELF files (unless @code{#:strip-binaries?}
  3499. is false), copying them to the @code{debug} output when available
  3500. (@pxref{Installing Debugging Files}).
  3501. @end table
  3502. @vindex %standard-phases
  3503. The build-side module @code{(guix build gnu-build-system)} defines
  3504. @var{%standard-phases} as the default list of build phases.
  3505. @var{%standard-phases} is a list of symbol/procedure pairs, where the
  3506. procedure implements the actual phase.
  3507. The list of phases used for a particular package can be changed with the
  3508. @code{#:phases} parameter. For instance, passing:
  3509. @example
  3510. #:phases (modify-phases %standard-phases (delete 'configure))
  3511. @end example
  3512. means that all the phases described above will be used, except the
  3513. @code{configure} phase.
  3514. In addition, this build system ensures that the ``standard'' environment
  3515. for GNU packages is available. This includes tools such as GCC, libc,
  3516. Coreutils, Bash, Make, Diffutils, grep, and sed (see the @code{(guix
  3517. build-system gnu)} module for a complete list). We call these the
  3518. @dfn{implicit inputs} of a package, because package definitions do not
  3519. have to mention them.
  3520. @end defvr
  3521. Other @code{<build-system>} objects are defined to support other
  3522. conventions and tools used by free software packages. They inherit most
  3523. of @var{gnu-build-system}, and differ mainly in the set of inputs
  3524. implicitly added to the build process, and in the list of phases
  3525. executed. Some of these build systems are listed below.
  3526. @defvr {Scheme Variable} ant-build-system
  3527. This variable is exported by @code{(guix build-system ant)}. It
  3528. implements the build procedure for Java packages that can be built with
  3529. @url{http://ant.apache.org/, Ant build tool}.
  3530. It adds both @code{ant} and the @dfn{Java Development Kit} (JDK) as
  3531. provided by the @code{icedtea} package to the set of inputs. Different
  3532. packages can be specified with the @code{#:ant} and @code{#:jdk}
  3533. parameters, respectively.
  3534. When the original package does not provide a suitable Ant build file,
  3535. the parameter @code{#:jar-name} can be used to generate a minimal Ant
  3536. build file @file{build.xml} with tasks to build the specified jar
  3537. archive. In this case the parameter @code{#:source-dir} can be used to
  3538. specify the source sub-directory, defaulting to ``src''.
  3539. The @code{#:main-class} parameter can be used with the minimal ant
  3540. buildfile to specify the main class of the resulting jar. This makes the
  3541. jar file executable. The @code{#:test-include} parameter can be used to
  3542. specify the list of junit tests to run. It defaults to
  3543. @code{(list "**/*Test.java")}. The @code{#:test-exclude} can be used to
  3544. disable some tests. It defaults to @code{(list "**/Abstract*.java")},
  3545. because abstract classes cannot be run as tests.
  3546. The parameter @code{#:build-target} can be used to specify the Ant task
  3547. that should be run during the @code{build} phase. By default the
  3548. ``jar'' task will be run.
  3549. @end defvr
  3550. @defvr {Scheme Variable} android-ndk-build-system
  3551. @cindex Android distribution
  3552. @cindex Android NDK build system
  3553. This variable is exported by @code{(guix build-system android-ndk)}. It
  3554. implements a build procedure for Android NDK (native development kit)
  3555. packages using a Guix-specific build process.
  3556. The build system assumes that packages install their public interface
  3557. (header) files to the subdirectory "include" of the "out" output and
  3558. their libraries to the subdirectory "lib" of the "out" output.
  3559. It's also assumed that the union of all the dependencies of a package
  3560. has no conflicting files.
  3561. For the time being, cross-compilation is not supported - so right now
  3562. the libraries and header files are assumed to be host tools.
  3563. @end defvr
  3564. @defvr {Scheme Variable} asdf-build-system/source
  3565. @defvrx {Scheme Variable} asdf-build-system/sbcl
  3566. @defvrx {Scheme Variable} asdf-build-system/ecl
  3567. These variables, exported by @code{(guix build-system asdf)}, implement
  3568. build procedures for Common Lisp packages using
  3569. @url{https://common-lisp.net/project/asdf/, ``ASDF''}. ASDF is a system
  3570. definition facility for Common Lisp programs and libraries.
  3571. The @code{asdf-build-system/source} system installs the packages in
  3572. source form, and can be loaded using any common lisp implementation, via
  3573. ASDF. The others, such as @code{asdf-build-system/sbcl}, install binary
  3574. systems in the format which a particular implementation understands.
  3575. These build systems can also be used to produce executable programs, or
  3576. lisp images which contain a set of packages pre-loaded.
  3577. The build system uses naming conventions. For binary packages, the
  3578. package name should be prefixed with the lisp implementation, such as
  3579. @code{sbcl-} for @code{asdf-build-system/sbcl}.
  3580. Additionally, the corresponding source package should be labeled using
  3581. the same convention as python packages (see @ref{Python Modules}), using
  3582. the @code{cl-} prefix.
  3583. For binary packages, each system should be defined as a Guix package.
  3584. If one package @code{origin} contains several systems, package variants
  3585. can be created in order to build all the systems. Source packages,
  3586. which use @code{asdf-build-system/source}, may contain several systems.
  3587. In order to create executable programs and images, the build-side
  3588. procedures @code{build-program} and @code{build-image} can be used.
  3589. They should be called in a build phase after the @code{create-symlinks}
  3590. phase, so that the system which was just built can be used within the
  3591. resulting image. @code{build-program} requires a list of Common Lisp
  3592. expressions to be passed as the @code{#:entry-program} argument.
  3593. If the system is not defined within its own @code{.asd} file of the same
  3594. name, then the @code{#:asd-file} parameter should be used to specify
  3595. which file the system is defined in. Furthermore, if the package
  3596. defines a system for its tests in a separate file, it will be loaded
  3597. before the tests are run if it is specified by the
  3598. @code{#:test-asd-file} parameter. If it is not set, the files
  3599. @code{<system>-tests.asd}, @code{<system>-test.asd}, @code{tests.asd},
  3600. and @code{test.asd} will be tried if they exist.
  3601. If for some reason the package must be named in a different way than the
  3602. naming conventions suggest, the @code{#:asd-system-name} parameter can
  3603. be used to specify the name of the system.
  3604. @end defvr
  3605. @defvr {Scheme Variable} cargo-build-system
  3606. @cindex Rust programming language
  3607. @cindex Cargo (Rust build system)
  3608. This variable is exported by @code{(guix build-system cargo)}. It
  3609. supports builds of packages using Cargo, the build tool of the
  3610. @uref{https://www.rust-lang.org, Rust programming language}.
  3611. In its @code{configure} phase, this build system replaces dependencies
  3612. specified in the @file{Carto.toml} file with inputs to the Guix package.
  3613. The @code{install} phase installs the binaries, and it also installs the
  3614. source code and @file{Cargo.toml} file.
  3615. @end defvr
  3616. @cindex Clojure (programming language)
  3617. @cindex simple Clojure build system
  3618. @defvr {Scheme Variable} clojure-build-system
  3619. This variable is exported by @code{(guix build-system clojure)}. It implements
  3620. a simple build procedure for @uref{https://clojure.org/, Clojure} packages
  3621. using plain old @code{compile} in Clojure. Cross-compilation is not supported
  3622. yet.
  3623. It adds @code{clojure}, @code{icedtea} and @code{zip} to the set of inputs.
  3624. Different packages can be specified with the @code{#:clojure}, @code{#:jdk} and
  3625. @code{#:zip} parameters, respectively.
  3626. A list of source directories, test directories and jar names can be specified
  3627. with the @code{#:source-dirs}, @code{#:test-dirs} and @code{#:jar-names}
  3628. parameters, respectively. Compile directory and main class can be specified
  3629. with the @code{#:compile-dir} and @code{#:main-class} parameters, respectively.
  3630. Other parameters are documented below.
  3631. This build system is an extension of @var{ant-build-system}, but with the
  3632. following phases changed:
  3633. @table @code
  3634. @item build
  3635. This phase calls @code{compile} in Clojure to compile source files and runs
  3636. @command{jar} to create jars from both source files and compiled files
  3637. according to the include list and exclude list specified in
  3638. @code{#:aot-include} and @code{#:aot-exclude}, respectively. The exclude list
  3639. has priority over the include list. These lists consist of symbols
  3640. representing Clojure libraries or the special keyword @code{#:all} representing
  3641. all Clojure libraries found under the source directories. The parameter
  3642. @code{#:omit-source?} decides if source should be included into the jars.
  3643. @item check
  3644. This phase runs tests according to the include list and exclude list specified
  3645. in @code{#:test-include} and @code{#:test-exclude}, respectively. Their
  3646. meanings are analogous to that of @code{#:aot-include} and
  3647. @code{#:aot-exclude}, except that the special keyword @code{#:all} now
  3648. stands for all Clojure libraries found under the test directories. The
  3649. parameter @code{#:tests?} decides if tests should be run.
  3650. @item install
  3651. This phase installs all jars built previously.
  3652. @end table
  3653. Apart from the above, this build system also contains an additional phase:
  3654. @table @code
  3655. @item install-doc
  3656. This phase installs all top-level files with base name matching
  3657. @var{%doc-regex}. A different regex can be specified with the
  3658. @code{#:doc-regex} parameter. All files (recursively) inside the documentation
  3659. directories specified in @code{#:doc-dirs} are installed as well.
  3660. @end table
  3661. @end defvr
  3662. @defvr {Scheme Variable} cmake-build-system
  3663. This variable is exported by @code{(guix build-system cmake)}. It
  3664. implements the build procedure for packages using the
  3665. @url{http://www.cmake.org, CMake build tool}.
  3666. It automatically adds the @code{cmake} package to the set of inputs.
  3667. Which package is used can be specified with the @code{#:cmake}
  3668. parameter.
  3669. The @code{#:configure-flags} parameter is taken as a list of flags
  3670. passed to the @command{cmake} command. The @code{#:build-type}
  3671. parameter specifies in abstract terms the flags passed to the compiler;
  3672. it defaults to @code{"RelWithDebInfo"} (short for ``release mode with
  3673. debugging information''), which roughly means that code is compiled with
  3674. @code{-O2 -g}, as is the case for Autoconf-based packages by default.
  3675. @end defvr
  3676. @defvr {Scheme Variable} go-build-system
  3677. This variable is exported by @code{(guix build-system go)}. It
  3678. implements a build procedure for Go packages using the standard
  3679. @url{https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies,
  3680. Go build mechanisms}.
  3681. The user is expected to provide a value for the key @code{#:import-path}
  3682. and, in some cases, @code{#:unpack-path}. The
  3683. @url{https://golang.org/doc/code.html#ImportPaths, import path}
  3684. corresponds to the file system path expected by the package's build
  3685. scripts and any referring packages, and provides a unique way to
  3686. refer to a Go package. It is typically based on a combination of the
  3687. package source code's remote URI and file system hierarchy structure. In
  3688. some cases, you will need to unpack the package's source code to a
  3689. different directory structure than the one indicated by the import path,
  3690. and @code{#:unpack-path} should be used in such cases.
  3691. Packages that provide Go libraries should be installed along with their
  3692. source code. The key @code{#:install-source?}, which defaults to
  3693. @code{#t}, controls whether or not the source code is installed. It can
  3694. be set to @code{#f} for packages that only provide executable files.
  3695. @end defvr
  3696. @defvr {Scheme Variable} glib-or-gtk-build-system
  3697. This variable is exported by @code{(guix build-system glib-or-gtk)}. It
  3698. is intended for use with packages making use of GLib or GTK+.
  3699. This build system adds the following two phases to the ones defined by
  3700. @var{gnu-build-system}:
  3701. @table @code
  3702. @item glib-or-gtk-wrap
  3703. The phase @code{glib-or-gtk-wrap} ensures that programs in
  3704. @file{bin/} are able to find GLib ``schemas'' and
  3705. @uref{https://developer.gnome.org/gtk3/stable/gtk-running.html, GTK+
  3706. modules}. This is achieved by wrapping the programs in launch scripts
  3707. that appropriately set the @code{XDG_DATA_DIRS} and @code{GTK_PATH}
  3708. environment variables.
  3709. It is possible to exclude specific package outputs from that wrapping
  3710. process by listing their names in the
  3711. @code{#:glib-or-gtk-wrap-excluded-outputs} parameter. This is useful
  3712. when an output is known not to contain any GLib or GTK+ binaries, and
  3713. where wrapping would gratuitously add a dependency of that output on
  3714. GLib and GTK+.
  3715. @item glib-or-gtk-compile-schemas
  3716. The phase @code{glib-or-gtk-compile-schemas} makes sure that all
  3717. @uref{https://developer.gnome.org/gio/stable/glib-compile-schemas.html,
  3718. GSettings schemas} of GLib are compiled. Compilation is performed by the
  3719. @command{glib-compile-schemas} program. It is provided by the package
  3720. @code{glib:bin} which is automatically imported by the build system.
  3721. The @code{glib} package providing @command{glib-compile-schemas} can be
  3722. specified with the @code{#:glib} parameter.
  3723. @end table
  3724. Both phases are executed after the @code{install} phase.
  3725. @end defvr
  3726. @defvr {Scheme Variable} guile-build-system
  3727. This build system is for Guile packages that consist exclusively of Scheme
  3728. code and that are so lean that they don't even have a makefile, let alone a
  3729. @file{configure} script. It compiles Scheme code using @command{guild
  3730. compile} (@pxref{Compilation,,, guile, GNU Guile Reference Manual}) and
  3731. installs the @file{.scm} and @file{.go} files in the right place. It also
  3732. installs documentation.
  3733. This build system supports cross-compilation by using the @code{--target}
  3734. option of @command{guild compile}.
  3735. Packages built with @code{guile-build-system} must provide a Guile package in
  3736. their @code{native-inputs} field.
  3737. @end defvr
  3738. @defvr {Scheme Variable} minify-build-system
  3739. This variable is exported by @code{(guix build-system minify)}. It
  3740. implements a minification procedure for simple JavaScript packages.
  3741. It adds @code{uglify-js} to the set of inputs and uses it to compress
  3742. all JavaScript files in the @file{src} directory. A different minifier
  3743. package can be specified with the @code{#:uglify-js} parameter, but it
  3744. is expected that the package writes the minified code to the standard
  3745. output.
  3746. When the input JavaScript files are not all located in the @file{src}
  3747. directory, the parameter @code{#:javascript-files} can be used to
  3748. specify a list of file names to feed to the minifier.
  3749. @end defvr
  3750. @defvr {Scheme Variable} ocaml-build-system
  3751. This variable is exported by @code{(guix build-system ocaml)}. It implements
  3752. a build procedure for @uref{https://ocaml.org, OCaml} packages, which consists
  3753. of choosing the correct set of commands to run for each package. OCaml
  3754. packages can expect many different commands to be run. This build system will
  3755. try some of them.
  3756. When the package has a @file{setup.ml} file present at the top-level, it will
  3757. run @code{ocaml setup.ml -configure}, @code{ocaml setup.ml -build} and
  3758. @code{ocaml setup.ml -install}. The build system will assume that this file
  3759. was generated by @uref{http://oasis.forge.ocamlcore.org/, OASIS} and will take
  3760. care of setting the prefix and enabling tests if they are not disabled. You
  3761. can pass configure and build flags with the @code{#:configure-flags} and
  3762. @code{#:build-flags}. The @code{#:test-flags} key can be passed to change the
  3763. set of flags used to enable tests. The @code{#:use-make?} key can be used to
  3764. bypass this system in the build and install phases.
  3765. When the package has a @file{configure} file, it is assumed that it is a
  3766. hand-made configure script that requires a different argument format than
  3767. in the @code{gnu-build-system}. You can add more flags with the
  3768. @code{#:configure-flags} key.
  3769. When the package has a @file{Makefile} file (or @code{#:use-make?} is
  3770. @code{#t}), it will be used and more flags can be passed to the build and
  3771. install phases with the @code{#:make-flags} key.
  3772. Finally, some packages do not have these files and use a somewhat standard
  3773. location for its build system. In that case, the build system will run
  3774. @code{ocaml pkg/pkg.ml} or @code{ocaml pkg/build.ml} and take care of
  3775. providing the path to the required findlib module. Additional flags can
  3776. be passed via the @code{#:build-flags} key. Install is taken care of by
  3777. @command{opam-installer}. In this case, the @code{opam} package must
  3778. be added to the @code{native-inputs} field of the package definition.
  3779. Note that most OCaml packages assume they will be installed in the same
  3780. directory as OCaml, which is not what we want in guix. In particular, they
  3781. will install @file{.so} files in their module's directory, which is usually
  3782. fine because it is in the OCaml compiler directory. In guix though, these
  3783. libraries cannot be found and we use @code{CAML_LD_LIBRARY_PATH}. This
  3784. variable points to @file{lib/ocaml/site-lib/stubslibs} and this is where
  3785. @file{.so} libraries should be installed.
  3786. @end defvr
  3787. @defvr {Scheme Variable} python-build-system
  3788. This variable is exported by @code{(guix build-system python)}. It
  3789. implements the more or less standard build procedure used by Python
  3790. packages, which consists in running @code{python setup.py build} and
  3791. then @code{python setup.py install --prefix=/gnu/store/@dots{}}.
  3792. For packages that install stand-alone Python programs under @code{bin/},
  3793. it takes care of wrapping these programs so that their @code{PYTHONPATH}
  3794. environment variable points to all the Python libraries they depend on.
  3795. Which Python package is used to perform the build can be specified with
  3796. the @code{#:python} parameter. This is a useful way to force a package
  3797. to be built for a specific version of the Python interpreter, which
  3798. might be necessary if the package is only compatible with a single
  3799. interpreter version.
  3800. By default guix calls @code{setup.py} under control of
  3801. @code{setuptools}, much like @command{pip} does. Some packages are not
  3802. compatible with setuptools (and pip), thus you can disable this by
  3803. setting the @code{#:use-setuptools} parameter to @code{#f}.
  3804. @end defvr
  3805. @defvr {Scheme Variable} perl-build-system
  3806. This variable is exported by @code{(guix build-system perl)}. It
  3807. implements the standard build procedure for Perl packages, which either
  3808. consists in running @code{perl Build.PL --prefix=/gnu/store/@dots{}},
  3809. followed by @code{Build} and @code{Build install}; or in running
  3810. @code{perl Makefile.PL PREFIX=/gnu/store/@dots{}}, followed by
  3811. @code{make} and @code{make install}, depending on which of
  3812. @code{Build.PL} or @code{Makefile.PL} is present in the package
  3813. distribution. Preference is given to the former if both @code{Build.PL}
  3814. and @code{Makefile.PL} exist in the package distribution. This
  3815. preference can be reversed by specifying @code{#t} for the
  3816. @code{#:make-maker?} parameter.
  3817. The initial @code{perl Makefile.PL} or @code{perl Build.PL} invocation
  3818. passes flags specified by the @code{#:make-maker-flags} or
  3819. @code{#:module-build-flags} parameter, respectively.
  3820. Which Perl package is used can be specified with @code{#:perl}.
  3821. @end defvr
  3822. @defvr {Scheme Variable} r-build-system
  3823. This variable is exported by @code{(guix build-system r)}. It
  3824. implements the build procedure used by @uref{http://r-project.org, R}
  3825. packages, which essentially is little more than running @code{R CMD
  3826. INSTALL --library=/gnu/store/@dots{}} in an environment where
  3827. @code{R_LIBS_SITE} contains the paths to all R package inputs. Tests
  3828. are run after installation using the R function
  3829. @code{tools::testInstalledPackage}.
  3830. @end defvr
  3831. @defvr {Scheme Variable} texlive-build-system
  3832. This variable is exported by @code{(guix build-system texlive)}. It is
  3833. used to build TeX packages in batch mode with a specified engine. The
  3834. build system sets the @code{TEXINPUTS} variable to find all TeX source
  3835. files in the inputs.
  3836. By default it runs @code{luatex} on all files ending on @code{ins}. A
  3837. different engine and format can be specified with the
  3838. @code{#:tex-format} argument. Different build targets can be specified
  3839. with the @code{#:build-targets} argument, which expects a list of file
  3840. names. The build system adds only @code{texlive-bin} and
  3841. @code{texlive-latex-base} (both from @code{(gnu packages tex}) to the
  3842. inputs. Both can be overridden with the arguments @code{#:texlive-bin}
  3843. and @code{#:texlive-latex-base}, respectively.
  3844. The @code{#:tex-directory} parameter tells the build system where to
  3845. install the built files under the texmf tree.
  3846. @end defvr
  3847. @defvr {Scheme Variable} ruby-build-system
  3848. This variable is exported by @code{(guix build-system ruby)}. It
  3849. implements the RubyGems build procedure used by Ruby packages, which
  3850. involves running @code{gem build} followed by @code{gem install}.
  3851. The @code{source} field of a package that uses this build system
  3852. typically references a gem archive, since this is the format that Ruby
  3853. developers use when releasing their software. The build system unpacks
  3854. the gem archive, potentially patches the source, runs the test suite,
  3855. repackages the gem, and installs it. Additionally, directories and
  3856. tarballs may be referenced to allow building unreleased gems from Git or
  3857. a traditional source release tarball.
  3858. Which Ruby package is used can be specified with the @code{#:ruby}
  3859. parameter. A list of additional flags to be passed to the @command{gem}
  3860. command can be specified with the @code{#:gem-flags} parameter.
  3861. @end defvr
  3862. @defvr {Scheme Variable} waf-build-system
  3863. This variable is exported by @code{(guix build-system waf)}. It
  3864. implements a build procedure around the @code{waf} script. The common
  3865. phases---@code{configure}, @code{build}, and @code{install}---are
  3866. implemented by passing their names as arguments to the @code{waf}
  3867. script.
  3868. The @code{waf} script is executed by the Python interpreter. Which
  3869. Python package is used to run the script can be specified with the
  3870. @code{#:python} parameter.
  3871. @end defvr
  3872. @defvr {Scheme Variable} scons-build-system
  3873. This variable is exported by @code{(guix build-system scons)}. It
  3874. implements the build procedure used by the SCons software construction
  3875. tool. This build system runs @code{scons} to build the package,
  3876. @code{scons test} to run tests, and then @code{scons install} to install
  3877. the package.
  3878. Additional flags to be passed to @code{scons} can be specified with the
  3879. @code{#:scons-flags} parameter. The version of Python used to run SCons
  3880. can be specified by selecting the appropriate SCons package with the
  3881. @code{#:scons} parameter.
  3882. @end defvr
  3883. @defvr {Scheme Variable} haskell-build-system
  3884. This variable is exported by @code{(guix build-system haskell)}. It
  3885. implements the Cabal build procedure used by Haskell packages, which
  3886. involves running @code{runhaskell Setup.hs configure
  3887. --prefix=/gnu/store/@dots{}} and @code{runhaskell Setup.hs build}.
  3888. Instead of installing the package by running @code{runhaskell Setup.hs
  3889. install}, to avoid trying to register libraries in the read-only
  3890. compiler store directory, the build system uses @code{runhaskell
  3891. Setup.hs copy}, followed by @code{runhaskell Setup.hs register}. In
  3892. addition, the build system generates the package documentation by
  3893. running @code{runhaskell Setup.hs haddock}, unless @code{#:haddock? #f}
  3894. is passed. Optional Haddock parameters can be passed with the help of
  3895. the @code{#:haddock-flags} parameter. If the file @code{Setup.hs} is
  3896. not found, the build system looks for @code{Setup.lhs} instead.
  3897. Which Haskell compiler is used can be specified with the @code{#:haskell}
  3898. parameter which defaults to @code{ghc}.
  3899. @end defvr
  3900. @defvr {Scheme Variable} dub-build-system
  3901. This variable is exported by @code{(guix build-system dub)}. It
  3902. implements the Dub build procedure used by D packages, which
  3903. involves running @code{dub build} and @code{dub run}.
  3904. Installation is done by copying the files manually.
  3905. Which D compiler is used can be specified with the @code{#:ldc}
  3906. parameter which defaults to @code{ldc}.
  3907. @end defvr
  3908. @defvr {Scheme Variable} emacs-build-system
  3909. This variable is exported by @code{(guix build-system emacs)}. It
  3910. implements an installation procedure similar to the packaging system
  3911. of Emacs itself (@pxref{Packages,,, emacs, The GNU Emacs Manual}).
  3912. It first creates the @code{@var{package}-autoloads.el} file, then it
  3913. byte compiles all Emacs Lisp files. Differently from the Emacs
  3914. packaging system, the Info documentation files are moved to the standard
  3915. documentation directory and the @file{dir} file is deleted. Each
  3916. package is installed in its own directory under
  3917. @file{share/emacs/site-lisp/guix.d}.
  3918. @end defvr
  3919. @defvr {Scheme Variable} font-build-system
  3920. This variable is exported by @code{(guix build-system font)}. It
  3921. implements an installation procedure for font packages where upstream
  3922. provides pre-compiled TrueType, OpenType, etc.@: font files that merely
  3923. need to be copied into place. It copies font files to standard
  3924. locations in the output directory.
  3925. @end defvr
  3926. @defvr {Scheme Variable} meson-build-system
  3927. This variable is exported by @code{(guix build-system meson)}. It
  3928. implements the build procedure for packages that use
  3929. @url{http://mesonbuild.com, Meson} as their build system.
  3930. It adds both Meson and @uref{https://ninja-build.org/, Ninja} to the set
  3931. of inputs, and they can be changed with the parameters @code{#:meson}
  3932. and @code{#:ninja} if needed. The default Meson is
  3933. @code{meson-for-build}, which is special because it doesn't clear the
  3934. @code{RUNPATH} of binaries and libraries when they are installed.
  3935. This build system is an extension of @var{gnu-build-system}, but with the
  3936. following phases changed to some specific for Meson:
  3937. @table @code
  3938. @item configure
  3939. The phase runs @code{meson} with the flags specified in
  3940. @code{#:configure-flags}. The flag @code{--build-type} is always set to
  3941. @code{plain} unless something else is specified in @code{#:build-type}.
  3942. @item build
  3943. The phase runs @code{ninja} to build the package in parallel by default, but
  3944. this can be changed with @code{#:parallel-build?}.
  3945. @item check
  3946. The phase runs @code{ninja} with the target specified in @code{#:test-target},
  3947. which is @code{"test"} by default.
  3948. @item install
  3949. The phase runs @code{ninja install} and can not be changed.
  3950. @end table
  3951. Apart from that, the build system also adds the following phases:
  3952. @table @code
  3953. @item fix-runpath
  3954. This phase ensures that all binaries can find the libraries they need.
  3955. It searches for required libraries in subdirectories of the package being
  3956. built, and adds those to @code{RUNPATH} where needed. It also removes
  3957. references to libraries left over from the build phase by
  3958. @code{meson-for-build}, such as test dependencies, that aren't actually
  3959. required for the program to run.
  3960. @item glib-or-gtk-wrap
  3961. This phase is the phase provided by @code{glib-or-gtk-build-system}, and it
  3962. is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
  3963. @item glib-or-gtk-compile-schemas
  3964. This phase is the phase provided by @code{glib-or-gtk-build-system}, and it
  3965. is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
  3966. @end table
  3967. @end defvr
  3968. Lastly, for packages that do not need anything as sophisticated, a
  3969. ``trivial'' build system is provided. It is trivial in the sense that
  3970. it provides basically no support: it does not pull any implicit inputs,
  3971. and does not have a notion of build phases.
  3972. @defvr {Scheme Variable} trivial-build-system
  3973. This variable is exported by @code{(guix build-system trivial)}.
  3974. This build system requires a @code{#:builder} argument. This argument
  3975. must be a Scheme expression that builds the package output(s)---as
  3976. with @code{build-expression->derivation} (@pxref{Derivations,
  3977. @code{build-expression->derivation}}).
  3978. @end defvr
  3979. @node The Store
  3980. @section The Store
  3981. @cindex store
  3982. @cindex store items
  3983. @cindex store paths
  3984. Conceptually, the @dfn{store} is the place where derivations that have
  3985. been built successfully are stored---by default, @file{/gnu/store}.
  3986. Sub-directories in the store are referred to as @dfn{store items} or
  3987. sometimes @dfn{store paths}. The store has an associated database that
  3988. contains information such as the store paths referred to by each store
  3989. path, and the list of @emph{valid} store items---results of successful
  3990. builds. This database resides in @file{@var{localstatedir}/guix/db},
  3991. where @var{localstatedir} is the state directory specified @i{via}
  3992. @option{--localstatedir} at configure time, usually @file{/var}.
  3993. The store is @emph{always} accessed by the daemon on behalf of its clients
  3994. (@pxref{Invoking guix-daemon}). To manipulate the store, clients
  3995. connect to the daemon over a Unix-domain socket, send requests to it,
  3996. and read the result---these are remote procedure calls, or RPCs.
  3997. @quotation Note
  3998. Users must @emph{never} modify files under @file{/gnu/store} directly.
  3999. This would lead to inconsistencies and break the immutability
  4000. assumptions of Guix's functional model (@pxref{Introduction}).
  4001. @xref{Invoking guix gc, @command{guix gc --verify}}, for information on
  4002. how to check the integrity of the store and attempt recovery from
  4003. accidental modifications.
  4004. @end quotation
  4005. The @code{(guix store)} module provides procedures to connect to the
  4006. daemon, and to perform RPCs. These are described below. By default,
  4007. @code{open-connection}, and thus all the @command{guix} commands,
  4008. connect to the local daemon or to the URI specified by the
  4009. @code{GUIX_DAEMON_SOCKET} environment variable.
  4010. @defvr {Environment Variable} GUIX_DAEMON_SOCKET
  4011. When set, the value of this variable should be a file name or a URI
  4012. designating the daemon endpoint. When it is a file name, it denotes a
  4013. Unix-domain socket to connect to. In addition to file names, the
  4014. supported URI schemes are:
  4015. @table @code
  4016. @item file
  4017. @itemx unix
  4018. These are for Unix-domain sockets.
  4019. @code{file:///var/guix/daemon-socket/socket} is equivalent to
  4020. @file{/var/guix/daemon-socket/socket}.
  4021. @item guix
  4022. @cindex daemon, remote access
  4023. @cindex remote access to the daemon
  4024. @cindex daemon, cluster setup
  4025. @cindex clusters, daemon setup
  4026. These URIs denote connections over TCP/IP, without encryption nor
  4027. authentication of the remote host. The URI must specify the host name
  4028. and optionally a port number (by default port 44146 is used):
  4029. @example
  4030. guix://master.guix.example.org:1234
  4031. @end example
  4032. This setup is suitable on local networks, such as clusters, where only
  4033. trusted nodes may connect to the build daemon at
  4034. @code{master.guix.example.org}.
  4035. The @code{--listen} option of @command{guix-daemon} can be used to
  4036. instruct it to listen for TCP connections (@pxref{Invoking guix-daemon,
  4037. @code{--listen}}).
  4038. @item ssh
  4039. @cindex SSH access to build daemons
  4040. These URIs allow you to connect to a remote daemon over
  4041. SSH@footnote{This feature requires Guile-SSH (@pxref{Requirements}).}.
  4042. A typical URL might look like this:
  4043. @example
  4044. ssh://charlie@@guix.example.org:22
  4045. @end example
  4046. As for @command{guix copy}, the usual OpenSSH client configuration files
  4047. are honored (@pxref{Invoking guix copy}).
  4048. @end table
  4049. Additional URI schemes may be supported in the future.
  4050. @c XXX: Remove this note when the protocol incurs fewer round trips
  4051. @c and when (guix derivations) no longer relies on file system access.
  4052. @quotation Note
  4053. The ability to connect to remote build daemons is considered
  4054. experimental as of @value{VERSION}. Please get in touch with us to
  4055. share any problems or suggestions you may have (@pxref{Contributing}).
  4056. @end quotation
  4057. @end defvr
  4058. @deffn {Scheme Procedure} open-connection [@var{uri}] [#:reserve-space? #t]
  4059. Connect to the daemon over the Unix-domain socket at @var{uri} (a string). When
  4060. @var{reserve-space?} is true, instruct it to reserve a little bit of
  4061. extra space on the file system so that the garbage collector can still
  4062. operate should the disk become full. Return a server object.
  4063. @var{file} defaults to @var{%default-socket-path}, which is the normal
  4064. location given the options that were passed to @command{configure}.
  4065. @end deffn
  4066. @deffn {Scheme Procedure} close-connection @var{server}
  4067. Close the connection to @var{server}.
  4068. @end deffn
  4069. @defvr {Scheme Variable} current-build-output-port
  4070. This variable is bound to a SRFI-39 parameter, which refers to the port
  4071. where build and error logs sent by the daemon should be written.
  4072. @end defvr
  4073. Procedures that make RPCs all take a server object as their first
  4074. argument.
  4075. @deffn {Scheme Procedure} valid-path? @var{server} @var{path}
  4076. @cindex invalid store items
  4077. Return @code{#t} when @var{path} designates a valid store item and
  4078. @code{#f} otherwise (an invalid item may exist on disk but still be
  4079. invalid, for instance because it is the result of an aborted or failed
  4080. build.)
  4081. A @code{&nix-protocol-error} condition is raised if @var{path} is not
  4082. prefixed by the store directory (@file{/gnu/store}).
  4083. @end deffn
  4084. @deffn {Scheme Procedure} add-text-to-store @var{server} @var{name} @var{text} [@var{references}]
  4085. Add @var{text} under file @var{name} in the store, and return its store
  4086. path. @var{references} is the list of store paths referred to by the
  4087. resulting store path.
  4088. @end deffn
  4089. @deffn {Scheme Procedure} build-derivations @var{server} @var{derivations}
  4090. Build @var{derivations} (a list of @code{<derivation>} objects or
  4091. derivation paths), and return when the worker is done building them.
  4092. Return @code{#t} on success.
  4093. @end deffn
  4094. Note that the @code{(guix monads)} module provides a monad as well as
  4095. monadic versions of the above procedures, with the goal of making it
  4096. more convenient to work with code that accesses the store (@pxref{The
  4097. Store Monad}).
  4098. @c FIXME
  4099. @i{This section is currently incomplete.}
  4100. @node Derivations
  4101. @section Derivations
  4102. @cindex derivations
  4103. Low-level build actions and the environment in which they are performed
  4104. are represented by @dfn{derivations}. A derivation contains the
  4105. following pieces of information:
  4106. @itemize
  4107. @item
  4108. The outputs of the derivation---derivations produce at least one file or
  4109. directory in the store, but may produce more.
  4110. @item
  4111. The inputs of the derivations, which may be other derivations or plain
  4112. files in the store (patches, build scripts, etc.)
  4113. @item
  4114. The system type targeted by the derivation---e.g., @code{x86_64-linux}.
  4115. @item
  4116. The file name of a build script in the store, along with the arguments
  4117. to be passed.
  4118. @item
  4119. A list of environment variables to be defined.
  4120. @end itemize
  4121. @cindex derivation path
  4122. Derivations allow clients of the daemon to communicate build actions to
  4123. the store. They exist in two forms: as an in-memory representation,
  4124. both on the client- and daemon-side, and as files in the store whose
  4125. name end in @code{.drv}---these files are referred to as @dfn{derivation
  4126. paths}. Derivations paths can be passed to the @code{build-derivations}
  4127. procedure to perform the build actions they prescribe (@pxref{The
  4128. Store}).
  4129. @cindex fixed-output derivations
  4130. Operations such as file downloads and version-control checkouts for
  4131. which the expected content hash is known in advance are modeled as
  4132. @dfn{fixed-output derivations}. Unlike regular derivations, the outputs
  4133. of a fixed-output derivation are independent of its inputs---e.g., a
  4134. source code download produces the same result regardless of the download
  4135. method and tools being used.
  4136. The @code{(guix derivations)} module provides a representation of
  4137. derivations as Scheme objects, along with procedures to create and
  4138. otherwise manipulate derivations. The lowest-level primitive to create
  4139. a derivation is the @code{derivation} procedure:
  4140. @deffn {Scheme Procedure} derivation @var{store} @var{name} @var{builder} @
  4141. @var{args} [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
  4142. [#:recursive? #f] [#:inputs '()] [#:env-vars '()] @
  4143. [#:system (%current-system)] [#:references-graphs #f] @
  4144. [#:allowed-references #f] [#:disallowed-references #f] @
  4145. [#:leaked-env-vars #f] [#:local-build? #f] @
  4146. [#:substitutable? #t] [#:properties '()]
  4147. Build a derivation with the given arguments, and return the resulting
  4148. @code{<derivation>} object.
  4149. When @var{hash} and @var{hash-algo} are given, a
  4150. @dfn{fixed-output derivation} is created---i.e., one whose result is
  4151. known in advance, such as a file download. If, in addition,
  4152. @var{recursive?} is true, then that fixed output may be an executable
  4153. file or a directory and @var{hash} must be the hash of an archive
  4154. containing this output.
  4155. When @var{references-graphs} is true, it must be a list of file
  4156. name/store path pairs. In that case, the reference graph of each store
  4157. path is exported in the build environment in the corresponding file, in
  4158. a simple text format.
  4159. When @var{allowed-references} is true, it must be a list of store items
  4160. or outputs that the derivation's output may refer to. Likewise,
  4161. @var{disallowed-references}, if true, must be a list of things the
  4162. outputs may @emph{not} refer to.
  4163. When @var{leaked-env-vars} is true, it must be a list of strings
  4164. denoting environment variables that are allowed to ``leak'' from the
  4165. daemon's environment to the build environment. This is only applicable
  4166. to fixed-output derivations---i.e., when @var{hash} is true. The main
  4167. use is to allow variables such as @code{http_proxy} to be passed to
  4168. derivations that download files.
  4169. When @var{local-build?} is true, declare that the derivation is not a
  4170. good candidate for offloading and should rather be built locally
  4171. (@pxref{Daemon Offload Setup}). This is the case for small derivations
  4172. where the costs of data transfers would outweigh the benefits.
  4173. When @var{substitutable?} is false, declare that substitutes of the
  4174. derivation's output should not be used (@pxref{Substitutes}). This is
  4175. useful, for instance, when building packages that capture details of the
  4176. host CPU instruction set.
  4177. @var{properties} must be an association list describing ``properties'' of the
  4178. derivation. It is kept as-is, uninterpreted, in the derivation.
  4179. @end deffn
  4180. @noindent
  4181. Here's an example with a shell script as its builder, assuming
  4182. @var{store} is an open connection to the daemon, and @var{bash} points
  4183. to a Bash executable in the store:
  4184. @lisp
  4185. (use-modules (guix utils)
  4186. (guix store)
  4187. (guix derivations))
  4188. (let ((builder ; add the Bash script to the store
  4189. (add-text-to-store store "my-builder.sh"
  4190. "echo hello world > $out\n" '())))
  4191. (derivation store "foo"
  4192. bash `("-e" ,builder)
  4193. #:inputs `((,bash) (,builder))
  4194. #:env-vars '(("HOME" . "/homeless"))))
  4195. @result{} #<derivation /gnu/store/@dots{}-foo.drv => /gnu/store/@dots{}-foo>
  4196. @end lisp
  4197. As can be guessed, this primitive is cumbersome to use directly. A
  4198. better approach is to write build scripts in Scheme, of course! The
  4199. best course of action for that is to write the build code as a
  4200. ``G-expression'', and to pass it to @code{gexp->derivation}. For more
  4201. information, @pxref{G-Expressions}.
  4202. Once upon a time, @code{gexp->derivation} did not exist and constructing
  4203. derivations with build code written in Scheme was achieved with
  4204. @code{build-expression->derivation}, documented below. This procedure
  4205. is now deprecated in favor of the much nicer @code{gexp->derivation}.
  4206. @deffn {Scheme Procedure} build-expression->derivation @var{store} @
  4207. @var{name} @var{exp} @
  4208. [#:system (%current-system)] [#:inputs '()] @
  4209. [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
  4210. [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
  4211. [#:references-graphs #f] [#:allowed-references #f] @
  4212. [#:disallowed-references #f] @
  4213. [#:local-build? #f] [#:substitutable? #t] [#:guile-for-build #f]
  4214. Return a derivation that executes Scheme expression @var{exp} as a
  4215. builder for derivation @var{name}. @var{inputs} must be a list of
  4216. @code{(name drv-path sub-drv)} tuples; when @var{sub-drv} is omitted,
  4217. @code{"out"} is assumed. @var{modules} is a list of names of Guile
  4218. modules from the current search path to be copied in the store,
  4219. compiled, and made available in the load path during the execution of
  4220. @var{exp}---e.g., @code{((guix build utils) (guix build
  4221. gnu-build-system))}.
  4222. @var{exp} is evaluated in an environment where @code{%outputs} is bound
  4223. to a list of output/path pairs, and where @code{%build-inputs} is bound
  4224. to a list of string/output-path pairs made from @var{inputs}.
  4225. Optionally, @var{env-vars} is a list of string pairs specifying the name
  4226. and value of environment variables visible to the builder. The builder
  4227. terminates by passing the result of @var{exp} to @code{exit}; thus, when
  4228. @var{exp} returns @code{#f}, the build is considered to have failed.
  4229. @var{exp} is built using @var{guile-for-build} (a derivation). When
  4230. @var{guile-for-build} is omitted or is @code{#f}, the value of the
  4231. @code{%guile-for-build} fluid is used instead.
  4232. See the @code{derivation} procedure for the meaning of
  4233. @var{references-graphs}, @var{allowed-references},
  4234. @var{disallowed-references}, @var{local-build?}, and
  4235. @var{substitutable?}.
  4236. @end deffn
  4237. @noindent
  4238. Here's an example of a single-output derivation that creates a directory
  4239. containing one file:
  4240. @lisp
  4241. (let ((builder '(let ((out (assoc-ref %outputs "out")))
  4242. (mkdir out) ; create /gnu/store/@dots{}-goo
  4243. (call-with-output-file (string-append out "/test")
  4244. (lambda (p)
  4245. (display '(hello guix) p))))))
  4246. (build-expression->derivation store "goo" builder))
  4247. @result{} #<derivation /gnu/store/@dots{}-goo.drv => @dots{}>
  4248. @end lisp
  4249. @node The Store Monad
  4250. @section The Store Monad
  4251. @cindex monad
  4252. The procedures that operate on the store described in the previous
  4253. sections all take an open connection to the build daemon as their first
  4254. argument. Although the underlying model is functional, they either have
  4255. side effects or depend on the current state of the store.
  4256. The former is inconvenient: the connection to the build daemon has to be
  4257. carried around in all those functions, making it impossible to compose
  4258. functions that do not take that parameter with functions that do. The
  4259. latter can be problematic: since store operations have side effects
  4260. and/or depend on external state, they have to be properly sequenced.
  4261. @cindex monadic values
  4262. @cindex monadic functions
  4263. This is where the @code{(guix monads)} module comes in. This module
  4264. provides a framework for working with @dfn{monads}, and a particularly
  4265. useful monad for our uses, the @dfn{store monad}. Monads are a
  4266. construct that allows two things: associating ``context'' with values
  4267. (in our case, the context is the store), and building sequences of
  4268. computations (here computations include accesses to the store). Values
  4269. in a monad---values that carry this additional context---are called
  4270. @dfn{monadic values}; procedures that return such values are called
  4271. @dfn{monadic procedures}.
  4272. Consider this ``normal'' procedure:
  4273. @example
  4274. (define (sh-symlink store)
  4275. ;; Return a derivation that symlinks the 'bash' executable.
  4276. (let* ((drv (package-derivation store bash))
  4277. (out (derivation->output-path drv))
  4278. (sh (string-append out "/bin/bash")))
  4279. (build-expression->derivation store "sh"
  4280. `(symlink ,sh %output))))
  4281. @end example
  4282. Using @code{(guix monads)} and @code{(guix gexp)}, it may be rewritten
  4283. as a monadic function:
  4284. @example
  4285. (define (sh-symlink)
  4286. ;; Same, but return a monadic value.
  4287. (mlet %store-monad ((drv (package->derivation bash)))
  4288. (gexp->derivation "sh"
  4289. #~(symlink (string-append #$drv "/bin/bash")
  4290. #$output))))
  4291. @end example
  4292. There are several things to note in the second version: the @code{store}
  4293. parameter is now implicit and is ``threaded'' in the calls to the
  4294. @code{package->derivation} and @code{gexp->derivation} monadic
  4295. procedures, and the monadic value returned by @code{package->derivation}
  4296. is @dfn{bound} using @code{mlet} instead of plain @code{let}.
  4297. As it turns out, the call to @code{package->derivation} can even be
  4298. omitted since it will take place implicitly, as we will see later
  4299. (@pxref{G-Expressions}):
  4300. @example
  4301. (define (sh-symlink)
  4302. (gexp->derivation "sh"
  4303. #~(symlink (string-append #$bash "/bin/bash")
  4304. #$output)))
  4305. @end example
  4306. @c See
  4307. @c <https://syntaxexclamation.wordpress.com/2014/06/26/escaping-continuations/>
  4308. @c for the funny quote.
  4309. Calling the monadic @code{sh-symlink} has no effect. As someone once
  4310. said, ``you exit a monad like you exit a building on fire: by running''.
  4311. So, to exit the monad and get the desired effect, one must use
  4312. @code{run-with-store}:
  4313. @example
  4314. (run-with-store (open-connection) (sh-symlink))
  4315. @result{} /gnu/store/...-sh-symlink
  4316. @end example
  4317. Note that the @code{(guix monad-repl)} module extends the Guile REPL with
  4318. new ``meta-commands'' to make it easier to deal with monadic procedures:
  4319. @code{run-in-store}, and @code{enter-store-monad}. The former is used
  4320. to ``run'' a single monadic value through the store:
  4321. @example
  4322. scheme@@(guile-user)> ,run-in-store (package->derivation hello)
  4323. $1 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
  4324. @end example
  4325. The latter enters a recursive REPL, where all the return values are
  4326. automatically run through the store:
  4327. @example
  4328. scheme@@(guile-user)> ,enter-store-monad
  4329. store-monad@@(guile-user) [1]> (package->derivation hello)
  4330. $2 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
  4331. store-monad@@(guile-user) [1]> (text-file "foo" "Hello!")
  4332. $3 = "/gnu/store/@dots{}-foo"
  4333. store-monad@@(guile-user) [1]> ,q
  4334. scheme@@(guile-user)>
  4335. @end example
  4336. @noindent
  4337. Note that non-monadic values cannot be returned in the
  4338. @code{store-monad} REPL.
  4339. The main syntactic forms to deal with monads in general are provided by
  4340. the @code{(guix monads)} module and are described below.
  4341. @deffn {Scheme Syntax} with-monad @var{monad} @var{body} ...
  4342. Evaluate any @code{>>=} or @code{return} forms in @var{body} as being
  4343. in @var{monad}.
  4344. @end deffn
  4345. @deffn {Scheme Syntax} return @var{val}
  4346. Return a monadic value that encapsulates @var{val}.
  4347. @end deffn
  4348. @deffn {Scheme Syntax} >>= @var{mval} @var{mproc} ...
  4349. @dfn{Bind} monadic value @var{mval}, passing its ``contents'' to monadic
  4350. procedures @var{mproc}@dots{}@footnote{This operation is commonly
  4351. referred to as ``bind'', but that name denotes an unrelated procedure in
  4352. Guile. Thus we use this somewhat cryptic symbol inherited from the
  4353. Haskell language.}. There can be one @var{mproc} or several of them, as
  4354. in this example:
  4355. @example
  4356. (run-with-state
  4357. (with-monad %state-monad
  4358. (>>= (return 1)
  4359. (lambda (x) (return (+ 1 x)))
  4360. (lambda (x) (return (* 2 x)))))
  4361. 'some-state)
  4362. @result{} 4
  4363. @result{} some-state
  4364. @end example
  4365. @end deffn
  4366. @deffn {Scheme Syntax} mlet @var{monad} ((@var{var} @var{mval}) ...) @
  4367. @var{body} ...
  4368. @deffnx {Scheme Syntax} mlet* @var{monad} ((@var{var} @var{mval}) ...) @
  4369. @var{body} ...
  4370. Bind the variables @var{var} to the monadic values @var{mval} in
  4371. @var{body}, which is a sequence of expressions. As with the bind
  4372. operator, this can be thought of as ``unpacking'' the raw, non-monadic
  4373. value ``contained'' in @var{mval} and making @var{var} refer to that
  4374. raw, non-monadic value within the scope of the @var{body}. The form
  4375. (@var{var} -> @var{val}) binds @var{var} to the ``normal'' value
  4376. @var{val}, as per @code{let}. The binding operations occur in sequence
  4377. from left to right. The last expression of @var{body} must be a monadic
  4378. expression, and its result will become the result of the @code{mlet} or
  4379. @code{mlet*} when run in the @var{monad}.
  4380. @code{mlet*} is to @code{mlet} what @code{let*} is to @code{let}
  4381. (@pxref{Local Bindings,,, guile, GNU Guile Reference Manual}).
  4382. @end deffn
  4383. @deffn {Scheme System} mbegin @var{monad} @var{mexp} ...
  4384. Bind @var{mexp} and the following monadic expressions in sequence,
  4385. returning the result of the last expression. Every expression in the
  4386. sequence must be a monadic expression.
  4387. This is akin to @code{mlet}, except that the return values of the
  4388. monadic expressions are ignored. In that sense, it is analogous to
  4389. @code{begin}, but applied to monadic expressions.
  4390. @end deffn
  4391. @deffn {Scheme System} mwhen @var{condition} @var{mexp0} @var{mexp*} ...
  4392. When @var{condition} is true, evaluate the sequence of monadic
  4393. expressions @var{mexp0}..@var{mexp*} as in an @code{mbegin}. When
  4394. @var{condition} is false, return @code{*unspecified*} in the current
  4395. monad. Every expression in the sequence must be a monadic expression.
  4396. @end deffn
  4397. @deffn {Scheme System} munless @var{condition} @var{mexp0} @var{mexp*} ...
  4398. When @var{condition} is false, evaluate the sequence of monadic
  4399. expressions @var{mexp0}..@var{mexp*} as in an @code{mbegin}. When
  4400. @var{condition} is true, return @code{*unspecified*} in the current
  4401. monad. Every expression in the sequence must be a monadic expression.
  4402. @end deffn
  4403. @cindex state monad
  4404. The @code{(guix monads)} module provides the @dfn{state monad}, which
  4405. allows an additional value---the state---to be @emph{threaded} through
  4406. monadic procedure calls.
  4407. @defvr {Scheme Variable} %state-monad
  4408. The state monad. Procedures in the state monad can access and change
  4409. the state that is threaded.
  4410. Consider the example below. The @code{square} procedure returns a value
  4411. in the state monad. It returns the square of its argument, but also
  4412. increments the current state value:
  4413. @example
  4414. (define (square x)
  4415. (mlet %state-monad ((count (current-state)))
  4416. (mbegin %state-monad
  4417. (set-current-state (+ 1 count))
  4418. (return (* x x)))))
  4419. (run-with-state (sequence %state-monad (map square (iota 3))) 0)
  4420. @result{} (0 1 4)
  4421. @result{} 3
  4422. @end example
  4423. When ``run'' through @var{%state-monad}, we obtain that additional state
  4424. value, which is the number of @code{square} calls.
  4425. @end defvr
  4426. @deffn {Monadic Procedure} current-state
  4427. Return the current state as a monadic value.
  4428. @end deffn
  4429. @deffn {Monadic Procedure} set-current-state @var{value}
  4430. Set the current state to @var{value} and return the previous state as a
  4431. monadic value.
  4432. @end deffn
  4433. @deffn {Monadic Procedure} state-push @var{value}
  4434. Push @var{value} to the current state, which is assumed to be a list,
  4435. and return the previous state as a monadic value.
  4436. @end deffn
  4437. @deffn {Monadic Procedure} state-pop
  4438. Pop a value from the current state and return it as a monadic value.
  4439. The state is assumed to be a list.
  4440. @end deffn
  4441. @deffn {Scheme Procedure} run-with-state @var{mval} [@var{state}]
  4442. Run monadic value @var{mval} starting with @var{state} as the initial
  4443. state. Return two values: the resulting value, and the resulting state.
  4444. @end deffn
  4445. The main interface to the store monad, provided by the @code{(guix
  4446. store)} module, is as follows.
  4447. @defvr {Scheme Variable} %store-monad
  4448. The store monad---an alias for @var{%state-monad}.
  4449. Values in the store monad encapsulate accesses to the store. When its
  4450. effect is needed, a value of the store monad must be ``evaluated'' by
  4451. passing it to the @code{run-with-store} procedure (see below.)
  4452. @end defvr
  4453. @deffn {Scheme Procedure} run-with-store @var{store} @var{mval} [#:guile-for-build] [#:system (%current-system)]
  4454. Run @var{mval}, a monadic value in the store monad, in @var{store}, an
  4455. open store connection.
  4456. @end deffn
  4457. @deffn {Monadic Procedure} text-file @var{name} @var{text} [@var{references}]
  4458. Return as a monadic value the absolute file name in the store of the file
  4459. containing @var{text}, a string. @var{references} is a list of store items that the
  4460. resulting text file refers to; it defaults to the empty list.
  4461. @end deffn
  4462. @deffn {Monadic Procedure} binary-file @var{name} @var{data} [@var{references}]
  4463. Return as a monadic value the absolute file name in the store of the file
  4464. containing @var{data}, a bytevector. @var{references} is a list of store
  4465. items that the resulting binary file refers to; it defaults to the empty list.
  4466. @end deffn
  4467. @deffn {Monadic Procedure} interned-file @var{file} [@var{name}] @
  4468. [#:recursive? #t] [#:select? (const #t)]
  4469. Return the name of @var{file} once interned in the store. Use
  4470. @var{name} as its store name, or the basename of @var{file} if
  4471. @var{name} is omitted.
  4472. When @var{recursive?} is true, the contents of @var{file} are added
  4473. recursively; if @var{file} designates a flat file and @var{recursive?}
  4474. is true, its contents are added, and its permission bits are kept.
  4475. When @var{recursive?} is true, call @code{(@var{select?} @var{file}
  4476. @var{stat})} for each directory entry, where @var{file} is the entry's
  4477. absolute file name and @var{stat} is the result of @code{lstat}; exclude
  4478. entries for which @var{select?} does not return true.
  4479. The example below adds a file to the store, under two different names:
  4480. @example
  4481. (run-with-store (open-connection)
  4482. (mlet %store-monad ((a (interned-file "README"))
  4483. (b (interned-file "README" "LEGU-MIN")))
  4484. (return (list a b))))
  4485. @result{} ("/gnu/store/rwm@dots{}-README" "/gnu/store/44i@dots{}-LEGU-MIN")
  4486. @end example
  4487. @end deffn
  4488. The @code{(guix packages)} module exports the following package-related
  4489. monadic procedures:
  4490. @deffn {Monadic Procedure} package-file @var{package} [@var{file}] @
  4491. [#:system (%current-system)] [#:target #f] @
  4492. [#:output "out"]
  4493. Return as a monadic
  4494. value in the absolute file name of @var{file} within the @var{output}
  4495. directory of @var{package}. When @var{file} is omitted, return the name
  4496. of the @var{output} directory of @var{package}. When @var{target} is
  4497. true, use it as a cross-compilation target triplet.
  4498. @end deffn
  4499. @deffn {Monadic Procedure} package->derivation @var{package} [@var{system}]
  4500. @deffnx {Monadic Procedure} package->cross-derivation @var{package} @
  4501. @var{target} [@var{system}]
  4502. Monadic version of @code{package-derivation} and
  4503. @code{package-cross-derivation} (@pxref{Defining Packages}).
  4504. @end deffn
  4505. @node G-Expressions
  4506. @section G-Expressions
  4507. @cindex G-expression
  4508. @cindex build code quoting
  4509. So we have ``derivations'', which represent a sequence of build actions
  4510. to be performed to produce an item in the store (@pxref{Derivations}).
  4511. These build actions are performed when asking the daemon to actually
  4512. build the derivations; they are run by the daemon in a container
  4513. (@pxref{Invoking guix-daemon}).
  4514. @cindex strata of code
  4515. It should come as no surprise that we like to write these build actions
  4516. in Scheme. When we do that, we end up with two @dfn{strata} of Scheme
  4517. code@footnote{The term @dfn{stratum} in this context was coined by
  4518. Manuel Serrano et al.@: in the context of their work on Hop. Oleg
  4519. Kiselyov, who has written insightful
  4520. @url{http://okmij.org/ftp/meta-programming/#meta-scheme, essays and code
  4521. on this topic}, refers to this kind of code generation as
  4522. @dfn{staging}.}: the ``host code''---code that defines packages, talks
  4523. to the daemon, etc.---and the ``build code''---code that actually
  4524. performs build actions, such as making directories, invoking
  4525. @command{make}, etc.
  4526. To describe a derivation and its build actions, one typically needs to
  4527. embed build code inside host code. It boils down to manipulating build
  4528. code as data, and the homoiconicity of Scheme---code has a direct
  4529. representation as data---comes in handy for that. But we need more than
  4530. the normal @code{quasiquote} mechanism in Scheme to construct build
  4531. expressions.
  4532. The @code{(guix gexp)} module implements @dfn{G-expressions}, a form of
  4533. S-expressions adapted to build expressions. G-expressions, or
  4534. @dfn{gexps}, consist essentially of three syntactic forms: @code{gexp},
  4535. @code{ungexp}, and @code{ungexp-splicing} (or simply: @code{#~},
  4536. @code{#$}, and @code{#$@@}), which are comparable to
  4537. @code{quasiquote}, @code{unquote}, and @code{unquote-splicing},
  4538. respectively (@pxref{Expression Syntax, @code{quasiquote},, guile,
  4539. GNU Guile Reference Manual}). However, there are major differences:
  4540. @itemize
  4541. @item
  4542. Gexps are meant to be written to a file and run or manipulated by other
  4543. processes.
  4544. @item
  4545. When a high-level object such as a package or derivation is unquoted
  4546. inside a gexp, the result is as if its output file name had been
  4547. introduced.
  4548. @item
  4549. Gexps carry information about the packages or derivations they refer to,
  4550. and these dependencies are automatically added as inputs to the build
  4551. processes that use them.
  4552. @end itemize
  4553. @cindex lowering, of high-level objects in gexps
  4554. This mechanism is not limited to package and derivation
  4555. objects: @dfn{compilers} able to ``lower'' other high-level objects to
  4556. derivations or files in the store can be defined,
  4557. such that these objects can also be inserted
  4558. into gexps. For example, a useful type of high-level objects that can be
  4559. inserted in a gexp is ``file-like objects'', which make it easy to
  4560. add files to the store and to refer to them in
  4561. derivations and such (see @code{local-file} and @code{plain-file}
  4562. below.)
  4563. To illustrate the idea, here is an example of a gexp:
  4564. @example
  4565. (define build-exp
  4566. #~(begin
  4567. (mkdir #$output)
  4568. (chdir #$output)
  4569. (symlink (string-append #$coreutils "/bin/ls")
  4570. "list-files")))
  4571. @end example
  4572. This gexp can be passed to @code{gexp->derivation}; we obtain a
  4573. derivation that builds a directory containing exactly one symlink to
  4574. @file{/gnu/store/@dots{}-coreutils-8.22/bin/ls}:
  4575. @example
  4576. (gexp->derivation "the-thing" build-exp)
  4577. @end example
  4578. As one would expect, the @code{"/gnu/store/@dots{}-coreutils-8.22"} string is
  4579. substituted to the reference to the @var{coreutils} package in the
  4580. actual build code, and @var{coreutils} is automatically made an input to
  4581. the derivation. Likewise, @code{#$output} (equivalent to @code{(ungexp
  4582. output)}) is replaced by a string containing the directory name of the
  4583. output of the derivation.
  4584. @cindex cross compilation
  4585. In a cross-compilation context, it is useful to distinguish between
  4586. references to the @emph{native} build of a package---that can run on the
  4587. host---versus references to cross builds of a package. To that end, the
  4588. @code{#+} plays the same role as @code{#$}, but is a reference to a
  4589. native package build:
  4590. @example
  4591. (gexp->derivation "vi"
  4592. #~(begin
  4593. (mkdir #$output)
  4594. (system* (string-append #+coreutils "/bin/ln")
  4595. "-s"
  4596. (string-append #$emacs "/bin/emacs")
  4597. (string-append #$output "/bin/vi")))
  4598. #:target "mips64el-linux-gnu")
  4599. @end example
  4600. @noindent
  4601. In the example above, the native build of @var{coreutils} is used, so
  4602. that @command{ln} can actually run on the host; but then the
  4603. cross-compiled build of @var{emacs} is referenced.
  4604. @cindex imported modules, for gexps
  4605. @findex with-imported-modules
  4606. Another gexp feature is @dfn{imported modules}: sometimes you want to be
  4607. able to use certain Guile modules from the ``host environment'' in the
  4608. gexp, so those modules should be imported in the ``build environment''.
  4609. The @code{with-imported-modules} form allows you to express that:
  4610. @example
  4611. (let ((build (with-imported-modules '((guix build utils))
  4612. #~(begin
  4613. (use-modules (guix build utils))
  4614. (mkdir-p (string-append #$output "/bin"))))))
  4615. (gexp->derivation "empty-dir"
  4616. #~(begin
  4617. #$build
  4618. (display "success!\n")
  4619. #t)))
  4620. @end example
  4621. @noindent
  4622. In this example, the @code{(guix build utils)} module is automatically
  4623. pulled into the isolated build environment of our gexp, such that
  4624. @code{(use-modules (guix build utils))} works as expected.
  4625. @cindex module closure
  4626. @findex source-module-closure
  4627. Usually you want the @emph{closure} of the module to be imported---i.e.,
  4628. the module itself and all the modules it depends on---rather than just
  4629. the module; failing to do that, attempts to use the module will fail
  4630. because of missing dependent modules. The @code{source-module-closure}
  4631. procedure computes the closure of a module by looking at its source file
  4632. headers, which comes in handy in this case:
  4633. @example
  4634. (use-modules (guix modules)) ;for 'source-module-closure'
  4635. (with-imported-modules (source-module-closure
  4636. '((guix build utils)
  4637. (gnu build vm)))
  4638. (gexp->derivation "something-with-vms"
  4639. #~(begin
  4640. (use-modules (guix build utils)
  4641. (gnu build vm))
  4642. @dots{})))
  4643. @end example
  4644. @cindex extensions, for gexps
  4645. @findex with-extensions
  4646. In the same vein, sometimes you want to import not just pure-Scheme
  4647. modules, but also ``extensions'' such as Guile bindings to C libraries
  4648. or other ``full-blown'' packages. Say you need the @code{guile-json}
  4649. package available on the build side, here's how you would do it:
  4650. @example
  4651. (use-modules (gnu packages guile)) ;for 'guile-json'
  4652. (with-extensions (list guile-json)
  4653. (gexp->derivation "something-with-json"
  4654. #~(begin
  4655. (use-modules (json))
  4656. @dots{})))
  4657. @end example
  4658. The syntactic form to construct gexps is summarized below.
  4659. @deffn {Scheme Syntax} #~@var{exp}
  4660. @deffnx {Scheme Syntax} (gexp @var{exp})
  4661. Return a G-expression containing @var{exp}. @var{exp} may contain one
  4662. or more of the following forms:
  4663. @table @code
  4664. @item #$@var{obj}
  4665. @itemx (ungexp @var{obj})
  4666. Introduce a reference to @var{obj}. @var{obj} may have one of the
  4667. supported types, for example a package or a
  4668. derivation, in which case the @code{ungexp} form is replaced by its
  4669. output file name---e.g., @code{"/gnu/store/@dots{}-coreutils-8.22}.
  4670. If @var{obj} is a list, it is traversed and references to supported
  4671. objects are substituted similarly.
  4672. If @var{obj} is another gexp, its contents are inserted and its
  4673. dependencies are added to those of the containing gexp.
  4674. If @var{obj} is another kind of object, it is inserted as is.
  4675. @item #$@var{obj}:@var{output}
  4676. @itemx (ungexp @var{obj} @var{output})
  4677. This is like the form above, but referring explicitly to the
  4678. @var{output} of @var{obj}---this is useful when @var{obj} produces
  4679. multiple outputs (@pxref{Packages with Multiple Outputs}).
  4680. @item #+@var{obj}
  4681. @itemx #+@var{obj}:output
  4682. @itemx (ungexp-native @var{obj})
  4683. @itemx (ungexp-native @var{obj} @var{output})
  4684. Same as @code{ungexp}, but produces a reference to the @emph{native}
  4685. build of @var{obj} when used in a cross compilation context.
  4686. @item #$output[:@var{output}]
  4687. @itemx (ungexp output [@var{output}])
  4688. Insert a reference to derivation output @var{output}, or to the main
  4689. output when @var{output} is omitted.
  4690. This only makes sense for gexps passed to @code{gexp->derivation}.
  4691. @item #$@@@var{lst}
  4692. @itemx (ungexp-splicing @var{lst})
  4693. Like the above, but splices the contents of @var{lst} inside the
  4694. containing list.
  4695. @item #+@@@var{lst}
  4696. @itemx (ungexp-native-splicing @var{lst})
  4697. Like the above, but refers to native builds of the objects listed in
  4698. @var{lst}.
  4699. @end table
  4700. G-expressions created by @code{gexp} or @code{#~} are run-time objects
  4701. of the @code{gexp?} type (see below.)
  4702. @end deffn
  4703. @deffn {Scheme Syntax} with-imported-modules @var{modules} @var{body}@dots{}
  4704. Mark the gexps defined in @var{body}@dots{} as requiring @var{modules}
  4705. in their execution environment.
  4706. Each item in @var{modules} can be the name of a module, such as
  4707. @code{(guix build utils)}, or it can be a module name, followed by an
  4708. arrow, followed by a file-like object:
  4709. @example
  4710. `((guix build utils)
  4711. (guix gcrypt)
  4712. ((guix config) => ,(scheme-file "config.scm"
  4713. #~(define-module @dots{}))))
  4714. @end example
  4715. @noindent
  4716. In the example above, the first two modules are taken from the search
  4717. path, and the last one is created from the given file-like object.
  4718. This form has @emph{lexical} scope: it has an effect on the gexps
  4719. directly defined in @var{body}@dots{}, but not on those defined, say, in
  4720. procedures called from @var{body}@dots{}.
  4721. @end deffn
  4722. @deffn {Scheme Syntax} with-extensions @var{extensions} @var{body}@dots{}
  4723. Mark the gexps defined in @var{body}@dots{} as requiring
  4724. @var{extensions} in their build and execution environment.
  4725. @var{extensions} is typically a list of package objects such as those
  4726. defined in the @code{(gnu packages guile)} module.
  4727. Concretely, the packages listed in @var{extensions} are added to the
  4728. load path while compiling imported modules in @var{body}@dots{}; they
  4729. are also added to the load path of the gexp returned by
  4730. @var{body}@dots{}.
  4731. @end deffn
  4732. @deffn {Scheme Procedure} gexp? @var{obj}
  4733. Return @code{#t} if @var{obj} is a G-expression.
  4734. @end deffn
  4735. G-expressions are meant to be written to disk, either as code building
  4736. some derivation, or as plain files in the store. The monadic procedures
  4737. below allow you to do that (@pxref{The Store Monad}, for more
  4738. information about monads.)
  4739. @deffn {Monadic Procedure} gexp->derivation @var{name} @var{exp} @
  4740. [#:system (%current-system)] [#:target #f] [#:graft? #t] @
  4741. [#:hash #f] [#:hash-algo #f] @
  4742. [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
  4743. [#:module-path @var{%load-path}] @
  4744. [#:effective-version "2.2"] @
  4745. [#:references-graphs #f] [#:allowed-references #f] @
  4746. [#:disallowed-references #f] @
  4747. [#:leaked-env-vars #f] @
  4748. [#:script-name (string-append @var{name} "-builder")] @
  4749. [#:deprecation-warnings #f] @
  4750. [#:local-build? #f] [#:substitutable? #t] @
  4751. [#:properties '()] [#:guile-for-build #f]
  4752. Return a derivation @var{name} that runs @var{exp} (a gexp) with
  4753. @var{guile-for-build} (a derivation) on @var{system}; @var{exp} is
  4754. stored in a file called @var{script-name}. When @var{target} is true,
  4755. it is used as the cross-compilation target triplet for packages referred
  4756. to by @var{exp}.
  4757. @var{modules} is deprecated in favor of @code{with-imported-modules}.
  4758. Its meaning is to
  4759. make @var{modules} available in the evaluation context of @var{exp};
  4760. @var{modules} is a list of names of Guile modules searched in
  4761. @var{module-path} to be copied in the store, compiled, and made available in
  4762. the load path during the execution of @var{exp}---e.g., @code{((guix
  4763. build utils) (guix build gnu-build-system))}.
  4764. @var{effective-version} determines the string to use when adding extensions of
  4765. @var{exp} (see @code{with-extensions}) to the search path---e.g., @code{"2.2"}.
  4766. @var{graft?} determines whether packages referred to by @var{exp} should be grafted when
  4767. applicable.
  4768. When @var{references-graphs} is true, it must be a list of tuples of one of the
  4769. following forms:
  4770. @example
  4771. (@var{file-name} @var{package})
  4772. (@var{file-name} @var{package} @var{output})
  4773. (@var{file-name} @var{derivation})
  4774. (@var{file-name} @var{derivation} @var{output})
  4775. (@var{file-name} @var{store-item})
  4776. @end example
  4777. The right-hand-side of each element of @var{references-graphs} is automatically made
  4778. an input of the build process of @var{exp}. In the build environment, each
  4779. @var{file-name} contains the reference graph of the corresponding item, in a simple
  4780. text format.
  4781. @var{allowed-references} must be either @code{#f} or a list of output names and packages.
  4782. In the latter case, the list denotes store items that the result is allowed to
  4783. refer to. Any reference to another store item will lead to a build error.
  4784. Similarly for @var{disallowed-references}, which can list items that must not be
  4785. referenced by the outputs.
  4786. @var{deprecation-warnings} determines whether to show deprecation warnings while
  4787. compiling modules. It can be @code{#f}, @code{#t}, or @code{'detailed}.
  4788. The other arguments are as for @code{derivation} (@pxref{Derivations}).
  4789. @end deffn
  4790. @cindex file-like objects
  4791. The @code{local-file}, @code{plain-file}, @code{computed-file},
  4792. @code{program-file}, and @code{scheme-file} procedures below return
  4793. @dfn{file-like objects}. That is, when unquoted in a G-expression,
  4794. these objects lead to a file in the store. Consider this G-expression:
  4795. @example
  4796. #~(system* #$(file-append glibc "/sbin/nscd") "-f"
  4797. #$(local-file "/tmp/my-nscd.conf"))
  4798. @end example
  4799. The effect here is to ``intern'' @file{/tmp/my-nscd.conf} by copying it
  4800. to the store. Once expanded, for instance @i{via}
  4801. @code{gexp->derivation}, the G-expression refers to that copy under
  4802. @file{/gnu/store}; thus, modifying or removing the file in @file{/tmp}
  4803. does not have any effect on what the G-expression does.
  4804. @code{plain-file} can be used similarly; it differs in that the file
  4805. content is directly passed as a string.
  4806. @deffn {Scheme Procedure} local-file @var{file} [@var{name}] @
  4807. [#:recursive? #f] [#:select? (const #t)]
  4808. Return an object representing local file @var{file} to add to the store; this
  4809. object can be used in a gexp. If @var{file} is a relative file name, it is looked
  4810. up relative to the source file where this form appears. @var{file} will be added to
  4811. the store under @var{name}--by default the base name of @var{file}.
  4812. When @var{recursive?} is true, the contents of @var{file} are added recursively; if @var{file}
  4813. designates a flat file and @var{recursive?} is true, its contents are added, and its
  4814. permission bits are kept.
  4815. When @var{recursive?} is true, call @code{(@var{select?} @var{file}
  4816. @var{stat})} for each directory entry, where @var{file} is the entry's
  4817. absolute file name and @var{stat} is the result of @code{lstat}; exclude
  4818. entries for which @var{select?} does not return true.
  4819. This is the declarative counterpart of the @code{interned-file} monadic
  4820. procedure (@pxref{The Store Monad, @code{interned-file}}).
  4821. @end deffn
  4822. @deffn {Scheme Procedure} plain-file @var{name} @var{content}
  4823. Return an object representing a text file called @var{name} with the given
  4824. @var{content} (a string or a bytevector) to be added to the store.
  4825. This is the declarative counterpart of @code{text-file}.
  4826. @end deffn
  4827. @deffn {Scheme Procedure} computed-file @var{name} @var{gexp} @
  4828. [#:options '(#:local-build? #t)]
  4829. Return an object representing the store item @var{name}, a file or
  4830. directory computed by @var{gexp}. @var{options}
  4831. is a list of additional arguments to pass to @code{gexp->derivation}.
  4832. This is the declarative counterpart of @code{gexp->derivation}.
  4833. @end deffn
  4834. @deffn {Monadic Procedure} gexp->script @var{name} @var{exp} @
  4835. [#:guile (default-guile)] [#:module-path %load-path]
  4836. Return an executable script @var{name} that runs @var{exp} using
  4837. @var{guile}, with @var{exp}'s imported modules in its search path.
  4838. Look up @var{exp}'s modules in @var{module-path}.
  4839. The example below builds a script that simply invokes the @command{ls}
  4840. command:
  4841. @example
  4842. (use-modules (guix gexp) (gnu packages base))
  4843. (gexp->script "list-files"
  4844. #~(execl #$(file-append coreutils "/bin/ls")
  4845. "ls"))
  4846. @end example
  4847. When ``running'' it through the store (@pxref{The Store Monad,
  4848. @code{run-with-store}}), we obtain a derivation that produces an
  4849. executable file @file{/gnu/store/@dots{}-list-files} along these lines:
  4850. @example
  4851. #!/gnu/store/@dots{}-guile-2.0.11/bin/guile -ds
  4852. !#
  4853. (execl "/gnu/store/@dots{}-coreutils-8.22"/bin/ls" "ls")
  4854. @end example
  4855. @end deffn
  4856. @deffn {Scheme Procedure} program-file @var{name} @var{exp} @
  4857. [#:guile #f] [#:module-path %load-path]
  4858. Return an object representing the executable store item @var{name} that
  4859. runs @var{gexp}. @var{guile} is the Guile package used to execute that
  4860. script. Imported modules of @var{gexp} are looked up in @var{module-path}.
  4861. This is the declarative counterpart of @code{gexp->script}.
  4862. @end deffn
  4863. @deffn {Monadic Procedure} gexp->file @var{name} @var{exp} @
  4864. [#:set-load-path? #t] [#:module-path %load-path] @
  4865. [#:splice? #f] @
  4866. [#:guile (default-guile)]
  4867. Return a derivation that builds a file @var{name} containing @var{exp}.
  4868. When @var{splice?} is true, @var{exp} is considered to be a list of
  4869. expressions that will be spliced in the resulting file.
  4870. When @var{set-load-path?} is true, emit code in the resulting file to
  4871. set @code{%load-path} and @code{%load-compiled-path} to honor
  4872. @var{exp}'s imported modules. Look up @var{exp}'s modules in
  4873. @var{module-path}.
  4874. The resulting file holds references to all the dependencies of @var{exp}
  4875. or a subset thereof.
  4876. @end deffn
  4877. @deffn {Scheme Procedure} scheme-file @var{name} @var{exp} [#:splice? #f]
  4878. Return an object representing the Scheme file @var{name} that contains
  4879. @var{exp}.
  4880. This is the declarative counterpart of @code{gexp->file}.
  4881. @end deffn
  4882. @deffn {Monadic Procedure} text-file* @var{name} @var{text} @dots{}
  4883. Return as a monadic value a derivation that builds a text file
  4884. containing all of @var{text}. @var{text} may list, in addition to
  4885. strings, objects of any type that can be used in a gexp: packages,
  4886. derivations, local file objects, etc. The resulting store file holds
  4887. references to all these.
  4888. This variant should be preferred over @code{text-file} anytime the file
  4889. to create will reference items from the store. This is typically the
  4890. case when building a configuration file that embeds store file names,
  4891. like this:
  4892. @example
  4893. (define (profile.sh)
  4894. ;; Return the name of a shell script in the store that
  4895. ;; initializes the 'PATH' environment variable.
  4896. (text-file* "profile.sh"
  4897. "export PATH=" coreutils "/bin:"
  4898. grep "/bin:" sed "/bin\n"))
  4899. @end example
  4900. In this example, the resulting @file{/gnu/store/@dots{}-profile.sh} file
  4901. will reference @var{coreutils}, @var{grep}, and @var{sed}, thereby
  4902. preventing them from being garbage-collected during its lifetime.
  4903. @end deffn
  4904. @deffn {Scheme Procedure} mixed-text-file @var{name} @var{text} @dots{}
  4905. Return an object representing store file @var{name} containing
  4906. @var{text}. @var{text} is a sequence of strings and file-like objects,
  4907. as in:
  4908. @example
  4909. (mixed-text-file "profile"
  4910. "export PATH=" coreutils "/bin:" grep "/bin")
  4911. @end example
  4912. This is the declarative counterpart of @code{text-file*}.
  4913. @end deffn
  4914. @deffn {Scheme Procedure} file-union @var{name} @var{files}
  4915. Return a @code{<computed-file>} that builds a directory containing all of @var{files}.
  4916. Each item in @var{files} must be a two-element list where the first element is the
  4917. file name to use in the new directory, and the second element is a gexp
  4918. denoting the target file. Here's an example:
  4919. @example
  4920. (file-union "etc"
  4921. `(("hosts" ,(plain-file "hosts"
  4922. "127.0.0.1 localhost"))
  4923. ("bashrc" ,(plain-file "bashrc"
  4924. "alias ls='ls --color=auto'"))))
  4925. @end example
  4926. This yields an @code{etc} directory containing these two files.
  4927. @end deffn
  4928. @deffn {Scheme Procedure} directory-union @var{name} @var{things}
  4929. Return a directory that is the union of @var{things}, where @var{things} is a list of
  4930. file-like objects denoting directories. For example:
  4931. @example
  4932. (directory-union "guile+emacs" (list guile emacs))
  4933. @end example
  4934. yields a directory that is the union of the @code{guile} and @code{emacs} packages.
  4935. @end deffn
  4936. @deffn {Scheme Procedure} file-append @var{obj} @var{suffix} @dots{}
  4937. Return a file-like object that expands to the concatenation of @var{obj}
  4938. and @var{suffix}, where @var{obj} is a lowerable object and each
  4939. @var{suffix} is a string.
  4940. As an example, consider this gexp:
  4941. @example
  4942. (gexp->script "run-uname"
  4943. #~(system* #$(file-append coreutils
  4944. "/bin/uname")))
  4945. @end example
  4946. The same effect could be achieved with:
  4947. @example
  4948. (gexp->script "run-uname"
  4949. #~(system* (string-append #$coreutils
  4950. "/bin/uname")))
  4951. @end example
  4952. There is one difference though: in the @code{file-append} case, the
  4953. resulting script contains the absolute file name as a string, whereas in
  4954. the second case, the resulting script contains a @code{(string-append
  4955. @dots{})} expression to construct the file name @emph{at run time}.
  4956. @end deffn
  4957. Of course, in addition to gexps embedded in ``host'' code, there are
  4958. also modules containing build tools. To make it clear that they are
  4959. meant to be used in the build stratum, these modules are kept in the
  4960. @code{(guix build @dots{})} name space.
  4961. @cindex lowering, of high-level objects in gexps
  4962. Internally, high-level objects are @dfn{lowered}, using their compiler,
  4963. to either derivations or store items. For instance, lowering a package
  4964. yields a derivation, and lowering a @code{plain-file} yields a store
  4965. item. This is achieved using the @code{lower-object} monadic procedure.
  4966. @deffn {Monadic Procedure} lower-object @var{obj} [@var{system}] @
  4967. [#:target #f]
  4968. Return as a value in @var{%store-monad} the derivation or store item
  4969. corresponding to @var{obj} for @var{system}, cross-compiling for
  4970. @var{target} if @var{target} is true. @var{obj} must be an object that
  4971. has an associated gexp compiler, such as a @code{<package>}.
  4972. @end deffn
  4973. @node Invoking guix repl
  4974. @section Invoking @command{guix repl}
  4975. @cindex REPL, read-eval-print loop
  4976. The @command{guix repl} command spawns a Guile @dfn{read-eval-print loop}
  4977. (REPL) for interactive programming (@pxref{Using Guile Interactively,,, guile,
  4978. GNU Guile Reference Manual}). Compared to just launching the @command{guile}
  4979. command, @command{guix repl} guarantees that all the Guix modules and all its
  4980. dependencies are available in the search path. You can use it this way:
  4981. @example
  4982. $ guix repl
  4983. scheme@@(guile-user)> ,use (gnu packages base)
  4984. scheme@@(guile-user)> coreutils
  4985. $1 = #<package coreutils@@8.29 gnu/packages/base.scm:327 3e28300>
  4986. @end example
  4987. @cindex inferiors
  4988. In addition, @command{guix repl} implements a simple machine-readable REPL
  4989. protocol for use by @code{(guix inferior)}, a facility to interact with
  4990. @dfn{inferiors}, separate processes running a potentially different revision
  4991. of Guix.
  4992. The available options are as follows:
  4993. @table @code
  4994. @item --type=@var{type}
  4995. @itemx -t @var{type}
  4996. Start a REPL of the given @var{TYPE}, which can be one of the following:
  4997. @table @code
  4998. @item guile
  4999. This is default, and it spawns a standard full-featured Guile REPL.
  5000. @item machine
  5001. Spawn a REPL that uses the machine-readable protocol. This is the protocol
  5002. that the @code{(guix inferior)} module speaks.
  5003. @end table
  5004. @item --listen=@var{endpoint}
  5005. By default, @command{guix repl} reads from standard input and writes to
  5006. standard output. When this option is passed, it will instead listen for
  5007. connections on @var{endpoint}. Here are examples of valid options:
  5008. @table @code
  5009. @item --listen=tcp:37146
  5010. Accept connections on localhost on port 37146.
  5011. @item --listen=unix:/tmp/socket
  5012. Accept connections on the Unix-domain socket @file{/tmp/socket}.
  5013. @end table
  5014. @end table
  5015. @c *********************************************************************
  5016. @node Utilities
  5017. @chapter Utilities
  5018. This section describes Guix command-line utilities. Some of them are
  5019. primarily targeted at developers and users who write new package
  5020. definitions, while others are more generally useful. They complement
  5021. the Scheme programming interface of Guix in a convenient way.
  5022. @menu
  5023. * Invoking guix build:: Building packages from the command line.
  5024. * Invoking guix edit:: Editing package definitions.
  5025. * Invoking guix download:: Downloading a file and printing its hash.
  5026. * Invoking guix hash:: Computing the cryptographic hash of a file.
  5027. * Invoking guix import:: Importing package definitions.
  5028. * Invoking guix refresh:: Updating package definitions.
  5029. * Invoking guix lint:: Finding errors in package definitions.
  5030. * Invoking guix size:: Profiling disk usage.
  5031. * Invoking guix graph:: Visualizing the graph of packages.
  5032. * Invoking guix environment:: Setting up development environments.
  5033. * Invoking guix publish:: Sharing substitutes.
  5034. * Invoking guix challenge:: Challenging substitute servers.
  5035. * Invoking guix copy:: Copying to and from a remote store.
  5036. * Invoking guix container:: Process isolation.
  5037. * Invoking guix weather:: Assessing substitute availability.
  5038. * Invoking guix processes:: Listing client processes.
  5039. @end menu
  5040. @node Invoking guix build
  5041. @section Invoking @command{guix build}
  5042. @cindex package building
  5043. @cindex @command{guix build}
  5044. The @command{guix build} command builds packages or derivations and
  5045. their dependencies, and prints the resulting store paths. Note that it
  5046. does not modify the user's profile---this is the job of the
  5047. @command{guix package} command (@pxref{Invoking guix package}). Thus,
  5048. it is mainly useful for distribution developers.
  5049. The general syntax is:
  5050. @example
  5051. guix build @var{options} @var{package-or-derivation}@dots{}
  5052. @end example
  5053. As an example, the following command builds the latest versions of Emacs
  5054. and of Guile, displays their build logs, and finally displays the
  5055. resulting directories:
  5056. @example
  5057. guix build emacs guile
  5058. @end example
  5059. Similarly, the following command builds all the available packages:
  5060. @example
  5061. guix build --quiet --keep-going \
  5062. `guix package -A | cut -f1,2 --output-delimiter=@@`
  5063. @end example
  5064. @var{package-or-derivation} may be either the name of a package found in
  5065. the software distribution such as @code{coreutils} or
  5066. @code{coreutils@@8.20}, or a derivation such as
  5067. @file{/gnu/store/@dots{}-coreutils-8.19.drv}. In the former case, a
  5068. package with the corresponding name (and optionally version) is searched
  5069. for among the GNU distribution modules (@pxref{Package Modules}).
  5070. Alternatively, the @code{--expression} option may be used to specify a
  5071. Scheme expression that evaluates to a package; this is useful when
  5072. disambiguating among several same-named packages or package variants is
  5073. needed.
  5074. There may be zero or more @var{options}. The available options are
  5075. described in the subsections below.
  5076. @menu
  5077. * Common Build Options:: Build options for most commands.
  5078. * Package Transformation Options:: Creating variants of packages.
  5079. * Additional Build Options:: Options specific to 'guix build'.
  5080. * Debugging Build Failures:: Real life packaging experience.
  5081. @end menu
  5082. @node Common Build Options
  5083. @subsection Common Build Options
  5084. A number of options that control the build process are common to
  5085. @command{guix build} and other commands that can spawn builds, such as
  5086. @command{guix package} or @command{guix archive}. These are the
  5087. following:
  5088. @table @code
  5089. @item --load-path=@var{directory}
  5090. @itemx -L @var{directory}
  5091. Add @var{directory} to the front of the package module search path
  5092. (@pxref{Package Modules}).
  5093. This allows users to define their own packages and make them visible to
  5094. the command-line tools.
  5095. @item --keep-failed
  5096. @itemx -K
  5097. Keep the build tree of failed builds. Thus, if a build fails, its build
  5098. tree is kept under @file{/tmp}, in a directory whose name is shown at
  5099. the end of the build log. This is useful when debugging build issues.
  5100. @xref{Debugging Build Failures}, for tips and tricks on how to debug
  5101. build issues.
  5102. This option has no effect when connecting to a remote daemon with a
  5103. @code{guix://} URI (@pxref{The Store, the @code{GUIX_DAEMON_SOCKET}
  5104. variable}).
  5105. @item --keep-going
  5106. @itemx -k
  5107. Keep going when some of the derivations fail to build; return only once
  5108. all the builds have either completed or failed.
  5109. The default behavior is to stop as soon as one of the specified
  5110. derivations has failed.
  5111. @item --dry-run
  5112. @itemx -n
  5113. Do not build the derivations.
  5114. @anchor{fallback-option}
  5115. @item --fallback
  5116. When substituting a pre-built binary fails, fall back to building
  5117. packages locally (@pxref{Substitution Failure}).
  5118. @item --substitute-urls=@var{urls}
  5119. @anchor{client-substitute-urls}
  5120. Consider @var{urls} the whitespace-separated list of substitute source
  5121. URLs, overriding the default list of URLs of @command{guix-daemon}
  5122. (@pxref{daemon-substitute-urls,, @command{guix-daemon} URLs}).
  5123. This means that substitutes may be downloaded from @var{urls}, provided
  5124. they are signed by a key authorized by the system administrator
  5125. (@pxref{Substitutes}).
  5126. When @var{urls} is the empty string, substitutes are effectively
  5127. disabled.
  5128. @item --no-substitutes
  5129. Do not use substitutes for build products. That is, always build things
  5130. locally instead of allowing downloads of pre-built binaries
  5131. (@pxref{Substitutes}).
  5132. @item --no-grafts
  5133. Do not ``graft'' packages. In practice, this means that package updates
  5134. available as grafts are not applied. @xref{Security Updates}, for more
  5135. information on grafts.
  5136. @item --rounds=@var{n}
  5137. Build each derivation @var{n} times in a row, and raise an error if
  5138. consecutive build results are not bit-for-bit identical.
  5139. This is a useful way to detect non-deterministic builds processes.
  5140. Non-deterministic build processes are a problem because they make it
  5141. practically impossible for users to @emph{verify} whether third-party
  5142. binaries are genuine. @xref{Invoking guix challenge}, for more.
  5143. Note that, currently, the differing build results are not kept around,
  5144. so you will have to manually investigate in case of an error---e.g., by
  5145. stashing one of the build results with @code{guix archive --export}
  5146. (@pxref{Invoking guix archive}), then rebuilding, and finally comparing
  5147. the two results.
  5148. @item --no-build-hook
  5149. Do not attempt to offload builds @i{via} the ``build hook'' of the daemon
  5150. (@pxref{Daemon Offload Setup}). That is, always build things locally
  5151. instead of offloading builds to remote machines.
  5152. @item --max-silent-time=@var{seconds}
  5153. When the build or substitution process remains silent for more than
  5154. @var{seconds}, terminate it and report a build failure.
  5155. By default, the daemon's setting is honored (@pxref{Invoking
  5156. guix-daemon, @code{--max-silent-time}}).
  5157. @item --timeout=@var{seconds}
  5158. Likewise, when the build or substitution process lasts for more than
  5159. @var{seconds}, terminate it and report a build failure.
  5160. By default, the daemon's setting is honored (@pxref{Invoking
  5161. guix-daemon, @code{--timeout}}).
  5162. @item --verbosity=@var{level}
  5163. Use the given verbosity level. @var{level} must be an integer between 0
  5164. and 5; higher means more verbose output. Setting a level of 4 or more
  5165. may be helpful when debugging setup issues with the build daemon.
  5166. @item --cores=@var{n}
  5167. @itemx -c @var{n}
  5168. Allow the use of up to @var{n} CPU cores for the build. The special
  5169. value @code{0} means to use as many CPU cores as available.
  5170. @item --max-jobs=@var{n}
  5171. @itemx -M @var{n}
  5172. Allow at most @var{n} build jobs in parallel. @xref{Invoking
  5173. guix-daemon, @code{--max-jobs}}, for details about this option and the
  5174. equivalent @command{guix-daemon} option.
  5175. @end table
  5176. Behind the scenes, @command{guix build} is essentially an interface to
  5177. the @code{package-derivation} procedure of the @code{(guix packages)}
  5178. module, and to the @code{build-derivations} procedure of the @code{(guix
  5179. derivations)} module.
  5180. In addition to options explicitly passed on the command line,
  5181. @command{guix build} and other @command{guix} commands that support
  5182. building honor the @code{GUIX_BUILD_OPTIONS} environment variable.
  5183. @defvr {Environment Variable} GUIX_BUILD_OPTIONS
  5184. Users can define this variable to a list of command line options that
  5185. will automatically be used by @command{guix build} and other
  5186. @command{guix} commands that can perform builds, as in the example
  5187. below:
  5188. @example
  5189. $ export GUIX_BUILD_OPTIONS="--no-substitutes -c 2 -L /foo/bar"
  5190. @end example
  5191. These options are parsed independently, and the result is appended to
  5192. the parsed command-line options.
  5193. @end defvr
  5194. @node Package Transformation Options
  5195. @subsection Package Transformation Options
  5196. @cindex package variants
  5197. Another set of command-line options supported by @command{guix build}
  5198. and also @command{guix package} are @dfn{package transformation
  5199. options}. These are options that make it possible to define @dfn{package
  5200. variants}---for instance, packages built from different source code.
  5201. This is a convenient way to create customized packages on the fly
  5202. without having to type in the definitions of package variants
  5203. (@pxref{Defining Packages}).
  5204. @table @code
  5205. @item --with-source=@var{source}
  5206. @itemx --with-source=@var{package}=@var{source}
  5207. @itemx --with-source=@var{package}@@@var{version}=@var{source}
  5208. Use @var{source} as the source of @var{package}, and @var{version} as
  5209. its version number.
  5210. @var{source} must be a file name or a URL, as for @command{guix
  5211. download} (@pxref{Invoking guix download}).
  5212. When @var{package} is omitted,
  5213. it is taken to be the package name specified on the
  5214. command line that matches the base of @var{source}---e.g.,
  5215. if @var{source} is @code{/src/guile-2.0.10.tar.gz}, the corresponding
  5216. package is @code{guile}.
  5217. Likewise, when @var{version} is omitted, the version string is inferred from
  5218. @var{source}; in the previous example, it is @code{2.0.10}.
  5219. This option allows users to try out versions of packages other than the
  5220. one provided by the distribution. The example below downloads
  5221. @file{ed-1.7.tar.gz} from a GNU mirror and uses that as the source for
  5222. the @code{ed} package:
  5223. @example
  5224. guix build ed --with-source=mirror://gnu/ed/ed-1.7.tar.gz
  5225. @end example
  5226. As a developer, @code{--with-source} makes it easy to test release
  5227. candidates:
  5228. @example
  5229. guix build guile --with-source=../guile-2.0.9.219-e1bb7.tar.xz
  5230. @end example
  5231. @dots{} or to build from a checkout in a pristine environment:
  5232. @example
  5233. $ git clone git://git.sv.gnu.org/guix.git
  5234. $ guix build guix --with-source=guix@@1.0=./guix
  5235. @end example
  5236. @item --with-input=@var{package}=@var{replacement}
  5237. Replace dependency on @var{package} by a dependency on
  5238. @var{replacement}. @var{package} must be a package name, and
  5239. @var{replacement} must be a package specification such as @code{guile}
  5240. or @code{guile@@1.8}.
  5241. For instance, the following command builds Guix, but replaces its
  5242. dependency on the current stable version of Guile with a dependency on
  5243. the legacy version of Guile, @code{guile@@2.0}:
  5244. @example
  5245. guix build --with-input=guile=guile@@2.0 guix
  5246. @end example
  5247. This is a recursive, deep replacement. So in this example, both
  5248. @code{guix} and its dependency @code{guile-json} (which also depends on
  5249. @code{guile}) get rebuilt against @code{guile@@2.0}.
  5250. This is implemented using the @code{package-input-rewriting} Scheme
  5251. procedure (@pxref{Defining Packages, @code{package-input-rewriting}}).
  5252. @item --with-graft=@var{package}=@var{replacement}
  5253. This is similar to @code{--with-input} but with an important difference:
  5254. instead of rebuilding the whole dependency chain, @var{replacement} is
  5255. built and then @dfn{grafted} onto the binaries that were initially
  5256. referring to @var{package}. @xref{Security Updates}, for more
  5257. information on grafts.
  5258. For example, the command below grafts version 3.5.4 of GnuTLS onto Wget
  5259. and all its dependencies, replacing references to the version of GnuTLS
  5260. they currently refer to:
  5261. @example
  5262. guix build --with-graft=gnutls=gnutls@@3.5.4 wget
  5263. @end example
  5264. This has the advantage of being much faster than rebuilding everything.
  5265. But there is a caveat: it works if and only if @var{package} and
  5266. @var{replacement} are strictly compatible---for example, if they provide
  5267. a library, the application binary interface (ABI) of those libraries
  5268. must be compatible. If @var{replacement} is somehow incompatible with
  5269. @var{package}, then the resulting package may be unusable. Use with
  5270. care!
  5271. @item --with-branch=@var{package}=@var{branch}
  5272. @cindex Git, using the latest commit
  5273. @cindex latest commit, building
  5274. Build @var{package} from the latest commit of @var{branch}. The @code{source}
  5275. field of @var{package} must be an origin with the @code{git-fetch} method
  5276. (@pxref{origin Reference}) or a @code{git-checkout} object; the repository URL
  5277. is taken from that @code{source}.
  5278. For instance, the following command builds @code{guile-sqlite3} from the
  5279. latest commit of its @code{master} branch, and then builds @code{guix} (which
  5280. depends on it) and @code{cuirass} (which depends on @code{guix}) against this
  5281. specific @code{guile-sqlite3} build:
  5282. @example
  5283. guix build --with-branch=guile-sqlite3=master cuirass
  5284. @end example
  5285. @cindex continuous integration
  5286. Obviously, since it uses the latest commit of the given branch, the result of
  5287. such a command varies over time. Nevertheless it is a convenient way to
  5288. rebuild entire software stacks against the latest commit of one or more
  5289. packages. This is particularly useful in the context of continuous
  5290. integration (CI).
  5291. Checkouts are kept in a cache under @file{~/.cache/guix/checkouts} to speed up
  5292. consecutive accesses to the same repository. You may want to clean it up once
  5293. in a while to save disk space.
  5294. @item --with-commit=@var{package}=@var{commit}
  5295. This is similar to @code{--with-branch}, except that it builds from
  5296. @var{commit} rather than the tip of a branch. @var{commit} must be a valid
  5297. Git commit SHA1 identifier.
  5298. @end table
  5299. @node Additional Build Options
  5300. @subsection Additional Build Options
  5301. The command-line options presented below are specific to @command{guix
  5302. build}.
  5303. @table @code
  5304. @item --quiet
  5305. @itemx -q
  5306. Build quietly, without displaying the build log. Upon completion, the
  5307. build log is kept in @file{/var} (or similar) and can always be
  5308. retrieved using the @option{--log-file} option.
  5309. @item --file=@var{file}
  5310. @itemx -f @var{file}
  5311. Build the package, derivation, or other file-like object that the code within
  5312. @var{file} evaluates to (@pxref{G-Expressions, file-like objects}).
  5313. As an example, @var{file} might contain a package definition like this
  5314. (@pxref{Defining Packages}):
  5315. @example
  5316. @verbatiminclude package-hello.scm
  5317. @end example
  5318. @item --expression=@var{expr}
  5319. @itemx -e @var{expr}
  5320. Build the package or derivation @var{expr} evaluates to.
  5321. For example, @var{expr} may be @code{(@@ (gnu packages guile)
  5322. guile-1.8)}, which unambiguously designates this specific variant of
  5323. version 1.8 of Guile.
  5324. Alternatively, @var{expr} may be a G-expression, in which case it is used
  5325. as a build program passed to @code{gexp->derivation}
  5326. (@pxref{G-Expressions}).
  5327. Lastly, @var{expr} may refer to a zero-argument monadic procedure
  5328. (@pxref{The Store Monad}). The procedure must return a derivation as a
  5329. monadic value, which is then passed through @code{run-with-store}.
  5330. @item --source
  5331. @itemx -S
  5332. Build the source derivations of the packages, rather than the packages
  5333. themselves.
  5334. For instance, @code{guix build -S gcc} returns something like
  5335. @file{/gnu/store/@dots{}-gcc-4.7.2.tar.bz2}, which is the GCC
  5336. source tarball.
  5337. The returned source tarball is the result of applying any patches and
  5338. code snippets specified in the package @code{origin} (@pxref{Defining
  5339. Packages}).
  5340. @item --sources
  5341. Fetch and return the source of @var{package-or-derivation} and all their
  5342. dependencies, recursively. This is a handy way to obtain a local copy
  5343. of all the source code needed to build @var{packages}, allowing you to
  5344. eventually build them even without network access. It is an extension
  5345. of the @code{--source} option and can accept one of the following
  5346. optional argument values:
  5347. @table @code
  5348. @item package
  5349. This value causes the @code{--sources} option to behave in the same way
  5350. as the @code{--source} option.
  5351. @item all
  5352. Build the source derivations of all packages, including any source that
  5353. might be listed as @code{inputs}. This is the default value.
  5354. @example
  5355. $ guix build --sources tzdata
  5356. The following derivations will be built:
  5357. /gnu/store/@dots{}-tzdata2015b.tar.gz.drv
  5358. /gnu/store/@dots{}-tzcode2015b.tar.gz.drv
  5359. @end example
  5360. @item transitive
  5361. Build the source derivations of all packages, as well of all transitive
  5362. inputs to the packages. This can be used e.g.@: to
  5363. prefetch package source for later offline building.
  5364. @example
  5365. $ guix build --sources=transitive tzdata
  5366. The following derivations will be built:
  5367. /gnu/store/@dots{}-tzcode2015b.tar.gz.drv
  5368. /gnu/store/@dots{}-findutils-4.4.2.tar.xz.drv
  5369. /gnu/store/@dots{}-grep-2.21.tar.xz.drv
  5370. /gnu/store/@dots{}-coreutils-8.23.tar.xz.drv
  5371. /gnu/store/@dots{}-make-4.1.tar.xz.drv
  5372. /gnu/store/@dots{}-bash-4.3.tar.xz.drv
  5373. @dots{}
  5374. @end example
  5375. @end table
  5376. @item --system=@var{system}
  5377. @itemx -s @var{system}
  5378. Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
  5379. the system type of the build host.
  5380. @quotation Note
  5381. The @code{--system} flag is for @emph{native} compilation and must not
  5382. be confused with cross-compilation. See @code{--target} below for
  5383. information on cross-compilation.
  5384. @end quotation
  5385. An example use of this is on Linux-based systems, which can emulate
  5386. different personalities. For instance, passing
  5387. @code{--system=i686-linux} on an @code{x86_64-linux} system or
  5388. @code{--system=armhf-linux} on an @code{aarch64-linux} system allows you
  5389. to build packages in a complete 32-bit environment.
  5390. @quotation Note
  5391. Building for an @code{armhf-linux} system is unconditionally enabled on
  5392. @code{aarch64-linux} machines, although certain aarch64 chipsets do not
  5393. allow for this functionality, notably the ThunderX.
  5394. @end quotation
  5395. Similarly, when transparent emulation with QEMU and @code{binfmt_misc}
  5396. is enabled (@pxref{Virtualization Services,
  5397. @code{qemu-binfmt-service-type}}), you can build for any system for
  5398. which a QEMU @code{binfmt_misc} handler is installed.
  5399. Builds for a system other than that of the machine you are using can
  5400. also be offloaded to a remote machine of the right architecture.
  5401. @xref{Daemon Offload Setup}, for more information on offloading.
  5402. @item --target=@var{triplet}
  5403. @cindex cross-compilation
  5404. Cross-build for @var{triplet}, which must be a valid GNU triplet, such
  5405. as @code{"mips64el-linux-gnu"} (@pxref{Specifying target triplets, GNU
  5406. configuration triplets,, autoconf, Autoconf}).
  5407. @anchor{build-check}
  5408. @item --check
  5409. @cindex determinism, checking
  5410. @cindex reproducibility, checking
  5411. Rebuild @var{package-or-derivation}, which are already available in the
  5412. store, and raise an error if the build results are not bit-for-bit
  5413. identical.
  5414. This mechanism allows you to check whether previously installed
  5415. substitutes are genuine (@pxref{Substitutes}), or whether the build result
  5416. of a package is deterministic. @xref{Invoking guix challenge}, for more
  5417. background information and tools.
  5418. When used in conjunction with @option{--keep-failed}, the differing
  5419. output is kept in the store, under @file{/gnu/store/@dots{}-check}.
  5420. This makes it easy to look for differences between the two results.
  5421. @item --repair
  5422. @cindex repairing store items
  5423. @cindex corruption, recovering from
  5424. Attempt to repair the specified store items, if they are corrupt, by
  5425. re-downloading or rebuilding them.
  5426. This operation is not atomic and thus restricted to @code{root}.
  5427. @item --derivations
  5428. @itemx -d
  5429. Return the derivation paths, not the output paths, of the given
  5430. packages.
  5431. @item --root=@var{file}
  5432. @itemx -r @var{file}
  5433. @cindex GC roots, adding
  5434. @cindex garbage collector roots, adding
  5435. Make @var{file} a symlink to the result, and register it as a garbage
  5436. collector root.
  5437. Consequently, the results of this @command{guix build} invocation are
  5438. protected from garbage collection until @var{file} is removed. When
  5439. that option is omitted, build results are eligible for garbage
  5440. collection as soon as the build completes. @xref{Invoking guix gc}, for
  5441. more on GC roots.
  5442. @item --log-file
  5443. @cindex build logs, access
  5444. Return the build log file names or URLs for the given
  5445. @var{package-or-derivation}, or raise an error if build logs are
  5446. missing.
  5447. This works regardless of how packages or derivations are specified. For
  5448. instance, the following invocations are equivalent:
  5449. @example
  5450. guix build --log-file `guix build -d guile`
  5451. guix build --log-file `guix build guile`
  5452. guix build --log-file guile
  5453. guix build --log-file -e '(@@ (gnu packages guile) guile-2.0)'
  5454. @end example
  5455. If a log is unavailable locally, and unless @code{--no-substitutes} is
  5456. passed, the command looks for a corresponding log on one of the
  5457. substitute servers (as specified with @code{--substitute-urls}.)
  5458. So for instance, imagine you want to see the build log of GDB on MIPS,
  5459. but you are actually on an @code{x86_64} machine:
  5460. @example
  5461. $ guix build --log-file gdb -s mips64el-linux
  5462. https://@value{SUBSTITUTE-SERVER}/log/@dots{}-gdb-7.10
  5463. @end example
  5464. You can freely access a huge library of build logs!
  5465. @end table
  5466. @node Debugging Build Failures
  5467. @subsection Debugging Build Failures
  5468. @cindex build failures, debugging
  5469. When defining a new package (@pxref{Defining Packages}), you will
  5470. probably find yourself spending some time debugging and tweaking the
  5471. build until it succeeds. To do that, you need to operate the build
  5472. commands yourself in an environment as close as possible to the one the
  5473. build daemon uses.
  5474. To that end, the first thing to do is to use the @option{--keep-failed}
  5475. or @option{-K} option of @command{guix build}, which will keep the
  5476. failed build tree in @file{/tmp} or whatever directory you specified as
  5477. @code{TMPDIR} (@pxref{Invoking guix build, @code{--keep-failed}}).
  5478. From there on, you can @command{cd} to the failed build tree and source
  5479. the @file{environment-variables} file, which contains all the
  5480. environment variable definitions that were in place when the build
  5481. failed. So let's say you're debugging a build failure in package
  5482. @code{foo}; a typical session would look like this:
  5483. @example
  5484. $ guix build foo -K
  5485. @dots{} @i{build fails}
  5486. $ cd /tmp/guix-build-foo.drv-0
  5487. $ source ./environment-variables
  5488. $ cd foo-1.2
  5489. @end example
  5490. Now, you can invoke commands as if you were the daemon (almost) and
  5491. troubleshoot your build process.
  5492. Sometimes it happens that, for example, a package's tests pass when you
  5493. run them manually but they fail when the daemon runs them. This can
  5494. happen because the daemon runs builds in containers where, unlike in our
  5495. environment above, network access is missing, @file{/bin/sh} does not
  5496. exist, etc. (@pxref{Build Environment Setup}).
  5497. In such cases, you may need to run inspect the build process from within
  5498. a container similar to the one the build daemon creates:
  5499. @example
  5500. $ guix build -K foo
  5501. @dots{}
  5502. $ cd /tmp/guix-build-foo.drv-0
  5503. $ guix environment --no-grafts -C foo --ad-hoc strace gdb
  5504. [env]# source ./environment-variables
  5505. [env]# cd foo-1.2
  5506. @end example
  5507. Here, @command{guix environment -C} creates a container and spawns a new
  5508. shell in it (@pxref{Invoking guix environment}). The @command{--ad-hoc
  5509. strace gdb} part adds the @command{strace} and @command{gdb} commands to
  5510. the container, which would may find handy while debugging. The
  5511. @option{--no-grafts} option makes sure we get the exact same
  5512. environment, with ungrafted packages (@pxref{Security Updates}, for more
  5513. info on grafts).
  5514. To get closer to a container like that used by the build daemon, we can
  5515. remove @file{/bin/sh}:
  5516. @example
  5517. [env]# rm /bin/sh
  5518. @end example
  5519. (Don't worry, this is harmless: this is all happening in the throw-away
  5520. container created by @command{guix environment}.)
  5521. The @command{strace} command is probably not in the search path, but we
  5522. can run:
  5523. @example
  5524. [env]# $GUIX_ENVIRONMENT/bin/strace -f -o log make check
  5525. @end example
  5526. In this way, not only you will have reproduced the environment variables
  5527. the daemon uses, you will also be running the build process in a container
  5528. similar to the one the daemon uses.
  5529. @node Invoking guix edit
  5530. @section Invoking @command{guix edit}
  5531. @cindex @command{guix edit}
  5532. @cindex package definition, editing
  5533. So many packages, so many source files! The @command{guix edit} command
  5534. facilitates the life of users and packagers by pointing their editor at
  5535. the source file containing the definition of the specified packages.
  5536. For instance:
  5537. @example
  5538. guix edit gcc@@4.9 vim
  5539. @end example
  5540. @noindent
  5541. launches the program specified in the @code{VISUAL} or in the
  5542. @code{EDITOR} environment variable to view the recipe of GCC@tie{}4.9.3
  5543. and that of Vim.
  5544. If you are using a Guix Git checkout (@pxref{Building from Git}), or
  5545. have created your own packages on @code{GUIX_PACKAGE_PATH}
  5546. (@pxref{Package Modules}), you will be able to edit the package
  5547. recipes. In other cases, you will be able to examine the read-only recipes
  5548. for packages currently in the store.
  5549. @node Invoking guix download
  5550. @section Invoking @command{guix download}
  5551. @cindex @command{guix download}
  5552. @cindex downloading package sources
  5553. When writing a package definition, developers typically need to download
  5554. a source tarball, compute its SHA256 hash, and write that
  5555. hash in the package definition (@pxref{Defining Packages}). The
  5556. @command{guix download} tool helps with this task: it downloads a file
  5557. from the given URI, adds it to the store, and prints both its file name
  5558. in the store and its SHA256 hash.
  5559. The fact that the downloaded file is added to the store saves bandwidth:
  5560. when the developer eventually tries to build the newly defined package
  5561. with @command{guix build}, the source tarball will not have to be
  5562. downloaded again because it is already in the store. It is also a
  5563. convenient way to temporarily stash files, which may be deleted
  5564. eventually (@pxref{Invoking guix gc}).
  5565. The @command{guix download} command supports the same URIs as used in
  5566. package definitions. In particular, it supports @code{mirror://} URIs.
  5567. @code{https} URIs (HTTP over TLS) are supported @emph{provided} the
  5568. Guile bindings for GnuTLS are available in the user's environment; when
  5569. they are not available, an error is raised. @xref{Guile Preparations,
  5570. how to install the GnuTLS bindings for Guile,, gnutls-guile,
  5571. GnuTLS-Guile}, for more information.
  5572. @command{guix download} verifies HTTPS server certificates by loading
  5573. the certificates of X.509 authorities from the directory pointed to by
  5574. the @code{SSL_CERT_DIR} environment variable (@pxref{X.509
  5575. Certificates}), unless @option{--no-check-certificate} is used.
  5576. The following options are available:
  5577. @table @code
  5578. @item --format=@var{fmt}
  5579. @itemx -f @var{fmt}
  5580. Write the hash in the format specified by @var{fmt}. For more
  5581. information on the valid values for @var{fmt}, @pxref{Invoking guix hash}.
  5582. @item --no-check-certificate
  5583. Do not validate the X.509 certificates of HTTPS servers.
  5584. When using this option, you have @emph{absolutely no guarantee} that you
  5585. are communicating with the authentic server responsible for the given
  5586. URL, which makes you vulnerable to ``man-in-the-middle'' attacks.
  5587. @item --output=@var{file}
  5588. @itemx -o @var{file}
  5589. Save the downloaded file to @var{file} instead of adding it to the
  5590. store.
  5591. @end table
  5592. @node Invoking guix hash
  5593. @section Invoking @command{guix hash}
  5594. @cindex @command{guix hash}
  5595. The @command{guix hash} command computes the SHA256 hash of a file.
  5596. It is primarily a convenience tool for anyone contributing to the
  5597. distribution: it computes the cryptographic hash of a file, which can be
  5598. used in the definition of a package (@pxref{Defining Packages}).
  5599. The general syntax is:
  5600. @example
  5601. guix hash @var{option} @var{file}
  5602. @end example
  5603. When @var{file} is @code{-} (a hyphen), @command{guix hash} computes the
  5604. hash of data read from standard input. @command{guix hash} has the
  5605. following options:
  5606. @table @code
  5607. @item --format=@var{fmt}
  5608. @itemx -f @var{fmt}
  5609. Write the hash in the format specified by @var{fmt}.
  5610. Supported formats: @code{nix-base32}, @code{base32}, @code{base16}
  5611. (@code{hex} and @code{hexadecimal} can be used as well).
  5612. If the @option{--format} option is not specified, @command{guix hash}
  5613. will output the hash in @code{nix-base32}. This representation is used
  5614. in the definitions of packages.
  5615. @item --recursive
  5616. @itemx -r
  5617. Compute the hash on @var{file} recursively.
  5618. In this case, the hash is computed on an archive containing @var{file},
  5619. including its children if it is a directory. Some of the metadata of
  5620. @var{file} is part of the archive; for instance, when @var{file} is a
  5621. regular file, the hash is different depending on whether @var{file} is
  5622. executable or not. Metadata such as time stamps has no impact on the
  5623. hash (@pxref{Invoking guix archive}).
  5624. @c FIXME: Replace xref above with xref to an ``Archive'' section when
  5625. @c it exists.
  5626. @item --exclude-vcs
  5627. @itemx -x
  5628. When combined with @option{--recursive}, exclude version control system
  5629. directories (@file{.bzr}, @file{.git}, @file{.hg}, etc.)
  5630. @vindex git-fetch
  5631. As an example, here is how you would compute the hash of a Git checkout,
  5632. which is useful when using the @code{git-fetch} method (@pxref{origin
  5633. Reference}):
  5634. @example
  5635. $ git clone http://example.org/foo.git
  5636. $ cd foo
  5637. $ guix hash -rx .
  5638. @end example
  5639. @end table
  5640. @node Invoking guix import
  5641. @section Invoking @command{guix import}
  5642. @cindex importing packages
  5643. @cindex package import
  5644. @cindex package conversion
  5645. @cindex Invoking @command{guix import}
  5646. The @command{guix import} command is useful for people who would like to
  5647. add a package to the distribution with as little work as
  5648. possible---a legitimate demand. The command knows of a few
  5649. repositories from which it can ``import'' package metadata. The result
  5650. is a package definition, or a template thereof, in the format we know
  5651. (@pxref{Defining Packages}).
  5652. The general syntax is:
  5653. @example
  5654. guix import @var{importer} @var{options}@dots{}
  5655. @end example
  5656. @var{importer} specifies the source from which to import package
  5657. metadata, and @var{options} specifies a package identifier and other
  5658. options specific to @var{importer}. Currently, the available
  5659. ``importers'' are:
  5660. @table @code
  5661. @item gnu
  5662. Import metadata for the given GNU package. This provides a template
  5663. for the latest version of that GNU package, including the hash of its
  5664. source tarball, and its canonical synopsis and description.
  5665. Additional information such as the package dependencies and its
  5666. license needs to be figured out manually.
  5667. For example, the following command returns a package definition for
  5668. GNU@tie{}Hello:
  5669. @example
  5670. guix import gnu hello
  5671. @end example
  5672. Specific command-line options are:
  5673. @table @code
  5674. @item --key-download=@var{policy}
  5675. As for @code{guix refresh}, specify the policy to handle missing OpenPGP
  5676. keys when verifying the package signature. @xref{Invoking guix
  5677. refresh, @code{--key-download}}.
  5678. @end table
  5679. @item pypi
  5680. @cindex pypi
  5681. Import metadata from the @uref{https://pypi.python.org/, Python Package
  5682. Index}. Information is taken from the JSON-formatted description
  5683. available at @code{pypi.python.org} and usually includes all the relevant
  5684. information, including package dependencies. For maximum efficiency, it
  5685. is recommended to install the @command{unzip} utility, so that the
  5686. importer can unzip Python wheels and gather data from them.
  5687. The command below imports metadata for the @code{itsdangerous} Python
  5688. package:
  5689. @example
  5690. guix import pypi itsdangerous
  5691. @end example
  5692. @table @code
  5693. @item --recursive
  5694. @itemx -r
  5695. Traverse the dependency graph of the given upstream package recursively
  5696. and generate package expressions for all those packages that are not yet
  5697. in Guix.
  5698. @end table
  5699. @item gem
  5700. @cindex gem
  5701. Import metadata from @uref{https://rubygems.org/, RubyGems}. Information
  5702. is taken from the JSON-formatted description available at
  5703. @code{rubygems.org} and includes most relevant information, including
  5704. runtime dependencies. There are some caveats, however. The metadata
  5705. doesn't distinguish between synopses and descriptions, so the same string
  5706. is used for both fields. Additionally, the details of non-Ruby
  5707. dependencies required to build native extensions is unavailable and left
  5708. as an exercise to the packager.
  5709. The command below imports metadata for the @code{rails} Ruby package:
  5710. @example
  5711. guix import gem rails
  5712. @end example
  5713. @table @code
  5714. @item --recursive
  5715. @itemx -r
  5716. Traverse the dependency graph of the given upstream package recursively
  5717. and generate package expressions for all those packages that are not yet
  5718. in Guix.
  5719. @end table
  5720. @item cpan
  5721. @cindex CPAN
  5722. Import metadata from @uref{https://www.metacpan.org/, MetaCPAN}.
  5723. Information is taken from the JSON-formatted metadata provided through
  5724. @uref{https://fastapi.metacpan.org/, MetaCPAN's API} and includes most
  5725. relevant information, such as module dependencies. License information
  5726. should be checked closely. If Perl is available in the store, then the
  5727. @code{corelist} utility will be used to filter core modules out of the
  5728. list of dependencies.
  5729. The command command below imports metadata for the @code{Acme::Boolean}
  5730. Perl module:
  5731. @example
  5732. guix import cpan Acme::Boolean
  5733. @end example
  5734. @item cran
  5735. @cindex CRAN
  5736. @cindex Bioconductor
  5737. Import metadata from @uref{https://cran.r-project.org/, CRAN}, the
  5738. central repository for the @uref{http://r-project.org, GNU@tie{}R
  5739. statistical and graphical environment}.
  5740. Information is extracted from the @code{DESCRIPTION} file of the package.
  5741. The command command below imports metadata for the @code{Cairo}
  5742. R package:
  5743. @example
  5744. guix import cran Cairo
  5745. @end example
  5746. When @code{--recursive} is added, the importer will traverse the
  5747. dependency graph of the given upstream package recursively and generate
  5748. package expressions for all those packages that are not yet in Guix.
  5749. When @code{--archive=bioconductor} is added, metadata is imported from
  5750. @uref{https://www.bioconductor.org/, Bioconductor}, a repository of R
  5751. packages for for the analysis and comprehension of high-throughput
  5752. genomic data in bioinformatics.
  5753. Information is extracted from the @code{DESCRIPTION} file of a package
  5754. published on the web interface of the Bioconductor SVN repository.
  5755. The command below imports metadata for the @code{GenomicRanges}
  5756. R package:
  5757. @example
  5758. guix import cran --archive=bioconductor GenomicRanges
  5759. @end example
  5760. @item texlive
  5761. @cindex TeX Live
  5762. @cindex CTAN
  5763. Import metadata from @uref{http://www.ctan.org/, CTAN}, the
  5764. comprehensive TeX archive network for TeX packages that are part of the
  5765. @uref{https://www.tug.org/texlive/, TeX Live distribution}.
  5766. Information about the package is obtained through the XML API provided
  5767. by CTAN, while the source code is downloaded from the SVN repository of
  5768. the Tex Live project. This is done because the CTAN does not keep
  5769. versioned archives.
  5770. The command command below imports metadata for the @code{fontspec}
  5771. TeX package:
  5772. @example
  5773. guix import texlive fontspec
  5774. @end example
  5775. When @code{--archive=DIRECTORY} is added, the source code is downloaded
  5776. not from the @file{latex} sub-directory of the @file{texmf-dist/source}
  5777. tree in the TeX Live SVN repository, but from the specified sibling
  5778. directory under the same root.
  5779. The command below imports metadata for the @code{ifxetex} package from
  5780. CTAN while fetching the sources from the directory
  5781. @file{texmf/source/generic}:
  5782. @example
  5783. guix import texlive --archive=generic ifxetex
  5784. @end example
  5785. @item json
  5786. @cindex JSON, import
  5787. Import package metadata from a local JSON file. Consider the following
  5788. example package definition in JSON format:
  5789. @example
  5790. @{
  5791. "name": "hello",
  5792. "version": "2.10",
  5793. "source": "mirror://gnu/hello/hello-2.10.tar.gz",
  5794. "build-system": "gnu",
  5795. "home-page": "https://www.gnu.org/software/hello/",
  5796. "synopsis": "Hello, GNU world: An example GNU package",
  5797. "description": "GNU Hello prints a greeting.",
  5798. "license": "GPL-3.0+",
  5799. "native-inputs": ["gcc@@6"]
  5800. @}
  5801. @end example
  5802. The field names are the same as for the @code{<package>} record
  5803. (@xref{Defining Packages}). References to other packages are provided
  5804. as JSON lists of quoted package specification strings such as
  5805. @code{guile} or @code{guile@@2.0}.
  5806. The importer also supports a more explicit source definition using the
  5807. common fields for @code{<origin>} records:
  5808. @example
  5809. @{
  5810. @dots{}
  5811. "source": @{
  5812. "method": "url-fetch",
  5813. "uri": "mirror://gnu/hello/hello-2.10.tar.gz",
  5814. "sha256": @{
  5815. "base32": "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"
  5816. @}
  5817. @}
  5818. @dots{}
  5819. @}
  5820. @end example
  5821. The command below reads metadata from the JSON file @code{hello.json}
  5822. and outputs a package expression:
  5823. @example
  5824. guix import json hello.json
  5825. @end example
  5826. @item nix
  5827. Import metadata from a local copy of the source of the
  5828. @uref{http://nixos.org/nixpkgs/, Nixpkgs distribution}@footnote{This
  5829. relies on the @command{nix-instantiate} command of
  5830. @uref{http://nixos.org/nix/, Nix}.}. Package definitions in Nixpkgs are
  5831. typically written in a mixture of Nix-language and Bash code. This
  5832. command only imports the high-level package structure that is written in
  5833. the Nix language. It normally includes all the basic fields of a
  5834. package definition.
  5835. When importing a GNU package, the synopsis and descriptions are replaced
  5836. by their canonical upstream variant.
  5837. Usually, you will first need to do:
  5838. @example
  5839. export NIX_REMOTE=daemon
  5840. @end example
  5841. @noindent
  5842. so that @command{nix-instantiate} does not try to open the Nix database.
  5843. As an example, the command below imports the package definition of
  5844. LibreOffice (more precisely, it imports the definition of the package
  5845. bound to the @code{libreoffice} top-level attribute):
  5846. @example
  5847. guix import nix ~/path/to/nixpkgs libreoffice
  5848. @end example
  5849. @item hackage
  5850. @cindex hackage
  5851. Import metadata from the Haskell community's central package archive
  5852. @uref{https://hackage.haskell.org/, Hackage}. Information is taken from
  5853. Cabal files and includes all the relevant information, including package
  5854. dependencies.
  5855. Specific command-line options are:
  5856. @table @code
  5857. @item --stdin
  5858. @itemx -s
  5859. Read a Cabal file from standard input.
  5860. @item --no-test-dependencies
  5861. @itemx -t
  5862. Do not include dependencies required only by the test suites.
  5863. @item --cabal-environment=@var{alist}
  5864. @itemx -e @var{alist}
  5865. @var{alist} is a Scheme alist defining the environment in which the
  5866. Cabal conditionals are evaluated. The accepted keys are: @code{os},
  5867. @code{arch}, @code{impl} and a string representing the name of a flag.
  5868. The value associated with a flag has to be either the symbol
  5869. @code{true} or @code{false}. The value associated with other keys
  5870. has to conform to the Cabal file format definition. The default value
  5871. associated with the keys @code{os}, @code{arch} and @code{impl} is
  5872. @samp{linux}, @samp{x86_64} and @samp{ghc}, respectively.
  5873. @item --recursive
  5874. @itemx -r
  5875. Traverse the dependency graph of the given upstream package recursively
  5876. and generate package expressions for all those packages that are not yet
  5877. in Guix.
  5878. @end table
  5879. The command below imports metadata for the latest version of the
  5880. @code{HTTP} Haskell package without including test dependencies and
  5881. specifying the value of the flag @samp{network-uri} as @code{false}:
  5882. @example
  5883. guix import hackage -t -e "'((\"network-uri\" . false))" HTTP
  5884. @end example
  5885. A specific package version may optionally be specified by following the
  5886. package name by an at-sign and a version number as in the following example:
  5887. @example
  5888. guix import hackage mtl@@2.1.3.1
  5889. @end example
  5890. @item stackage
  5891. @cindex stackage
  5892. The @code{stackage} importer is a wrapper around the @code{hackage} one.
  5893. It takes a package name, looks up the package version included in a
  5894. long-term support (LTS) @uref{https://www.stackage.org, Stackage}
  5895. release and uses the @code{hackage} importer to retrieve its metadata.
  5896. Note that it is up to you to select an LTS release compatible with the
  5897. GHC compiler used by Guix.
  5898. Specific command-line options are:
  5899. @table @code
  5900. @item --no-test-dependencies
  5901. @itemx -t
  5902. Do not include dependencies required only by the test suites.
  5903. @item --lts-version=@var{version}
  5904. @itemx -l @var{version}
  5905. @var{version} is the desired LTS release version. If omitted the latest
  5906. release is used.
  5907. @item --recursive
  5908. @itemx -r
  5909. Traverse the dependency graph of the given upstream package recursively
  5910. and generate package expressions for all those packages that are not yet
  5911. in Guix.
  5912. @end table
  5913. The command below imports metadata for the @code{HTTP} Haskell package
  5914. included in the LTS Stackage release version 7.18:
  5915. @example
  5916. guix import stackage --lts-version=7.18 HTTP
  5917. @end example
  5918. @item elpa
  5919. @cindex elpa
  5920. Import metadata from an Emacs Lisp Package Archive (ELPA) package
  5921. repository (@pxref{Packages,,, emacs, The GNU Emacs Manual}).
  5922. Specific command-line options are:
  5923. @table @code
  5924. @item --archive=@var{repo}
  5925. @itemx -a @var{repo}
  5926. @var{repo} identifies the archive repository from which to retrieve the
  5927. information. Currently the supported repositories and their identifiers
  5928. are:
  5929. @itemize -
  5930. @item
  5931. @uref{http://elpa.gnu.org/packages, GNU}, selected by the @code{gnu}
  5932. identifier. This is the default.
  5933. Packages from @code{elpa.gnu.org} are signed with one of the keys
  5934. contained in the GnuPG keyring at
  5935. @file{share/emacs/25.1/etc/package-keyring.gpg} (or similar) in the
  5936. @code{emacs} package (@pxref{Package Installation, ELPA package
  5937. signatures,, emacs, The GNU Emacs Manual}).
  5938. @item
  5939. @uref{http://stable.melpa.org/packages, MELPA-Stable}, selected by the
  5940. @code{melpa-stable} identifier.
  5941. @item
  5942. @uref{http://melpa.org/packages, MELPA}, selected by the @code{melpa}
  5943. identifier.
  5944. @end itemize
  5945. @item --recursive
  5946. @itemx -r
  5947. Traverse the dependency graph of the given upstream package recursively
  5948. and generate package expressions for all those packages that are not yet
  5949. in Guix.
  5950. @end table
  5951. @item crate
  5952. @cindex crate
  5953. Import metadata from the crates.io Rust package repository
  5954. @uref{https://crates.io, crates.io}.
  5955. @item opam
  5956. @cindex OPAM
  5957. @cindex OCaml
  5958. Import metadata from the @uref{https://opam.ocaml.org/, OPAM} package
  5959. repository used by the OCaml community.
  5960. @end table
  5961. The structure of the @command{guix import} code is modular. It would be
  5962. useful to have more importers for other package formats, and your help
  5963. is welcome here (@pxref{Contributing}).
  5964. @node Invoking guix refresh
  5965. @section Invoking @command{guix refresh}
  5966. @cindex @command {guix refresh}
  5967. The primary audience of the @command{guix refresh} command is developers
  5968. of the GNU software distribution. By default, it reports any packages
  5969. provided by the distribution that are outdated compared to the latest
  5970. upstream version, like this:
  5971. @example
  5972. $ guix refresh
  5973. gnu/packages/gettext.scm:29:13: gettext would be upgraded from 0.18.1.1 to 0.18.2.1
  5974. gnu/packages/glib.scm:77:12: glib would be upgraded from 2.34.3 to 2.37.0
  5975. @end example
  5976. Alternately, one can specify packages to consider, in which case a
  5977. warning is emitted for packages that lack an updater:
  5978. @example
  5979. $ guix refresh coreutils guile guile-ssh
  5980. gnu/packages/ssh.scm:205:2: warning: no updater for guile-ssh
  5981. gnu/packages/guile.scm:136:12: guile would be upgraded from 2.0.12 to 2.0.13
  5982. @end example
  5983. @command{guix refresh} browses the upstream repository of each package and determines
  5984. the highest version number of the releases therein. The command
  5985. knows how to update specific types of packages: GNU packages, ELPA
  5986. packages, etc.---see the documentation for @option{--type} below. There
  5987. are many packages, though, for which it lacks a method to determine
  5988. whether a new upstream release is available. However, the mechanism is
  5989. extensible, so feel free to get in touch with us to add a new method!
  5990. Sometimes the upstream name differs from the package name used in Guix,
  5991. and @command{guix refresh} needs a little help. Most updaters honor the
  5992. @code{upstream-name} property in package definitions, which can be used
  5993. to that effect:
  5994. @example
  5995. (define-public network-manager
  5996. (package
  5997. (name "network-manager")
  5998. ;; @dots{}
  5999. (properties '((upstream-name . "NetworkManager")))))
  6000. @end example
  6001. When passed @code{--update}, it modifies distribution source files to
  6002. update the version numbers and source tarball hashes of those package
  6003. recipes (@pxref{Defining Packages}). This is achieved by downloading
  6004. each package's latest source tarball and its associated OpenPGP
  6005. signature, authenticating the downloaded tarball against its signature
  6006. using @command{gpg}, and finally computing its hash. When the public
  6007. key used to sign the tarball is missing from the user's keyring, an
  6008. attempt is made to automatically retrieve it from a public key server;
  6009. when this is successful, the key is added to the user's keyring; otherwise,
  6010. @command{guix refresh} reports an error.
  6011. The following options are supported:
  6012. @table @code
  6013. @item --expression=@var{expr}
  6014. @itemx -e @var{expr}
  6015. Consider the package @var{expr} evaluates to.
  6016. This is useful to precisely refer to a package, as in this example:
  6017. @example
  6018. guix refresh -l -e '(@@@@ (gnu packages commencement) glibc-final)'
  6019. @end example
  6020. This command lists the dependents of the ``final'' libc (essentially all
  6021. the packages.)
  6022. @item --update
  6023. @itemx -u
  6024. Update distribution source files (package recipes) in place. This is
  6025. usually run from a checkout of the Guix source tree (@pxref{Running
  6026. Guix Before It Is Installed}):
  6027. @example
  6028. $ ./pre-inst-env guix refresh -s non-core -u
  6029. @end example
  6030. @xref{Defining Packages}, for more information on package definitions.
  6031. @item --select=[@var{subset}]
  6032. @itemx -s @var{subset}
  6033. Select all the packages in @var{subset}, one of @code{core} or
  6034. @code{non-core}.
  6035. The @code{core} subset refers to all the packages at the core of the
  6036. distribution---i.e., packages that are used to build ``everything
  6037. else''. This includes GCC, libc, Binutils, Bash, etc. Usually,
  6038. changing one of these packages in the distribution entails a rebuild of
  6039. all the others. Thus, such updates are an inconvenience to users in
  6040. terms of build time or bandwidth used to achieve the upgrade.
  6041. The @code{non-core} subset refers to the remaining packages. It is
  6042. typically useful in cases where an update of the core packages would be
  6043. inconvenient.
  6044. @item --manifest=@var{file}
  6045. @itemx -m @var{file}
  6046. Select all the packages from the manifest in @var{file}. This is useful to
  6047. check if any packages of the user manifest can be updated.
  6048. @item --type=@var{updater}
  6049. @itemx -t @var{updater}
  6050. Select only packages handled by @var{updater} (may be a comma-separated
  6051. list of updaters). Currently, @var{updater} may be one of:
  6052. @table @code
  6053. @item gnu
  6054. the updater for GNU packages;
  6055. @item gnome
  6056. the updater for GNOME packages;
  6057. @item kde
  6058. the updater for KDE packages;
  6059. @item xorg
  6060. the updater for X.org packages;
  6061. @item kernel.org
  6062. the updater for packages hosted on kernel.org;
  6063. @item elpa
  6064. the updater for @uref{http://elpa.gnu.org/, ELPA} packages;
  6065. @item cran
  6066. the updater for @uref{https://cran.r-project.org/, CRAN} packages;
  6067. @item bioconductor
  6068. the updater for @uref{https://www.bioconductor.org/, Bioconductor} R packages;
  6069. @item cpan
  6070. the updater for @uref{http://www.cpan.org/, CPAN} packages;
  6071. @item pypi
  6072. the updater for @uref{https://pypi.python.org, PyPI} packages.
  6073. @item gem
  6074. the updater for @uref{https://rubygems.org, RubyGems} packages.
  6075. @item github
  6076. the updater for @uref{https://github.com, GitHub} packages.
  6077. @item hackage
  6078. the updater for @uref{https://hackage.haskell.org, Hackage} packages.
  6079. @item stackage
  6080. the updater for @uref{https://www.stackage.org, Stackage} packages.
  6081. @item crate
  6082. the updater for @uref{https://crates.io, Crates} packages.
  6083. @end table
  6084. For instance, the following command only checks for updates of Emacs
  6085. packages hosted at @code{elpa.gnu.org} and for updates of CRAN packages:
  6086. @example
  6087. $ guix refresh --type=elpa,cran
  6088. gnu/packages/statistics.scm:819:13: r-testthat would be upgraded from 0.10.0 to 0.11.0
  6089. gnu/packages/emacs.scm:856:13: emacs-auctex would be upgraded from 11.88.6 to 11.88.9
  6090. @end example
  6091. @end table
  6092. In addition, @command{guix refresh} can be passed one or more package
  6093. names, as in this example:
  6094. @example
  6095. $ ./pre-inst-env guix refresh -u emacs idutils gcc@@4.8
  6096. @end example
  6097. @noindent
  6098. The command above specifically updates the @code{emacs} and
  6099. @code{idutils} packages. The @code{--select} option would have no
  6100. effect in this case.
  6101. When considering whether to upgrade a package, it is sometimes
  6102. convenient to know which packages would be affected by the upgrade and
  6103. should be checked for compatibility. For this the following option may
  6104. be used when passing @command{guix refresh} one or more package names:
  6105. @table @code
  6106. @item --list-updaters
  6107. @itemx -L
  6108. List available updaters and exit (see @option{--type} above.)
  6109. For each updater, display the fraction of packages it covers; at the
  6110. end, display the fraction of packages covered by all these updaters.
  6111. @item --list-dependent
  6112. @itemx -l
  6113. List top-level dependent packages that would need to be rebuilt as a
  6114. result of upgrading one or more packages.
  6115. @xref{Invoking guix graph, the @code{reverse-package} type of
  6116. @command{guix graph}}, for information on how to visualize the list of
  6117. dependents of a package.
  6118. @end table
  6119. Be aware that the @code{--list-dependent} option only
  6120. @emph{approximates} the rebuilds that would be required as a result of
  6121. an upgrade. More rebuilds might be required under some circumstances.
  6122. @example
  6123. $ guix refresh --list-dependent flex
  6124. Building the following 120 packages would ensure 213 dependent packages are rebuilt:
  6125. hop@@2.4.0 geiser@@0.4 notmuch@@0.18 mu@@0.9.9.5 cflow@@1.4 idutils@@4.6 @dots{}
  6126. @end example
  6127. The command above lists a set of packages that could be built to check
  6128. for compatibility with an upgraded @code{flex} package.
  6129. The following options can be used to customize GnuPG operation:
  6130. @table @code
  6131. @item --gpg=@var{command}
  6132. Use @var{command} as the GnuPG 2.x command. @var{command} is searched
  6133. for in @code{$PATH}.
  6134. @item --keyring=@var{file}
  6135. Use @var{file} as the keyring for upstream keys. @var{file} must be in the
  6136. @dfn{keybox format}. Keybox files usually have a name ending in @file{.kbx}
  6137. and the GNU@tie{}Privacy Guard (GPG) can manipulate these files
  6138. (@pxref{kbxutil, @command{kbxutil},, gnupg, Using the GNU Privacy Guard}, for
  6139. information on a tool to manipulate keybox files).
  6140. When this option is omitted, @command{guix refresh} uses
  6141. @file{~/.config/guix/upstream/trustedkeys.kbx} as the keyring for upstream
  6142. signing keys. OpenPGP signatures are checked against keys from this keyring;
  6143. missing keys are downloaded to this keyring as well (see
  6144. @option{--key-download} below.)
  6145. You can export keys from your default GPG keyring into a keybox file using
  6146. commands like this one:
  6147. @example
  6148. gpg --export rms@@gnu.org | kbxutil --import-openpgp >> mykeyring.kbx
  6149. @end example
  6150. Likewise, you can fetch keys to a specific keybox file like this:
  6151. @example
  6152. gpg --no-default-keyring --keyring mykeyring.kbx \
  6153. --recv-keys @value{OPENPGP-SIGNING-KEY-ID}
  6154. @end example
  6155. @ref{GPG Configuration Options, @option{--keyring},, gnupg, Using the GNU
  6156. Privacy Guard}, for more information on GPG's @option{--keyring} option.
  6157. @item --key-download=@var{policy}
  6158. Handle missing OpenPGP keys according to @var{policy}, which may be one
  6159. of:
  6160. @table @code
  6161. @item always
  6162. Always download missing OpenPGP keys from the key server, and add them
  6163. to the user's GnuPG keyring.
  6164. @item never
  6165. Never try to download missing OpenPGP keys. Instead just bail out.
  6166. @item interactive
  6167. When a package signed with an unknown OpenPGP key is encountered, ask
  6168. the user whether to download it or not. This is the default behavior.
  6169. @end table
  6170. @item --key-server=@var{host}
  6171. Use @var{host} as the OpenPGP key server when importing a public key.
  6172. @end table
  6173. The @code{github} updater uses the
  6174. @uref{https://developer.github.com/v3/, GitHub API} to query for new
  6175. releases. When used repeatedly e.g.@: when refreshing all packages,
  6176. GitHub will eventually refuse to answer any further API requests. By
  6177. default 60 API requests per hour are allowed, and a full refresh on all
  6178. GitHub packages in Guix requires more than this. Authentication with
  6179. GitHub through the use of an API token alleviates these limits. To use
  6180. an API token, set the environment variable @code{GUIX_GITHUB_TOKEN} to a
  6181. token procured from @uref{https://github.com/settings/tokens} or
  6182. otherwise.
  6183. @node Invoking guix lint
  6184. @section Invoking @command{guix lint}
  6185. @cindex @command{guix lint}
  6186. @cindex package, checking for errors
  6187. The @command{guix lint} command is meant to help package developers avoid
  6188. common errors and use a consistent style. It runs a number of checks on
  6189. a given set of packages in order to find common mistakes in their
  6190. definitions. Available @dfn{checkers} include (see
  6191. @code{--list-checkers} for a complete list):
  6192. @table @code
  6193. @item synopsis
  6194. @itemx description
  6195. Validate certain typographical and stylistic rules about package
  6196. descriptions and synopses.
  6197. @item inputs-should-be-native
  6198. Identify inputs that should most likely be native inputs.
  6199. @item source
  6200. @itemx home-page
  6201. @itemx mirror-url
  6202. @itemx source-file-name
  6203. Probe @code{home-page} and @code{source} URLs and report those that are
  6204. invalid. Suggest a @code{mirror://} URL when applicable. Check that
  6205. the source file name is meaningful, e.g.@: is not
  6206. just a version number or ``git-checkout'', without a declared
  6207. @code{file-name} (@pxref{origin Reference}).
  6208. @item cve
  6209. @cindex security vulnerabilities
  6210. @cindex CVE, Common Vulnerabilities and Exposures
  6211. Report known vulnerabilities found in the Common Vulnerabilities and
  6212. Exposures (CVE) databases of the current and past year
  6213. @uref{https://nvd.nist.gov/download.cfm#CVE_FEED, published by the US
  6214. NIST}.
  6215. To view information about a particular vulnerability, visit pages such as:
  6216. @itemize
  6217. @item
  6218. @indicateurl{https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-YYYY-ABCD}
  6219. @item
  6220. @indicateurl{https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-YYYY-ABCD}
  6221. @end itemize
  6222. @noindent
  6223. where @code{CVE-YYYY-ABCD} is the CVE identifier---e.g.,
  6224. @code{CVE-2015-7554}.
  6225. Package developers can specify in package recipes the
  6226. @uref{https://nvd.nist.gov/cpe.cfm,Common Platform Enumeration (CPE)}
  6227. name and version of the package when they differ from the name or version
  6228. that Guix uses, as in this example:
  6229. @example
  6230. (package
  6231. (name "grub")
  6232. ;; @dots{}
  6233. ;; CPE calls this package "grub2".
  6234. (properties '((cpe-name . "grub2")
  6235. (cpe-version . "2.3")))
  6236. @end example
  6237. @c See <http://www.openwall.com/lists/oss-security/2017/03/15/3>.
  6238. Some entries in the CVE database do not specify which version of a
  6239. package they apply to, and would thus ``stick around'' forever. Package
  6240. developers who found CVE alerts and verified they can be ignored can
  6241. declare them as in this example:
  6242. @example
  6243. (package
  6244. (name "t1lib")
  6245. ;; @dots{}
  6246. ;; These CVEs no longer apply and can be safely ignored.
  6247. (properties `((lint-hidden-cve . ("CVE-2011-0433"
  6248. "CVE-2011-1553"
  6249. "CVE-2011-1554"
  6250. "CVE-2011-5244")))))
  6251. @end example
  6252. @item formatting
  6253. Warn about obvious source code formatting issues: trailing white space,
  6254. use of tabulations, etc.
  6255. @end table
  6256. The general syntax is:
  6257. @example
  6258. guix lint @var{options} @var{package}@dots{}
  6259. @end example
  6260. If no package is given on the command line, then all packages are checked.
  6261. The @var{options} may be zero or more of the following:
  6262. @table @code
  6263. @item --list-checkers
  6264. @itemx -l
  6265. List and describe all the available checkers that will be run on packages
  6266. and exit.
  6267. @item --checkers
  6268. @itemx -c
  6269. Only enable the checkers specified in a comma-separated list using the
  6270. names returned by @code{--list-checkers}.
  6271. @end table
  6272. @node Invoking guix size
  6273. @section Invoking @command{guix size}
  6274. @cindex size
  6275. @cindex package size
  6276. @cindex closure
  6277. @cindex @command{guix size}
  6278. The @command{guix size} command helps package developers profile the
  6279. disk usage of packages. It is easy to overlook the impact of an
  6280. additional dependency added to a package, or the impact of using a
  6281. single output for a package that could easily be split (@pxref{Packages
  6282. with Multiple Outputs}). Such are the typical issues that
  6283. @command{guix size} can highlight.
  6284. The command can be passed one or more package specifications
  6285. such as @code{gcc@@4.8}
  6286. or @code{guile:debug}, or a file name in the store. Consider this
  6287. example:
  6288. @example
  6289. $ guix size coreutils
  6290. store item total self
  6291. /gnu/store/@dots{}-gcc-5.5.0-lib 60.4 30.1 38.1%
  6292. /gnu/store/@dots{}-glibc-2.27 30.3 28.8 36.6%
  6293. /gnu/store/@dots{}-coreutils-8.28 78.9 15.0 19.0%
  6294. /gnu/store/@dots{}-gmp-6.1.2 63.1 2.7 3.4%
  6295. /gnu/store/@dots{}-bash-static-4.4.12 1.5 1.5 1.9%
  6296. /gnu/store/@dots{}-acl-2.2.52 61.1 0.4 0.5%
  6297. /gnu/store/@dots{}-attr-2.4.47 60.6 0.2 0.3%
  6298. /gnu/store/@dots{}-libcap-2.25 60.5 0.2 0.2%
  6299. total: 78.9 MiB
  6300. @end example
  6301. @cindex closure
  6302. The store items listed here constitute the @dfn{transitive closure} of
  6303. Coreutils---i.e., Coreutils and all its dependencies, recursively---as
  6304. would be returned by:
  6305. @example
  6306. $ guix gc -R /gnu/store/@dots{}-coreutils-8.23
  6307. @end example
  6308. Here the output shows three columns next to store items. The first column,
  6309. labeled ``total'', shows the size in mebibytes (MiB) of the closure of
  6310. the store item---that is, its own size plus the size of all its
  6311. dependencies. The next column, labeled ``self'', shows the size of the
  6312. item itself. The last column shows the ratio of the size of the item
  6313. itself to the space occupied by all the items listed here.
  6314. In this example, we see that the closure of Coreutils weighs in at
  6315. 79@tie{}MiB, most of which is taken by libc and GCC's run-time support
  6316. libraries. (That libc and GCC's libraries represent a large fraction of
  6317. the closure is not a problem @i{per se} because they are always available
  6318. on the system anyway.)
  6319. When the package(s) passed to @command{guix size} are available in the
  6320. store@footnote{More precisely, @command{guix size} looks for the
  6321. @emph{ungrafted} variant of the given package(s), as returned by
  6322. @code{guix build @var{package} --no-grafts}. @xref{Security Updates},
  6323. for information on grafts.}, @command{guix size} queries the daemon to determine its
  6324. dependencies, and measures its size in the store, similar to @command{du
  6325. -ms --apparent-size} (@pxref{du invocation,,, coreutils, GNU
  6326. Coreutils}).
  6327. When the given packages are @emph{not} in the store, @command{guix size}
  6328. reports information based on the available substitutes
  6329. (@pxref{Substitutes}). This makes it possible it to profile disk usage of
  6330. store items that are not even on disk, only available remotely.
  6331. You can also specify several package names:
  6332. @example
  6333. $ guix size coreutils grep sed bash
  6334. store item total self
  6335. /gnu/store/@dots{}-coreutils-8.24 77.8 13.8 13.4%
  6336. /gnu/store/@dots{}-grep-2.22 73.1 0.8 0.8%
  6337. /gnu/store/@dots{}-bash-4.3.42 72.3 4.7 4.6%
  6338. /gnu/store/@dots{}-readline-6.3 67.6 1.2 1.2%
  6339. @dots{}
  6340. total: 102.3 MiB
  6341. @end example
  6342. @noindent
  6343. In this example we see that the combination of the four packages takes
  6344. 102.3@tie{}MiB in total, which is much less than the sum of each closure
  6345. since they have a lot of dependencies in common.
  6346. The available options are:
  6347. @table @option
  6348. @item --substitute-urls=@var{urls}
  6349. Use substitute information from @var{urls}.
  6350. @xref{client-substitute-urls, the same option for @code{guix build}}.
  6351. @item --sort=@var{key}
  6352. Sort lines according to @var{key}, one of the following options:
  6353. @table @code
  6354. @item self
  6355. the size of each item (the default);
  6356. @item closure
  6357. the total size of the item's closure.
  6358. @end table
  6359. @item --map-file=@var{file}
  6360. Write a graphical map of disk usage in PNG format to @var{file}.
  6361. For the example above, the map looks like this:
  6362. @image{images/coreutils-size-map,5in,, map of Coreutils disk usage
  6363. produced by @command{guix size}}
  6364. This option requires that
  6365. @uref{http://wingolog.org/software/guile-charting/, Guile-Charting} be
  6366. installed and visible in Guile's module search path. When that is not
  6367. the case, @command{guix size} fails as it tries to load it.
  6368. @item --system=@var{system}
  6369. @itemx -s @var{system}
  6370. Consider packages for @var{system}---e.g., @code{x86_64-linux}.
  6371. @end table
  6372. @node Invoking guix graph
  6373. @section Invoking @command{guix graph}
  6374. @cindex DAG
  6375. @cindex @command{guix graph}
  6376. @cindex package dependencies
  6377. Packages and their dependencies form a @dfn{graph}, specifically a
  6378. directed acyclic graph (DAG). It can quickly become difficult to have a
  6379. mental model of the package DAG, so the @command{guix graph} command
  6380. provides a visual representation of the DAG. By default,
  6381. @command{guix graph} emits a DAG representation in the input format of
  6382. @uref{http://www.graphviz.org/, Graphviz}, so its output can be passed
  6383. directly to the @command{dot} command of Graphviz. It can also emit an
  6384. HTML page with embedded JavaScript code to display a ``chord diagram''
  6385. in a Web browser, using the @uref{https://d3js.org/, d3.js} library, or
  6386. emit Cypher queries to construct a graph in a graph database supporting
  6387. the @uref{http://www.opencypher.org/, openCypher} query language.
  6388. The general syntax is:
  6389. @example
  6390. guix graph @var{options} @var{package}@dots{}
  6391. @end example
  6392. For example, the following command generates a PDF file representing the
  6393. package DAG for the GNU@tie{}Core Utilities, showing its build-time
  6394. dependencies:
  6395. @example
  6396. guix graph coreutils | dot -Tpdf > dag.pdf
  6397. @end example
  6398. The output looks like this:
  6399. @image{images/coreutils-graph,2in,,Dependency graph of the GNU Coreutils}
  6400. Nice little graph, no?
  6401. But there is more than one graph! The one above is concise: it is the
  6402. graph of package objects, omitting implicit inputs such as GCC, libc,
  6403. grep, etc. It is often useful to have such a concise graph, but
  6404. sometimes one may want to see more details. @command{guix graph} supports
  6405. several types of graphs, allowing you to choose the level of detail:
  6406. @table @code
  6407. @item package
  6408. This is the default type used in the example above. It shows the DAG of
  6409. package objects, excluding implicit dependencies. It is concise, but
  6410. filters out many details.
  6411. @item reverse-package
  6412. This shows the @emph{reverse} DAG of packages. For example:
  6413. @example
  6414. guix graph --type=reverse-package ocaml
  6415. @end example
  6416. ...@: yields the graph of packages that depend on OCaml.
  6417. Note that for core packages this can yield huge graphs. If all you want
  6418. is to know the number of packages that depend on a given package, use
  6419. @command{guix refresh --list-dependent} (@pxref{Invoking guix refresh,
  6420. @option{--list-dependent}}).
  6421. @item bag-emerged
  6422. This is the package DAG, @emph{including} implicit inputs.
  6423. For instance, the following command:
  6424. @example
  6425. guix graph --type=bag-emerged coreutils | dot -Tpdf > dag.pdf
  6426. @end example
  6427. ...@: yields this bigger graph:
  6428. @image{images/coreutils-bag-graph,,5in,Detailed dependency graph of the GNU Coreutils}
  6429. At the bottom of the graph, we see all the implicit inputs of
  6430. @var{gnu-build-system} (@pxref{Build Systems, @code{gnu-build-system}}).
  6431. Now, note that the dependencies of these implicit inputs---that is, the
  6432. @dfn{bootstrap dependencies} (@pxref{Bootstrapping})---are not shown
  6433. here, for conciseness.
  6434. @item bag
  6435. Similar to @code{bag-emerged}, but this time including all the bootstrap
  6436. dependencies.
  6437. @item bag-with-origins
  6438. Similar to @code{bag}, but also showing origins and their dependencies.
  6439. @item derivation
  6440. This is the most detailed representation: It shows the DAG of
  6441. derivations (@pxref{Derivations}) and plain store items. Compared to
  6442. the above representation, many additional nodes are visible, including
  6443. build scripts, patches, Guile modules, etc.
  6444. For this type of graph, it is also possible to pass a @file{.drv} file
  6445. name instead of a package name, as in:
  6446. @example
  6447. guix graph -t derivation `guix system build -d my-config.scm`
  6448. @end example
  6449. @item module
  6450. This is the graph of @dfn{package modules} (@pxref{Package Modules}).
  6451. For example, the following command shows the graph for the package
  6452. module that defines the @code{guile} package:
  6453. @example
  6454. guix graph -t module guile | dot -Tpdf > module-graph.pdf
  6455. @end example
  6456. @end table
  6457. All the types above correspond to @emph{build-time dependencies}. The
  6458. following graph type represents the @emph{run-time dependencies}:
  6459. @table @code
  6460. @item references
  6461. This is the graph of @dfn{references} of a package output, as returned
  6462. by @command{guix gc --references} (@pxref{Invoking guix gc}).
  6463. If the given package output is not available in the store, @command{guix
  6464. graph} attempts to obtain dependency information from substitutes.
  6465. Here you can also pass a store file name instead of a package name. For
  6466. example, the command below produces the reference graph of your profile
  6467. (which can be big!):
  6468. @example
  6469. guix graph -t references `readlink -f ~/.guix-profile`
  6470. @end example
  6471. @item referrers
  6472. This is the graph of the @dfn{referrers} of a store item, as returned by
  6473. @command{guix gc --referrers} (@pxref{Invoking guix gc}).
  6474. This relies exclusively on local information from your store. For
  6475. instance, let us suppose that the current Inkscape is available in 10
  6476. profiles on your machine; @command{guix graph -t referrers inkscape}
  6477. will show a graph rooted at Inkscape and with those 10 profiles linked
  6478. to it.
  6479. It can help determine what is preventing a store item from being garbage
  6480. collected.
  6481. @end table
  6482. The available options are the following:
  6483. @table @option
  6484. @item --type=@var{type}
  6485. @itemx -t @var{type}
  6486. Produce a graph output of @var{type}, where @var{type} must be one of
  6487. the values listed above.
  6488. @item --list-types
  6489. List the supported graph types.
  6490. @item --backend=@var{backend}
  6491. @itemx -b @var{backend}
  6492. Produce a graph using the selected @var{backend}.
  6493. @item --list-backends
  6494. List the supported graph backends.
  6495. Currently, the available backends are Graphviz and d3.js.
  6496. @item --expression=@var{expr}
  6497. @itemx -e @var{expr}
  6498. Consider the package @var{expr} evaluates to.
  6499. This is useful to precisely refer to a package, as in this example:
  6500. @example
  6501. guix graph -e '(@@@@ (gnu packages commencement) gnu-make-final)'
  6502. @end example
  6503. @item --system=@var{system}
  6504. @itemx -s @var{system}
  6505. Display the graph for @var{system}---e.g., @code{i686-linux}.
  6506. The package dependency graph is largely architecture-independent, but there
  6507. are some architecture-dependent bits that this option allows you to visualize.
  6508. @end table
  6509. @node Invoking guix environment
  6510. @section Invoking @command{guix environment}
  6511. @cindex reproducible build environments
  6512. @cindex development environments
  6513. @cindex @command{guix environment}
  6514. @cindex environment, package build environment
  6515. The purpose of @command{guix environment} is to assist hackers in
  6516. creating reproducible development environments without polluting their
  6517. package profile. The @command{guix environment} tool takes one or more
  6518. packages, builds all of their inputs, and creates a shell
  6519. environment to use them.
  6520. The general syntax is:
  6521. @example
  6522. guix environment @var{options} @var{package}@dots{}
  6523. @end example
  6524. The following example spawns a new shell set up for the development of
  6525. GNU@tie{}Guile:
  6526. @example
  6527. guix environment guile
  6528. @end example
  6529. If the needed dependencies are not built yet, @command{guix environment}
  6530. automatically builds them. The environment of the new shell is an augmented
  6531. version of the environment that @command{guix environment} was run in.
  6532. It contains the necessary search paths for building the given package
  6533. added to the existing environment variables. To create a ``pure''
  6534. environment, in which the original environment variables have been unset,
  6535. use the @code{--pure} option@footnote{Users sometimes wrongfully augment
  6536. environment variables such as @code{PATH} in their @file{~/.bashrc}
  6537. file. As a consequence, when @code{guix environment} launches it, Bash
  6538. may read @file{~/.bashrc}, thereby introducing ``impurities'' in these
  6539. environment variables. It is an error to define such environment
  6540. variables in @file{.bashrc}; instead, they should be defined in
  6541. @file{.bash_profile}, which is sourced only by log-in shells.
  6542. @xref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}, for
  6543. details on Bash start-up files.}.
  6544. @vindex GUIX_ENVIRONMENT
  6545. @command{guix environment} defines the @code{GUIX_ENVIRONMENT}
  6546. variable in the shell it spawns; its value is the file name of the
  6547. profile of this environment. This allows users to, say, define a
  6548. specific prompt for development environments in their @file{.bashrc}
  6549. (@pxref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}):
  6550. @example
  6551. if [ -n "$GUIX_ENVIRONMENT" ]
  6552. then
  6553. export PS1="\u@@\h \w [dev]\$ "
  6554. fi
  6555. @end example
  6556. @noindent
  6557. ...@: or to browse the profile:
  6558. @example
  6559. $ ls "$GUIX_ENVIRONMENT/bin"
  6560. @end example
  6561. Additionally, more than one package may be specified, in which case the
  6562. union of the inputs for the given packages are used. For example, the
  6563. command below spawns a shell where all of the dependencies of both Guile
  6564. and Emacs are available:
  6565. @example
  6566. guix environment guile emacs
  6567. @end example
  6568. Sometimes an interactive shell session is not desired. An arbitrary
  6569. command may be invoked by placing the @code{--} token to separate the
  6570. command from the rest of the arguments:
  6571. @example
  6572. guix environment guile -- make -j4
  6573. @end example
  6574. In other situations, it is more convenient to specify the list of
  6575. packages needed in the environment. For example, the following command
  6576. runs @command{python} from an environment containing Python@tie{}2.7 and
  6577. NumPy:
  6578. @example
  6579. guix environment --ad-hoc python2-numpy python-2.7 -- python
  6580. @end example
  6581. Furthermore, one might want the dependencies of a package and also some
  6582. additional packages that are not build-time or runtime dependencies, but
  6583. are useful when developing nonetheless. Because of this, the
  6584. @code{--ad-hoc} flag is positional. Packages appearing before
  6585. @code{--ad-hoc} are interpreted as packages whose dependencies will be
  6586. added to the environment. Packages appearing after are interpreted as
  6587. packages that will be added to the environment directly. For example,
  6588. the following command creates a Guix development environment that
  6589. additionally includes Git and strace:
  6590. @example
  6591. guix environment guix --ad-hoc git strace
  6592. @end example
  6593. Sometimes it is desirable to isolate the environment as much as
  6594. possible, for maximal purity and reproducibility. In particular, when
  6595. using Guix on a host distro that is not GuixSD, it is desirable to
  6596. prevent access to @file{/usr/bin} and other system-wide resources from
  6597. the development environment. For example, the following command spawns
  6598. a Guile REPL in a ``container'' where only the store and the current
  6599. working directory are mounted:
  6600. @example
  6601. guix environment --ad-hoc --container guile -- guile
  6602. @end example
  6603. @quotation Note
  6604. The @code{--container} option requires Linux-libre 3.19 or newer.
  6605. @end quotation
  6606. The available options are summarized below.
  6607. @table @code
  6608. @item --root=@var{file}
  6609. @itemx -r @var{file}
  6610. @cindex persistent environment
  6611. @cindex garbage collector root, for environments
  6612. Make @var{file} a symlink to the profile for this environment, and
  6613. register it as a garbage collector root.
  6614. This is useful if you want to protect your environment from garbage
  6615. collection, to make it ``persistent''.
  6616. When this option is omitted, the environment is protected from garbage
  6617. collection only for the duration of the @command{guix environment}
  6618. session. This means that next time you recreate the same environment,
  6619. you could have to rebuild or re-download packages. @xref{Invoking guix
  6620. gc}, for more on GC roots.
  6621. @item --expression=@var{expr}
  6622. @itemx -e @var{expr}
  6623. Create an environment for the package or list of packages that
  6624. @var{expr} evaluates to.
  6625. For example, running:
  6626. @example
  6627. guix environment -e '(@@ (gnu packages maths) petsc-openmpi)'
  6628. @end example
  6629. starts a shell with the environment for this specific variant of the
  6630. PETSc package.
  6631. Running:
  6632. @example
  6633. guix environment --ad-hoc -e '(@@ (gnu) %base-packages)'
  6634. @end example
  6635. starts a shell with all the GuixSD base packages available.
  6636. The above commands only use the default output of the given packages.
  6637. To select other outputs, two element tuples can be specified:
  6638. @example
  6639. guix environment --ad-hoc -e '(list (@@ (gnu packages bash) bash) "include")'
  6640. @end example
  6641. @item --load=@var{file}
  6642. @itemx -l @var{file}
  6643. Create an environment for the package or list of packages that the code
  6644. within @var{file} evaluates to.
  6645. As an example, @var{file} might contain a definition like this
  6646. (@pxref{Defining Packages}):
  6647. @example
  6648. @verbatiminclude environment-gdb.scm
  6649. @end example
  6650. @item --manifest=@var{file}
  6651. @itemx -m @var{file}
  6652. Create an environment for the packages contained in the manifest object
  6653. returned by the Scheme code in @var{file}.
  6654. This is similar to the same-named option in @command{guix package}
  6655. (@pxref{profile-manifest, @option{--manifest}}) and uses the same
  6656. manifest files.
  6657. @item --ad-hoc
  6658. Include all specified packages in the resulting environment, as if an
  6659. @i{ad hoc} package were defined with them as inputs. This option is
  6660. useful for quickly creating an environment without having to write a
  6661. package expression to contain the desired inputs.
  6662. For instance, the command:
  6663. @example
  6664. guix environment --ad-hoc guile guile-sdl -- guile
  6665. @end example
  6666. runs @command{guile} in an environment where Guile and Guile-SDL are
  6667. available.
  6668. Note that this example implicitly asks for the default output of
  6669. @code{guile} and @code{guile-sdl}, but it is possible to ask for a
  6670. specific output---e.g., @code{glib:bin} asks for the @code{bin} output
  6671. of @code{glib} (@pxref{Packages with Multiple Outputs}).
  6672. This option may be composed with the default behavior of @command{guix
  6673. environment}. Packages appearing before @code{--ad-hoc} are interpreted
  6674. as packages whose dependencies will be added to the environment, the
  6675. default behavior. Packages appearing after are interpreted as packages
  6676. that will be added to the environment directly.
  6677. @item --pure
  6678. Unset existing environment variables when building the new environment.
  6679. This has the effect of creating an environment in which search paths
  6680. only contain package inputs.
  6681. @item --search-paths
  6682. Display the environment variable definitions that make up the
  6683. environment.
  6684. @item --system=@var{system}
  6685. @itemx -s @var{system}
  6686. Attempt to build for @var{system}---e.g., @code{i686-linux}.
  6687. @item --container
  6688. @itemx -C
  6689. @cindex container
  6690. Run @var{command} within an isolated container. The current working
  6691. directory outside the container is mapped inside the container.
  6692. Additionally, unless overridden with @code{--user}, a dummy home
  6693. directory is created that matches the current user's home directory, and
  6694. @file{/etc/passwd} is configured accordingly. The spawned process runs
  6695. as the current user outside the container, but has root privileges in
  6696. the context of the container.
  6697. @item --network
  6698. @itemx -N
  6699. For containers, share the network namespace with the host system.
  6700. Containers created without this flag only have access to the loopback
  6701. device.
  6702. @item --link-profile
  6703. @itemx -P
  6704. For containers, link the environment profile to
  6705. @file{~/.guix-profile} within the container. This is equivalent to
  6706. running the command @command{ln -s $GUIX_ENVIRONMENT ~/.guix-profile}
  6707. within the container. Linking will fail and abort the environment if
  6708. the directory already exists, which will certainly be the case if
  6709. @command{guix environment} was invoked in the user's home directory.
  6710. Certain packages are configured to look in
  6711. @code{~/.guix-profile} for configuration files and data;@footnote{For
  6712. example, the @code{fontconfig} package inspects
  6713. @file{~/.guix-profile/share/fonts} for additional fonts.}
  6714. @code{--link-profile} allows these programs to behave as expected within
  6715. the environment.
  6716. @item --user=@var{user}
  6717. @itemx -u @var{user}
  6718. For containers, use the username @var{user} in place of the current
  6719. user. The generated @file{/etc/passwd} entry within the container will
  6720. contain the name @var{user}; the home directory will be
  6721. @file{/home/USER}; and no user GECOS data will be copied. @var{user}
  6722. need not exist on the system.
  6723. Additionally, any shared or exposed path (see @code{--share} and
  6724. @code{--expose} respectively) whose target is within the current user's
  6725. home directory will be remapped relative to @file{/home/USER}; this
  6726. includes the automatic mapping of the current working directory.
  6727. @example
  6728. # will expose paths as /home/foo/wd, /home/foo/test, and /home/foo/target
  6729. cd $HOME/wd
  6730. guix environment --container --user=foo \
  6731. --expose=$HOME/test \
  6732. --expose=/tmp/target=$HOME/target
  6733. @end example
  6734. While this will limit the leaking of user identity through home paths
  6735. and each of the user fields, this is only one useful component of a
  6736. broader privacy/anonymity solution---not one in and of itself.
  6737. @item --expose=@var{source}[=@var{target}]
  6738. For containers, expose the file system @var{source} from the host system
  6739. as the read-only file system @var{target} within the container. If
  6740. @var{target} is not specified, @var{source} is used as the target mount
  6741. point in the container.
  6742. The example below spawns a Guile REPL in a container in which the user's
  6743. home directory is accessible read-only via the @file{/exchange}
  6744. directory:
  6745. @example
  6746. guix environment --container --expose=$HOME=/exchange --ad-hoc guile -- guile
  6747. @end example
  6748. @item --share=@var{source}[=@var{target}]
  6749. For containers, share the file system @var{source} from the host system
  6750. as the writable file system @var{target} within the container. If
  6751. @var{target} is not specified, @var{source} is used as the target mount
  6752. point in the container.
  6753. The example below spawns a Guile REPL in a container in which the user's
  6754. home directory is accessible for both reading and writing via the
  6755. @file{/exchange} directory:
  6756. @example
  6757. guix environment --container --share=$HOME=/exchange --ad-hoc guile -- guile
  6758. @end example
  6759. @end table
  6760. @command{guix environment}
  6761. also supports all of the common build options that @command{guix
  6762. build} supports (@pxref{Common Build Options}).
  6763. @node Invoking guix publish
  6764. @section Invoking @command{guix publish}
  6765. @cindex @command{guix publish}
  6766. The purpose of @command{guix publish} is to enable users to easily share
  6767. their store with others, who can then use it as a substitute server
  6768. (@pxref{Substitutes}).
  6769. When @command{guix publish} runs, it spawns an HTTP server which allows
  6770. anyone with network access to obtain substitutes from it. This means
  6771. that any machine running Guix can also act as if it were a build farm,
  6772. since the HTTP interface is compatible with Hydra, the software behind
  6773. the @code{@value{SUBSTITUTE-SERVER}} build farm.
  6774. For security, each substitute is signed, allowing recipients to check
  6775. their authenticity and integrity (@pxref{Substitutes}). Because
  6776. @command{guix publish} uses the signing key of the system, which is only
  6777. readable by the system administrator, it must be started as root; the
  6778. @code{--user} option makes it drop root privileges early on.
  6779. The signing key pair must be generated before @command{guix publish} is
  6780. launched, using @command{guix archive --generate-key} (@pxref{Invoking
  6781. guix archive}).
  6782. The general syntax is:
  6783. @example
  6784. guix publish @var{options}@dots{}
  6785. @end example
  6786. Running @command{guix publish} without any additional arguments will
  6787. spawn an HTTP server on port 8080:
  6788. @example
  6789. guix publish
  6790. @end example
  6791. Once a publishing server has been authorized (@pxref{Invoking guix
  6792. archive}), the daemon may download substitutes from it:
  6793. @example
  6794. guix-daemon --substitute-urls=http://example.org:8080
  6795. @end example
  6796. By default, @command{guix publish} compresses archives on the fly as it
  6797. serves them. This ``on-the-fly'' mode is convenient in that it requires
  6798. no setup and is immediately available. However, when serving lots of
  6799. clients, we recommend using the @option{--cache} option, which enables
  6800. caching of the archives before they are sent to clients---see below for
  6801. details. The @command{guix weather} command provides a handy way to
  6802. check what a server provides (@pxref{Invoking guix weather}).
  6803. As a bonus, @command{guix publish} also serves as a content-addressed
  6804. mirror for source files referenced in @code{origin} records
  6805. (@pxref{origin Reference}). For instance, assuming @command{guix
  6806. publish} is running on @code{example.org}, the following URL returns the
  6807. raw @file{hello-2.10.tar.gz} file with the given SHA256 hash
  6808. (represented in @code{nix-base32} format, @pxref{Invoking guix hash}):
  6809. @example
  6810. http://example.org/file/hello-2.10.tar.gz/sha256/0ssi1@dots{}ndq1i
  6811. @end example
  6812. Obviously, these URLs only work for files that are in the store; in
  6813. other cases, they return 404 (``Not Found'').
  6814. @cindex build logs, publication
  6815. Build logs are available from @code{/log} URLs like:
  6816. @example
  6817. http://example.org/log/gwspk@dots{}-guile-2.2.3
  6818. @end example
  6819. @noindent
  6820. When @command{guix-daemon} is configured to save compressed build logs,
  6821. as is the case by default (@pxref{Invoking guix-daemon}), @code{/log}
  6822. URLs return the compressed log as-is, with an appropriate
  6823. @code{Content-Type} and/or @code{Content-Encoding} header. We recommend
  6824. running @command{guix-daemon} with @code{--log-compression=gzip} since
  6825. Web browsers can automatically decompress it, which is not the case with
  6826. bzip2 compression.
  6827. The following options are available:
  6828. @table @code
  6829. @item --port=@var{port}
  6830. @itemx -p @var{port}
  6831. Listen for HTTP requests on @var{port}.
  6832. @item --listen=@var{host}
  6833. Listen on the network interface for @var{host}. The default is to
  6834. accept connections from any interface.
  6835. @item --user=@var{user}
  6836. @itemx -u @var{user}
  6837. Change privileges to @var{user} as soon as possible---i.e., once the
  6838. server socket is open and the signing key has been read.
  6839. @item --compression[=@var{level}]
  6840. @itemx -C [@var{level}]
  6841. Compress data using the given @var{level}. When @var{level} is zero,
  6842. disable compression. The range 1 to 9 corresponds to different gzip
  6843. compression levels: 1 is the fastest, and 9 is the best (CPU-intensive).
  6844. The default is 3.
  6845. Unless @option{--cache} is used, compression occurs on the fly and
  6846. the compressed streams are not
  6847. cached. Thus, to reduce load on the machine that runs @command{guix
  6848. publish}, it may be a good idea to choose a low compression level, to
  6849. run @command{guix publish} behind a caching proxy, or to use
  6850. @option{--cache}. Using @option{--cache} has the advantage that it
  6851. allows @command{guix publish} to add @code{Content-Length} HTTP header
  6852. to its responses.
  6853. @item --cache=@var{directory}
  6854. @itemx -c @var{directory}
  6855. Cache archives and meta-data (@code{.narinfo} URLs) to @var{directory}
  6856. and only serve archives that are in cache.
  6857. When this option is omitted, archives and meta-data are created
  6858. on-the-fly. This can reduce the available bandwidth, especially when
  6859. compression is enabled, since this may become CPU-bound. Another
  6860. drawback of the default mode is that the length of archives is not known
  6861. in advance, so @command{guix publish} does not add a
  6862. @code{Content-Length} HTTP header to its responses, which in turn
  6863. prevents clients from knowing the amount of data being downloaded.
  6864. Conversely, when @option{--cache} is used, the first request for a store
  6865. item (@i{via} a @code{.narinfo} URL) returns 404 and triggers a
  6866. background process to @dfn{bake} the archive---computing its
  6867. @code{.narinfo} and compressing the archive, if needed. Once the
  6868. archive is cached in @var{directory}, subsequent requests succeed and
  6869. are served directly from the cache, which guarantees that clients get
  6870. the best possible bandwidth.
  6871. The ``baking'' process is performed by worker threads. By default, one
  6872. thread per CPU core is created, but this can be customized. See
  6873. @option{--workers} below.
  6874. When @option{--ttl} is used, cached entries are automatically deleted
  6875. when they have expired.
  6876. @item --workers=@var{N}
  6877. When @option{--cache} is used, request the allocation of @var{N} worker
  6878. threads to ``bake'' archives.
  6879. @item --ttl=@var{ttl}
  6880. Produce @code{Cache-Control} HTTP headers that advertise a time-to-live
  6881. (TTL) of @var{ttl}. @var{ttl} must denote a duration: @code{5d} means 5
  6882. days, @code{1m} means 1 month, and so on.
  6883. This allows the user's Guix to keep substitute information in cache for
  6884. @var{ttl}. However, note that @code{guix publish} does not itself
  6885. guarantee that the store items it provides will indeed remain available
  6886. for as long as @var{ttl}.
  6887. Additionally, when @option{--cache} is used, cached entries that have
  6888. not been accessed for @var{ttl} and that no longer have a corresponding
  6889. item in the store, may be deleted.
  6890. @item --nar-path=@var{path}
  6891. Use @var{path} as the prefix for the URLs of ``nar'' files
  6892. (@pxref{Invoking guix archive, normalized archives}).
  6893. By default, nars are served at a URL such as
  6894. @code{/nar/gzip/@dots{}-coreutils-8.25}. This option allows you to
  6895. change the @code{/nar} part to @var{path}.
  6896. @item --public-key=@var{file}
  6897. @itemx --private-key=@var{file}
  6898. Use the specific @var{file}s as the public/private key pair used to sign
  6899. the store items being published.
  6900. The files must correspond to the same key pair (the private key is used
  6901. for signing and the public key is merely advertised in the signature
  6902. metadata). They must contain keys in the canonical s-expression format
  6903. as produced by @command{guix archive --generate-key} (@pxref{Invoking
  6904. guix archive}). By default, @file{/etc/guix/signing-key.pub} and
  6905. @file{/etc/guix/signing-key.sec} are used.
  6906. @item --repl[=@var{port}]
  6907. @itemx -r [@var{port}]
  6908. Spawn a Guile REPL server (@pxref{REPL Servers,,, guile, GNU Guile
  6909. Reference Manual}) on @var{port} (37146 by default). This is used
  6910. primarily for debugging a running @command{guix publish} server.
  6911. @end table
  6912. Enabling @command{guix publish} on a GuixSD system is a one-liner: just
  6913. instantiate a @code{guix-publish-service-type} service in the @code{services} field
  6914. of the @code{operating-system} declaration (@pxref{guix-publish-service-type,
  6915. @code{guix-publish-service-type}}).
  6916. If you are instead running Guix on a ``foreign distro'', follow these
  6917. instructions:”
  6918. @itemize
  6919. @item
  6920. If your host distro uses the systemd init system:
  6921. @example
  6922. # ln -s ~root/.guix-profile/lib/systemd/system/guix-publish.service \
  6923. /etc/systemd/system/
  6924. # systemctl start guix-publish && systemctl enable guix-publish
  6925. @end example
  6926. @item
  6927. If your host distro uses the Upstart init system:
  6928. @example
  6929. # ln -s ~root/.guix-profile/lib/upstart/system/guix-publish.conf /etc/init/
  6930. # start guix-publish
  6931. @end example
  6932. @item
  6933. Otherwise, proceed similarly with your distro's init system.
  6934. @end itemize
  6935. @node Invoking guix challenge
  6936. @section Invoking @command{guix challenge}
  6937. @cindex reproducible builds
  6938. @cindex verifiable builds
  6939. @cindex @command{guix challenge}
  6940. @cindex challenge
  6941. Do the binaries provided by this server really correspond to the source
  6942. code it claims to build? Is a package build process deterministic?
  6943. These are the questions the @command{guix challenge} command attempts to
  6944. answer.
  6945. The former is obviously an important question: Before using a substitute
  6946. server (@pxref{Substitutes}), one had better @emph{verify} that it
  6947. provides the right binaries, and thus @emph{challenge} it. The latter
  6948. is what enables the former: If package builds are deterministic, then
  6949. independent builds of the package should yield the exact same result,
  6950. bit for bit; if a server provides a binary different from the one
  6951. obtained locally, it may be either corrupt or malicious.
  6952. We know that the hash that shows up in @file{/gnu/store} file names is
  6953. the hash of all the inputs of the process that built the file or
  6954. directory---compilers, libraries, build scripts,
  6955. etc. (@pxref{Introduction}). Assuming deterministic build processes,
  6956. one store file name should map to exactly one build output.
  6957. @command{guix challenge} checks whether there is, indeed, a single
  6958. mapping by comparing the build outputs of several independent builds of
  6959. any given store item.
  6960. The command output looks like this:
  6961. @smallexample
  6962. $ guix challenge --substitute-urls="https://@value{SUBSTITUTE-SERVER} https://guix.example.org"
  6963. updating list of substitutes from 'https://@value{SUBSTITUTE-SERVER}'... 100.0%
  6964. updating list of substitutes from 'https://guix.example.org'... 100.0%
  6965. /gnu/store/@dots{}-openssl-1.0.2d contents differ:
  6966. local hash: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q
  6967. https://@value{SUBSTITUTE-SERVER}/nar/@dots{}-openssl-1.0.2d: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q
  6968. https://guix.example.org/nar/@dots{}-openssl-1.0.2d: 1zy4fmaaqcnjrzzajkdn3f5gmjk754b43qkq47llbyak9z0qjyim
  6969. /gnu/store/@dots{}-git-2.5.0 contents differ:
  6970. local hash: 00p3bmryhjxrhpn2gxs2fy0a15lnip05l97205pgbk5ra395hyha
  6971. https://@value{SUBSTITUTE-SERVER}/nar/@dots{}-git-2.5.0: 069nb85bv4d4a6slrwjdy8v1cn4cwspm3kdbmyb81d6zckj3nq9f
  6972. https://guix.example.org/nar/@dots{}-git-2.5.0: 0mdqa9w1p6cmli6976v4wi0sw9r4p5prkj7lzfd1877wk11c9c73
  6973. /gnu/store/@dots{}-pius-2.1.1 contents differ:
  6974. local hash: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax
  6975. https://@value{SUBSTITUTE-SERVER}/nar/@dots{}-pius-2.1.1: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax
  6976. https://guix.example.org/nar/@dots{}-pius-2.1.1: 1cy25x1a4fzq5rk0pmvc8xhwyffnqz95h2bpvqsz2mpvlbccy0gs
  6977. @dots{}
  6978. 6,406 store items were analyzed:
  6979. - 4,749 (74.1%) were identical
  6980. - 525 (8.2%) differed
  6981. - 1,132 (17.7%) were inconclusive
  6982. @end smallexample
  6983. @noindent
  6984. In this example, @command{guix challenge} first scans the store to
  6985. determine the set of locally-built derivations---as opposed to store
  6986. items that were downloaded from a substitute server---and then queries
  6987. all the substitute servers. It then reports those store items for which
  6988. the servers obtained a result different from the local build.
  6989. @cindex non-determinism, in package builds
  6990. As an example, @code{guix.example.org} always gets a different answer.
  6991. Conversely, @code{@value{SUBSTITUTE-SERVER}} agrees with local builds, except in the
  6992. case of Git. This might indicate that the build process of Git is
  6993. non-deterministic, meaning that its output varies as a function of
  6994. various things that Guix does not fully control, in spite of building
  6995. packages in isolated environments (@pxref{Features}). Most common
  6996. sources of non-determinism include the addition of timestamps in build
  6997. results, the inclusion of random numbers, and directory listings sorted
  6998. by inode number. See @uref{https://reproducible-builds.org/docs/}, for
  6999. more information.
  7000. To find out what is wrong with this Git binary, we can do something along
  7001. these lines (@pxref{Invoking guix archive}):
  7002. @example
  7003. $ wget -q -O - https://@value{SUBSTITUTE-SERVER}/nar/@dots{}-git-2.5.0 \
  7004. | guix archive -x /tmp/git
  7005. $ diff -ur --no-dereference /gnu/store/@dots{}-git.2.5.0 /tmp/git
  7006. @end example
  7007. This command shows the difference between the files resulting from the
  7008. local build, and the files resulting from the build on
  7009. @code{@value{SUBSTITUTE-SERVER}} (@pxref{Overview, Comparing and Merging Files,,
  7010. diffutils, Comparing and Merging Files}). The @command{diff} command
  7011. works great for text files. When binary files differ, a better option
  7012. is @uref{https://diffoscope.org/, Diffoscope}, a tool that helps
  7013. visualize differences for all kinds of files.
  7014. Once you have done that work, you can tell whether the differences are due
  7015. to a non-deterministic build process or to a malicious server. We try
  7016. hard to remove sources of non-determinism in packages to make it easier
  7017. to verify substitutes, but of course, this is a process that
  7018. involves not just Guix, but a large part of the free software community.
  7019. In the meantime, @command{guix challenge} is one tool to help address
  7020. the problem.
  7021. If you are writing packages for Guix, you are encouraged to check
  7022. whether @code{@value{SUBSTITUTE-SERVER}} and other substitute servers obtain the
  7023. same build result as you did with:
  7024. @example
  7025. $ guix challenge @var{package}
  7026. @end example
  7027. @noindent
  7028. where @var{package} is a package specification such as
  7029. @code{guile@@2.0} or @code{glibc:debug}.
  7030. The general syntax is:
  7031. @example
  7032. guix challenge @var{options} [@var{packages}@dots{}]
  7033. @end example
  7034. When a difference is found between the hash of a locally-built item and
  7035. that of a server-provided substitute, or among substitutes provided by
  7036. different servers, the command displays it as in the example above and
  7037. its exit code is 2 (other non-zero exit codes denote other kinds of
  7038. errors.)
  7039. The one option that matters is:
  7040. @table @code
  7041. @item --substitute-urls=@var{urls}
  7042. Consider @var{urls} the whitespace-separated list of substitute source
  7043. URLs to compare to.
  7044. @item --verbose
  7045. @itemx -v
  7046. Show details about matches (identical contents) in addition to
  7047. information about mismatches.
  7048. @end table
  7049. @node Invoking guix copy
  7050. @section Invoking @command{guix copy}
  7051. @cindex copy, of store items, over SSH
  7052. @cindex SSH, copy of store items
  7053. @cindex sharing store items across machines
  7054. @cindex transferring store items across machines
  7055. The @command{guix copy} command copies items from the store of one
  7056. machine to that of another machine over a secure shell (SSH)
  7057. connection@footnote{This command is available only when Guile-SSH was
  7058. found. @xref{Requirements}, for details.}. For example, the following
  7059. command copies the @code{coreutils} package, the user's profile, and all
  7060. their dependencies over to @var{host}, logged in as @var{user}:
  7061. @example
  7062. guix copy --to=@var{user}@@@var{host} \
  7063. coreutils `readlink -f ~/.guix-profile`
  7064. @end example
  7065. If some of the items to be copied are already present on @var{host},
  7066. they are not actually sent.
  7067. The command below retrieves @code{libreoffice} and @code{gimp} from
  7068. @var{host}, assuming they are available there:
  7069. @example
  7070. guix copy --from=@var{host} libreoffice gimp
  7071. @end example
  7072. The SSH connection is established using the Guile-SSH client, which is
  7073. compatible with OpenSSH: it honors @file{~/.ssh/known_hosts} and
  7074. @file{~/.ssh/config}, and uses the SSH agent for authentication.
  7075. The key used to sign items that are sent must be accepted by the remote
  7076. machine. Likewise, the key used by the remote machine to sign items you
  7077. are retrieving must be in @file{/etc/guix/acl} so it is accepted by your
  7078. own daemon. @xref{Invoking guix archive}, for more information about
  7079. store item authentication.
  7080. The general syntax is:
  7081. @example
  7082. guix copy [--to=@var{spec}|--from=@var{spec}] @var{items}@dots{}
  7083. @end example
  7084. You must always specify one of the following options:
  7085. @table @code
  7086. @item --to=@var{spec}
  7087. @itemx --from=@var{spec}
  7088. Specify the host to send to or receive from. @var{spec} must be an SSH
  7089. spec such as @code{example.org}, @code{charlie@@example.org}, or
  7090. @code{charlie@@example.org:2222}.
  7091. @end table
  7092. The @var{items} can be either package names, such as @code{gimp}, or
  7093. store items, such as @file{/gnu/store/@dots{}-idutils-4.6}.
  7094. When specifying the name of a package to send, it is first built if
  7095. needed, unless @option{--dry-run} was specified. Common build options
  7096. are supported (@pxref{Common Build Options}).
  7097. @node Invoking guix container
  7098. @section Invoking @command{guix container}
  7099. @cindex container
  7100. @cindex @command{guix container}
  7101. @quotation Note
  7102. As of version @value{VERSION}, this tool is experimental. The interface
  7103. is subject to radical change in the future.
  7104. @end quotation
  7105. The purpose of @command{guix container} is to manipulate processes
  7106. running within an isolated environment, commonly known as a
  7107. ``container'', typically created by the @command{guix environment}
  7108. (@pxref{Invoking guix environment}) and @command{guix system container}
  7109. (@pxref{Invoking guix system}) commands.
  7110. The general syntax is:
  7111. @example
  7112. guix container @var{action} @var{options}@dots{}
  7113. @end example
  7114. @var{action} specifies the operation to perform with a container, and
  7115. @var{options} specifies the context-specific arguments for the action.
  7116. The following actions are available:
  7117. @table @code
  7118. @item exec
  7119. Execute a command within the context of a running container.
  7120. The syntax is:
  7121. @example
  7122. guix container exec @var{pid} @var{program} @var{arguments}@dots{}
  7123. @end example
  7124. @var{pid} specifies the process ID of the running container.
  7125. @var{program} specifies an executable file name within the root file
  7126. system of the container. @var{arguments} are the additional options that
  7127. will be passed to @var{program}.
  7128. The following command launches an interactive login shell inside a
  7129. GuixSD container, started by @command{guix system container}, and whose
  7130. process ID is 9001:
  7131. @example
  7132. guix container exec 9001 /run/current-system/profile/bin/bash --login
  7133. @end example
  7134. Note that the @var{pid} cannot be the parent process of a container. It
  7135. must be PID 1 of the container or one of its child processes.
  7136. @end table
  7137. @node Invoking guix weather
  7138. @section Invoking @command{guix weather}
  7139. Occasionally you're grumpy because substitutes are lacking and you end
  7140. up building packages by yourself (@pxref{Substitutes}). The
  7141. @command{guix weather} command reports on substitute availability on the
  7142. specified servers so you can have an idea of whether you'll be grumpy
  7143. today. It can sometimes be useful info as a user, but it is primarily
  7144. useful to people running @command{guix publish} (@pxref{Invoking guix
  7145. publish}).
  7146. @cindex statistics, for substitutes
  7147. @cindex availability of substitutes
  7148. @cindex substitute availability
  7149. @cindex weather, substitute availability
  7150. Here's a sample run:
  7151. @example
  7152. $ guix weather --substitute-urls=https://guix.example.org
  7153. computing 5,872 package derivations for x86_64-linux...
  7154. looking for 6,128 store items on https://guix.example.org..
  7155. updating list of substitutes from 'https://guix.example.org'... 100.0%
  7156. https://guix.example.org
  7157. 43.4% substitutes available (2,658 out of 6,128)
  7158. 7,032.5 MiB of nars (compressed)
  7159. 19,824.2 MiB on disk (uncompressed)
  7160. 0.030 seconds per request (182.9 seconds in total)
  7161. 33.5 requests per second
  7162. 9.8% (342 out of 3,470) of the missing items are queued
  7163. 867 queued builds
  7164. x86_64-linux: 518 (59.7%)
  7165. i686-linux: 221 (25.5%)
  7166. aarch64-linux: 128 (14.8%)
  7167. build rate: 23.41 builds per hour
  7168. x86_64-linux: 11.16 builds per hour
  7169. i686-linux: 6.03 builds per hour
  7170. aarch64-linux: 6.41 builds per hour
  7171. @end example
  7172. @cindex continuous integration, statistics
  7173. As you can see, it reports the fraction of all the packages for which
  7174. substitutes are available on the server---regardless of whether
  7175. substitutes are enabled, and regardless of whether this server's signing
  7176. key is authorized. It also reports the size of the compressed archives
  7177. (``nars'') provided by the server, the size the corresponding store
  7178. items occupy in the store (assuming deduplication is turned off), and
  7179. the server's throughput. The second part gives continuous integration
  7180. (CI) statistics, if the server supports it.
  7181. To achieve that, @command{guix weather} queries over HTTP(S) meta-data
  7182. (@dfn{narinfos}) for all the relevant store items. Like @command{guix
  7183. challenge}, it ignores signatures on those substitutes, which is
  7184. innocuous since the command only gathers statistics and cannot install
  7185. those substitutes.
  7186. Among other things, it is possible to query specific system types and
  7187. specific package sets. The available options are listed below.
  7188. @table @code
  7189. @item --substitute-urls=@var{urls}
  7190. @var{urls} is the space-separated list of substitute server URLs to
  7191. query. When this option is omitted, the default set of substitute
  7192. servers is queried.
  7193. @item --system=@var{system}
  7194. @itemx -s @var{system}
  7195. Query substitutes for @var{system}---e.g., @code{aarch64-linux}. This
  7196. option can be repeated, in which case @command{guix weather} will query
  7197. substitutes for several system types.
  7198. @item --manifest=@var{file}
  7199. Instead of querying substitutes for all the packages, only ask for those
  7200. specified in @var{file}. @var{file} must contain a @dfn{manifest}, as
  7201. with the @code{-m} option of @command{guix package} (@pxref{Invoking
  7202. guix package}).
  7203. @end table
  7204. @node Invoking guix processes
  7205. @section Invoking @command{guix processes}
  7206. The @command{guix processes} command can be useful to developers and system
  7207. administrators, especially on multi-user machines and on build farms: it lists
  7208. the current sessions (connections to the daemon), as well as information about
  7209. the processes involved@footnote{Remote sessions, when @command{guix-daemon} is
  7210. started with @option{--listen} specifying a TCP endpoint, are @emph{not}
  7211. listed.}. Here's an example of the information it returns:
  7212. @example
  7213. $ sudo guix processes
  7214. SessionPID: 19002
  7215. ClientPID: 19090
  7216. ClientCommand: guix environment --ad-hoc python
  7217. SessionPID: 19402
  7218. ClientPID: 19367
  7219. ClientCommand: guix publish -u guix-publish -p 3000 -C 9 @dots{}
  7220. SessionPID: 19444
  7221. ClientPID: 19419
  7222. ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{}
  7223. LockHeld: /gnu/store/@dots{}-perl-ipc-cmd-0.96.lock
  7224. LockHeld: /gnu/store/@dots{}-python-six-bootstrap-1.11.0.lock
  7225. LockHeld: /gnu/store/@dots{}-libjpeg-turbo-2.0.0.lock
  7226. ChildProcess: 20495: guix offload x86_64-linux 7200 1 28800
  7227. ChildProcess: 27733: guix offload x86_64-linux 7200 1 28800
  7228. ChildProcess: 27793: guix offload x86_64-linux 7200 1 28800
  7229. @end example
  7230. In this example we see that @command{guix-daemon} has three clients:
  7231. @command{guix environment}, @command{guix publish}, and the Cuirass continuous
  7232. integration tool; their process identifier (PID) is given by the
  7233. @code{ClientPID} field. The @code{SessionPID} field gives the PID of the
  7234. @command{guix-daemon} sub-process of this particular session.
  7235. The @code{LockHeld} fields show which store items are currently locked by this
  7236. session, which corresponds to store items being built or substituted (the
  7237. @code{LockHeld} field is not displayed when @command{guix processes} is not
  7238. running as root.) Last, by looking at the @code{ChildProcess} field, we
  7239. understand that these three builds are being offloaded (@pxref{Daemon Offload
  7240. Setup}).
  7241. The output is in Recutils format so we can use the handy @command{recsel}
  7242. command to select sessions of interest (@pxref{Selection Expressions,,,
  7243. recutils, GNU recutils manual}). As an example, the command shows the command
  7244. line and PID of the client that triggered the build of a Perl package:
  7245. @example
  7246. $ sudo guix processes | \
  7247. recsel -p ClientPID,ClientCommand -e 'LockHeld ~ "perl"'
  7248. ClientPID: 19419
  7249. ClientCommand: cuirass --cache-directory /var/cache/cuirass @dots{}
  7250. @end example
  7251. @c *********************************************************************
  7252. @node GNU Distribution
  7253. @chapter GNU Distribution
  7254. @cindex Guix System Distribution
  7255. @cindex GuixSD
  7256. Guix comes with a distribution of the GNU system consisting entirely of
  7257. free software@footnote{The term ``free'' here refers to the
  7258. @url{http://www.gnu.org/philosophy/free-sw.html,freedom provided to
  7259. users of that software}.}. The
  7260. distribution can be installed on its own (@pxref{System Installation}),
  7261. but it is also possible to install Guix as a package manager on top of
  7262. an installed GNU/Linux system (@pxref{Installation}). To distinguish
  7263. between the two, we refer to the standalone distribution as the Guix
  7264. System Distribution, or GuixSD.
  7265. The distribution provides core GNU packages such as GNU libc, GCC, and
  7266. Binutils, as well as many GNU and non-GNU applications. The complete
  7267. list of available packages can be browsed
  7268. @url{http://www.gnu.org/software/guix/packages,on-line} or by
  7269. running @command{guix package} (@pxref{Invoking guix package}):
  7270. @example
  7271. guix package --list-available
  7272. @end example
  7273. Our goal is to provide a practical 100% free software distribution of
  7274. Linux-based and other variants of GNU, with a focus on the promotion and
  7275. tight integration of GNU components, and an emphasis on programs and
  7276. tools that help users exert that freedom.
  7277. Packages are currently available on the following platforms:
  7278. @table @code
  7279. @item x86_64-linux
  7280. Intel/AMD @code{x86_64} architecture, Linux-Libre kernel;
  7281. @item i686-linux
  7282. Intel 32-bit architecture (IA32), Linux-Libre kernel;
  7283. @item armhf-linux
  7284. ARMv7-A architecture with hard float, Thumb-2 and NEON,
  7285. using the EABI hard-float application binary interface (ABI),
  7286. and Linux-Libre kernel.
  7287. @item aarch64-linux
  7288. little-endian 64-bit ARMv8-A processors, Linux-Libre kernel. This is
  7289. currently in an experimental stage, with limited support.
  7290. @xref{Contributing}, for how to help!
  7291. @item mips64el-linux
  7292. little-endian 64-bit MIPS processors, specifically the Loongson series,
  7293. n32 ABI, and Linux-Libre kernel.
  7294. @end table
  7295. GuixSD itself is currently only available on @code{i686} and @code{x86_64}.
  7296. @noindent
  7297. For information on porting to other architectures or kernels,
  7298. @pxref{Porting}.
  7299. @menu
  7300. * System Installation:: Installing the whole operating system.
  7301. * System Configuration:: Configuring the operating system.
  7302. * Documentation:: Browsing software user manuals.
  7303. * Installing Debugging Files:: Feeding the debugger.
  7304. * Security Updates:: Deploying security fixes quickly.
  7305. * Package Modules:: Packages from the programmer's viewpoint.
  7306. * Packaging Guidelines:: Growing the distribution.
  7307. * Bootstrapping:: GNU/Linux built from scratch.
  7308. * Porting:: Targeting another platform or kernel.
  7309. @end menu
  7310. Building this distribution is a cooperative effort, and you are invited
  7311. to join! @xref{Contributing}, for information about how you can help.
  7312. @node System Installation
  7313. @section System Installation
  7314. @cindex installing GuixSD
  7315. @cindex Guix System Distribution
  7316. This section explains how to install the Guix System Distribution (GuixSD)
  7317. on a machine. The Guix package manager can
  7318. also be installed on top of a running GNU/Linux system,
  7319. @pxref{Installation}.
  7320. @ifinfo
  7321. @quotation Note
  7322. @c This paragraph is for people reading this from tty2 of the
  7323. @c installation image.
  7324. You are reading this documentation with an Info reader. For details on
  7325. how to use it, hit the @key{RET} key (``return'' or ``enter'') on the
  7326. link that follows: @pxref{Top, Info reader,, info-stnd, Stand-alone GNU
  7327. Info}. Hit @kbd{l} afterwards to come back here.
  7328. Alternately, run @command{info info} in another tty to keep the manual
  7329. available.
  7330. @end quotation
  7331. @end ifinfo
  7332. @menu
  7333. * Limitations:: What you can expect.
  7334. * Hardware Considerations:: Supported hardware.
  7335. * USB Stick and DVD Installation:: Preparing the installation medium.
  7336. * Preparing for Installation:: Networking, partitioning, etc.
  7337. * Proceeding with the Installation:: The real thing.
  7338. * Installing GuixSD in a VM:: GuixSD playground.
  7339. * Building the Installation Image:: How this comes to be.
  7340. @end menu
  7341. @node Limitations
  7342. @subsection Limitations
  7343. As of version @value{VERSION}, the Guix System Distribution (GuixSD) is
  7344. not production-ready. It may contain bugs and lack important
  7345. features. Thus, if you are looking for a stable production system that
  7346. respects your freedom as a computer user, a good solution at this point
  7347. is to consider @url{http://www.gnu.org/distros/free-distros.html, one of
  7348. the more established GNU/Linux distributions}. We hope you can soon switch
  7349. to the GuixSD without fear, of course. In the meantime, you can
  7350. also keep using your distribution and try out the package manager on top
  7351. of it (@pxref{Installation}).
  7352. Before you proceed with the installation, be aware of the following
  7353. noteworthy limitations applicable to version @value{VERSION}:
  7354. @itemize
  7355. @item
  7356. The installation process does not include a graphical user interface and
  7357. requires familiarity with GNU/Linux (see the following subsections to
  7358. get a feel of what that means.)
  7359. @item
  7360. Support for the Logical Volume Manager (LVM) is missing.
  7361. @item
  7362. More and more system services are provided (@pxref{Services}), but some
  7363. may be missing.
  7364. @item
  7365. More than 8,500 packages are available, but you might
  7366. occasionally find that a useful package is missing.
  7367. @item
  7368. GNOME, Xfce, LXDE, and Enlightenment are available (@pxref{Desktop Services}),
  7369. as well as a number of X11 window managers. However, some graphical
  7370. applications may be missing, as well as KDE.
  7371. @end itemize
  7372. You have been warned! But more than a disclaimer, this is an invitation
  7373. to report issues (and success stories!), and to join us in improving it.
  7374. @xref{Contributing}, for more info.
  7375. @node Hardware Considerations
  7376. @subsection Hardware Considerations
  7377. @cindex hardware support on GuixSD
  7378. GNU@tie{}GuixSD focuses on respecting the user's computing freedom. It
  7379. builds around the kernel Linux-libre, which means that only hardware for
  7380. which free software drivers and firmware exist is supported. Nowadays,
  7381. a wide range of off-the-shelf hardware is supported on
  7382. GNU/Linux-libre---from keyboards to graphics cards to scanners and
  7383. Ethernet controllers. Unfortunately, there are still areas where
  7384. hardware vendors deny users control over their own computing, and such
  7385. hardware is not supported on GuixSD.
  7386. @cindex WiFi, hardware support
  7387. One of the main areas where free drivers or firmware are lacking is WiFi
  7388. devices. WiFi devices known to work include those using Atheros chips
  7389. (AR9271 and AR7010), which corresponds to the @code{ath9k} Linux-libre
  7390. driver, and those using Broadcom/AirForce chips (BCM43xx with
  7391. Wireless-Core Revision 5), which corresponds to the @code{b43-open}
  7392. Linux-libre driver. Free firmware exists for both and is available
  7393. out-of-the-box on GuixSD, as part of @var{%base-firmware}
  7394. (@pxref{operating-system Reference, @code{firmware}}).
  7395. @cindex RYF, Respects Your Freedom
  7396. The @uref{https://www.fsf.org/, Free Software Foundation} runs
  7397. @uref{https://www.fsf.org/ryf, @dfn{Respects Your Freedom}} (RYF), a
  7398. certification program for hardware products that respect your freedom
  7399. and your privacy and ensure that you have control over your device. We
  7400. encourage you to check the list of RYF-certified devices.
  7401. Another useful resource is the @uref{https://www.h-node.org/, H-Node}
  7402. web site. It contains a catalog of hardware devices with information
  7403. about their support in GNU/Linux.
  7404. @node USB Stick and DVD Installation
  7405. @subsection USB Stick and DVD Installation
  7406. An ISO-9660 installation image that can be written to a USB stick or
  7407. burnt to a DVD can be downloaded from
  7408. @indicateurl{https://alpha.gnu.org/gnu/guix/guixsd-install-@value{VERSION}.@var{system}.iso.xz},
  7409. where @var{system} is one of:
  7410. @table @code
  7411. @item x86_64-linux
  7412. for a GNU/Linux system on Intel/AMD-compatible 64-bit CPUs;
  7413. @item i686-linux
  7414. for a 32-bit GNU/Linux system on Intel-compatible CPUs.
  7415. @end table
  7416. @c start duplication of authentication part from ``Binary Installation''
  7417. Make sure to download the associated @file{.sig} file and to verify the
  7418. authenticity of the image against it, along these lines:
  7419. @example
  7420. $ wget https://alpha.gnu.org/gnu/guix/guixsd-install-@value{VERSION}.@var{system}.iso.xz.sig
  7421. $ gpg --verify guixsd-install-@value{VERSION}.@var{system}.iso.xz.sig
  7422. @end example
  7423. If that command fails because you do not have the required public key,
  7424. then run this command to import it:
  7425. @example
  7426. $ gpg --keyserver @value{KEY-SERVER} \
  7427. --recv-keys @value{OPENPGP-SIGNING-KEY-ID}
  7428. @end example
  7429. @noindent
  7430. and rerun the @code{gpg --verify} command.
  7431. @c end duplication
  7432. This image contains the tools necessary for an installation.
  7433. It is meant to be copied @emph{as is} to a large-enough USB stick or DVD.
  7434. @unnumberedsubsubsec Copying to a USB Stick
  7435. To copy the image to a USB stick, follow these steps:
  7436. @enumerate
  7437. @item
  7438. Decompress the image using the @command{xz} command:
  7439. @example
  7440. xz -d guixsd-install-@value{VERSION}.@var{system}.iso.xz
  7441. @end example
  7442. @item
  7443. Insert a USB stick of 1@tie{}GiB or more into your machine, and determine
  7444. its device name. Assuming that the USB stick is known as @file{/dev/sdX},
  7445. copy the image with:
  7446. @example
  7447. dd if=guixsd-install-@value{VERSION}.@var{system}.iso of=/dev/sdX
  7448. sync
  7449. @end example
  7450. Access to @file{/dev/sdX} usually requires root privileges.
  7451. @end enumerate
  7452. @unnumberedsubsubsec Burning on a DVD
  7453. To copy the image to a DVD, follow these steps:
  7454. @enumerate
  7455. @item
  7456. Decompress the image using the @command{xz} command:
  7457. @example
  7458. xz -d guixsd-install-@value{VERSION}.@var{system}.iso.xz
  7459. @end example
  7460. @item
  7461. Insert a blank DVD into your machine, and determine
  7462. its device name. Assuming that the DVD drive is known as @file{/dev/srX},
  7463. copy the image with:
  7464. @example
  7465. growisofs -dvd-compat -Z /dev/srX=guixsd-install-@value{VERSION}.@var{system}.iso
  7466. @end example
  7467. Access to @file{/dev/srX} usually requires root privileges.
  7468. @end enumerate
  7469. @unnumberedsubsubsec Booting
  7470. Once this is done, you should be able to reboot the system and boot from
  7471. the USB stick or DVD. The latter usually requires you to get in the
  7472. BIOS or UEFI boot menu, where you can choose to boot from the USB stick.
  7473. @xref{Installing GuixSD in a VM}, if, instead, you would like to install
  7474. GuixSD in a virtual machine (VM).
  7475. @node Preparing for Installation
  7476. @subsection Preparing for Installation
  7477. Once you have successfully booted your computer using the installation medium,
  7478. you should end up with a root prompt. Several console TTYs are configured
  7479. and can be used to run commands as root. TTY2 shows this documentation,
  7480. browsable using the Info reader commands (@pxref{Top,,, info-stnd,
  7481. Stand-alone GNU Info}). The installation system runs the GPM mouse
  7482. daemon, which allows you to select text with the left mouse button and
  7483. to paste it with the middle button.
  7484. @quotation Note
  7485. Installation requires access to the Internet so that any missing
  7486. dependencies of your system configuration can be downloaded. See the
  7487. ``Networking'' section below.
  7488. @end quotation
  7489. The installation system includes many common tools needed for this task.
  7490. But it is also a full-blown GuixSD system, which means that you can
  7491. install additional packages, should you need it, using @command{guix
  7492. package} (@pxref{Invoking guix package}).
  7493. @subsubsection Keyboard Layout
  7494. @cindex keyboard layout
  7495. The installation image uses the US qwerty keyboard layout. If you want
  7496. to change it, you can use the @command{loadkeys} command. For example,
  7497. the following command selects the Dvorak keyboard layout:
  7498. @example
  7499. loadkeys dvorak
  7500. @end example
  7501. See the files under @file{/run/current-system/profile/share/keymaps} for
  7502. a list of available keyboard layouts. Run @command{man loadkeys} for
  7503. more information.
  7504. @subsubsection Networking
  7505. Run the following command to see what your network interfaces are called:
  7506. @example
  7507. ifconfig -a
  7508. @end example
  7509. @noindent
  7510. @dots{} or, using the GNU/Linux-specific @command{ip} command:
  7511. @example
  7512. ip a
  7513. @end example
  7514. @c http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-net_id.c#n20
  7515. Wired interfaces have a name starting with @samp{e}; for example, the
  7516. interface corresponding to the first on-board Ethernet controller is
  7517. called @samp{eno1}. Wireless interfaces have a name starting with
  7518. @samp{w}, like @samp{w1p2s0}.
  7519. @table @asis
  7520. @item Wired connection
  7521. To configure a wired network run the following command, substituting
  7522. @var{interface} with the name of the wired interface you want to use.
  7523. @example
  7524. ifconfig @var{interface} up
  7525. @end example
  7526. @item Wireless connection
  7527. @cindex wireless
  7528. @cindex WiFi
  7529. To configure wireless networking, you can create a configuration file
  7530. for the @command{wpa_supplicant} configuration tool (its location is not
  7531. important) using one of the available text editors such as
  7532. @command{nano}:
  7533. @example
  7534. nano wpa_supplicant.conf
  7535. @end example
  7536. As an example, the following stanza can go to this file and will work
  7537. for many wireless networks, provided you give the actual SSID and
  7538. passphrase for the network you are connecting to:
  7539. @example
  7540. network=@{
  7541. ssid="@var{my-ssid}"
  7542. key_mgmt=WPA-PSK
  7543. psk="the network's secret passphrase"
  7544. @}
  7545. @end example
  7546. Start the wireless service and run it in the background with the
  7547. following command (substitute @var{interface} with the name of the
  7548. network interface you want to use):
  7549. @example
  7550. wpa_supplicant -c wpa_supplicant.conf -i @var{interface} -B
  7551. @end example
  7552. Run @command{man wpa_supplicant} for more information.
  7553. @end table
  7554. @cindex DHCP
  7555. At this point, you need to acquire an IP address. On a network where IP
  7556. addresses are automatically assigned @i{via} DHCP, you can run:
  7557. @example
  7558. dhclient -v @var{interface}
  7559. @end example
  7560. Try to ping a server to see if networking is up and running:
  7561. @example
  7562. ping -c 3 gnu.org
  7563. @end example
  7564. Setting up network access is almost always a requirement because the
  7565. image does not contain all the software and tools that may be needed.
  7566. @cindex installing over SSH
  7567. If you want to, you can continue the installation remotely by starting
  7568. an SSH server:
  7569. @example
  7570. herd start ssh-daemon
  7571. @end example
  7572. Make sure to either set a password with @command{passwd}, or configure
  7573. OpenSSH public key authentication before logging in.
  7574. @subsubsection Disk Partitioning
  7575. Unless this has already been done, the next step is to partition, and
  7576. then format the target partition(s).
  7577. The installation image includes several partitioning tools, including
  7578. Parted (@pxref{Overview,,, parted, GNU Parted User Manual}),
  7579. @command{fdisk}, and @command{cfdisk}. Run it and set up your disk with
  7580. the partition layout you want:
  7581. @example
  7582. cfdisk
  7583. @end example
  7584. If your disk uses the GUID Partition Table (GPT) format and you plan to
  7585. install BIOS-based GRUB (which is the default), make sure a BIOS Boot
  7586. Partition is available (@pxref{BIOS installation,,, grub, GNU GRUB
  7587. manual}).
  7588. @cindex EFI, installation
  7589. @cindex UEFI, installation
  7590. @cindex ESP, EFI system partition
  7591. If you instead wish to use EFI-based GRUB, a FAT32 @dfn{EFI System Partition}
  7592. (ESP) is required. This partition should be mounted at @file{/boot/efi} and
  7593. must have the @code{esp} flag set. E.g., for @command{parted}:
  7594. @example
  7595. parted /dev/sda set 1 esp on
  7596. @end example
  7597. @quotation Note
  7598. @vindex grub-bootloader
  7599. @vindex grub-efi-bootloader
  7600. Unsure whether to use EFI- or BIOS-based GRUB? If the directory
  7601. @file{/sys/firmware/efi} exists in the installation image, then you should
  7602. probably perform an EFI installation, using @code{grub-efi-bootloader}.
  7603. Otherwise you should use the BIOS-based GRUB, known as
  7604. @code{grub-bootloader}. @xref{Bootloader Configuration}, for more info on
  7605. bootloaders.
  7606. @end quotation
  7607. Once you are done partitioning the target hard disk drive, you have to
  7608. create a file system on the relevant partition(s)@footnote{Currently
  7609. GuixSD only supports ext4 and btrfs file systems. In particular, code
  7610. that reads file system UUIDs and labels only works for these file system
  7611. types.}. For the ESP, if you have one and assuming it is
  7612. @file{/dev/sda1}, run:
  7613. @example
  7614. mkfs.fat -F32 /dev/sda1
  7615. @end example
  7616. Preferably, assign file systems a label so that you can easily and
  7617. reliably refer to them in @code{file-system} declarations (@pxref{File
  7618. Systems}). This is typically done using the @code{-L} option of
  7619. @command{mkfs.ext4} and related commands. So, assuming the target root
  7620. partition lives at @file{/dev/sda2}, a file system with the label
  7621. @code{my-root} can be created with:
  7622. @example
  7623. mkfs.ext4 -L my-root /dev/sda2
  7624. @end example
  7625. @cindex encrypted disk
  7626. If you are instead planning to encrypt the root partition, you can use
  7627. the Cryptsetup/LUKS utilities to do that (see @inlinefmtifelse{html,
  7628. @uref{https://linux.die.net/man/8/cryptsetup, @code{man cryptsetup}},
  7629. @code{man cryptsetup}} for more information.) Assuming you want to
  7630. store the root partition on @file{/dev/sda2}, the command sequence would
  7631. be along these lines:
  7632. @example
  7633. cryptsetup luksFormat /dev/sda2
  7634. cryptsetup open --type luks /dev/sda2 my-partition
  7635. mkfs.ext4 -L my-root /dev/mapper/my-partition
  7636. @end example
  7637. Once that is done, mount the target file system under @file{/mnt}
  7638. with a command like (again, assuming @code{my-root} is the label of the
  7639. root file system):
  7640. @example
  7641. mount LABEL=my-root /mnt
  7642. @end example
  7643. Also mount any other file systems you would like to use on the target
  7644. system relative to this path. If you have @file{/boot} on a separate
  7645. partition for example, mount it at @file{/mnt/boot} now so it is found
  7646. by @code{guix system init} afterwards.
  7647. Finally, if you plan to use one or more swap partitions (@pxref{Memory
  7648. Concepts, swap space,, libc, The GNU C Library Reference Manual}), make
  7649. sure to initialize them with @command{mkswap}. Assuming you have one
  7650. swap partition on @file{/dev/sda3}, you would run:
  7651. @example
  7652. mkswap /dev/sda3
  7653. swapon /dev/sda3
  7654. @end example
  7655. Alternatively, you may use a swap file. For example, assuming that in
  7656. the new system you want to use the file @file{/swapfile} as a swap file,
  7657. you would run@footnote{This example will work for many types of file
  7658. systems (e.g., ext4). However, for copy-on-write file systems (e.g.,
  7659. btrfs), the required steps may be different. For details, see the
  7660. manual pages for @command{mkswap} and @command{swapon}.}:
  7661. @example
  7662. # This is 10 GiB of swap space. Adjust "count" to change the size.
  7663. dd if=/dev/zero of=/mnt/swapfile bs=1MiB count=10240
  7664. # For security, make the file readable and writable only by root.
  7665. chmod 600 /mnt/swapfile
  7666. mkswap /mnt/swapfile
  7667. swapon /mnt/swapfile
  7668. @end example
  7669. Note that if you have encrypted the root partition and created a swap
  7670. file in its file system as described above, then the encryption also
  7671. protects the swap file, just like any other file in that file system.
  7672. @node Proceeding with the Installation
  7673. @subsection Proceeding with the Installation
  7674. With the target partitions ready and the target root mounted on
  7675. @file{/mnt}, we're ready to go. First, run:
  7676. @example
  7677. herd start cow-store /mnt
  7678. @end example
  7679. This makes @file{/gnu/store} copy-on-write, such that packages added to it
  7680. during the installation phase are written to the target disk on @file{/mnt}
  7681. rather than kept in memory. This is necessary because the first phase of
  7682. the @command{guix system init} command (see below) entails downloads or
  7683. builds to @file{/gnu/store} which, initially, is an in-memory file system.
  7684. Next, you have to edit a file and
  7685. provide the declaration of the operating system to be installed. To
  7686. that end, the installation system comes with three text editors. We
  7687. recommend GNU nano (@pxref{Top,,, nano, GNU nano Manual}), which
  7688. supports syntax highlighting and parentheses matching; other editors
  7689. include GNU Zile (an Emacs clone), and
  7690. nvi (a clone of the original BSD @command{vi} editor).
  7691. We strongly recommend storing that file on the target root file system, say,
  7692. as @file{/mnt/etc/config.scm}. Failing to do that, you will have lost your
  7693. configuration file once you have rebooted into the newly-installed system.
  7694. @xref{Using the Configuration System}, for an overview of the
  7695. configuration file. The example configurations discussed in that
  7696. section are available under @file{/etc/configuration} in the
  7697. installation image. Thus, to get started with a system configuration
  7698. providing a graphical display server (a ``desktop'' system), you can run
  7699. something along these lines:
  7700. @example
  7701. # mkdir /mnt/etc
  7702. # cp /etc/configuration/desktop.scm /mnt/etc/config.scm
  7703. # nano /mnt/etc/config.scm
  7704. @end example
  7705. You should pay attention to what your configuration file contains, and
  7706. in particular:
  7707. @itemize
  7708. @item
  7709. Make sure the @code{bootloader-configuration} form refers to the target
  7710. you want to install GRUB on. It should mention @code{grub-bootloader} if
  7711. you are installing GRUB in the legacy way, or @code{grub-efi-bootloader}
  7712. for newer UEFI systems. For legacy systems, the @code{target} field
  7713. names a device, like @code{/dev/sda}; for UEFI systems it names a path
  7714. to a mounted EFI partition, like @code{/boot/efi}, and do make sure the
  7715. path is actually mounted.
  7716. @item
  7717. Be sure that your file system labels match the value of their respective
  7718. @code{device} fields in your @code{file-system} configuration, assuming
  7719. your @code{file-system} configuration uses the @code{file-system-label}
  7720. procedure in its @code{device} field.
  7721. @item
  7722. If there are encrypted or RAID partitions, make sure to add a
  7723. @code{mapped-devices} field to describe them (@pxref{Mapped Devices}).
  7724. @end itemize
  7725. Once you are done preparing the configuration file, the new system must
  7726. be initialized (remember that the target root file system is mounted
  7727. under @file{/mnt}):
  7728. @example
  7729. guix system init /mnt/etc/config.scm /mnt
  7730. @end example
  7731. @noindent
  7732. This copies all the necessary files and installs GRUB on
  7733. @file{/dev/sdX}, unless you pass the @option{--no-bootloader} option. For
  7734. more information, @pxref{Invoking guix system}. This command may trigger
  7735. downloads or builds of missing packages, which can take some time.
  7736. Once that command has completed---and hopefully succeeded!---you can run
  7737. @command{reboot} and boot into the new system. The @code{root} password
  7738. in the new system is initially empty; other users' passwords need to be
  7739. initialized by running the @command{passwd} command as @code{root},
  7740. unless your configuration specifies otherwise
  7741. (@pxref{user-account-password, user account passwords}).
  7742. @cindex upgrading GuixSD
  7743. From then on, you can update GuixSD whenever you want by running
  7744. @command{guix pull} as @code{root} (@pxref{Invoking guix pull}), and
  7745. then running @command{guix system reconfigure} to build a new system
  7746. generation with the latest packages and services (@pxref{Invoking guix
  7747. system}). We recommend doing that regularly so that your system
  7748. includes the latest security updates (@pxref{Security Updates}).
  7749. Join us on @code{#guix} on the Freenode IRC network or on
  7750. @email{guix-devel@@gnu.org} to share your experience---good or not so
  7751. good.
  7752. @node Installing GuixSD in a VM
  7753. @subsection Installing GuixSD in a Virtual Machine
  7754. @cindex virtual machine, GuixSD installation
  7755. @cindex virtual private server (VPS)
  7756. @cindex VPS (virtual private server)
  7757. If you'd like to install GuixSD in a virtual machine (VM) or on a
  7758. virtual private server (VPS) rather than on your beloved machine, this
  7759. section is for you.
  7760. To boot a @uref{http://qemu.org/,QEMU} VM for installing GuixSD in a
  7761. disk image, follow these steps:
  7762. @enumerate
  7763. @item
  7764. First, retrieve and decompress the GuixSD installation image as
  7765. described previously (@pxref{USB Stick and DVD Installation}).
  7766. @item
  7767. Create a disk image that will hold the installed system. To make a
  7768. qcow2-formatted disk image, use the @command{qemu-img} command:
  7769. @example
  7770. qemu-img create -f qcow2 guixsd.img 50G
  7771. @end example
  7772. The resulting file will be much smaller than 50 GB (typically less than
  7773. 1 MB), but it will grow as the virtualized storage device is filled up.
  7774. @item
  7775. Boot the USB installation image in an VM:
  7776. @example
  7777. qemu-system-x86_64 -m 1024 -smp 1 \
  7778. -net user -net nic,model=virtio -boot menu=on \
  7779. -drive file=guixsd-install-@value{VERSION}.@var{system}.iso \
  7780. -drive file=guixsd.img
  7781. @end example
  7782. The ordering of the drives matters.
  7783. In the VM console, quickly press the @kbd{F12} key to enter the boot
  7784. menu. Then press the @kbd{2} key and the @kbd{RET} key to validate your
  7785. selection.
  7786. @item
  7787. You're now root in the VM, proceed with the installation process.
  7788. @xref{Preparing for Installation}, and follow the instructions.
  7789. @end enumerate
  7790. Once installation is complete, you can boot the system that's on your
  7791. @file{guixsd.img} image. @xref{Running GuixSD in a VM}, for how to do
  7792. that.
  7793. @node Building the Installation Image
  7794. @subsection Building the Installation Image
  7795. @cindex installation image
  7796. The installation image described above was built using the @command{guix
  7797. system} command, specifically:
  7798. @example
  7799. guix system disk-image gnu/system/install.scm
  7800. @end example
  7801. Have a look at @file{gnu/system/install.scm} in the source tree,
  7802. and see also @ref{Invoking guix system} for more information
  7803. about the installation image.
  7804. @subsection Building the Installation Image for ARM Boards
  7805. Many ARM boards require a specific variant of the
  7806. @uref{http://www.denx.de/wiki/U-Boot/, U-Boot} bootloader.
  7807. If you build a disk image and the bootloader is not available otherwise
  7808. (on another boot drive etc), it's advisable to build an image that
  7809. includes the bootloader, specifically:
  7810. @example
  7811. guix system disk-image --system=armhf-linux -e '((@@ (gnu system install) os-with-u-boot) (@@ (gnu system install) installation-os) "A20-OLinuXino-Lime2")'
  7812. @end example
  7813. @code{A20-OLinuXino-Lime2} is the name of the board. If you specify an invalid
  7814. board, a list of possible boards will be printed.
  7815. @node System Configuration
  7816. @section System Configuration
  7817. @cindex system configuration
  7818. The Guix System Distribution supports a consistent whole-system configuration
  7819. mechanism. By that we mean that all aspects of the global system
  7820. configuration---such as the available system services, timezone and
  7821. locale settings, user accounts---are declared in a single place. Such
  7822. a @dfn{system configuration} can be @dfn{instantiated}---i.e., effected.
  7823. One of the advantages of putting all the system configuration under the
  7824. control of Guix is that it supports transactional system upgrades, and
  7825. makes it possible to roll back to a previous system instantiation,
  7826. should something go wrong with the new one (@pxref{Features}). Another
  7827. advantage is that it makes it easy to replicate the exact same configuration
  7828. across different machines, or at different points in time, without
  7829. having to resort to additional administration tools layered on top of
  7830. the own tools of the system.
  7831. @c Yes, we're talking of Puppet, Chef, & co. here. ↑
  7832. This section describes this mechanism. First we focus on the system
  7833. administrator's viewpoint---explaining how the system is configured and
  7834. instantiated. Then we show how this mechanism can be extended, for
  7835. instance to support new system services.
  7836. @menu
  7837. * Using the Configuration System:: Customizing your GNU system.
  7838. * operating-system Reference:: Detail of operating-system declarations.
  7839. * File Systems:: Configuring file system mounts.
  7840. * Mapped Devices:: Block device extra processing.
  7841. * User Accounts:: Specifying user accounts.
  7842. * Locales:: Language and cultural convention settings.
  7843. * Services:: Specifying system services.
  7844. * Setuid Programs:: Programs running with root privileges.
  7845. * X.509 Certificates:: Authenticating HTTPS servers.
  7846. * Name Service Switch:: Configuring libc's name service switch.
  7847. * Initial RAM Disk:: Linux-Libre bootstrapping.
  7848. * Bootloader Configuration:: Configuring the boot loader.
  7849. * Invoking guix system:: Instantiating a system configuration.
  7850. * Running GuixSD in a VM:: How to run GuixSD in a virtual machine.
  7851. * Defining Services:: Adding new service definitions.
  7852. @end menu
  7853. @node Using the Configuration System
  7854. @subsection Using the Configuration System
  7855. The operating system is configured by providing an
  7856. @code{operating-system} declaration in a file that can then be passed to
  7857. the @command{guix system} command (@pxref{Invoking guix system}). A
  7858. simple setup, with the default system services, the default Linux-Libre
  7859. kernel, initial RAM disk, and boot loader looks like this:
  7860. @findex operating-system
  7861. @lisp
  7862. @include os-config-bare-bones.texi
  7863. @end lisp
  7864. This example should be self-describing. Some of the fields defined
  7865. above, such as @code{host-name} and @code{bootloader}, are mandatory.
  7866. Others, such as @code{packages} and @code{services}, can be omitted, in
  7867. which case they get a default value.
  7868. Below we discuss the effect of some of the most important fields
  7869. (@pxref{operating-system Reference}, for details about all the available
  7870. fields), and how to @dfn{instantiate} the operating system using
  7871. @command{guix system}.
  7872. @unnumberedsubsubsec Bootloader
  7873. @cindex legacy boot, on Intel machines
  7874. @cindex BIOS boot, on Intel machines
  7875. @cindex UEFI boot
  7876. @cindex EFI boot
  7877. The @code{bootloader} field describes the method that will be used to boot
  7878. your system. Machines based on Intel processors can boot in ``legacy'' BIOS
  7879. mode, as in the example above. However, more recent machines rely instead on
  7880. the @dfn{Unified Extensible Firmware Interface} (UEFI) to boot. In that case,
  7881. the @code{bootloader} field should contain something along these lines:
  7882. @example
  7883. (bootloader-configuration
  7884. (bootloader grub-efi-bootloader)
  7885. (target "/boot/efi"))
  7886. @end example
  7887. @xref{Bootloader Configuration}, for more information on the available
  7888. configuration options.
  7889. @unnumberedsubsubsec Globally-Visible Packages
  7890. @vindex %base-packages
  7891. The @code{packages} field lists packages that will be globally visible
  7892. on the system, for all user accounts---i.e., in every user's @code{PATH}
  7893. environment variable---in addition to the per-user profiles
  7894. (@pxref{Invoking guix package}). The @var{%base-packages} variable
  7895. provides all the tools one would expect for basic user and administrator
  7896. tasks---including the GNU Core Utilities, the GNU Networking Utilities,
  7897. the GNU Zile lightweight text editor, @command{find}, @command{grep},
  7898. etc. The example above adds GNU@tie{}Screen to those,
  7899. taken from the @code{(gnu packages screen)}
  7900. module (@pxref{Package Modules}). The
  7901. @code{(list package output)} syntax can be used to add a specific output
  7902. of a package:
  7903. @lisp
  7904. (use-modules (gnu packages))
  7905. (use-modules (gnu packages dns))
  7906. (operating-system
  7907. ;; ...
  7908. (packages (cons (list bind "utils")
  7909. %base-packages)))
  7910. @end lisp
  7911. @findex specification->package
  7912. Referring to packages by variable name, like @code{bind} above, has
  7913. the advantage of being unambiguous; it also allows typos and such to be
  7914. diagnosed right away as ``unbound variables''. The downside is that one
  7915. needs to know which module defines which package, and to augment the
  7916. @code{use-package-modules} line accordingly. To avoid that, one can use
  7917. the @code{specification->package} procedure of the @code{(gnu packages)}
  7918. module, which returns the best package for a given name or name and
  7919. version:
  7920. @lisp
  7921. (use-modules (gnu packages))
  7922. (operating-system
  7923. ;; ...
  7924. (packages (append (map specification->package
  7925. '("tcpdump" "htop" "gnupg@@2.0"))
  7926. %base-packages)))
  7927. @end lisp
  7928. @unnumberedsubsubsec System Services
  7929. @cindex services
  7930. @vindex %base-services
  7931. The @code{services} field lists @dfn{system services} to be made
  7932. available when the system starts (@pxref{Services}).
  7933. The @code{operating-system} declaration above specifies that, in
  7934. addition to the basic services, we want the @command{lshd} secure shell
  7935. daemon listening on port 2222 (@pxref{Networking Services,
  7936. @code{lsh-service}}). Under the hood,
  7937. @code{lsh-service} arranges so that @code{lshd} is started with the
  7938. right command-line options, possibly with supporting configuration files
  7939. generated as needed (@pxref{Defining Services}).
  7940. @cindex customization, of services
  7941. @findex modify-services
  7942. Occasionally, instead of using the base services as is, you will want to
  7943. customize them. To do this, use @code{modify-services} (@pxref{Service
  7944. Reference, @code{modify-services}}) to modify the list.
  7945. For example, suppose you want to modify @code{guix-daemon} and Mingetty
  7946. (the console log-in) in the @var{%base-services} list (@pxref{Base
  7947. Services, @code{%base-services}}). To do that, you can write the
  7948. following in your operating system declaration:
  7949. @lisp
  7950. (define %my-services
  7951. ;; My very own list of services.
  7952. (modify-services %base-services
  7953. (guix-service-type config =>
  7954. (guix-configuration
  7955. (inherit config)
  7956. (use-substitutes? #f)
  7957. (extra-options '("--gc-keep-derivations"))))
  7958. (mingetty-service-type config =>
  7959. (mingetty-configuration
  7960. (inherit config)))))
  7961. (operating-system
  7962. ;; @dots{}
  7963. (services %my-services))
  7964. @end lisp
  7965. This changes the configuration---i.e., the service parameters---of the
  7966. @code{guix-service-type} instance, and that of all the
  7967. @code{mingetty-service-type} instances in the @var{%base-services} list.
  7968. Observe how this is accomplished: first, we arrange for the original
  7969. configuration to be bound to the identifier @code{config} in the
  7970. @var{body}, and then we write the @var{body} so that it evaluates to the
  7971. desired configuration. In particular, notice how we use @code{inherit}
  7972. to create a new configuration which has the same values as the old
  7973. configuration, but with a few modifications.
  7974. @cindex encrypted disk
  7975. The configuration for a typical ``desktop'' usage, with an encrypted
  7976. root partition, the X11 display
  7977. server, GNOME and Xfce (users can choose which of these desktop
  7978. environments to use at the log-in screen by pressing @kbd{F1}), network
  7979. management, power management, and more, would look like this:
  7980. @lisp
  7981. @include os-config-desktop.texi
  7982. @end lisp
  7983. A graphical system with a choice of lightweight window managers
  7984. instead of full-blown desktop environments would look like this:
  7985. @lisp
  7986. @include os-config-lightweight-desktop.texi
  7987. @end lisp
  7988. This example refers to the @file{/boot/efi} file system by its UUID,
  7989. @code{1234-ABCD}. Replace this UUID with the right UUID on your system,
  7990. as returned by the @command{blkid} command.
  7991. @xref{Desktop Services}, for the exact list of services provided by
  7992. @var{%desktop-services}. @xref{X.509 Certificates}, for background
  7993. information about the @code{nss-certs} package that is used here.
  7994. Again, @var{%desktop-services} is just a list of service objects. If
  7995. you want to remove services from there, you can do so using the
  7996. procedures for list filtering (@pxref{SRFI-1 Filtering and
  7997. Partitioning,,, guile, GNU Guile Reference Manual}). For instance, the
  7998. following expression returns a list that contains all the services in
  7999. @var{%desktop-services} minus the Avahi service:
  8000. @example
  8001. (remove (lambda (service)
  8002. (eq? (service-kind service) avahi-service-type))
  8003. %desktop-services)
  8004. @end example
  8005. @unnumberedsubsubsec Instantiating the System
  8006. Assuming the @code{operating-system} declaration
  8007. is stored in the @file{my-system-config.scm}
  8008. file, the @command{guix system reconfigure my-system-config.scm} command
  8009. instantiates that configuration, and makes it the default GRUB boot
  8010. entry (@pxref{Invoking guix system}).
  8011. The normal way to change the system configuration is by updating this
  8012. file and re-running @command{guix system reconfigure}. One should never
  8013. have to touch files in @file{/etc} or to run commands that modify the
  8014. system state such as @command{useradd} or @command{grub-install}. In
  8015. fact, you must avoid that since that would not only void your warranty
  8016. but also prevent you from rolling back to previous versions of your
  8017. system, should you ever need to.
  8018. @cindex roll-back, of the operating system
  8019. Speaking of roll-back, each time you run @command{guix system
  8020. reconfigure}, a new @dfn{generation} of the system is created---without
  8021. modifying or deleting previous generations. Old system generations get
  8022. an entry in the bootloader boot menu, allowing you to boot them in case
  8023. something went wrong with the latest generation. Reassuring, no? The
  8024. @command{guix system list-generations} command lists the system
  8025. generations available on disk. It is also possible to roll back the
  8026. system via the commands @command{guix system roll-back} and
  8027. @command{guix system switch-generation}.
  8028. Although the @command{guix system reconfigure} command will not modify
  8029. previous generations, you must take care when the current generation is not
  8030. the latest (e.g., after invoking @command{guix system roll-back}), since
  8031. the operation might overwrite a later generation (@pxref{Invoking guix
  8032. system}).
  8033. @unnumberedsubsubsec The Programming Interface
  8034. At the Scheme level, the bulk of an @code{operating-system} declaration
  8035. is instantiated with the following monadic procedure (@pxref{The Store
  8036. Monad}):
  8037. @deffn {Monadic Procedure} operating-system-derivation os
  8038. Return a derivation that builds @var{os}, an @code{operating-system}
  8039. object (@pxref{Derivations}).
  8040. The output of the derivation is a single directory that refers to all
  8041. the packages, configuration files, and other supporting files needed to
  8042. instantiate @var{os}.
  8043. @end deffn
  8044. This procedure is provided by the @code{(gnu system)} module. Along
  8045. with @code{(gnu services)} (@pxref{Services}), this module contains the
  8046. guts of GuixSD. Make sure to visit it!
  8047. @node operating-system Reference
  8048. @subsection @code{operating-system} Reference
  8049. This section summarizes all the options available in
  8050. @code{operating-system} declarations (@pxref{Using the Configuration
  8051. System}).
  8052. @deftp {Data Type} operating-system
  8053. This is the data type representing an operating system configuration.
  8054. By that, we mean all the global system configuration, not per-user
  8055. configuration (@pxref{Using the Configuration System}).
  8056. @table @asis
  8057. @item @code{kernel} (default: @var{linux-libre})
  8058. The package object of the operating system kernel to use@footnote{Currently
  8059. only the Linux-libre kernel is supported. In the future, it will be
  8060. possible to use the GNU@tie{}Hurd.}.
  8061. @item @code{kernel-arguments} (default: @code{'()})
  8062. List of strings or gexps representing additional arguments to pass on
  8063. the command-line of the kernel---e.g., @code{("console=ttyS0")}.
  8064. @item @code{bootloader}
  8065. The system bootloader configuration object. @xref{Bootloader Configuration}.
  8066. @item @code{initrd-modules} (default: @code{%base-initrd-modules})
  8067. @cindex initrd
  8068. @cindex initial RAM disk
  8069. The list of Linux kernel modules that need to be available in the
  8070. initial RAM disk. @xref{Initial RAM Disk}.
  8071. @item @code{initrd} (default: @code{base-initrd})
  8072. A procedure that returns an initial RAM disk for the Linux
  8073. kernel. This field is provided to support low-level customization and
  8074. should rarely be needed for casual use. @xref{Initial RAM Disk}.
  8075. @item @code{firmware} (default: @var{%base-firmware})
  8076. @cindex firmware
  8077. List of firmware packages loadable by the operating system kernel.
  8078. The default includes firmware needed for Atheros- and Broadcom-based
  8079. WiFi devices (Linux-libre modules @code{ath9k} and @code{b43-open},
  8080. respectively). @xref{Hardware Considerations}, for more info on
  8081. supported hardware.
  8082. @item @code{host-name}
  8083. The host name.
  8084. @item @code{hosts-file}
  8085. @cindex hosts file
  8086. A file-like object (@pxref{G-Expressions, file-like objects}) for use as
  8087. @file{/etc/hosts} (@pxref{Host Names,,, libc, The GNU C Library
  8088. Reference Manual}). The default is a file with entries for
  8089. @code{localhost} and @var{host-name}.
  8090. @item @code{mapped-devices} (default: @code{'()})
  8091. A list of mapped devices. @xref{Mapped Devices}.
  8092. @item @code{file-systems}
  8093. A list of file systems. @xref{File Systems}.
  8094. @item @code{swap-devices} (default: @code{'()})
  8095. @cindex swap devices
  8096. A list of strings identifying devices or files to be used for ``swap
  8097. space'' (@pxref{Memory Concepts,,, libc, The GNU C Library Reference
  8098. Manual}). For example, @code{'("/dev/sda3")} or @code{'("/swapfile")}.
  8099. It is possible to specify a swap file in a file system on a mapped
  8100. device, provided that the necessary device mapping and file system are
  8101. also specified. @xref{Mapped Devices} and @ref{File Systems}.
  8102. @item @code{users} (default: @code{%base-user-accounts})
  8103. @itemx @code{groups} (default: @var{%base-groups})
  8104. List of user accounts and groups. @xref{User Accounts}.
  8105. If the @code{users} list lacks a user account with UID@tie{}0, a
  8106. ``root'' account with UID@tie{}0 is automatically added.
  8107. @item @code{skeletons} (default: @code{(default-skeletons)})
  8108. A list target file name/file-like object tuples (@pxref{G-Expressions,
  8109. file-like objects}). These are the skeleton files that will be added to
  8110. the home directory of newly-created user accounts.
  8111. For instance, a valid value may look like this:
  8112. @example
  8113. `((".bashrc" ,(plain-file "bashrc" "echo Hello\n"))
  8114. (".guile" ,(plain-file "guile"
  8115. "(use-modules (ice-9 readline))
  8116. (activate-readline)")))
  8117. @end example
  8118. @item @code{issue} (default: @var{%default-issue})
  8119. A string denoting the contents of the @file{/etc/issue} file, which is
  8120. displayed when users log in on a text console.
  8121. @item @code{packages} (default: @var{%base-packages})
  8122. The set of packages installed in the global profile, which is accessible
  8123. at @file{/run/current-system/profile}.
  8124. The default set includes core utilities and it is good practice to
  8125. install non-core utilities in user profiles (@pxref{Invoking guix
  8126. package}).
  8127. @item @code{timezone}
  8128. A timezone identifying string---e.g., @code{"Europe/Paris"}.
  8129. You can run the @command{tzselect} command to find out which timezone
  8130. string corresponds to your region. Choosing an invalid timezone name
  8131. causes @command{guix system} to fail.
  8132. @item @code{locale} (default: @code{"en_US.utf8"})
  8133. The name of the default locale (@pxref{Locale Names,,, libc, The GNU C
  8134. Library Reference Manual}). @xref{Locales}, for more information.
  8135. @item @code{locale-definitions} (default: @var{%default-locale-definitions})
  8136. The list of locale definitions to be compiled and that may be used at
  8137. run time. @xref{Locales}.
  8138. @item @code{locale-libcs} (default: @code{(list @var{glibc})})
  8139. The list of GNU@tie{}libc packages whose locale data and tools are used
  8140. to build the locale definitions. @xref{Locales}, for compatibility
  8141. considerations that justify this option.
  8142. @item @code{name-service-switch} (default: @var{%default-nss})
  8143. Configuration of the libc name service switch (NSS)---a
  8144. @code{<name-service-switch>} object. @xref{Name Service Switch}, for
  8145. details.
  8146. @item @code{services} (default: @var{%base-services})
  8147. A list of service objects denoting system services. @xref{Services}.
  8148. @item @code{pam-services} (default: @code{(base-pam-services)})
  8149. @cindex PAM
  8150. @cindex pluggable authentication modules
  8151. Linux @dfn{pluggable authentication module} (PAM) services.
  8152. @c FIXME: Add xref to PAM services section.
  8153. @item @code{setuid-programs} (default: @var{%setuid-programs})
  8154. List of string-valued G-expressions denoting setuid programs.
  8155. @xref{Setuid Programs}.
  8156. @item @code{sudoers-file} (default: @var{%sudoers-specification})
  8157. @cindex sudoers file
  8158. The contents of the @file{/etc/sudoers} file as a file-like object
  8159. (@pxref{G-Expressions, @code{local-file} and @code{plain-file}}).
  8160. This file specifies which users can use the @command{sudo} command, what
  8161. they are allowed to do, and what privileges they may gain. The default
  8162. is that only @code{root} and members of the @code{wheel} group may use
  8163. @code{sudo}.
  8164. @end table
  8165. @end deftp
  8166. @node File Systems
  8167. @subsection File Systems
  8168. The list of file systems to be mounted is specified in the
  8169. @code{file-systems} field of the operating system declaration
  8170. (@pxref{Using the Configuration System}). Each file system is declared
  8171. using the @code{file-system} form, like this:
  8172. @example
  8173. (file-system
  8174. (mount-point "/home")
  8175. (device "/dev/sda3")
  8176. (type "ext4"))
  8177. @end example
  8178. As usual, some of the fields are mandatory---those shown in the example
  8179. above---while others can be omitted. These are described below.
  8180. @deftp {Data Type} file-system
  8181. Objects of this type represent file systems to be mounted. They
  8182. contain the following members:
  8183. @table @asis
  8184. @item @code{type}
  8185. This is a string specifying the type of the file system---e.g.,
  8186. @code{"ext4"}.
  8187. @item @code{mount-point}
  8188. This designates the place where the file system is to be mounted.
  8189. @item @code{device}
  8190. This names the ``source'' of the file system. It can be one of three
  8191. things: a file system label, a file system UUID, or the name of a
  8192. @file{/dev} node. Labels and UUIDs offer a way to refer to file
  8193. systems without having to hard-code their actual device
  8194. name@footnote{Note that, while it is tempting to use
  8195. @file{/dev/disk/by-uuid} and similar device names to achieve the same
  8196. result, this is not recommended: These special device nodes are created
  8197. by the udev daemon and may be unavailable at the time the device is
  8198. mounted.}.
  8199. @findex file-system-label
  8200. File system labels are created using the @code{file-system-label}
  8201. procedure, UUIDs are created using @code{uuid}, and @file{/dev} node are
  8202. plain strings. Here's an example of a file system referred to by its
  8203. label, as shown by the @command{e2label} command:
  8204. @example
  8205. (file-system
  8206. (mount-point "/home")
  8207. (type "ext4")
  8208. (device (file-system-label "my-home")))
  8209. @end example
  8210. @findex uuid
  8211. UUIDs are converted from their string representation (as shown by the
  8212. @command{tune2fs -l} command) using the @code{uuid} form@footnote{The
  8213. @code{uuid} form expects 16-byte UUIDs as defined in
  8214. @uref{https://tools.ietf.org/html/rfc4122, RFC@tie{}4122}. This is the
  8215. form of UUID used by the ext2 family of file systems and others, but it
  8216. is different from ``UUIDs'' found in FAT file systems, for instance.},
  8217. like this:
  8218. @example
  8219. (file-system
  8220. (mount-point "/home")
  8221. (type "ext4")
  8222. (device (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb")))
  8223. @end example
  8224. When the source of a file system is a mapped device (@pxref{Mapped
  8225. Devices}), its @code{device} field @emph{must} refer to the mapped
  8226. device name---e.g., @file{"/dev/mapper/root-partition"}.
  8227. This is required so that
  8228. the system knows that mounting the file system depends on having the
  8229. corresponding device mapping established.
  8230. @item @code{flags} (default: @code{'()})
  8231. This is a list of symbols denoting mount flags. Recognized flags
  8232. include @code{read-only}, @code{bind-mount}, @code{no-dev} (disallow
  8233. access to special files), @code{no-suid} (ignore setuid and setgid
  8234. bits), and @code{no-exec} (disallow program execution.)
  8235. @item @code{options} (default: @code{#f})
  8236. This is either @code{#f}, or a string denoting mount options.
  8237. @item @code{mount?} (default: @code{#t})
  8238. This value indicates whether to automatically mount the file system when
  8239. the system is brought up. When set to @code{#f}, the file system gets
  8240. an entry in @file{/etc/fstab} (read by the @command{mount} command) but
  8241. is not automatically mounted.
  8242. @item @code{needed-for-boot?} (default: @code{#f})
  8243. This Boolean value indicates whether the file system is needed when
  8244. booting. If that is true, then the file system is mounted when the
  8245. initial RAM disk (initrd) is loaded. This is always the case, for
  8246. instance, for the root file system.
  8247. @item @code{check?} (default: @code{#t})
  8248. This Boolean indicates whether the file system needs to be checked for
  8249. errors before being mounted.
  8250. @item @code{create-mount-point?} (default: @code{#f})
  8251. When true, the mount point is created if it does not exist yet.
  8252. @item @code{dependencies} (default: @code{'()})
  8253. This is a list of @code{<file-system>} or @code{<mapped-device>} objects
  8254. representing file systems that must be mounted or mapped devices that
  8255. must be opened before (and unmounted or closed after) this one.
  8256. As an example, consider a hierarchy of mounts: @file{/sys/fs/cgroup} is
  8257. a dependency of @file{/sys/fs/cgroup/cpu} and
  8258. @file{/sys/fs/cgroup/memory}.
  8259. Another example is a file system that depends on a mapped device, for
  8260. example for an encrypted partition (@pxref{Mapped Devices}).
  8261. @end table
  8262. @end deftp
  8263. The @code{(gnu system file-systems)} exports the following useful
  8264. variables.
  8265. @defvr {Scheme Variable} %base-file-systems
  8266. These are essential file systems that are required on normal systems,
  8267. such as @var{%pseudo-terminal-file-system} and @var{%immutable-store} (see
  8268. below.) Operating system declarations should always contain at least
  8269. these.
  8270. @end defvr
  8271. @defvr {Scheme Variable} %pseudo-terminal-file-system
  8272. This is the file system to be mounted as @file{/dev/pts}. It supports
  8273. @dfn{pseudo-terminals} created @i{via} @code{openpty} and similar
  8274. functions (@pxref{Pseudo-Terminals,,, libc, The GNU C Library Reference
  8275. Manual}). Pseudo-terminals are used by terminal emulators such as
  8276. @command{xterm}.
  8277. @end defvr
  8278. @defvr {Scheme Variable} %shared-memory-file-system
  8279. This file system is mounted as @file{/dev/shm} and is used to support
  8280. memory sharing across processes (@pxref{Memory-mapped I/O,
  8281. @code{shm_open},, libc, The GNU C Library Reference Manual}).
  8282. @end defvr
  8283. @defvr {Scheme Variable} %immutable-store
  8284. This file system performs a read-only ``bind mount'' of
  8285. @file{/gnu/store}, making it read-only for all the users including
  8286. @code{root}. This prevents against accidental modification by software
  8287. running as @code{root} or by system administrators.
  8288. The daemon itself is still able to write to the store: it remounts it
  8289. read-write in its own ``name space.''
  8290. @end defvr
  8291. @defvr {Scheme Variable} %binary-format-file-system
  8292. The @code{binfmt_misc} file system, which allows handling of arbitrary
  8293. executable file types to be delegated to user space. This requires the
  8294. @code{binfmt.ko} kernel module to be loaded.
  8295. @end defvr
  8296. @defvr {Scheme Variable} %fuse-control-file-system
  8297. The @code{fusectl} file system, which allows unprivileged users to mount
  8298. and unmount user-space FUSE file systems. This requires the
  8299. @code{fuse.ko} kernel module to be loaded.
  8300. @end defvr
  8301. @node Mapped Devices
  8302. @subsection Mapped Devices
  8303. @cindex device mapping
  8304. @cindex mapped devices
  8305. The Linux kernel has a notion of @dfn{device mapping}: a block device,
  8306. such as a hard disk partition, can be @dfn{mapped} into another device,
  8307. usually in @code{/dev/mapper/},
  8308. with additional processing over the data that flows through
  8309. it@footnote{Note that the GNU@tie{}Hurd makes no difference between the
  8310. concept of a ``mapped device'' and that of a file system: both boil down
  8311. to @emph{translating} input/output operations made on a file to
  8312. operations on its backing store. Thus, the Hurd implements mapped
  8313. devices, like file systems, using the generic @dfn{translator} mechanism
  8314. (@pxref{Translators,,, hurd, The GNU Hurd Reference Manual}).}. A
  8315. typical example is encryption device mapping: all writes to the mapped
  8316. device are encrypted, and all reads are deciphered, transparently.
  8317. Guix extends this notion by considering any device or set of devices that
  8318. are @dfn{transformed} in some way to create a new device; for instance,
  8319. RAID devices are obtained by @dfn{assembling} several other devices, such
  8320. as hard disks or partitions, into a new one that behaves as one partition.
  8321. Other examples, not yet implemented, are LVM logical volumes.
  8322. Mapped devices are declared using the @code{mapped-device} form,
  8323. defined as follows; for examples, see below.
  8324. @deftp {Data Type} mapped-device
  8325. Objects of this type represent device mappings that will be made when
  8326. the system boots up.
  8327. @table @code
  8328. @item source
  8329. This is either a string specifying the name of the block device to be mapped,
  8330. such as @code{"/dev/sda3"}, or a list of such strings when several devices
  8331. need to be assembled for creating a new one.
  8332. @item target
  8333. This string specifies the name of the resulting mapped device. For
  8334. kernel mappers such as encrypted devices of type @code{luks-device-mapping},
  8335. specifying @code{"my-partition"} leads to the creation of
  8336. the @code{"/dev/mapper/my-partition"} device.
  8337. For RAID devices of type @code{raid-device-mapping}, the full device name
  8338. such as @code{"/dev/md0"} needs to be given.
  8339. @item type
  8340. This must be a @code{mapped-device-kind} object, which specifies how
  8341. @var{source} is mapped to @var{target}.
  8342. @end table
  8343. @end deftp
  8344. @defvr {Scheme Variable} luks-device-mapping
  8345. This defines LUKS block device encryption using the @command{cryptsetup}
  8346. command from the package with the same name. It relies on the
  8347. @code{dm-crypt} Linux kernel module.
  8348. @end defvr
  8349. @defvr {Scheme Variable} raid-device-mapping
  8350. This defines a RAID device, which is assembled using the @code{mdadm}
  8351. command from the package with the same name. It requires a Linux kernel
  8352. module for the appropriate RAID level to be loaded, such as @code{raid456}
  8353. for RAID-4, RAID-5 or RAID-6, or @code{raid10} for RAID-10.
  8354. @end defvr
  8355. @cindex disk encryption
  8356. @cindex LUKS
  8357. The following example specifies a mapping from @file{/dev/sda3} to
  8358. @file{/dev/mapper/home} using LUKS---the
  8359. @url{https://gitlab.com/cryptsetup/cryptsetup,Linux Unified Key Setup}, a
  8360. standard mechanism for disk encryption.
  8361. The @file{/dev/mapper/home}
  8362. device can then be used as the @code{device} of a @code{file-system}
  8363. declaration (@pxref{File Systems}).
  8364. @example
  8365. (mapped-device
  8366. (source "/dev/sda3")
  8367. (target "home")
  8368. (type luks-device-mapping))
  8369. @end example
  8370. Alternatively, to become independent of device numbering, one may obtain
  8371. the LUKS UUID (@dfn{unique identifier}) of the source device by a
  8372. command like:
  8373. @example
  8374. cryptsetup luksUUID /dev/sda3
  8375. @end example
  8376. and use it as follows:
  8377. @example
  8378. (mapped-device
  8379. (source (uuid "cb67fc72-0d54-4c88-9d4b-b225f30b0f44"))
  8380. (target "home")
  8381. (type luks-device-mapping))
  8382. @end example
  8383. @cindex swap encryption
  8384. It is also desirable to encrypt swap space, since swap space may contain
  8385. sensitive data. One way to accomplish that is to use a swap file in a
  8386. file system on a device mapped via LUKS encryption. In this way, the
  8387. swap file is encrypted because the entire device is encrypted.
  8388. @xref{Preparing for Installation,,Disk Partitioning}, for an example.
  8389. A RAID device formed of the partitions @file{/dev/sda1} and @file{/dev/sdb1}
  8390. may be declared as follows:
  8391. @example
  8392. (mapped-device
  8393. (source (list "/dev/sda1" "/dev/sdb1"))
  8394. (target "/dev/md0")
  8395. (type raid-device-mapping))
  8396. @end example
  8397. The @file{/dev/md0} device can then be used as the @code{device} of a
  8398. @code{file-system} declaration (@pxref{File Systems}).
  8399. Note that the RAID level need not be given; it is chosen during the
  8400. initial creation and formatting of the RAID device and is determined
  8401. automatically later.
  8402. @node User Accounts
  8403. @subsection User Accounts
  8404. @cindex users
  8405. @cindex accounts
  8406. @cindex user accounts
  8407. User accounts and groups are entirely managed through the
  8408. @code{operating-system} declaration. They are specified with the
  8409. @code{user-account} and @code{user-group} forms:
  8410. @example
  8411. (user-account
  8412. (name "alice")
  8413. (group "users")
  8414. (supplementary-groups '("wheel" ;allow use of sudo, etc.
  8415. "audio" ;sound card
  8416. "video" ;video devices such as webcams
  8417. "cdrom")) ;the good ol' CD-ROM
  8418. (comment "Bob's sister")
  8419. (home-directory "/home/alice"))
  8420. @end example
  8421. When booting or upon completion of @command{guix system reconfigure},
  8422. the system ensures that only the user accounts and groups specified in
  8423. the @code{operating-system} declaration exist, and with the specified
  8424. properties. Thus, account or group creations or modifications made by
  8425. directly invoking commands such as @command{useradd} are lost upon
  8426. reconfiguration or reboot. This ensures that the system remains exactly
  8427. as declared.
  8428. @deftp {Data Type} user-account
  8429. Objects of this type represent user accounts. The following members may
  8430. be specified:
  8431. @table @asis
  8432. @item @code{name}
  8433. The name of the user account.
  8434. @item @code{group}
  8435. @cindex groups
  8436. This is the name (a string) or identifier (a number) of the user group
  8437. this account belongs to.
  8438. @item @code{supplementary-groups} (default: @code{'()})
  8439. Optionally, this can be defined as a list of group names that this
  8440. account belongs to.
  8441. @item @code{uid} (default: @code{#f})
  8442. This is the user ID for this account (a number), or @code{#f}. In the
  8443. latter case, a number is automatically chosen by the system when the
  8444. account is created.
  8445. @item @code{comment} (default: @code{""})
  8446. A comment about the account, such as the account owner's full name.
  8447. @item @code{home-directory}
  8448. This is the name of the home directory for the account.
  8449. @item @code{create-home-directory?} (default: @code{#t})
  8450. Indicates whether the home directory of this account should be created
  8451. if it does not exist yet.
  8452. @item @code{shell} (default: Bash)
  8453. This is a G-expression denoting the file name of a program to be used as
  8454. the shell (@pxref{G-Expressions}).
  8455. @item @code{system?} (default: @code{#f})
  8456. This Boolean value indicates whether the account is a ``system''
  8457. account. System accounts are sometimes treated specially; for instance,
  8458. graphical login managers do not list them.
  8459. @anchor{user-account-password}
  8460. @item @code{password} (default: @code{#f})
  8461. You would normally leave this field to @code{#f}, initialize user
  8462. passwords as @code{root} with the @command{passwd} command, and then let
  8463. users change it with @command{passwd}. Passwords set with
  8464. @command{passwd} are of course preserved across reboot and
  8465. reconfiguration.
  8466. If you @emph{do} want to have a preset password for an account, then
  8467. this field must contain the encrypted password, as a string.
  8468. @xref{crypt,,, libc, The GNU C Library Reference Manual}, for more information
  8469. on password encryption, and @ref{Encryption,,, guile, GNU Guile Reference
  8470. Manual}, for information on Guile's @code{crypt} procedure.
  8471. @end table
  8472. @end deftp
  8473. @cindex groups
  8474. User group declarations are even simpler:
  8475. @example
  8476. (user-group (name "students"))
  8477. @end example
  8478. @deftp {Data Type} user-group
  8479. This type is for, well, user groups. There are just a few fields:
  8480. @table @asis
  8481. @item @code{name}
  8482. The name of the group.
  8483. @item @code{id} (default: @code{#f})
  8484. The group identifier (a number). If @code{#f}, a new number is
  8485. automatically allocated when the group is created.
  8486. @item @code{system?} (default: @code{#f})
  8487. This Boolean value indicates whether the group is a ``system'' group.
  8488. System groups have low numerical IDs.
  8489. @item @code{password} (default: @code{#f})
  8490. What, user groups can have a password? Well, apparently yes. Unless
  8491. @code{#f}, this field specifies the password of the group.
  8492. @end table
  8493. @end deftp
  8494. For convenience, a variable lists all the basic user groups one may
  8495. expect:
  8496. @defvr {Scheme Variable} %base-groups
  8497. This is the list of basic user groups that users and/or packages expect
  8498. to be present on the system. This includes groups such as ``root'',
  8499. ``wheel'', and ``users'', as well as groups used to control access to
  8500. specific devices such as ``audio'', ``disk'', and ``cdrom''.
  8501. @end defvr
  8502. @defvr {Scheme Variable} %base-user-accounts
  8503. This is the list of basic system accounts that programs may expect to
  8504. find on a GNU/Linux system, such as the ``nobody'' account.
  8505. Note that the ``root'' account is not included here. It is a
  8506. special-case and is automatically added whether or not it is specified.
  8507. @end defvr
  8508. @node Locales
  8509. @subsection Locales
  8510. @cindex locale
  8511. A @dfn{locale} defines cultural conventions for a particular language
  8512. and region of the world (@pxref{Locales,,, libc, The GNU C Library
  8513. Reference Manual}). Each locale has a name that typically has the form
  8514. @code{@var{language}_@var{territory}.@var{codeset}}---e.g.,
  8515. @code{fr_LU.utf8} designates the locale for the French language, with
  8516. cultural conventions from Luxembourg, and using the UTF-8 encoding.
  8517. @cindex locale definition
  8518. Usually, you will want to specify the default locale for the machine
  8519. using the @code{locale} field of the @code{operating-system} declaration
  8520. (@pxref{operating-system Reference, @code{locale}}).
  8521. The selected locale is automatically added to the @dfn{locale
  8522. definitions} known to the system if needed, with its codeset inferred
  8523. from its name---e.g., @code{bo_CN.utf8} will be assumed to use the
  8524. @code{UTF-8} codeset. Additional locale definitions can be specified in
  8525. the @code{locale-definitions} slot of @code{operating-system}---this is
  8526. useful, for instance, if the codeset could not be inferred from the
  8527. locale name. The default set of locale definitions includes some widely
  8528. used locales, but not all the available locales, in order to save space.
  8529. For instance, to add the North Frisian locale for Germany, the value of
  8530. that field may be:
  8531. @example
  8532. (cons (locale-definition
  8533. (name "fy_DE.utf8") (source "fy_DE"))
  8534. %default-locale-definitions)
  8535. @end example
  8536. Likewise, to save space, one might want @code{locale-definitions} to
  8537. list only the locales that are actually used, as in:
  8538. @example
  8539. (list (locale-definition
  8540. (name "ja_JP.eucjp") (source "ja_JP")
  8541. (charset "EUC-JP")))
  8542. @end example
  8543. @vindex LOCPATH
  8544. The compiled locale definitions are available at
  8545. @file{/run/current-system/locale/X.Y}, where @code{X.Y} is the libc
  8546. version, which is the default location where the GNU@tie{}libc provided
  8547. by Guix looks for locale data. This can be overridden using the
  8548. @code{LOCPATH} environment variable (@pxref{locales-and-locpath,
  8549. @code{LOCPATH} and locale packages}).
  8550. The @code{locale-definition} form is provided by the @code{(gnu system
  8551. locale)} module. Details are given below.
  8552. @deftp {Data Type} locale-definition
  8553. This is the data type of a locale definition.
  8554. @table @asis
  8555. @item @code{name}
  8556. The name of the locale. @xref{Locale Names,,, libc, The GNU C Library
  8557. Reference Manual}, for more information on locale names.
  8558. @item @code{source}
  8559. The name of the source for that locale. This is typically the
  8560. @code{@var{language}_@var{territory}} part of the locale name.
  8561. @item @code{charset} (default: @code{"UTF-8"})
  8562. The ``character set'' or ``code set'' for that locale,
  8563. @uref{http://www.iana.org/assignments/character-sets, as defined by
  8564. IANA}.
  8565. @end table
  8566. @end deftp
  8567. @defvr {Scheme Variable} %default-locale-definitions
  8568. A list of commonly used UTF-8 locales, used as the default
  8569. value of the @code{locale-definitions} field of @code{operating-system}
  8570. declarations.
  8571. @cindex locale name
  8572. @cindex normalized codeset in locale names
  8573. These locale definitions use the @dfn{normalized codeset} for the part
  8574. that follows the dot in the name (@pxref{Using gettextized software,
  8575. normalized codeset,, libc, The GNU C Library Reference Manual}). So for
  8576. instance it has @code{uk_UA.utf8} but @emph{not}, say,
  8577. @code{uk_UA.UTF-8}.
  8578. @end defvr
  8579. @subsubsection Locale Data Compatibility Considerations
  8580. @cindex incompatibility, of locale data
  8581. @code{operating-system} declarations provide a @code{locale-libcs} field
  8582. to specify the GNU@tie{}libc packages that are used to compile locale
  8583. declarations (@pxref{operating-system Reference}). ``Why would I
  8584. care?'', you may ask. Well, it turns out that the binary format of
  8585. locale data is occasionally incompatible from one libc version to
  8586. another.
  8587. @c See <https://sourceware.org/ml/libc-alpha/2015-09/msg00575.html>
  8588. @c and <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
  8589. For instance, a program linked against libc version 2.21 is unable to
  8590. read locale data produced with libc 2.22; worse, that program
  8591. @emph{aborts} instead of simply ignoring the incompatible locale
  8592. data@footnote{Versions 2.23 and later of GNU@tie{}libc will simply skip
  8593. the incompatible locale data, which is already an improvement.}.
  8594. Similarly, a program linked against libc 2.22 can read most, but not
  8595. all, of the locale data from libc 2.21 (specifically, @code{LC_COLLATE}
  8596. data is incompatible); thus calls to @code{setlocale} may fail, but
  8597. programs will not abort.
  8598. The ``problem'' in GuixSD is that users have a lot of freedom: They can
  8599. choose whether and when to upgrade software in their profiles, and might
  8600. be using a libc version different from the one the system administrator
  8601. used to build the system-wide locale data.
  8602. Fortunately, unprivileged users can also install their own locale data
  8603. and define @var{GUIX_LOCPATH} accordingly (@pxref{locales-and-locpath,
  8604. @code{GUIX_LOCPATH} and locale packages}).
  8605. Still, it is best if the system-wide locale data at
  8606. @file{/run/current-system/locale} is built for all the libc versions
  8607. actually in use on the system, so that all the programs can access
  8608. it---this is especially crucial on a multi-user system. To do that, the
  8609. administrator can specify several libc packages in the
  8610. @code{locale-libcs} field of @code{operating-system}:
  8611. @example
  8612. (use-package-modules base)
  8613. (operating-system
  8614. ;; @dots{}
  8615. (locale-libcs (list glibc-2.21 (canonical-package glibc))))
  8616. @end example
  8617. This example would lead to a system containing locale definitions for
  8618. both libc 2.21 and the current version of libc in
  8619. @file{/run/current-system/locale}.
  8620. @node Services
  8621. @subsection Services
  8622. @cindex system services
  8623. An important part of preparing an @code{operating-system} declaration is
  8624. listing @dfn{system services} and their configuration (@pxref{Using the
  8625. Configuration System}). System services are typically daemons launched
  8626. when the system boots, or other actions needed at that time---e.g.,
  8627. configuring network access.
  8628. GuixSD has a broad definition of ``service'' (@pxref{Service
  8629. Composition}), but many services are managed by the GNU@tie{}Shepherd
  8630. (@pxref{Shepherd Services}). On a running system, the @command{herd}
  8631. command allows you to list the available services, show their status,
  8632. start and stop them, or do other specific operations (@pxref{Jump
  8633. Start,,, shepherd, The GNU Shepherd Manual}). For example:
  8634. @example
  8635. # herd status
  8636. @end example
  8637. The above command, run as @code{root}, lists the currently defined
  8638. services. The @command{herd doc} command shows a synopsis of the given
  8639. service and its associated actions:
  8640. @example
  8641. # herd doc nscd
  8642. Run libc's name service cache daemon (nscd).
  8643. # herd doc nscd action invalidate
  8644. invalidate: Invalidate the given cache--e.g., 'hosts' for host name lookups.
  8645. @end example
  8646. The @command{start}, @command{stop}, and @command{restart} sub-commands
  8647. have the effect you would expect. For instance, the commands below stop
  8648. the nscd service and restart the Xorg display server:
  8649. @example
  8650. # herd stop nscd
  8651. Service nscd has been stopped.
  8652. # herd restart xorg-server
  8653. Service xorg-server has been stopped.
  8654. Service xorg-server has been started.
  8655. @end example
  8656. The following sections document the available services, starting with
  8657. the core services, that may be used in an @code{operating-system}
  8658. declaration.
  8659. @menu
  8660. * Base Services:: Essential system services.
  8661. * Scheduled Job Execution:: The mcron service.
  8662. * Log Rotation:: The rottlog service.
  8663. * Networking Services:: Network setup, SSH daemon, etc.
  8664. * X Window:: Graphical display.
  8665. * Printing Services:: Local and remote printer support.
  8666. * Desktop Services:: D-Bus and desktop services.
  8667. * Sound Services:: ALSA and Pulseaudio services.
  8668. * Database Services:: SQL databases, key-value stores, etc.
  8669. * Mail Services:: IMAP, POP3, SMTP, and all that.
  8670. * Messaging Services:: Messaging services.
  8671. * Telephony Services:: Telephony services.
  8672. * Monitoring Services:: Monitoring services.
  8673. * Kerberos Services:: Kerberos services.
  8674. * Web Services:: Web servers.
  8675. * Certificate Services:: TLS certificates via Let's Encrypt.
  8676. * DNS Services:: DNS daemons.
  8677. * VPN Services:: VPN daemons.
  8678. * Network File System:: NFS related services.
  8679. * Continuous Integration:: The Cuirass service.
  8680. * Power Management Services:: Extending battery life.
  8681. * Audio Services:: The MPD.
  8682. * Virtualization Services:: Virtualization services.
  8683. * Version Control Services:: Providing remote access to Git repositories.
  8684. * Game Services:: Game servers.
  8685. * Miscellaneous Services:: Other services.
  8686. @end menu
  8687. @node Base Services
  8688. @subsubsection Base Services
  8689. The @code{(gnu services base)} module provides definitions for the basic
  8690. services that one expects from the system. The services exported by
  8691. this module are listed below.
  8692. @defvr {Scheme Variable} %base-services
  8693. This variable contains a list of basic services (@pxref{Service Types
  8694. and Services}, for more information on service objects) one would
  8695. expect from the system: a login service (mingetty) on each tty, syslogd,
  8696. the libc name service cache daemon (nscd), the udev device manager, and
  8697. more.
  8698. This is the default value of the @code{services} field of
  8699. @code{operating-system} declarations. Usually, when customizing a
  8700. system, you will want to append services to @var{%base-services}, like
  8701. this:
  8702. @example
  8703. (cons* (avahi-service) (lsh-service) %base-services)
  8704. @end example
  8705. @end defvr
  8706. @defvr {Scheme Variable} special-files-service-type
  8707. This is the service that sets up ``special files'' such as
  8708. @file{/bin/sh}; an instance of it is part of @code{%base-services}.
  8709. The value associated with @code{special-files-service-type} services
  8710. must be a list of tuples where the first element is the ``special file''
  8711. and the second element is its target. By default it is:
  8712. @cindex @file{/bin/sh}
  8713. @cindex @file{sh}, in @file{/bin}
  8714. @example
  8715. `(("/bin/sh" ,(file-append @var{bash} "/bin/sh")))
  8716. @end example
  8717. @cindex @file{/usr/bin/env}
  8718. @cindex @file{env}, in @file{/usr/bin}
  8719. If you want to add, say, @code{/usr/bin/env} to your system, you can
  8720. change it to:
  8721. @example
  8722. `(("/bin/sh" ,(file-append @var{bash} "/bin/sh"))
  8723. ("/usr/bin/env" ,(file-append @var{coreutils} "/bin/env")))
  8724. @end example
  8725. Since this is part of @code{%base-services}, you can use
  8726. @code{modify-services} to customize the set of special files
  8727. (@pxref{Service Reference, @code{modify-services}}). But the simple way
  8728. to add a special file is @i{via} the @code{extra-special-file} procedure
  8729. (see below.)
  8730. @end defvr
  8731. @deffn {Scheme Procedure} extra-special-file @var{file} @var{target}
  8732. Use @var{target} as the ``special file'' @var{file}.
  8733. For example, adding the following lines to the @code{services} field of
  8734. your operating system declaration leads to a @file{/usr/bin/env}
  8735. symlink:
  8736. @example
  8737. (extra-special-file "/usr/bin/env"
  8738. (file-append coreutils "/bin/env"))
  8739. @end example
  8740. @end deffn
  8741. @deffn {Scheme Procedure} host-name-service @var{name}
  8742. Return a service that sets the host name to @var{name}.
  8743. @end deffn
  8744. @deffn {Scheme Procedure} login-service @var{config}
  8745. Return a service to run login according to @var{config}, a
  8746. @code{<login-configuration>} object, which specifies the message of the day,
  8747. among other things.
  8748. @end deffn
  8749. @deftp {Data Type} login-configuration
  8750. This is the data type representing the configuration of login.
  8751. @table @asis
  8752. @item @code{motd}
  8753. @cindex message of the day
  8754. A file-like object containing the ``message of the day''.
  8755. @item @code{allow-empty-passwords?} (default: @code{#t})
  8756. Allow empty passwords by default so that first-time users can log in when
  8757. the 'root' account has just been created.
  8758. @end table
  8759. @end deftp
  8760. @deffn {Scheme Procedure} mingetty-service @var{config}
  8761. Return a service to run mingetty according to @var{config}, a
  8762. @code{<mingetty-configuration>} object, which specifies the tty to run, among
  8763. other things.
  8764. @end deffn
  8765. @deftp {Data Type} mingetty-configuration
  8766. This is the data type representing the configuration of Mingetty, which
  8767. provides the default implementation of virtual console log-in.
  8768. @table @asis
  8769. @item @code{tty}
  8770. The name of the console this Mingetty runs on---e.g., @code{"tty1"}.
  8771. @item @code{auto-login} (default: @code{#f})
  8772. When true, this field must be a string denoting the user name under
  8773. which the system automatically logs in. When it is @code{#f}, a
  8774. user name and password must be entered to log in.
  8775. @item @code{login-program} (default: @code{#f})
  8776. This must be either @code{#f}, in which case the default log-in program
  8777. is used (@command{login} from the Shadow tool suite), or a gexp denoting
  8778. the name of the log-in program.
  8779. @item @code{login-pause?} (default: @code{#f})
  8780. When set to @code{#t} in conjunction with @var{auto-login}, the user
  8781. will have to press a key before the log-in shell is launched.
  8782. @item @code{mingetty} (default: @var{mingetty})
  8783. The Mingetty package to use.
  8784. @end table
  8785. @end deftp
  8786. @deffn {Scheme Procedure} agetty-service @var{config}
  8787. Return a service to run agetty according to @var{config}, an
  8788. @code{<agetty-configuration>} object, which specifies the tty to run,
  8789. among other things.
  8790. @end deffn
  8791. @deftp {Data Type} agetty-configuration
  8792. This is the data type representing the configuration of agetty, which
  8793. implements virtual and serial console log-in. See the @code{agetty(8)}
  8794. man page for more information.
  8795. @table @asis
  8796. @item @code{tty}
  8797. The name of the console this agetty runs on, as a string---e.g.,
  8798. @code{"ttyS0"}. This argument is optional, it will default to
  8799. a reasonable default serial port used by the kernel Linux.
  8800. For this, if there is a value for an option @code{agetty.tty} in the kernel
  8801. command line, agetty will extract the device name of the serial port
  8802. from it and use that.
  8803. If not and if there is a value for an option @code{console} with a tty in
  8804. the Linux command line, agetty will extract the device name of the
  8805. serial port from it and use that.
  8806. In both cases, agetty will leave the other serial device settings
  8807. (baud rate etc.)@: alone---in the hope that Linux pinned them to the
  8808. correct values.
  8809. @item @code{baud-rate} (default: @code{#f})
  8810. A string containing a comma-separated list of one or more baud rates, in
  8811. descending order.
  8812. @item @code{term} (default: @code{#f})
  8813. A string containing the value used for the @code{TERM} environment
  8814. variable.
  8815. @item @code{eight-bits?} (default: @code{#f})
  8816. When @code{#t}, the tty is assumed to be 8-bit clean, and parity detection is
  8817. disabled.
  8818. @item @code{auto-login} (default: @code{#f})
  8819. When passed a login name, as a string, the specified user will be logged
  8820. in automatically without prompting for their login name or password.
  8821. @item @code{no-reset?} (default: @code{#f})
  8822. When @code{#t}, don't reset terminal cflags (control modes).
  8823. @item @code{host} (default: @code{#f})
  8824. This accepts a string containing the "login_host", which will be written
  8825. into the @file{/var/run/utmpx} file.
  8826. @item @code{remote?} (default: @code{#f})
  8827. When set to @code{#t} in conjunction with @var{host}, this will add an
  8828. @code{-r} fakehost option to the command line of the login program
  8829. specified in @var{login-program}.
  8830. @item @code{flow-control?} (default: @code{#f})
  8831. When set to @code{#t}, enable hardware (RTS/CTS) flow control.
  8832. @item @code{no-issue?} (default: @code{#f})
  8833. When set to @code{#t}, the contents of the @file{/etc/issue} file will
  8834. not be displayed before presenting the login prompt.
  8835. @item @code{init-string} (default: @code{#f})
  8836. This accepts a string that will be sent to the tty or modem before
  8837. sending anything else. It can be used to initialize a modem.
  8838. @item @code{no-clear?} (default: @code{#f})
  8839. When set to @code{#t}, agetty will not clear the screen before showing
  8840. the login prompt.
  8841. @item @code{login-program} (default: (file-append shadow "/bin/login"))
  8842. This must be either a gexp denoting the name of a log-in program, or
  8843. unset, in which case the default value is the @command{login} from the
  8844. Shadow tool suite.
  8845. @item @code{local-line} (default: @code{#f})
  8846. Control the CLOCAL line flag. This accepts one of three symbols as
  8847. arguments, @code{'auto}, @code{'always}, or @code{'never}. If @code{#f},
  8848. the default value chosen by agetty is @code{'auto}.
  8849. @item @code{extract-baud?} (default: @code{#f})
  8850. When set to @code{#t}, instruct agetty to try to extract the baud rate
  8851. from the status messages produced by certain types of modems.
  8852. @item @code{skip-login?} (default: @code{#f})
  8853. When set to @code{#t}, do not prompt the user for a login name. This
  8854. can be used with @var{login-program} field to use non-standard login
  8855. systems.
  8856. @item @code{no-newline?} (default: @code{#f})
  8857. When set to @code{#t}, do not print a newline before printing the
  8858. @file{/etc/issue} file.
  8859. @c Is this dangerous only when used with login-program, or always?
  8860. @item @code{login-options} (default: @code{#f})
  8861. This option accepts a string containing options that are passed to the
  8862. login program. When used with the @var{login-program}, be aware that a
  8863. malicious user could try to enter a login name containing embedded
  8864. options that could be parsed by the login program.
  8865. @item @code{login-pause} (default: @code{#f})
  8866. When set to @code{#t}, wait for any key before showing the login prompt.
  8867. This can be used in conjunction with @var{auto-login} to save memory by
  8868. lazily spawning shells.
  8869. @item @code{chroot} (default: @code{#f})
  8870. Change root to the specified directory. This option accepts a directory
  8871. path as a string.
  8872. @item @code{hangup?} (default: @code{#f})
  8873. Use the Linux system call @code{vhangup} to do a virtual hangup of the
  8874. specified terminal.
  8875. @item @code{keep-baud?} (default: @code{#f})
  8876. When set to @code{#t}, try to keep the existing baud rate. The baud
  8877. rates from @var{baud-rate} are used when agetty receives a @key{BREAK}
  8878. character.
  8879. @item @code{timeout} (default: @code{#f})
  8880. When set to an integer value, terminate if no user name could be read
  8881. within @var{timeout} seconds.
  8882. @item @code{detect-case?} (default: @code{#f})
  8883. When set to @code{#t}, turn on support for detecting an uppercase-only
  8884. terminal. This setting will detect a login name containing only
  8885. uppercase letters as indicating an uppercase-only terminal and turn on
  8886. some upper-to-lower case conversions. Note that this will not support
  8887. Unicode characters.
  8888. @item @code{wait-cr?} (default: @code{#f})
  8889. When set to @code{#t}, wait for the user or modem to send a
  8890. carriage-return or linefeed character before displaying
  8891. @file{/etc/issue} or login prompt. This is typically used with the
  8892. @var{init-string} option.
  8893. @item @code{no-hints?} (default: @code{#f})
  8894. When set to @code{#t}, do not print hints about Num, Caps, and Scroll
  8895. locks.
  8896. @item @code{no-hostname?} (default: @code{#f})
  8897. By default, the hostname is printed. When this option is set to
  8898. @code{#t}, no hostname will be shown at all.
  8899. @item @code{long-hostname?} (default: @code{#f})
  8900. By default, the hostname is only printed until the first dot. When this
  8901. option is set to @code{#t}, the fully qualified hostname by
  8902. @code{gethostname} or @code{getaddrinfo} is shown.
  8903. @item @code{erase-characters} (default: @code{#f})
  8904. This option accepts a string of additional characters that should be
  8905. interpreted as backspace when the user types their login name.
  8906. @item @code{kill-characters} (default: @code{#f})
  8907. This option accepts a string that should be interpreted to mean "ignore
  8908. all previous characters" (also called a "kill" character) when the types
  8909. their login name.
  8910. @item @code{chdir} (default: @code{#f})
  8911. This option accepts, as a string, a directory path that will be changed
  8912. to before login.
  8913. @item @code{delay} (default: @code{#f})
  8914. This options accepts, as an integer, the number of seconds to sleep
  8915. before opening the tty and displaying the login prompt.
  8916. @item @code{nice} (default: @code{#f})
  8917. This option accepts, as an integer, the nice value with which to run the
  8918. @command{login} program.
  8919. @item @code{extra-options} (default: @code{'()})
  8920. This option provides an "escape hatch" for the user to provide arbitrary
  8921. command-line arguments to @command{agetty} as a list of strings.
  8922. @end table
  8923. @end deftp
  8924. @deffn {Scheme Procedure} kmscon-service-type @var{config}
  8925. Return a service to run @uref{https://www.freedesktop.org/wiki/Software/kmscon,kmscon}
  8926. according to @var{config}, a @code{<kmscon-configuration>} object, which
  8927. specifies the tty to run, among other things.
  8928. @end deffn
  8929. @deftp {Data Type} kmscon-configuration
  8930. This is the data type representing the configuration of Kmscon, which
  8931. implements virtual console log-in.
  8932. @table @asis
  8933. @item @code{virtual-terminal}
  8934. The name of the console this Kmscon runs on---e.g., @code{"tty1"}.
  8935. @item @code{login-program} (default: @code{#~(string-append #$shadow "/bin/login")})
  8936. A gexp denoting the name of the log-in program. The default log-in program is
  8937. @command{login} from the Shadow tool suite.
  8938. @item @code{login-arguments} (default: @code{'("-p")})
  8939. A list of arguments to pass to @command{login}.
  8940. @item @code{auto-login} (default: @code{#f})
  8941. When passed a login name, as a string, the specified user will be logged
  8942. in automatically without prompting for their login name or password.
  8943. @item @code{hardware-acceleration?} (default: #f)
  8944. Whether to use hardware acceleration.
  8945. @item @code{kmscon} (default: @var{kmscon})
  8946. The Kmscon package to use.
  8947. @end table
  8948. @end deftp
  8949. @cindex name service cache daemon
  8950. @cindex nscd
  8951. @deffn {Scheme Procedure} nscd-service [@var{config}] [#:glibc glibc] @
  8952. [#:name-services '()]
  8953. Return a service that runs the libc name service cache daemon (nscd) with the
  8954. given @var{config}---an @code{<nscd-configuration>} object. @xref{Name
  8955. Service Switch}, for an example.
  8956. For convenience, the Shepherd service for nscd provides the following actions:
  8957. @table @code
  8958. @item invalidate
  8959. @cindex cache invalidation, nscd
  8960. @cindex nscd, cache invalidation
  8961. This invalidate the given cache. For instance, running:
  8962. @example
  8963. herd invalidate nscd hosts
  8964. @end example
  8965. @noindent
  8966. invalidates the host name lookup cache of nscd.
  8967. @item statistics
  8968. Running @command{herd statistics nscd} displays information about nscd usage
  8969. and caches.
  8970. @end table
  8971. @end deffn
  8972. @defvr {Scheme Variable} %nscd-default-configuration
  8973. This is the default @code{<nscd-configuration>} value (see below) used
  8974. by @code{nscd-service}. It uses the caches defined by
  8975. @var{%nscd-default-caches}; see below.
  8976. @end defvr
  8977. @deftp {Data Type} nscd-configuration
  8978. This is the data type representing the name service cache daemon (nscd)
  8979. configuration.
  8980. @table @asis
  8981. @item @code{name-services} (default: @code{'()})
  8982. List of packages denoting @dfn{name services} that must be visible to
  8983. the nscd---e.g., @code{(list @var{nss-mdns})}.
  8984. @item @code{glibc} (default: @var{glibc})
  8985. Package object denoting the GNU C Library providing the @command{nscd}
  8986. command.
  8987. @item @code{log-file} (default: @code{"/var/log/nscd.log"})
  8988. Name of the nscd log file. This is where debugging output goes when
  8989. @code{debug-level} is strictly positive.
  8990. @item @code{debug-level} (default: @code{0})
  8991. Integer denoting the debugging levels. Higher numbers mean that more
  8992. debugging output is logged.
  8993. @item @code{caches} (default: @var{%nscd-default-caches})
  8994. List of @code{<nscd-cache>} objects denoting things to be cached; see
  8995. below.
  8996. @end table
  8997. @end deftp
  8998. @deftp {Data Type} nscd-cache
  8999. Data type representing a cache database of nscd and its parameters.
  9000. @table @asis
  9001. @item @code{database}
  9002. This is a symbol representing the name of the database to be cached.
  9003. Valid values are @code{passwd}, @code{group}, @code{hosts}, and
  9004. @code{services}, which designate the corresponding NSS database
  9005. (@pxref{NSS Basics,,, libc, The GNU C Library Reference Manual}).
  9006. @item @code{positive-time-to-live}
  9007. @itemx @code{negative-time-to-live} (default: @code{20})
  9008. A number representing the number of seconds during which a positive or
  9009. negative lookup result remains in cache.
  9010. @item @code{check-files?} (default: @code{#t})
  9011. Whether to check for updates of the files corresponding to
  9012. @var{database}.
  9013. For instance, when @var{database} is @code{hosts}, setting this flag
  9014. instructs nscd to check for updates in @file{/etc/hosts} and to take
  9015. them into account.
  9016. @item @code{persistent?} (default: @code{#t})
  9017. Whether the cache should be stored persistently on disk.
  9018. @item @code{shared?} (default: @code{#t})
  9019. Whether the cache should be shared among users.
  9020. @item @code{max-database-size} (default: 32@tie{}MiB)
  9021. Maximum size in bytes of the database cache.
  9022. @c XXX: 'suggested-size' and 'auto-propagate?' seem to be expert
  9023. @c settings, so leave them out.
  9024. @end table
  9025. @end deftp
  9026. @defvr {Scheme Variable} %nscd-default-caches
  9027. List of @code{<nscd-cache>} objects used by default by
  9028. @code{nscd-configuration} (see above).
  9029. It enables persistent and aggressive caching of service and host name
  9030. lookups. The latter provides better host name lookup performance,
  9031. resilience in the face of unreliable name servers, and also better
  9032. privacy---often the result of host name lookups is in local cache, so
  9033. external name servers do not even need to be queried.
  9034. @end defvr
  9035. @anchor{syslog-configuration-type}
  9036. @cindex syslog
  9037. @cindex logging
  9038. @deftp {Data Type} syslog-configuration
  9039. This data type represents the configuration of the syslog daemon.
  9040. @table @asis
  9041. @item @code{syslogd} (default: @code{#~(string-append #$inetutils "/libexec/syslogd")})
  9042. The syslog daemon to use.
  9043. @item @code{config-file} (default: @code{%default-syslog.conf})
  9044. The syslog configuration file to use.
  9045. @end table
  9046. @end deftp
  9047. @anchor{syslog-service}
  9048. @cindex syslog
  9049. @deffn {Scheme Procedure} syslog-service @var{config}
  9050. Return a service that runs a syslog daemon according to @var{config}.
  9051. @xref{syslogd invocation,,, inetutils, GNU Inetutils}, for more
  9052. information on the configuration file syntax.
  9053. @end deffn
  9054. @defvr {Scheme Variable} guix-service-type
  9055. This is the type of the service that runs the build daemon,
  9056. @command{guix-daemon} (@pxref{Invoking guix-daemon}). Its value must be a
  9057. @code{guix-configuration} record as described below.
  9058. @end defvr
  9059. @anchor{guix-configuration-type}
  9060. @deftp {Data Type} guix-configuration
  9061. This data type represents the configuration of the Guix build daemon.
  9062. @xref{Invoking guix-daemon}, for more information.
  9063. @table @asis
  9064. @item @code{guix} (default: @var{guix})
  9065. The Guix package to use.
  9066. @item @code{build-group} (default: @code{"guixbuild"})
  9067. Name of the group for build user accounts.
  9068. @item @code{build-accounts} (default: @code{10})
  9069. Number of build user accounts to create.
  9070. @item @code{authorize-key?} (default: @code{#t})
  9071. @cindex substitutes, authorization thereof
  9072. Whether to authorize the substitute keys listed in
  9073. @code{authorized-keys}---by default that of @code{@value{SUBSTITUTE-SERVER}}
  9074. (@pxref{Substitutes}).
  9075. @vindex %default-authorized-guix-keys
  9076. @item @code{authorized-keys} (default: @var{%default-authorized-guix-keys})
  9077. The list of authorized key files for archive imports, as a list of
  9078. string-valued gexps (@pxref{Invoking guix archive}). By default, it
  9079. contains that of @code{@value{SUBSTITUTE-SERVER}} (@pxref{Substitutes}).
  9080. @item @code{use-substitutes?} (default: @code{#t})
  9081. Whether to use substitutes.
  9082. @item @code{substitute-urls} (default: @var{%default-substitute-urls})
  9083. The list of URLs where to look for substitutes by default.
  9084. @item @code{max-silent-time} (default: @code{0})
  9085. @itemx @code{timeout} (default: @code{0})
  9086. The number of seconds of silence and the number of seconds of activity,
  9087. respectively, after which a build process times out. A value of zero
  9088. disables the timeout.
  9089. @item @code{log-compression} (default: @code{'bzip2})
  9090. The type of compression used for build logs---one of @code{gzip},
  9091. @code{bzip2}, or @code{none}.
  9092. @item @code{extra-options} (default: @code{'()})
  9093. List of extra command-line options for @command{guix-daemon}.
  9094. @item @code{log-file} (default: @code{"/var/log/guix-daemon.log"})
  9095. File where @command{guix-daemon}'s standard output and standard error
  9096. are written.
  9097. @item @code{http-proxy} (default: @code{#f})
  9098. The HTTP proxy used for downloading fixed-output derivations and
  9099. substitutes.
  9100. @item @code{tmpdir} (default: @code{#f})
  9101. A directory path where the @command{guix-daemon} will perform builds.
  9102. @end table
  9103. @end deftp
  9104. @deffn {Scheme Procedure} udev-service [#:udev @var{eudev} #:rules @code{'()}]
  9105. Run @var{udev}, which populates the @file{/dev} directory dynamically.
  9106. udev rules can be provided as a list of files through the @var{rules}
  9107. variable. The procedures @var{udev-rule} and @var{file->udev-rule} from
  9108. @code{(gnu services base)} simplify the creation of such rule files.
  9109. @deffn {Scheme Procedure} udev-rule [@var{file-name} @var{contents}]
  9110. Return a udev-rule file named @var{file-name} containing the rules
  9111. defined by the @var{contents} literal.
  9112. In the following example, a rule for a USB device is defined to be
  9113. stored in the file @file{90-usb-thing.rules}. The rule runs a script
  9114. upon detecting a USB device with a given product identifier.
  9115. @example
  9116. (define %example-udev-rule
  9117. (udev-rule
  9118. "90-usb-thing.rules"
  9119. (string-append "ACTION==\"add\", SUBSYSTEM==\"usb\", "
  9120. "ATTR@{product@}==\"Example\", "
  9121. "RUN+=\"/path/to/script\"")))
  9122. @end example
  9123. @end deffn
  9124. Here we show how the default @var{udev-service} can be extended with it.
  9125. @example
  9126. (operating-system
  9127. ;; @dots{}
  9128. (services
  9129. (modify-services %desktop-services
  9130. (udev-service-type config =>
  9131. (udev-configuration (inherit config)
  9132. (rules (append (udev-configuration-rules config)
  9133. (list %example-udev-rule))))))))
  9134. @end example
  9135. @deffn {Scheme Procedure} file->udev-rule [@var{file-name} @var{file}]
  9136. Return a udev file named @var{file-name} containing the rules defined
  9137. within @var{file}, a file-like object.
  9138. The following example showcases how we can use an existing rule file.
  9139. @example
  9140. (use-modules (guix download) ;for url-fetch
  9141. (guix packages) ;for origin
  9142. ;; @dots{})
  9143. (define %android-udev-rules
  9144. (file->udev-rule
  9145. "51-android-udev.rules"
  9146. (let ((version "20170910"))
  9147. (origin
  9148. (method url-fetch)
  9149. (uri (string-append "https://raw.githubusercontent.com/M0Rf30/"
  9150. "android-udev-rules/" version "/51-android.rules"))
  9151. (sha256
  9152. (base32 "0lmmagpyb6xsq6zcr2w1cyx9qmjqmajkvrdbhjx32gqf1d9is003"))))))
  9153. @end example
  9154. @end deffn
  9155. Additionally, Guix package definitions can be included in @var{rules} in
  9156. order to extend the udev rules with the definitions found under their
  9157. @file{lib/udev/rules.d} sub-directory. In lieu of the previous
  9158. @var{file->udev-rule} example, we could have used the
  9159. @var{android-udev-rules} package which exists in Guix in the @code{(gnu
  9160. packages android)} module.
  9161. The following example shows how to use the @var{android-udev-rules}
  9162. package so that the Android tool @command{adb} can detect devices
  9163. without root privileges. It also details how to create the
  9164. @code{adbusers} group, which is required for the proper functioning of
  9165. the rules defined within the @var{android-udev-rules} package. To
  9166. create such a group, we must define it both as part of the
  9167. @var{supplementary-groups} of our @var{user-account} declaration, as
  9168. well as in the @var{groups} field of the @var{operating-system} record.
  9169. @example
  9170. (use-modules (gnu packages android) ;for android-udev-rules
  9171. (gnu system shadow) ;for user-group
  9172. ;; @dots{})
  9173. (operating-system
  9174. ;; @dots{}
  9175. (users (cons (user-acount
  9176. ;; @dots{}
  9177. (supplementary-groups
  9178. '("adbusers" ;for adb
  9179. "wheel" "netdev" "audio" "video"))
  9180. ;; @dots{})))
  9181. (groups (cons (user-group (system? #t) (name "adbusers"))
  9182. %base-groups))
  9183. ;; @dots{}
  9184. (services
  9185. (modify-services %desktop-services
  9186. (udev-service-type config =>
  9187. (udev-configuration (inherit config)
  9188. (rules (cons* android-udev-rules
  9189. (udev-configuration-rules config))))))))
  9190. @end example
  9191. @end deffn
  9192. @defvr {Scheme Variable} urandom-seed-service-type
  9193. Save some entropy in @var{%random-seed-file} to seed @file{/dev/urandom}
  9194. when rebooting. It also tries to seed @file{/dev/urandom} from
  9195. @file{/dev/hwrng} while booting, if @file{/dev/hwrng} exists and is
  9196. readable.
  9197. @end defvr
  9198. @defvr {Scheme Variable} %random-seed-file
  9199. This is the name of the file where some random bytes are saved by
  9200. @var{urandom-seed-service} to seed @file{/dev/urandom} when rebooting.
  9201. It defaults to @file{/var/lib/random-seed}.
  9202. @end defvr
  9203. @cindex keymap
  9204. @cindex keyboard
  9205. @deffn {Scheme Procedure} console-keymap-service @var{files} ...
  9206. @cindex keyboard layout
  9207. Return a service to load console keymaps from @var{files} using
  9208. @command{loadkeys} command. Most likely, you want to load some default
  9209. keymap, which can be done like this:
  9210. @example
  9211. (console-keymap-service "dvorak")
  9212. @end example
  9213. Or, for example, for a Swedish keyboard, you may need to combine
  9214. the following keymaps:
  9215. @example
  9216. (console-keymap-service "se-lat6" "se-fi-lat6")
  9217. @end example
  9218. Also you can specify a full file name (or file names) of your keymap(s).
  9219. See @code{man loadkeys} for details.
  9220. @end deffn
  9221. @cindex mouse
  9222. @cindex gpm
  9223. @defvr {Scheme Variable} gpm-service-type
  9224. This is the type of the service that runs GPM, the @dfn{general-purpose
  9225. mouse daemon}, which provides mouse support to the Linux console. GPM
  9226. allows users to use the mouse in the console, notably to select, copy,
  9227. and paste text.
  9228. The value for services of this type must be a @code{gpm-configuration}
  9229. (see below). This service is not part of @var{%base-services}.
  9230. @end defvr
  9231. @deftp {Data Type} gpm-configuration
  9232. Data type representing the configuration of GPM.
  9233. @table @asis
  9234. @item @code{options} (default: @code{%default-gpm-options})
  9235. Command-line options passed to @command{gpm}. The default set of
  9236. options instruct @command{gpm} to listen to mouse events on
  9237. @file{/dev/input/mice}. @xref{Command Line,,, gpm, gpm manual}, for
  9238. more information.
  9239. @item @code{gpm} (default: @code{gpm})
  9240. The GPM package to use.
  9241. @end table
  9242. @end deftp
  9243. @anchor{guix-publish-service-type}
  9244. @deffn {Scheme Variable} guix-publish-service-type
  9245. This is the service type for @command{guix publish} (@pxref{Invoking
  9246. guix publish}). Its value must be a @code{guix-configuration}
  9247. object, as described below.
  9248. This assumes that @file{/etc/guix} already contains a signing key pair as
  9249. created by @command{guix archive --generate-key} (@pxref{Invoking guix
  9250. archive}). If that is not the case, the service will fail to start.
  9251. @end deffn
  9252. @deftp {Data Type} guix-publish-configuration
  9253. Data type representing the configuration of the @code{guix publish}
  9254. service.
  9255. @table @asis
  9256. @item @code{guix} (default: @code{guix})
  9257. The Guix package to use.
  9258. @item @code{port} (default: @code{80})
  9259. The TCP port to listen for connections.
  9260. @item @code{host} (default: @code{"localhost"})
  9261. The host (and thus, network interface) to listen to. Use
  9262. @code{"0.0.0.0"} to listen on all the network interfaces.
  9263. @item @code{compression-level} (default: @code{3})
  9264. The gzip compression level at which substitutes are compressed. Use
  9265. @code{0} to disable compression altogether, and @code{9} to get the best
  9266. compression ratio at the expense of increased CPU usage.
  9267. @item @code{nar-path} (default: @code{"nar"})
  9268. The URL path at which ``nars'' can be fetched. @xref{Invoking guix
  9269. publish, @code{--nar-path}}, for details.
  9270. @item @code{cache} (default: @code{#f})
  9271. When it is @code{#f}, disable caching and instead generate archives on
  9272. demand. Otherwise, this should be the name of a directory---e.g.,
  9273. @code{"/var/cache/guix/publish"}---where @command{guix publish} caches
  9274. archives and meta-data ready to be sent. @xref{Invoking guix publish,
  9275. @option{--cache}}, for more information on the tradeoffs involved.
  9276. @item @code{workers} (default: @code{#f})
  9277. When it is an integer, this is the number of worker threads used for
  9278. caching; when @code{#f}, the number of processors is used.
  9279. @xref{Invoking guix publish, @option{--workers}}, for more information.
  9280. @item @code{ttl} (default: @code{#f})
  9281. When it is an integer, this denotes the @dfn{time-to-live} in seconds
  9282. of the published archives. @xref{Invoking guix publish, @option{--ttl}},
  9283. for more information.
  9284. @end table
  9285. @end deftp
  9286. @anchor{rngd-service}
  9287. @deffn {Scheme Procedure} rngd-service [#:rng-tools @var{rng-tools}] @
  9288. [#:device "/dev/hwrng"]
  9289. Return a service that runs the @command{rngd} program from @var{rng-tools}
  9290. to add @var{device} to the kernel's entropy pool. The service will fail if
  9291. @var{device} does not exist.
  9292. @end deffn
  9293. @anchor{pam-limits-service}
  9294. @cindex session limits
  9295. @cindex ulimit
  9296. @cindex priority
  9297. @cindex realtime
  9298. @cindex jackd
  9299. @deffn {Scheme Procedure} pam-limits-service [#:limits @code{'()}]
  9300. Return a service that installs a configuration file for the
  9301. @uref{http://linux-pam.org/Linux-PAM-html/sag-pam_limits.html,
  9302. @code{pam_limits} module}. The procedure optionally takes a list of
  9303. @code{pam-limits-entry} values, which can be used to specify
  9304. @code{ulimit} limits and nice priority limits to user sessions.
  9305. The following limits definition sets two hard and soft limits for all
  9306. login sessions of users in the @code{realtime} group:
  9307. @example
  9308. (pam-limits-service
  9309. (list
  9310. (pam-limits-entry "@@realtime" 'both 'rtprio 99)
  9311. (pam-limits-entry "@@realtime" 'both 'memlock 'unlimited)))
  9312. @end example
  9313. The first entry increases the maximum realtime priority for
  9314. non-privileged processes; the second entry lifts any restriction of the
  9315. maximum address space that can be locked in memory. These settings are
  9316. commonly used for real-time audio systems.
  9317. @end deffn
  9318. @node Scheduled Job Execution
  9319. @subsubsection Scheduled Job Execution
  9320. @cindex cron
  9321. @cindex mcron
  9322. @cindex scheduling jobs
  9323. The @code{(gnu services mcron)} module provides an interface to
  9324. GNU@tie{}mcron, a daemon to run jobs at scheduled times (@pxref{Top,,,
  9325. mcron, GNU@tie{}mcron}). GNU@tie{}mcron is similar to the traditional
  9326. Unix @command{cron} daemon; the main difference is that it is
  9327. implemented in Guile Scheme, which provides a lot of flexibility when
  9328. specifying the scheduling of jobs and their actions.
  9329. The example below defines an operating system that runs the
  9330. @command{updatedb} (@pxref{Invoking updatedb,,, find, Finding Files})
  9331. and the @command{guix gc} commands (@pxref{Invoking guix gc}) daily, as
  9332. well as the @command{mkid} command on behalf of an unprivileged user
  9333. (@pxref{mkid invocation,,, idutils, ID Database Utilities}). It uses
  9334. gexps to introduce job definitions that are passed to mcron
  9335. (@pxref{G-Expressions}).
  9336. @lisp
  9337. (use-modules (guix) (gnu) (gnu services mcron))
  9338. (use-package-modules base idutils)
  9339. (define updatedb-job
  9340. ;; Run 'updatedb' at 3AM every day. Here we write the
  9341. ;; job's action as a Scheme procedure.
  9342. #~(job '(next-hour '(3))
  9343. (lambda ()
  9344. (execl (string-append #$findutils "/bin/updatedb")
  9345. "updatedb"
  9346. "--prunepaths=/tmp /var/tmp /gnu/store"))))
  9347. (define garbage-collector-job
  9348. ;; Collect garbage 5 minutes after midnight every day.
  9349. ;; The job's action is a shell command.
  9350. #~(job "5 0 * * *" ;Vixie cron syntax
  9351. "guix gc -F 1G"))
  9352. (define idutils-job
  9353. ;; Update the index database as user "charlie" at 12:15PM
  9354. ;; and 19:15PM. This runs from the user's home directory.
  9355. #~(job '(next-minute-from (next-hour '(12 19)) '(15))
  9356. (string-append #$idutils "/bin/mkid src")
  9357. #:user "charlie"))
  9358. (operating-system
  9359. ;; @dots{}
  9360. (services (cons (mcron-service (list garbage-collector-job
  9361. updatedb-job
  9362. idutils-job))
  9363. %base-services)))
  9364. @end lisp
  9365. @xref{Guile Syntax, mcron job specifications,, mcron, GNU@tie{}mcron},
  9366. for more information on mcron job specifications. Below is the
  9367. reference of the mcron service.
  9368. On a running system, you can use the @code{schedule} action of the service to
  9369. visualize the mcron jobs that will be executed next:
  9370. @example
  9371. # herd schedule mcron
  9372. @end example
  9373. @noindent
  9374. The example above lists the next five tasks that will be executed, but you can
  9375. also specify the number of tasks to display:
  9376. @example
  9377. # herd schedule mcron 10
  9378. @end example
  9379. @deffn {Scheme Procedure} mcron-service @var{jobs} [#:mcron @var{mcron}]
  9380. Return an mcron service running @var{mcron} that schedules @var{jobs}, a
  9381. list of gexps denoting mcron job specifications.
  9382. This is a shorthand for:
  9383. @example
  9384. (service mcron-service-type
  9385. (mcron-configuration (mcron mcron) (jobs jobs)))
  9386. @end example
  9387. @end deffn
  9388. @defvr {Scheme Variable} mcron-service-type
  9389. This is the type of the @code{mcron} service, whose value is an
  9390. @code{mcron-configuration} object.
  9391. This service type can be the target of a service extension that provides
  9392. it additional job specifications (@pxref{Service Composition}). In
  9393. other words, it is possible to define services that provide additional
  9394. mcron jobs to run.
  9395. @end defvr
  9396. @deftp {Data Type} mcron-configuration
  9397. Data type representing the configuration of mcron.
  9398. @table @asis
  9399. @item @code{mcron} (default: @var{mcron})
  9400. The mcron package to use.
  9401. @item @code{jobs}
  9402. This is a list of gexps (@pxref{G-Expressions}), where each gexp
  9403. corresponds to an mcron job specification (@pxref{Syntax, mcron job
  9404. specifications,, mcron, GNU@tie{}mcron}).
  9405. @end table
  9406. @end deftp
  9407. @node Log Rotation
  9408. @subsubsection Log Rotation
  9409. @cindex rottlog
  9410. @cindex log rotation
  9411. @cindex logging
  9412. Log files such as those found in @file{/var/log} tend to grow endlessly,
  9413. so it's a good idea to @dfn{rotate} them once in a while---i.e., archive
  9414. their contents in separate files, possibly compressed. The @code{(gnu
  9415. services admin)} module provides an interface to GNU@tie{}Rot[t]log, a
  9416. log rotation tool (@pxref{Top,,, rottlog, GNU Rot[t]log Manual}).
  9417. The example below defines an operating system that provides log rotation
  9418. with the default settings, for commonly encountered log files.
  9419. @lisp
  9420. (use-modules (guix) (gnu))
  9421. (use-service-modules admin mcron)
  9422. (use-package-modules base idutils)
  9423. (operating-system
  9424. ;; @dots{}
  9425. (services (cons (service rottlog-service-type)
  9426. %base-services)))
  9427. @end lisp
  9428. @defvr {Scheme Variable} rottlog-service-type
  9429. This is the type of the Rottlog service, whose value is a
  9430. @code{rottlog-configuration} object.
  9431. Other services can extend this one with new @code{log-rotation} objects
  9432. (see below), thereby augmenting the set of files to be rotated.
  9433. This service type can define mcron jobs (@pxref{Scheduled Job
  9434. Execution}) to run the rottlog service.
  9435. @end defvr
  9436. @deftp {Data Type} rottlog-configuration
  9437. Data type representing the configuration of rottlog.
  9438. @table @asis
  9439. @item @code{rottlog} (default: @code{rottlog})
  9440. The Rottlog package to use.
  9441. @item @code{rc-file} (default: @code{(file-append rottlog "/etc/rc")})
  9442. The Rottlog configuration file to use (@pxref{Mandatory RC Variables,,,
  9443. rottlog, GNU Rot[t]log Manual}).
  9444. @item @code{rotations} (default: @code{%default-rotations})
  9445. A list of @code{log-rotation} objects as defined below.
  9446. @item @code{jobs}
  9447. This is a list of gexps where each gexp corresponds to an mcron job
  9448. specification (@pxref{Scheduled Job Execution}).
  9449. @end table
  9450. @end deftp
  9451. @deftp {Data Type} log-rotation
  9452. Data type representing the rotation of a group of log files.
  9453. Taking an example from the Rottlog manual (@pxref{Period Related File
  9454. Examples,,, rottlog, GNU Rot[t]log Manual}), a log rotation might be
  9455. defined like this:
  9456. @example
  9457. (log-rotation
  9458. (frequency 'daily)
  9459. (files '("/var/log/apache/*"))
  9460. (options '("storedir apache-archives"
  9461. "rotate 6"
  9462. "notifempty"
  9463. "nocompress")))
  9464. @end example
  9465. The list of fields is as follows:
  9466. @table @asis
  9467. @item @code{frequency} (default: @code{'weekly})
  9468. The log rotation frequency, a symbol.
  9469. @item @code{files}
  9470. The list of files or file glob patterns to rotate.
  9471. @item @code{options} (default: @code{'()})
  9472. The list of rottlog options for this rotation (@pxref{Configuration
  9473. parameters,,, rottlog, GNU Rot[t]lg Manual}).
  9474. @item @code{post-rotate} (default: @code{#f})
  9475. Either @code{#f} or a gexp to execute once the rotation has completed.
  9476. @end table
  9477. @end deftp
  9478. @defvr {Scheme Variable} %default-rotations
  9479. Specifies weekly rotation of @var{%rotated-files} and
  9480. a couple of other files.
  9481. @end defvr
  9482. @defvr {Scheme Variable} %rotated-files
  9483. The list of syslog-controlled files to be rotated. By default it is:
  9484. @code{'("/var/log/messages" "/var/log/secure")}.
  9485. @end defvr
  9486. @node Networking Services
  9487. @subsubsection Networking Services
  9488. The @code{(gnu services networking)} module provides services to configure
  9489. the network interface.
  9490. @cindex DHCP, networking service
  9491. @defvr {Scheme Variable} dhcp-client-service-type
  9492. This is the type of services that run @var{dhcp}, a Dynamic Host Configuration
  9493. Protocol (DHCP) client, on all the non-loopback network interfaces. Its value
  9494. is the DHCP client package to use, @code{isc-dhcp} by default.
  9495. @end defvr
  9496. @deffn {Scheme Procedure} dhcpd-service-type
  9497. This type defines a service that runs a DHCP daemon. To create a
  9498. service of this type, you must supply a @code{<dhcpd-configuration>}.
  9499. For example:
  9500. @example
  9501. (service dhcpd-service-type
  9502. (dhcpd-configuration
  9503. (config-file (local-file "my-dhcpd.conf"))
  9504. (interfaces '("enp0s25"))))
  9505. @end example
  9506. @end deffn
  9507. @deftp {Data Type} dhcpd-configuration
  9508. @table @asis
  9509. @item @code{package} (default: @code{isc-dhcp})
  9510. The package that provides the DHCP daemon. This package is expected to
  9511. provide the daemon at @file{sbin/dhcpd} relative to its output
  9512. directory. The default package is the
  9513. @uref{http://www.isc.org/products/DHCP, ISC's DHCP server}.
  9514. @item @code{config-file} (default: @code{#f})
  9515. The configuration file to use. This is required. It will be passed to
  9516. @code{dhcpd} via its @code{-cf} option. This may be any ``file-like''
  9517. object (@pxref{G-Expressions, file-like objects}). See @code{man
  9518. dhcpd.conf} for details on the configuration file syntax.
  9519. @item @code{version} (default: @code{"4"})
  9520. The DHCP version to use. The ISC DHCP server supports the values ``4'',
  9521. ``6'', and ``4o6''. These correspond to the @code{dhcpd} program
  9522. options @code{-4}, @code{-6}, and @code{-4o6}. See @code{man dhcpd} for
  9523. details.
  9524. @item @code{run-directory} (default: @code{"/run/dhcpd"})
  9525. The run directory to use. At service activation time, this directory
  9526. will be created if it does not exist.
  9527. @item @code{pid-file} (default: @code{"/run/dhcpd/dhcpd.pid"})
  9528. The PID file to use. This corresponds to the @code{-pf} option of
  9529. @code{dhcpd}. See @code{man dhcpd} for details.
  9530. @item @code{interfaces} (default: @code{'()})
  9531. The names of the network interfaces on which dhcpd should listen for
  9532. broadcasts. If this list is not empty, then its elements (which must be
  9533. strings) will be appended to the @code{dhcpd} invocation when starting
  9534. the daemon. It may not be necessary to explicitly specify any
  9535. interfaces here; see @code{man dhcpd} for details.
  9536. @end table
  9537. @end deftp
  9538. @defvr {Scheme Variable} static-networking-service-type
  9539. This is the type for statically-configured network interfaces.
  9540. @c TODO Document <static-networking> data structures.
  9541. @end defvr
  9542. @deffn {Scheme Procedure} static-networking-service @var{interface} @var{ip} @
  9543. [#:netmask #f] [#:gateway #f] [#:name-servers @code{'()}] @
  9544. [#:requirement @code{'(udev)}]
  9545. Return a service that starts @var{interface} with address @var{ip}. If
  9546. @var{netmask} is true, use it as the network mask. If @var{gateway} is true,
  9547. it must be a string specifying the default network gateway. @var{requirement}
  9548. can be used to declare a dependency on another service before configuring the
  9549. interface.
  9550. This procedure can be called several times, one for each network
  9551. interface of interest. Behind the scenes what it does is extend
  9552. @code{static-networking-service-type} with additional network interfaces
  9553. to handle.
  9554. For example:
  9555. @example
  9556. (static-networking-service "eno1" "192.168.1.82"
  9557. #:gateway "192.168.1.2"
  9558. #:name-servers '("192.168.1.2"))
  9559. @end example
  9560. @end deffn
  9561. @cindex wicd
  9562. @cindex wireless
  9563. @cindex WiFi
  9564. @cindex network management
  9565. @deffn {Scheme Procedure} wicd-service [#:wicd @var{wicd}]
  9566. Return a service that runs @url{https://launchpad.net/wicd,Wicd}, a network
  9567. management daemon that aims to simplify wired and wireless networking.
  9568. This service adds the @var{wicd} package to the global profile, providing
  9569. several commands to interact with the daemon and configure networking:
  9570. @command{wicd-client}, a graphical user interface, and the @command{wicd-cli}
  9571. and @command{wicd-curses} user interfaces.
  9572. @end deffn
  9573. @cindex ModemManager
  9574. @defvr {Scheme Variable} modem-manager-service-type
  9575. This is the service type for the
  9576. @uref{https://wiki.gnome.org/Projects/ModemManager, ModemManager}
  9577. service. The value for this service type is a
  9578. @code{modem-manager-configuration} record.
  9579. This service is part of @code{%desktop-services} (@pxref{Desktop
  9580. Services}).
  9581. @end defvr
  9582. @deftp {Data Type} modem-manager-configuration
  9583. Data type representing the configuration of ModemManager.
  9584. @table @asis
  9585. @item @code{modem-manager} (default: @code{modem-manager})
  9586. The ModemManager package to use.
  9587. @end table
  9588. @end deftp
  9589. @cindex NetworkManager
  9590. @defvr {Scheme Variable} network-manager-service-type
  9591. This is the service type for the
  9592. @uref{https://wiki.gnome.org/Projects/NetworkManager, NetworkManager}
  9593. service. The value for this service type is a
  9594. @code{network-manager-configuration} record.
  9595. This service is part of @code{%desktop-services} (@pxref{Desktop
  9596. Services}).
  9597. @end defvr
  9598. @deftp {Data Type} network-manager-configuration
  9599. Data type representing the configuration of NetworkManager.
  9600. @table @asis
  9601. @item @code{network-manager} (default: @code{network-manager})
  9602. The NetworkManager package to use.
  9603. @item @code{dns} (default: @code{"default"})
  9604. Processing mode for DNS, which affects how NetworkManager uses the
  9605. @code{resolv.conf} configuration file.
  9606. @table @samp
  9607. @item default
  9608. NetworkManager will update @code{resolv.conf} to reflect the nameservers
  9609. provided by currently active connections.
  9610. @item dnsmasq
  9611. NetworkManager will run @code{dnsmasq} as a local caching nameserver,
  9612. using a "split DNS" configuration if you are connected to a VPN, and
  9613. then update @code{resolv.conf} to point to the local nameserver.
  9614. @item none
  9615. NetworkManager will not modify @code{resolv.conf}.
  9616. @end table
  9617. @item @code{vpn-plugins} (default: @code{'()})
  9618. This is the list of available plugins for virtual private networks
  9619. (VPNs). An example of this is the @code{network-manager-openvpn}
  9620. package, which allows NetworkManager to manage VPNs @i{via} OpenVPN.
  9621. @end table
  9622. @end deftp
  9623. @cindex Connman
  9624. @deffn {Scheme Variable} connman-service-type
  9625. This is the service type to run @url{https://01.org/connman,Connman},
  9626. a network connection manager.
  9627. Its value must be an
  9628. @code{connman-configuration} record as in this example:
  9629. @example
  9630. (service connman-service-type
  9631. (connman-configuration
  9632. (disable-vpn? #t)))
  9633. @end example
  9634. See below for details about @code{connman-configuration}.
  9635. @end deffn
  9636. @deftp {Data Type} connman-configuration
  9637. Data Type representing the configuration of connman.
  9638. @table @asis
  9639. @item @code{connman} (default: @var{connman})
  9640. The connman package to use.
  9641. @item @code{disable-vpn?} (default: @code{#f})
  9642. When true, disable connman's vpn plugin.
  9643. @end table
  9644. @end deftp
  9645. @cindex WPA Supplicant
  9646. @defvr {Scheme Variable} wpa-supplicant-service-type
  9647. This is the service type to run @url{https://w1.fi/wpa_supplicant/,WPA
  9648. supplicant}, an authentication daemon required to authenticate against
  9649. encrypted WiFi or ethernet networks.
  9650. @end defvr
  9651. @deftp {Data Type} wpa-supplicant-configuration
  9652. Data type representing the configuration of WPA Supplicant.
  9653. It takes the following parameters:
  9654. @table @asis
  9655. @item @code{wpa-supplicant} (default: @code{wpa-supplicant})
  9656. The WPA Supplicant package to use.
  9657. @item @code{dbus?} (default: @code{#t})
  9658. Whether to listen for requests on D-Bus.
  9659. @item @code{pid-file} (default: @code{"/var/run/wpa_supplicant.pid"})
  9660. Where to store the PID file.
  9661. @item @code{interface} (default: @code{#f})
  9662. If this is set, it must specify the name of a network interface that
  9663. WPA supplicant will control.
  9664. @item @code{config-file} (default: @code{#f})
  9665. Optional configuration file to use.
  9666. @item @code{extra-options} (default: @code{'()})
  9667. List of additional command-line arguments to pass to the daemon.
  9668. @end table
  9669. @end deftp
  9670. @cindex iptables
  9671. @defvr {Scheme Variable} iptables-service-type
  9672. This is the service type to set up an iptables configuration. iptables is a
  9673. packet filtering framework supported by the Linux kernel. This service
  9674. supports configuring iptables for both IPv4 and IPv6. A simple example
  9675. configuration rejecting all incoming connections except those to the ssh port
  9676. 22 is shown below.
  9677. @lisp
  9678. (service iptables-service-type
  9679. (iptables-configuration
  9680. (ipv4-rules (plain-file "iptables.rules" "*filter
  9681. :INPUT ACCEPT
  9682. :FORWARD ACCEPT
  9683. :OUTPUT ACCEPT
  9684. -A INPUT -p tcp --dport 22 -j ACCEPT
  9685. -A INPUT -j REJECT --reject-with icmp-port-unreachable
  9686. COMMIT
  9687. "))
  9688. (ipv6-rules (plain-file "ip6tables.rules" "*filter
  9689. :INPUT ACCEPT
  9690. :FORWARD ACCEPT
  9691. :OUTPUT ACCEPT
  9692. -A INPUT -p tcp --dport 22 -j ACCEPT
  9693. -A INPUT -j REJECT --reject-with icmp6-port-unreachable
  9694. COMMIT
  9695. "))))
  9696. @end lisp
  9697. @end defvr
  9698. @deftp {Data Type} iptables-configuration
  9699. The data type representing the configuration of iptables.
  9700. @table @asis
  9701. @item @code{iptables} (default: @code{iptables})
  9702. The iptables package that provides @code{iptables-restore} and
  9703. @code{ip6tables-restore}.
  9704. @item @code{ipv4-rules} (default: @code{%iptables-accept-all-rules})
  9705. The iptables rules to use. It will be passed to @code{iptables-restore}.
  9706. This may be any ``file-like'' object (@pxref{G-Expressions, file-like
  9707. objects}).
  9708. @item @code{ipv6-rules} (default: @code{%iptables-accept-all-rules})
  9709. The ip6tables rules to use. It will be passed to @code{ip6tables-restore}.
  9710. This may be any ``file-like'' object (@pxref{G-Expressions, file-like
  9711. objects}).
  9712. @end table
  9713. @end deftp
  9714. @cindex NTP (Network Time Protocol), service
  9715. @cindex real time clock
  9716. @defvr {Scheme Variable} ntp-service-type
  9717. This is the type of the service running the @uref{http://www.ntp.org,
  9718. Network Time Protocol (NTP)} daemon, @command{ntpd}. The daemon will keep the
  9719. system clock synchronized with that of the specified NTP servers.
  9720. The value of this service is an @code{ntpd-configuration} object, as described
  9721. below.
  9722. @end defvr
  9723. @deftp {Data Type} ntp-configuration
  9724. This is the data type for the NTP service configuration.
  9725. @table @asis
  9726. @item @code{servers} (default: @code{%ntp-servers})
  9727. This is the list of servers (host names) with which @command{ntpd} will be
  9728. synchronized.
  9729. @item @code{allow-large-adjustment?} (default: @code{#f})
  9730. This determines whether @command{ntpd} is allowed to make an initial
  9731. adjustment of more than 1,000 seconds.
  9732. @item @code{ntp} (default: @code{ntp})
  9733. The NTP package to use.
  9734. @end table
  9735. @end deftp
  9736. @defvr {Scheme Variable} %ntp-servers
  9737. List of host names used as the default NTP servers. These are servers of the
  9738. @uref{https://www.ntppool.org/en/, NTP Pool Project}.
  9739. @end defvr
  9740. @cindex OpenNTPD
  9741. @deffn {Scheme Procedure} openntpd-service-type
  9742. Run the @command{ntpd}, the Network Time Protocol (NTP) daemon, as implemented
  9743. by @uref{http://www.openntpd.org, OpenNTPD}. The daemon will keep the system
  9744. clock synchronized with that of the given servers.
  9745. @example
  9746. (service
  9747. openntpd-service-type
  9748. (openntpd-configuration
  9749. (listen-on '("127.0.0.1" "::1"))
  9750. (sensor '("udcf0 correction 70000"))
  9751. (constraint-from '("www.gnu.org"))
  9752. (constraints-from '("https://www.google.com/"))
  9753. (allow-large-adjustment? #t)))
  9754. @end example
  9755. @end deffn
  9756. @deftp {Data Type} openntpd-configuration
  9757. @table @asis
  9758. @item @code{openntpd} (default: @code{(file-append openntpd "/sbin/ntpd")})
  9759. The openntpd executable to use.
  9760. @item @code{listen-on} (default: @code{'("127.0.0.1" "::1")})
  9761. A list of local IP addresses or hostnames the ntpd daemon should listen on.
  9762. @item @code{query-from} (default: @code{'()})
  9763. A list of local IP address the ntpd daemon should use for outgoing queries.
  9764. @item @code{sensor} (default: @code{'()})
  9765. Specify a list of timedelta sensor devices ntpd should use. @code{ntpd}
  9766. will listen to each sensor that acutally exists and ignore non-existant ones.
  9767. See @uref{https://man.openbsd.org/ntpd.conf, upstream documentation} for more
  9768. information.
  9769. @item @code{server} (default: @var{%ntp-servers})
  9770. Specify a list of IP addresses or hostnames of NTP servers to synchronize to.
  9771. @item @code{servers} (default: @code{'()})
  9772. Specify a list of IP addresses or hostnames of NTP pools to synchronize to.
  9773. @item @code{constraint-from} (default: @code{'()})
  9774. @code{ntpd} can be configured to query the ‘Date’ from trusted HTTPS servers via TLS.
  9775. This time information is not used for precision but acts as an authenticated
  9776. constraint, thereby reducing the impact of unauthenticated NTP
  9777. man-in-the-middle attacks.
  9778. Specify a list of URLs, IP addresses or hostnames of HTTPS servers to provide
  9779. a constraint.
  9780. @item @code{constraints-from} (default: @code{'()})
  9781. As with constraint from, specify a list of URLs, IP addresses or hostnames of
  9782. HTTPS servers to provide a constraint. Should the hostname resolve to multiple
  9783. IP addresses, @code{ntpd} will calculate a median constraint from all of them.
  9784. @item @code{allow-large-adjustment?} (default: @code{#f})
  9785. Determines if @code{ntpd} is allowed to make an initial adjustment of more
  9786. than 180 seconds.
  9787. @end table
  9788. @end deftp
  9789. @cindex inetd
  9790. @deffn {Scheme variable} inetd-service-type
  9791. This service runs the @command{inetd} (@pxref{inetd invocation,,,
  9792. inetutils, GNU Inetutils}) daemon. @command{inetd} listens for
  9793. connections on internet sockets, and lazily starts the specified server
  9794. program when a connection is made on one of these sockets.
  9795. The value of this service is an @code{inetd-configuration} object. The
  9796. following example configures the @command{inetd} daemon to provide the
  9797. built-in @command{echo} service, as well as an smtp service which
  9798. forwards smtp traffic over ssh to a server @code{smtp-server} behind a
  9799. gateway @code{hostname}:
  9800. @example
  9801. (service
  9802. inetd-service-type
  9803. (inetd-configuration
  9804. (entries (list
  9805. (inetd-entry
  9806. (name "echo")
  9807. (socket-type 'stream)
  9808. (protocol "tcp")
  9809. (wait? #f)
  9810. (user "root"))
  9811. (inetd-entry
  9812. (node "127.0.0.1")
  9813. (name "smtp")
  9814. (socket-type 'stream)
  9815. (protocol "tcp")
  9816. (wait? #f)
  9817. (user "root")
  9818. (program (file-append openssh "/bin/ssh"))
  9819. (arguments
  9820. '("ssh" "-qT" "-i" "/path/to/ssh_key"
  9821. "-W" "smtp-server:25" "user@@hostname")))))
  9822. @end example
  9823. See below for more details about @code{inetd-configuration}.
  9824. @end deffn
  9825. @deftp {Data Type} inetd-configuration
  9826. Data type representing the configuration of @command{inetd}.
  9827. @table @asis
  9828. @item @code{program} (default: @code{(file-append inetutils "/libexec/inetd")})
  9829. The @command{inetd} executable to use.
  9830. @item @code{entries} (default: @code{'()})
  9831. A list of @command{inetd} service entries. Each entry should be created
  9832. by the @code{inetd-entry} constructor.
  9833. @end table
  9834. @end deftp
  9835. @deftp {Data Type} inetd-entry
  9836. Data type representing an entry in the @command{inetd} configuration.
  9837. Each entry corresponds to a socket where @command{inetd} will listen for
  9838. requests.
  9839. @table @asis
  9840. @item @code{node} (default: @code{#f})
  9841. Optional string, a comma-separated list of local addresses
  9842. @command{inetd} should use when listening for this service.
  9843. @xref{Configuration file,,, inetutils, GNU Inetutils} for a complete
  9844. description of all options.
  9845. @item @code{name}
  9846. A string, the name must correspond to an entry in @code{/etc/services}.
  9847. @item @code{socket-type}
  9848. One of @code{'stream}, @code{'dgram}, @code{'raw}, @code{'rdm} or
  9849. @code{'seqpacket}.
  9850. @item @code{protocol}
  9851. A string, must correspond to an entry in @code{/etc/protocols}.
  9852. @item @code{wait?} (default: @code{#t})
  9853. Whether @command{inetd} should wait for the server to exit before
  9854. listening to new service requests.
  9855. @item @code{user}
  9856. A string containing the user (and, optionally, group) name of the user
  9857. as whom the server should run. The group name can be specified in a
  9858. suffix, separated by a colon or period, i.e.@: @code{"user"},
  9859. @code{"user:group"} or @code{"user.group"}.
  9860. @item @code{program} (default: @code{"internal"})
  9861. The server program which will serve the requests, or @code{"internal"}
  9862. if @command{inetd} should use a built-in service.
  9863. @item @code{arguments} (default: @code{'()})
  9864. A list strings or file-like objects, which are the server program's
  9865. arguments, starting with the zeroth argument, i.e.@: the name of the
  9866. program itself. For @command{inetd}'s internal services, this entry
  9867. must be @code{'()} or @code{'("internal")}.
  9868. @end table
  9869. @xref{Configuration file,,, inetutils, GNU Inetutils} for a more
  9870. detailed discussion of each configuration field.
  9871. @end deftp
  9872. @cindex Tor
  9873. @defvr {Scheme Variable} tor-service-type
  9874. This is the type for a service that runs the @uref{https://torproject.org,
  9875. Tor} anonymous networking daemon. The service is configured using a
  9876. @code{<tor-configuration>} record. By default, the Tor daemon runs as the
  9877. @code{tor} unprivileged user, which is a member of the @code{tor} group.
  9878. @end defvr
  9879. @deffn {Scheme Procedure} tor-service [@var{config-file}] [#:tor @var{tor}]
  9880. This procedure is deprecated and will be removed in a future release. Return
  9881. a service of the @code{tor-service-type} type. @var{config-file} and
  9882. @var{tor} have the same meaning as in @code{<tor-configuration>}.
  9883. @end deffn
  9884. @deftp {Data Type} tor-configuration
  9885. @table @asis
  9886. @item @code{tor} (default: @code{tor})
  9887. The package that provides the Tor daemon. This package is expected to provide
  9888. the daemon at @file{bin/tor} relative to its output directory. The default
  9889. package is the @uref{https://www.torproject.org, Tor Project's}
  9890. implementation.
  9891. @item @code{config-file} (default: @code{(plain-file "empty" "")})
  9892. The configuration file to use. It will be appended to a default configuration
  9893. file, and the final configuration file will be passed to @code{tor} via its
  9894. @code{-f} option. This may be any ``file-like'' object (@pxref{G-Expressions,
  9895. file-like objects}). See @code{man tor} for details on the configuration file
  9896. syntax.
  9897. @item @code{hidden-services} (default: @code{'()})
  9898. The list of @code{<hidden-service>} records to use. For any hidden service
  9899. you include in this list, appropriate configuration to enable the hidden
  9900. service will be automatically added to the default configuration file. You
  9901. may conveniently create @code{<hidden-service>} records using the
  9902. @code{tor-hidden-service} procedure described below.
  9903. @item @code{socks-socket-type} (default: @code{'tcp})
  9904. The default socket type that Tor should use for its SOCKS socket. This must
  9905. be either @code{'tcp} or @code{'unix}. If it is @code{'tcp}, then by default
  9906. Tor will listen on TCP port 9050 on the loopback interface (i.e., localhost).
  9907. If it is @code{'unix}, then Tor will listen on the UNIX domain socket
  9908. @file{/var/run/tor/socks-sock}, which will be made writable by members of the
  9909. @code{tor} group.
  9910. If you want to customize the SOCKS socket in more detail, leave
  9911. @code{socks-socket-type} at its default value of @code{'tcp} and use
  9912. @code{config-file} to override the default by providing your own
  9913. @code{SocksPort} option.
  9914. @end table
  9915. @end deftp
  9916. @cindex hidden service
  9917. @deffn {Scheme Procedure} tor-hidden-service @var{name} @var{mapping}
  9918. Define a new Tor @dfn{hidden service} called @var{name} and implementing
  9919. @var{mapping}. @var{mapping} is a list of port/host tuples, such as:
  9920. @example
  9921. '((22 "127.0.0.1:22")
  9922. (80 "127.0.0.1:8080"))
  9923. @end example
  9924. In this example, port 22 of the hidden service is mapped to local port 22, and
  9925. port 80 is mapped to local port 8080.
  9926. This creates a @file{/var/lib/tor/hidden-services/@var{name}} directory, where
  9927. the @file{hostname} file contains the @code{.onion} host name for the hidden
  9928. service.
  9929. See @uref{https://www.torproject.org/docs/tor-hidden-service.html.en, the Tor
  9930. project's documentation} for more information.
  9931. @end deffn
  9932. The @code{(gnu services rsync)} module provides the following services:
  9933. You might want an rsync daemon if you have files that you want available
  9934. so anyone (or just yourself) can download existing files or upload new
  9935. files.
  9936. @deffn {Scheme Variable} rsync-service-type
  9937. This is the type for the @uref{https://rsync.samba.org, rsync} rsync daemon,
  9938. @command{rsync-configuration} record as in this example:
  9939. @example
  9940. (service rsync-service-type)
  9941. @end example
  9942. See below for details about @code{rsync-configuration}.
  9943. @end deffn
  9944. @deftp {Data Type} rsync-configuration
  9945. Data type representing the configuration for @code{rsync-service}.
  9946. @table @asis
  9947. @item @code{package} (default: @var{rsync})
  9948. @code{rsync} package to use.
  9949. @item @code{port-number} (default: @code{873})
  9950. TCP port on which @command{rsync} listens for incoming connections. If port
  9951. is less than @code{1024} @command{rsync} needs to be started as the
  9952. @code{root} user and group.
  9953. @item @code{pid-file} (default: @code{"/var/run/rsyncd/rsyncd.pid"})
  9954. Name of the file where @command{rsync} writes its PID.
  9955. @item @code{lock-file} (default: @code{"/var/run/rsyncd/rsyncd.lock"})
  9956. Name of the file where @command{rsync} writes its lock file.
  9957. @item @code{log-file} (default: @code{"/var/log/rsyncd.log"})
  9958. Name of the file where @command{rsync} writes its log file.
  9959. @item @code{use-chroot?} (default: @var{#t})
  9960. Whether to use chroot for @command{rsync} shared directory.
  9961. @item @code{share-path} (default: @file{/srv/rsync})
  9962. Location of the @command{rsync} shared directory.
  9963. @item @code{share-comment} (default: @code{"Rsync share"})
  9964. Comment of the @command{rsync} shared directory.
  9965. @item @code{read-only?} (default: @var{#f})
  9966. Read-write permissions to shared directory.
  9967. @item @code{timeout} (default: @code{300})
  9968. I/O timeout in seconds.
  9969. @item @code{user} (default: @var{"root"})
  9970. Owner of the @code{rsync} process.
  9971. @item @code{group} (default: @var{"root"})
  9972. Group of the @code{rsync} process.
  9973. @item @code{uid} (default: @var{"rsyncd"})
  9974. User name or user ID that file transfers to and from that module should take
  9975. place as when the daemon was run as @code{root}.
  9976. @item @code{gid} (default: @var{"rsyncd"})
  9977. Group name or group ID that will be used when accessing the module.
  9978. @end table
  9979. @end deftp
  9980. Furthermore, @code{(gnu services ssh)} provides the following services.
  9981. @cindex SSH
  9982. @cindex SSH server
  9983. @deffn {Scheme Procedure} lsh-service [#:host-key "/etc/lsh/host-key"] @
  9984. [#:daemonic? #t] [#:interfaces '()] [#:port-number 22] @
  9985. [#:allow-empty-passwords? #f] [#:root-login? #f] @
  9986. [#:syslog-output? #t] [#:x11-forwarding? #t] @
  9987. [#:tcp/ip-forwarding? #t] [#:password-authentication? #t] @
  9988. [#:public-key-authentication? #t] [#:initialize? #t]
  9989. Run the @command{lshd} program from @var{lsh} to listen on port @var{port-number}.
  9990. @var{host-key} must designate a file containing the host key, and readable
  9991. only by root.
  9992. When @var{daemonic?} is true, @command{lshd} will detach from the
  9993. controlling terminal and log its output to syslogd, unless one sets
  9994. @var{syslog-output?} to false. Obviously, it also makes lsh-service
  9995. depend on existence of syslogd service. When @var{pid-file?} is true,
  9996. @command{lshd} writes its PID to the file called @var{pid-file}.
  9997. When @var{initialize?} is true, automatically create the seed and host key
  9998. upon service activation if they do not exist yet. This may take long and
  9999. require interaction.
  10000. When @var{initialize?} is false, it is up to the user to initialize the
  10001. randomness generator (@pxref{lsh-make-seed,,, lsh, LSH Manual}), and to create
  10002. a key pair with the private key stored in file @var{host-key} (@pxref{lshd
  10003. basics,,, lsh, LSH Manual}).
  10004. When @var{interfaces} is empty, lshd listens for connections on all the
  10005. network interfaces; otherwise, @var{interfaces} must be a list of host names
  10006. or addresses.
  10007. @var{allow-empty-passwords?} specifies whether to accept log-ins with empty
  10008. passwords, and @var{root-login?} specifies whether to accept log-ins as
  10009. root.
  10010. The other options should be self-descriptive.
  10011. @end deffn
  10012. @cindex SSH
  10013. @cindex SSH server
  10014. @deffn {Scheme Variable} openssh-service-type
  10015. This is the type for the @uref{http://www.openssh.org, OpenSSH} secure
  10016. shell daemon, @command{sshd}. Its value must be an
  10017. @code{openssh-configuration} record as in this example:
  10018. @example
  10019. (service openssh-service-type
  10020. (openssh-configuration
  10021. (x11-forwarding? #t)
  10022. (permit-root-login 'without-password)
  10023. (authorized-keys
  10024. `(("alice" ,(local-file "alice.pub"))
  10025. ("bob" ,(local-file "bob.pub"))))))
  10026. @end example
  10027. See below for details about @code{openssh-configuration}.
  10028. This service can be extended with extra authorized keys, as in this
  10029. example:
  10030. @example
  10031. (service-extension openssh-service-type
  10032. (const `(("charlie"
  10033. ,(local-file "charlie.pub")))))
  10034. @end example
  10035. @end deffn
  10036. @deftp {Data Type} openssh-configuration
  10037. This is the configuration record for OpenSSH's @command{sshd}.
  10038. @table @asis
  10039. @item @code{pid-file} (default: @code{"/var/run/sshd.pid"})
  10040. Name of the file where @command{sshd} writes its PID.
  10041. @item @code{port-number} (default: @code{22})
  10042. TCP port on which @command{sshd} listens for incoming connections.
  10043. @item @code{permit-root-login} (default: @code{#f})
  10044. This field determines whether and when to allow logins as root. If
  10045. @code{#f}, root logins are disallowed; if @code{#t}, they are allowed.
  10046. If it's the symbol @code{'without-password}, then root logins are
  10047. permitted but not with password-based authentication.
  10048. @item @code{allow-empty-passwords?} (default: @code{#f})
  10049. When true, users with empty passwords may log in. When false, they may
  10050. not.
  10051. @item @code{password-authentication?} (default: @code{#t})
  10052. When true, users may log in with their password. When false, they have
  10053. other authentication methods.
  10054. @item @code{public-key-authentication?} (default: @code{#t})
  10055. When true, users may log in using public key authentication. When
  10056. false, users have to use other authentication method.
  10057. Authorized public keys are stored in @file{~/.ssh/authorized_keys}.
  10058. This is used only by protocol version 2.
  10059. @item @code{x11-forwarding?} (default: @code{#f})
  10060. When true, forwarding of X11 graphical client connections is
  10061. enabled---in other words, @command{ssh} options @option{-X} and
  10062. @option{-Y} will work.
  10063. @item @code{allow-agent-forwarding?} (default: @code{#t})
  10064. Whether to allow agent forwarding.
  10065. @item @code{allow-tcp-forwarding?} (default: @code{#t})
  10066. Whether to allow TCP forwarding.
  10067. @item @code{gateway-ports?} (default: @code{#f})
  10068. Whether to allow gateway ports.
  10069. @item @code{challenge-response-authentication?} (default: @code{#f})
  10070. Specifies whether challenge response authentication is allowed (e.g.@: via
  10071. PAM).
  10072. @item @code{use-pam?} (default: @code{#t})
  10073. Enables the Pluggable Authentication Module interface. If set to
  10074. @code{#t}, this will enable PAM authentication using
  10075. @code{challenge-response-authentication?} and
  10076. @code{password-authentication?}, in addition to PAM account and session
  10077. module processing for all authentication types.
  10078. Because PAM challenge response authentication usually serves an
  10079. equivalent role to password authentication, you should disable either
  10080. @code{challenge-response-authentication?} or
  10081. @code{password-authentication?}.
  10082. @item @code{print-last-log?} (default: @code{#t})
  10083. Specifies whether @command{sshd} should print the date and time of the
  10084. last user login when a user logs in interactively.
  10085. @item @code{subsystems} (default: @code{'(("sftp" "internal-sftp"))})
  10086. Configures external subsystems (e.g.@: file transfer daemon).
  10087. This is a list of two-element lists, each of which containing the
  10088. subsystem name and a command (with optional arguments) to execute upon
  10089. subsystem request.
  10090. The command @command{internal-sftp} implements an in-process SFTP
  10091. server. Alternately, one can specify the @command{sftp-server} command:
  10092. @example
  10093. (service openssh-service-type
  10094. (openssh-configuration
  10095. (subsystems
  10096. `(("sftp" ,(file-append openssh "/libexec/sftp-server"))))))
  10097. @end example
  10098. @item @code{accepted-environment} (default: @code{'()})
  10099. List of strings describing which environment variables may be exported.
  10100. Each string gets on its own line. See the @code{AcceptEnv} option in
  10101. @code{man sshd_config}.
  10102. This example allows ssh-clients to export the @code{COLORTERM} variable.
  10103. It is set by terminal emulators, which support colors. You can use it in
  10104. your shell's ressource file to enable colors for the prompt and commands
  10105. if this variable is set.
  10106. @example
  10107. (service openssh-service-type
  10108. (openssh-configuration
  10109. (accepted-environment '("COLORTERM"))))
  10110. @end example
  10111. @item @code{authorized-keys} (default: @code{'()})
  10112. @cindex authorized keys, SSH
  10113. @cindex SSH authorized keys
  10114. This is the list of authorized keys. Each element of the list is a user
  10115. name followed by one or more file-like objects that represent SSH public
  10116. keys. For example:
  10117. @example
  10118. (openssh-configuration
  10119. (authorized-keys
  10120. `(("rekado" ,(local-file "rekado.pub"))
  10121. ("chris" ,(local-file "chris.pub"))
  10122. ("root" ,(local-file "rekado.pub") ,(local-file "chris.pub")))))
  10123. @end example
  10124. @noindent
  10125. registers the specified public keys for user accounts @code{rekado},
  10126. @code{chris}, and @code{root}.
  10127. Additional authorized keys can be specified @i{via}
  10128. @code{service-extension}.
  10129. Note that this does @emph{not} interfere with the use of
  10130. @file{~/.ssh/authorized_keys}.
  10131. @item @code{log-level} (default: @code{'info})
  10132. This is a symbol specifying the logging level: @code{quiet}, @code{fatal},
  10133. @code{error}, @code{info}, @code{verbose}, @code{debug}, etc. See the man
  10134. page for @file{sshd_config} for the full list of level names.
  10135. @end table
  10136. @end deftp
  10137. @deffn {Scheme Procedure} dropbear-service [@var{config}]
  10138. Run the @uref{https://matt.ucc.asn.au/dropbear/dropbear.html,Dropbear SSH
  10139. daemon} with the given @var{config}, a @code{<dropbear-configuration>}
  10140. object.
  10141. For example, to specify a Dropbear service listening on port 1234, add
  10142. this call to the operating system's @code{services} field:
  10143. @example
  10144. (dropbear-service (dropbear-configuration
  10145. (port-number 1234)))
  10146. @end example
  10147. @end deffn
  10148. @deftp {Data Type} dropbear-configuration
  10149. This data type represents the configuration of a Dropbear SSH daemon.
  10150. @table @asis
  10151. @item @code{dropbear} (default: @var{dropbear})
  10152. The Dropbear package to use.
  10153. @item @code{port-number} (default: 22)
  10154. The TCP port where the daemon waits for incoming connections.
  10155. @item @code{syslog-output?} (default: @code{#t})
  10156. Whether to enable syslog output.
  10157. @item @code{pid-file} (default: @code{"/var/run/dropbear.pid"})
  10158. File name of the daemon's PID file.
  10159. @item @code{root-login?} (default: @code{#f})
  10160. Whether to allow @code{root} logins.
  10161. @item @code{allow-empty-passwords?} (default: @code{#f})
  10162. Whether to allow empty passwords.
  10163. @item @code{password-authentication?} (default: @code{#t})
  10164. Whether to enable password-based authentication.
  10165. @end table
  10166. @end deftp
  10167. @defvr {Scheme Variable} %facebook-host-aliases
  10168. This variable contains a string for use in @file{/etc/hosts}
  10169. (@pxref{Host Names,,, libc, The GNU C Library Reference Manual}). Each
  10170. line contains a entry that maps a known server name of the Facebook
  10171. on-line service---e.g., @code{www.facebook.com}---to the local
  10172. host---@code{127.0.0.1} or its IPv6 equivalent, @code{::1}.
  10173. This variable is typically used in the @code{hosts-file} field of an
  10174. @code{operating-system} declaration (@pxref{operating-system Reference,
  10175. @file{/etc/hosts}}):
  10176. @example
  10177. (use-modules (gnu) (guix))
  10178. (operating-system
  10179. (host-name "mymachine")
  10180. ;; ...
  10181. (hosts-file
  10182. ;; Create a /etc/hosts file with aliases for "localhost"
  10183. ;; and "mymachine", as well as for Facebook servers.
  10184. (plain-file "hosts"
  10185. (string-append (local-host-aliases host-name)
  10186. %facebook-host-aliases))))
  10187. @end example
  10188. This mechanism can prevent programs running locally, such as Web
  10189. browsers, from accessing Facebook.
  10190. @end defvr
  10191. The @code{(gnu services avahi)} provides the following definition.
  10192. @deffn {Scheme Procedure} avahi-service [#:avahi @var{avahi}] @
  10193. [#:host-name #f] [#:publish? #t] [#:ipv4? #t] @
  10194. [#:ipv6? #t] [#:wide-area? #f] @
  10195. [#:domains-to-browse '()] [#:debug? #f]
  10196. Return a service that runs @command{avahi-daemon}, a system-wide
  10197. mDNS/DNS-SD responder that allows for service discovery and
  10198. "zero-configuration" host name lookups (see @uref{http://avahi.org/}), and
  10199. extends the name service cache daemon (nscd) so that it can resolve
  10200. @code{.local} host names using
  10201. @uref{http://0pointer.de/lennart/projects/nss-mdns/, nss-mdns}. Additionally,
  10202. add the @var{avahi} package to the system profile so that commands such as
  10203. @command{avahi-browse} are directly usable.
  10204. If @var{host-name} is different from @code{#f}, use that as the host name to
  10205. publish for this machine; otherwise, use the machine's actual host name.
  10206. When @var{publish?} is true, publishing of host names and services is allowed;
  10207. in particular, avahi-daemon will publish the machine's host name and IP
  10208. address via mDNS on the local network.
  10209. When @var{wide-area?} is true, DNS-SD over unicast DNS is enabled.
  10210. Boolean values @var{ipv4?} and @var{ipv6?} determine whether to use IPv4/IPv6
  10211. sockets.
  10212. @end deffn
  10213. @deffn {Scheme Variable} openvswitch-service-type
  10214. This is the type of the @uref{http://www.openvswitch.org, Open vSwitch}
  10215. service, whose value should be an @code{openvswitch-configuration}
  10216. object.
  10217. @end deffn
  10218. @deftp {Data Type} openvswitch-configuration
  10219. Data type representing the configuration of Open vSwitch, a multilayer
  10220. virtual switch which is designed to enable massive network automation
  10221. through programmatic extension.
  10222. @table @asis
  10223. @item @code{package} (default: @var{openvswitch})
  10224. Package object of the Open vSwitch.
  10225. @end table
  10226. @end deftp
  10227. @node X Window
  10228. @subsubsection X Window
  10229. @cindex X11
  10230. @cindex X Window System
  10231. @cindex login manager
  10232. Support for the X Window graphical display system---specifically
  10233. Xorg---is provided by the @code{(gnu services xorg)} module. Note that
  10234. there is no @code{xorg-service} procedure. Instead, the X server is
  10235. started by the @dfn{login manager}, by default SLiM.
  10236. @cindex window manager
  10237. To use X11, you must install at least one @dfn{window manager}---for
  10238. example the @code{windowmaker} or @code{openbox} packages---preferably
  10239. by adding it to the @code{packages} field of your operating system
  10240. definition (@pxref{operating-system Reference, system-wide packages}).
  10241. @defvr {Scheme Variable} slim-service-type
  10242. This is the type for the SLiM graphical login manager for X11.
  10243. @cindex session types (X11)
  10244. @cindex X11 session types
  10245. SLiM looks for @dfn{session types} described by the @file{.desktop} files in
  10246. @file{/run/current-system/profile/share/xsessions} and allows users to
  10247. choose a session from the log-in screen using @kbd{F1}. Packages such
  10248. as @code{xfce}, @code{sawfish}, and @code{ratpoison} provide
  10249. @file{.desktop} files; adding them to the system-wide set of packages
  10250. automatically makes them available at the log-in screen.
  10251. In addition, @file{~/.xsession} files are honored. When available,
  10252. @file{~/.xsession} must be an executable that starts a window manager
  10253. and/or other X clients.
  10254. @end defvr
  10255. @deftp {Data Type} slim-configuration
  10256. Data type representing the configuration of @code{slim-service-type}.
  10257. @table @asis
  10258. @item @code{allow-empty-passwords?} (default: @code{#t})
  10259. Whether to allow logins with empty passwords.
  10260. @item @code{auto-login?} (default: @code{#f})
  10261. @itemx @code{default-user} (default: @code{""})
  10262. When @code{auto-login?} is false, SLiM presents a log-in screen.
  10263. When @code{auto-login?} is true, SLiM logs in directly as
  10264. @code{default-user}.
  10265. @item @code{theme} (default: @code{%default-slim-theme})
  10266. @itemx @code{theme-name} (default: @code{%default-slim-theme-name})
  10267. The graphical theme to use and its name.
  10268. @item @code{auto-login-session} (default: @code{#f})
  10269. If true, this must be the name of the executable to start as the default
  10270. session---e.g., @code{(file-append windowmaker "/bin/windowmaker")}.
  10271. If false, a session described by one of the available @file{.desktop}
  10272. files in @code{/run/current-system/profile} and @code{~/.guix-profile}
  10273. will be used.
  10274. @quotation Note
  10275. You must install at least one window manager in the system profile or in
  10276. your user profile. Failing to do that, if @code{auto-login-session} is
  10277. false, you will be unable to log in.
  10278. @end quotation
  10279. @item @code{startx} (default: @code{(xorg-start-command)})
  10280. The command used to start the X11 graphical server.
  10281. @item @code{xauth} (default: @code{xauth})
  10282. The XAuth package to use.
  10283. @item @code{shepherd} (default: @code{shepherd})
  10284. The Shepherd package used when invoking @command{halt} and
  10285. @command{reboot}.
  10286. @item @code{sessreg} (default: @code{sessreg})
  10287. The sessreg package used in order to register the session.
  10288. @item @code{slim} (default: @code{slim})
  10289. The SLiM package to use.
  10290. @end table
  10291. @end deftp
  10292. @defvr {Scheme Variable} %default-theme
  10293. @defvrx {Scheme Variable} %default-theme-name
  10294. The default SLiM theme and its name.
  10295. @end defvr
  10296. @deftp {Data Type} sddm-configuration
  10297. This is the data type representing the sddm service configuration.
  10298. @table @asis
  10299. @item @code{display-server} (default: "x11")
  10300. Select display server to use for the greeter. Valid values are "x11"
  10301. or "wayland".
  10302. @item @code{numlock} (default: "on")
  10303. Valid values are "on", "off" or "none".
  10304. @item @code{halt-command} (default @code{#~(string-apppend #$shepherd "/sbin/halt")})
  10305. Command to run when halting.
  10306. @item @code{reboot-command} (default @code{#~(string-append #$shepherd "/sbin/reboot")})
  10307. Command to run when rebooting.
  10308. @item @code{theme} (default "maldives")
  10309. Theme to use. Default themes provided by SDDM are "elarun" or "maldives".
  10310. @item @code{themes-directory} (default "/run/current-system/profile/share/sddm/themes")
  10311. Directory to look for themes.
  10312. @item @code{faces-directory} (default "/run/current-system/profile/share/sddm/faces")
  10313. Directory to look for faces.
  10314. @item @code{default-path} (default "/run/current-system/profile/bin")
  10315. Default PATH to use.
  10316. @item @code{minimum-uid} (default 1000)
  10317. Minimum UID to display in SDDM.
  10318. @item @code{maximum-uid} (default 2000)
  10319. Maximum UID to display in SDDM
  10320. @item @code{remember-last-user?} (default #t)
  10321. Remember last user.
  10322. @item @code{remember-last-session?} (default #t)
  10323. Remember last session.
  10324. @item @code{hide-users} (default "")
  10325. Usernames to hide from SDDM greeter.
  10326. @item @code{hide-shells} (default @code{#~(string-append #$shadow "/sbin/nologin")})
  10327. Users with shells listed will be hidden from the SDDM greeter.
  10328. @item @code{session-command} (default @code{#~(string-append #$sddm "/share/sddm/scripts/wayland-session")})
  10329. Script to run before starting a wayland session.
  10330. @item @code{sessions-directory} (default "/run/current-system/profile/share/wayland-sessions")
  10331. Directory to look for desktop files starting wayland sessions.
  10332. @item @code{xorg-server-path} (default @code{xorg-start-command})
  10333. Path to xorg-server.
  10334. @item @code{xauth-path} (default @code{#~(string-append #$xauth "/bin/xauth")})
  10335. Path to xauth.
  10336. @item @code{xephyr-path} (default @code{#~(string-append #$xorg-server "/bin/Xephyr")})
  10337. Path to Xephyr.
  10338. @item @code{xdisplay-start} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xsetup")})
  10339. Script to run after starting xorg-server.
  10340. @item @code{xdisplay-stop} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xstop")})
  10341. Script to run before stopping xorg-server.
  10342. @item @code{xsession-command} (default: @code{xinitrc})
  10343. Script to run before starting a X session.
  10344. @item @code{xsessions-directory} (default: "/run/current-system/profile/share/xsessions")
  10345. Directory to look for desktop files starting X sessions.
  10346. @item @code{minimum-vt} (default: 7)
  10347. Minimum VT to use.
  10348. @item @code{xserver-arguments} (default "-nolisten tcp")
  10349. Arguments to pass to xorg-server.
  10350. @item @code{auto-login-user} (default "")
  10351. User to use for auto-login.
  10352. @item @code{auto-login-session} (default "")
  10353. Desktop file to use for auto-login.
  10354. @item @code{relogin?} (default #f)
  10355. Relogin after logout.
  10356. @end table
  10357. @end deftp
  10358. @cindex login manager
  10359. @cindex X11 login
  10360. @deffn {Scheme Procedure} sddm-service config
  10361. Return a service that spawns the SDDM graphical login manager for config of
  10362. type @code{<sddm-configuration>}.
  10363. @example
  10364. (sddm-service (sddm-configuration
  10365. (auto-login-user "Alice")
  10366. (auto-login-session "xfce.desktop")))
  10367. @end example
  10368. @end deffn
  10369. @deffn {Scheme Procedure} xorg-start-command [#:guile] @
  10370. [#:modules %default-xorg-modules] @
  10371. [#:fonts %default-xorg-fonts] @
  10372. [#:configuration-file (xorg-configuration-file @dots{})] @
  10373. [#:xorg-server @var{xorg-server}]
  10374. Return a @code{startx} script in which @var{modules}, a list of X module
  10375. packages, and @var{fonts}, a list of X font directories, are available. See
  10376. @code{xorg-wrapper} for more details on the arguments. The result should be
  10377. used in place of @code{startx}.
  10378. Usually the X server is started by a login manager.
  10379. @end deffn
  10380. @deffn {Scheme Procedure} xorg-configuration-file @
  10381. [#:modules %default-xorg-modules] @
  10382. [#:fonts %default-xorg-fonts] @
  10383. [#:drivers '()] [#:resolutions '()] [#:extra-config '()]
  10384. Return a configuration file for the Xorg server containing search paths for
  10385. all the common drivers.
  10386. @var{modules} must be a list of @dfn{module packages} loaded by the Xorg
  10387. server---e.g., @code{xf86-video-vesa}, @code{xf86-input-keyboard}, and so on.
  10388. @var{fonts} must be a list of font directories to add to the server's
  10389. @dfn{font path}.
  10390. @var{drivers} must be either the empty list, in which case Xorg chooses a
  10391. graphics driver automatically, or a list of driver names that will be tried in
  10392. this order---e.g., @code{("modesetting" "vesa")}.
  10393. Likewise, when @var{resolutions} is the empty list, Xorg chooses an
  10394. appropriate screen resolution; otherwise, it must be a list of
  10395. resolutions---e.g., @code{((1024 768) (640 480))}.
  10396. Last, @var{extra-config} is a list of strings or objects appended to the
  10397. configuration file. It is used to pass extra text to be
  10398. added verbatim to the configuration file.
  10399. @cindex keymap
  10400. @cindex keyboard layout
  10401. This procedure is especially useful to configure a different keyboard layout
  10402. than the default US keymap. For instance, to use the ``bépo'' keymap by
  10403. default on the display manager:
  10404. @example
  10405. (define bepo-evdev
  10406. "Section \"InputClass\"
  10407. Identifier \"evdev keyboard catchall\"
  10408. Driver \"evdev\"
  10409. MatchIsKeyboard \"on\"
  10410. Option \"xkb_layout\" \"fr\"
  10411. Option \"xkb_variant\" \"bepo\"
  10412. EndSection")
  10413. (operating-system
  10414. ...
  10415. (services
  10416. (modify-services %desktop-services
  10417. (slim-service-type config =>
  10418. (slim-configuration
  10419. (inherit config)
  10420. (startx (xorg-start-command
  10421. #:configuration-file
  10422. (xorg-configuration-file
  10423. #:extra-config
  10424. (list bepo-evdev)))))))))
  10425. @end example
  10426. The @code{MatchIsKeyboard} line specifies that we only apply the configuration
  10427. to keyboards. Without this line, other devices such as touchpad may not work
  10428. correctly because they will be attached to the wrong driver. In this example,
  10429. the user typically used @code{setxkbmap fr bepo} to set their favorite keymap
  10430. once logged in. The first argument corresponds to the layout, while the second
  10431. argument corresponds to the variant. The @code{xkb_variant} line can be omitted
  10432. to select the default variant.
  10433. @end deffn
  10434. @deffn {Scheme Procedure} screen-locker-service @var{package} [@var{program}]
  10435. Add @var{package}, a package for a screen locker or screen saver whose
  10436. command is @var{program}, to the set of setuid programs and add a PAM entry
  10437. for it. For example:
  10438. @lisp
  10439. (screen-locker-service xlockmore "xlock")
  10440. @end lisp
  10441. makes the good ol' XlockMore usable.
  10442. @end deffn
  10443. @node Printing Services
  10444. @subsubsection Printing Services
  10445. @cindex printer support with CUPS
  10446. The @code{(gnu services cups)} module provides a Guix service definition
  10447. for the CUPS printing service. To add printer support to a GuixSD
  10448. system, add a @code{cups-service} to the operating system definition:
  10449. @deffn {Scheme Variable} cups-service-type
  10450. The service type for the CUPS print server. Its value should be a valid
  10451. CUPS configuration (see below). To use the default settings, simply
  10452. write:
  10453. @example
  10454. (service cups-service-type)
  10455. @end example
  10456. @end deffn
  10457. The CUPS configuration controls the basic things about your CUPS
  10458. installation: what interfaces it listens on, what to do if a print job
  10459. fails, how much logging to do, and so on. To actually add a printer,
  10460. you have to visit the @url{http://localhost:631} URL, or use a tool such
  10461. as GNOME's printer configuration services. By default, configuring a
  10462. CUPS service will generate a self-signed certificate if needed, for
  10463. secure connections to the print server.
  10464. Suppose you want to enable the Web interface of CUPS and also add
  10465. support for Epson printers @i{via} the @code{escpr} package and for HP
  10466. printers @i{via} the @code{hplip-minimal} package. You can do that directly,
  10467. like this (you need to use the @code{(gnu packages cups)} module):
  10468. @example
  10469. (service cups-service-type
  10470. (cups-configuration
  10471. (web-interface? #t)
  10472. (extensions
  10473. (list cups-filters escpr hplip-minimal))))
  10474. @end example
  10475. Note: If you wish to use the Qt5 based GUI which comes with the hplip
  10476. package then it is suggested that you install the @code{hplip} package,
  10477. either in your OS configuration file or as your user.
  10478. The available configuration parameters follow. Each parameter
  10479. definition is preceded by its type; for example, @samp{string-list foo}
  10480. indicates that the @code{foo} parameter should be specified as a list of
  10481. strings. There is also a way to specify the configuration as a string,
  10482. if you have an old @code{cupsd.conf} file that you want to port over
  10483. from some other system; see the end for more details.
  10484. @c The following documentation was initially generated by
  10485. @c (generate-documentation) in (gnu services cups). Manually maintained
  10486. @c documentation is better, so we shouldn't hesitate to edit below as
  10487. @c needed. However if the change you want to make to this documentation
  10488. @c can be done in an automated way, it's probably easier to change
  10489. @c (generate-documentation) than to make it below and have to deal with
  10490. @c the churn as CUPS updates.
  10491. Available @code{cups-configuration} fields are:
  10492. @deftypevr {@code{cups-configuration} parameter} package cups
  10493. The CUPS package.
  10494. @end deftypevr
  10495. @deftypevr {@code{cups-configuration} parameter} package-list extensions
  10496. Drivers and other extensions to the CUPS package.
  10497. @end deftypevr
  10498. @deftypevr {@code{cups-configuration} parameter} files-configuration files-configuration
  10499. Configuration of where to write logs, what directories to use for print
  10500. spools, and related privileged configuration parameters.
  10501. Available @code{files-configuration} fields are:
  10502. @deftypevr {@code{files-configuration} parameter} log-location access-log
  10503. Defines the access log filename. Specifying a blank filename disables
  10504. access log generation. The value @code{stderr} causes log entries to be
  10505. sent to the standard error file when the scheduler is running in the
  10506. foreground, or to the system log daemon when run in the background. The
  10507. value @code{syslog} causes log entries to be sent to the system log
  10508. daemon. The server name may be included in filenames using the string
  10509. @code{%s}, as in @code{/var/log/cups/%s-access_log}.
  10510. Defaults to @samp{"/var/log/cups/access_log"}.
  10511. @end deftypevr
  10512. @deftypevr {@code{files-configuration} parameter} file-name cache-dir
  10513. Where CUPS should cache data.
  10514. Defaults to @samp{"/var/cache/cups"}.
  10515. @end deftypevr
  10516. @deftypevr {@code{files-configuration} parameter} string config-file-perm
  10517. Specifies the permissions for all configuration files that the scheduler
  10518. writes.
  10519. Note that the permissions for the printers.conf file are currently
  10520. masked to only allow access from the scheduler user (typically root).
  10521. This is done because printer device URIs sometimes contain sensitive
  10522. authentication information that should not be generally known on the
  10523. system. There is no way to disable this security feature.
  10524. Defaults to @samp{"0640"}.
  10525. @end deftypevr
  10526. @deftypevr {@code{files-configuration} parameter} log-location error-log
  10527. Defines the error log filename. Specifying a blank filename disables
  10528. access log generation. The value @code{stderr} causes log entries to be
  10529. sent to the standard error file when the scheduler is running in the
  10530. foreground, or to the system log daemon when run in the background. The
  10531. value @code{syslog} causes log entries to be sent to the system log
  10532. daemon. The server name may be included in filenames using the string
  10533. @code{%s}, as in @code{/var/log/cups/%s-error_log}.
  10534. Defaults to @samp{"/var/log/cups/error_log"}.
  10535. @end deftypevr
  10536. @deftypevr {@code{files-configuration} parameter} string fatal-errors
  10537. Specifies which errors are fatal, causing the scheduler to exit. The
  10538. kind strings are:
  10539. @table @code
  10540. @item none
  10541. No errors are fatal.
  10542. @item all
  10543. All of the errors below are fatal.
  10544. @item browse
  10545. Browsing initialization errors are fatal, for example failed connections
  10546. to the DNS-SD daemon.
  10547. @item config
  10548. Configuration file syntax errors are fatal.
  10549. @item listen
  10550. Listen or Port errors are fatal, except for IPv6 failures on the
  10551. loopback or @code{any} addresses.
  10552. @item log
  10553. Log file creation or write errors are fatal.
  10554. @item permissions
  10555. Bad startup file permissions are fatal, for example shared TLS
  10556. certificate and key files with world-read permissions.
  10557. @end table
  10558. Defaults to @samp{"all -browse"}.
  10559. @end deftypevr
  10560. @deftypevr {@code{files-configuration} parameter} boolean file-device?
  10561. Specifies whether the file pseudo-device can be used for new printer
  10562. queues. The URI @uref{file:///dev/null} is always allowed.
  10563. Defaults to @samp{#f}.
  10564. @end deftypevr
  10565. @deftypevr {@code{files-configuration} parameter} string group
  10566. Specifies the group name or ID that will be used when executing external
  10567. programs.
  10568. Defaults to @samp{"lp"}.
  10569. @end deftypevr
  10570. @deftypevr {@code{files-configuration} parameter} string log-file-perm
  10571. Specifies the permissions for all log files that the scheduler writes.
  10572. Defaults to @samp{"0644"}.
  10573. @end deftypevr
  10574. @deftypevr {@code{files-configuration} parameter} log-location page-log
  10575. Defines the page log filename. Specifying a blank filename disables
  10576. access log generation. The value @code{stderr} causes log entries to be
  10577. sent to the standard error file when the scheduler is running in the
  10578. foreground, or to the system log daemon when run in the background. The
  10579. value @code{syslog} causes log entries to be sent to the system log
  10580. daemon. The server name may be included in filenames using the string
  10581. @code{%s}, as in @code{/var/log/cups/%s-page_log}.
  10582. Defaults to @samp{"/var/log/cups/page_log"}.
  10583. @end deftypevr
  10584. @deftypevr {@code{files-configuration} parameter} string remote-root
  10585. Specifies the username that is associated with unauthenticated accesses
  10586. by clients claiming to be the root user. The default is @code{remroot}.
  10587. Defaults to @samp{"remroot"}.
  10588. @end deftypevr
  10589. @deftypevr {@code{files-configuration} parameter} file-name request-root
  10590. Specifies the directory that contains print jobs and other HTTP request
  10591. data.
  10592. Defaults to @samp{"/var/spool/cups"}.
  10593. @end deftypevr
  10594. @deftypevr {@code{files-configuration} parameter} sandboxing sandboxing
  10595. Specifies the level of security sandboxing that is applied to print
  10596. filters, backends, and other child processes of the scheduler; either
  10597. @code{relaxed} or @code{strict}. This directive is currently only
  10598. used/supported on macOS.
  10599. Defaults to @samp{strict}.
  10600. @end deftypevr
  10601. @deftypevr {@code{files-configuration} parameter} file-name server-keychain
  10602. Specifies the location of TLS certificates and private keys. CUPS will
  10603. look for public and private keys in this directory: a @code{.crt} files
  10604. for PEM-encoded certificates and corresponding @code{.key} files for
  10605. PEM-encoded private keys.
  10606. Defaults to @samp{"/etc/cups/ssl"}.
  10607. @end deftypevr
  10608. @deftypevr {@code{files-configuration} parameter} file-name server-root
  10609. Specifies the directory containing the server configuration files.
  10610. Defaults to @samp{"/etc/cups"}.
  10611. @end deftypevr
  10612. @deftypevr {@code{files-configuration} parameter} boolean sync-on-close?
  10613. Specifies whether the scheduler calls fsync(2) after writing
  10614. configuration or state files.
  10615. Defaults to @samp{#f}.
  10616. @end deftypevr
  10617. @deftypevr {@code{files-configuration} parameter} space-separated-string-list system-group
  10618. Specifies the group(s) to use for @code{@@SYSTEM} group authentication.
  10619. @end deftypevr
  10620. @deftypevr {@code{files-configuration} parameter} file-name temp-dir
  10621. Specifies the directory where temporary files are stored.
  10622. Defaults to @samp{"/var/spool/cups/tmp"}.
  10623. @end deftypevr
  10624. @deftypevr {@code{files-configuration} parameter} string user
  10625. Specifies the user name or ID that is used when running external
  10626. programs.
  10627. Defaults to @samp{"lp"}.
  10628. @end deftypevr
  10629. @end deftypevr
  10630. @deftypevr {@code{cups-configuration} parameter} access-log-level access-log-level
  10631. Specifies the logging level for the AccessLog file. The @code{config}
  10632. level logs when printers and classes are added, deleted, or modified and
  10633. when configuration files are accessed or updated. The @code{actions}
  10634. level logs when print jobs are submitted, held, released, modified, or
  10635. canceled, and any of the conditions for @code{config}. The @code{all}
  10636. level logs all requests.
  10637. Defaults to @samp{actions}.
  10638. @end deftypevr
  10639. @deftypevr {@code{cups-configuration} parameter} boolean auto-purge-jobs?
  10640. Specifies whether to purge job history data automatically when it is no
  10641. longer required for quotas.
  10642. Defaults to @samp{#f}.
  10643. @end deftypevr
  10644. @deftypevr {@code{cups-configuration} parameter} browse-local-protocols browse-local-protocols
  10645. Specifies which protocols to use for local printer sharing.
  10646. Defaults to @samp{dnssd}.
  10647. @end deftypevr
  10648. @deftypevr {@code{cups-configuration} parameter} boolean browse-web-if?
  10649. Specifies whether the CUPS web interface is advertised.
  10650. Defaults to @samp{#f}.
  10651. @end deftypevr
  10652. @deftypevr {@code{cups-configuration} parameter} boolean browsing?
  10653. Specifies whether shared printers are advertised.
  10654. Defaults to @samp{#f}.
  10655. @end deftypevr
  10656. @deftypevr {@code{cups-configuration} parameter} string classification
  10657. Specifies the security classification of the server. Any valid banner
  10658. name can be used, including "classified", "confidential", "secret",
  10659. "topsecret", and "unclassified", or the banner can be omitted to disable
  10660. secure printing functions.
  10661. Defaults to @samp{""}.
  10662. @end deftypevr
  10663. @deftypevr {@code{cups-configuration} parameter} boolean classify-override?
  10664. Specifies whether users may override the classification (cover page) of
  10665. individual print jobs using the @code{job-sheets} option.
  10666. Defaults to @samp{#f}.
  10667. @end deftypevr
  10668. @deftypevr {@code{cups-configuration} parameter} default-auth-type default-auth-type
  10669. Specifies the default type of authentication to use.
  10670. Defaults to @samp{Basic}.
  10671. @end deftypevr
  10672. @deftypevr {@code{cups-configuration} parameter} default-encryption default-encryption
  10673. Specifies whether encryption will be used for authenticated requests.
  10674. Defaults to @samp{Required}.
  10675. @end deftypevr
  10676. @deftypevr {@code{cups-configuration} parameter} string default-language
  10677. Specifies the default language to use for text and web content.
  10678. Defaults to @samp{"en"}.
  10679. @end deftypevr
  10680. @deftypevr {@code{cups-configuration} parameter} string default-paper-size
  10681. Specifies the default paper size for new print queues. @samp{"Auto"}
  10682. uses a locale-specific default, while @samp{"None"} specifies there is
  10683. no default paper size. Specific size names are typically
  10684. @samp{"Letter"} or @samp{"A4"}.
  10685. Defaults to @samp{"Auto"}.
  10686. @end deftypevr
  10687. @deftypevr {@code{cups-configuration} parameter} string default-policy
  10688. Specifies the default access policy to use.
  10689. Defaults to @samp{"default"}.
  10690. @end deftypevr
  10691. @deftypevr {@code{cups-configuration} parameter} boolean default-shared?
  10692. Specifies whether local printers are shared by default.
  10693. Defaults to @samp{#t}.
  10694. @end deftypevr
  10695. @deftypevr {@code{cups-configuration} parameter} non-negative-integer dirty-clean-interval
  10696. Specifies the delay for updating of configuration and state files, in
  10697. seconds. A value of 0 causes the update to happen as soon as possible,
  10698. typically within a few milliseconds.
  10699. Defaults to @samp{30}.
  10700. @end deftypevr
  10701. @deftypevr {@code{cups-configuration} parameter} error-policy error-policy
  10702. Specifies what to do when an error occurs. Possible values are
  10703. @code{abort-job}, which will discard the failed print job;
  10704. @code{retry-job}, which will retry the job at a later time;
  10705. @code{retry-this-job}, which retries the failed job immediately; and
  10706. @code{stop-printer}, which stops the printer.
  10707. Defaults to @samp{stop-printer}.
  10708. @end deftypevr
  10709. @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-limit
  10710. Specifies the maximum cost of filters that are run concurrently, which
  10711. can be used to minimize disk, memory, and CPU resource problems. A
  10712. limit of 0 disables filter limiting. An average print to a
  10713. non-PostScript printer needs a filter limit of about 200. A PostScript
  10714. printer needs about half that (100). Setting the limit below these
  10715. thresholds will effectively limit the scheduler to printing a single job
  10716. at any time.
  10717. Defaults to @samp{0}.
  10718. @end deftypevr
  10719. @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-nice
  10720. Specifies the scheduling priority of filters that are run to print a
  10721. job. The nice value ranges from 0, the highest priority, to 19, the
  10722. lowest priority.
  10723. Defaults to @samp{0}.
  10724. @end deftypevr
  10725. @deftypevr {@code{cups-configuration} parameter} host-name-lookups host-name-lookups
  10726. Specifies whether to do reverse lookups on connecting clients. The
  10727. @code{double} setting causes @code{cupsd} to verify that the hostname
  10728. resolved from the address matches one of the addresses returned for that
  10729. hostname. Double lookups also prevent clients with unregistered
  10730. addresses from connecting to your server. Only set this option to
  10731. @code{#t} or @code{double} if absolutely required.
  10732. Defaults to @samp{#f}.
  10733. @end deftypevr
  10734. @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-kill-delay
  10735. Specifies the number of seconds to wait before killing the filters and
  10736. backend associated with a canceled or held job.
  10737. Defaults to @samp{30}.
  10738. @end deftypevr
  10739. @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-interval
  10740. Specifies the interval between retries of jobs in seconds. This is
  10741. typically used for fax queues but can also be used with normal print
  10742. queues whose error policy is @code{retry-job} or
  10743. @code{retry-current-job}.
  10744. Defaults to @samp{30}.
  10745. @end deftypevr
  10746. @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-limit
  10747. Specifies the number of retries that are done for jobs. This is
  10748. typically used for fax queues but can also be used with normal print
  10749. queues whose error policy is @code{retry-job} or
  10750. @code{retry-current-job}.
  10751. Defaults to @samp{5}.
  10752. @end deftypevr
  10753. @deftypevr {@code{cups-configuration} parameter} boolean keep-alive?
  10754. Specifies whether to support HTTP keep-alive connections.
  10755. Defaults to @samp{#t}.
  10756. @end deftypevr
  10757. @deftypevr {@code{cups-configuration} parameter} non-negative-integer keep-alive-timeout
  10758. Specifies how long an idle client connection remains open, in seconds.
  10759. Defaults to @samp{30}.
  10760. @end deftypevr
  10761. @deftypevr {@code{cups-configuration} parameter} non-negative-integer limit-request-body
  10762. Specifies the maximum size of print files, IPP requests, and HTML form
  10763. data. A limit of 0 disables the limit check.
  10764. Defaults to @samp{0}.
  10765. @end deftypevr
  10766. @deftypevr {@code{cups-configuration} parameter} multiline-string-list listen
  10767. Listens on the specified interfaces for connections. Valid values are
  10768. of the form @var{address}:@var{port}, where @var{address} is either an
  10769. IPv6 address enclosed in brackets, an IPv4 address, or @code{*} to
  10770. indicate all addresses. Values can also be file names of local UNIX
  10771. domain sockets. The Listen directive is similar to the Port directive
  10772. but allows you to restrict access to specific interfaces or networks.
  10773. @end deftypevr
  10774. @deftypevr {@code{cups-configuration} parameter} non-negative-integer listen-back-log
  10775. Specifies the number of pending connections that will be allowed. This
  10776. normally only affects very busy servers that have reached the MaxClients
  10777. limit, but can also be triggered by large numbers of simultaneous
  10778. connections. When the limit is reached, the operating system will
  10779. refuse additional connections until the scheduler can accept the pending
  10780. ones.
  10781. Defaults to @samp{128}.
  10782. @end deftypevr
  10783. @deftypevr {@code{cups-configuration} parameter} location-access-control-list location-access-controls
  10784. Specifies a set of additional access controls.
  10785. Available @code{location-access-controls} fields are:
  10786. @deftypevr {@code{location-access-controls} parameter} file-name path
  10787. Specifies the URI path to which the access control applies.
  10788. @end deftypevr
  10789. @deftypevr {@code{location-access-controls} parameter} access-control-list access-controls
  10790. Access controls for all access to this path, in the same format as the
  10791. @code{access-controls} of @code{operation-access-control}.
  10792. Defaults to @samp{()}.
  10793. @end deftypevr
  10794. @deftypevr {@code{location-access-controls} parameter} method-access-control-list method-access-controls
  10795. Access controls for method-specific access to this path.
  10796. Defaults to @samp{()}.
  10797. Available @code{method-access-controls} fields are:
  10798. @deftypevr {@code{method-access-controls} parameter} boolean reverse?
  10799. If @code{#t}, apply access controls to all methods except the listed
  10800. methods. Otherwise apply to only the listed methods.
  10801. Defaults to @samp{#f}.
  10802. @end deftypevr
  10803. @deftypevr {@code{method-access-controls} parameter} method-list methods
  10804. Methods to which this access control applies.
  10805. Defaults to @samp{()}.
  10806. @end deftypevr
  10807. @deftypevr {@code{method-access-controls} parameter} access-control-list access-controls
  10808. Access control directives, as a list of strings. Each string should be
  10809. one directive, such as "Order allow,deny".
  10810. Defaults to @samp{()}.
  10811. @end deftypevr
  10812. @end deftypevr
  10813. @end deftypevr
  10814. @deftypevr {@code{cups-configuration} parameter} non-negative-integer log-debug-history
  10815. Specifies the number of debugging messages that are retained for logging
  10816. if an error occurs in a print job. Debug messages are logged regardless
  10817. of the LogLevel setting.
  10818. Defaults to @samp{100}.
  10819. @end deftypevr
  10820. @deftypevr {@code{cups-configuration} parameter} log-level log-level
  10821. Specifies the level of logging for the ErrorLog file. The value
  10822. @code{none} stops all logging while @code{debug2} logs everything.
  10823. Defaults to @samp{info}.
  10824. @end deftypevr
  10825. @deftypevr {@code{cups-configuration} parameter} log-time-format log-time-format
  10826. Specifies the format of the date and time in the log files. The value
  10827. @code{standard} logs whole seconds while @code{usecs} logs microseconds.
  10828. Defaults to @samp{standard}.
  10829. @end deftypevr
  10830. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients
  10831. Specifies the maximum number of simultaneous clients that are allowed by
  10832. the scheduler.
  10833. Defaults to @samp{100}.
  10834. @end deftypevr
  10835. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients-per-host
  10836. Specifies the maximum number of simultaneous clients that are allowed
  10837. from a single address.
  10838. Defaults to @samp{100}.
  10839. @end deftypevr
  10840. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-copies
  10841. Specifies the maximum number of copies that a user can print of each
  10842. job.
  10843. Defaults to @samp{9999}.
  10844. @end deftypevr
  10845. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-hold-time
  10846. Specifies the maximum time a job may remain in the @code{indefinite}
  10847. hold state before it is canceled. A value of 0 disables cancellation of
  10848. held jobs.
  10849. Defaults to @samp{0}.
  10850. @end deftypevr
  10851. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs
  10852. Specifies the maximum number of simultaneous jobs that are allowed. Set
  10853. to 0 to allow an unlimited number of jobs.
  10854. Defaults to @samp{500}.
  10855. @end deftypevr
  10856. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-printer
  10857. Specifies the maximum number of simultaneous jobs that are allowed per
  10858. printer. A value of 0 allows up to MaxJobs jobs per printer.
  10859. Defaults to @samp{0}.
  10860. @end deftypevr
  10861. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-user
  10862. Specifies the maximum number of simultaneous jobs that are allowed per
  10863. user. A value of 0 allows up to MaxJobs jobs per user.
  10864. Defaults to @samp{0}.
  10865. @end deftypevr
  10866. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-job-time
  10867. Specifies the maximum time a job may take to print before it is
  10868. canceled, in seconds. Set to 0 to disable cancellation of "stuck" jobs.
  10869. Defaults to @samp{10800}.
  10870. @end deftypevr
  10871. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-log-size
  10872. Specifies the maximum size of the log files before they are rotated, in
  10873. bytes. The value 0 disables log rotation.
  10874. Defaults to @samp{1048576}.
  10875. @end deftypevr
  10876. @deftypevr {@code{cups-configuration} parameter} non-negative-integer multiple-operation-timeout
  10877. Specifies the maximum amount of time to allow between files in a
  10878. multiple file print job, in seconds.
  10879. Defaults to @samp{300}.
  10880. @end deftypevr
  10881. @deftypevr {@code{cups-configuration} parameter} string page-log-format
  10882. Specifies the format of PageLog lines. Sequences beginning with percent
  10883. (@samp{%}) characters are replaced with the corresponding information,
  10884. while all other characters are copied literally. The following percent
  10885. sequences are recognized:
  10886. @table @samp
  10887. @item %%
  10888. insert a single percent character
  10889. @item %@{name@}
  10890. insert the value of the specified IPP attribute
  10891. @item %C
  10892. insert the number of copies for the current page
  10893. @item %P
  10894. insert the current page number
  10895. @item %T
  10896. insert the current date and time in common log format
  10897. @item %j
  10898. insert the job ID
  10899. @item %p
  10900. insert the printer name
  10901. @item %u
  10902. insert the username
  10903. @end table
  10904. A value of the empty string disables page logging. The string @code{%p
  10905. %u %j %T %P %C %@{job-billing@} %@{job-originating-host-name@}
  10906. %@{job-name@} %@{media@} %@{sides@}} creates a page log with the
  10907. standard items.
  10908. Defaults to @samp{""}.
  10909. @end deftypevr
  10910. @deftypevr {@code{cups-configuration} parameter} environment-variables environment-variables
  10911. Passes the specified environment variable(s) to child processes; a list
  10912. of strings.
  10913. Defaults to @samp{()}.
  10914. @end deftypevr
  10915. @deftypevr {@code{cups-configuration} parameter} policy-configuration-list policies
  10916. Specifies named access control policies.
  10917. Available @code{policy-configuration} fields are:
  10918. @deftypevr {@code{policy-configuration} parameter} string name
  10919. Name of the policy.
  10920. @end deftypevr
  10921. @deftypevr {@code{policy-configuration} parameter} string job-private-access
  10922. Specifies an access list for a job's private values. @code{@@ACL} maps
  10923. to the printer's requesting-user-name-allowed or
  10924. requesting-user-name-denied values. @code{@@OWNER} maps to the job's
  10925. owner. @code{@@SYSTEM} maps to the groups listed for the
  10926. @code{system-group} field of the @code{files-config} configuration,
  10927. which is reified into the @code{cups-files.conf(5)} file. Other
  10928. possible elements of the access list include specific user names, and
  10929. @code{@@@var{group}} to indicate members of a specific group. The
  10930. access list may also be simply @code{all} or @code{default}.
  10931. Defaults to @samp{"@@OWNER @@SYSTEM"}.
  10932. @end deftypevr
  10933. @deftypevr {@code{policy-configuration} parameter} string job-private-values
  10934. Specifies the list of job values to make private, or @code{all},
  10935. @code{default}, or @code{none}.
  10936. Defaults to @samp{"job-name job-originating-host-name
  10937. job-originating-user-name phone"}.
  10938. @end deftypevr
  10939. @deftypevr {@code{policy-configuration} parameter} string subscription-private-access
  10940. Specifies an access list for a subscription's private values.
  10941. @code{@@ACL} maps to the printer's requesting-user-name-allowed or
  10942. requesting-user-name-denied values. @code{@@OWNER} maps to the job's
  10943. owner. @code{@@SYSTEM} maps to the groups listed for the
  10944. @code{system-group} field of the @code{files-config} configuration,
  10945. which is reified into the @code{cups-files.conf(5)} file. Other
  10946. possible elements of the access list include specific user names, and
  10947. @code{@@@var{group}} to indicate members of a specific group. The
  10948. access list may also be simply @code{all} or @code{default}.
  10949. Defaults to @samp{"@@OWNER @@SYSTEM"}.
  10950. @end deftypevr
  10951. @deftypevr {@code{policy-configuration} parameter} string subscription-private-values
  10952. Specifies the list of job values to make private, or @code{all},
  10953. @code{default}, or @code{none}.
  10954. Defaults to @samp{"notify-events notify-pull-method notify-recipient-uri
  10955. notify-subscriber-user-name notify-user-data"}.
  10956. @end deftypevr
  10957. @deftypevr {@code{policy-configuration} parameter} operation-access-control-list access-controls
  10958. Access control by IPP operation.
  10959. Defaults to @samp{()}.
  10960. @end deftypevr
  10961. @end deftypevr
  10962. @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-files
  10963. Specifies whether job files (documents) are preserved after a job is
  10964. printed. If a numeric value is specified, job files are preserved for
  10965. the indicated number of seconds after printing. Otherwise a boolean
  10966. value applies indefinitely.
  10967. Defaults to @samp{86400}.
  10968. @end deftypevr
  10969. @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-history
  10970. Specifies whether the job history is preserved after a job is printed.
  10971. If a numeric value is specified, the job history is preserved for the
  10972. indicated number of seconds after printing. If @code{#t}, the job
  10973. history is preserved until the MaxJobs limit is reached.
  10974. Defaults to @samp{#t}.
  10975. @end deftypevr
  10976. @deftypevr {@code{cups-configuration} parameter} non-negative-integer reload-timeout
  10977. Specifies the amount of time to wait for job completion before
  10978. restarting the scheduler.
  10979. Defaults to @samp{30}.
  10980. @end deftypevr
  10981. @deftypevr {@code{cups-configuration} parameter} string rip-cache
  10982. Specifies the maximum amount of memory to use when converting documents
  10983. into bitmaps for a printer.
  10984. Defaults to @samp{"128m"}.
  10985. @end deftypevr
  10986. @deftypevr {@code{cups-configuration} parameter} string server-admin
  10987. Specifies the email address of the server administrator.
  10988. Defaults to @samp{"root@@localhost.localdomain"}.
  10989. @end deftypevr
  10990. @deftypevr {@code{cups-configuration} parameter} host-name-list-or-* server-alias
  10991. The ServerAlias directive is used for HTTP Host header validation when
  10992. clients connect to the scheduler from external interfaces. Using the
  10993. special name @code{*} can expose your system to known browser-based DNS
  10994. rebinding attacks, even when accessing sites through a firewall. If the
  10995. auto-discovery of alternate names does not work, we recommend listing
  10996. each alternate name with a ServerAlias directive instead of using
  10997. @code{*}.
  10998. Defaults to @samp{*}.
  10999. @end deftypevr
  11000. @deftypevr {@code{cups-configuration} parameter} string server-name
  11001. Specifies the fully-qualified host name of the server.
  11002. Defaults to @samp{"localhost"}.
  11003. @end deftypevr
  11004. @deftypevr {@code{cups-configuration} parameter} server-tokens server-tokens
  11005. Specifies what information is included in the Server header of HTTP
  11006. responses. @code{None} disables the Server header. @code{ProductOnly}
  11007. reports @code{CUPS}. @code{Major} reports @code{CUPS 2}. @code{Minor}
  11008. reports @code{CUPS 2.0}. @code{Minimal} reports @code{CUPS 2.0.0}.
  11009. @code{OS} reports @code{CUPS 2.0.0 (@var{uname})} where @var{uname} is
  11010. the output of the @code{uname} command. @code{Full} reports @code{CUPS
  11011. 2.0.0 (@var{uname}) IPP/2.0}.
  11012. Defaults to @samp{Minimal}.
  11013. @end deftypevr
  11014. @deftypevr {@code{cups-configuration} parameter} string set-env
  11015. Set the specified environment variable to be passed to child processes.
  11016. Defaults to @samp{"variable value"}.
  11017. @end deftypevr
  11018. @deftypevr {@code{cups-configuration} parameter} multiline-string-list ssl-listen
  11019. Listens on the specified interfaces for encrypted connections. Valid
  11020. values are of the form @var{address}:@var{port}, where @var{address} is
  11021. either an IPv6 address enclosed in brackets, an IPv4 address, or
  11022. @code{*} to indicate all addresses.
  11023. Defaults to @samp{()}.
  11024. @end deftypevr
  11025. @deftypevr {@code{cups-configuration} parameter} ssl-options ssl-options
  11026. Sets encryption options. By default, CUPS only supports encryption
  11027. using TLS v1.0 or higher using known secure cipher suites. The
  11028. @code{AllowRC4} option enables the 128-bit RC4 cipher suites, which are
  11029. required for some older clients that do not implement newer ones. The
  11030. @code{AllowSSL3} option enables SSL v3.0, which is required for some
  11031. older clients that do not support TLS v1.0.
  11032. Defaults to @samp{()}.
  11033. @end deftypevr
  11034. @deftypevr {@code{cups-configuration} parameter} boolean strict-conformance?
  11035. Specifies whether the scheduler requires clients to strictly adhere to
  11036. the IPP specifications.
  11037. Defaults to @samp{#f}.
  11038. @end deftypevr
  11039. @deftypevr {@code{cups-configuration} parameter} non-negative-integer timeout
  11040. Specifies the HTTP request timeout, in seconds.
  11041. Defaults to @samp{300}.
  11042. @end deftypevr
  11043. @deftypevr {@code{cups-configuration} parameter} boolean web-interface?
  11044. Specifies whether the web interface is enabled.
  11045. Defaults to @samp{#f}.
  11046. @end deftypevr
  11047. At this point you're probably thinking ``oh dear, Guix manual, I like
  11048. you but you can stop already with the configuration options''. Indeed.
  11049. However, one more point: it could be that you have an existing
  11050. @code{cupsd.conf} that you want to use. In that case, you can pass an
  11051. @code{opaque-cups-configuration} as the configuration of a
  11052. @code{cups-service-type}.
  11053. Available @code{opaque-cups-configuration} fields are:
  11054. @deftypevr {@code{opaque-cups-configuration} parameter} package cups
  11055. The CUPS package.
  11056. @end deftypevr
  11057. @deftypevr {@code{opaque-cups-configuration} parameter} string cupsd.conf
  11058. The contents of the @code{cupsd.conf}, as a string.
  11059. @end deftypevr
  11060. @deftypevr {@code{opaque-cups-configuration} parameter} string cups-files.conf
  11061. The contents of the @code{cups-files.conf} file, as a string.
  11062. @end deftypevr
  11063. For example, if your @code{cupsd.conf} and @code{cups-files.conf} are in
  11064. strings of the same name, you could instantiate a CUPS service like
  11065. this:
  11066. @example
  11067. (service cups-service-type
  11068. (opaque-cups-configuration
  11069. (cupsd.conf cupsd.conf)
  11070. (cups-files.conf cups-files.conf)))
  11071. @end example
  11072. @node Desktop Services
  11073. @subsubsection Desktop Services
  11074. The @code{(gnu services desktop)} module provides services that are
  11075. usually useful in the context of a ``desktop'' setup---that is, on a
  11076. machine running a graphical display server, possibly with graphical user
  11077. interfaces, etc. It also defines services that provide specific desktop
  11078. environments like GNOME, XFCE or MATE.
  11079. To simplify things, the module defines a variable containing the set of
  11080. services that users typically expect on a machine with a graphical
  11081. environment and networking:
  11082. @defvr {Scheme Variable} %desktop-services
  11083. This is a list of services that builds upon @var{%base-services} and
  11084. adds or adjusts services for a typical ``desktop'' setup.
  11085. In particular, it adds a graphical login manager (@pxref{X Window,
  11086. @code{slim-service}}), screen lockers, a network management tool
  11087. (@pxref{Networking Services, @code{network-manager-service-type}}), energy and color
  11088. management services, the @code{elogind} login and seat manager, the
  11089. Polkit privilege service, the GeoClue location service, the
  11090. AccountsService daemon that allows authorized users change system
  11091. passwords, an NTP client (@pxref{Networking Services}), the Avahi
  11092. daemon, and has the name service switch service configured to be able to
  11093. use @code{nss-mdns} (@pxref{Name Service Switch, mDNS}).
  11094. @end defvr
  11095. The @var{%desktop-services} variable can be used as the @code{services}
  11096. field of an @code{operating-system} declaration (@pxref{operating-system
  11097. Reference, @code{services}}).
  11098. Additionally, the @code{gnome-desktop-service},
  11099. @code{xfce-desktop-service}, @code{mate-desktop-service} and
  11100. @code{enlightenment-desktop-service-type} procedures can add GNOME, XFCE, MATE
  11101. and/or Enlightenment to a system. To ``add GNOME'' means that system-level
  11102. services like the backlight adjustment helpers and the power management
  11103. utilities are added to the system, extending @code{polkit} and @code{dbus}
  11104. appropriately, allowing GNOME to operate with elevated privileges on a
  11105. limited number of special-purpose system interfaces. Additionally,
  11106. adding a service made by @code{gnome-desktop-service} adds the GNOME
  11107. metapackage to the system profile. Likewise, adding the XFCE service
  11108. not only adds the @code{xfce} metapackage to the system profile, but it
  11109. also gives the Thunar file manager the ability to open a ``root-mode''
  11110. file management window, if the user authenticates using the
  11111. administrator's password via the standard polkit graphical interface.
  11112. To ``add MATE'' means that @code{polkit} and @code{dbus} are extended
  11113. appropriately, allowing MATE to operate with elevated privileges on a
  11114. limited number of special-purpose system interfaces. Additionally,
  11115. adding a service made by @code{mate-desktop-service} adds the MATE
  11116. metapackage to the system profile. ``Adding ENLIGHTENMENT'' means that
  11117. @code{dbus} is extended appropriately, and several of Enlightenment's binaries
  11118. are set as setuid, allowing Enlightenment's screen locker and other
  11119. functionality to work as expetected.
  11120. The desktop environments in Guix use the Xorg display server by
  11121. default. If you'd like to use the newer display server protocol
  11122. called Wayland, you need to use the @code{sddm-service} instead of the
  11123. @code{slim-service} for the graphical login manager. You should then
  11124. select the ``GNOME (Wayland)'' session in SDDM. Alternatively you can
  11125. also try starting GNOME on Wayland manually from a TTY with the
  11126. command ``XDG_SESSION_TYPE=wayland exec dbus-run-session
  11127. gnome-session``. Currently only GNOME has support for Wayland.
  11128. @deffn {Scheme Procedure} gnome-desktop-service
  11129. Return a service that adds the @code{gnome} package to the system
  11130. profile, and extends polkit with the actions from
  11131. @code{gnome-settings-daemon}.
  11132. @end deffn
  11133. @deffn {Scheme Procedure} xfce-desktop-service
  11134. Return a service that adds the @code{xfce} package to the system profile,
  11135. and extends polkit with the ability for @code{thunar} to manipulate the
  11136. file system as root from within a user session, after the user has
  11137. authenticated with the administrator's password.
  11138. @end deffn
  11139. @deffn {Scheme Procedure} mate-desktop-service
  11140. Return a service that adds the @code{mate} package to the system
  11141. profile, and extends polkit with the actions from
  11142. @code{mate-settings-daemon}.
  11143. @end deffn
  11144. @deffn {Scheme Procedure} enlightenment-desktop-service-type
  11145. Return a service that adds the @code{enlightenment} package to the system
  11146. profile, and extends dbus with actions from @code{efl}.
  11147. @end deffn
  11148. @deftp {Data Type} enlightenment-desktop-service-configuration
  11149. @table @asis
  11150. @item @code{enlightenment} (default @code{enlightenment})
  11151. The enlightenment package to use.
  11152. @end table
  11153. @end deftp
  11154. Because the GNOME, XFCE and MATE desktop services pull in so many packages,
  11155. the default @code{%desktop-services} variable doesn't include any of
  11156. them by default. To add GNOME, XFCE or MATE, just @code{cons} them onto
  11157. @code{%desktop-services} in the @code{services} field of your
  11158. @code{operating-system}:
  11159. @example
  11160. (use-modules (gnu))
  11161. (use-service-modules desktop)
  11162. (operating-system
  11163. ...
  11164. ;; cons* adds items to the list given as its last argument.
  11165. (services (cons* (gnome-desktop-service)
  11166. (xfce-desktop-service)
  11167. %desktop-services))
  11168. ...)
  11169. @end example
  11170. These desktop environments will then be available as options in the
  11171. graphical login window.
  11172. The actual service definitions included in @code{%desktop-services} and
  11173. provided by @code{(gnu services dbus)} and @code{(gnu services desktop)}
  11174. are described below.
  11175. @deffn {Scheme Procedure} dbus-service [#:dbus @var{dbus}] [#:services '()]
  11176. Return a service that runs the ``system bus'', using @var{dbus}, with
  11177. support for @var{services}.
  11178. @uref{http://dbus.freedesktop.org/, D-Bus} is an inter-process communication
  11179. facility. Its system bus is used to allow system services to communicate
  11180. and to be notified of system-wide events.
  11181. @var{services} must be a list of packages that provide an
  11182. @file{etc/dbus-1/system.d} directory containing additional D-Bus configuration
  11183. and policy files. For example, to allow avahi-daemon to use the system bus,
  11184. @var{services} must be equal to @code{(list avahi)}.
  11185. @end deffn
  11186. @deffn {Scheme Procedure} elogind-service [#:config @var{config}]
  11187. Return a service that runs the @code{elogind} login and
  11188. seat management daemon. @uref{https://github.com/elogind/elogind,
  11189. Elogind} exposes a D-Bus interface that can be used to know which users
  11190. are logged in, know what kind of sessions they have open, suspend the
  11191. system, inhibit system suspend, reboot the system, and other tasks.
  11192. Elogind handles most system-level power events for a computer, for
  11193. example suspending the system when a lid is closed, or shutting it down
  11194. when the power button is pressed.
  11195. The @var{config} keyword argument specifies the configuration for
  11196. elogind, and should be the result of an @code{(elogind-configuration
  11197. (@var{parameter} @var{value})...)} invocation. Available parameters and
  11198. their default values are:
  11199. @table @code
  11200. @item kill-user-processes?
  11201. @code{#f}
  11202. @item kill-only-users
  11203. @code{()}
  11204. @item kill-exclude-users
  11205. @code{("root")}
  11206. @item inhibit-delay-max-seconds
  11207. @code{5}
  11208. @item handle-power-key
  11209. @code{poweroff}
  11210. @item handle-suspend-key
  11211. @code{suspend}
  11212. @item handle-hibernate-key
  11213. @code{hibernate}
  11214. @item handle-lid-switch
  11215. @code{suspend}
  11216. @item handle-lid-switch-docked
  11217. @code{ignore}
  11218. @item power-key-ignore-inhibited?
  11219. @code{#f}
  11220. @item suspend-key-ignore-inhibited?
  11221. @code{#f}
  11222. @item hibernate-key-ignore-inhibited?
  11223. @code{#f}
  11224. @item lid-switch-ignore-inhibited?
  11225. @code{#t}
  11226. @item holdoff-timeout-seconds
  11227. @code{30}
  11228. @item idle-action
  11229. @code{ignore}
  11230. @item idle-action-seconds
  11231. @code{(* 30 60)}
  11232. @item runtime-directory-size-percent
  11233. @code{10}
  11234. @item runtime-directory-size
  11235. @code{#f}
  11236. @item remove-ipc?
  11237. @code{#t}
  11238. @item suspend-state
  11239. @code{("mem" "standby" "freeze")}
  11240. @item suspend-mode
  11241. @code{()}
  11242. @item hibernate-state
  11243. @code{("disk")}
  11244. @item hibernate-mode
  11245. @code{("platform" "shutdown")}
  11246. @item hybrid-sleep-state
  11247. @code{("disk")}
  11248. @item hybrid-sleep-mode
  11249. @code{("suspend" "platform" "shutdown")}
  11250. @end table
  11251. @end deffn
  11252. @deffn {Scheme Procedure} accountsservice-service @
  11253. [#:accountsservice @var{accountsservice}]
  11254. Return a service that runs AccountsService, a system service that can
  11255. list available accounts, change their passwords, and so on.
  11256. AccountsService integrates with PolicyKit to enable unprivileged users
  11257. to acquire the capability to modify their system configuration.
  11258. @uref{https://www.freedesktop.org/wiki/Software/AccountsService/, the
  11259. accountsservice web site} for more information.
  11260. The @var{accountsservice} keyword argument is the @code{accountsservice}
  11261. package to expose as a service.
  11262. @end deffn
  11263. @deffn {Scheme Procedure} polkit-service @
  11264. [#:polkit @var{polkit}]
  11265. Return a service that runs the
  11266. @uref{http://www.freedesktop.org/wiki/Software/polkit/, Polkit privilege
  11267. management service}, which allows system administrators to grant access to
  11268. privileged operations in a structured way. By querying the Polkit service, a
  11269. privileged system component can know when it should grant additional
  11270. capabilities to ordinary users. For example, an ordinary user can be granted
  11271. the capability to suspend the system if the user is logged in locally.
  11272. @end deffn
  11273. @deffn {Scheme Procedure} upower-service [#:upower @var{upower}] @
  11274. [#:watts-up-pro? #f] @
  11275. [#:poll-batteries? #t] @
  11276. [#:ignore-lid? #f] @
  11277. [#:use-percentage-for-policy? #f] @
  11278. [#:percentage-low 10] @
  11279. [#:percentage-critical 3] @
  11280. [#:percentage-action 2] @
  11281. [#:time-low 1200] @
  11282. [#:time-critical 300] @
  11283. [#:time-action 120] @
  11284. [#:critical-power-action 'hybrid-sleep]
  11285. Return a service that runs @uref{http://upower.freedesktop.org/,
  11286. @command{upowerd}}, a system-wide monitor for power consumption and battery
  11287. levels, with the given configuration settings. It implements the
  11288. @code{org.freedesktop.UPower} D-Bus interface, and is notably used by
  11289. GNOME.
  11290. @end deffn
  11291. @deffn {Scheme Procedure} udisks-service [#:udisks @var{udisks}]
  11292. Return a service for @uref{http://udisks.freedesktop.org/docs/latest/,
  11293. UDisks}, a @dfn{disk management} daemon that provides user interfaces with
  11294. notifications and ways to mount/unmount disks. Programs that talk to UDisks
  11295. include the @command{udisksctl} command, part of UDisks, and GNOME Disks.
  11296. @end deffn
  11297. @deffn {Scheme Procedure} colord-service [#:colord @var{colord}]
  11298. Return a service that runs @command{colord}, a system service with a D-Bus
  11299. interface to manage the color profiles of input and output devices such as
  11300. screens and scanners. It is notably used by the GNOME Color Manager graphical
  11301. tool. See @uref{http://www.freedesktop.org/software/colord/, the colord web
  11302. site} for more information.
  11303. @end deffn
  11304. @deffn {Scheme Procedure} geoclue-application name [#:allowed? #t] [#:system? #f] [#:users '()]
  11305. Return a configuration allowing an application to access GeoClue
  11306. location data. @var{name} is the Desktop ID of the application, without
  11307. the @code{.desktop} part. If @var{allowed?} is true, the application
  11308. will have access to location information by default. The boolean
  11309. @var{system?} value indicates whether an application is a system component
  11310. or not. Finally @var{users} is a list of UIDs of all users for which
  11311. this application is allowed location info access. An empty users list
  11312. means that all users are allowed.
  11313. @end deffn
  11314. @defvr {Scheme Variable} %standard-geoclue-applications
  11315. The standard list of well-known GeoClue application configurations,
  11316. granting authority to the GNOME date-and-time utility to ask for the
  11317. current location in order to set the time zone, and allowing the
  11318. IceCat and Epiphany web browsers to request location information.
  11319. IceCat and Epiphany both query the user before allowing a web page to
  11320. know the user's location.
  11321. @end defvr
  11322. @deffn {Scheme Procedure} geoclue-service [#:colord @var{colord}] @
  11323. [#:whitelist '()] @
  11324. [#:wifi-geolocation-url "https://location.services.mozilla.com/v1/geolocate?key=geoclue"] @
  11325. [#:submit-data? #f]
  11326. [#:wifi-submission-url "https://location.services.mozilla.com/v1/submit?key=geoclue"] @
  11327. [#:submission-nick "geoclue"] @
  11328. [#:applications %standard-geoclue-applications]
  11329. Return a service that runs the GeoClue location service. This service
  11330. provides a D-Bus interface to allow applications to request access to a
  11331. user's physical location, and optionally to add information to online
  11332. location databases. See
  11333. @uref{https://wiki.freedesktop.org/www/Software/GeoClue/, the GeoClue
  11334. web site} for more information.
  11335. @end deffn
  11336. @deffn {Scheme Procedure} bluetooth-service [#:bluez @var{bluez}] @
  11337. [@w{#:auto-enable? #f}]
  11338. Return a service that runs the @command{bluetoothd} daemon, which
  11339. manages all the Bluetooth devices and provides a number of D-Bus
  11340. interfaces. When AUTO-ENABLE? is true, the bluetooth controller is
  11341. powered automatically at boot, which can be useful when using a
  11342. bluetooth keyboard or mouse.
  11343. Users need to be in the @code{lp} group to access the D-Bus service.
  11344. @end deffn
  11345. @node Sound Services
  11346. @subsubsection Sound Services
  11347. @cindex sound support
  11348. @cindex ALSA
  11349. @cindex PulseAudio, sound support
  11350. The @code{(gnu services sound)} module provides a service to configure the
  11351. Advanced Linux Sound Architecture (ALSA) system, which makes PulseAudio the
  11352. preferred ALSA output driver.
  11353. @deffn {Scheme Variable} alsa-service-type
  11354. This is the type for the @uref{https://alsa-project.org/, Advanced Linux Sound
  11355. Architecture} (ALSA) system, which generates the @file{/etc/asound.conf}
  11356. configuration file. The value for this type is a @command{alsa-configuration}
  11357. record as in this example:
  11358. @example
  11359. (service alsa-service-type)
  11360. @end example
  11361. See below for details about @code{alsa-configuration}.
  11362. @end deffn
  11363. @deftp {Data Type} alsa-configuration
  11364. Data type representing the configuration for @code{alsa-service}.
  11365. @table @asis
  11366. @item @code{alsa-plugins} (default: @var{alsa-plugins})
  11367. @code{alsa-plugins} package to use.
  11368. @item @code{pulseaudio?} (default: @var{#t})
  11369. Whether ALSA applications should transparently be made to use the
  11370. @uref{http://www.pulseaudio.org/, PulseAudio} sound server.
  11371. Using PulseAudio allows you to run several sound-producing applications
  11372. at the same time and to individual control them @i{via}
  11373. @command{pavucontrol}, among other things.
  11374. @item @code{extra-options} (default: @var{""})
  11375. String to append to the @file{/etc/asound.conf} file.
  11376. @end table
  11377. @end deftp
  11378. Individual users who want to override the system configuration of ALSA can do
  11379. it with the @file{~/.asoundrc} file:
  11380. @example
  11381. # In guix, we have to specify the absolute path for plugins.
  11382. pcm_type.jack @{
  11383. lib "/home/alice/.guix-profile/lib/alsa-lib/libasound_module_pcm_jack.so"
  11384. @}
  11385. # Routing ALSA to jack:
  11386. # <http://jackaudio.org/faq/routing_alsa.html>.
  11387. pcm.rawjack @{
  11388. type jack
  11389. playback_ports @{
  11390. 0 system:playback_1
  11391. 1 system:playback_2
  11392. @}
  11393. capture_ports @{
  11394. 0 system:capture_1
  11395. 1 system:capture_2
  11396. @}
  11397. @}
  11398. pcm.!default @{
  11399. type plug
  11400. slave @{
  11401. pcm "rawjack"
  11402. @}
  11403. @}
  11404. @end example
  11405. See @uref{https://www.alsa-project.org/main/index.php/Asoundrc} for the
  11406. details.
  11407. @node Database Services
  11408. @subsubsection Database Services
  11409. @cindex database
  11410. @cindex SQL
  11411. The @code{(gnu services databases)} module provides the following services.
  11412. @deffn {Scheme Procedure} postgresql-service [#:postgresql postgresql] @
  11413. [#:config-file] [#:data-directory ``/var/lib/postgresql/data''] @
  11414. [#:port 5432] [#:locale ``en_US.utf8'']
  11415. Return a service that runs @var{postgresql}, the PostgreSQL database
  11416. server.
  11417. The PostgreSQL daemon loads its runtime configuration from @var{config-file},
  11418. creates a database cluster with @var{locale} as the default
  11419. locale, stored in @var{data-directory}. It then listens on @var{port}.
  11420. @end deffn
  11421. @deffn {Scheme Procedure} mysql-service [#:config (mysql-configuration)]
  11422. Return a service that runs @command{mysqld}, the MySQL or MariaDB
  11423. database server.
  11424. The optional @var{config} argument specifies the configuration for
  11425. @command{mysqld}, which should be a @code{<mysql-configuration>} object.
  11426. @end deffn
  11427. @deftp {Data Type} mysql-configuration
  11428. Data type representing the configuration of @var{mysql-service}.
  11429. @table @asis
  11430. @item @code{mysql} (default: @var{mariadb})
  11431. Package object of the MySQL database server, can be either @var{mariadb}
  11432. or @var{mysql}.
  11433. For MySQL, a temporary root password will be displayed at activation time.
  11434. For MariaDB, the root password is empty.
  11435. @item @code{port} (default: @code{3306})
  11436. TCP port on which the database server listens for incoming connections.
  11437. @end table
  11438. @end deftp
  11439. @defvr {Scheme Variable} memcached-service-type
  11440. This is the service type for the @uref{https://memcached.org/,
  11441. Memcached} service, which provides a distributed in memory cache. The
  11442. value for the service type is a @code{memcached-configuration} object.
  11443. @end defvr
  11444. @example
  11445. (service memcached-service-type)
  11446. @end example
  11447. @deftp {Data Type} memcached-configuration
  11448. Data type representing the configuration of memcached.
  11449. @table @asis
  11450. @item @code{memcached} (default: @code{memcached})
  11451. The Memcached package to use.
  11452. @item @code{interfaces} (default: @code{'("0.0.0.0")})
  11453. Network interfaces on which to listen.
  11454. @item @code{tcp-port} (default: @code{11211})
  11455. Port on which to accept connections on,
  11456. @item @code{udp-port} (default: @code{11211})
  11457. Port on which to accept UDP connections on, a value of 0 will disable
  11458. listening on a UDP socket.
  11459. @item @code{additional-options} (default: @code{'()})
  11460. Additional command line options to pass to @code{memcached}.
  11461. @end table
  11462. @end deftp
  11463. @defvr {Scheme Variable} mongodb-service-type
  11464. This is the service type for @uref{https://www.mongodb.com/, MongoDB}.
  11465. The value for the service type is a @code{mongodb-configuration} object.
  11466. @end defvr
  11467. @example
  11468. (service mongodb-service-type)
  11469. @end example
  11470. @deftp {Data Type} mongodb-configuration
  11471. Data type representing the configuration of mongodb.
  11472. @table @asis
  11473. @item @code{mongodb} (default: @code{mongodb})
  11474. The MongoDB package to use.
  11475. @item @code{config-file} (default: @code{%default-mongodb-configuration-file})
  11476. The configuration file for MongoDB.
  11477. @item @code{data-directory} (default: @code{"/var/lib/mongodb"})
  11478. This value is used to create the directory, so that it exists and is
  11479. owned by the mongodb user. It should match the data-directory which
  11480. MongoDB is configured to use through the configuration file.
  11481. @end table
  11482. @end deftp
  11483. @defvr {Scheme Variable} redis-service-type
  11484. This is the service type for the @uref{https://redis.io/, Redis}
  11485. key/value store, whose value is a @code{redis-configuration} object.
  11486. @end defvr
  11487. @deftp {Data Type} redis-configuration
  11488. Data type representing the configuration of redis.
  11489. @table @asis
  11490. @item @code{redis} (default: @code{redis})
  11491. The Redis package to use.
  11492. @item @code{bind} (default: @code{"127.0.0.1"})
  11493. Network interface on which to listen.
  11494. @item @code{port} (default: @code{6379})
  11495. Port on which to accept connections on, a value of 0 will disable
  11496. listening on a TCP socket.
  11497. @item @code{working-directory} (default: @code{"/var/lib/redis"})
  11498. Directory in which to store the database and related files.
  11499. @end table
  11500. @end deftp
  11501. @node Mail Services
  11502. @subsubsection Mail Services
  11503. @cindex mail
  11504. @cindex email
  11505. The @code{(gnu services mail)} module provides Guix service definitions
  11506. for email services: IMAP, POP3, and LMTP servers, as well as mail
  11507. transport agents (MTAs). Lots of acronyms! These services are detailed
  11508. in the subsections below.
  11509. @subsubheading Dovecot Service
  11510. @deffn {Scheme Procedure} dovecot-service [#:config (dovecot-configuration)]
  11511. Return a service that runs the Dovecot IMAP/POP3/LMTP mail server.
  11512. @end deffn
  11513. By default, Dovecot does not need much configuration; the default
  11514. configuration object created by @code{(dovecot-configuration)} will
  11515. suffice if your mail is delivered to @code{~/Maildir}. A self-signed
  11516. certificate will be generated for TLS-protected connections, though
  11517. Dovecot will also listen on cleartext ports by default. There are a
  11518. number of options, though, which mail administrators might need to change,
  11519. and as is the case with other services, Guix allows the system
  11520. administrator to specify these parameters via a uniform Scheme interface.
  11521. For example, to specify that mail is located at @code{maildir~/.mail},
  11522. one would instantiate the Dovecot service like this:
  11523. @example
  11524. (dovecot-service #:config
  11525. (dovecot-configuration
  11526. (mail-location "maildir:~/.mail")))
  11527. @end example
  11528. The available configuration parameters follow. Each parameter
  11529. definition is preceded by its type; for example, @samp{string-list foo}
  11530. indicates that the @code{foo} parameter should be specified as a list of
  11531. strings. There is also a way to specify the configuration as a string,
  11532. if you have an old @code{dovecot.conf} file that you want to port over
  11533. from some other system; see the end for more details.
  11534. @c The following documentation was initially generated by
  11535. @c (generate-documentation) in (gnu services mail). Manually maintained
  11536. @c documentation is better, so we shouldn't hesitate to edit below as
  11537. @c needed. However if the change you want to make to this documentation
  11538. @c can be done in an automated way, it's probably easier to change
  11539. @c (generate-documentation) than to make it below and have to deal with
  11540. @c the churn as dovecot updates.
  11541. Available @code{dovecot-configuration} fields are:
  11542. @deftypevr {@code{dovecot-configuration} parameter} package dovecot
  11543. The dovecot package.
  11544. @end deftypevr
  11545. @deftypevr {@code{dovecot-configuration} parameter} comma-separated-string-list listen
  11546. A list of IPs or hosts where to listen for connections. @samp{*}
  11547. listens on all IPv4 interfaces, @samp{::} listens on all IPv6
  11548. interfaces. If you want to specify non-default ports or anything more
  11549. complex, customize the address and port fields of the
  11550. @samp{inet-listener} of the specific services you are interested in.
  11551. @end deftypevr
  11552. @deftypevr {@code{dovecot-configuration} parameter} protocol-configuration-list protocols
  11553. List of protocols we want to serve. Available protocols include
  11554. @samp{imap}, @samp{pop3}, and @samp{lmtp}.
  11555. Available @code{protocol-configuration} fields are:
  11556. @deftypevr {@code{protocol-configuration} parameter} string name
  11557. The name of the protocol.
  11558. @end deftypevr
  11559. @deftypevr {@code{protocol-configuration} parameter} string auth-socket-path
  11560. UNIX socket path to the master authentication server to find users.
  11561. This is used by imap (for shared users) and lda.
  11562. It defaults to @samp{"/var/run/dovecot/auth-userdb"}.
  11563. @end deftypevr
  11564. @deftypevr {@code{protocol-configuration} parameter} space-separated-string-list mail-plugins
  11565. Space separated list of plugins to load.
  11566. @end deftypevr
  11567. @deftypevr {@code{protocol-configuration} parameter} non-negative-integer mail-max-userip-connections
  11568. Maximum number of IMAP connections allowed for a user from each IP
  11569. address. NOTE: The username is compared case-sensitively.
  11570. Defaults to @samp{10}.
  11571. @end deftypevr
  11572. @end deftypevr
  11573. @deftypevr {@code{dovecot-configuration} parameter} service-configuration-list services
  11574. List of services to enable. Available services include @samp{imap},
  11575. @samp{imap-login}, @samp{pop3}, @samp{pop3-login}, @samp{auth}, and
  11576. @samp{lmtp}.
  11577. Available @code{service-configuration} fields are:
  11578. @deftypevr {@code{service-configuration} parameter} string kind
  11579. The service kind. Valid values include @code{director},
  11580. @code{imap-login}, @code{pop3-login}, @code{lmtp}, @code{imap},
  11581. @code{pop3}, @code{auth}, @code{auth-worker}, @code{dict},
  11582. @code{tcpwrap}, @code{quota-warning}, or anything else.
  11583. @end deftypevr
  11584. @deftypevr {@code{service-configuration} parameter} listener-configuration-list listeners
  11585. Listeners for the service. A listener is either a
  11586. @code{unix-listener-configuration}, a @code{fifo-listener-configuration}, or
  11587. an @code{inet-listener-configuration}.
  11588. Defaults to @samp{()}.
  11589. Available @code{unix-listener-configuration} fields are:
  11590. @deftypevr {@code{unix-listener-configuration} parameter} string path
  11591. Path to the file, relative to @code{base-dir} field. This is also used as
  11592. the section name.
  11593. @end deftypevr
  11594. @deftypevr {@code{unix-listener-configuration} parameter} string mode
  11595. The access mode for the socket.
  11596. Defaults to @samp{"0600"}.
  11597. @end deftypevr
  11598. @deftypevr {@code{unix-listener-configuration} parameter} string user
  11599. The user to own the socket.
  11600. Defaults to @samp{""}.
  11601. @end deftypevr
  11602. @deftypevr {@code{unix-listener-configuration} parameter} string group
  11603. The group to own the socket.
  11604. Defaults to @samp{""}.
  11605. @end deftypevr
  11606. Available @code{fifo-listener-configuration} fields are:
  11607. @deftypevr {@code{fifo-listener-configuration} parameter} string path
  11608. Path to the file, relative to @code{base-dir} field. This is also used as
  11609. the section name.
  11610. @end deftypevr
  11611. @deftypevr {@code{fifo-listener-configuration} parameter} string mode
  11612. The access mode for the socket.
  11613. Defaults to @samp{"0600"}.
  11614. @end deftypevr
  11615. @deftypevr {@code{fifo-listener-configuration} parameter} string user
  11616. The user to own the socket.
  11617. Defaults to @samp{""}.
  11618. @end deftypevr
  11619. @deftypevr {@code{fifo-listener-configuration} parameter} string group
  11620. The group to own the socket.
  11621. Defaults to @samp{""}.
  11622. @end deftypevr
  11623. Available @code{inet-listener-configuration} fields are:
  11624. @deftypevr {@code{inet-listener-configuration} parameter} string protocol
  11625. The protocol to listen for.
  11626. @end deftypevr
  11627. @deftypevr {@code{inet-listener-configuration} parameter} string address
  11628. The address on which to listen, or empty for all addresses.
  11629. Defaults to @samp{""}.
  11630. @end deftypevr
  11631. @deftypevr {@code{inet-listener-configuration} parameter} non-negative-integer port
  11632. The port on which to listen.
  11633. @end deftypevr
  11634. @deftypevr {@code{inet-listener-configuration} parameter} boolean ssl?
  11635. Whether to use SSL for this service; @samp{yes}, @samp{no}, or
  11636. @samp{required}.
  11637. Defaults to @samp{#t}.
  11638. @end deftypevr
  11639. @end deftypevr
  11640. @deftypevr {@code{service-configuration} parameter} non-negative-integer client-limit
  11641. Maximum number of simultaneous client connections per process. Once
  11642. this number of connections is received, the next incoming connection
  11643. will prompt Dovecot to spawn another process. If set to 0,
  11644. @code{default-client-limit} is used instead.
  11645. Defaults to @samp{0}.
  11646. @end deftypevr
  11647. @deftypevr {@code{service-configuration} parameter} non-negative-integer service-count
  11648. Number of connections to handle before starting a new process.
  11649. Typically the only useful values are 0 (unlimited) or 1. 1 is more
  11650. secure, but 0 is faster. <doc/wiki/LoginProcess.txt>.
  11651. Defaults to @samp{1}.
  11652. @end deftypevr
  11653. @deftypevr {@code{service-configuration} parameter} non-negative-integer process-limit
  11654. Maximum number of processes that can exist for this service. If set to
  11655. 0, @code{default-process-limit} is used instead.
  11656. Defaults to @samp{0}.
  11657. @end deftypevr
  11658. @deftypevr {@code{service-configuration} parameter} non-negative-integer process-min-avail
  11659. Number of processes to always keep waiting for more connections.
  11660. Defaults to @samp{0}.
  11661. @end deftypevr
  11662. @deftypevr {@code{service-configuration} parameter} non-negative-integer vsz-limit
  11663. If you set @samp{service-count 0}, you probably need to grow
  11664. this.
  11665. Defaults to @samp{256000000}.
  11666. @end deftypevr
  11667. @end deftypevr
  11668. @deftypevr {@code{dovecot-configuration} parameter} dict-configuration dict
  11669. Dict configuration, as created by the @code{dict-configuration}
  11670. constructor.
  11671. Available @code{dict-configuration} fields are:
  11672. @deftypevr {@code{dict-configuration} parameter} free-form-fields entries
  11673. A list of key-value pairs that this dict should hold.
  11674. Defaults to @samp{()}.
  11675. @end deftypevr
  11676. @end deftypevr
  11677. @deftypevr {@code{dovecot-configuration} parameter} passdb-configuration-list passdbs
  11678. A list of passdb configurations, each one created by the
  11679. @code{passdb-configuration} constructor.
  11680. Available @code{passdb-configuration} fields are:
  11681. @deftypevr {@code{passdb-configuration} parameter} string driver
  11682. The driver that the passdb should use. Valid values include
  11683. @samp{pam}, @samp{passwd}, @samp{shadow}, @samp{bsdauth}, and
  11684. @samp{static}.
  11685. Defaults to @samp{"pam"}.
  11686. @end deftypevr
  11687. @deftypevr {@code{passdb-configuration} parameter} space-separated-string-list args
  11688. Space separated list of arguments to the passdb driver.
  11689. Defaults to @samp{""}.
  11690. @end deftypevr
  11691. @end deftypevr
  11692. @deftypevr {@code{dovecot-configuration} parameter} userdb-configuration-list userdbs
  11693. List of userdb configurations, each one created by the
  11694. @code{userdb-configuration} constructor.
  11695. Available @code{userdb-configuration} fields are:
  11696. @deftypevr {@code{userdb-configuration} parameter} string driver
  11697. The driver that the userdb should use. Valid values include
  11698. @samp{passwd} and @samp{static}.
  11699. Defaults to @samp{"passwd"}.
  11700. @end deftypevr
  11701. @deftypevr {@code{userdb-configuration} parameter} space-separated-string-list args
  11702. Space separated list of arguments to the userdb driver.
  11703. Defaults to @samp{""}.
  11704. @end deftypevr
  11705. @deftypevr {@code{userdb-configuration} parameter} free-form-args override-fields
  11706. Override fields from passwd.
  11707. Defaults to @samp{()}.
  11708. @end deftypevr
  11709. @end deftypevr
  11710. @deftypevr {@code{dovecot-configuration} parameter} plugin-configuration plugin-configuration
  11711. Plug-in configuration, created by the @code{plugin-configuration}
  11712. constructor.
  11713. @end deftypevr
  11714. @deftypevr {@code{dovecot-configuration} parameter} list-of-namespace-configuration namespaces
  11715. List of namespaces. Each item in the list is created by the
  11716. @code{namespace-configuration} constructor.
  11717. Available @code{namespace-configuration} fields are:
  11718. @deftypevr {@code{namespace-configuration} parameter} string name
  11719. Name for this namespace.
  11720. @end deftypevr
  11721. @deftypevr {@code{namespace-configuration} parameter} string type
  11722. Namespace type: @samp{private}, @samp{shared} or @samp{public}.
  11723. Defaults to @samp{"private"}.
  11724. @end deftypevr
  11725. @deftypevr {@code{namespace-configuration} parameter} string separator
  11726. Hierarchy separator to use. You should use the same separator for
  11727. all namespaces or some clients get confused. @samp{/} is usually a good
  11728. one. The default however depends on the underlying mail storage
  11729. format.
  11730. Defaults to @samp{""}.
  11731. @end deftypevr
  11732. @deftypevr {@code{namespace-configuration} parameter} string prefix
  11733. Prefix required to access this namespace. This needs to be
  11734. different for all namespaces. For example @samp{Public/}.
  11735. Defaults to @samp{""}.
  11736. @end deftypevr
  11737. @deftypevr {@code{namespace-configuration} parameter} string location
  11738. Physical location of the mailbox. This is in the same format as
  11739. mail_location, which is also the default for it.
  11740. Defaults to @samp{""}.
  11741. @end deftypevr
  11742. @deftypevr {@code{namespace-configuration} parameter} boolean inbox?
  11743. There can be only one INBOX, and this setting defines which
  11744. namespace has it.
  11745. Defaults to @samp{#f}.
  11746. @end deftypevr
  11747. @deftypevr {@code{namespace-configuration} parameter} boolean hidden?
  11748. If namespace is hidden, it's not advertised to clients via NAMESPACE
  11749. extension. You'll most likely also want to set @samp{list? #f}. This is mostly
  11750. useful when converting from another server with different namespaces
  11751. which you want to deprecate but still keep working. For example you can
  11752. create hidden namespaces with prefixes @samp{~/mail/}, @samp{~%u/mail/}
  11753. and @samp{mail/}.
  11754. Defaults to @samp{#f}.
  11755. @end deftypevr
  11756. @deftypevr {@code{namespace-configuration} parameter} boolean list?
  11757. Show the mailboxes under this namespace with the LIST command. This
  11758. makes the namespace visible for clients that do not support the NAMESPACE
  11759. extension. The special @code{children} value lists child mailboxes, but
  11760. hides the namespace prefix.
  11761. Defaults to @samp{#t}.
  11762. @end deftypevr
  11763. @deftypevr {@code{namespace-configuration} parameter} boolean subscriptions?
  11764. Namespace handles its own subscriptions. If set to @code{#f}, the
  11765. parent namespace handles them. The empty prefix should always have this
  11766. as @code{#t}).
  11767. Defaults to @samp{#t}.
  11768. @end deftypevr
  11769. @deftypevr {@code{namespace-configuration} parameter} mailbox-configuration-list mailboxes
  11770. List of predefined mailboxes in this namespace.
  11771. Defaults to @samp{()}.
  11772. Available @code{mailbox-configuration} fields are:
  11773. @deftypevr {@code{mailbox-configuration} parameter} string name
  11774. Name for this mailbox.
  11775. @end deftypevr
  11776. @deftypevr {@code{mailbox-configuration} parameter} string auto
  11777. @samp{create} will automatically create this mailbox.
  11778. @samp{subscribe} will both create and subscribe to the mailbox.
  11779. Defaults to @samp{"no"}.
  11780. @end deftypevr
  11781. @deftypevr {@code{mailbox-configuration} parameter} space-separated-string-list special-use
  11782. List of IMAP @code{SPECIAL-USE} attributes as specified by RFC 6154.
  11783. Valid values are @code{\All}, @code{\Archive}, @code{\Drafts},
  11784. @code{\Flagged}, @code{\Junk}, @code{\Sent}, and @code{\Trash}.
  11785. Defaults to @samp{()}.
  11786. @end deftypevr
  11787. @end deftypevr
  11788. @end deftypevr
  11789. @deftypevr {@code{dovecot-configuration} parameter} file-name base-dir
  11790. Base directory where to store runtime data.
  11791. Defaults to @samp{"/var/run/dovecot/"}.
  11792. @end deftypevr
  11793. @deftypevr {@code{dovecot-configuration} parameter} string login-greeting
  11794. Greeting message for clients.
  11795. Defaults to @samp{"Dovecot ready."}.
  11796. @end deftypevr
  11797. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-trusted-networks
  11798. List of trusted network ranges. Connections from these IPs are
  11799. allowed to override their IP addresses and ports (for logging and for
  11800. authentication checks). @samp{disable-plaintext-auth} is also ignored
  11801. for these networks. Typically you would specify your IMAP proxy servers
  11802. here.
  11803. Defaults to @samp{()}.
  11804. @end deftypevr
  11805. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-access-sockets
  11806. List of login access check sockets (e.g.@: tcpwrap).
  11807. Defaults to @samp{()}.
  11808. @end deftypevr
  11809. @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-proctitle?
  11810. Show more verbose process titles (in ps). Currently shows user name
  11811. and IP address. Useful for seeing who is actually using the IMAP
  11812. processes (e.g.@: shared mailboxes or if the same uid is used for multiple
  11813. accounts).
  11814. Defaults to @samp{#f}.
  11815. @end deftypevr
  11816. @deftypevr {@code{dovecot-configuration} parameter} boolean shutdown-clients?
  11817. Should all processes be killed when Dovecot master process shuts down.
  11818. Setting this to @code{#f} means that Dovecot can be upgraded without
  11819. forcing existing client connections to close (although that could also
  11820. be a problem if the upgrade is e.g.@: due to a security fix).
  11821. Defaults to @samp{#t}.
  11822. @end deftypevr
  11823. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer doveadm-worker-count
  11824. If non-zero, run mail commands via this many connections to doveadm
  11825. server, instead of running them directly in the same process.
  11826. Defaults to @samp{0}.
  11827. @end deftypevr
  11828. @deftypevr {@code{dovecot-configuration} parameter} string doveadm-socket-path
  11829. UNIX socket or host:port used for connecting to doveadm server.
  11830. Defaults to @samp{"doveadm-server"}.
  11831. @end deftypevr
  11832. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list import-environment
  11833. List of environment variables that are preserved on Dovecot startup
  11834. and passed down to all of its child processes. You can also give
  11835. key=value pairs to always set specific settings.
  11836. @end deftypevr
  11837. @deftypevr {@code{dovecot-configuration} parameter} boolean disable-plaintext-auth?
  11838. Disable LOGIN command and all other plaintext authentications unless
  11839. SSL/TLS is used (LOGINDISABLED capability). Note that if the remote IP
  11840. matches the local IP (i.e.@: you're connecting from the same computer),
  11841. the connection is considered secure and plaintext authentication is
  11842. allowed. See also ssl=required setting.
  11843. Defaults to @samp{#t}.
  11844. @end deftypevr
  11845. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-cache-size
  11846. Authentication cache size (e.g.@: @samp{#e10e6}). 0 means it's disabled.
  11847. Note that bsdauth, PAM and vpopmail require @samp{cache-key} to be set
  11848. for caching to be used.
  11849. Defaults to @samp{0}.
  11850. @end deftypevr
  11851. @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-ttl
  11852. Time to live for cached data. After TTL expires the cached record
  11853. is no longer used, *except* if the main database lookup returns internal
  11854. failure. We also try to handle password changes automatically: If
  11855. user's previous authentication was successful, but this one wasn't, the
  11856. cache isn't used. For now this works only with plaintext
  11857. authentication.
  11858. Defaults to @samp{"1 hour"}.
  11859. @end deftypevr
  11860. @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-negative-ttl
  11861. TTL for negative hits (user not found, password mismatch).
  11862. 0 disables caching them completely.
  11863. Defaults to @samp{"1 hour"}.
  11864. @end deftypevr
  11865. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-realms
  11866. List of realms for SASL authentication mechanisms that need them.
  11867. You can leave it empty if you don't want to support multiple realms.
  11868. Many clients simply use the first one listed here, so keep the default
  11869. realm first.
  11870. Defaults to @samp{()}.
  11871. @end deftypevr
  11872. @deftypevr {@code{dovecot-configuration} parameter} string auth-default-realm
  11873. Default realm/domain to use if none was specified. This is used for
  11874. both SASL realms and appending @@domain to username in plaintext
  11875. logins.
  11876. Defaults to @samp{""}.
  11877. @end deftypevr
  11878. @deftypevr {@code{dovecot-configuration} parameter} string auth-username-chars
  11879. List of allowed characters in username. If the user-given username
  11880. contains a character not listed in here, the login automatically fails.
  11881. This is just an extra check to make sure user can't exploit any
  11882. potential quote escaping vulnerabilities with SQL/LDAP databases. If
  11883. you want to allow all characters, set this value to empty.
  11884. Defaults to @samp{"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@@"}.
  11885. @end deftypevr
  11886. @deftypevr {@code{dovecot-configuration} parameter} string auth-username-translation
  11887. Username character translations before it's looked up from
  11888. databases. The value contains series of from -> to characters. For
  11889. example @samp{#@@/@@} means that @samp{#} and @samp{/} characters are
  11890. translated to @samp{@@}.
  11891. Defaults to @samp{""}.
  11892. @end deftypevr
  11893. @deftypevr {@code{dovecot-configuration} parameter} string auth-username-format
  11894. Username formatting before it's looked up from databases. You can
  11895. use the standard variables here, e.g.@: %Lu would lowercase the username,
  11896. %n would drop away the domain if it was given, or @samp{%n-AT-%d} would
  11897. change the @samp{@@} into @samp{-AT-}. This translation is done after
  11898. @samp{auth-username-translation} changes.
  11899. Defaults to @samp{"%Lu"}.
  11900. @end deftypevr
  11901. @deftypevr {@code{dovecot-configuration} parameter} string auth-master-user-separator
  11902. If you want to allow master users to log in by specifying the master
  11903. username within the normal username string (i.e.@: not using SASL
  11904. mechanism's support for it), you can specify the separator character
  11905. here. The format is then <username><separator><master username>.
  11906. UW-IMAP uses @samp{*} as the separator, so that could be a good
  11907. choice.
  11908. Defaults to @samp{""}.
  11909. @end deftypevr
  11910. @deftypevr {@code{dovecot-configuration} parameter} string auth-anonymous-username
  11911. Username to use for users logging in with ANONYMOUS SASL
  11912. mechanism.
  11913. Defaults to @samp{"anonymous"}.
  11914. @end deftypevr
  11915. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-worker-max-count
  11916. Maximum number of dovecot-auth worker processes. They're used to
  11917. execute blocking passdb and userdb queries (e.g.@: MySQL and PAM).
  11918. They're automatically created and destroyed as needed.
  11919. Defaults to @samp{30}.
  11920. @end deftypevr
  11921. @deftypevr {@code{dovecot-configuration} parameter} string auth-gssapi-hostname
  11922. Host name to use in GSSAPI principal names. The default is to use
  11923. the name returned by gethostname(). Use @samp{$ALL} (with quotes) to
  11924. allow all keytab entries.
  11925. Defaults to @samp{""}.
  11926. @end deftypevr
  11927. @deftypevr {@code{dovecot-configuration} parameter} string auth-krb5-keytab
  11928. Kerberos keytab to use for the GSSAPI mechanism. Will use the
  11929. system default (usually @file{/etc/krb5.keytab}) if not specified. You may
  11930. need to change the auth service to run as root to be able to read this
  11931. file.
  11932. Defaults to @samp{""}.
  11933. @end deftypevr
  11934. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-use-winbind?
  11935. Do NTLM and GSS-SPNEGO authentication using Samba's winbind daemon
  11936. and @samp{ntlm-auth} helper.
  11937. <doc/wiki/Authentication/Mechanisms/Winbind.txt>.
  11938. Defaults to @samp{#f}.
  11939. @end deftypevr
  11940. @deftypevr {@code{dovecot-configuration} parameter} file-name auth-winbind-helper-path
  11941. Path for Samba's @samp{ntlm-auth} helper binary.
  11942. Defaults to @samp{"/usr/bin/ntlm_auth"}.
  11943. @end deftypevr
  11944. @deftypevr {@code{dovecot-configuration} parameter} string auth-failure-delay
  11945. Time to delay before replying to failed authentications.
  11946. Defaults to @samp{"2 secs"}.
  11947. @end deftypevr
  11948. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-require-client-cert?
  11949. Require a valid SSL client certificate or the authentication
  11950. fails.
  11951. Defaults to @samp{#f}.
  11952. @end deftypevr
  11953. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-username-from-cert?
  11954. Take the username from client's SSL certificate, using
  11955. @code{X509_NAME_get_text_by_NID()} which returns the subject's DN's
  11956. CommonName.
  11957. Defaults to @samp{#f}.
  11958. @end deftypevr
  11959. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-mechanisms
  11960. List of wanted authentication mechanisms. Supported mechanisms are:
  11961. @samp{plain}, @samp{login}, @samp{digest-md5}, @samp{cram-md5},
  11962. @samp{ntlm}, @samp{rpa}, @samp{apop}, @samp{anonymous}, @samp{gssapi},
  11963. @samp{otp}, @samp{skey}, and @samp{gss-spnego}. NOTE: See also
  11964. @samp{disable-plaintext-auth} setting.
  11965. @end deftypevr
  11966. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-servers
  11967. List of IPs or hostnames to all director servers, including ourself.
  11968. Ports can be specified as ip:port. The default port is the same as what
  11969. director service's @samp{inet-listener} is using.
  11970. Defaults to @samp{()}.
  11971. @end deftypevr
  11972. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-mail-servers
  11973. List of IPs or hostnames to all backend mail servers. Ranges are
  11974. allowed too, like 10.0.0.10-10.0.0.30.
  11975. Defaults to @samp{()}.
  11976. @end deftypevr
  11977. @deftypevr {@code{dovecot-configuration} parameter} string director-user-expire
  11978. How long to redirect users to a specific server after it no longer
  11979. has any connections.
  11980. Defaults to @samp{"15 min"}.
  11981. @end deftypevr
  11982. @deftypevr {@code{dovecot-configuration} parameter} string director-username-hash
  11983. How the username is translated before being hashed. Useful values
  11984. include %Ln if user can log in with or without @@domain, %Ld if mailboxes
  11985. are shared within domain.
  11986. Defaults to @samp{"%Lu"}.
  11987. @end deftypevr
  11988. @deftypevr {@code{dovecot-configuration} parameter} string log-path
  11989. Log file to use for error messages. @samp{syslog} logs to syslog,
  11990. @samp{/dev/stderr} logs to stderr.
  11991. Defaults to @samp{"syslog"}.
  11992. @end deftypevr
  11993. @deftypevr {@code{dovecot-configuration} parameter} string info-log-path
  11994. Log file to use for informational messages. Defaults to
  11995. @samp{log-path}.
  11996. Defaults to @samp{""}.
  11997. @end deftypevr
  11998. @deftypevr {@code{dovecot-configuration} parameter} string debug-log-path
  11999. Log file to use for debug messages. Defaults to
  12000. @samp{info-log-path}.
  12001. Defaults to @samp{""}.
  12002. @end deftypevr
  12003. @deftypevr {@code{dovecot-configuration} parameter} string syslog-facility
  12004. Syslog facility to use if you're logging to syslog. Usually if you
  12005. don't want to use @samp{mail}, you'll use local0..local7. Also other
  12006. standard facilities are supported.
  12007. Defaults to @samp{"mail"}.
  12008. @end deftypevr
  12009. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-verbose?
  12010. Log unsuccessful authentication attempts and the reasons why they
  12011. failed.
  12012. Defaults to @samp{#f}.
  12013. @end deftypevr
  12014. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-verbose-passwords?
  12015. In case of password mismatches, log the attempted password. Valid
  12016. values are no, plain and sha1. sha1 can be useful for detecting brute
  12017. force password attempts vs. user simply trying the same password over
  12018. and over again. You can also truncate the value to n chars by appending
  12019. ":n" (e.g.@: sha1:6).
  12020. Defaults to @samp{#f}.
  12021. @end deftypevr
  12022. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug?
  12023. Even more verbose logging for debugging purposes. Shows for example
  12024. SQL queries.
  12025. Defaults to @samp{#f}.
  12026. @end deftypevr
  12027. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug-passwords?
  12028. In case of password mismatches, log the passwords and used scheme so
  12029. the problem can be debugged. Enabling this also enables
  12030. @samp{auth-debug}.
  12031. Defaults to @samp{#f}.
  12032. @end deftypevr
  12033. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-debug?
  12034. Enable mail process debugging. This can help you figure out why
  12035. Dovecot isn't finding your mails.
  12036. Defaults to @samp{#f}.
  12037. @end deftypevr
  12038. @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-ssl?
  12039. Show protocol level SSL errors.
  12040. Defaults to @samp{#f}.
  12041. @end deftypevr
  12042. @deftypevr {@code{dovecot-configuration} parameter} string log-timestamp
  12043. Prefix for each line written to log file. % codes are in
  12044. strftime(3) format.
  12045. Defaults to @samp{"\"%b %d %H:%M:%S \""}.
  12046. @end deftypevr
  12047. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-log-format-elements
  12048. List of elements we want to log. The elements which have a
  12049. non-empty variable value are joined together to form a comma-separated
  12050. string.
  12051. @end deftypevr
  12052. @deftypevr {@code{dovecot-configuration} parameter} string login-log-format
  12053. Login log format. %s contains @samp{login-log-format-elements}
  12054. string, %$ contains the data we want to log.
  12055. Defaults to @samp{"%$: %s"}.
  12056. @end deftypevr
  12057. @deftypevr {@code{dovecot-configuration} parameter} string mail-log-prefix
  12058. Log prefix for mail processes. See doc/wiki/Variables.txt for list
  12059. of possible variables you can use.
  12060. Defaults to @samp{"\"%s(%u)<%@{pid@}><%@{session@}>: \""}.
  12061. @end deftypevr
  12062. @deftypevr {@code{dovecot-configuration} parameter} string deliver-log-format
  12063. Format to use for logging mail deliveries. You can use variables:
  12064. @table @code
  12065. @item %$
  12066. Delivery status message (e.g.@: @samp{saved to INBOX})
  12067. @item %m
  12068. Message-ID
  12069. @item %s
  12070. Subject
  12071. @item %f
  12072. From address
  12073. @item %p
  12074. Physical size
  12075. @item %w
  12076. Virtual size.
  12077. @end table
  12078. Defaults to @samp{"msgid=%m: %$"}.
  12079. @end deftypevr
  12080. @deftypevr {@code{dovecot-configuration} parameter} string mail-location
  12081. Location for users' mailboxes. The default is empty, which means
  12082. that Dovecot tries to find the mailboxes automatically. This won't work
  12083. if the user doesn't yet have any mail, so you should explicitly tell
  12084. Dovecot the full location.
  12085. If you're using mbox, giving a path to the INBOX
  12086. file (e.g.@: /var/mail/%u) isn't enough. You'll also need to tell Dovecot
  12087. where the other mailboxes are kept. This is called the "root mail
  12088. directory", and it must be the first path given in the
  12089. @samp{mail-location} setting.
  12090. There are a few special variables you can use, eg.:
  12091. @table @samp
  12092. @item %u
  12093. username
  12094. @item %n
  12095. user part in user@@domain, same as %u if there's no domain
  12096. @item %d
  12097. domain part in user@@domain, empty if there's no domain
  12098. @item %h
  12099. home director
  12100. @end table
  12101. See doc/wiki/Variables.txt for full list. Some examples:
  12102. @table @samp
  12103. @item maildir:~/Maildir
  12104. @item mbox:~/mail:INBOX=/var/mail/%u
  12105. @item mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/%
  12106. @end table
  12107. Defaults to @samp{""}.
  12108. @end deftypevr
  12109. @deftypevr {@code{dovecot-configuration} parameter} string mail-uid
  12110. System user and group used to access mails. If you use multiple,
  12111. userdb can override these by returning uid or gid fields. You can use
  12112. either numbers or names. <doc/wiki/UserIds.txt>.
  12113. Defaults to @samp{""}.
  12114. @end deftypevr
  12115. @deftypevr {@code{dovecot-configuration} parameter} string mail-gid
  12116. Defaults to @samp{""}.
  12117. @end deftypevr
  12118. @deftypevr {@code{dovecot-configuration} parameter} string mail-privileged-group
  12119. Group to enable temporarily for privileged operations. Currently
  12120. this is used only with INBOX when either its initial creation or
  12121. dotlocking fails. Typically this is set to "mail" to give access to
  12122. /var/mail.
  12123. Defaults to @samp{""}.
  12124. @end deftypevr
  12125. @deftypevr {@code{dovecot-configuration} parameter} string mail-access-groups
  12126. Grant access to these supplementary groups for mail processes.
  12127. Typically these are used to set up access to shared mailboxes. Note
  12128. that it may be dangerous to set these if users can create
  12129. symlinks (e.g.@: if "mail" group is set here, ln -s /var/mail ~/mail/var
  12130. could allow a user to delete others' mailboxes, or ln -s
  12131. /secret/shared/box ~/mail/mybox would allow reading it).
  12132. Defaults to @samp{""}.
  12133. @end deftypevr
  12134. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-full-filesystem-access?
  12135. Allow full file system access to clients. There's no access checks
  12136. other than what the operating system does for the active UID/GID. It
  12137. works with both maildir and mboxes, allowing you to prefix mailboxes
  12138. names with e.g.@: /path/ or ~user/.
  12139. Defaults to @samp{#f}.
  12140. @end deftypevr
  12141. @deftypevr {@code{dovecot-configuration} parameter} boolean mmap-disable?
  12142. Don't use mmap() at all. This is required if you store indexes to
  12143. shared file systems (NFS or clustered file system).
  12144. Defaults to @samp{#f}.
  12145. @end deftypevr
  12146. @deftypevr {@code{dovecot-configuration} parameter} boolean dotlock-use-excl?
  12147. Rely on @samp{O_EXCL} to work when creating dotlock files. NFS
  12148. supports @samp{O_EXCL} since version 3, so this should be safe to use
  12149. nowadays by default.
  12150. Defaults to @samp{#t}.
  12151. @end deftypevr
  12152. @deftypevr {@code{dovecot-configuration} parameter} string mail-fsync
  12153. When to use fsync() or fdatasync() calls:
  12154. @table @code
  12155. @item optimized
  12156. Whenever necessary to avoid losing important data
  12157. @item always
  12158. Useful with e.g.@: NFS when write()s are delayed
  12159. @item never
  12160. Never use it (best performance, but crashes can lose data).
  12161. @end table
  12162. Defaults to @samp{"optimized"}.
  12163. @end deftypevr
  12164. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-storage?
  12165. Mail storage exists in NFS. Set this to yes to make Dovecot flush
  12166. NFS caches whenever needed. If you're using only a single mail server
  12167. this isn't needed.
  12168. Defaults to @samp{#f}.
  12169. @end deftypevr
  12170. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-index?
  12171. Mail index files also exist in NFS. Setting this to yes requires
  12172. @samp{mmap-disable? #t} and @samp{fsync-disable? #f}.
  12173. Defaults to @samp{#f}.
  12174. @end deftypevr
  12175. @deftypevr {@code{dovecot-configuration} parameter} string lock-method
  12176. Locking method for index files. Alternatives are fcntl, flock and
  12177. dotlock. Dotlocking uses some tricks which may create more disk I/O
  12178. than other locking methods. NFS users: flock doesn't work, remember to
  12179. change @samp{mmap-disable}.
  12180. Defaults to @samp{"fcntl"}.
  12181. @end deftypevr
  12182. @deftypevr {@code{dovecot-configuration} parameter} file-name mail-temp-dir
  12183. Directory in which LDA/LMTP temporarily stores incoming mails >128
  12184. kB.
  12185. Defaults to @samp{"/tmp"}.
  12186. @end deftypevr
  12187. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-uid
  12188. Valid UID range for users. This is mostly to make sure that users can't
  12189. log in as daemons or other system users. Note that denying root logins is
  12190. hardcoded to dovecot binary and can't be done even if @samp{first-valid-uid}
  12191. is set to 0.
  12192. Defaults to @samp{500}.
  12193. @end deftypevr
  12194. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-uid
  12195. Defaults to @samp{0}.
  12196. @end deftypevr
  12197. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-gid
  12198. Valid GID range for users. Users having non-valid GID as primary group ID
  12199. aren't allowed to log in. If user belongs to supplementary groups with
  12200. non-valid GIDs, those groups are not set.
  12201. Defaults to @samp{1}.
  12202. @end deftypevr
  12203. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-gid
  12204. Defaults to @samp{0}.
  12205. @end deftypevr
  12206. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-max-keyword-length
  12207. Maximum allowed length for mail keyword name. It's only forced when
  12208. trying to create new keywords.
  12209. Defaults to @samp{50}.
  12210. @end deftypevr
  12211. @deftypevr {@code{dovecot-configuration} parameter} colon-separated-file-name-list valid-chroot-dirs
  12212. List of directories under which chrooting is allowed for mail
  12213. processes (i.e.@: /var/mail will allow chrooting to /var/mail/foo/bar
  12214. too). This setting doesn't affect @samp{login-chroot}
  12215. @samp{mail-chroot} or auth chroot settings. If this setting is empty,
  12216. "/./" in home dirs are ignored. WARNING: Never add directories here
  12217. which local users can modify, that may lead to root exploit. Usually
  12218. this should be done only if you don't allow shell access for users.
  12219. <doc/wiki/Chrooting.txt>.
  12220. Defaults to @samp{()}.
  12221. @end deftypevr
  12222. @deftypevr {@code{dovecot-configuration} parameter} string mail-chroot
  12223. Default chroot directory for mail processes. This can be overridden
  12224. for specific users in user database by giving /./ in user's home
  12225. directory (e.g.@: /home/./user chroots into /home). Note that usually
  12226. there is no real need to do chrooting, Dovecot doesn't allow users to
  12227. access files outside their mail directory anyway. If your home
  12228. directories are prefixed with the chroot directory, append "/."@: to
  12229. @samp{mail-chroot}. <doc/wiki/Chrooting.txt>.
  12230. Defaults to @samp{""}.
  12231. @end deftypevr
  12232. @deftypevr {@code{dovecot-configuration} parameter} file-name auth-socket-path
  12233. UNIX socket path to master authentication server to find users.
  12234. This is used by imap (for shared users) and lda.
  12235. Defaults to @samp{"/var/run/dovecot/auth-userdb"}.
  12236. @end deftypevr
  12237. @deftypevr {@code{dovecot-configuration} parameter} file-name mail-plugin-dir
  12238. Directory where to look up mail plugins.
  12239. Defaults to @samp{"/usr/lib/dovecot"}.
  12240. @end deftypevr
  12241. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mail-plugins
  12242. List of plugins to load for all services. Plugins specific to IMAP,
  12243. LDA, etc.@: are added to this list in their own .conf files.
  12244. Defaults to @samp{()}.
  12245. @end deftypevr
  12246. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-cache-min-mail-count
  12247. The minimum number of mails in a mailbox before updates are done to
  12248. cache file. This allows optimizing Dovecot's behavior to do less disk
  12249. writes at the cost of more disk reads.
  12250. Defaults to @samp{0}.
  12251. @end deftypevr
  12252. @deftypevr {@code{dovecot-configuration} parameter} string mailbox-idle-check-interval
  12253. When IDLE command is running, mailbox is checked once in a while to
  12254. see if there are any new mails or other changes. This setting defines
  12255. the minimum time to wait between those checks. Dovecot can also use
  12256. dnotify, inotify and kqueue to find out immediately when changes
  12257. occur.
  12258. Defaults to @samp{"30 secs"}.
  12259. @end deftypevr
  12260. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-save-crlf?
  12261. Save mails with CR+LF instead of plain LF. This makes sending those
  12262. mails take less CPU, especially with sendfile() syscall with Linux and
  12263. FreeBSD. But it also creates a bit more disk I/O which may just make it
  12264. slower. Also note that if other software reads the mboxes/maildirs,
  12265. they may handle the extra CRs wrong and cause problems.
  12266. Defaults to @samp{#f}.
  12267. @end deftypevr
  12268. @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-stat-dirs?
  12269. By default LIST command returns all entries in maildir beginning
  12270. with a dot. Enabling this option makes Dovecot return only entries
  12271. which are directories. This is done by stat()ing each entry, so it
  12272. causes more disk I/O.
  12273. (For systems setting struct @samp{dirent->d_type} this check is free
  12274. and it's done always regardless of this setting).
  12275. Defaults to @samp{#f}.
  12276. @end deftypevr
  12277. @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-copy-with-hardlinks?
  12278. When copying a message, do it with hard links whenever possible.
  12279. This makes the performance much better, and it's unlikely to have any
  12280. side effects.
  12281. Defaults to @samp{#t}.
  12282. @end deftypevr
  12283. @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-very-dirty-syncs?
  12284. Assume Dovecot is the only MUA accessing Maildir: Scan cur/
  12285. directory only when its mtime changes unexpectedly or when we can't find
  12286. the mail otherwise.
  12287. Defaults to @samp{#f}.
  12288. @end deftypevr
  12289. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-read-locks
  12290. Which locking methods to use for locking mbox. There are four
  12291. available:
  12292. @table @code
  12293. @item dotlock
  12294. Create <mailbox>.lock file. This is the oldest and most NFS-safe
  12295. solution. If you want to use /var/mail/ like directory, the users will
  12296. need write access to that directory.
  12297. @item dotlock-try
  12298. Same as dotlock, but if it fails because of permissions or because there
  12299. isn't enough disk space, just skip it.
  12300. @item fcntl
  12301. Use this if possible. Works with NFS too if lockd is used.
  12302. @item flock
  12303. May not exist in all systems. Doesn't work with NFS.
  12304. @item lockf
  12305. May not exist in all systems. Doesn't work with NFS.
  12306. @end table
  12307. You can use multiple locking methods; if you do the order they're declared
  12308. in is important to avoid deadlocks if other MTAs/MUAs are using multiple
  12309. locking methods as well. Some operating systems don't allow using some of
  12310. them simultaneously.
  12311. @end deftypevr
  12312. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-write-locks
  12313. @end deftypevr
  12314. @deftypevr {@code{dovecot-configuration} parameter} string mbox-lock-timeout
  12315. Maximum time to wait for lock (all of them) before aborting.
  12316. Defaults to @samp{"5 mins"}.
  12317. @end deftypevr
  12318. @deftypevr {@code{dovecot-configuration} parameter} string mbox-dotlock-change-timeout
  12319. If dotlock exists but the mailbox isn't modified in any way,
  12320. override the lock file after this much time.
  12321. Defaults to @samp{"2 mins"}.
  12322. @end deftypevr
  12323. @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-dirty-syncs?
  12324. When mbox changes unexpectedly we have to fully read it to find out
  12325. what changed. If the mbox is large this can take a long time. Since
  12326. the change is usually just a newly appended mail, it'd be faster to
  12327. simply read the new mails. If this setting is enabled, Dovecot does
  12328. this but still safely fallbacks to re-reading the whole mbox file
  12329. whenever something in mbox isn't how it's expected to be. The only real
  12330. downside to this setting is that if some other MUA changes message
  12331. flags, Dovecot doesn't notice it immediately. Note that a full sync is
  12332. done with SELECT, EXAMINE, EXPUNGE and CHECK commands.
  12333. Defaults to @samp{#t}.
  12334. @end deftypevr
  12335. @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-very-dirty-syncs?
  12336. Like @samp{mbox-dirty-syncs}, but don't do full syncs even with SELECT,
  12337. EXAMINE, EXPUNGE or CHECK commands. If this is set,
  12338. @samp{mbox-dirty-syncs} is ignored.
  12339. Defaults to @samp{#f}.
  12340. @end deftypevr
  12341. @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-lazy-writes?
  12342. Delay writing mbox headers until doing a full write sync (EXPUNGE
  12343. and CHECK commands and when closing the mailbox). This is especially
  12344. useful for POP3 where clients often delete all mails. The downside is
  12345. that our changes aren't immediately visible to other MUAs.
  12346. Defaults to @samp{#t}.
  12347. @end deftypevr
  12348. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mbox-min-index-size
  12349. If mbox size is smaller than this (e.g.@: 100k), don't write index
  12350. files. If an index file already exists it's still read, just not
  12351. updated.
  12352. Defaults to @samp{0}.
  12353. @end deftypevr
  12354. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mdbox-rotate-size
  12355. Maximum dbox file size until it's rotated.
  12356. Defaults to @samp{10000000}.
  12357. @end deftypevr
  12358. @deftypevr {@code{dovecot-configuration} parameter} string mdbox-rotate-interval
  12359. Maximum dbox file age until it's rotated. Typically in days. Day
  12360. begins from midnight, so 1d = today, 2d = yesterday, etc. 0 = check
  12361. disabled.
  12362. Defaults to @samp{"1d"}.
  12363. @end deftypevr
  12364. @deftypevr {@code{dovecot-configuration} parameter} boolean mdbox-preallocate-space?
  12365. When creating new mdbox files, immediately preallocate their size to
  12366. @samp{mdbox-rotate-size}. This setting currently works only in Linux
  12367. with some file systems (ext4, xfs).
  12368. Defaults to @samp{#f}.
  12369. @end deftypevr
  12370. @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-dir
  12371. sdbox and mdbox support saving mail attachments to external files,
  12372. which also allows single instance storage for them. Other backends
  12373. don't support this for now.
  12374. WARNING: This feature hasn't been tested much yet. Use at your own risk.
  12375. Directory root where to store mail attachments. Disabled, if empty.
  12376. Defaults to @samp{""}.
  12377. @end deftypevr
  12378. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-attachment-min-size
  12379. Attachments smaller than this aren't saved externally. It's also
  12380. possible to write a plugin to disable saving specific attachments
  12381. externally.
  12382. Defaults to @samp{128000}.
  12383. @end deftypevr
  12384. @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-fs
  12385. File system backend to use for saving attachments:
  12386. @table @code
  12387. @item posix
  12388. No SiS done by Dovecot (but this might help FS's own deduplication)
  12389. @item sis posix
  12390. SiS with immediate byte-by-byte comparison during saving
  12391. @item sis-queue posix
  12392. SiS with delayed comparison and deduplication.
  12393. @end table
  12394. Defaults to @samp{"sis posix"}.
  12395. @end deftypevr
  12396. @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-hash
  12397. Hash format to use in attachment filenames. You can add any text and
  12398. variables: @code{%@{md4@}}, @code{%@{md5@}}, @code{%@{sha1@}},
  12399. @code{%@{sha256@}}, @code{%@{sha512@}}, @code{%@{size@}}. Variables can be
  12400. truncated, e.g.@: @code{%@{sha256:80@}} returns only first 80 bits.
  12401. Defaults to @samp{"%@{sha1@}"}.
  12402. @end deftypevr
  12403. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-process-limit
  12404. Defaults to @samp{100}.
  12405. @end deftypevr
  12406. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-client-limit
  12407. Defaults to @samp{1000}.
  12408. @end deftypevr
  12409. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-vsz-limit
  12410. Default VSZ (virtual memory size) limit for service processes.
  12411. This is mainly intended to catch and kill processes that leak memory
  12412. before they eat up everything.
  12413. Defaults to @samp{256000000}.
  12414. @end deftypevr
  12415. @deftypevr {@code{dovecot-configuration} parameter} string default-login-user
  12416. Login user is internally used by login processes. This is the most
  12417. untrusted user in Dovecot system. It shouldn't have access to anything
  12418. at all.
  12419. Defaults to @samp{"dovenull"}.
  12420. @end deftypevr
  12421. @deftypevr {@code{dovecot-configuration} parameter} string default-internal-user
  12422. Internal user is used by unprivileged processes. It should be
  12423. separate from login user, so that login processes can't disturb other
  12424. processes.
  12425. Defaults to @samp{"dovecot"}.
  12426. @end deftypevr
  12427. @deftypevr {@code{dovecot-configuration} parameter} string ssl?
  12428. SSL/TLS support: yes, no, required. <doc/wiki/SSL.txt>.
  12429. Defaults to @samp{"required"}.
  12430. @end deftypevr
  12431. @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert
  12432. PEM encoded X.509 SSL/TLS certificate (public key).
  12433. Defaults to @samp{"</etc/dovecot/default.pem"}.
  12434. @end deftypevr
  12435. @deftypevr {@code{dovecot-configuration} parameter} string ssl-key
  12436. PEM encoded SSL/TLS private key. The key is opened before
  12437. dropping root privileges, so keep the key file unreadable by anyone but
  12438. root.
  12439. Defaults to @samp{"</etc/dovecot/private/default.pem"}.
  12440. @end deftypevr
  12441. @deftypevr {@code{dovecot-configuration} parameter} string ssl-key-password
  12442. If key file is password protected, give the password here.
  12443. Alternatively give it when starting dovecot with -p parameter. Since
  12444. this file is often world-readable, you may want to place this setting
  12445. instead to a different.
  12446. Defaults to @samp{""}.
  12447. @end deftypevr
  12448. @deftypevr {@code{dovecot-configuration} parameter} string ssl-ca
  12449. PEM encoded trusted certificate authority. Set this only if you
  12450. intend to use @samp{ssl-verify-client-cert? #t}. The file should
  12451. contain the CA certificate(s) followed by the matching
  12452. CRL(s). (e.g.@: @samp{ssl-ca </etc/ssl/certs/ca.pem}).
  12453. Defaults to @samp{""}.
  12454. @end deftypevr
  12455. @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-require-crl?
  12456. Require that CRL check succeeds for client certificates.
  12457. Defaults to @samp{#t}.
  12458. @end deftypevr
  12459. @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-verify-client-cert?
  12460. Request client to send a certificate. If you also want to require
  12461. it, set @samp{auth-ssl-require-client-cert? #t} in auth section.
  12462. Defaults to @samp{#f}.
  12463. @end deftypevr
  12464. @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert-username-field
  12465. Which field from certificate to use for username. commonName and
  12466. x500UniqueIdentifier are the usual choices. You'll also need to set
  12467. @samp{auth-ssl-username-from-cert? #t}.
  12468. Defaults to @samp{"commonName"}.
  12469. @end deftypevr
  12470. @deftypevr {@code{dovecot-configuration} parameter} string ssl-min-protocol
  12471. Minimum SSL protocol version to accept.
  12472. Defaults to @samp{"TLSv1"}.
  12473. @end deftypevr
  12474. @deftypevr {@code{dovecot-configuration} parameter} string ssl-cipher-list
  12475. SSL ciphers to use.
  12476. Defaults to @samp{"ALL:!kRSA:!SRP:!kDHd:!DSS:!aNULL:!eNULL:!EXPORT:!DES:!3DES:!MD5:!PSK:!RC4:!ADH:!LOW@@STRENGTH"}.
  12477. @end deftypevr
  12478. @deftypevr {@code{dovecot-configuration} parameter} string ssl-crypto-device
  12479. SSL crypto device to use, for valid values run "openssl engine".
  12480. Defaults to @samp{""}.
  12481. @end deftypevr
  12482. @deftypevr {@code{dovecot-configuration} parameter} string postmaster-address
  12483. Address to use when sending rejection mails.
  12484. %d expands to recipient domain.
  12485. Defaults to @samp{"postmaster@@%d"}.
  12486. @end deftypevr
  12487. @deftypevr {@code{dovecot-configuration} parameter} string hostname
  12488. Hostname to use in various parts of sent mails (e.g.@: in Message-Id)
  12489. and in LMTP replies. Default is the system's real hostname@@domain.
  12490. Defaults to @samp{""}.
  12491. @end deftypevr
  12492. @deftypevr {@code{dovecot-configuration} parameter} boolean quota-full-tempfail?
  12493. If user is over quota, return with temporary failure instead of
  12494. bouncing the mail.
  12495. Defaults to @samp{#f}.
  12496. @end deftypevr
  12497. @deftypevr {@code{dovecot-configuration} parameter} file-name sendmail-path
  12498. Binary to use for sending mails.
  12499. Defaults to @samp{"/usr/sbin/sendmail"}.
  12500. @end deftypevr
  12501. @deftypevr {@code{dovecot-configuration} parameter} string submission-host
  12502. If non-empty, send mails via this SMTP host[:port] instead of
  12503. sendmail.
  12504. Defaults to @samp{""}.
  12505. @end deftypevr
  12506. @deftypevr {@code{dovecot-configuration} parameter} string rejection-subject
  12507. Subject: header to use for rejection mails. You can use the same
  12508. variables as for @samp{rejection-reason} below.
  12509. Defaults to @samp{"Rejected: %s"}.
  12510. @end deftypevr
  12511. @deftypevr {@code{dovecot-configuration} parameter} string rejection-reason
  12512. Human readable error message for rejection mails. You can use
  12513. variables:
  12514. @table @code
  12515. @item %n
  12516. CRLF
  12517. @item %r
  12518. reason
  12519. @item %s
  12520. original subject
  12521. @item %t
  12522. recipient
  12523. @end table
  12524. Defaults to @samp{"Your message to <%t> was automatically rejected:%n%r"}.
  12525. @end deftypevr
  12526. @deftypevr {@code{dovecot-configuration} parameter} string recipient-delimiter
  12527. Delimiter character between local-part and detail in email
  12528. address.
  12529. Defaults to @samp{"+"}.
  12530. @end deftypevr
  12531. @deftypevr {@code{dovecot-configuration} parameter} string lda-original-recipient-header
  12532. Header where the original recipient address (SMTP's RCPT TO:
  12533. address) is taken from if not available elsewhere. With dovecot-lda -a
  12534. parameter overrides this. A commonly used header for this is
  12535. X-Original-To.
  12536. Defaults to @samp{""}.
  12537. @end deftypevr
  12538. @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autocreate?
  12539. Should saving a mail to a nonexistent mailbox automatically create
  12540. it?.
  12541. Defaults to @samp{#f}.
  12542. @end deftypevr
  12543. @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autosubscribe?
  12544. Should automatically created mailboxes be also automatically
  12545. subscribed?.
  12546. Defaults to @samp{#f}.
  12547. @end deftypevr
  12548. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer imap-max-line-length
  12549. Maximum IMAP command line length. Some clients generate very long
  12550. command lines with huge mailboxes, so you may need to raise this if you
  12551. get "Too long argument" or "IMAP command line too large" errors
  12552. often.
  12553. Defaults to @samp{64000}.
  12554. @end deftypevr
  12555. @deftypevr {@code{dovecot-configuration} parameter} string imap-logout-format
  12556. IMAP logout format string:
  12557. @table @code
  12558. @item %i
  12559. total number of bytes read from client
  12560. @item %o
  12561. total number of bytes sent to client.
  12562. @end table
  12563. See @file{doc/wiki/Variables.txt} for a list of all the variables you can use.
  12564. 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@}"}.
  12565. @end deftypevr
  12566. @deftypevr {@code{dovecot-configuration} parameter} string imap-capability
  12567. Override the IMAP CAPABILITY response. If the value begins with '+',
  12568. add the given capabilities on top of the defaults (e.g.@: +XFOO XBAR).
  12569. Defaults to @samp{""}.
  12570. @end deftypevr
  12571. @deftypevr {@code{dovecot-configuration} parameter} string imap-idle-notify-interval
  12572. How long to wait between "OK Still here" notifications when client
  12573. is IDLEing.
  12574. Defaults to @samp{"2 mins"}.
  12575. @end deftypevr
  12576. @deftypevr {@code{dovecot-configuration} parameter} string imap-id-send
  12577. ID field names and values to send to clients. Using * as the value
  12578. makes Dovecot use the default value. The following fields have default
  12579. values currently: name, version, os, os-version, support-url,
  12580. support-email.
  12581. Defaults to @samp{""}.
  12582. @end deftypevr
  12583. @deftypevr {@code{dovecot-configuration} parameter} string imap-id-log
  12584. ID fields sent by client to log. * means everything.
  12585. Defaults to @samp{""}.
  12586. @end deftypevr
  12587. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list imap-client-workarounds
  12588. Workarounds for various client bugs:
  12589. @table @code
  12590. @item delay-newmail
  12591. Send EXISTS/RECENT new mail notifications only when replying to NOOP and
  12592. CHECK commands. Some clients ignore them otherwise, for example OSX
  12593. Mail (<v2.1). Outlook Express breaks more badly though, without this it
  12594. may show user "Message no longer in server" errors. Note that OE6
  12595. still breaks even with this workaround if synchronization is set to
  12596. "Headers Only".
  12597. @item tb-extra-mailbox-sep
  12598. Thunderbird gets somehow confused with LAYOUT=fs (mbox and dbox) and
  12599. adds extra @samp{/} suffixes to mailbox names. This option causes Dovecot to
  12600. ignore the extra @samp{/} instead of treating it as invalid mailbox name.
  12601. @item tb-lsub-flags
  12602. Show \Noselect flags for LSUB replies with LAYOUT=fs (e.g.@: mbox).
  12603. This makes Thunderbird realize they aren't selectable and show them
  12604. greyed out, instead of only later giving "not selectable" popup error.
  12605. @end table
  12606. Defaults to @samp{()}.
  12607. @end deftypevr
  12608. @deftypevr {@code{dovecot-configuration} parameter} string imap-urlauth-host
  12609. Host allowed in URLAUTH URLs sent by client. "*" allows all.
  12610. Defaults to @samp{""}.
  12611. @end deftypevr
  12612. Whew! Lots of configuration options. The nice thing about it though is
  12613. that GuixSD has a complete interface to Dovecot's configuration
  12614. language. This allows not only a nice way to declare configurations,
  12615. but also offers reflective capabilities as well: users can write code to
  12616. inspect and transform configurations from within Scheme.
  12617. However, it could be that you just want to get a @code{dovecot.conf} up
  12618. and running. In that case, you can pass an
  12619. @code{opaque-dovecot-configuration} as the @code{#:config} parameter to
  12620. @code{dovecot-service}. As its name indicates, an opaque configuration
  12621. does not have easy reflective capabilities.
  12622. Available @code{opaque-dovecot-configuration} fields are:
  12623. @deftypevr {@code{opaque-dovecot-configuration} parameter} package dovecot
  12624. The dovecot package.
  12625. @end deftypevr
  12626. @deftypevr {@code{opaque-dovecot-configuration} parameter} string string
  12627. The contents of the @code{dovecot.conf}, as a string.
  12628. @end deftypevr
  12629. For example, if your @code{dovecot.conf} is just the empty string, you
  12630. could instantiate a dovecot service like this:
  12631. @example
  12632. (dovecot-service #:config
  12633. (opaque-dovecot-configuration
  12634. (string "")))
  12635. @end example
  12636. @subsubheading OpenSMTPD Service
  12637. @deffn {Scheme Variable} opensmtpd-service-type
  12638. This is the type of the @uref{https://www.opensmtpd.org, OpenSMTPD}
  12639. service, whose value should be an @code{opensmtpd-configuration} object
  12640. as in this example:
  12641. @example
  12642. (service opensmtpd-service-type
  12643. (opensmtpd-configuration
  12644. (config-file (local-file "./my-smtpd.conf"))))
  12645. @end example
  12646. @end deffn
  12647. @deftp {Data Type} opensmtpd-configuration
  12648. Data type representing the configuration of opensmtpd.
  12649. @table @asis
  12650. @item @code{package} (default: @var{opensmtpd})
  12651. Package object of the OpenSMTPD SMTP server.
  12652. @item @code{config-file} (default: @var{%default-opensmtpd-file})
  12653. File-like object of the OpenSMTPD configuration file to use. By default
  12654. it listens on the loopback network interface, and allows for mail from
  12655. users and daemons on the local machine, as well as permitting email to
  12656. remote servers. Run @command{man smtpd.conf} for more information.
  12657. @end table
  12658. @end deftp
  12659. @subsubheading Exim Service
  12660. @cindex mail transfer agent (MTA)
  12661. @cindex MTA (mail transfer agent)
  12662. @cindex SMTP
  12663. @deffn {Scheme Variable} exim-service-type
  12664. This is the type of the @uref{https://exim.org, Exim} mail transfer
  12665. agent (MTA), whose value should be an @code{exim-configuration} object
  12666. as in this example:
  12667. @example
  12668. (service exim-service-type
  12669. (exim-configuration
  12670. (config-file (local-file "./my-exim.conf"))))
  12671. @end example
  12672. @end deffn
  12673. In order to use an @code{exim-service-type} service you must also have a
  12674. @code{mail-aliases-service-type} service present in your
  12675. @code{operating-system} (even if it has no aliases).
  12676. @deftp {Data Type} exim-configuration
  12677. Data type representing the configuration of exim.
  12678. @table @asis
  12679. @item @code{package} (default: @var{exim})
  12680. Package object of the Exim server.
  12681. @item @code{config-file} (default: @code{#f})
  12682. File-like object of the Exim configuration file to use. If its value is
  12683. @code{#f} then use the default configuration file from the package
  12684. provided in @code{package}. The resulting configuration file is loaded
  12685. after setting the @code{exim_user} and @code{exim_group} configuration
  12686. variables.
  12687. @end table
  12688. @end deftp
  12689. @subsubheading Mail Aliases Service
  12690. @cindex email aliases
  12691. @cindex aliases, for email addresses
  12692. @deffn {Scheme Variable} mail-aliases-service-type
  12693. This is the type of the service which provides @code{/etc/aliases},
  12694. specifying how to deliver mail to users on this system.
  12695. @example
  12696. (service mail-aliases-service-type
  12697. '(("postmaster" "bob")
  12698. ("bob" "bob@@example.com" "bob@@example2.com")))
  12699. @end example
  12700. @end deffn
  12701. The configuration for a @code{mail-aliases-service-type} service is an
  12702. association list denoting how to deliver mail that comes to this
  12703. system. Each entry is of the form @code{(alias addresses ...)}, with
  12704. @code{alias} specifying the local alias and @code{addresses} specifying
  12705. where to deliver this user's mail.
  12706. The aliases aren't required to exist as users on the local system. In
  12707. the above example, there doesn't need to be a @code{postmaster} entry in
  12708. the @code{operating-system}'s @code{user-accounts} in order to deliver
  12709. the @code{postmaster} mail to @code{bob} (which subsequently would
  12710. deliver mail to @code{bob@@example.com} and @code{bob@@example2.com}).
  12711. @node Messaging Services
  12712. @subsubsection Messaging Services
  12713. @cindex messaging
  12714. @cindex jabber
  12715. @cindex XMPP
  12716. The @code{(gnu services messaging)} module provides Guix service
  12717. definitions for messaging services: currently only Prosody is supported.
  12718. @subsubheading Prosody Service
  12719. @deffn {Scheme Variable} prosody-service-type
  12720. This is the type for the @uref{https://prosody.im, Prosody XMPP
  12721. communication server}. Its value must be a @code{prosody-configuration}
  12722. record as in this example:
  12723. @example
  12724. (service prosody-service-type
  12725. (prosody-configuration
  12726. (modules-enabled (cons "groups" "mam" %default-modules-enabled))
  12727. (int-components
  12728. (list
  12729. (int-component-configuration
  12730. (hostname "conference.example.net")
  12731. (plugin "muc")
  12732. (mod-muc (mod-muc-configuration)))))
  12733. (virtualhosts
  12734. (list
  12735. (virtualhost-configuration
  12736. (domain "example.net"))))))
  12737. @end example
  12738. See below for details about @code{prosody-configuration}.
  12739. @end deffn
  12740. By default, Prosody does not need much configuration. Only one
  12741. @code{virtualhosts} field is needed: it specifies the domain you wish
  12742. Prosody to serve.
  12743. You can perform various sanity checks on the generated configuration
  12744. with the @code{prosodyctl check} command.
  12745. Prosodyctl will also help you to import certificates from the
  12746. @code{letsencrypt} directory so that the @code{prosody} user can access
  12747. them. See @url{https://prosody.im/doc/letsencrypt}.
  12748. @example
  12749. prosodyctl --root cert import /etc/letsencrypt/live
  12750. @end example
  12751. The available configuration parameters follow. Each parameter
  12752. definition is preceded by its type; for example, @samp{string-list foo}
  12753. indicates that the @code{foo} parameter should be specified as a list of
  12754. strings. Types starting with @code{maybe-} denote parameters that won't
  12755. show up in @code{prosody.cfg.lua} when their value is @code{'disabled}.
  12756. There is also a way to specify the configuration as a string, if you
  12757. have an old @code{prosody.cfg.lua} file that you want to port over from
  12758. some other system; see the end for more details.
  12759. The @code{file-object} type designates either a file-like object
  12760. (@pxref{G-Expressions, file-like objects}) or a file name.
  12761. @c The following documentation was initially generated by
  12762. @c (generate-documentation) in (gnu services messaging). Manually maintained
  12763. @c documentation is better, so we shouldn't hesitate to edit below as
  12764. @c needed. However if the change you want to make to this documentation
  12765. @c can be done in an automated way, it's probably easier to change
  12766. @c (generate-documentation) than to make it below and have to deal with
  12767. @c the churn as Prosody updates.
  12768. Available @code{prosody-configuration} fields are:
  12769. @deftypevr {@code{prosody-configuration} parameter} package prosody
  12770. The Prosody package.
  12771. @end deftypevr
  12772. @deftypevr {@code{prosody-configuration} parameter} file-name data-path
  12773. Location of the Prosody data storage directory. See
  12774. @url{https://prosody.im/doc/configure}.
  12775. Defaults to @samp{"/var/lib/prosody"}.
  12776. @end deftypevr
  12777. @deftypevr {@code{prosody-configuration} parameter} file-object-list plugin-paths
  12778. Additional plugin directories. They are searched in all the specified
  12779. paths in order. See @url{https://prosody.im/doc/plugins_directory}.
  12780. Defaults to @samp{()}.
  12781. @end deftypevr
  12782. @deftypevr {@code{prosody-configuration} parameter} file-name certificates
  12783. Every virtual host and component needs a certificate so that clients and
  12784. servers can securely verify its identity. Prosody will automatically load
  12785. certificates/keys from the directory specified here.
  12786. Defaults to @samp{"/etc/prosody/certs"}.
  12787. @end deftypevr
  12788. @deftypevr {@code{prosody-configuration} parameter} string-list admins
  12789. This is a list of accounts that are admins for the server. Note that you
  12790. must create the accounts separately. See @url{https://prosody.im/doc/admins} and
  12791. @url{https://prosody.im/doc/creating_accounts}.
  12792. Example: @code{(admins '("user1@@example.com" "user2@@example.net"))}
  12793. Defaults to @samp{()}.
  12794. @end deftypevr
  12795. @deftypevr {@code{prosody-configuration} parameter} boolean use-libevent?
  12796. Enable use of libevent for better performance under high load. See
  12797. @url{https://prosody.im/doc/libevent}.
  12798. Defaults to @samp{#f}.
  12799. @end deftypevr
  12800. @deftypevr {@code{prosody-configuration} parameter} module-list modules-enabled
  12801. This is the list of modules Prosody will load on startup. It looks for
  12802. @code{mod_modulename.lua} in the plugins folder, so make sure that exists too.
  12803. Documentation on modules can be found at:
  12804. @url{https://prosody.im/doc/modules}.
  12805. Defaults to @samp{("roster" "saslauth" "tls" "dialback" "disco" "carbons" "private" "blocklist" "vcard" "version" "uptime" "time" "ping" "pep" "register" "admin_adhoc")}.
  12806. @end deftypevr
  12807. @deftypevr {@code{prosody-configuration} parameter} string-list modules-disabled
  12808. @samp{"offline"}, @samp{"c2s"} and @samp{"s2s"} are auto-loaded, but
  12809. should you want to disable them then add them to this list.
  12810. Defaults to @samp{()}.
  12811. @end deftypevr
  12812. @deftypevr {@code{prosody-configuration} parameter} file-object groups-file
  12813. Path to a text file where the shared groups are defined. If this path is
  12814. empty then @samp{mod_groups} does nothing. See
  12815. @url{https://prosody.im/doc/modules/mod_groups}.
  12816. Defaults to @samp{"/var/lib/prosody/sharedgroups.txt"}.
  12817. @end deftypevr
  12818. @deftypevr {@code{prosody-configuration} parameter} boolean allow-registration?
  12819. Disable account creation by default, for security. See
  12820. @url{https://prosody.im/doc/creating_accounts}.
  12821. Defaults to @samp{#f}.
  12822. @end deftypevr
  12823. @deftypevr {@code{prosody-configuration} parameter} maybe-ssl-configuration ssl
  12824. These are the SSL/TLS-related settings. Most of them are disabled so to
  12825. use Prosody's defaults. If you do not completely understand these options, do
  12826. not add them to your config, it is easy to lower the security of your server
  12827. using them. See @url{https://prosody.im/doc/advanced_ssl_config}.
  12828. Available @code{ssl-configuration} fields are:
  12829. @deftypevr {@code{ssl-configuration} parameter} maybe-string protocol
  12830. This determines what handshake to use.
  12831. @end deftypevr
  12832. @deftypevr {@code{ssl-configuration} parameter} maybe-file-name key
  12833. Path to your private key file.
  12834. @end deftypevr
  12835. @deftypevr {@code{ssl-configuration} parameter} maybe-file-name certificate
  12836. Path to your certificate file.
  12837. @end deftypevr
  12838. @deftypevr {@code{ssl-configuration} parameter} file-object capath
  12839. Path to directory containing root certificates that you wish Prosody to
  12840. trust when verifying the certificates of remote servers.
  12841. Defaults to @samp{"/etc/ssl/certs"}.
  12842. @end deftypevr
  12843. @deftypevr {@code{ssl-configuration} parameter} maybe-file-object cafile
  12844. Path to a file containing root certificates that you wish Prosody to trust.
  12845. Similar to @code{capath} but with all certificates concatenated together.
  12846. @end deftypevr
  12847. @deftypevr {@code{ssl-configuration} parameter} maybe-string-list verify
  12848. A list of verification options (these mostly map to OpenSSL's
  12849. @code{set_verify()} flags).
  12850. @end deftypevr
  12851. @deftypevr {@code{ssl-configuration} parameter} maybe-string-list options
  12852. A list of general options relating to SSL/TLS. These map to OpenSSL's
  12853. @code{set_options()}. For a full list of options available in LuaSec, see the
  12854. LuaSec source.
  12855. @end deftypevr
  12856. @deftypevr {@code{ssl-configuration} parameter} maybe-non-negative-integer depth
  12857. How long a chain of certificate authorities to check when looking for a
  12858. trusted root certificate.
  12859. @end deftypevr
  12860. @deftypevr {@code{ssl-configuration} parameter} maybe-string ciphers
  12861. An OpenSSL cipher string. This selects what ciphers Prosody will offer to
  12862. clients, and in what order.
  12863. @end deftypevr
  12864. @deftypevr {@code{ssl-configuration} parameter} maybe-file-name dhparam
  12865. A path to a file containing parameters for Diffie-Hellman key exchange. You
  12866. can create such a file with:
  12867. @code{openssl dhparam -out /etc/prosody/certs/dh-2048.pem 2048}
  12868. @end deftypevr
  12869. @deftypevr {@code{ssl-configuration} parameter} maybe-string curve
  12870. Curve for Elliptic curve Diffie-Hellman. Prosody's default is
  12871. @samp{"secp384r1"}.
  12872. @end deftypevr
  12873. @deftypevr {@code{ssl-configuration} parameter} maybe-string-list verifyext
  12874. A list of "extra" verification options.
  12875. @end deftypevr
  12876. @deftypevr {@code{ssl-configuration} parameter} maybe-string password
  12877. Password for encrypted private keys.
  12878. @end deftypevr
  12879. @end deftypevr
  12880. @deftypevr {@code{prosody-configuration} parameter} boolean c2s-require-encryption?
  12881. Whether to force all client-to-server connections to be encrypted or not.
  12882. See @url{https://prosody.im/doc/modules/mod_tls}.
  12883. Defaults to @samp{#f}.
  12884. @end deftypevr
  12885. @deftypevr {@code{prosody-configuration} parameter} string-list disable-sasl-mechanisms
  12886. Set of mechanisms that will never be offered. See
  12887. @url{https://prosody.im/doc/modules/mod_saslauth}.
  12888. Defaults to @samp{("DIGEST-MD5")}.
  12889. @end deftypevr
  12890. @deftypevr {@code{prosody-configuration} parameter} boolean s2s-require-encryption?
  12891. Whether to force all server-to-server connections to be encrypted or not.
  12892. See @url{https://prosody.im/doc/modules/mod_tls}.
  12893. Defaults to @samp{#f}.
  12894. @end deftypevr
  12895. @deftypevr {@code{prosody-configuration} parameter} boolean s2s-secure-auth?
  12896. Whether to require encryption and certificate authentication. This
  12897. provides ideal security, but requires servers you communicate with to support
  12898. encryption AND present valid, trusted certificates. See
  12899. @url{https://prosody.im/doc/s2s#security}.
  12900. Defaults to @samp{#f}.
  12901. @end deftypevr
  12902. @deftypevr {@code{prosody-configuration} parameter} string-list s2s-insecure-domains
  12903. Many servers don't support encryption or have invalid or self-signed
  12904. certificates. You can list domains here that will not be required to
  12905. authenticate using certificates. They will be authenticated using DNS. See
  12906. @url{https://prosody.im/doc/s2s#security}.
  12907. Defaults to @samp{()}.
  12908. @end deftypevr
  12909. @deftypevr {@code{prosody-configuration} parameter} string-list s2s-secure-domains
  12910. Even if you leave @code{s2s-secure-auth?} disabled, you can still require
  12911. valid certificates for some domains by specifying a list here. See
  12912. @url{https://prosody.im/doc/s2s#security}.
  12913. Defaults to @samp{()}.
  12914. @end deftypevr
  12915. @deftypevr {@code{prosody-configuration} parameter} string authentication
  12916. Select the authentication backend to use. The default provider stores
  12917. passwords in plaintext and uses Prosody's configured data storage to store the
  12918. authentication data. If you do not trust your server please see
  12919. @url{https://prosody.im/doc/modules/mod_auth_internal_hashed} for information
  12920. about using the hashed backend. See also
  12921. @url{https://prosody.im/doc/authentication}
  12922. Defaults to @samp{"internal_plain"}.
  12923. @end deftypevr
  12924. @deftypevr {@code{prosody-configuration} parameter} maybe-string log
  12925. Set logging options. Advanced logging configuration is not yet supported
  12926. by the GuixSD Prosody Service. See @url{https://prosody.im/doc/logging}.
  12927. Defaults to @samp{"*syslog"}.
  12928. @end deftypevr
  12929. @deftypevr {@code{prosody-configuration} parameter} file-name pidfile
  12930. File to write pid in. See @url{https://prosody.im/doc/modules/mod_posix}.
  12931. Defaults to @samp{"/var/run/prosody/prosody.pid"}.
  12932. @end deftypevr
  12933. @deftypevr {@code{prosody-configuration} parameter} maybe-non-negative-integer http-max-content-size
  12934. Maximum allowed size of the HTTP body (in bytes).
  12935. @end deftypevr
  12936. @deftypevr {@code{prosody-configuration} parameter} maybe-string http-external-url
  12937. Some modules expose their own URL in various ways. This URL is built
  12938. from the protocol, host and port used. If Prosody sits behind a proxy, the
  12939. public URL will be @code{http-external-url} instead. See
  12940. @url{https://prosody.im/doc/http#external_url}.
  12941. @end deftypevr
  12942. @deftypevr {@code{prosody-configuration} parameter} virtualhost-configuration-list virtualhosts
  12943. A host in Prosody is a domain on which user accounts can be created. For
  12944. example if you want your users to have addresses like
  12945. @samp{"john.smith@@example.com"} then you need to add a host
  12946. @samp{"example.com"}. All options in this list will apply only to this host.
  12947. Note: the name "virtual" host is used in configuration to avoid confusion with
  12948. the actual physical host that Prosody is installed on. A single Prosody
  12949. instance can serve many domains, each one defined as a VirtualHost entry in
  12950. Prosody's configuration. Conversely a server that hosts a single domain would
  12951. have just one VirtualHost entry.
  12952. See @url{https://prosody.im/doc/configure#virtual_host_settings}.
  12953. Available @code{virtualhost-configuration} fields are:
  12954. 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:
  12955. @deftypevr {@code{virtualhost-configuration} parameter} string domain
  12956. Domain you wish Prosody to serve.
  12957. @end deftypevr
  12958. @end deftypevr
  12959. @deftypevr {@code{prosody-configuration} parameter} int-component-configuration-list int-components
  12960. Components are extra services on a server which are available to clients,
  12961. usually on a subdomain of the main server (such as
  12962. @samp{"mycomponent.example.com"}). Example components might be chatroom
  12963. servers, user directories, or gateways to other protocols.
  12964. Internal components are implemented with Prosody-specific plugins. To add an
  12965. internal component, you simply fill the hostname field, and the plugin you wish
  12966. to use for the component.
  12967. See @url{https://prosody.im/doc/components}.
  12968. Defaults to @samp{()}.
  12969. Available @code{int-component-configuration} fields are:
  12970. 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:
  12971. @deftypevr {@code{int-component-configuration} parameter} string hostname
  12972. Hostname of the component.
  12973. @end deftypevr
  12974. @deftypevr {@code{int-component-configuration} parameter} string plugin
  12975. Plugin you wish to use for the component.
  12976. @end deftypevr
  12977. @deftypevr {@code{int-component-configuration} parameter} maybe-mod-muc-configuration mod-muc
  12978. Multi-user chat (MUC) is Prosody's module for allowing you to create
  12979. hosted chatrooms/conferences for XMPP users.
  12980. General information on setting up and using multi-user chatrooms can be found
  12981. in the "Chatrooms" documentation (@url{https://prosody.im/doc/chatrooms}),
  12982. which you should read if you are new to XMPP chatrooms.
  12983. See also @url{https://prosody.im/doc/modules/mod_muc}.
  12984. Available @code{mod-muc-configuration} fields are:
  12985. @deftypevr {@code{mod-muc-configuration} parameter} string name
  12986. The name to return in service discovery responses.
  12987. Defaults to @samp{"Prosody Chatrooms"}.
  12988. @end deftypevr
  12989. @deftypevr {@code{mod-muc-configuration} parameter} string-or-boolean restrict-room-creation
  12990. If @samp{#t}, this will only allow admins to create new chatrooms.
  12991. Otherwise anyone can create a room. The value @samp{"local"} restricts room
  12992. creation to users on the service's parent domain. E.g.@: @samp{user@@example.com}
  12993. can create rooms on @samp{rooms.example.com}. The value @samp{"admin"}
  12994. restricts to service administrators only.
  12995. Defaults to @samp{#f}.
  12996. @end deftypevr
  12997. @deftypevr {@code{mod-muc-configuration} parameter} non-negative-integer max-history-messages
  12998. Maximum number of history messages that will be sent to the member that has
  12999. just joined the room.
  13000. Defaults to @samp{20}.
  13001. @end deftypevr
  13002. @end deftypevr
  13003. @end deftypevr
  13004. @deftypevr {@code{prosody-configuration} parameter} ext-component-configuration-list ext-components
  13005. External components use XEP-0114, which most standalone components
  13006. support. To add an external component, you simply fill the hostname field. See
  13007. @url{https://prosody.im/doc/components}.
  13008. Defaults to @samp{()}.
  13009. Available @code{ext-component-configuration} fields are:
  13010. 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:
  13011. @deftypevr {@code{ext-component-configuration} parameter} string component-secret
  13012. Password which the component will use to log in.
  13013. @end deftypevr
  13014. @deftypevr {@code{ext-component-configuration} parameter} string hostname
  13015. Hostname of the component.
  13016. @end deftypevr
  13017. @end deftypevr
  13018. @deftypevr {@code{prosody-configuration} parameter} non-negative-integer-list component-ports
  13019. Port(s) Prosody listens on for component connections.
  13020. Defaults to @samp{(5347)}.
  13021. @end deftypevr
  13022. @deftypevr {@code{prosody-configuration} parameter} string component-interface
  13023. Interface Prosody listens on for component connections.
  13024. Defaults to @samp{"127.0.0.1"}.
  13025. @end deftypevr
  13026. @deftypevr {@code{prosody-configuration} parameter} maybe-raw-content raw-content
  13027. Raw content that will be added to the configuration file.
  13028. @end deftypevr
  13029. It could be that you just want to get a @code{prosody.cfg.lua}
  13030. up and running. In that case, you can pass an
  13031. @code{opaque-prosody-configuration} record as the value of
  13032. @code{prosody-service-type}. As its name indicates, an opaque configuration
  13033. does not have easy reflective capabilities.
  13034. Available @code{opaque-prosody-configuration} fields are:
  13035. @deftypevr {@code{opaque-prosody-configuration} parameter} package prosody
  13036. The prosody package.
  13037. @end deftypevr
  13038. @deftypevr {@code{opaque-prosody-configuration} parameter} string prosody.cfg.lua
  13039. The contents of the @code{prosody.cfg.lua} to use.
  13040. @end deftypevr
  13041. For example, if your @code{prosody.cfg.lua} is just the empty
  13042. string, you could instantiate a prosody service like this:
  13043. @example
  13044. (service prosody-service-type
  13045. (opaque-prosody-configuration
  13046. (prosody.cfg.lua "")))
  13047. @end example
  13048. @c end of Prosody auto-generated documentation
  13049. @subsubheading BitlBee Service
  13050. @cindex IRC (Internet Relay Chat)
  13051. @cindex IRC gateway
  13052. @url{http://bitlbee.org,BitlBee} is a gateway that provides an IRC
  13053. interface to a variety of messaging protocols such as XMPP.
  13054. @defvr {Scheme Variable} bitlbee-service-type
  13055. This is the service type for the @url{http://bitlbee.org,BitlBee} IRC
  13056. gateway daemon. Its value is a @code{bitlbee-configuration} (see
  13057. below).
  13058. To have BitlBee listen on port 6667 on localhost, add this line to your
  13059. services:
  13060. @example
  13061. (service bitlbee-service-type)
  13062. @end example
  13063. @end defvr
  13064. @deftp {Data Type} bitlbee-configuration
  13065. This is the configuration for BitlBee, with the following fields:
  13066. @table @asis
  13067. @item @code{interface} (default: @code{"127.0.0.1"})
  13068. @itemx @code{port} (default: @code{6667})
  13069. Listen on the network interface corresponding to the IP address
  13070. specified in @var{interface}, on @var{port}.
  13071. When @var{interface} is @code{127.0.0.1}, only local clients can
  13072. connect; when it is @code{0.0.0.0}, connections can come from any
  13073. networking interface.
  13074. @item @code{package} (default: @code{bitlbee})
  13075. The BitlBee package to use.
  13076. @item @code{plugins} (default: @code{'()})
  13077. List of plugin packages to use---e.g., @code{bitlbee-discord}.
  13078. @item @code{extra-settings} (default: @code{""})
  13079. Configuration snippet added as-is to the BitlBee configuration file.
  13080. @end table
  13081. @end deftp
  13082. @node Telephony Services
  13083. @subsubsection Telephony Services
  13084. @cindex Murmur (VoIP server)
  13085. @cindex VoIP server
  13086. This section describes how to set up and run a Murmur server. Murmur is
  13087. the server of the @uref{https://mumble.info, Mumble} voice-over-IP
  13088. (VoIP) suite.
  13089. @deftp {Data Type} murmur-configuration
  13090. The service type for the Murmur server. An example configuration can
  13091. look like this:
  13092. @example
  13093. (service murmur-service-type
  13094. (murmur-configuration
  13095. (welcome-text
  13096. "Welcome to this Mumble server running on GuixSD!")
  13097. (cert-required? #t) ;disallow text password logins
  13098. (ssl-cert "/etc/letsencrypt/live/mumble.example.com/fullchain.pem")
  13099. (ssl-key "/etc/letsencrypt/live/mumble.example.com/privkey.pem")))
  13100. @end example
  13101. After reconfiguring your system, you can manually set the murmur @code{SuperUser}
  13102. password with the command that is printed during the activation phase.
  13103. It is recommended to register a normal Mumble user account
  13104. and grant it admin or moderator rights.
  13105. You can use the @code{mumble} client to
  13106. login as new normal user, register yourself, and log out.
  13107. For the next step login with the name @code{SuperUser} use
  13108. the @code{SuperUser} password that you set previously,
  13109. and grant your newly registered mumble user administrator or moderator
  13110. rights and create some channels.
  13111. Available @code{murmur-configuration} fields are:
  13112. @table @asis
  13113. @item @code{package} (default: @code{mumble})
  13114. Package that contains @code{bin/murmurd}.
  13115. @item @code{user} (default: @code{"murmur"})
  13116. User who will run the Murmur server.
  13117. @item @code{group} (default: @code{"murmur"})
  13118. Group of the user who will run the murmur server.
  13119. @item @code{port} (default: @code{64738})
  13120. Port on which the server will listen.
  13121. @item @code{welcome-text} (default: @code{""})
  13122. Welcome text sent to clients when they connect.
  13123. @item @code{server-password} (default: @code{""})
  13124. Password the clients have to enter in order to connect.
  13125. @item @code{max-users} (default: @code{100})
  13126. Maximum of users that can be connected to the server at once.
  13127. @item @code{max-user-bandwidth} (default: @code{#f})
  13128. Maximum voice traffic a user can send per second.
  13129. @item @code{database-file} (default: @code{"/var/lib/murmur/db.sqlite"})
  13130. File name of the sqlite database.
  13131. The service's user will become the owner of the directory.
  13132. @item @code{log-file} (default: @code{"/var/log/murmur/murmur.log"})
  13133. File name of the log file.
  13134. The service's user will become the owner of the directory.
  13135. @item @code{autoban-attempts} (default: @code{10})
  13136. Maximum number of logins a user can make in @code{autoban-timeframe}
  13137. without getting auto banned for @code{autoban-time}.
  13138. @item @code{autoban-timeframe} (default: @code{120})
  13139. Timeframe for autoban in seconds.
  13140. @item @code{autoban-time} (default: @code{300})
  13141. Amount of time in seconds for which a client gets banned
  13142. when violating the autoban limits.
  13143. @item @code{opus-threshold} (default: @code{100})
  13144. Percentage of clients that need to support opus
  13145. before switching over to opus audio codec.
  13146. @item @code{channel-nesting-limit} (default: @code{10})
  13147. How deep channels can be nested at maximum.
  13148. @item @code{channelname-regex} (default: @code{#f})
  13149. A string in form of a Qt regular expression that channel names must conform to.
  13150. @item @code{username-regex} (default: @code{#f})
  13151. A string in form of a Qt regular expression that user names must conform to.
  13152. @item @code{text-message-length} (default: @code{5000})
  13153. Maximum size in bytes that a user can send in one text chat message.
  13154. @item @code{image-message-length} (default: @code{(* 128 1024)})
  13155. Maximum size in bytes that a user can send in one image message.
  13156. @item @code{cert-required?} (default: @code{#f})
  13157. If it is set to @code{#t} clients that use weak password authentification
  13158. will not be accepted. Users must have completed the certificate wizard to join.
  13159. @item @code{remember-channel?} (default: @code{#f})
  13160. Should murmur remember the last channel each user was in when they disconnected
  13161. and put them into the remembered channel when they rejoin.
  13162. @item @code{allow-html?} (default: @code{#f})
  13163. Should html be allowed in text messages, user comments, and channel descriptions.
  13164. @item @code{allow-ping?} (default: @code{#f})
  13165. Setting to true exposes the current user count, the maximum user count, and
  13166. the server's maximum bandwidth per client to unauthenticated users. In the
  13167. Mumble client, this information is shown in the Connect dialog.
  13168. Disabling this setting will prevent public listing of the server.
  13169. @item @code{bonjour?} (default: @code{#f})
  13170. Should the server advertise itself in the local network through the bonjour protocol.
  13171. @item @code{send-version?} (default: @code{#f})
  13172. Should the murmur server version be exposed in ping requests.
  13173. @item @code{log-days} (default: @code{31})
  13174. Murmur also stores logs in the database, which are accessible via RPC.
  13175. The default is 31 days of months, but you can set this setting to 0 to keep logs forever,
  13176. or -1 to disable logging to the database.
  13177. @item @code{obfuscate-ips?} (default: @code{#t})
  13178. Should logged ips be obfuscated to protect the privacy of users.
  13179. @item @code{ssl-cert} (default: @code{#f})
  13180. File name of the SSL/TLS certificate used for encrypted connections.
  13181. @example
  13182. (ssl-cert "/etc/letsencrypt/live/example.com/fullchain.pem")
  13183. @end example
  13184. @item @code{ssl-key} (default: @code{#f})
  13185. Filepath to the ssl private key used for encrypted connections.
  13186. @example
  13187. (ssl-key "/etc/letsencrypt/live/example.com/privkey.pem")
  13188. @end example
  13189. @item @code{ssl-dh-params} (default: @code{#f})
  13190. File name of a PEM-encoded file with Diffie-Hellman parameters
  13191. for the SSL/TLS encryption. Alternatively you set it to
  13192. @code{"@@ffdhe2048"}, @code{"@@ffdhe3072"}, @code{"@@ffdhe4096"}, @code{"@@ffdhe6144"}
  13193. or @code{"@@ffdhe8192"} to use bundled parameters from RFC 7919.
  13194. @item @code{ssl-ciphers} (default: @code{#f})
  13195. The @code{ssl-ciphers} option chooses the cipher suites to make available for use
  13196. in SSL/TLS.
  13197. This option is specified using
  13198. @uref{https://www.openssl.org/docs/apps/ciphers.html#CIPHER-LIST-FORMAT,
  13199. OpenSSL cipher list notation}.
  13200. It is recommended that you try your cipher string using 'openssl ciphers <string>'
  13201. before setting it here, to get a feel for which cipher suites you will get.
  13202. After setting this option, it is recommend that you inspect your Murmur log
  13203. to ensure that Murmur is using the cipher suites that you expected it to.
  13204. Note: Changing this option may impact the backwards compatibility of your
  13205. Murmur server, and can remove the ability for older Mumble clients to be able
  13206. to connect to it.
  13207. @item @code{public-registration} (default: @code{#f})
  13208. Must be a @code{<murmur-public-registration-configuration>} record or @code{#f}.
  13209. You can optionally register your server in the public server list that the
  13210. @code{mumble} client shows on startup.
  13211. You cannot register your server if you have set a @code{server-password},
  13212. or set @code{allow-ping} to @code{#f}.
  13213. It might take a few hours until it shows up in the public list.
  13214. @item @code{file} (default: @code{#f})
  13215. Optional alternative override for this configuration.
  13216. @end table
  13217. @end deftp
  13218. @deftp {Data Type} murmur-public-registration-configuration
  13219. Configuration for public registration of a murmur service.
  13220. @table @asis
  13221. @item @code{name}
  13222. This is a display name for your server. Not to be confused with the hostname.
  13223. @item @code{password}
  13224. A password to identify your registration.
  13225. Subsequent updates will need the same password. Don't lose your password.
  13226. @item @code{url}
  13227. This should be a @code{http://} or @code{https://} link to your web
  13228. site.
  13229. @item @code{hostname} (default: @code{#f})
  13230. By default your server will be listed by its IP address.
  13231. If it is set your server will be linked by this host name instead.
  13232. @end table
  13233. @end deftp
  13234. @node Monitoring Services
  13235. @subsubsection Monitoring Services
  13236. @subsubheading Tailon Service
  13237. @uref{https://tailon.readthedocs.io/, Tailon} is a web application for
  13238. viewing and searching log files.
  13239. The following example will configure the service with default values.
  13240. By default, Tailon can be accessed on port 8080 (@code{http://localhost:8080}).
  13241. @example
  13242. (service tailon-service-type)
  13243. @end example
  13244. The following example customises more of the Tailon configuration,
  13245. adding @command{sed} to the list of allowed commands.
  13246. @example
  13247. (service tailon-service-type
  13248. (tailon-configuration
  13249. (config-file
  13250. (tailon-configuration-file
  13251. (allowed-commands '("tail" "grep" "awk" "sed"))))))
  13252. @end example
  13253. @deftp {Data Type} tailon-configuration
  13254. Data type representing the configuration of Tailon.
  13255. This type has the following parameters:
  13256. @table @asis
  13257. @item @code{config-file} (default: @code{(tailon-configuration-file)})
  13258. The configuration file to use for Tailon. This can be set to a
  13259. @dfn{tailon-configuration-file} record value, or any gexp
  13260. (@pxref{G-Expressions}).
  13261. For example, to instead use a local file, the @code{local-file} function
  13262. can be used:
  13263. @example
  13264. (service tailon-service-type
  13265. (tailon-configuration
  13266. (config-file (local-file "./my-tailon.conf"))))
  13267. @end example
  13268. @item @code{package} (default: @code{tailon})
  13269. The tailon package to use.
  13270. @end table
  13271. @end deftp
  13272. @deftp {Data Type} tailon-configuration-file
  13273. Data type representing the configuration options for Tailon.
  13274. This type has the following parameters:
  13275. @table @asis
  13276. @item @code{files} (default: @code{(list "/var/log")})
  13277. List of files to display. The list can include strings for a single file
  13278. or directory, or a list, where the first item is the name of a
  13279. subsection, and the remaining items are the files or directories in that
  13280. subsection.
  13281. @item @code{bind} (default: @code{"localhost:8080"})
  13282. Address and port to which Tailon should bind on.
  13283. @item @code{relative-root} (default: @code{#f})
  13284. URL path to use for Tailon, set to @code{#f} to not use a path.
  13285. @item @code{allow-transfers?} (default: @code{#t})
  13286. Allow downloading the log files in the web interface.
  13287. @item @code{follow-names?} (default: @code{#t})
  13288. Allow tailing of not-yet existent files.
  13289. @item @code{tail-lines} (default: @code{200})
  13290. Number of lines to read initially from each file.
  13291. @item @code{allowed-commands} (default: @code{(list "tail" "grep" "awk")})
  13292. Commands to allow running. By default, @code{sed} is disabled.
  13293. @item @code{debug?} (default: @code{#f})
  13294. Set @code{debug?} to @code{#t} to show debug messages.
  13295. @item @code{wrap-lines} (default: @code{#t})
  13296. Initial line wrapping state in the web interface. Set to @code{#t} to
  13297. initially wrap lines (the default), or to @code{#f} to initially not
  13298. wrap lines.
  13299. @item @code{http-auth} (default: @code{#f})
  13300. HTTP authentication type to use. Set to @code{#f} to disable
  13301. authentication (the default). Supported values are @code{"digest"} or
  13302. @code{"basic"}.
  13303. @item @code{users} (default: @code{#f})
  13304. If HTTP authentication is enabled (see @code{http-auth}), access will be
  13305. restricted to the credentials provided here. To configure users, use a
  13306. list of pairs, where the first element of the pair is the username, and
  13307. the 2nd element of the pair is the password.
  13308. @example
  13309. (tailon-configuration-file
  13310. (http-auth "basic")
  13311. (users '(("user1" . "password1")
  13312. ("user2" . "password2"))))
  13313. @end example
  13314. @end table
  13315. @end deftp
  13316. @subsubheading Darkstat Service
  13317. @cindex darkstat
  13318. Darkstat is a packet sniffer that captures network traffic, calculates
  13319. statistics about usage, and serves reports over HTTP.
  13320. @defvar {Scheme Variable} darkstat-service-type
  13321. This is the service type for the
  13322. @uref{https://unix4lyfe.org/darkstat/, darkstat}
  13323. service, its value must be a @code{darkstat-configuration} record as in
  13324. this example:
  13325. @example
  13326. (service darkstat-service-type
  13327. (darkstat-configuration
  13328. (interface "eno1")))
  13329. @end example
  13330. @end defvar
  13331. @deftp {Data Type} darkstat-configuration
  13332. Data type representing the configuration of @command{darkstat}.
  13333. @table @asis
  13334. @item @code{package} (default: @code{darkstat})
  13335. The darkstat package to use.
  13336. @item @code{interface}
  13337. Capture traffic on the specified network interface.
  13338. @item @code{port} (default: @code{"667"})
  13339. Bind the web interface to the specified port.
  13340. @item @code{bind-address} (default: @code{"127.0.0.1"})
  13341. Bind the web interface to the specified address.
  13342. @item @code{base} (default: @code{"/"})
  13343. Specify the path of the base URL. This can be useful if
  13344. @command{darkstat} is accessed via a reverse proxy.
  13345. @end table
  13346. @end deftp
  13347. @subsubheading Prometheus Node Exporter Service
  13348. @cindex prometheus-node-exporter
  13349. The Prometheus ``node exporter'' makes hardware and operating system statistics
  13350. provided by the Linux kernel available for the Prometheus monitoring system.
  13351. This service should be deployed on all physical nodes and virtual machines,
  13352. where monitoring these statistics is desirable.
  13353. @defvar {Scheme variable} prometheus-node-exporter-service-type
  13354. This is the service type for the
  13355. @uref{https://github.com/prometheus/node_exporter/, prometheus-node-exporter}
  13356. service, its value must be a @code{prometheus-node-exporter-configuration}
  13357. record as in this example:
  13358. @example
  13359. (service prometheus-node-exporter-service-type
  13360. (prometheus-node-exporter-configuration
  13361. (web-listen-address ":9100")))
  13362. @end example
  13363. @end defvar
  13364. @deftp {Data Type} prometheus-node-exporter-configuration
  13365. Data type representing the configuration of @command{node_exporter}.
  13366. @table @asis
  13367. @item @code{package} (default: @code{go-github-com-prometheus-node-exporter})
  13368. The prometheus-node-exporter package to use.
  13369. @item @code{web-listen-address} (default: @code{":9100"})
  13370. Bind the web interface to the specified address.
  13371. @end table
  13372. @end deftp
  13373. @node Kerberos Services
  13374. @subsubsection Kerberos Services
  13375. @cindex Kerberos
  13376. The @code{(gnu services kerberos)} module provides services relating to
  13377. the authentication protocol @dfn{Kerberos}.
  13378. @subsubheading Krb5 Service
  13379. Programs using a Kerberos client library normally
  13380. expect a configuration file in @file{/etc/krb5.conf}.
  13381. This service generates such a file from a definition provided in the
  13382. operating system declaration.
  13383. It does not cause any daemon to be started.
  13384. No ``keytab'' files are provided by this service---you must explicitly create them.
  13385. This service is known to work with the MIT client library, @code{mit-krb5}.
  13386. Other implementations have not been tested.
  13387. @defvr {Scheme Variable} krb5-service-type
  13388. A service type for Kerberos 5 clients.
  13389. @end defvr
  13390. @noindent
  13391. Here is an example of its use:
  13392. @lisp
  13393. (service krb5-service-type
  13394. (krb5-configuration
  13395. (default-realm "EXAMPLE.COM")
  13396. (allow-weak-crypto? #t)
  13397. (realms (list
  13398. (krb5-realm
  13399. (name "EXAMPLE.COM")
  13400. (admin-server "groucho.example.com")
  13401. (kdc "karl.example.com"))
  13402. (krb5-realm
  13403. (name "ARGRX.EDU")
  13404. (admin-server "kerb-admin.argrx.edu")
  13405. (kdc "keys.argrx.edu"))))))
  13406. @end lisp
  13407. @noindent
  13408. This example provides a Kerberos@tie{}5 client configuration which:
  13409. @itemize
  13410. @item Recognizes two realms, @i{viz:} ``EXAMPLE.COM'' and ``ARGRX.EDU'', both
  13411. of which have distinct administration servers and key distribution centers;
  13412. @item Will default to the realm ``EXAMPLE.COM'' if the realm is not explicitly
  13413. specified by clients;
  13414. @item Accepts services which only support encryption types known to be weak.
  13415. @end itemize
  13416. The @code{krb5-realm} and @code{krb5-configuration} types have many fields.
  13417. Only the most commonly used ones are described here.
  13418. For a full list, and more detailed explanation of each, see the MIT
  13419. @uref{http://web.mit.edu/kerberos/krb5-devel/doc/admin/conf_files/krb5_conf.html,,krb5.conf}
  13420. documentation.
  13421. @deftp {Data Type} krb5-realm
  13422. @cindex realm, kerberos
  13423. @table @asis
  13424. @item @code{name}
  13425. This field is a string identifying the name of the realm.
  13426. A common convention is to use the fully qualified DNS name of your organization,
  13427. converted to upper case.
  13428. @item @code{admin-server}
  13429. This field is a string identifying the host where the administration server is
  13430. running.
  13431. @item @code{kdc}
  13432. This field is a string identifying the key distribution center
  13433. for the realm.
  13434. @end table
  13435. @end deftp
  13436. @deftp {Data Type} krb5-configuration
  13437. @table @asis
  13438. @item @code{allow-weak-crypto?} (default: @code{#f})
  13439. If this flag is @code{#t} then services which only offer encryption algorithms
  13440. known to be weak will be accepted.
  13441. @item @code{default-realm} (default: @code{#f})
  13442. This field should be a string identifying the default Kerberos
  13443. realm for the client.
  13444. You should set this field to the name of your Kerberos realm.
  13445. If this value is @code{#f}
  13446. then a realm must be specified with every Kerberos principal when invoking programs
  13447. such as @command{kinit}.
  13448. @item @code{realms}
  13449. This should be a non-empty list of @code{krb5-realm} objects, which clients may
  13450. access.
  13451. Normally, one of them will have a @code{name} field matching the @code{default-realm}
  13452. field.
  13453. @end table
  13454. @end deftp
  13455. @subsubheading PAM krb5 Service
  13456. @cindex pam-krb5
  13457. The @code{pam-krb5} service allows for login authentication and password
  13458. management via Kerberos.
  13459. You will need this service if you want PAM enabled applications to authenticate
  13460. users using Kerberos.
  13461. @defvr {Scheme Variable} pam-krb5-service-type
  13462. A service type for the Kerberos 5 PAM module.
  13463. @end defvr
  13464. @deftp {Data Type} pam-krb5-configuration
  13465. Data type representing the configuration of the Kerberos 5 PAM module
  13466. This type has the following parameters:
  13467. @table @asis
  13468. @item @code{pam-krb5} (default: @code{pam-krb5})
  13469. The pam-krb5 package to use.
  13470. @item @code{minimum-uid} (default: @code{1000})
  13471. The smallest user ID for which Kerberos authentications should be attempted.
  13472. Local accounts with lower values will silently fail to authenticate.
  13473. @end table
  13474. @end deftp
  13475. @node Web Services
  13476. @subsubsection Web Services
  13477. @cindex web
  13478. @cindex www
  13479. @cindex HTTP
  13480. The @code{(gnu services web)} module provides the Apache HTTP Server,
  13481. the nginx web server, and also a fastcgi wrapper daemon.
  13482. @subsubheading Apache HTTP Server
  13483. @deffn {Scheme Variable} httpd-service-type
  13484. Service type for the @uref{https://httpd.apache.org/,Apache HTTP} server
  13485. (@dfn{httpd}). The value for this service type is a
  13486. @code{httpd-configuration} record.
  13487. A simple example configuration is given below.
  13488. @example
  13489. (service httpd-service-type
  13490. (httpd-configuration
  13491. (config
  13492. (httpd-config-file
  13493. (server-name "www.example.com")
  13494. (document-root "/srv/http/www.example.com")))))
  13495. @end example
  13496. Other services can also extend the @code{httpd-service-type} to add to
  13497. the configuration.
  13498. @example
  13499. (simple-service 'my-extra-server httpd-service-type
  13500. (list
  13501. (httpd-virtualhost
  13502. "*:80"
  13503. (list (string-append
  13504. "ServerName "www.example.com
  13505. DocumentRoot \"/srv/http/www.example.com\"")))))
  13506. @end example
  13507. @end deffn
  13508. The details for the @code{httpd-configuration}, @code{httpd-module},
  13509. @code{httpd-config-file} and @code{httpd-virtualhost} record types are
  13510. given below.
  13511. @deffn {Data Type} httpd-configuration
  13512. This data type represents the configuration for the httpd service.
  13513. @table @asis
  13514. @item @code{package} (default: @code{httpd})
  13515. The httpd package to use.
  13516. @item @code{pid-file} (default: @code{"/var/run/httpd"})
  13517. The pid file used by the shepherd-service.
  13518. @item @code{config} (default: @code{(httpd-config-file)})
  13519. The configuration file to use with the httpd service. The default value
  13520. is a @code{httpd-config-file} record, but this can also be a different
  13521. G-expression that generates a file, for example a @code{plain-file}. A
  13522. file outside of the store can also be specified through a string.
  13523. @end table
  13524. @end deffn
  13525. @deffn {Data Type} httpd-module
  13526. This data type represents a module for the httpd service.
  13527. @table @asis
  13528. @item @code{name}
  13529. The name of the module.
  13530. @item @code{file}
  13531. The file for the module. This can be relative to the httpd package being
  13532. used, the absolute location of a file, or a G-expression for a file
  13533. within the store, for example @code{(file-append mod-wsgi
  13534. "/modules/mod_wsgi.so")}.
  13535. @end table
  13536. @end deffn
  13537. @defvr {Scheme Variable} %default-httpd-modules
  13538. A default list of @code{httpd-module} objects.
  13539. @end defvr
  13540. @deffn {Data Type} httpd-config-file
  13541. This data type represents a configuration file for the httpd service.
  13542. @table @asis
  13543. @item @code{modules} (default: @code{%default-httpd-modules})
  13544. The modules to load. Additional modules can be added here, or loaded by
  13545. additional configuration.
  13546. For example, in order to handle requests for PHP files, you can use Apache’s
  13547. @code{mod_proxy_fcgi} module along with @code{php-fpm-service-type}:
  13548. @example
  13549. (service httpd-service-type
  13550. (httpd-configuration
  13551. (config
  13552. (httpd-config-file
  13553. (modules (cons*
  13554. (httpd-module
  13555. (name "proxy_module")
  13556. (file "modules/mod_proxy.so"))
  13557. (httpd-module
  13558. (name "proxy_fcgi_module")
  13559. (file "modules/mod_proxy_fcgi.so"))
  13560. %default-httpd-modules))
  13561. (extra-config (list "\
  13562. <FilesMatch \\.php$>
  13563. SetHandler \"proxy:unix:/var/run/php-fpm.sock|fcgi://localhost/\"
  13564. </FilesMatch>"))))))
  13565. (service php-fpm-service-type
  13566. (php-fpm-configuration
  13567. (socket "/var/run/php-fpm.sock")
  13568. (socket-group "httpd")))
  13569. @end example
  13570. @item @code{server-root} (default: @code{httpd})
  13571. The @code{ServerRoot} in the configuration file, defaults to the httpd
  13572. package. Directives including @code{Include} and @code{LoadModule} are
  13573. taken as relative to the server root.
  13574. @item @code{server-name} (default: @code{#f})
  13575. The @code{ServerName} in the configuration file, used to specify the
  13576. request scheme, hostname and port that the server uses to identify
  13577. itself.
  13578. This doesn't need to be set in the server config, and can be specifyed
  13579. in virtual hosts. The default is @code{#f} to not specify a
  13580. @code{ServerName}.
  13581. @item @code{document-root} (default: @code{"/srv/http"})
  13582. The @code{DocumentRoot} from which files will be served.
  13583. @item @code{listen} (default: @code{'("80")})
  13584. The list of values for the @code{Listen} directives in the config
  13585. file. The value should be a list of strings, when each string can
  13586. specify the port number to listen on, and optionally the IP address and
  13587. protocol to use.
  13588. @item @code{pid-file} (default: @code{"/var/run/httpd"})
  13589. The @code{PidFile} to use. This should match the @code{pid-file} set in
  13590. the @code{httpd-configuration} so that the Shepherd service is
  13591. configured correctly.
  13592. @item @code{error-log} (default: @code{"/var/log/httpd/error_log"})
  13593. The @code{ErrorLog} to which the server will log errors.
  13594. @item @code{user} (default: @code{"httpd"})
  13595. The @code{User} which the server will answer requests as.
  13596. @item @code{group} (default: @code{"httpd"})
  13597. The @code{Group} which the server will answer requests as.
  13598. @item @code{extra-config} (default: @code{(list "TypesConfig etc/httpd/mime.types")})
  13599. A flat list of strings and G-expressions which will be added to the end
  13600. of the configuration file.
  13601. Any values which the service is extended with will be appended to this
  13602. list.
  13603. @end table
  13604. @end deffn
  13605. @deffn {Data Type} httpd-virtualhost
  13606. This data type represents a virtualhost configuration block for the httpd service.
  13607. These should be added to the extra-config for the httpd-service.
  13608. @example
  13609. (simple-service 'my-extra-server httpd-service-type
  13610. (list
  13611. (httpd-virtualhost
  13612. "*:80"
  13613. (list (string-append
  13614. "ServerName "www.example.com
  13615. DocumentRoot \"/srv/http/www.example.com\"")))))
  13616. @end example
  13617. @table @asis
  13618. @item @code{addresses-and-ports}
  13619. The addresses and ports for the @code{VirtualHost} directive.
  13620. @item @code{contents}
  13621. The contents of the @code{VirtualHost} directive, this should be a list
  13622. of strings and G-expressions.
  13623. @end table
  13624. @end deffn
  13625. @subsubheading NGINX
  13626. @deffn {Scheme Variable} nginx-service-type
  13627. Service type for the @uref{https://nginx.org/,NGinx} web server. The
  13628. value for this service type is a @code{<nginx-configuration>} record.
  13629. A simple example configuration is given below.
  13630. @example
  13631. (service nginx-service-type
  13632. (nginx-configuration
  13633. (server-blocks
  13634. (list (nginx-server-configuration
  13635. (server-name '("www.example.com"))
  13636. (root "/srv/http/www.example.com"))))))
  13637. @end example
  13638. In addition to adding server blocks to the service configuration
  13639. directly, this service can be extended by other services to add server
  13640. blocks, as in this example:
  13641. @example
  13642. (simple-service 'my-extra-server nginx-service-type
  13643. (list (nginx-server-configuration
  13644. (root "/srv/http/extra-website")
  13645. (try-files (list "$uri" "$uri/index.html")))))
  13646. @end example
  13647. @end deffn
  13648. At startup, @command{nginx} has not yet read its configuration file, so
  13649. it uses a default file to log error messages. If it fails to load its
  13650. configuration file, that is where error messages are logged. After the
  13651. configuration file is loaded, the default error log file changes as per
  13652. configuration. In our case, startup error messages can be found in
  13653. @file{/var/run/nginx/logs/error.log}, and after configuration in
  13654. @file{/var/log/nginx/error.log}. The second location can be changed
  13655. with the @var{log-directory} configuration option.
  13656. @deffn {Data Type} nginx-configuration
  13657. This data type represents the configuration for NGinx. Some
  13658. configuration can be done through this and the other provided record
  13659. types, or alternatively, a config file can be provided.
  13660. @table @asis
  13661. @item @code{nginx} (default: @code{nginx})
  13662. The nginx package to use.
  13663. @item @code{log-directory} (default: @code{"/var/log/nginx"})
  13664. The directory to which NGinx will write log files.
  13665. @item @code{run-directory} (default: @code{"/var/run/nginx"})
  13666. The directory in which NGinx will create a pid file, and write temporary
  13667. files.
  13668. @item @code{server-blocks} (default: @code{'()})
  13669. A list of @dfn{server blocks} to create in the generated configuration
  13670. file, the elements should be of type
  13671. @code{<nginx-server-configuration>}.
  13672. The following example would setup NGinx to serve @code{www.example.com}
  13673. from the @code{/srv/http/www.example.com} directory, without using
  13674. HTTPS.
  13675. @example
  13676. (service nginx-service-type
  13677. (nginx-configuration
  13678. (server-blocks
  13679. (list (nginx-server-configuration
  13680. (server-name '("www.example.com"))
  13681. (root "/srv/http/www.example.com"))))))
  13682. @end example
  13683. @item @code{upstream-blocks} (default: @code{'()})
  13684. A list of @dfn{upstream blocks} to create in the generated configuration
  13685. file, the elements should be of type
  13686. @code{<nginx-upstream-configuration>}.
  13687. Configuring upstreams through the @code{upstream-blocks} can be useful
  13688. when combined with @code{locations} in the
  13689. @code{<nginx-server-configuration>} records. The following example
  13690. creates a server configuration with one location configuration, that
  13691. will proxy requests to a upstream configuration, which will handle
  13692. requests with two servers.
  13693. @example
  13694. (service
  13695. nginx-service-type
  13696. (nginx-configuration
  13697. (server-blocks
  13698. (list (nginx-server-configuration
  13699. (server-name '("www.example.com"))
  13700. (root "/srv/http/www.example.com")
  13701. (locations
  13702. (list
  13703. (nginx-location-configuration
  13704. (uri "/path1")
  13705. (body '("proxy_pass http://server-proxy;"))))))))
  13706. (upstream-blocks
  13707. (list (nginx-upstream-configuration
  13708. (name "server-proxy")
  13709. (servers (list "server1.example.com"
  13710. "server2.example.com")))))))
  13711. @end example
  13712. @item @code{file} (default: @code{#f})
  13713. If a configuration @var{file} is provided, this will be used, rather than
  13714. generating a configuration file from the provided @code{log-directory},
  13715. @code{run-directory}, @code{server-blocks} and @code{upstream-blocks}. For
  13716. proper operation, these arguments should match what is in @var{file} to ensure
  13717. that the directories are created when the service is activated.
  13718. This can be useful if you have an existing configuration file, or it's
  13719. not possible to do what is required through the other parts of the
  13720. nginx-configuration record.
  13721. @item @code{server-names-hash-bucket-size} (default: @code{#f})
  13722. Bucket size for the server names hash tables, defaults to @code{#f} to
  13723. use the size of the processors cache line.
  13724. @item @code{server-names-hash-bucket-max-size} (default: @code{#f})
  13725. Maximum bucket size for the server names hash tables.
  13726. @item @code{extra-content} (default: @code{""})
  13727. Extra content for the @code{http} block. Should be string or a string
  13728. valued G-expression.
  13729. @end table
  13730. @end deffn
  13731. @deftp {Data Type} nginx-server-configuration
  13732. Data type representing the configuration of an nginx server block.
  13733. This type has the following parameters:
  13734. @table @asis
  13735. @item @code{listen} (default: @code{'("80" "443 ssl")})
  13736. Each @code{listen} directive sets the address and port for IP, or the
  13737. path for a UNIX-domain socket on which the server will accept requests.
  13738. Both address and port, or only address or only port can be specified.
  13739. An address may also be a hostname, for example:
  13740. @example
  13741. '("127.0.0.1:8000" "127.0.0.1" "8000" "*:8000" "localhost:8000")
  13742. @end example
  13743. @item @code{server-name} (default: @code{(list 'default)})
  13744. A list of server names this server represents. @code{'default} represents the
  13745. default server for connections matching no other server.
  13746. @item @code{root} (default: @code{"/srv/http"})
  13747. Root of the website nginx will serve.
  13748. @item @code{locations} (default: @code{'()})
  13749. A list of @dfn{nginx-location-configuration} or
  13750. @dfn{nginx-named-location-configuration} records to use within this
  13751. server block.
  13752. @item @code{index} (default: @code{(list "index.html")})
  13753. Index files to look for when clients ask for a directory. If it cannot be found,
  13754. Nginx will send the list of files in the directory.
  13755. @item @code{try-files} (default: @code{'()})
  13756. A list of files whose existence is checked in the specified order.
  13757. @code{nginx} will use the first file it finds to process the request.
  13758. @item @code{ssl-certificate} (default: @code{#f})
  13759. Where to find the certificate for secure connections. Set it to @code{#f} if
  13760. you don't have a certificate or you don't want to use HTTPS.
  13761. @item @code{ssl-certificate-key} (default: @code{#f})
  13762. Where to find the private key for secure connections. Set it to @code{#f} if
  13763. you don't have a key or you don't want to use HTTPS.
  13764. @item @code{server-tokens?} (default: @code{#f})
  13765. Whether the server should add its configuration to response.
  13766. @item @code{raw-content} (default: @code{'()})
  13767. A list of raw lines added to the server block.
  13768. @end table
  13769. @end deftp
  13770. @deftp {Data Type} nginx-upstream-configuration
  13771. Data type representing the configuration of an nginx @code{upstream}
  13772. block. This type has the following parameters:
  13773. @table @asis
  13774. @item @code{name}
  13775. Name for this group of servers.
  13776. @item @code{servers}
  13777. Specify the addresses of the servers in the group. The address can be
  13778. specified as a IP address (e.g.@: @samp{127.0.0.1}), domain name
  13779. (e.g.@: @samp{backend1.example.com}) or a path to a UNIX socket using the
  13780. prefix @samp{unix:}. For addresses using an IP address or domain name,
  13781. the default port is 80, and a different port can be specified
  13782. explicitly.
  13783. @end table
  13784. @end deftp
  13785. @deftp {Data Type} nginx-location-configuration
  13786. Data type representing the configuration of an nginx @code{location}
  13787. block. This type has the following parameters:
  13788. @table @asis
  13789. @item @code{uri}
  13790. URI which this location block matches.
  13791. @anchor{nginx-location-configuration body}
  13792. @item @code{body}
  13793. Body of the location block, specified as a list of strings. This can contain
  13794. many
  13795. configuration directives. For example, to pass requests to a upstream
  13796. server group defined using an @code{nginx-upstream-configuration} block,
  13797. the following directive would be specified in the body @samp{(list "proxy_pass
  13798. http://upstream-name;")}.
  13799. @end table
  13800. @end deftp
  13801. @deftp {Data Type} nginx-named-location-configuration
  13802. Data type representing the configuration of an nginx named location
  13803. block. Named location blocks are used for request redirection, and not
  13804. used for regular request processing. This type has the following
  13805. parameters:
  13806. @table @asis
  13807. @item @code{name}
  13808. Name to identify this location block.
  13809. @item @code{body}
  13810. @xref{nginx-location-configuration body}, as the body for named location
  13811. blocks can be used in a similar way to the
  13812. @code{nginx-location-configuration body}. One restriction is that the
  13813. body of a named location block cannot contain location blocks.
  13814. @end table
  13815. @end deftp
  13816. @subsubheading Varnish Cache
  13817. @cindex Varnish
  13818. Varnish is a fast cache server that sits in between web applications
  13819. and end users. It proxies requests from clients and caches the
  13820. accessed URLs such that multiple requests for the same resource only
  13821. creates one request to the back-end.
  13822. @defvr {Scheme Variable} varnish-service-type
  13823. Service type for the Varnish daemon.
  13824. @end defvr
  13825. @deftp {Data Type} varnish-configuration
  13826. Data type representing the @code{varnish} service configuration.
  13827. This type has the following parameters:
  13828. @table @asis
  13829. @item @code{package} (default: @code{varnish})
  13830. The Varnish package to use.
  13831. @item @code{name} (default: @code{"default"})
  13832. A name for this Varnish instance. Varnish will create a directory in
  13833. @file{/var/varnish/} with this name and keep temporary files there. If
  13834. the name starts with a forward slash, it is interpreted as an absolute
  13835. directory name.
  13836. Pass the @code{-n} argument to other Varnish programs to connect to the
  13837. named instance, e.g.@: @command{varnishncsa -n default}.
  13838. @item @code{backend} (default: @code{"localhost:8080"})
  13839. The backend to use. This option has no effect if @code{vcl} is set.
  13840. @item @code{vcl} (default: #f)
  13841. The @dfn{VCL} (Varnish Configuration Language) program to run. If this
  13842. is @code{#f}, Varnish will proxy @code{backend} using the default
  13843. configuration. Otherwise this must be a file-like object with valid
  13844. VCL syntax.
  13845. @c Varnish does not support HTTPS, so keep this URL to avoid confusion.
  13846. For example, to mirror @url{http://www.gnu.org,www.gnu.org} with VCL you
  13847. can do something along these lines:
  13848. @example
  13849. (define %gnu-mirror
  13850. (plain-file
  13851. "gnu.vcl"
  13852. "vcl 4.1;
  13853. backend gnu @{ .host = "www.gnu.org"; @}"))
  13854. (operating-system
  13855. ...
  13856. (services (cons (service varnish-service-type
  13857. (varnish-configuration
  13858. (listen '(":80"))
  13859. (vcl %gnu-mirror)))
  13860. %base-services)))
  13861. @end example
  13862. The configuration of an already running Varnish instance can be inspected
  13863. and changed using the @command{varnishadm} program.
  13864. Consult the @url{https://varnish-cache.org/docs/,Varnish User Guide} and
  13865. @url{https://book.varnish-software.com/4.0/,Varnish Book} for
  13866. comprehensive documentation on Varnish and its configuration language.
  13867. @item @code{listen} (default: @code{'("localhost:80")})
  13868. List of addresses Varnish will listen on.
  13869. @item @code{storage} (default: @code{'("malloc,128m")})
  13870. List of storage backends that will be available in VCL.
  13871. @item @code{parameters} (default: @code{'()})
  13872. List of run-time parameters in the form @code{'(("parameter" . "value"))}.
  13873. @item @code{extra-options} (default: @code{'()})
  13874. Additional arguments to pass to the @command{varnishd} process.
  13875. @end table
  13876. @end deftp
  13877. @subsubheading FastCGI
  13878. @cindex fastcgi
  13879. @cindex fcgiwrap
  13880. FastCGI is an interface between the front-end and the back-end of a web
  13881. service. It is a somewhat legacy facility; new web services should
  13882. generally just talk HTTP between the front-end and the back-end.
  13883. However there are a number of back-end services such as PHP or the
  13884. optimized HTTP Git repository access that use FastCGI, so we have
  13885. support for it in Guix.
  13886. To use FastCGI, you configure the front-end web server (e.g., nginx) to
  13887. dispatch some subset of its requests to the fastcgi backend, which
  13888. listens on a local TCP or UNIX socket. There is an intermediary
  13889. @code{fcgiwrap} program that sits between the actual backend process and
  13890. the web server. The front-end indicates which backend program to run,
  13891. passing that information to the @code{fcgiwrap} process.
  13892. @defvr {Scheme Variable} fcgiwrap-service-type
  13893. A service type for the @code{fcgiwrap} FastCGI proxy.
  13894. @end defvr
  13895. @deftp {Data Type} fcgiwrap-configuration
  13896. Data type representing the configuration of the @code{fcgiwrap} serice.
  13897. This type has the following parameters:
  13898. @table @asis
  13899. @item @code{package} (default: @code{fcgiwrap})
  13900. The fcgiwrap package to use.
  13901. @item @code{socket} (default: @code{tcp:127.0.0.1:9000})
  13902. The socket on which the @code{fcgiwrap} process should listen, as a
  13903. string. Valid @var{socket} values include
  13904. @code{unix:@var{/path/to/unix/socket}},
  13905. @code{tcp:@var{dot.ted.qu.ad}:@var{port}} and
  13906. @code{tcp6:[@var{ipv6_addr}]:port}.
  13907. @item @code{user} (default: @code{fcgiwrap})
  13908. @itemx @code{group} (default: @code{fcgiwrap})
  13909. The user and group names, as strings, under which to run the
  13910. @code{fcgiwrap} process. The @code{fastcgi} service will ensure that if
  13911. the user asks for the specific user or group names @code{fcgiwrap} that
  13912. the corresponding user and/or group is present on the system.
  13913. It is possible to configure a FastCGI-backed web service to pass HTTP
  13914. authentication information from the front-end to the back-end, and to
  13915. allow @code{fcgiwrap} to run the back-end process as a corresponding
  13916. local user. To enable this capability on the back-end., run
  13917. @code{fcgiwrap} as the @code{root} user and group. Note that this
  13918. capability also has to be configured on the front-end as well.
  13919. @end table
  13920. @end deftp
  13921. @cindex php-fpm
  13922. PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation
  13923. with some additional features useful for sites of any size.
  13924. These features include:
  13925. @itemize @bullet
  13926. @item Adaptive process spawning
  13927. @item Basic statistics (similar to Apache's mod_status)
  13928. @item Advanced process management with graceful stop/start
  13929. @item Ability to start workers with different uid/gid/chroot/environment
  13930. and different php.ini (replaces safe_mode)
  13931. @item Stdout & stderr logging
  13932. @item Emergency restart in case of accidental opcode cache destruction
  13933. @item Accelerated upload support
  13934. @item Support for a "slowlog"
  13935. @item Enhancements to FastCGI, such as fastcgi_finish_request() -
  13936. a special function to finish request & flush all data while continuing to do
  13937. something time-consuming (video converting, stats processing, etc.)
  13938. @end itemize
  13939. ...@: and much more.
  13940. @defvr {Scheme Variable} php-fpm-service-type
  13941. A Service type for @code{php-fpm}.
  13942. @end defvr
  13943. @deftp {Data Type} php-fpm-configuration
  13944. Data Type for php-fpm service configuration.
  13945. @table @asis
  13946. @item @code{php} (default: @code{php})
  13947. The php package to use.
  13948. @item @code{socket} (default: @code{(string-append "/var/run/php" (version-major (package-version php)) "-fpm.sock")})
  13949. The address on which to accept FastCGI requests. Valid syntaxes are:
  13950. @table @asis
  13951. @item @code{"ip.add.re.ss:port"}
  13952. Listen on a TCP socket to a specific address on a specific port.
  13953. @item @code{"port"}
  13954. Listen on a TCP socket to all addresses on a specific port.
  13955. @item @code{"/path/to/unix/socket"}
  13956. Listen on a unix socket.
  13957. @end table
  13958. @item @code{user} (default: @code{php-fpm})
  13959. User who will own the php worker processes.
  13960. @item @code{group} (default: @code{php-fpm})
  13961. Group of the worker processes.
  13962. @item @code{socket-user} (default: @code{php-fpm})
  13963. User who can speak to the php-fpm socket.
  13964. @item @code{socket-group} (default: @code{php-fpm})
  13965. Group that can speak to the php-fpm socket.
  13966. @item @code{pid-file} (default: @code{(string-append "/var/run/php" (version-major (package-version php)) "-fpm.pid")})
  13967. The process id of the php-fpm process is written to this file
  13968. once the service has started.
  13969. @item @code{log-file} (default: @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.log")})
  13970. Log for the php-fpm master process.
  13971. @item @code{process-manager} (default: @code{(php-fpm-dynamic-process-manager-configuration)})
  13972. Detailed settings for the php-fpm process manager.
  13973. Must be either:
  13974. @table @asis
  13975. @item @code{<php-fpm-dynamic-process-manager-configuration>}
  13976. @item @code{<php-fpm-static-process-manager-configuration>}
  13977. @item @code{<php-fpm-on-demand-process-manager-configuration>}
  13978. @end table
  13979. @item @code{display-errors} (default @code{#f})
  13980. Determines whether php errors and warning should be sent to clients
  13981. and displayed in their browsers.
  13982. This is useful for local php development, but a security risk for public sites,
  13983. as error messages can reveal passwords and personal data.
  13984. @item @code{workers-logfile} (default @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.www.log")})
  13985. This file will log the @code{stderr} outputs of php worker processes.
  13986. Can be set to @code{#f} to disable logging.
  13987. @item @code{file} (default @code{#f})
  13988. An optional override of the whole configuration.
  13989. You can use the @code{mixed-text-file} function or an absolute filepath for it.
  13990. @end table
  13991. @end deftp
  13992. @deftp {Data type} php-fpm-dynamic-process-manager-configuration
  13993. Data Type for the @code{dynamic} php-fpm process manager. With the
  13994. @code{dynamic} process manager, spare worker processes are kept around
  13995. based on it's configured limits.
  13996. @table @asis
  13997. @item @code{max-children} (default: @code{5})
  13998. Maximum of worker processes.
  13999. @item @code{start-servers} (default: @code{2})
  14000. How many worker processes should be started on start-up.
  14001. @item @code{min-spare-servers} (default: @code{1})
  14002. How many spare worker processes should be kept around at minimum.
  14003. @item @code{max-spare-servers} (default: @code{3})
  14004. How many spare worker processes should be kept around at maximum.
  14005. @end table
  14006. @end deftp
  14007. @deftp {Data type} php-fpm-static-process-manager-configuration
  14008. Data Type for the @code{static} php-fpm process manager. With the
  14009. @code{static} process manager, an unchanging number of worker processes
  14010. are created.
  14011. @table @asis
  14012. @item @code{max-children} (default: @code{5})
  14013. Maximum of worker processes.
  14014. @end table
  14015. @end deftp
  14016. @deftp {Data type} php-fpm-on-demand-process-manager-configuration
  14017. Data Type for the @code{on-demand} php-fpm process manager. With the
  14018. @code{on-demand} process manager, worker processes are only created as
  14019. requests arrive.
  14020. @table @asis
  14021. @item @code{max-children} (default: @code{5})
  14022. Maximum of worker processes.
  14023. @item @code{process-idle-timeout} (default: @code{10})
  14024. The time in seconds after which a process with no requests is killed.
  14025. @end table
  14026. @end deftp
  14027. @deffn {Scheme Procedure} nginx-php-fpm-location @
  14028. [#:nginx-package nginx] @
  14029. [socket (string-append "/var/run/php" @
  14030. (version-major (package-version php)) @
  14031. "-fpm.sock")]
  14032. A helper function to quickly add php to an @code{nginx-server-configuration}.
  14033. @end deffn
  14034. A simple services setup for nginx with php can look like this:
  14035. @example
  14036. (services (cons* (service dhcp-client-service-type)
  14037. (service php-fpm-service-type)
  14038. (service nginx-service-type
  14039. (nginx-server-configuration
  14040. (server-name '("example.com"))
  14041. (root "/srv/http/")
  14042. (locations
  14043. (list (nginx-php-location)))
  14044. (https-port #f)
  14045. (ssl-certificate #f)
  14046. (ssl-certificate-key #f)))
  14047. %base-services))
  14048. @end example
  14049. @cindex cat-avatar-generator
  14050. The cat avatar generator is a simple service to demonstrate the use of php-fpm
  14051. in @code{Nginx}. It is used to generate cat avatar from a seed, for instance
  14052. the hash of a user's email address.
  14053. @deffn {Scheme Procedure} cat-avatar-generator-serice @
  14054. [#:cache-dir "/var/cache/cat-avatar-generator"] @
  14055. [#:package cat-avatar-generator] @
  14056. [#:configuration (nginx-server-configuration)]
  14057. Returns an nginx-server-configuration that inherits @code{configuration}. It
  14058. extends the nginx configuration to add a server block that serves @code{package},
  14059. a version of cat-avatar-generator. During execution, cat-avatar-generator will
  14060. be able to use @code{cache-dir} as its cache directory.
  14061. @end deffn
  14062. A simple setup for cat-avatar-generator can look like this:
  14063. @example
  14064. (services (cons* (cat-avatar-generator-service
  14065. #:configuration
  14066. (nginx-server-configuration
  14067. (server-name '("example.com"))))
  14068. ...
  14069. %base-services))
  14070. @end example
  14071. @subsubheading Hpcguix-web
  14072. @cindex hpcguix-web
  14073. The @uref{hpcguix-web, https://github.com/UMCUGenetics/hpcguix-web/}
  14074. program is a customizable web interface to browse Guix packages,
  14075. initially designed for users of high-performance computing (HPC)
  14076. clusters.
  14077. @defvr {Scheme Variable} hpcguix-web-service-type
  14078. The service type for @code{hpcguix-web}.
  14079. @end defvr
  14080. @deftp {Data Type} hpcguix-web-configuration
  14081. Data type for the hpcguix-web service configuration.
  14082. @table @asis
  14083. @item @code{specs}
  14084. A gexp (@pxref{G-Expressions}) specifying the hpcguix-web service
  14085. configuration. The main items available in this spec are:
  14086. @table @asis
  14087. @item @code{title-prefix} (default: @code{"hpcguix | "})
  14088. The page title prefix.
  14089. @item @code{guix-command} (default: @code{"guix"})
  14090. The @command{guix} command.
  14091. @item @code{package-filter-proc} (default: @code{(const #t)})
  14092. A procedure specifying how to filter packages that are displayed.
  14093. @item @code{package-page-extension-proc} (default: @code{(const '())})
  14094. Extension package for @code{hpcguix-web}.
  14095. @item @code{menu} (default: @code{'()})
  14096. Additional entry in page @code{menu}.
  14097. @item @code{channels} (default: @code{%default-channels})
  14098. List of channels from which the package list is built (@pxref{Channels}).
  14099. @item @code{package-list-expiration} (default: @code{(* 12 3600)})
  14100. The expiration time, in seconds, after which the package list is rebuilt from
  14101. the latest instances of the given channels.
  14102. @end table
  14103. See the hpcguix-web repository for a
  14104. @uref{https://github.com/UMCUGenetics/hpcguix-web/blob/master/hpcweb-configuration.scm,
  14105. complete example}.
  14106. @item @code{package} (default: @code{hpcguix-web})
  14107. The hpcguix-web package to use.
  14108. @end table
  14109. @end deftp
  14110. A typical hpcguix-web service declaration looks like this:
  14111. @example
  14112. (service hpcguix-web-service-type
  14113. (hpcguix-web-configuration
  14114. (specs
  14115. #~(define site-config
  14116. (hpcweb-configuration
  14117. (title-prefix "Guix-HPC - ")
  14118. (menu '(("/about" "ABOUT"))))))))
  14119. @end example
  14120. @quotation Note
  14121. The hpcguix-web service periodically updates the package list it publishes by
  14122. pulling channels from Git. To that end, it needs to access X.509 certificates
  14123. so that it can authenticate Git servers when communicating over HTTPS, and it
  14124. assumes that @file{/etc/ssl/certs} contains those certificates.
  14125. Thus, make sure to add @code{nss-certs} or another certificate package to the
  14126. @code{packages} field of your configuration. @ref{X.509 Certificates}, for
  14127. more information on X.509 certificates.
  14128. @end quotation
  14129. @node Certificate Services
  14130. @subsubsection Certificate Services
  14131. @cindex Web
  14132. @cindex HTTP, HTTPS
  14133. @cindex Let's Encrypt
  14134. @cindex TLS certificates
  14135. The @code{(gnu services certbot)} module provides a service to
  14136. automatically obtain a valid TLS certificate from the Let's Encrypt
  14137. certificate authority. These certificates can then be used to serve
  14138. content securely over HTTPS or other TLS-based protocols, with the
  14139. knowledge that the client will be able to verify the server's
  14140. authenticity.
  14141. @url{https://letsencrypt.org/, Let's Encrypt} provides the
  14142. @code{certbot} tool to automate the certification process. This tool
  14143. first securely generates a key on the server. It then makes a request
  14144. to the Let's Encrypt certificate authority (CA) to sign the key. The CA
  14145. checks that the request originates from the host in question by using a
  14146. challenge-response protocol, requiring the server to provide its
  14147. response over HTTP. If that protocol completes successfully, the CA
  14148. signs the key, resulting in a certificate. That certificate is valid
  14149. for a limited period of time, and therefore to continue to provide TLS
  14150. services, the server needs to periodically ask the CA to renew its
  14151. signature.
  14152. The certbot service automates this process: the initial key
  14153. generation, the initial certification request to the Let's Encrypt
  14154. service, the web server challenge/response integration, writing the
  14155. certificate to disk, the automated periodic renewals, and the deployment
  14156. tasks associated with the renewal (e.g.@: reloading services, copying keys
  14157. with different permissions).
  14158. Certbot is run twice a day, at a random minute within the hour. It
  14159. won't do anything until your certificates are due for renewal or
  14160. revoked, but running it regularly would give your service a chance of
  14161. staying online in case a Let's Encrypt-initiated revocation happened for
  14162. some reason.
  14163. By using this service, you agree to the ACME Subscriber Agreement, which
  14164. can be found there:
  14165. @url{https://acme-v01.api.letsencrypt.org/directory}.
  14166. @defvr {Scheme Variable} certbot-service-type
  14167. A service type for the @code{certbot} Let's Encrypt client. Its value
  14168. must be a @code{certbot-configuration} record as in this example:
  14169. @example
  14170. (define %nginx-deploy-hook
  14171. (program-file
  14172. "nginx-deploy-hook"
  14173. #~(let ((pid (call-with-input-file "/var/run/nginx/pid" read)))
  14174. (kill pid SIGHUP))))
  14175. (service certbot-service-type
  14176. (certbot-configuration
  14177. (email "foo@@example.net")
  14178. (certificates
  14179. (list
  14180. (certificate-configuration
  14181. (domains '("example.net" "www.example.net"))
  14182. (deploy-hook %nginx-deploy-hook))
  14183. (certificate-configuration
  14184. (domains '("bar.example.net")))))))
  14185. @end example
  14186. See below for details about @code{certbot-configuration}.
  14187. @end defvr
  14188. @deftp {Data Type} certbot-configuration
  14189. Data type representing the configuration of the @code{certbot} service.
  14190. This type has the following parameters:
  14191. @table @asis
  14192. @item @code{package} (default: @code{certbot})
  14193. The certbot package to use.
  14194. @item @code{webroot} (default: @code{/var/www})
  14195. The directory from which to serve the Let's Encrypt challenge/response
  14196. files.
  14197. @item @code{certificates} (default: @code{()})
  14198. A list of @code{certificates-configuration}s for which to generate
  14199. certificates and request signatures. Each certificate has a @code{name}
  14200. and several @code{domains}.
  14201. @item @code{email}
  14202. Mandatory email used for registration, recovery contact, and important
  14203. account notifications.
  14204. @item @code{rsa-key-size} (default: @code{2048})
  14205. Size of the RSA key.
  14206. @item @code{default-location} (default: @i{see below})
  14207. The default @code{nginx-location-configuration}. Because @code{certbot}
  14208. needs to be able to serve challenges and responses, it needs to be able
  14209. to run a web server. It does so by extending the @code{nginx} web
  14210. service with an @code{nginx-server-configuration} listening on the
  14211. @var{domains} on port 80, and which has a
  14212. @code{nginx-location-configuration} for the @code{/.well-known/} URI
  14213. path subspace used by Let's Encrypt. @xref{Web Services}, for more on
  14214. these nginx configuration data types.
  14215. Requests to other URL paths will be matched by the
  14216. @code{default-location}, which if present is added to all
  14217. @code{nginx-server-configuration}s.
  14218. By default, the @code{default-location} will issue a redirect from
  14219. @code{http://@var{domain}/...} to @code{https://@var{domain}/...}, leaving
  14220. you to define what to serve on your site via @code{https}.
  14221. Pass @code{#f} to not issue a default location.
  14222. @end table
  14223. @end deftp
  14224. @deftp {Data Type} certificate-configuration
  14225. Data type representing the configuration of a certificate.
  14226. This type has the following parameters:
  14227. @table @asis
  14228. @item @code{name} (default: @i{see below})
  14229. This name is used by Certbot for housekeeping and in file paths; it
  14230. doesn't affect the content of the certificate itself. To see
  14231. certificate names, run @code{certbot certificates}.
  14232. Its default is the first provided domain.
  14233. @item @code{domains} (default: @code{()})
  14234. The first domain provided will be the subject CN of the certificate, and
  14235. all domains will be Subject Alternative Names on the certificate.
  14236. @item @code{deploy-hook} (default: @code{#f})
  14237. Command to be run in a shell once for each successfully issued
  14238. certificate. For this command, the shell variable
  14239. @code{$RENEWED_LINEAGE} will point to the config live subdirectory (for
  14240. example, @samp{"/etc/letsencrypt/live/example.com"}) containing the new
  14241. certificates and keys; the shell variable @code{$RENEWED_DOMAINS} will
  14242. contain a space-delimited list of renewed certificate domains (for
  14243. example, @samp{"example.com www.example.com"}.
  14244. @end table
  14245. @end deftp
  14246. For each @code{certificate-configuration}, the certificate is saved to
  14247. @code{/etc/letsencrypt/live/@var{name}/fullchain.pem} and the key is
  14248. saved to @code{/etc/letsencrypt/live/@var{name}/privkey.pem}.
  14249. @node DNS Services
  14250. @subsubsection DNS Services
  14251. @cindex DNS (domain name system)
  14252. @cindex domain name system (DNS)
  14253. The @code{(gnu services dns)} module provides services related to the
  14254. @dfn{domain name system} (DNS). It provides a server service for hosting
  14255. an @emph{authoritative} DNS server for multiple zones, slave or master.
  14256. This service uses @uref{https://www.knot-dns.cz/, Knot DNS}. And also a
  14257. caching and forwarding DNS server for the LAN, which uses
  14258. @uref{http://www.thekelleys.org.uk/dnsmasq/doc.html, dnsmasq}.
  14259. @subsubheading Knot Service
  14260. An example configuration of an authoritative server for two zones, one master
  14261. and one slave, is:
  14262. @lisp
  14263. (define-zone-entries example.org.zone
  14264. ;; Name TTL Class Type Data
  14265. ("@@" "" "IN" "A" "127.0.0.1")
  14266. ("@@" "" "IN" "NS" "ns")
  14267. ("ns" "" "IN" "A" "127.0.0.1"))
  14268. (define master-zone
  14269. (knot-zone-configuration
  14270. (domain "example.org")
  14271. (zone (zone-file
  14272. (origin "example.org")
  14273. (entries example.org.zone)))))
  14274. (define slave-zone
  14275. (knot-zone-configuration
  14276. (domain "plop.org")
  14277. (dnssec-policy "default")
  14278. (master (list "plop-master"))))
  14279. (define plop-master
  14280. (knot-remote-configuration
  14281. (id "plop-master")
  14282. (address (list "208.76.58.171"))))
  14283. (operating-system
  14284. ;; ...
  14285. (services (cons* (service knot-service-type
  14286. (knot-configuration
  14287. (remotes (list plop-master))
  14288. (zones (list master-zone slave-zone))))
  14289. ;; ...
  14290. %base-services)))
  14291. @end lisp
  14292. @deffn {Scheme Variable} knot-service-type
  14293. This is the type for the Knot DNS server.
  14294. Knot DNS is an authoritative DNS server, meaning that it can serve multiple
  14295. zones, that is to say domain names you would buy from a registrar. This server
  14296. is not a resolver, meaning that it can only resolve names for which it is
  14297. authoritative. This server can be configured to serve zones as a master server
  14298. or a slave server as a per-zone basis. Slave zones will get their data from
  14299. masters, and will serve it as an authoritative server. From the point of view
  14300. of a resolver, there is no difference between master and slave.
  14301. The following data types are used to configure the Knot DNS server:
  14302. @end deffn
  14303. @deftp {Data Type} knot-key-configuration
  14304. Data type representing a key.
  14305. This type has the following parameters:
  14306. @table @asis
  14307. @item @code{id} (default: @code{""})
  14308. An identifier for other configuration fields to refer to this key. IDs must
  14309. be unique and must not be empty.
  14310. @item @code{algorithm} (default: @code{#f})
  14311. The algorithm to use. Choose between @code{#f}, @code{'hmac-md5},
  14312. @code{'hmac-sha1}, @code{'hmac-sha224}, @code{'hmac-sha256}, @code{'hmac-sha384}
  14313. and @code{'hmac-sha512}.
  14314. @item @code{secret} (default: @code{""})
  14315. The secret key itself.
  14316. @end table
  14317. @end deftp
  14318. @deftp {Data Type} knot-acl-configuration
  14319. Data type representing an Access Control List (ACL) configuration.
  14320. This type has the following parameters:
  14321. @table @asis
  14322. @item @code{id} (default: @code{""})
  14323. An identifier for ether configuration fields to refer to this key. IDs must be
  14324. unique and must not be empty.
  14325. @item @code{address} (default: @code{'()})
  14326. An ordered list of IP addresses, network subnets, or network ranges represented
  14327. with strings. The query must match one of them. Empty value means that
  14328. address match is not required.
  14329. @item @code{key} (default: @code{'()})
  14330. An ordered list of references to keys represented with strings. The string
  14331. must match a key ID defined in a @code{knot-key-configuration}. No key means
  14332. that a key is not require to match that ACL.
  14333. @item @code{action} (default: @code{'()})
  14334. An ordered list of actions that are permitted or forbidden by this ACL. Possible
  14335. values are lists of zero or more elements from @code{'transfer}, @code{'notify}
  14336. and @code{'update}.
  14337. @item @code{deny?} (default: @code{#f})
  14338. When true, the ACL defines restrictions. Listed actions are forbidden. When
  14339. false, listed actions are allowed.
  14340. @end table
  14341. @end deftp
  14342. @deftp {Data Type} zone-entry
  14343. Data type represnting a record entry in a zone file.
  14344. This type has the following parameters:
  14345. @table @asis
  14346. @item @code{name} (default: @code{"@@"})
  14347. The name of the record. @code{"@@"} refers to the origin of the zone. Names
  14348. are relative to the origin of the zone. For example, in the @code{example.org}
  14349. zone, @code{"ns.example.org"} actually refers to @code{ns.example.org.example.org}.
  14350. Names ending with a dot are absolute, which means that @code{"ns.example.org."}
  14351. refers to @code{ns.example.org}.
  14352. @item @code{ttl} (default: @code{""})
  14353. The Time-To-Live (TTL) of this record. If not set, the default TTL is used.
  14354. @item @code{class} (default: @code{"IN"})
  14355. The class of the record. Knot currently supports only @code{"IN"} and
  14356. partially @code{"CH"}.
  14357. @item @code{type} (default: @code{"A"})
  14358. The type of the record. Common types include A (IPv4 address), AAAA (IPv6
  14359. address), NS (Name Server) and MX (Mail eXchange). Many other types are
  14360. defined.
  14361. @item @code{data} (default: @code{""})
  14362. The data contained in the record. For instance an IP address associated with
  14363. an A record, or a domain name associated with an NS record. Remember that
  14364. domain names are relative to the origin unless they end with a dot.
  14365. @end table
  14366. @end deftp
  14367. @deftp {Data Type} zone-file
  14368. Data type representing the content of a zone file.
  14369. This type has the following parameters:
  14370. @table @asis
  14371. @item @code{entries} (default: @code{'()})
  14372. The list of entries. The SOA record is taken care of, so you don't need to
  14373. put it in the list of entries. This list should probably contain an entry
  14374. for your primary authoritative DNS server. Other than using a list of entries
  14375. directly, you can use @code{define-zone-entries} to define a object containing
  14376. the list of entries more easily, that you can later pass to the @code{entries}
  14377. field of the @code{zone-file}.
  14378. @item @code{origin} (default: @code{""})
  14379. The name of your zone. This parameter cannot be empty.
  14380. @item @code{ns} (default: @code{"ns"})
  14381. The domain of your primary authoritative DNS server. The name is relative to
  14382. the origin, unless it ends with a dot. It is mandatory that this primary
  14383. DNS server corresponds to an NS record in the zone and that it is associated
  14384. to an IP address in the list of entries.
  14385. @item @code{mail} (default: @code{"hostmaster"})
  14386. An email address people can contact you at, as the owner of the zone. This
  14387. is translated as @code{<mail>@@<origin>}.
  14388. @item @code{serial} (default: @code{1})
  14389. The serial number of the zone. As this is used to keep track of changes by
  14390. both slaves and resolvers, it is mandatory that it @emph{never} decreases.
  14391. Always increment it when you make a change in your zone.
  14392. @item @code{refresh} (default: @code{(* 2 24 3600)})
  14393. The frequency at which slaves will do a zone transfer. This value is a number
  14394. of seconds. It can be computed by multiplications or with
  14395. @code{(string->duration)}.
  14396. @item @code{retry} (default: @code{(* 15 60)})
  14397. The period after which a slave will retry to contact its master when it fails
  14398. to do so a first time.
  14399. @item @code{expiry} (default: @code{(* 14 24 3600)})
  14400. Default TTL of records. Existing records are considered correct for at most
  14401. this amount of time. After this period, resolvers will invalidate their cache
  14402. and check again that it still exists.
  14403. @item @code{nx} (default: @code{3600})
  14404. Default TTL of inexistant records. This delay is usually short because you want
  14405. your new domains to reach everyone quickly.
  14406. @end table
  14407. @end deftp
  14408. @deftp {Data Type} knot-remote-configuration
  14409. Data type representing a remote configuration.
  14410. This type has the following parameters:
  14411. @table @asis
  14412. @item @code{id} (default: @code{""})
  14413. An identifier for other configuration fields to refer to this remote. IDs must
  14414. be unique and must not be empty.
  14415. @item @code{address} (default: @code{'()})
  14416. An ordered list of destination IP addresses. Addresses are tried in sequence.
  14417. An optional port can be given with the @@ separator. For instance:
  14418. @code{(list "1.2.3.4" "2.3.4.5@@53")}. Default port is 53.
  14419. @item @code{via} (default: @code{'()})
  14420. An ordered list of source IP addresses. An empty list will have Knot choose
  14421. an appropriate source IP. An optional port can be given with the @@ separator.
  14422. The default is to choose at random.
  14423. @item @code{key} (default: @code{#f})
  14424. A reference to a key, that is a string containing the identifier of a key
  14425. defined in a @code{knot-key-configuration} field.
  14426. @end table
  14427. @end deftp
  14428. @deftp {Data Type} knot-keystore-configuration
  14429. Data type representing a keystore to hold dnssec keys.
  14430. This type has the following parameters:
  14431. @table @asis
  14432. @item @code{id} (default: @code{""})
  14433. The id of the keystore. It must not be empty.
  14434. @item @code{backend} (default: @code{'pem})
  14435. The backend to store the keys in. Can be @code{'pem} or @code{'pkcs11}.
  14436. @item @code{config} (default: @code{"/var/lib/knot/keys/keys"})
  14437. The configuration string of the backend. An example for the PKCS#11 is:
  14438. @code{"pkcs11:token=knot;pin-value=1234 /gnu/store/.../lib/pkcs11/libsofthsm2.so"}.
  14439. For the pem backend, the string reprensents a path in the file system.
  14440. @end table
  14441. @end deftp
  14442. @deftp {Data Type} knot-policy-configuration
  14443. Data type representing a dnssec policy. Knot DNS is able to automatically
  14444. sign your zones. It can either generate and manage your keys automatically or
  14445. use keys that you generate.
  14446. Dnssec is usually implemented using two keys: a Key Signing Key (KSK) that is
  14447. used to sign the second, and a Zone Signing Key (ZSK) that is used to sign the
  14448. zone. In order to be trusted, the KSK needs to be present in the parent zone
  14449. (usually a top-level domain). If your registrar supports dnssec, you will
  14450. have to send them your KSK's hash so they can add a DS record in their zone.
  14451. This is not automated and need to be done each time you change your KSK.
  14452. The policy also defines the lifetime of keys. Usually, ZSK can be changed
  14453. easily and use weaker cryptographic functions (they use lower parameters) in
  14454. order to sign records quickly, so they are changed often. The KSK however
  14455. requires manual interaction with the registrar, so they are changed less often
  14456. and use stronger parameters because they sign only one record.
  14457. This type has the following parameters:
  14458. @table @asis
  14459. @item @code{id} (default: @code{""})
  14460. The id of the policy. It must not be empty.
  14461. @item @code{keystore} (default: @code{"default"})
  14462. A reference to a keystore, that is a string containing the identifier of a
  14463. keystore defined in a @code{knot-keystore-configuration} field. The
  14464. @code{"default"} identifier means the default keystore (a kasp database that
  14465. was setup by this service).
  14466. @item @code{manual?} (default: @code{#f})
  14467. Whether the key management is manual or automatic.
  14468. @item @code{single-type-signing?} (default: @code{#f})
  14469. When @code{#t}, use the Single-Type Signing Scheme.
  14470. @item @code{algorithm} (default: @code{"ecdsap256sha256"})
  14471. An algorithm of signing keys and issued signatures.
  14472. @item @code{ksk-size} (default: @code{256})
  14473. The length of the KSK. Note that this value is correct for the default
  14474. algorithm, but would be unsecure for other algorithms.
  14475. @item @code{zsk-size} (default: @code{256})
  14476. The length of the ZSK. Note that this value is correct for the default
  14477. algorithm, but would be unsecure for other algorithms.
  14478. @item @code{dnskey-ttl} (default: @code{'default})
  14479. The TTL value for DNSKEY records added into zone apex. The special
  14480. @code{'default} value means same as the zone SOA TTL.
  14481. @item @code{zsk-lifetime} (default: @code{(* 30 24 3600)})
  14482. The period between ZSK publication and the next rollover initiation.
  14483. @item @code{propagation-delay} (default: @code{(* 24 3600)})
  14484. An extra delay added for each key rollover step. This value should be high
  14485. enough to cover propagation of data from the master server to all slaves.
  14486. @item @code{rrsig-lifetime} (default: @code{(* 14 24 3600)})
  14487. A validity period of newly issued signatures.
  14488. @item @code{rrsig-refresh} (default: @code{(* 7 24 3600)})
  14489. A period how long before a signature expiration the signature will be refreshed.
  14490. @item @code{nsec3?} (default: @code{#f})
  14491. When @code{#t}, NSEC3 will be used instead of NSEC.
  14492. @item @code{nsec3-iterations} (default: @code{5})
  14493. The number of additional times the hashing is performed.
  14494. @item @code{nsec3-salt-length} (default: @code{8})
  14495. The length of a salt field in octets, which is appended to the original owner
  14496. name before hashing.
  14497. @item @code{nsec3-salt-lifetime} (default: @code{(* 30 24 3600)})
  14498. The validity period of newly issued salt field.
  14499. @end table
  14500. @end deftp
  14501. @deftp {Data Type} knot-zone-configuration
  14502. Data type representing a zone served by Knot.
  14503. This type has the following parameters:
  14504. @table @asis
  14505. @item @code{domain} (default: @code{""})
  14506. The domain served by this configuration. It must not be empty.
  14507. @item @code{file} (default: @code{""})
  14508. The file where this zone is saved. This parameter is ignored by master zones.
  14509. Empty means default location that depends on the domain name.
  14510. @item @code{zone} (default: @code{(zone-file)})
  14511. The content of the zone file. This parameter is ignored by slave zones. It
  14512. must contain a zone-file record.
  14513. @item @code{master} (default: @code{'()})
  14514. A list of master remotes. When empty, this zone is a master. When set, this
  14515. zone is a slave. This is a list of remotes identifiers.
  14516. @item @code{ddns-master} (default: @code{#f})
  14517. The main master. When empty, it defaults to the first master in the list of
  14518. masters.
  14519. @item @code{notify} (default: @code{'()})
  14520. A list of slave remote identifiers.
  14521. @item @code{acl} (default: @code{'()})
  14522. A list of acl identifiers.
  14523. @item @code{semantic-checks?} (default: @code{#f})
  14524. When set, this adds more semantic checks to the zone.
  14525. @item @code{disable-any?} (default: @code{#f})
  14526. When set, this forbids queries of the ANY type.
  14527. @item @code{zonefile-sync} (default: @code{0})
  14528. The delay between a modification in memory and on disk. 0 means immediate
  14529. synchronization.
  14530. @item @code{serial-policy} (default: @code{'increment})
  14531. A policy between @code{'increment} and @code{'unixtime}.
  14532. @end table
  14533. @end deftp
  14534. @deftp {Data Type} knot-configuration
  14535. Data type representing the Knot configuration.
  14536. This type has the following parameters:
  14537. @table @asis
  14538. @item @code{knot} (default: @code{knot})
  14539. The Knot package.
  14540. @item @code{run-directory} (default: @code{"/var/run/knot"})
  14541. The run directory. This directory will be used for pid file and sockets.
  14542. @item @code{listen-v4} (default: @code{"0.0.0.0"})
  14543. An ip address on which to listen.
  14544. @item @code{listen-v6} (default: @code{"::"})
  14545. An ip address on which to listen.
  14546. @item @code{listen-port} (default: @code{53})
  14547. A port on which to listen.
  14548. @item @code{keys} (default: @code{'()})
  14549. The list of knot-key-configuration used by this configuration.
  14550. @item @code{acls} (default: @code{'()})
  14551. The list of knot-acl-configuration used by this configuration.
  14552. @item @code{remotes} (default: @code{'()})
  14553. The list of knot-remote-configuration used by this configuration.
  14554. @item @code{zones} (default: @code{'()})
  14555. The list of knot-zone-configuration used by this configuration.
  14556. @end table
  14557. @end deftp
  14558. @subsubheading Dnsmasq Service
  14559. @deffn {Scheme Variable} dnsmasq-service-type
  14560. This is the type of the dnsmasq service, whose value should be an
  14561. @code{dnsmasq-configuration} object as in this example:
  14562. @example
  14563. (service dnsmasq-service-type
  14564. (dnsmasq-configuration
  14565. (no-resolv? #t)
  14566. (servers '("192.168.1.1"))))
  14567. @end example
  14568. @end deffn
  14569. @deftp {Data Type} dnsmasq-configuration
  14570. Data type representing the configuration of dnsmasq.
  14571. @table @asis
  14572. @item @code{package} (default: @var{dnsmasq})
  14573. Package object of the dnsmasq server.
  14574. @item @code{no-hosts?} (default: @code{#f})
  14575. When true, don't read the hostnames in /etc/hosts.
  14576. @item @code{port} (default: @code{53})
  14577. The port to listen on. Setting this to zero completely disables DNS
  14578. responses, leaving only DHCP and/or TFTP functions.
  14579. @item @code{local-service?} (default: @code{#t})
  14580. Accept DNS queries only from hosts whose address is on a local subnet,
  14581. ie a subnet for which an interface exists on the server.
  14582. @item @code{listen-addresses} (default: @code{'()})
  14583. Listen on the given IP addresses.
  14584. @item @code{resolv-file} (default: @code{"/etc/resolv.conf"})
  14585. The file to read the IP address of the upstream nameservers from.
  14586. @item @code{no-resolv?} (default: @code{#f})
  14587. When true, don't read @var{resolv-file}.
  14588. @item @code{servers} (default: @code{'()})
  14589. Specify IP address of upstream servers directly.
  14590. @item @code{cache-size} (default: @code{150})
  14591. Set the size of dnsmasq's cache. Setting the cache size to zero
  14592. disables caching.
  14593. @item @code{negative-cache?} (default: @code{#t})
  14594. When false, disable negative caching.
  14595. @end table
  14596. @end deftp
  14597. @subsubheading ddclient Service
  14598. @cindex ddclient
  14599. The ddclient service described below runs the ddclient daemon, which takes
  14600. care of automatically updating DNS entries for service providers such as
  14601. @uref{https://dyn.com/dns/, Dyn}.
  14602. The following example show instantiates the service with its default
  14603. configuration:
  14604. @example
  14605. (service ddclient-service-type)
  14606. @end example
  14607. Note that ddclient needs to access credentials that are stored in a
  14608. @dfn{secret file}, by default @file{/etc/ddclient/secrets} (see
  14609. @code{secret-file} below.) You are expected to create this file manually, in
  14610. an ``out-of-band'' fashion (you @emph{could} make this file part of the
  14611. service configuration, for instance by using @code{plain-file}, but it will be
  14612. world-readable @i{via} @file{/gnu/store}.) See the examples in the
  14613. @file{share/ddclient} directory of the @code{ddclient} package.
  14614. @c %start of fragment
  14615. Available @code{ddclient-configuration} fields are:
  14616. @deftypevr {@code{ddclient-configuration} parameter} package ddclient
  14617. The ddclient package.
  14618. @end deftypevr
  14619. @deftypevr {@code{ddclient-configuration} parameter} integer daemon
  14620. The period after which ddclient will retry to check IP and domain name.
  14621. Defaults to @samp{300}.
  14622. @end deftypevr
  14623. @deftypevr {@code{ddclient-configuration} parameter} boolean syslog
  14624. Use syslog for the output.
  14625. Defaults to @samp{#t}.
  14626. @end deftypevr
  14627. @deftypevr {@code{ddclient-configuration} parameter} string mail
  14628. Mail to user.
  14629. Defaults to @samp{"root"}.
  14630. @end deftypevr
  14631. @deftypevr {@code{ddclient-configuration} parameter} string mail-failure
  14632. Mail failed update to user.
  14633. Defaults to @samp{"root"}.
  14634. @end deftypevr
  14635. @deftypevr {@code{ddclient-configuration} parameter} string pid
  14636. The ddclient PID file.
  14637. Defaults to @samp{"/var/run/ddclient/ddclient.pid"}.
  14638. @end deftypevr
  14639. @deftypevr {@code{ddclient-configuration} parameter} boolean ssl
  14640. Enable SSL support.
  14641. Defaults to @samp{#t}.
  14642. @end deftypevr
  14643. @deftypevr {@code{ddclient-configuration} parameter} string user
  14644. Specifies the user name or ID that is used when running ddclient
  14645. program.
  14646. Defaults to @samp{"ddclient"}.
  14647. @end deftypevr
  14648. @deftypevr {@code{ddclient-configuration} parameter} string group
  14649. Group of the user who will run the ddclient program.
  14650. Defaults to @samp{"ddclient"}.
  14651. @end deftypevr
  14652. @deftypevr {@code{ddclient-configuration} parameter} string secret-file
  14653. Secret file which will be appended to @file{ddclient.conf} file. This
  14654. file contains credentials for use by ddclient. You are expected to
  14655. create it manually.
  14656. Defaults to @samp{"/etc/ddclient/secrets.conf"}.
  14657. @end deftypevr
  14658. @deftypevr {@code{ddclient-configuration} parameter} list extra-options
  14659. Extra options will be appended to @file{ddclient.conf} file.
  14660. Defaults to @samp{()}.
  14661. @end deftypevr
  14662. @c %end of fragment
  14663. @node VPN Services
  14664. @subsubsection VPN Services
  14665. @cindex VPN (virtual private network)
  14666. @cindex virtual private network (VPN)
  14667. The @code{(gnu services vpn)} module provides services related to
  14668. @dfn{virtual private networks} (VPNs). It provides a @emph{client} service for
  14669. your machine to connect to a VPN, and a @emph{servire} service for your machine
  14670. to host a VPN. Both services use @uref{https://openvpn.net/, OpenVPN}.
  14671. @deffn {Scheme Procedure} openvpn-client-service @
  14672. [#:config (openvpn-client-configuration)]
  14673. Return a service that runs @command{openvpn}, a VPN daemon, as a client.
  14674. @end deffn
  14675. @deffn {Scheme Procedure} openvpn-server-service @
  14676. [#:config (openvpn-server-configuration)]
  14677. Return a service that runs @command{openvpn}, a VPN daemon, as a server.
  14678. Both can be run simultaneously.
  14679. @end deffn
  14680. @c %automatically generated documentation
  14681. Available @code{openvpn-client-configuration} fields are:
  14682. @deftypevr {@code{openvpn-client-configuration} parameter} package openvpn
  14683. The OpenVPN package.
  14684. @end deftypevr
  14685. @deftypevr {@code{openvpn-client-configuration} parameter} string pid-file
  14686. The OpenVPN pid file.
  14687. Defaults to @samp{"/var/run/openvpn/openvpn.pid"}.
  14688. @end deftypevr
  14689. @deftypevr {@code{openvpn-client-configuration} parameter} proto proto
  14690. The protocol (UDP or TCP) used to open a channel between clients and
  14691. servers.
  14692. Defaults to @samp{udp}.
  14693. @end deftypevr
  14694. @deftypevr {@code{openvpn-client-configuration} parameter} dev dev
  14695. The device type used to represent the VPN connection.
  14696. Defaults to @samp{tun}.
  14697. @end deftypevr
  14698. @deftypevr {@code{openvpn-client-configuration} parameter} string ca
  14699. The certificate authority to check connections against.
  14700. Defaults to @samp{"/etc/openvpn/ca.crt"}.
  14701. @end deftypevr
  14702. @deftypevr {@code{openvpn-client-configuration} parameter} string cert
  14703. The certificate of the machine the daemon is running on. It should be
  14704. signed by the authority given in @code{ca}.
  14705. Defaults to @samp{"/etc/openvpn/client.crt"}.
  14706. @end deftypevr
  14707. @deftypevr {@code{openvpn-client-configuration} parameter} string key
  14708. The key of the machine the daemon is running on. It must be the key whose
  14709. certificate is @code{cert}.
  14710. Defaults to @samp{"/etc/openvpn/client.key"}.
  14711. @end deftypevr
  14712. @deftypevr {@code{openvpn-client-configuration} parameter} boolean comp-lzo?
  14713. Whether to use the lzo compression algorithm.
  14714. Defaults to @samp{#t}.
  14715. @end deftypevr
  14716. @deftypevr {@code{openvpn-client-configuration} parameter} boolean persist-key?
  14717. Don't re-read key files across SIGUSR1 or --ping-restart.
  14718. Defaults to @samp{#t}.
  14719. @end deftypevr
  14720. @deftypevr {@code{openvpn-client-configuration} parameter} boolean persist-tun?
  14721. Don't close and reopen TUN/TAP device or run up/down scripts across
  14722. SIGUSR1 or --ping-restart restarts.
  14723. Defaults to @samp{#t}.
  14724. @end deftypevr
  14725. @deftypevr {@code{openvpn-client-configuration} parameter} number verbosity
  14726. Verbosity level.
  14727. Defaults to @samp{3}.
  14728. @end deftypevr
  14729. @deftypevr {@code{openvpn-client-configuration} parameter} tls-auth-client tls-auth
  14730. Add an additional layer of HMAC authentication on top of the TLS control
  14731. channel to protect against DoS attacks.
  14732. Defaults to @samp{#f}.
  14733. @end deftypevr
  14734. @deftypevr {@code{openvpn-client-configuration} parameter} key-usage verify-key-usage?
  14735. Whether to check the server certificate has server usage extension.
  14736. Defaults to @samp{#t}.
  14737. @end deftypevr
  14738. @deftypevr {@code{openvpn-client-configuration} parameter} bind bind?
  14739. Bind to a specific local port number.
  14740. Defaults to @samp{#f}.
  14741. @end deftypevr
  14742. @deftypevr {@code{openvpn-client-configuration} parameter} resolv-retry resolv-retry?
  14743. Retry resolving server address.
  14744. Defaults to @samp{#t}.
  14745. @end deftypevr
  14746. @deftypevr {@code{openvpn-client-configuration} parameter} openvpn-remote-list remote
  14747. A list of remote servers to connect to.
  14748. Defaults to @samp{()}.
  14749. Available @code{openvpn-remote-configuration} fields are:
  14750. @deftypevr {@code{openvpn-remote-configuration} parameter} string name
  14751. Server name.
  14752. Defaults to @samp{"my-server"}.
  14753. @end deftypevr
  14754. @deftypevr {@code{openvpn-remote-configuration} parameter} number port
  14755. Port number the server listens to.
  14756. Defaults to @samp{1194}.
  14757. @end deftypevr
  14758. @end deftypevr
  14759. @c %end of automatic openvpn-client documentation
  14760. @c %automatically generated documentation
  14761. Available @code{openvpn-server-configuration} fields are:
  14762. @deftypevr {@code{openvpn-server-configuration} parameter} package openvpn
  14763. The OpenVPN package.
  14764. @end deftypevr
  14765. @deftypevr {@code{openvpn-server-configuration} parameter} string pid-file
  14766. The OpenVPN pid file.
  14767. Defaults to @samp{"/var/run/openvpn/openvpn.pid"}.
  14768. @end deftypevr
  14769. @deftypevr {@code{openvpn-server-configuration} parameter} proto proto
  14770. The protocol (UDP or TCP) used to open a channel between clients and
  14771. servers.
  14772. Defaults to @samp{udp}.
  14773. @end deftypevr
  14774. @deftypevr {@code{openvpn-server-configuration} parameter} dev dev
  14775. The device type used to represent the VPN connection.
  14776. Defaults to @samp{tun}.
  14777. @end deftypevr
  14778. @deftypevr {@code{openvpn-server-configuration} parameter} string ca
  14779. The certificate authority to check connections against.
  14780. Defaults to @samp{"/etc/openvpn/ca.crt"}.
  14781. @end deftypevr
  14782. @deftypevr {@code{openvpn-server-configuration} parameter} string cert
  14783. The certificate of the machine the daemon is running on. It should be
  14784. signed by the authority given in @code{ca}.
  14785. Defaults to @samp{"/etc/openvpn/client.crt"}.
  14786. @end deftypevr
  14787. @deftypevr {@code{openvpn-server-configuration} parameter} string key
  14788. The key of the machine the daemon is running on. It must be the key whose
  14789. certificate is @code{cert}.
  14790. Defaults to @samp{"/etc/openvpn/client.key"}.
  14791. @end deftypevr
  14792. @deftypevr {@code{openvpn-server-configuration} parameter} boolean comp-lzo?
  14793. Whether to use the lzo compression algorithm.
  14794. Defaults to @samp{#t}.
  14795. @end deftypevr
  14796. @deftypevr {@code{openvpn-server-configuration} parameter} boolean persist-key?
  14797. Don't re-read key files across SIGUSR1 or --ping-restart.
  14798. Defaults to @samp{#t}.
  14799. @end deftypevr
  14800. @deftypevr {@code{openvpn-server-configuration} parameter} boolean persist-tun?
  14801. Don't close and reopen TUN/TAP device or run up/down scripts across
  14802. SIGUSR1 or --ping-restart restarts.
  14803. Defaults to @samp{#t}.
  14804. @end deftypevr
  14805. @deftypevr {@code{openvpn-server-configuration} parameter} number verbosity
  14806. Verbosity level.
  14807. Defaults to @samp{3}.
  14808. @end deftypevr
  14809. @deftypevr {@code{openvpn-server-configuration} parameter} tls-auth-server tls-auth
  14810. Add an additional layer of HMAC authentication on top of the TLS control
  14811. channel to protect against DoS attacks.
  14812. Defaults to @samp{#f}.
  14813. @end deftypevr
  14814. @deftypevr {@code{openvpn-server-configuration} parameter} number port
  14815. Specifies the port number on which the server listens.
  14816. Defaults to @samp{1194}.
  14817. @end deftypevr
  14818. @deftypevr {@code{openvpn-server-configuration} parameter} ip-mask server
  14819. An ip and mask specifying the subnet inside the virtual network.
  14820. Defaults to @samp{"10.8.0.0 255.255.255.0"}.
  14821. @end deftypevr
  14822. @deftypevr {@code{openvpn-server-configuration} parameter} cidr6 server-ipv6
  14823. A CIDR notation specifying the IPv6 subnet inside the virtual network.
  14824. Defaults to @samp{#f}.
  14825. @end deftypevr
  14826. @deftypevr {@code{openvpn-server-configuration} parameter} string dh
  14827. The Diffie-Hellman parameters file.
  14828. Defaults to @samp{"/etc/openvpn/dh2048.pem"}.
  14829. @end deftypevr
  14830. @deftypevr {@code{openvpn-server-configuration} parameter} string ifconfig-pool-persist
  14831. The file that records client IPs.
  14832. Defaults to @samp{"/etc/openvpn/ipp.txt"}.
  14833. @end deftypevr
  14834. @deftypevr {@code{openvpn-server-configuration} parameter} gateway redirect-gateway?
  14835. When true, the server will act as a gateway for its clients.
  14836. Defaults to @samp{#f}.
  14837. @end deftypevr
  14838. @deftypevr {@code{openvpn-server-configuration} parameter} boolean client-to-client?
  14839. When true, clients are allowed to talk to each other inside the VPN.
  14840. Defaults to @samp{#f}.
  14841. @end deftypevr
  14842. @deftypevr {@code{openvpn-server-configuration} parameter} keepalive keepalive
  14843. Causes ping-like messages to be sent back and forth over the link so
  14844. that each side knows when the other side has gone down. @code{keepalive}
  14845. requires a pair. The first element is the period of the ping sending,
  14846. and the second element is the timeout before considering the other side
  14847. down.
  14848. @end deftypevr
  14849. @deftypevr {@code{openvpn-server-configuration} parameter} number max-clients
  14850. The maximum number of clients.
  14851. Defaults to @samp{100}.
  14852. @end deftypevr
  14853. @deftypevr {@code{openvpn-server-configuration} parameter} string status
  14854. The status file. This file shows a small report on current connection.
  14855. It is truncated and rewritten every minute.
  14856. Defaults to @samp{"/var/run/openvpn/status"}.
  14857. @end deftypevr
  14858. @deftypevr {@code{openvpn-server-configuration} parameter} openvpn-ccd-list client-config-dir
  14859. The list of configuration for some clients.
  14860. Defaults to @samp{()}.
  14861. Available @code{openvpn-ccd-configuration} fields are:
  14862. @deftypevr {@code{openvpn-ccd-configuration} parameter} string name
  14863. Client name.
  14864. Defaults to @samp{"client"}.
  14865. @end deftypevr
  14866. @deftypevr {@code{openvpn-ccd-configuration} parameter} ip-mask iroute
  14867. Client own network
  14868. Defaults to @samp{#f}.
  14869. @end deftypevr
  14870. @deftypevr {@code{openvpn-ccd-configuration} parameter} ip-mask ifconfig-push
  14871. Client VPN IP.
  14872. Defaults to @samp{#f}.
  14873. @end deftypevr
  14874. @end deftypevr
  14875. @c %end of automatic openvpn-server documentation
  14876. @node Network File System
  14877. @subsubsection Network File System
  14878. @cindex NFS
  14879. The @code{(gnu services nfs)} module provides the following services,
  14880. which are most commonly used in relation to mounting or exporting
  14881. directory trees as @dfn{network file systems} (NFS).
  14882. @subsubheading RPC Bind Service
  14883. @cindex rpcbind
  14884. The RPC Bind service provides a facility to map program numbers into
  14885. universal addresses.
  14886. Many NFS related services use this facility. Hence it is automatically
  14887. started when a dependent service starts.
  14888. @defvr {Scheme Variable} rpcbind-service-type
  14889. A service type for the RPC portmapper daemon.
  14890. @end defvr
  14891. @deftp {Data Type} rpcbind-configuration
  14892. Data type representing the configuration of the RPC Bind Service.
  14893. This type has the following parameters:
  14894. @table @asis
  14895. @item @code{rpcbind} (default: @code{rpcbind})
  14896. The rpcbind package to use.
  14897. @item @code{warm-start?} (default: @code{#t})
  14898. If this parameter is @code{#t}, then the daemon will read a
  14899. state file on startup thus reloading state information saved by a previous
  14900. instance.
  14901. @end table
  14902. @end deftp
  14903. @subsubheading Pipefs Pseudo File System
  14904. @cindex pipefs
  14905. @cindex rpc_pipefs
  14906. The pipefs file system is used to transfer NFS related data
  14907. between the kernel and user space programs.
  14908. @defvr {Scheme Variable} pipefs-service-type
  14909. A service type for the pipefs pseudo file system.
  14910. @end defvr
  14911. @deftp {Data Type} pipefs-configuration
  14912. Data type representing the configuration of the pipefs pseudo file system service.
  14913. This type has the following parameters:
  14914. @table @asis
  14915. @item @code{mount-point} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  14916. The directory to which the file system is to be attached.
  14917. @end table
  14918. @end deftp
  14919. @subsubheading GSS Daemon Service
  14920. @cindex GSSD
  14921. @cindex GSS
  14922. @cindex global security system
  14923. The @dfn{global security system} (GSS) daemon provides strong security for RPC
  14924. based protocols.
  14925. Before exchanging RPC requests an RPC client must establish a security
  14926. context. Typically this is done using the Kerberos command @command{kinit}
  14927. or automatically at login time using PAM services (@pxref{Kerberos Services}).
  14928. @defvr {Scheme Variable} gss-service-type
  14929. A service type for the Global Security System (GSS) daemon.
  14930. @end defvr
  14931. @deftp {Data Type} gss-configuration
  14932. Data type representing the configuration of the GSS daemon service.
  14933. This type has the following parameters:
  14934. @table @asis
  14935. @item @code{nfs-utils} (default: @code{nfs-utils})
  14936. The package in which the @command{rpc.gssd} command is to be found.
  14937. @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  14938. The directory where the pipefs file system is mounted.
  14939. @end table
  14940. @end deftp
  14941. @subsubheading IDMAP Daemon Service
  14942. @cindex idmapd
  14943. @cindex name mapper
  14944. The idmap daemon service provides mapping between user IDs and user names.
  14945. Typically it is required in order to access file systems mounted via NFSv4.
  14946. @defvr {Scheme Variable} idmap-service-type
  14947. A service type for the Identity Mapper (IDMAP) daemon.
  14948. @end defvr
  14949. @deftp {Data Type} idmap-configuration
  14950. Data type representing the configuration of the IDMAP daemon service.
  14951. This type has the following parameters:
  14952. @table @asis
  14953. @item @code{nfs-utils} (default: @code{nfs-utils})
  14954. The package in which the @command{rpc.idmapd} command is to be found.
  14955. @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  14956. The directory where the pipefs file system is mounted.
  14957. @item @code{domain} (default: @code{#f})
  14958. The local NFSv4 domain name.
  14959. This must be a string or @code{#f}.
  14960. If it is @code{#f} then the daemon will use the host's fully qualified domain name.
  14961. @end table
  14962. @end deftp
  14963. @node Continuous Integration
  14964. @subsubsection Continuous Integration
  14965. @cindex continuous integration
  14966. @uref{https://git.savannah.gnu.org/cgit/guix/guix-cuirass.git, Cuirass} is a
  14967. continuous integration tool for Guix. It can be used both for development and
  14968. for providing substitutes to others (@pxref{Substitutes}).
  14969. The @code{(gnu services cuirass)} module provides the following service.
  14970. @defvr {Scheme Procedure} cuirass-service-type
  14971. The type of the Cuirass service. Its value must be a
  14972. @code{cuirass-configuration} object, as described below.
  14973. @end defvr
  14974. To add build jobs, you have to set the @code{specifications} field of the
  14975. configuration. Here is an example of a service that polls the Guix repository
  14976. and builds the packages from a manifest. Some of the packages are defined in
  14977. the @code{"custom-packages"} input, which is the equivalent of
  14978. @code{GUIX_PACKAGE_PATH}.
  14979. @example
  14980. (define %cuirass-specs
  14981. #~(list
  14982. '((#:name . "my-manifest")
  14983. (#:load-path-inputs . ("guix"))
  14984. (#:package-path-inputs . ("custom-packages"))
  14985. (#:proc-input . "guix")
  14986. (#:proc-file . "build-aux/cuirass/gnu-system.scm")
  14987. (#:proc . cuirass-jobs)
  14988. (#:proc-args . ((subset . "manifests")
  14989. (systems . ("x86_64-linux"))
  14990. (manifests . (("config" . "guix/manifest.scm")))))
  14991. (#:inputs . (((#:name . "guix")
  14992. (#:url . "git://git.savannah.gnu.org/guix.git")
  14993. (#:load-path . ".")
  14994. (#:branch . "master")
  14995. (#:no-compile? . #t))
  14996. ((#:name . "config")
  14997. (#:url . "git://git.example.org/config.git")
  14998. (#:load-path . ".")
  14999. (#:branch . "master")
  15000. (#:no-compile? . #t))
  15001. ((#:name . "custom-packages")
  15002. (#:url . "git://git.example.org/custom-packages.git")
  15003. (#:load-path . ".")
  15004. (#:branch . "master")
  15005. (#:no-compile? . #t)))))))
  15006. (service cuirass-service-type
  15007. (cuirass-configuration
  15008. (specifications %cuirass-specs)))
  15009. @end example
  15010. While information related to build jobs is located directly in the
  15011. specifications, global settings for the @command{cuirass} process are
  15012. accessible in other @code{cuirass-configuration} fields.
  15013. @deftp {Data Type} cuirass-configuration
  15014. Data type representing the configuration of Cuirass.
  15015. @table @asis
  15016. @item @code{log-file} (default: @code{"/var/log/cuirass.log"})
  15017. Location of the log file.
  15018. @item @code{cache-directory} (default: @code{"/var/cache/cuirass"})
  15019. Location of the repository cache.
  15020. @item @code{user} (default: @code{"cuirass"})
  15021. Owner of the @code{cuirass} process.
  15022. @item @code{group} (default: @code{"cuirass"})
  15023. Owner's group of the @code{cuirass} process.
  15024. @item @code{interval} (default: @code{60})
  15025. Number of seconds between the poll of the repositories followed by the
  15026. Cuirass jobs.
  15027. @item @code{database} (default: @code{"/var/lib/cuirass/cuirass.db"})
  15028. Location of sqlite database which contains the build results and previously
  15029. added specifications.
  15030. @item @code{ttl} (default: @code{(* 30 24 3600)})
  15031. Specifies the time-to-live (TTL) in seconds of garbage collector roots that
  15032. are registered for build results. This means that build results are protected
  15033. from garbage collection for at least @var{ttl} seconds.
  15034. @item @code{port} (default: @code{8081})
  15035. Port number used by the HTTP server.
  15036. @item --listen=@var{host}
  15037. Listen on the network interface for @var{host}. The default is to
  15038. accept connections from localhost.
  15039. @item @code{specifications} (default: @code{#~'()})
  15040. A gexp (@pxref{G-Expressions}) that evaluates to a list of specifications,
  15041. where a specification is an association list
  15042. (@pxref{Associations Lists,,, guile, GNU Guile Reference Manual}) whose
  15043. keys are keywords (@code{#:keyword-example}) as shown in the example
  15044. above.
  15045. @item @code{use-substitutes?} (default: @code{#f})
  15046. This allows using substitutes to avoid building every dependencies of a job
  15047. from source.
  15048. @item @code{one-shot?} (default: @code{#f})
  15049. Only evaluate specifications and build derivations once.
  15050. @item @code{fallback?} (default: @code{#f})
  15051. When substituting a pre-built binary fails, fall back to building
  15052. packages locally.
  15053. @item @code{cuirass} (default: @code{cuirass})
  15054. The Cuirass package to use.
  15055. @end table
  15056. @end deftp
  15057. @node Power Management Services
  15058. @subsubsection Power Management Services
  15059. @cindex tlp
  15060. @cindex power management with TLP
  15061. @subsubheading TLP daemon
  15062. The @code{(gnu services pm)} module provides a Guix service definition
  15063. for the Linux power management tool TLP.
  15064. TLP enables various powersaving modes in userspace and kernel.
  15065. Contrary to @code{upower-service}, it is not a passive,
  15066. monitoring tool, as it will apply custom settings each time a new power
  15067. source is detected. More information can be found at
  15068. @uref{http://linrunner.de/en/tlp/tlp.html, TLP home page}.
  15069. @deffn {Scheme Variable} tlp-service-type
  15070. The service type for the TLP tool. Its value should be a valid
  15071. TLP configuration (see below). To use the default settings, simply
  15072. write:
  15073. @example
  15074. (service tlp-service-type)
  15075. @end example
  15076. @end deffn
  15077. By default TLP does not need much configuration but most TLP parameters
  15078. can be tweaked using @code{tlp-configuration}.
  15079. Each parameter definition is preceded by its type; for example,
  15080. @samp{boolean foo} indicates that the @code{foo} parameter
  15081. should be specified as a boolean. Types starting with
  15082. @code{maybe-} denote parameters that won't show up in TLP config file
  15083. when their value is @code{'disabled}.
  15084. @c The following documentation was initially generated by
  15085. @c (generate-tlp-documentation) in (gnu services pm). Manually maintained
  15086. @c documentation is better, so we shouldn't hesitate to edit below as
  15087. @c needed. However if the change you want to make to this documentation
  15088. @c can be done in an automated way, it's probably easier to change
  15089. @c (generate-documentation) than to make it below and have to deal with
  15090. @c the churn as TLP updates.
  15091. Available @code{tlp-configuration} fields are:
  15092. @deftypevr {@code{tlp-configuration} parameter} package tlp
  15093. The TLP package.
  15094. @end deftypevr
  15095. @deftypevr {@code{tlp-configuration} parameter} boolean tlp-enable?
  15096. Set to true if you wish to enable TLP.
  15097. Defaults to @samp{#t}.
  15098. @end deftypevr
  15099. @deftypevr {@code{tlp-configuration} parameter} string tlp-default-mode
  15100. Default mode when no power supply can be detected. Alternatives are AC
  15101. and BAT.
  15102. Defaults to @samp{"AC"}.
  15103. @end deftypevr
  15104. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer disk-idle-secs-on-ac
  15105. Number of seconds Linux kernel has to wait after the disk goes idle,
  15106. before syncing on AC.
  15107. Defaults to @samp{0}.
  15108. @end deftypevr
  15109. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer disk-idle-secs-on-bat
  15110. Same as @code{disk-idle-ac} but on BAT mode.
  15111. Defaults to @samp{2}.
  15112. @end deftypevr
  15113. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer max-lost-work-secs-on-ac
  15114. Dirty pages flushing periodicity, expressed in seconds.
  15115. Defaults to @samp{15}.
  15116. @end deftypevr
  15117. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer max-lost-work-secs-on-bat
  15118. Same as @code{max-lost-work-secs-on-ac} but on BAT mode.
  15119. Defaults to @samp{60}.
  15120. @end deftypevr
  15121. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list cpu-scaling-governor-on-ac
  15122. CPU frequency scaling governor on AC mode. With intel_pstate driver,
  15123. alternatives are powersave and performance. With acpi-cpufreq driver,
  15124. alternatives are ondemand, powersave, performance and conservative.
  15125. Defaults to @samp{disabled}.
  15126. @end deftypevr
  15127. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list cpu-scaling-governor-on-bat
  15128. Same as @code{cpu-scaling-governor-on-ac} but on BAT mode.
  15129. Defaults to @samp{disabled}.
  15130. @end deftypevr
  15131. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-min-freq-on-ac
  15132. Set the min available frequency for the scaling governor on AC.
  15133. Defaults to @samp{disabled}.
  15134. @end deftypevr
  15135. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-max-freq-on-ac
  15136. Set the max available frequency for the scaling governor on AC.
  15137. Defaults to @samp{disabled}.
  15138. @end deftypevr
  15139. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-min-freq-on-bat
  15140. Set the min available frequency for the scaling governor on BAT.
  15141. Defaults to @samp{disabled}.
  15142. @end deftypevr
  15143. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-max-freq-on-bat
  15144. Set the max available frequency for the scaling governor on BAT.
  15145. Defaults to @samp{disabled}.
  15146. @end deftypevr
  15147. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-min-perf-on-ac
  15148. Limit the min P-state to control the power dissipation of the CPU, in AC
  15149. mode. Values are stated as a percentage of the available performance.
  15150. Defaults to @samp{disabled}.
  15151. @end deftypevr
  15152. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-max-perf-on-ac
  15153. Limit the max P-state to control the power dissipation of the CPU, in AC
  15154. mode. Values are stated as a percentage of the available performance.
  15155. Defaults to @samp{disabled}.
  15156. @end deftypevr
  15157. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-min-perf-on-bat
  15158. Same as @code{cpu-min-perf-on-ac} on BAT mode.
  15159. Defaults to @samp{disabled}.
  15160. @end deftypevr
  15161. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-max-perf-on-bat
  15162. Same as @code{cpu-max-perf-on-ac} on BAT mode.
  15163. Defaults to @samp{disabled}.
  15164. @end deftypevr
  15165. @deftypevr {@code{tlp-configuration} parameter} maybe-boolean cpu-boost-on-ac?
  15166. Enable CPU turbo boost feature on AC mode.
  15167. Defaults to @samp{disabled}.
  15168. @end deftypevr
  15169. @deftypevr {@code{tlp-configuration} parameter} maybe-boolean cpu-boost-on-bat?
  15170. Same as @code{cpu-boost-on-ac?} on BAT mode.
  15171. Defaults to @samp{disabled}.
  15172. @end deftypevr
  15173. @deftypevr {@code{tlp-configuration} parameter} boolean sched-powersave-on-ac?
  15174. Allow Linux kernel to minimize the number of CPU cores/hyper-threads
  15175. used under light load conditions.
  15176. Defaults to @samp{#f}.
  15177. @end deftypevr
  15178. @deftypevr {@code{tlp-configuration} parameter} boolean sched-powersave-on-bat?
  15179. Same as @code{sched-powersave-on-ac?} but on BAT mode.
  15180. Defaults to @samp{#t}.
  15181. @end deftypevr
  15182. @deftypevr {@code{tlp-configuration} parameter} boolean nmi-watchdog?
  15183. Enable Linux kernel NMI watchdog.
  15184. Defaults to @samp{#f}.
  15185. @end deftypevr
  15186. @deftypevr {@code{tlp-configuration} parameter} maybe-string phc-controls
  15187. For Linux kernels with PHC patch applied, change CPU voltages. An
  15188. example value would be @samp{"F:V F:V F:V F:V"}.
  15189. Defaults to @samp{disabled}.
  15190. @end deftypevr
  15191. @deftypevr {@code{tlp-configuration} parameter} string energy-perf-policy-on-ac
  15192. Set CPU performance versus energy saving policy on AC. Alternatives are
  15193. performance, normal, powersave.
  15194. Defaults to @samp{"performance"}.
  15195. @end deftypevr
  15196. @deftypevr {@code{tlp-configuration} parameter} string energy-perf-policy-on-bat
  15197. Same as @code{energy-perf-policy-ac} but on BAT mode.
  15198. Defaults to @samp{"powersave"}.
  15199. @end deftypevr
  15200. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disks-devices
  15201. Hard disk devices.
  15202. @end deftypevr
  15203. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disk-apm-level-on-ac
  15204. Hard disk advanced power management level.
  15205. @end deftypevr
  15206. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disk-apm-level-on-bat
  15207. Same as @code{disk-apm-bat} but on BAT mode.
  15208. @end deftypevr
  15209. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-spindown-timeout-on-ac
  15210. Hard disk spin down timeout. One value has to be specified for each
  15211. declared hard disk.
  15212. Defaults to @samp{disabled}.
  15213. @end deftypevr
  15214. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-spindown-timeout-on-bat
  15215. Same as @code{disk-spindown-timeout-on-ac} but on BAT mode.
  15216. Defaults to @samp{disabled}.
  15217. @end deftypevr
  15218. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-iosched
  15219. Select IO scheduler for disk devices. One value has to be specified for
  15220. each declared hard disk. Example alternatives are cfq, deadline and
  15221. noop.
  15222. Defaults to @samp{disabled}.
  15223. @end deftypevr
  15224. @deftypevr {@code{tlp-configuration} parameter} string sata-linkpwr-on-ac
  15225. SATA aggressive link power management (ALPM) level. Alternatives are
  15226. min_power, medium_power, max_performance.
  15227. Defaults to @samp{"max_performance"}.
  15228. @end deftypevr
  15229. @deftypevr {@code{tlp-configuration} parameter} string sata-linkpwr-on-bat
  15230. Same as @code{sata-linkpwr-ac} but on BAT mode.
  15231. Defaults to @samp{"min_power"}.
  15232. @end deftypevr
  15233. @deftypevr {@code{tlp-configuration} parameter} maybe-string sata-linkpwr-blacklist
  15234. Exclude specified SATA host devices for link power management.
  15235. Defaults to @samp{disabled}.
  15236. @end deftypevr
  15237. @deftypevr {@code{tlp-configuration} parameter} maybe-on-off-boolean ahci-runtime-pm-on-ac?
  15238. Enable Runtime Power Management for AHCI controller and disks on AC
  15239. mode.
  15240. Defaults to @samp{disabled}.
  15241. @end deftypevr
  15242. @deftypevr {@code{tlp-configuration} parameter} maybe-on-off-boolean ahci-runtime-pm-on-bat?
  15243. Same as @code{ahci-runtime-pm-on-ac} on BAT mode.
  15244. Defaults to @samp{disabled}.
  15245. @end deftypevr
  15246. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer ahci-runtime-pm-timeout
  15247. Seconds of inactivity before disk is suspended.
  15248. Defaults to @samp{15}.
  15249. @end deftypevr
  15250. @deftypevr {@code{tlp-configuration} parameter} string pcie-aspm-on-ac
  15251. PCI Express Active State Power Management level. Alternatives are
  15252. default, performance, powersave.
  15253. Defaults to @samp{"performance"}.
  15254. @end deftypevr
  15255. @deftypevr {@code{tlp-configuration} parameter} string pcie-aspm-on-bat
  15256. Same as @code{pcie-aspm-ac} but on BAT mode.
  15257. Defaults to @samp{"powersave"}.
  15258. @end deftypevr
  15259. @deftypevr {@code{tlp-configuration} parameter} string radeon-power-profile-on-ac
  15260. Radeon graphics clock speed level. Alternatives are low, mid, high,
  15261. auto, default.
  15262. Defaults to @samp{"high"}.
  15263. @end deftypevr
  15264. @deftypevr {@code{tlp-configuration} parameter} string radeon-power-profile-on-bat
  15265. Same as @code{radeon-power-ac} but on BAT mode.
  15266. Defaults to @samp{"low"}.
  15267. @end deftypevr
  15268. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-state-on-ac
  15269. Radeon dynamic power management method (DPM). Alternatives are battery,
  15270. performance.
  15271. Defaults to @samp{"performance"}.
  15272. @end deftypevr
  15273. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-state-on-bat
  15274. Same as @code{radeon-dpm-state-ac} but on BAT mode.
  15275. Defaults to @samp{"battery"}.
  15276. @end deftypevr
  15277. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-perf-level-on-ac
  15278. Radeon DPM performance level. Alternatives are auto, low, high.
  15279. Defaults to @samp{"auto"}.
  15280. @end deftypevr
  15281. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-perf-level-on-bat
  15282. Same as @code{radeon-dpm-perf-ac} but on BAT mode.
  15283. Defaults to @samp{"auto"}.
  15284. @end deftypevr
  15285. @deftypevr {@code{tlp-configuration} parameter} on-off-boolean wifi-pwr-on-ac?
  15286. Wifi power saving mode.
  15287. Defaults to @samp{#f}.
  15288. @end deftypevr
  15289. @deftypevr {@code{tlp-configuration} parameter} on-off-boolean wifi-pwr-on-bat?
  15290. Same as @code{wifi-power-ac?} but on BAT mode.
  15291. Defaults to @samp{#t}.
  15292. @end deftypevr
  15293. @deftypevr {@code{tlp-configuration} parameter} y-n-boolean wol-disable?
  15294. Disable wake on LAN.
  15295. Defaults to @samp{#t}.
  15296. @end deftypevr
  15297. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer sound-power-save-on-ac
  15298. Timeout duration in seconds before activating audio power saving on
  15299. Intel HDA and AC97 devices. A value of 0 disables power saving.
  15300. Defaults to @samp{0}.
  15301. @end deftypevr
  15302. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer sound-power-save-on-bat
  15303. Same as @code{sound-powersave-ac} but on BAT mode.
  15304. Defaults to @samp{1}.
  15305. @end deftypevr
  15306. @deftypevr {@code{tlp-configuration} parameter} y-n-boolean sound-power-save-controller?
  15307. Disable controller in powersaving mode on Intel HDA devices.
  15308. Defaults to @samp{#t}.
  15309. @end deftypevr
  15310. @deftypevr {@code{tlp-configuration} parameter} boolean bay-poweroff-on-bat?
  15311. Enable optical drive in UltraBay/MediaBay on BAT mode. Drive can be
  15312. powered on again by releasing (and reinserting) the eject lever or by
  15313. pressing the disc eject button on newer models.
  15314. Defaults to @samp{#f}.
  15315. @end deftypevr
  15316. @deftypevr {@code{tlp-configuration} parameter} string bay-device
  15317. Name of the optical drive device to power off.
  15318. Defaults to @samp{"sr0"}.
  15319. @end deftypevr
  15320. @deftypevr {@code{tlp-configuration} parameter} string runtime-pm-on-ac
  15321. Runtime Power Management for PCI(e) bus devices. Alternatives are on
  15322. and auto.
  15323. Defaults to @samp{"on"}.
  15324. @end deftypevr
  15325. @deftypevr {@code{tlp-configuration} parameter} string runtime-pm-on-bat
  15326. Same as @code{runtime-pm-ac} but on BAT mode.
  15327. Defaults to @samp{"auto"}.
  15328. @end deftypevr
  15329. @deftypevr {@code{tlp-configuration} parameter} boolean runtime-pm-all?
  15330. Runtime Power Management for all PCI(e) bus devices, except blacklisted
  15331. ones.
  15332. Defaults to @samp{#t}.
  15333. @end deftypevr
  15334. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list runtime-pm-blacklist
  15335. Exclude specified PCI(e) device addresses from Runtime Power Management.
  15336. Defaults to @samp{disabled}.
  15337. @end deftypevr
  15338. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list runtime-pm-driver-blacklist
  15339. Exclude PCI(e) devices assigned to the specified drivers from Runtime
  15340. Power Management.
  15341. @end deftypevr
  15342. @deftypevr {@code{tlp-configuration} parameter} boolean usb-autosuspend?
  15343. Enable USB autosuspend feature.
  15344. Defaults to @samp{#t}.
  15345. @end deftypevr
  15346. @deftypevr {@code{tlp-configuration} parameter} maybe-string usb-blacklist
  15347. Exclude specified devices from USB autosuspend.
  15348. Defaults to @samp{disabled}.
  15349. @end deftypevr
  15350. @deftypevr {@code{tlp-configuration} parameter} boolean usb-blacklist-wwan?
  15351. Exclude WWAN devices from USB autosuspend.
  15352. Defaults to @samp{#t}.
  15353. @end deftypevr
  15354. @deftypevr {@code{tlp-configuration} parameter} maybe-string usb-whitelist
  15355. Include specified devices into USB autosuspend, even if they are already
  15356. excluded by the driver or via @code{usb-blacklist-wwan?}.
  15357. Defaults to @samp{disabled}.
  15358. @end deftypevr
  15359. @deftypevr {@code{tlp-configuration} parameter} maybe-boolean usb-autosuspend-disable-on-shutdown?
  15360. Enable USB autosuspend before shutdown.
  15361. Defaults to @samp{disabled}.
  15362. @end deftypevr
  15363. @deftypevr {@code{tlp-configuration} parameter} boolean restore-device-state-on-startup?
  15364. Restore radio device state (bluetooth, wifi, wwan) from previous
  15365. shutdown on system startup.
  15366. Defaults to @samp{#f}.
  15367. @end deftypevr
  15368. @cindex thermald
  15369. @cindex CPU frequency scaling with thermald
  15370. @subsubheading Thermald daemon
  15371. The @code{(gnu services pm)} module provides an interface to
  15372. thermald, a CPU frequency scaling service which helps prevent overheating.
  15373. @defvr {Scheme Variable} thermald-service-type
  15374. This is the service type for
  15375. @uref{https://01.org/linux-thermal-daemon/, thermald}, the Linux
  15376. Thermal Daemon, which is responsible for controlling the thermal state
  15377. of processors and preventing overheating.
  15378. @end defvr
  15379. @deftp {Data Type} thermald-configuration
  15380. Data type representing the configuration of @code{thermald-service-type}.
  15381. @table @asis
  15382. @item @code{ignore-cpuid-check?} (default: @code{#f})
  15383. Ignore cpuid check for supported CPU models.
  15384. @item @code{thermald} (default: @var{thermald})
  15385. Package object of thermald.
  15386. @end table
  15387. @end deftp
  15388. @node Audio Services
  15389. @subsubsection Audio Services
  15390. The @code{(gnu services audio)} module provides a service to start MPD
  15391. (the Music Player Daemon).
  15392. @cindex mpd
  15393. @subsubheading Music Player Daemon
  15394. The Music Player Daemon (MPD) is a service that can play music while
  15395. being controlled from the local machine or over the network by a variety
  15396. of clients.
  15397. The following example shows how one might run @code{mpd} as user
  15398. @code{"bob"} on port @code{6666}. It uses pulseaudio for output.
  15399. @example
  15400. (service mpd-service-type
  15401. (mpd-configuration
  15402. (user "bob")
  15403. (port "6666")))
  15404. @end example
  15405. @defvr {Scheme Variable} mpd-service-type
  15406. The service type for @command{mpd}
  15407. @end defvr
  15408. @deftp {Data Type} mpd-configuration
  15409. Data type representing the configuration of @command{mpd}.
  15410. @table @asis
  15411. @item @code{user} (default: @code{"mpd"})
  15412. The user to run mpd as.
  15413. @item @code{music-dir} (default: @code{"~/Music"})
  15414. The directory to scan for music files.
  15415. @item @code{playlist-dir} (default: @code{"~/.mpd/playlists"})
  15416. The directory to store playlists.
  15417. @item @code{port} (default: @code{"6600"})
  15418. The port to run mpd on.
  15419. @item @code{address} (default: @code{"any"})
  15420. The address that mpd will bind to. To use a Unix domain socket,
  15421. an absolute path can be specified here.
  15422. @end table
  15423. @end deftp
  15424. @node Virtualization Services
  15425. @subsubsection Virtualization services
  15426. The @code{(gnu services virtualization)} module provides services for
  15427. the libvirt and virtlog daemons, as well as other virtualization-related
  15428. services.
  15429. @subsubheading Libvirt daemon
  15430. @code{libvirtd} is the server side daemon component of the libvirt
  15431. virtualization management system. This daemon runs on host servers
  15432. and performs required management tasks for virtualized guests.
  15433. @deffn {Scheme Variable} libvirt-service-type
  15434. This is the type of the @uref{https://libvirt.org, libvirt daemon}.
  15435. Its value must be a @code{libvirt-configuration}.
  15436. @example
  15437. (service libvirt-service-type
  15438. (libvirt-configuration
  15439. (unix-sock-group "libvirt")
  15440. (tls-port "16555")))
  15441. @end example
  15442. @end deffn
  15443. @c Auto-generated with (generate-libvirt-documentation)
  15444. Available @code{libvirt-configuration} fields are:
  15445. @deftypevr {@code{libvirt-configuration} parameter} package libvirt
  15446. Libvirt package.
  15447. @end deftypevr
  15448. @deftypevr {@code{libvirt-configuration} parameter} boolean listen-tls?
  15449. Flag listening for secure TLS connections on the public TCP/IP port.
  15450. must set @code{listen} for this to have any effect.
  15451. It is necessary to setup a CA and issue server certificates before using
  15452. this capability.
  15453. Defaults to @samp{#t}.
  15454. @end deftypevr
  15455. @deftypevr {@code{libvirt-configuration} parameter} boolean listen-tcp?
  15456. Listen for unencrypted TCP connections on the public TCP/IP port. must
  15457. set @code{listen} for this to have any effect.
  15458. Using the TCP socket requires SASL authentication by default. Only SASL
  15459. mechanisms which support data encryption are allowed. This is
  15460. DIGEST_MD5 and GSSAPI (Kerberos5)
  15461. Defaults to @samp{#f}.
  15462. @end deftypevr
  15463. @deftypevr {@code{libvirt-configuration} parameter} string tls-port
  15464. Port for accepting secure TLS connections This can be a port number, or
  15465. service name
  15466. Defaults to @samp{"16514"}.
  15467. @end deftypevr
  15468. @deftypevr {@code{libvirt-configuration} parameter} string tcp-port
  15469. Port for accepting insecure TCP connections This can be a port number,
  15470. or service name
  15471. Defaults to @samp{"16509"}.
  15472. @end deftypevr
  15473. @deftypevr {@code{libvirt-configuration} parameter} string listen-addr
  15474. IP address or hostname used for client connections.
  15475. Defaults to @samp{"0.0.0.0"}.
  15476. @end deftypevr
  15477. @deftypevr {@code{libvirt-configuration} parameter} boolean mdns-adv?
  15478. Flag toggling mDNS advertisement of the libvirt service.
  15479. Alternatively can disable for all services on a host by stopping the
  15480. Avahi daemon.
  15481. Defaults to @samp{#f}.
  15482. @end deftypevr
  15483. @deftypevr {@code{libvirt-configuration} parameter} string mdns-name
  15484. Default mDNS advertisement name. This must be unique on the immediate
  15485. broadcast network.
  15486. Defaults to @samp{"Virtualization Host <hostname>"}.
  15487. @end deftypevr
  15488. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-group
  15489. UNIX domain socket group ownership. This can be used to allow a
  15490. 'trusted' set of users access to management capabilities without
  15491. becoming root.
  15492. Defaults to @samp{"root"}.
  15493. @end deftypevr
  15494. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-ro-perms
  15495. UNIX socket permissions for the R/O socket. This is used for monitoring
  15496. VM status only.
  15497. Defaults to @samp{"0777"}.
  15498. @end deftypevr
  15499. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-rw-perms
  15500. UNIX socket permissions for the R/W socket. Default allows only root.
  15501. If PolicyKit is enabled on the socket, the default will change to allow
  15502. everyone (eg, 0777)
  15503. Defaults to @samp{"0770"}.
  15504. @end deftypevr
  15505. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-admin-perms
  15506. UNIX socket permissions for the admin socket. Default allows only owner
  15507. (root), do not change it unless you are sure to whom you are exposing
  15508. the access to.
  15509. Defaults to @samp{"0777"}.
  15510. @end deftypevr
  15511. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-dir
  15512. The directory in which sockets will be found/created.
  15513. Defaults to @samp{"/var/run/libvirt"}.
  15514. @end deftypevr
  15515. @deftypevr {@code{libvirt-configuration} parameter} string auth-unix-ro
  15516. Authentication scheme for UNIX read-only sockets. By default socket
  15517. permissions allow anyone to connect
  15518. Defaults to @samp{"polkit"}.
  15519. @end deftypevr
  15520. @deftypevr {@code{libvirt-configuration} parameter} string auth-unix-rw
  15521. Authentication scheme for UNIX read-write sockets. By default socket
  15522. permissions only allow root. If PolicyKit support was compiled into
  15523. libvirt, the default will be to use 'polkit' auth.
  15524. Defaults to @samp{"polkit"}.
  15525. @end deftypevr
  15526. @deftypevr {@code{libvirt-configuration} parameter} string auth-tcp
  15527. Authentication scheme for TCP sockets. If you don't enable SASL, then
  15528. all TCP traffic is cleartext. Don't do this outside of a dev/test
  15529. scenario.
  15530. Defaults to @samp{"sasl"}.
  15531. @end deftypevr
  15532. @deftypevr {@code{libvirt-configuration} parameter} string auth-tls
  15533. Authentication scheme for TLS sockets. TLS sockets already have
  15534. encryption provided by the TLS layer, and limited authentication is done
  15535. by certificates.
  15536. It is possible to make use of any SASL authentication mechanism as well,
  15537. by using 'sasl' for this option
  15538. Defaults to @samp{"none"}.
  15539. @end deftypevr
  15540. @deftypevr {@code{libvirt-configuration} parameter} optional-list access-drivers
  15541. API access control scheme.
  15542. By default an authenticated user is allowed access to all APIs. Access
  15543. drivers can place restrictions on this.
  15544. Defaults to @samp{()}.
  15545. @end deftypevr
  15546. @deftypevr {@code{libvirt-configuration} parameter} string key-file
  15547. Server key file path. If set to an empty string, then no private key is
  15548. loaded.
  15549. Defaults to @samp{""}.
  15550. @end deftypevr
  15551. @deftypevr {@code{libvirt-configuration} parameter} string cert-file
  15552. Server key file path. If set to an empty string, then no certificate is
  15553. loaded.
  15554. Defaults to @samp{""}.
  15555. @end deftypevr
  15556. @deftypevr {@code{libvirt-configuration} parameter} string ca-file
  15557. Server key file path. If set to an empty string, then no CA certificate
  15558. is loaded.
  15559. Defaults to @samp{""}.
  15560. @end deftypevr
  15561. @deftypevr {@code{libvirt-configuration} parameter} string crl-file
  15562. Certificate revocation list path. If set to an empty string, then no
  15563. CRL is loaded.
  15564. Defaults to @samp{""}.
  15565. @end deftypevr
  15566. @deftypevr {@code{libvirt-configuration} parameter} boolean tls-no-sanity-cert
  15567. Disable verification of our own server certificates.
  15568. When libvirtd starts it performs some sanity checks against its own
  15569. certificates.
  15570. Defaults to @samp{#f}.
  15571. @end deftypevr
  15572. @deftypevr {@code{libvirt-configuration} parameter} boolean tls-no-verify-cert
  15573. Disable verification of client certificates.
  15574. Client certificate verification is the primary authentication mechanism.
  15575. Any client which does not present a certificate signed by the CA will be
  15576. rejected.
  15577. Defaults to @samp{#f}.
  15578. @end deftypevr
  15579. @deftypevr {@code{libvirt-configuration} parameter} optional-list tls-allowed-dn-list
  15580. Whitelist of allowed x509 Distinguished Name.
  15581. Defaults to @samp{()}.
  15582. @end deftypevr
  15583. @deftypevr {@code{libvirt-configuration} parameter} optional-list sasl-allowed-usernames
  15584. Whitelist of allowed SASL usernames. The format for username depends on
  15585. the SASL authentication mechanism.
  15586. Defaults to @samp{()}.
  15587. @end deftypevr
  15588. @deftypevr {@code{libvirt-configuration} parameter} string tls-priority
  15589. Override the compile time default TLS priority string. The default is
  15590. usually "NORMAL" unless overridden at build time. Only set this is it
  15591. is desired for libvirt to deviate from the global default settings.
  15592. Defaults to @samp{"NORMAL"}.
  15593. @end deftypevr
  15594. @deftypevr {@code{libvirt-configuration} parameter} integer max-clients
  15595. Maximum number of concurrent client connections to allow over all
  15596. sockets combined.
  15597. Defaults to @samp{5000}.
  15598. @end deftypevr
  15599. @deftypevr {@code{libvirt-configuration} parameter} integer max-queued-clients
  15600. Maximum length of queue of connections waiting to be accepted by the
  15601. daemon. Note, that some protocols supporting retransmission may obey
  15602. this so that a later reattempt at connection succeeds.
  15603. Defaults to @samp{1000}.
  15604. @end deftypevr
  15605. @deftypevr {@code{libvirt-configuration} parameter} integer max-anonymous-clients
  15606. Maximum length of queue of accepted but not yet authenticated clients.
  15607. Set this to zero to turn this feature off
  15608. Defaults to @samp{20}.
  15609. @end deftypevr
  15610. @deftypevr {@code{libvirt-configuration} parameter} integer min-workers
  15611. Number of workers to start up initially.
  15612. Defaults to @samp{5}.
  15613. @end deftypevr
  15614. @deftypevr {@code{libvirt-configuration} parameter} integer max-workers
  15615. Maximum number of worker threads.
  15616. If the number of active clients exceeds @code{min-workers}, then more
  15617. threads are spawned, up to max_workers limit. Typically you'd want
  15618. max_workers to equal maximum number of clients allowed.
  15619. Defaults to @samp{20}.
  15620. @end deftypevr
  15621. @deftypevr {@code{libvirt-configuration} parameter} integer prio-workers
  15622. Number of priority workers. If all workers from above pool are stuck,
  15623. some calls marked as high priority (notably domainDestroy) can be
  15624. executed in this pool.
  15625. Defaults to @samp{5}.
  15626. @end deftypevr
  15627. @deftypevr {@code{libvirt-configuration} parameter} integer max-requests
  15628. Total global limit on concurrent RPC calls.
  15629. Defaults to @samp{20}.
  15630. @end deftypevr
  15631. @deftypevr {@code{libvirt-configuration} parameter} integer max-client-requests
  15632. Limit on concurrent requests from a single client connection. To avoid
  15633. one client monopolizing the server this should be a small fraction of
  15634. the global max_requests and max_workers parameter.
  15635. Defaults to @samp{5}.
  15636. @end deftypevr
  15637. @deftypevr {@code{libvirt-configuration} parameter} integer admin-min-workers
  15638. Same as @code{min-workers} but for the admin interface.
  15639. Defaults to @samp{1}.
  15640. @end deftypevr
  15641. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-workers
  15642. Same as @code{max-workers} but for the admin interface.
  15643. Defaults to @samp{5}.
  15644. @end deftypevr
  15645. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-clients
  15646. Same as @code{max-clients} but for the admin interface.
  15647. Defaults to @samp{5}.
  15648. @end deftypevr
  15649. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-queued-clients
  15650. Same as @code{max-queued-clients} but for the admin interface.
  15651. Defaults to @samp{5}.
  15652. @end deftypevr
  15653. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-client-requests
  15654. Same as @code{max-client-requests} but for the admin interface.
  15655. Defaults to @samp{5}.
  15656. @end deftypevr
  15657. @deftypevr {@code{libvirt-configuration} parameter} integer log-level
  15658. Logging level. 4 errors, 3 warnings, 2 information, 1 debug.
  15659. Defaults to @samp{3}.
  15660. @end deftypevr
  15661. @deftypevr {@code{libvirt-configuration} parameter} string log-filters
  15662. Logging filters.
  15663. A filter allows to select a different logging level for a given category
  15664. of logs The format for a filter is one of:
  15665. @itemize @bullet
  15666. @item
  15667. x:name
  15668. @item
  15669. x:+name
  15670. @end itemize
  15671. where @code{name} is a string which is matched against the category
  15672. given in the @code{VIR_LOG_INIT()} at the top of each libvirt source
  15673. file, e.g., "remote", "qemu", or "util.json" (the name in the filter can
  15674. be a substring of the full category name, in order to match multiple
  15675. similar categories), the optional "+" prefix tells libvirt to log stack
  15676. trace for each message matching name, and @code{x} is the minimal level
  15677. where matching messages should be logged:
  15678. @itemize @bullet
  15679. @item
  15680. 1: DEBUG
  15681. @item
  15682. 2: INFO
  15683. @item
  15684. 3: WARNING
  15685. @item
  15686. 4: ERROR
  15687. @end itemize
  15688. Multiple filters can be defined in a single filters statement, they just
  15689. need to be separated by spaces.
  15690. Defaults to @samp{"3:remote 4:event"}.
  15691. @end deftypevr
  15692. @deftypevr {@code{libvirt-configuration} parameter} string log-outputs
  15693. Logging outputs.
  15694. An output is one of the places to save logging information The format
  15695. for an output can be:
  15696. @table @code
  15697. @item x:stderr
  15698. output goes to stderr
  15699. @item x:syslog:name
  15700. use syslog for the output and use the given name as the ident
  15701. @item x:file:file_path
  15702. output to a file, with the given filepath
  15703. @item x:journald
  15704. output to journald logging system
  15705. @end table
  15706. In all case the x prefix is the minimal level, acting as a filter
  15707. @itemize @bullet
  15708. @item
  15709. 1: DEBUG
  15710. @item
  15711. 2: INFO
  15712. @item
  15713. 3: WARNING
  15714. @item
  15715. 4: ERROR
  15716. @end itemize
  15717. Multiple outputs can be defined, they just need to be separated by
  15718. spaces.
  15719. Defaults to @samp{"3:stderr"}.
  15720. @end deftypevr
  15721. @deftypevr {@code{libvirt-configuration} parameter} integer audit-level
  15722. Allows usage of the auditing subsystem to be altered
  15723. @itemize @bullet
  15724. @item
  15725. 0: disable all auditing
  15726. @item
  15727. 1: enable auditing, only if enabled on host
  15728. @item
  15729. 2: enable auditing, and exit if disabled on host.
  15730. @end itemize
  15731. Defaults to @samp{1}.
  15732. @end deftypevr
  15733. @deftypevr {@code{libvirt-configuration} parameter} boolean audit-logging
  15734. Send audit messages via libvirt logging infrastructure.
  15735. Defaults to @samp{#f}.
  15736. @end deftypevr
  15737. @deftypevr {@code{libvirt-configuration} parameter} optional-string host-uuid
  15738. Host UUID. UUID must not have all digits be the same.
  15739. Defaults to @samp{""}.
  15740. @end deftypevr
  15741. @deftypevr {@code{libvirt-configuration} parameter} string host-uuid-source
  15742. Source to read host UUID.
  15743. @itemize @bullet
  15744. @item
  15745. @code{smbios}: fetch the UUID from @code{dmidecode -s system-uuid}
  15746. @item
  15747. @code{machine-id}: fetch the UUID from @code{/etc/machine-id}
  15748. @end itemize
  15749. If @code{dmidecode} does not provide a valid UUID a temporary UUID will
  15750. be generated.
  15751. Defaults to @samp{"smbios"}.
  15752. @end deftypevr
  15753. @deftypevr {@code{libvirt-configuration} parameter} integer keepalive-interval
  15754. A keepalive message is sent to a client after @code{keepalive_interval}
  15755. seconds of inactivity to check if the client is still responding. If
  15756. set to -1, libvirtd will never send keepalive requests; however clients
  15757. can still send them and the daemon will send responses.
  15758. Defaults to @samp{5}.
  15759. @end deftypevr
  15760. @deftypevr {@code{libvirt-configuration} parameter} integer keepalive-count
  15761. Maximum number of keepalive messages that are allowed to be sent to the
  15762. client without getting any response before the connection is considered
  15763. broken.
  15764. In other words, the connection is automatically closed approximately
  15765. after @code{keepalive_interval * (keepalive_count + 1)} seconds since
  15766. the last message received from the client. When @code{keepalive-count}
  15767. is set to 0, connections will be automatically closed after
  15768. @code{keepalive-interval} seconds of inactivity without sending any
  15769. keepalive messages.
  15770. Defaults to @samp{5}.
  15771. @end deftypevr
  15772. @deftypevr {@code{libvirt-configuration} parameter} integer admin-keepalive-interval
  15773. Same as above but for admin interface.
  15774. Defaults to @samp{5}.
  15775. @end deftypevr
  15776. @deftypevr {@code{libvirt-configuration} parameter} integer admin-keepalive-count
  15777. Same as above but for admin interface.
  15778. Defaults to @samp{5}.
  15779. @end deftypevr
  15780. @deftypevr {@code{libvirt-configuration} parameter} integer ovs-timeout
  15781. Timeout for Open vSwitch calls.
  15782. The @code{ovs-vsctl} utility is used for the configuration and its
  15783. timeout option is set by default to 5 seconds to avoid potential
  15784. infinite waits blocking libvirt.
  15785. Defaults to @samp{5}.
  15786. @end deftypevr
  15787. @c %end of autogenerated docs
  15788. @subsubheading Virtlog daemon
  15789. The virtlogd service is a server side daemon component of libvirt that is
  15790. used to manage logs from virtual machine consoles.
  15791. This daemon is not used directly by libvirt client applications, rather it
  15792. is called on their behalf by @code{libvirtd}. By maintaining the logs in a
  15793. standalone daemon, the main @code{libvirtd} daemon can be restarted without
  15794. risk of losing logs. The @code{virtlogd} daemon has the ability to re-exec()
  15795. itself upon receiving @code{SIGUSR1}, to allow live upgrades without downtime.
  15796. @deffn {Scheme Variable} virtlog-service-type
  15797. This is the type of the virtlog daemon.
  15798. Its value must be a @code{virtlog-configuration}.
  15799. @example
  15800. (service virtlog-service-type
  15801. (virtlog-configuration
  15802. (max-clients 1000)))
  15803. @end example
  15804. @end deffn
  15805. @deftypevr {@code{virtlog-configuration} parameter} integer log-level
  15806. Logging level. 4 errors, 3 warnings, 2 information, 1 debug.
  15807. Defaults to @samp{3}.
  15808. @end deftypevr
  15809. @deftypevr {@code{virtlog-configuration} parameter} string log-filters
  15810. Logging filters.
  15811. A filter allows to select a different logging level for a given category
  15812. of logs The format for a filter is one of:
  15813. @itemize @bullet
  15814. @item
  15815. x:name
  15816. @item
  15817. x:+name
  15818. @end itemize
  15819. where @code{name} is a string which is matched against the category
  15820. given in the @code{VIR_LOG_INIT()} at the top of each libvirt source
  15821. file, e.g., "remote", "qemu", or "util.json" (the name in the filter can
  15822. be a substring of the full category name, in order to match multiple
  15823. similar categories), the optional "+" prefix tells libvirt to log stack
  15824. trace for each message matching name, and @code{x} is the minimal level
  15825. where matching messages should be logged:
  15826. @itemize @bullet
  15827. @item
  15828. 1: DEBUG
  15829. @item
  15830. 2: INFO
  15831. @item
  15832. 3: WARNING
  15833. @item
  15834. 4: ERROR
  15835. @end itemize
  15836. Multiple filters can be defined in a single filters statement, they just
  15837. need to be separated by spaces.
  15838. Defaults to @samp{"3:remote 4:event"}.
  15839. @end deftypevr
  15840. @deftypevr {@code{virtlog-configuration} parameter} string log-outputs
  15841. Logging outputs.
  15842. An output is one of the places to save logging information The format
  15843. for an output can be:
  15844. @table @code
  15845. @item x:stderr
  15846. output goes to stderr
  15847. @item x:syslog:name
  15848. use syslog for the output and use the given name as the ident
  15849. @item x:file:file_path
  15850. output to a file, with the given filepath
  15851. @item x:journald
  15852. output to journald logging system
  15853. @end table
  15854. In all case the x prefix is the minimal level, acting as a filter
  15855. @itemize @bullet
  15856. @item
  15857. 1: DEBUG
  15858. @item
  15859. 2: INFO
  15860. @item
  15861. 3: WARNING
  15862. @item
  15863. 4: ERROR
  15864. @end itemize
  15865. Multiple outputs can be defined, they just need to be separated by
  15866. spaces.
  15867. Defaults to @samp{"3:stderr"}.
  15868. @end deftypevr
  15869. @deftypevr {@code{virtlog-configuration} parameter} integer max-clients
  15870. Maximum number of concurrent client connections to allow over all
  15871. sockets combined.
  15872. Defaults to @samp{1024}.
  15873. @end deftypevr
  15874. @deftypevr {@code{virtlog-configuration} parameter} integer max-size
  15875. Maximum file size before rolling over.
  15876. Defaults to @samp{2MB}
  15877. @end deftypevr
  15878. @deftypevr {@code{virtlog-configuration} parameter} integer max-backups
  15879. Maximum number of backup files to keep.
  15880. Defaults to @samp{3}
  15881. @end deftypevr
  15882. @subsubheading Transparent Emulation with QEMU
  15883. @cindex emulation
  15884. @cindex @code{binfmt_misc}
  15885. @code{qemu-binfmt-service-type} provides support for transparent
  15886. emulation of program binaries built for different architectures---e.g.,
  15887. it allows you to transparently execute an ARMv7 program on an x86_64
  15888. machine. It achieves this by combining the @uref{https://www.qemu.org,
  15889. QEMU} emulator and the @code{binfmt_misc} feature of the kernel Linux.
  15890. @defvr {Scheme Variable} qemu-binfmt-service-type
  15891. This is the type of the QEMU/binfmt service for transparent emulation.
  15892. Its value must be a @code{qemu-binfmt-configuration} object, which
  15893. specifies the QEMU package to use as well as the architecture we want to
  15894. emulated:
  15895. @example
  15896. (service qemu-binfmt-service-type
  15897. (qemu-binfmt-configuration
  15898. (platforms (lookup-qemu-platforms "arm" "aarch64" "ppc"))))
  15899. @end example
  15900. In this example, we enable transparent emulation for the ARM and aarch64
  15901. platforms. Running @code{herd stop qemu-binfmt} turns it off, and
  15902. running @code{herd start qemu-binfmt} turns it back on (@pxref{Invoking
  15903. herd, the @command{herd} command,, shepherd, The GNU Shepherd Manual}).
  15904. @end defvr
  15905. @deftp {Data Type} qemu-binfmt-configuration
  15906. This is the configuration for the @code{qemu-binfmt} service.
  15907. @table @asis
  15908. @item @code{platforms} (default: @code{'()})
  15909. The list of emulated QEMU platforms. Each item must be a @dfn{platform
  15910. object} as returned by @code{lookup-qemu-platforms} (see below).
  15911. @item @code{guix-support?} (default: @code{#f})
  15912. When it is true, QEMU and all its dependencies are added to the build
  15913. environment of @command{guix-daemon} (@pxref{Invoking guix-daemon,
  15914. @code{--chroot-directory} option}). This allows the @code{binfmt_misc}
  15915. handlers to be used within the build environment, which in turn means
  15916. that you can transparently build programs for another architecture.
  15917. For example, let's suppose you're on an x86_64 machine and you have this
  15918. service:
  15919. @example
  15920. (service qemu-binfmt-service-type
  15921. (qemu-binfmt-configuration
  15922. (platforms (lookup-qemu-platforms "arm"))
  15923. (guix-support? #t)))
  15924. @end example
  15925. You can run:
  15926. @example
  15927. guix build -s armhf-linux inkscape
  15928. @end example
  15929. @noindent
  15930. and it will build Inkscape for ARMv7 @emph{as if it were a native
  15931. build}, transparently using QEMU to emulate the ARMv7 CPU. Pretty handy
  15932. if you'd like to test a package build for an architecture you don't have
  15933. access to!
  15934. @item @code{qemu} (default: @code{qemu})
  15935. The QEMU package to use.
  15936. @end table
  15937. @end deftp
  15938. @deffn {Scheme Procedure} lookup-qemu-platforms @var{platforms}@dots{}
  15939. Return the list of QEMU platform objects corresponding to
  15940. @var{platforms}@dots{}. @var{platforms} must be a list of strings
  15941. corresponding to platform names, such as @code{"arm"}, @code{"sparc"},
  15942. @code{"mips64el"}, and so on.
  15943. @end deffn
  15944. @deffn {Scheme Procedure} qemu-platform? @var{obj}
  15945. Return true if @var{obj} is a platform object.
  15946. @end deffn
  15947. @deffn {Scheme Procedure} qemu-platform-name @var{platform}
  15948. Return the name of @var{platform}---a string such as @code{"arm"}.
  15949. @end deffn
  15950. @node Version Control Services
  15951. @subsubsection Version Control Services
  15952. The @code{(gnu services version-control)} module provides a service to
  15953. allow remote access to local Git repositories. There are three options:
  15954. the @code{git-daemon-service}, which provides access to repositories via
  15955. the @code{git://} unsecured TCP-based protocol, extending the
  15956. @code{nginx} web server to proxy some requests to
  15957. @code{git-http-backend}, or providing a web interface with
  15958. @code{cgit-service-type}.
  15959. @deffn {Scheme Procedure} git-daemon-service [#:config (git-daemon-configuration)]
  15960. Return a service that runs @command{git daemon}, a simple TCP server to
  15961. expose repositories over the Git protocol for anonymous access.
  15962. The optional @var{config} argument should be a
  15963. @code{<git-daemon-configuration>} object, by default it allows read-only
  15964. access to exported@footnote{By creating the magic file
  15965. "git-daemon-export-ok" in the repository directory.} repositories under
  15966. @file{/srv/git}.
  15967. @end deffn
  15968. @deftp {Data Type} git-daemon-configuration
  15969. Data type representing the configuration for @code{git-daemon-service}.
  15970. @table @asis
  15971. @item @code{package} (default: @var{git})
  15972. Package object of the Git distributed version control system.
  15973. @item @code{export-all?} (default: @var{#f})
  15974. Whether to allow access for all Git repositories, even if they do not
  15975. have the @file{git-daemon-export-ok} file.
  15976. @item @code{base-path} (default: @file{/srv/git})
  15977. Whether to remap all the path requests as relative to the given path.
  15978. If you run git daemon with @var{(base-path "/srv/git")} on example.com,
  15979. then if you later try to pull @code{git://example.com/hello.git}, git
  15980. daemon will interpret the path as @code{/srv/git/hello.git}.
  15981. @item @code{user-path} (default: @var{#f})
  15982. Whether to allow @code{~user} notation to be used in requests. When
  15983. specified with empty string, requests to @code{git://host/~alice/foo} is
  15984. taken as a request to access @code{foo} repository in the home directory
  15985. of user @code{alice}. If @var{(user-path "path")} is specified, the
  15986. same request is taken as a request to access @code{path/foo} repository
  15987. in the home directory of user @code{alice}.
  15988. @item @code{listen} (default: @var{'()})
  15989. Whether to listen on specific IP addresses or hostnames, defaults to
  15990. all.
  15991. @item @code{port} (default: @var{#f})
  15992. Whether to listen on an alternative port, which defaults to 9418.
  15993. @item @code{whitelist} (default: @var{'()})
  15994. If not empty, only allow access to this list of directories.
  15995. @item @code{extra-options} (default: @var{'()})
  15996. Extra options will be passed to @code{git daemon}, please run
  15997. @command{man git-daemon} for more information.
  15998. @end table
  15999. @end deftp
  16000. The @code{git://} protocol lacks authentication. When you pull from a
  16001. repository fetched via @code{git://}, you don't know that the data you
  16002. receive was modified is really coming from the specified host, and you
  16003. have your connection is subject to eavesdropping. It's better to use an
  16004. authenticated and encrypted transport, such as @code{https}. Although Git allows you
  16005. to serve repositories using unsophisticated file-based web servers,
  16006. there is a faster protocol implemented by the @code{git-http-backend}
  16007. program. This program is the back-end of a proper Git web service. It
  16008. is designed to sit behind a FastCGI proxy. @xref{Web Services}, for more
  16009. on running the necessary @code{fcgiwrap} daemon.
  16010. Guix has a separate configuration data type for serving Git repositories
  16011. over HTTP.
  16012. @deftp {Data Type} git-http-configuration
  16013. Data type representing the configuration for @code{git-http-service}.
  16014. @table @asis
  16015. @item @code{package} (default: @var{git})
  16016. Package object of the Git distributed version control system.
  16017. @item @code{git-root} (default: @file{/srv/git})
  16018. Directory containing the Git repositories to expose to the world.
  16019. @item @code{export-all?} (default: @var{#f})
  16020. Whether to expose access for all Git repositories in @var{git-root},
  16021. even if they do not have the @file{git-daemon-export-ok} file.
  16022. @item @code{uri-path} (default: @file{/git/})
  16023. Path prefix for Git access. With the default @code{/git/} prefix, this
  16024. will map @code{http://@var{server}/git/@var{repo}.git} to
  16025. @code{/srv/git/@var{repo}.git}. Requests whose URI paths do not begin
  16026. with this prefix are not passed on to this Git instance.
  16027. @item @code{fcgiwrap-socket} (default: @code{127.0.0.1:9000})
  16028. The socket on which the @code{fcgiwrap} daemon is listening. @xref{Web
  16029. Services}.
  16030. @end table
  16031. @end deftp
  16032. There is no @code{git-http-service-type}, currently; instead you can
  16033. create an @code{nginx-location-configuration} from a
  16034. @code{git-http-configuration} and then add that location to a web
  16035. server.
  16036. @deffn {Scheme Procedure} git-http-nginx-location-configuration @
  16037. [config=(git-http-configuration)]
  16038. Compute an @code{nginx-location-configuration} that corresponds to the
  16039. given Git http configuration. An example nginx service definition to
  16040. serve the default @file{/srv/git} over HTTPS might be:
  16041. @example
  16042. (service nginx-service-type
  16043. (nginx-configuration
  16044. (server-blocks
  16045. (list
  16046. (nginx-server-configuration
  16047. (listen '("443 ssl"))
  16048. (server-name "git.my-host.org")
  16049. (ssl-certificate
  16050. "/etc/letsencrypt/live/git.my-host.org/fullchain.pem")
  16051. (ssl-certificate-key
  16052. "/etc/letsencrypt/live/git.my-host.org/privkey.pem")
  16053. (locations
  16054. (list
  16055. (git-http-nginx-location-configuration
  16056. (git-http-configuration (uri-path "/"))))))))))
  16057. @end example
  16058. This example assumes that you are using Let's Encrypt to get your TLS
  16059. certificate. @xref{Certificate Services}. The default @code{certbot}
  16060. service will redirect all HTTP traffic on @code{git.my-host.org} to
  16061. HTTPS. You will also need to add an @code{fcgiwrap} proxy to your
  16062. system services. @xref{Web Services}.
  16063. @end deffn
  16064. @subsubheading Cgit Service
  16065. @cindex Cgit service
  16066. @cindex Git, web interface
  16067. @uref{https://git.zx2c4.com/cgit/, Cgit} is a web frontend for Git
  16068. repositories written in C.
  16069. The following example will configure the service with default values.
  16070. By default, Cgit can be accessed on port 80 (@code{http://localhost:80}).
  16071. @example
  16072. (service cgit-service-type)
  16073. @end example
  16074. The @code{file-object} type designates either a file-like object
  16075. (@pxref{G-Expressions, file-like objects}) or a string.
  16076. @c %start of fragment
  16077. Available @code{cgit-configuration} fields are:
  16078. @deftypevr {@code{cgit-configuration} parameter} package package
  16079. The CGIT package.
  16080. @end deftypevr
  16081. @deftypevr {@code{cgit-configuration} parameter} nginx-server-configuration-list nginx
  16082. NGINX configuration.
  16083. @end deftypevr
  16084. @deftypevr {@code{cgit-configuration} parameter} file-object about-filter
  16085. Specifies a command which will be invoked to format the content of about
  16086. pages (both top-level and for each repository).
  16087. Defaults to @samp{""}.
  16088. @end deftypevr
  16089. @deftypevr {@code{cgit-configuration} parameter} string agefile
  16090. Specifies a path, relative to each repository path, which can be used to
  16091. specify the date and time of the youngest commit in the repository.
  16092. Defaults to @samp{""}.
  16093. @end deftypevr
  16094. @deftypevr {@code{cgit-configuration} parameter} file-object auth-filter
  16095. Specifies a command that will be invoked for authenticating repository
  16096. access.
  16097. Defaults to @samp{""}.
  16098. @end deftypevr
  16099. @deftypevr {@code{cgit-configuration} parameter} string branch-sort
  16100. Flag which, when set to @samp{age}, enables date ordering in the branch
  16101. ref list, and when set @samp{name} enables ordering by branch name.
  16102. Defaults to @samp{"name"}.
  16103. @end deftypevr
  16104. @deftypevr {@code{cgit-configuration} parameter} string cache-root
  16105. Path used to store the cgit cache entries.
  16106. Defaults to @samp{"/var/cache/cgit"}.
  16107. @end deftypevr
  16108. @deftypevr {@code{cgit-configuration} parameter} integer cache-static-ttl
  16109. Number which specifies the time-to-live, in minutes, for the cached
  16110. version of repository pages accessed with a fixed SHA1.
  16111. Defaults to @samp{-1}.
  16112. @end deftypevr
  16113. @deftypevr {@code{cgit-configuration} parameter} integer cache-dynamic-ttl
  16114. Number which specifies the time-to-live, in minutes, for the cached
  16115. version of repository pages accessed without a fixed SHA1.
  16116. Defaults to @samp{5}.
  16117. @end deftypevr
  16118. @deftypevr {@code{cgit-configuration} parameter} integer cache-repo-ttl
  16119. Number which specifies the time-to-live, in minutes, for the cached
  16120. version of the repository summary page.
  16121. Defaults to @samp{5}.
  16122. @end deftypevr
  16123. @deftypevr {@code{cgit-configuration} parameter} integer cache-root-ttl
  16124. Number which specifies the time-to-live, in minutes, for the cached
  16125. version of the repository index page.
  16126. Defaults to @samp{5}.
  16127. @end deftypevr
  16128. @deftypevr {@code{cgit-configuration} parameter} integer cache-scanrc-ttl
  16129. Number which specifies the time-to-live, in minutes, for the result of
  16130. scanning a path for Git repositories.
  16131. Defaults to @samp{15}.
  16132. @end deftypevr
  16133. @deftypevr {@code{cgit-configuration} parameter} integer cache-about-ttl
  16134. Number which specifies the time-to-live, in minutes, for the cached
  16135. version of the repository about page.
  16136. Defaults to @samp{15}.
  16137. @end deftypevr
  16138. @deftypevr {@code{cgit-configuration} parameter} integer cache-snapshot-ttl
  16139. Number which specifies the time-to-live, in minutes, for the cached
  16140. version of snapshots.
  16141. Defaults to @samp{5}.
  16142. @end deftypevr
  16143. @deftypevr {@code{cgit-configuration} parameter} integer cache-size
  16144. The maximum number of entries in the cgit cache. When set to @samp{0},
  16145. caching is disabled.
  16146. Defaults to @samp{0}.
  16147. @end deftypevr
  16148. @deftypevr {@code{cgit-configuration} parameter} boolean case-sensitive-sort?
  16149. Sort items in the repo list case sensitively.
  16150. Defaults to @samp{#t}.
  16151. @end deftypevr
  16152. @deftypevr {@code{cgit-configuration} parameter} list clone-prefix
  16153. List of common prefixes which, when combined with a repository URL,
  16154. generates valid clone URLs for the repository.
  16155. Defaults to @samp{()}.
  16156. @end deftypevr
  16157. @deftypevr {@code{cgit-configuration} parameter} list clone-url
  16158. List of @code{clone-url} templates.
  16159. Defaults to @samp{()}.
  16160. @end deftypevr
  16161. @deftypevr {@code{cgit-configuration} parameter} file-object commit-filter
  16162. Command which will be invoked to format commit messages.
  16163. Defaults to @samp{""}.
  16164. @end deftypevr
  16165. @deftypevr {@code{cgit-configuration} parameter} string commit-sort
  16166. Flag which, when set to @samp{date}, enables strict date ordering in the
  16167. commit log, and when set to @samp{topo} enables strict topological
  16168. ordering.
  16169. Defaults to @samp{"git log"}.
  16170. @end deftypevr
  16171. @deftypevr {@code{cgit-configuration} parameter} file-object css
  16172. URL which specifies the css document to include in all cgit pages.
  16173. Defaults to @samp{"/share/cgit/cgit.css"}.
  16174. @end deftypevr
  16175. @deftypevr {@code{cgit-configuration} parameter} file-object email-filter
  16176. Specifies a command which will be invoked to format names and email
  16177. address of committers, authors, and taggers, as represented in various
  16178. places throughout the cgit interface.
  16179. Defaults to @samp{""}.
  16180. @end deftypevr
  16181. @deftypevr {@code{cgit-configuration} parameter} boolean embedded?
  16182. Flag which, when set to @samp{#t}, will make cgit generate a HTML
  16183. fragment suitable for embedding in other HTML pages.
  16184. Defaults to @samp{#f}.
  16185. @end deftypevr
  16186. @deftypevr {@code{cgit-configuration} parameter} boolean enable-commit-graph?
  16187. Flag which, when set to @samp{#t}, will make cgit print an ASCII-art
  16188. commit history graph to the left of the commit messages in the
  16189. repository log page.
  16190. Defaults to @samp{#f}.
  16191. @end deftypevr
  16192. @deftypevr {@code{cgit-configuration} parameter} boolean enable-filter-overrides?
  16193. Flag which, when set to @samp{#t}, allows all filter settings to be
  16194. overridden in repository-specific cgitrc files.
  16195. Defaults to @samp{#f}.
  16196. @end deftypevr
  16197. @deftypevr {@code{cgit-configuration} parameter} boolean enable-follow-links?
  16198. Flag which, when set to @samp{#t}, allows users to follow a file in the
  16199. log view.
  16200. Defaults to @samp{#f}.
  16201. @end deftypevr
  16202. @deftypevr {@code{cgit-configuration} parameter} boolean enable-http-clone?
  16203. If set to @samp{#t}, cgit will act as an dumb HTTP endpoint for Git
  16204. clones.
  16205. Defaults to @samp{#t}.
  16206. @end deftypevr
  16207. @deftypevr {@code{cgit-configuration} parameter} boolean enable-index-links?
  16208. Flag which, when set to @samp{#t}, will make cgit generate extra links
  16209. "summary", "commit", "tree" for each repo in the repository index.
  16210. Defaults to @samp{#f}.
  16211. @end deftypevr
  16212. @deftypevr {@code{cgit-configuration} parameter} boolean enable-index-owner?
  16213. Flag which, when set to @samp{#t}, will make cgit display the owner of
  16214. each repo in the repository index.
  16215. Defaults to @samp{#t}.
  16216. @end deftypevr
  16217. @deftypevr {@code{cgit-configuration} parameter} boolean enable-log-filecount?
  16218. Flag which, when set to @samp{#t}, will make cgit print the number of
  16219. modified files for each commit on the repository log page.
  16220. Defaults to @samp{#f}.
  16221. @end deftypevr
  16222. @deftypevr {@code{cgit-configuration} parameter} boolean enable-log-linecount?
  16223. Flag which, when set to @samp{#t}, will make cgit print the number of
  16224. added and removed lines for each commit on the repository log page.
  16225. Defaults to @samp{#f}.
  16226. @end deftypevr
  16227. @deftypevr {@code{cgit-configuration} parameter} boolean enable-remote-branches?
  16228. Flag which, when set to @code{#t}, will make cgit display remote
  16229. branches in the summary and refs views.
  16230. Defaults to @samp{#f}.
  16231. @end deftypevr
  16232. @deftypevr {@code{cgit-configuration} parameter} boolean enable-subject-links?
  16233. Flag which, when set to @code{1}, will make cgit use the subject of the
  16234. parent commit as link text when generating links to parent commits in
  16235. commit view.
  16236. Defaults to @samp{#f}.
  16237. @end deftypevr
  16238. @deftypevr {@code{cgit-configuration} parameter} boolean enable-html-serving?
  16239. Flag which, when set to @samp{#t}, will make cgit use the subject of the
  16240. parent commit as link text when generating links to parent commits in
  16241. commit view.
  16242. Defaults to @samp{#f}.
  16243. @end deftypevr
  16244. @deftypevr {@code{cgit-configuration} parameter} boolean enable-tree-linenumbers?
  16245. Flag which, when set to @samp{#t}, will make cgit generate linenumber
  16246. links for plaintext blobs printed in the tree view.
  16247. Defaults to @samp{#t}.
  16248. @end deftypevr
  16249. @deftypevr {@code{cgit-configuration} parameter} boolean enable-git-config?
  16250. Flag which, when set to @samp{#f}, will allow cgit to use Git config to
  16251. set any repo specific settings.
  16252. Defaults to @samp{#f}.
  16253. @end deftypevr
  16254. @deftypevr {@code{cgit-configuration} parameter} file-object favicon
  16255. URL used as link to a shortcut icon for cgit.
  16256. Defaults to @samp{"/favicon.ico"}.
  16257. @end deftypevr
  16258. @deftypevr {@code{cgit-configuration} parameter} string footer
  16259. The content of the file specified with this option will be included
  16260. verbatim at the bottom of all pages (i.e.@: it replaces the standard
  16261. "generated by..."@: message).
  16262. Defaults to @samp{""}.
  16263. @end deftypevr
  16264. @deftypevr {@code{cgit-configuration} parameter} string head-include
  16265. The content of the file specified with this option will be included
  16266. verbatim in the HTML HEAD section on all pages.
  16267. Defaults to @samp{""}.
  16268. @end deftypevr
  16269. @deftypevr {@code{cgit-configuration} parameter} string header
  16270. The content of the file specified with this option will be included
  16271. verbatim at the top of all pages.
  16272. Defaults to @samp{""}.
  16273. @end deftypevr
  16274. @deftypevr {@code{cgit-configuration} parameter} file-object include
  16275. Name of a configfile to include before the rest of the current config-
  16276. file is parsed.
  16277. Defaults to @samp{""}.
  16278. @end deftypevr
  16279. @deftypevr {@code{cgit-configuration} parameter} string index-header
  16280. The content of the file specified with this option will be included
  16281. verbatim above the repository index.
  16282. Defaults to @samp{""}.
  16283. @end deftypevr
  16284. @deftypevr {@code{cgit-configuration} parameter} string index-info
  16285. The content of the file specified with this option will be included
  16286. verbatim below the heading on the repository index page.
  16287. Defaults to @samp{""}.
  16288. @end deftypevr
  16289. @deftypevr {@code{cgit-configuration} parameter} boolean local-time?
  16290. Flag which, if set to @samp{#t}, makes cgit print commit and tag times
  16291. in the servers timezone.
  16292. Defaults to @samp{#f}.
  16293. @end deftypevr
  16294. @deftypevr {@code{cgit-configuration} parameter} file-object logo
  16295. URL which specifies the source of an image which will be used as a logo
  16296. on all cgit pages.
  16297. Defaults to @samp{"/share/cgit/cgit.png"}.
  16298. @end deftypevr
  16299. @deftypevr {@code{cgit-configuration} parameter} string logo-link
  16300. URL loaded when clicking on the cgit logo image.
  16301. Defaults to @samp{""}.
  16302. @end deftypevr
  16303. @deftypevr {@code{cgit-configuration} parameter} file-object owner-filter
  16304. Command which will be invoked to format the Owner column of the main
  16305. page.
  16306. Defaults to @samp{""}.
  16307. @end deftypevr
  16308. @deftypevr {@code{cgit-configuration} parameter} integer max-atom-items
  16309. Number of items to display in atom feeds view.
  16310. Defaults to @samp{10}.
  16311. @end deftypevr
  16312. @deftypevr {@code{cgit-configuration} parameter} integer max-commit-count
  16313. Number of entries to list per page in "log" view.
  16314. Defaults to @samp{50}.
  16315. @end deftypevr
  16316. @deftypevr {@code{cgit-configuration} parameter} integer max-message-length
  16317. Number of commit message characters to display in "log" view.
  16318. Defaults to @samp{80}.
  16319. @end deftypevr
  16320. @deftypevr {@code{cgit-configuration} parameter} integer max-repo-count
  16321. Specifies the number of entries to list per page on the repository index
  16322. page.
  16323. Defaults to @samp{50}.
  16324. @end deftypevr
  16325. @deftypevr {@code{cgit-configuration} parameter} integer max-repodesc-length
  16326. Specifies the maximum number of repo description characters to display
  16327. on the repository index page.
  16328. Defaults to @samp{80}.
  16329. @end deftypevr
  16330. @deftypevr {@code{cgit-configuration} parameter} integer max-blob-size
  16331. Specifies the maximum size of a blob to display HTML for in KBytes.
  16332. Defaults to @samp{0}.
  16333. @end deftypevr
  16334. @deftypevr {@code{cgit-configuration} parameter} string max-stats
  16335. Maximum statistics period. Valid values are @samp{week},@samp{month},
  16336. @samp{quarter} and @samp{year}.
  16337. Defaults to @samp{""}.
  16338. @end deftypevr
  16339. @deftypevr {@code{cgit-configuration} parameter} mimetype-alist mimetype
  16340. Mimetype for the specified filename extension.
  16341. Defaults to @samp{((gif "image/gif") (html "text/html") (jpg
  16342. "image/jpeg") (jpeg "image/jpeg") (pdf "application/pdf") (png
  16343. "image/png") (svg "image/svg+xml"))}.
  16344. @end deftypevr
  16345. @deftypevr {@code{cgit-configuration} parameter} file-object mimetype-file
  16346. Specifies the file to use for automatic mimetype lookup.
  16347. Defaults to @samp{""}.
  16348. @end deftypevr
  16349. @deftypevr {@code{cgit-configuration} parameter} string module-link
  16350. Text which will be used as the formatstring for a hyperlink when a
  16351. submodule is printed in a directory listing.
  16352. Defaults to @samp{""}.
  16353. @end deftypevr
  16354. @deftypevr {@code{cgit-configuration} parameter} boolean nocache?
  16355. If set to the value @samp{#t} caching will be disabled.
  16356. Defaults to @samp{#f}.
  16357. @end deftypevr
  16358. @deftypevr {@code{cgit-configuration} parameter} boolean noplainemail?
  16359. If set to @samp{#t} showing full author email addresses will be
  16360. disabled.
  16361. Defaults to @samp{#f}.
  16362. @end deftypevr
  16363. @deftypevr {@code{cgit-configuration} parameter} boolean noheader?
  16364. Flag which, when set to @samp{#t}, will make cgit omit the standard
  16365. header on all pages.
  16366. Defaults to @samp{#f}.
  16367. @end deftypevr
  16368. @deftypevr {@code{cgit-configuration} parameter} project-list project-list
  16369. A list of subdirectories inside of @code{repository-directory}, relative
  16370. to it, that should loaded as Git repositories. An empty list means that
  16371. all subdirectories will be loaded.
  16372. Defaults to @samp{()}.
  16373. @end deftypevr
  16374. @deftypevr {@code{cgit-configuration} parameter} file-object readme
  16375. Text which will be used as default value for @code{cgit-repo-readme}.
  16376. Defaults to @samp{""}.
  16377. @end deftypevr
  16378. @deftypevr {@code{cgit-configuration} parameter} boolean remove-suffix?
  16379. If set to @code{#t} and @code{repository-directory} is enabled, if any
  16380. repositories are found with a suffix of @code{.git}, this suffix will be
  16381. removed for the URL and name.
  16382. Defaults to @samp{#f}.
  16383. @end deftypevr
  16384. @deftypevr {@code{cgit-configuration} parameter} integer renamelimit
  16385. Maximum number of files to consider when detecting renames.
  16386. Defaults to @samp{-1}.
  16387. @end deftypevr
  16388. @deftypevr {@code{cgit-configuration} parameter} string repository-sort
  16389. The way in which repositories in each section are sorted.
  16390. Defaults to @samp{""}.
  16391. @end deftypevr
  16392. @deftypevr {@code{cgit-configuration} parameter} robots-list robots
  16393. Text used as content for the @code{robots} meta-tag.
  16394. Defaults to @samp{("noindex" "nofollow")}.
  16395. @end deftypevr
  16396. @deftypevr {@code{cgit-configuration} parameter} string root-desc
  16397. Text printed below the heading on the repository index page.
  16398. Defaults to @samp{"a fast webinterface for the git dscm"}.
  16399. @end deftypevr
  16400. @deftypevr {@code{cgit-configuration} parameter} string root-readme
  16401. The content of the file specified with this option will be included
  16402. verbatim below thef "about" link on the repository index page.
  16403. Defaults to @samp{""}.
  16404. @end deftypevr
  16405. @deftypevr {@code{cgit-configuration} parameter} string root-title
  16406. Text printed as heading on the repository index page.
  16407. Defaults to @samp{""}.
  16408. @end deftypevr
  16409. @deftypevr {@code{cgit-configuration} parameter} boolean scan-hidden-path
  16410. If set to @samp{#t} and repository-directory is enabled,
  16411. repository-directory will recurse into directories whose name starts
  16412. with a period. Otherwise, repository-directory will stay away from such
  16413. directories, considered as "hidden". Note that this does not apply to
  16414. the ".git" directory in non-bare repos.
  16415. Defaults to @samp{#f}.
  16416. @end deftypevr
  16417. @deftypevr {@code{cgit-configuration} parameter} list snapshots
  16418. Text which specifies the default set of snapshot formats that cgit
  16419. generates links for.
  16420. Defaults to @samp{()}.
  16421. @end deftypevr
  16422. @deftypevr {@code{cgit-configuration} parameter} repository-directory repository-directory
  16423. Name of the directory to scan for repositories (represents
  16424. @code{scan-path}).
  16425. Defaults to @samp{"/srv/git"}.
  16426. @end deftypevr
  16427. @deftypevr {@code{cgit-configuration} parameter} string section
  16428. The name of the current repository section - all repositories defined
  16429. after this option will inherit the current section name.
  16430. Defaults to @samp{""}.
  16431. @end deftypevr
  16432. @deftypevr {@code{cgit-configuration} parameter} string section-sort
  16433. Flag which, when set to @samp{1}, will sort the sections on the
  16434. repository listing by name.
  16435. Defaults to @samp{""}.
  16436. @end deftypevr
  16437. @deftypevr {@code{cgit-configuration} parameter} integer section-from-path
  16438. A number which, if defined prior to repository-directory, specifies how
  16439. many path elements from each repo path to use as a default section name.
  16440. Defaults to @samp{0}.
  16441. @end deftypevr
  16442. @deftypevr {@code{cgit-configuration} parameter} boolean side-by-side-diffs?
  16443. If set to @samp{#t} shows side-by-side diffs instead of unidiffs per
  16444. default.
  16445. Defaults to @samp{#f}.
  16446. @end deftypevr
  16447. @deftypevr {@code{cgit-configuration} parameter} file-object source-filter
  16448. Specifies a command which will be invoked to format plaintext blobs in
  16449. the tree view.
  16450. Defaults to @samp{""}.
  16451. @end deftypevr
  16452. @deftypevr {@code{cgit-configuration} parameter} integer summary-branches
  16453. Specifies the number of branches to display in the repository "summary"
  16454. view.
  16455. Defaults to @samp{10}.
  16456. @end deftypevr
  16457. @deftypevr {@code{cgit-configuration} parameter} integer summary-log
  16458. Specifies the number of log entries to display in the repository
  16459. "summary" view.
  16460. Defaults to @samp{10}.
  16461. @end deftypevr
  16462. @deftypevr {@code{cgit-configuration} parameter} integer summary-tags
  16463. Specifies the number of tags to display in the repository "summary"
  16464. view.
  16465. Defaults to @samp{10}.
  16466. @end deftypevr
  16467. @deftypevr {@code{cgit-configuration} parameter} string strict-export
  16468. Filename which, if specified, needs to be present within the repository
  16469. for cgit to allow access to that repository.
  16470. Defaults to @samp{""}.
  16471. @end deftypevr
  16472. @deftypevr {@code{cgit-configuration} parameter} string virtual-root
  16473. URL which, if specified, will be used as root for all cgit links.
  16474. Defaults to @samp{"/"}.
  16475. @end deftypevr
  16476. @deftypevr {@code{cgit-configuration} parameter} repository-cgit-configuration-list repositories
  16477. A list of @dfn{cgit-repo} records to use with config.
  16478. Defaults to @samp{()}.
  16479. Available @code{repository-cgit-configuration} fields are:
  16480. @deftypevr {@code{repository-cgit-configuration} parameter} repo-list snapshots
  16481. A mask of snapshot formats for this repo that cgit generates links for,
  16482. restricted by the global @code{snapshots} setting.
  16483. Defaults to @samp{()}.
  16484. @end deftypevr
  16485. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object source-filter
  16486. Override the default @code{source-filter}.
  16487. Defaults to @samp{""}.
  16488. @end deftypevr
  16489. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string url
  16490. The relative URL used to access the repository.
  16491. Defaults to @samp{""}.
  16492. @end deftypevr
  16493. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object about-filter
  16494. Override the default @code{about-filter}.
  16495. Defaults to @samp{""}.
  16496. @end deftypevr
  16497. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string branch-sort
  16498. Flag which, when set to @samp{age}, enables date ordering in the branch
  16499. ref list, and when set to @samp{name} enables ordering by branch name.
  16500. Defaults to @samp{""}.
  16501. @end deftypevr
  16502. @deftypevr {@code{repository-cgit-configuration} parameter} repo-list clone-url
  16503. A list of URLs which can be used to clone repo.
  16504. Defaults to @samp{()}.
  16505. @end deftypevr
  16506. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object commit-filter
  16507. Override the default @code{commit-filter}.
  16508. Defaults to @samp{""}.
  16509. @end deftypevr
  16510. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string commit-sort
  16511. Flag which, when set to @samp{date}, enables strict date ordering in the
  16512. commit log, and when set to @samp{topo} enables strict topological
  16513. ordering.
  16514. Defaults to @samp{""}.
  16515. @end deftypevr
  16516. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string defbranch
  16517. The name of the default branch for this repository. If no such branch
  16518. exists in the repository, the first branch name (when sorted) is used as
  16519. default instead. By default branch pointed to by HEAD, or "master" if
  16520. there is no suitable HEAD.
  16521. Defaults to @samp{""}.
  16522. @end deftypevr
  16523. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string desc
  16524. The value to show as repository description.
  16525. Defaults to @samp{""}.
  16526. @end deftypevr
  16527. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string homepage
  16528. The value to show as repository homepage.
  16529. Defaults to @samp{""}.
  16530. @end deftypevr
  16531. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object email-filter
  16532. Override the default @code{email-filter}.
  16533. Defaults to @samp{""}.
  16534. @end deftypevr
  16535. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-commit-graph?
  16536. A flag which can be used to disable the global setting
  16537. @code{enable-commit-graph?}.
  16538. Defaults to @samp{disabled}.
  16539. @end deftypevr
  16540. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-log-filecount?
  16541. A flag which can be used to disable the global setting
  16542. @code{enable-log-filecount?}.
  16543. Defaults to @samp{disabled}.
  16544. @end deftypevr
  16545. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-log-linecount?
  16546. A flag which can be used to disable the global setting
  16547. @code{enable-log-linecount?}.
  16548. Defaults to @samp{disabled}.
  16549. @end deftypevr
  16550. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-remote-branches?
  16551. Flag which, when set to @code{#t}, will make cgit display remote
  16552. branches in the summary and refs views.
  16553. Defaults to @samp{disabled}.
  16554. @end deftypevr
  16555. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-subject-links?
  16556. A flag which can be used to override the global setting
  16557. @code{enable-subject-links?}.
  16558. Defaults to @samp{disabled}.
  16559. @end deftypevr
  16560. @deftypevr {@code{repository-cgit-configuration} parameter} maybe-repo-boolean enable-html-serving?
  16561. A flag which can be used to override the global setting
  16562. @code{enable-html-serving?}.
  16563. Defaults to @samp{disabled}.
  16564. @end deftypevr
  16565. @deftypevr {@code{repository-cgit-configuration} parameter} repo-boolean hide?
  16566. Flag which, when set to @code{#t}, hides the repository from the
  16567. repository index.
  16568. Defaults to @samp{#f}.
  16569. @end deftypevr
  16570. @deftypevr {@code{repository-cgit-configuration} parameter} repo-boolean ignore?
  16571. Flag which, when set to @samp{#t}, ignores the repository.
  16572. Defaults to @samp{#f}.
  16573. @end deftypevr
  16574. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object logo
  16575. URL which specifies the source of an image which will be used as a logo
  16576. on this repo’s pages.
  16577. Defaults to @samp{""}.
  16578. @end deftypevr
  16579. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string logo-link
  16580. URL loaded when clicking on the cgit logo image.
  16581. Defaults to @samp{""}.
  16582. @end deftypevr
  16583. @deftypevr {@code{repository-cgit-configuration} parameter} repo-file-object owner-filter
  16584. Override the default @code{owner-filter}.
  16585. Defaults to @samp{""}.
  16586. @end deftypevr
  16587. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string module-link
  16588. Text which will be used as the formatstring for a hyperlink when a
  16589. submodule is printed in a directory listing. The arguments for the
  16590. formatstring are the path and SHA1 of the submodule commit.
  16591. Defaults to @samp{""}.
  16592. @end deftypevr
  16593. @deftypevr {@code{repository-cgit-configuration} parameter} module-link-path module-link-path
  16594. Text which will be used as the formatstring for a hyperlink when a
  16595. submodule with the specified subdirectory path is printed in a directory
  16596. listing.
  16597. Defaults to @samp{()}.
  16598. @end deftypevr
  16599. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string max-stats
  16600. Override the default maximum statistics period.
  16601. Defaults to @samp{""}.
  16602. @end deftypevr
  16603. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string name
  16604. The value to show as repository name.
  16605. Defaults to @samp{""}.
  16606. @end deftypevr
  16607. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string owner
  16608. A value used to identify the owner of the repository.
  16609. Defaults to @samp{""}.
  16610. @end deftypevr
  16611. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string path
  16612. An absolute path to the repository directory.
  16613. Defaults to @samp{""}.
  16614. @end deftypevr
  16615. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string readme
  16616. A path (relative to repo) which specifies a file to include verbatim as
  16617. the "About" page for this repo.
  16618. Defaults to @samp{""}.
  16619. @end deftypevr
  16620. @deftypevr {@code{repository-cgit-configuration} parameter} repo-string section
  16621. The name of the current repository section - all repositories defined
  16622. after this option will inherit the current section name.
  16623. Defaults to @samp{""}.
  16624. @end deftypevr
  16625. @deftypevr {@code{repository-cgit-configuration} parameter} repo-list extra-options
  16626. Extra options will be appended to cgitrc file.
  16627. Defaults to @samp{()}.
  16628. @end deftypevr
  16629. @end deftypevr
  16630. @deftypevr {@code{cgit-configuration} parameter} list extra-options
  16631. Extra options will be appended to cgitrc file.
  16632. Defaults to @samp{()}.
  16633. @end deftypevr
  16634. @c %end of fragment
  16635. However, it could be that you just want to get a @code{cgitrc} up and
  16636. running. In that case, you can pass an @code{opaque-cgit-configuration}
  16637. as a record to @code{cgit-service-type}. As its name indicates, an
  16638. opaque configuration does not have easy reflective capabilities.
  16639. Available @code{opaque-cgit-configuration} fields are:
  16640. @deftypevr {@code{opaque-cgit-configuration} parameter} package cgit
  16641. The cgit package.
  16642. @end deftypevr
  16643. @deftypevr {@code{opaque-cgit-configuration} parameter} string string
  16644. The contents of the @code{cgitrc}, as a string.
  16645. @end deftypevr
  16646. For example, if your @code{cgitrc} is just the empty string, you
  16647. could instantiate a cgit service like this:
  16648. @example
  16649. (service cgit-service-type
  16650. (opaque-cgit-configuration
  16651. (cgitrc "")))
  16652. @end example
  16653. @subsubheading Gitolite Service
  16654. @cindex Gitolite service
  16655. @cindex Git, hosting
  16656. @uref{http://gitolite.com/gitolite/, Gitolite} is a tool for hosting Git
  16657. repositories on a central server.
  16658. Gitolite can handle multiple repositories and users, and supports flexible
  16659. configuration of the permissions for the users on the repositories.
  16660. The following example will configure Gitolite using the default @code{git}
  16661. user, and the provided SSH public key.
  16662. @example
  16663. (service gitolite-service-type
  16664. (gitolite-configuration
  16665. (admin-pubkey (plain-file
  16666. "yourname.pub"
  16667. "ssh-rsa AAAA... guix@@example.com"))))
  16668. @end example
  16669. Gitolite is configured through a special admin repository which you can clone,
  16670. for example, if you setup Gitolite on @code{example.com}, you would run the
  16671. following command to clone the admin repository.
  16672. @example
  16673. git clone git@@example.com:gitolite-admin
  16674. @end example
  16675. When the Gitolite service is activated, the provided @code{admin-pubkey} will
  16676. be inserted in to the @file{keydir} directory in the gitolite-admin
  16677. repository. If this results in a change in the repository, it will be
  16678. committed using the message ``gitolite setup by GNU Guix''.
  16679. @deftp {Data Type} gitolite-configuration
  16680. Data type representing the configuration for @code{gitolite-service-type}.
  16681. @table @asis
  16682. @item @code{package} (default: @var{gitolite})
  16683. Gitolite package to use.
  16684. @item @code{user} (default: @var{git})
  16685. User to use for Gitolite. This will be user that you use when accessing
  16686. Gitolite over SSH.
  16687. @item @code{group} (default: @var{git})
  16688. Group to use for Gitolite.
  16689. @item @code{home-directory} (default: @var{"/var/lib/gitolite"})
  16690. Directory in which to store the Gitolite configuration and repositories.
  16691. @item @code{rc-file} (default: @var{(gitolite-rc-file)})
  16692. A ``file-like'' object (@pxref{G-Expressions, file-like objects}),
  16693. representing the configuration for Gitolite.
  16694. @item @code{admin-pubkey} (default: @var{#f})
  16695. A ``file-like'' object (@pxref{G-Expressions, file-like objects}) used to
  16696. setup Gitolite. This will be inserted in to the @file{keydir} directory
  16697. within the gitolite-admin repository.
  16698. To specify the SSH key as a string, use the @code{plain-file} function.
  16699. @example
  16700. (plain-file "yourname.pub" "ssh-rsa AAAA... guix@@example.com")
  16701. @end example
  16702. @end table
  16703. @end deftp
  16704. @deftp {Data Type} gitolite-rc-file
  16705. Data type representing the Gitolite RC file.
  16706. @table @asis
  16707. @item @code{umask} (default: @code{#o0077})
  16708. This controls the permissions Gitolite sets on the repositories and their
  16709. contents.
  16710. A value like @code{#o0027} will give read access to the group used by Gitolite
  16711. (by default: @code{git}). This is necessary when using Gitolite with software
  16712. like cgit or gitweb.
  16713. @item @code{git-config-keys} (default: @code{""})
  16714. Gitolite allows you to set git config values using the "config" keyword. This
  16715. setting allows control over the config keys to accept.
  16716. @item @code{roles} (default: @code{'(("READERS" . 1) ("WRITERS" . ))})
  16717. Set the role names allowed to be used by users running the perms command.
  16718. @item @code{enable} (default: @code{'("help" "desc" "info" "perms" "writable" "ssh-authkeys" "git-config" "daemon" "gitweb")})
  16719. This setting controls the commands and features to enable within Gitolite.
  16720. @end table
  16721. @end deftp
  16722. @node Game Services
  16723. @subsubsection Game Services
  16724. @subsubheading The Battle for Wesnoth Service
  16725. @cindex wesnothd
  16726. @uref{https://wesnoth.org, The Battle for Wesnoth} is a fantasy, turn
  16727. based tactical strategy game, with several single player campaigns, and
  16728. multiplayer games (both networked and local).
  16729. @defvar {Scheme Variable} wesnothd-service-type
  16730. Service type for the wesnothd service. Its value must be a
  16731. @code{wesnothd-configuration} object. To run wesnothd in the default
  16732. configuration, instantiate it as:
  16733. @example
  16734. (service wesnothd-service-type)
  16735. @end example
  16736. @end defvar
  16737. @deftp {Data Type} wesnothd-configuration
  16738. Data type representing the configuration of @command{wesnothd}.
  16739. @table @asis
  16740. @item @code{package} (default: @code{wesnoth-server})
  16741. The wesnoth server package to use.
  16742. @item @code{port} (default: @code{15000})
  16743. The port to bind the server to.
  16744. @end table
  16745. @end deftp
  16746. @node Miscellaneous Services
  16747. @subsubsection Miscellaneous Services
  16748. @cindex fingerprint
  16749. @subsubheading Fingerprint Service
  16750. The @code{(gnu services fingerprint)} module provides a DBus service to
  16751. read and identify fingerprints via a fingerprint sensor.
  16752. @defvr {Scheme Variable} fprintd-service-type
  16753. The service type for @command{fprintd}, which provides the fingerprint
  16754. reading capability.
  16755. @example
  16756. (service fprintd-service-type)
  16757. @end example
  16758. @end defvr
  16759. @cindex sysctl
  16760. @subsubheading System Control Service
  16761. The @code{(gnu services sysctl)} provides a service to configure kernel
  16762. parameters at boot.
  16763. @defvr {Scheme Variable} sysctl-service-type
  16764. The service type for @command{sysctl}, which modifies kernel parameters
  16765. under @file{/proc/sys/}. To enable IPv4 forwarding, it can be
  16766. instantiated as:
  16767. @example
  16768. (service sysctl-service-type
  16769. (sysctl-configuration
  16770. (settings '(("net.ipv4.ip_forward" . "1")))))
  16771. @end example
  16772. @end defvr
  16773. @deftp {Data Type} sysctl-configuration
  16774. The data type representing the configuration of @command{sysctl}.
  16775. @table @asis
  16776. @item @code{sysctl} (default: @code{(file-append procps "/sbin/sysctl"})
  16777. The @command{sysctl} executable to use.
  16778. @item @code{settings} (default: @code{'()})
  16779. An association list specifies kernel parameters and their values.
  16780. @end table
  16781. @end deftp
  16782. @cindex pcscd
  16783. @subsubheading PC/SC Smart Card Daemon Service
  16784. The @code{(gnu services security-token)} module provides the following service
  16785. to run @command{pcscd}, the PC/SC Smart Card Daemon. @command{pcscd} is the
  16786. daemon program for pcsc-lite and the MuscleCard framework. It is a resource
  16787. manager that coordinates communications with smart card readers, smart cards
  16788. and cryptographic tokens that are connected to the system.
  16789. @defvr {Scheme Variable} pcscd-service-type
  16790. Service type for the @command{pcscd} service. Its value must be a
  16791. @code{pcscd-configuration} object. To run pcscd in the default
  16792. configuration, instantiate it as:
  16793. @example
  16794. (service pcscd-service-type)
  16795. @end example
  16796. @end defvr
  16797. @deftp {Data Type} pcscd-configuration
  16798. The data type representing the configuration of @command{pcscd}.
  16799. @table @asis
  16800. @item @code{pcsc-lite} (default: @code{pcsc-lite})
  16801. The pcsc-lite package that provides pcscd.
  16802. @item @code{usb-drivers} (default: @code{(list ccid)})
  16803. List of packages that provide USB drivers to pcscd. Drivers are expected to be
  16804. under @file{pcsc/drivers} in the store directory of the package.
  16805. @end table
  16806. @end deftp
  16807. @cindex lirc
  16808. @subsubheading Lirc Service
  16809. The @code{(gnu services lirc)} module provides the following service.
  16810. @deffn {Scheme Procedure} lirc-service [#:lirc lirc] @
  16811. [#:device #f] [#:driver #f] [#:config-file #f] @
  16812. [#:extra-options '()]
  16813. Return a service that runs @url{http://www.lirc.org,LIRC}, a daemon that
  16814. decodes infrared signals from remote controls.
  16815. Optionally, @var{device}, @var{driver} and @var{config-file}
  16816. (configuration file name) may be specified. See @command{lircd} manual
  16817. for details.
  16818. Finally, @var{extra-options} is a list of additional command-line options
  16819. passed to @command{lircd}.
  16820. @end deffn
  16821. @cindex spice
  16822. @subsubheading Spice Service
  16823. The @code{(gnu services spice)} module provides the following service.
  16824. @deffn {Scheme Procedure} spice-vdagent-service [#:spice-vdagent]
  16825. Returns a service that runs @url{http://www.spice-space.org,VDAGENT}, a daemon
  16826. that enables sharing the clipboard with a vm and setting the guest display
  16827. resolution when the graphical console window resizes.
  16828. @end deffn
  16829. @subsubsection Dictionary Services
  16830. @cindex dictionary
  16831. The @code{(gnu services dict)} module provides the following service:
  16832. @deffn {Scheme Procedure} dicod-service [#:config (dicod-configuration)]
  16833. Return a service that runs the @command{dicod} daemon, an implementation
  16834. of DICT server (@pxref{Dicod,,, dico, GNU Dico Manual}).
  16835. The optional @var{config} argument specifies the configuration for
  16836. @command{dicod}, which should be a @code{<dicod-configuration>} object, by
  16837. default it serves the GNU Collaborative International Dictonary of English.
  16838. You can add @command{open localhost} to your @file{~/.dico} file to make
  16839. @code{localhost} the default server for @command{dico} client
  16840. (@pxref{Initialization File,,, dico, GNU Dico Manual}).
  16841. @end deffn
  16842. @deftp {Data Type} dicod-configuration
  16843. Data type representing the configuration of dicod.
  16844. @table @asis
  16845. @item @code{dico} (default: @var{dico})
  16846. Package object of the GNU Dico dictionary server.
  16847. @item @code{interfaces} (default: @var{'("localhost")})
  16848. This is the list of IP addresses and ports and possibly socket file
  16849. names to listen to (@pxref{Server Settings, @code{listen} directive,,
  16850. dico, GNU Dico Manual}).
  16851. @item @code{handlers} (default: @var{'()})
  16852. List of @code{<dicod-handler>} objects denoting handlers (module instances).
  16853. @item @code{databases} (default: @var{(list %dicod-database:gcide)})
  16854. List of @code{<dicod-database>} objects denoting dictionaries to be served.
  16855. @end table
  16856. @end deftp
  16857. @deftp {Data Type} dicod-handler
  16858. Data type representing a dictionary handler (module instance).
  16859. @table @asis
  16860. @item @code{name}
  16861. Name of the handler (module instance).
  16862. @item @code{module} (default: @var{#f})
  16863. Name of the dicod module of the handler (instance). If it is @code{#f},
  16864. the module has the same name as the handler.
  16865. (@pxref{Modules,,, dico, GNU Dico Manual}).
  16866. @item @code{options}
  16867. List of strings or gexps representing the arguments for the module handler
  16868. @end table
  16869. @end deftp
  16870. @deftp {Data Type} dicod-database
  16871. Data type representing a dictionary database.
  16872. @table @asis
  16873. @item @code{name}
  16874. Name of the database, will be used in DICT commands.
  16875. @item @code{handler}
  16876. Name of the dicod handler (module instance) used by this database
  16877. (@pxref{Handlers,,, dico, GNU Dico Manual}).
  16878. @item @code{complex?} (default: @var{#f})
  16879. Whether the database configuration complex. The complex configuration
  16880. will need a corresponding @code{<dicod-handler>} object, otherwise not.
  16881. @item @code{options}
  16882. List of strings or gexps representing the arguments for the database
  16883. (@pxref{Databases,,, dico, GNU Dico Manual}).
  16884. @end table
  16885. @end deftp
  16886. @defvr {Scheme Variable} %dicod-database:gcide
  16887. A @code{<dicod-database>} object serving the GNU Collaborative International
  16888. Dictionary of English using the @code{gcide} package.
  16889. @end defvr
  16890. The following is an example @code{dicod-service} configuration.
  16891. @example
  16892. (dicod-service #:config
  16893. (dicod-configuration
  16894. (handlers (list (dicod-handler
  16895. (name "wordnet")
  16896. (module "dictorg")
  16897. (options
  16898. (list #~(string-append "dbdir=" #$wordnet))))))
  16899. (databases (list (dicod-database
  16900. (name "wordnet")
  16901. (complex? #t)
  16902. (handler "wordnet")
  16903. (options '("database=wn")))
  16904. %dicod-database:gcide))))
  16905. @end example
  16906. @node Setuid Programs
  16907. @subsection Setuid Programs
  16908. @cindex setuid programs
  16909. Some programs need to run with ``root'' privileges, even when they are
  16910. launched by unprivileged users. A notorious example is the
  16911. @command{passwd} program, which users can run to change their
  16912. password, and which needs to access the @file{/etc/passwd} and
  16913. @file{/etc/shadow} files---something normally restricted to root, for
  16914. obvious security reasons. To address that, these executables are
  16915. @dfn{setuid-root}, meaning that they always run with root privileges
  16916. (@pxref{How Change Persona,,, libc, The GNU C Library Reference Manual},
  16917. for more info about the setuid mechanism.)
  16918. The store itself @emph{cannot} contain setuid programs: that would be a
  16919. security issue since any user on the system can write derivations that
  16920. populate the store (@pxref{The Store}). Thus, a different mechanism is
  16921. used: instead of changing the setuid bit directly on files that are in
  16922. the store, we let the system administrator @emph{declare} which programs
  16923. should be setuid root.
  16924. The @code{setuid-programs} field of an @code{operating-system}
  16925. declaration contains a list of G-expressions denoting the names of
  16926. programs to be setuid-root (@pxref{Using the Configuration System}).
  16927. For instance, the @command{passwd} program, which is part of the Shadow
  16928. package, can be designated by this G-expression (@pxref{G-Expressions}):
  16929. @example
  16930. #~(string-append #$shadow "/bin/passwd")
  16931. @end example
  16932. A default set of setuid programs is defined by the
  16933. @code{%setuid-programs} variable of the @code{(gnu system)} module.
  16934. @defvr {Scheme Variable} %setuid-programs
  16935. A list of G-expressions denoting common programs that are setuid-root.
  16936. The list includes commands such as @command{passwd}, @command{ping},
  16937. @command{su}, and @command{sudo}.
  16938. @end defvr
  16939. Under the hood, the actual setuid programs are created in the
  16940. @file{/run/setuid-programs} directory at system activation time. The
  16941. files in this directory refer to the ``real'' binaries, which are in the
  16942. store.
  16943. @node X.509 Certificates
  16944. @subsection X.509 Certificates
  16945. @cindex HTTPS, certificates
  16946. @cindex X.509 certificates
  16947. @cindex TLS
  16948. Web servers available over HTTPS (that is, HTTP over the transport-layer
  16949. security mechanism, TLS) send client programs an @dfn{X.509 certificate}
  16950. that the client can then use to @emph{authenticate} the server. To do
  16951. that, clients verify that the server's certificate is signed by a
  16952. so-called @dfn{certificate authority} (CA). But to verify the CA's
  16953. signature, clients must have first acquired the CA's certificate.
  16954. Web browsers such as GNU@tie{}IceCat include their own set of CA
  16955. certificates, such that they are able to verify CA signatures
  16956. out-of-the-box.
  16957. However, most other programs that can talk HTTPS---@command{wget},
  16958. @command{git}, @command{w3m}, etc.---need to be told where CA
  16959. certificates can be found.
  16960. @cindex @code{nss-certs}
  16961. In GuixSD, this is done by adding a package that provides certificates
  16962. to the @code{packages} field of the @code{operating-system} declaration
  16963. (@pxref{operating-system Reference}). GuixSD includes one such package,
  16964. @code{nss-certs}, which is a set of CA certificates provided as part of
  16965. Mozilla's Network Security Services.
  16966. Note that it is @emph{not} part of @var{%base-packages}, so you need to
  16967. explicitly add it. The @file{/etc/ssl/certs} directory, which is where
  16968. most applications and libraries look for certificates by default, points
  16969. to the certificates installed globally.
  16970. Unprivileged users, including users of Guix on a foreign distro,
  16971. can also install their own certificate package in
  16972. their profile. A number of environment variables need to be defined so
  16973. that applications and libraries know where to find them. Namely, the
  16974. OpenSSL library honors the @code{SSL_CERT_DIR} and @code{SSL_CERT_FILE}
  16975. variables. Some applications add their own environment variables; for
  16976. instance, the Git version control system honors the certificate bundle
  16977. pointed to by the @code{GIT_SSL_CAINFO} environment variable. Thus, you
  16978. would typically run something like:
  16979. @example
  16980. $ guix package -i nss-certs
  16981. $ export SSL_CERT_DIR="$HOME/.guix-profile/etc/ssl/certs"
  16982. $ export SSL_CERT_FILE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt"
  16983. $ export GIT_SSL_CAINFO="$SSL_CERT_FILE"
  16984. @end example
  16985. As another example, R requires the @code{CURL_CA_BUNDLE} environment
  16986. variable to point to a certificate bundle, so you would have to run
  16987. something like this:
  16988. @example
  16989. $ guix package -i nss-certs
  16990. $ export CURL_CA_BUNDLE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt"
  16991. @end example
  16992. For other applications you may want to look up the required environment
  16993. variable in the relevant documentation.
  16994. @node Name Service Switch
  16995. @subsection Name Service Switch
  16996. @cindex name service switch
  16997. @cindex NSS
  16998. The @code{(gnu system nss)} module provides bindings to the
  16999. configuration file of the libc @dfn{name service switch} or @dfn{NSS}
  17000. (@pxref{NSS Configuration File,,, libc, The GNU C Library Reference
  17001. Manual}). In a nutshell, the NSS is a mechanism that allows libc to be
  17002. extended with new ``name'' lookup methods for system databases, which
  17003. includes host names, service names, user accounts, and more (@pxref{Name
  17004. Service Switch, System Databases and Name Service Switch,, libc, The GNU
  17005. C Library Reference Manual}).
  17006. The NSS configuration specifies, for each system database, which lookup
  17007. method is to be used, and how the various methods are chained
  17008. together---for instance, under which circumstances NSS should try the
  17009. next method in the list. The NSS configuration is given in the
  17010. @code{name-service-switch} field of @code{operating-system} declarations
  17011. (@pxref{operating-system Reference, @code{name-service-switch}}).
  17012. @cindex nss-mdns
  17013. @cindex .local, host name lookup
  17014. As an example, the declaration below configures the NSS to use the
  17015. @uref{http://0pointer.de/lennart/projects/nss-mdns/, @code{nss-mdns}
  17016. back-end}, which supports host name lookups over multicast DNS (mDNS)
  17017. for host names ending in @code{.local}:
  17018. @example
  17019. (name-service-switch
  17020. (hosts (list %files ;first, check /etc/hosts
  17021. ;; If the above did not succeed, try
  17022. ;; with 'mdns_minimal'.
  17023. (name-service
  17024. (name "mdns_minimal")
  17025. ;; 'mdns_minimal' is authoritative for
  17026. ;; '.local'. When it returns "not found",
  17027. ;; no need to try the next methods.
  17028. (reaction (lookup-specification
  17029. (not-found => return))))
  17030. ;; Then fall back to DNS.
  17031. (name-service
  17032. (name "dns"))
  17033. ;; Finally, try with the "full" 'mdns'.
  17034. (name-service
  17035. (name "mdns")))))
  17036. @end example
  17037. Do not worry: the @code{%mdns-host-lookup-nss} variable (see below)
  17038. contains this configuration, so you will not have to type it if all you
  17039. want is to have @code{.local} host lookup working.
  17040. Note that, in this case, in addition to setting the
  17041. @code{name-service-switch} of the @code{operating-system} declaration,
  17042. you also need to use @code{avahi-service} (@pxref{Networking Services,
  17043. @code{avahi-service}}), or @var{%desktop-services}, which includes it
  17044. (@pxref{Desktop Services}). Doing this makes @code{nss-mdns} accessible
  17045. to the name service cache daemon (@pxref{Base Services,
  17046. @code{nscd-service}}).
  17047. For convenience, the following variables provide typical NSS
  17048. configurations.
  17049. @defvr {Scheme Variable} %default-nss
  17050. This is the default name service switch configuration, a
  17051. @code{name-service-switch} object.
  17052. @end defvr
  17053. @defvr {Scheme Variable} %mdns-host-lookup-nss
  17054. This is the name service switch configuration with support for host name
  17055. lookup over multicast DNS (mDNS) for host names ending in @code{.local}.
  17056. @end defvr
  17057. The reference for name service switch configuration is given below. It
  17058. is a direct mapping of the configuration file format of the C library , so
  17059. please refer to the C library manual for more information (@pxref{NSS
  17060. Configuration File,,, libc, The GNU C Library Reference Manual}).
  17061. Compared to the configuration file format of libc NSS, it has the advantage
  17062. not only of adding this warm parenthetic feel that we like, but also
  17063. static checks: you will know about syntax errors and typos as soon as you
  17064. run @command{guix system}.
  17065. @deftp {Data Type} name-service-switch
  17066. This is the data type representation the configuration of libc's name
  17067. service switch (NSS). Each field below represents one of the supported
  17068. system databases.
  17069. @table @code
  17070. @item aliases
  17071. @itemx ethers
  17072. @itemx group
  17073. @itemx gshadow
  17074. @itemx hosts
  17075. @itemx initgroups
  17076. @itemx netgroup
  17077. @itemx networks
  17078. @itemx password
  17079. @itemx public-key
  17080. @itemx rpc
  17081. @itemx services
  17082. @itemx shadow
  17083. The system databases handled by the NSS. Each of these fields must be a
  17084. list of @code{<name-service>} objects (see below).
  17085. @end table
  17086. @end deftp
  17087. @deftp {Data Type} name-service
  17088. This is the data type representing an actual name service and the
  17089. associated lookup action.
  17090. @table @code
  17091. @item name
  17092. A string denoting the name service (@pxref{Services in the NSS
  17093. configuration,,, libc, The GNU C Library Reference Manual}).
  17094. Note that name services listed here must be visible to nscd. This is
  17095. achieved by passing the @code{#:name-services} argument to
  17096. @code{nscd-service} the list of packages providing the needed name
  17097. services (@pxref{Base Services, @code{nscd-service}}).
  17098. @item reaction
  17099. An action specified using the @code{lookup-specification} macro
  17100. (@pxref{Actions in the NSS configuration,,, libc, The GNU C Library
  17101. Reference Manual}). For example:
  17102. @example
  17103. (lookup-specification (unavailable => continue)
  17104. (success => return))
  17105. @end example
  17106. @end table
  17107. @end deftp
  17108. @node Initial RAM Disk
  17109. @subsection Initial RAM Disk
  17110. @cindex initrd
  17111. @cindex initial RAM disk
  17112. For bootstrapping purposes, the Linux-Libre kernel is passed an
  17113. @dfn{initial RAM disk}, or @dfn{initrd}. An initrd contains a temporary
  17114. root file system as well as an initialization script. The latter is
  17115. responsible for mounting the real root file system, and for loading any
  17116. kernel modules that may be needed to achieve that.
  17117. The @code{initrd-modules} field of an @code{operating-system}
  17118. declaration allows you to specify Linux-libre kernel modules that must
  17119. be available in the initrd. In particular, this is where you would list
  17120. modules needed to actually drive the hard disk where your root partition
  17121. is---although the default value of @code{initrd-modules} should cover
  17122. most use cases. For example, assuming you need the @code{megaraid_sas}
  17123. module in addition to the default modules to be able to access your root
  17124. file system, you would write:
  17125. @example
  17126. (operating-system
  17127. ;; @dots{}
  17128. (initrd-modules (cons "megaraid_sas" %base-initrd-modules)))
  17129. @end example
  17130. @defvr {Scheme Variable} %base-initrd-modules
  17131. This is the list of kernel modules included in the initrd by default.
  17132. @end defvr
  17133. Furthermore, if you need lower-level customization, the @code{initrd}
  17134. field of an @code{operating-system} declaration allows
  17135. you to specify which initrd you would like to use. The @code{(gnu
  17136. system linux-initrd)} module provides three ways to build an initrd: the
  17137. high-level @code{base-initrd} procedure and the low-level
  17138. @code{raw-initrd} and @code{expression->initrd} procedures.
  17139. The @code{base-initrd} procedure is intended to cover most common uses.
  17140. For example, if you want to add a bunch of kernel modules to be loaded
  17141. at boot time, you can define the @code{initrd} field of the operating
  17142. system declaration like this:
  17143. @example
  17144. (initrd (lambda (file-systems . rest)
  17145. ;; Create a standard initrd but set up networking
  17146. ;; with the parameters QEMU expects by default.
  17147. (apply base-initrd file-systems
  17148. #:qemu-networking? #t
  17149. rest)))
  17150. @end example
  17151. The @code{base-initrd} procedure also handles common use cases that
  17152. involves using the system as a QEMU guest, or as a ``live'' system with
  17153. volatile root file system.
  17154. The @code{base-initrd} procedure is built from @code{raw-initrd} procedure.
  17155. Unlike @code{base-initrd}, @code{raw-initrd} doesn't do anything high-level,
  17156. such as trying to guess which kernel modules and packages should be included
  17157. to the initrd. An example use of @code{raw-initrd} is when a user has
  17158. a custom Linux kernel configuration and default kernel modules included by
  17159. @code{base-initrd} are not available.
  17160. The initial RAM disk produced by @code{base-initrd} or @code{raw-initrd}
  17161. honors several options passed on the Linux kernel command line
  17162. (that is, arguments passed @i{via} the @code{linux} command of GRUB, or the
  17163. @code{-append} option of QEMU), notably:
  17164. @table @code
  17165. @item --load=@var{boot}
  17166. Tell the initial RAM disk to load @var{boot}, a file containing a Scheme
  17167. program, once it has mounted the root file system.
  17168. GuixSD uses this option to yield control to a boot program that runs the
  17169. service activation programs and then spawns the GNU@tie{}Shepherd, the
  17170. initialization system.
  17171. @item --root=@var{root}
  17172. Mount @var{root} as the root file system. @var{root} can be a
  17173. device name like @code{/dev/sda1}, a file system label, or a file system
  17174. UUID.
  17175. @item --system=@var{system}
  17176. Have @file{/run/booted-system} and @file{/run/current-system} point to
  17177. @var{system}.
  17178. @item modprobe.blacklist=@var{modules}@dots{}
  17179. @cindex module, black-listing
  17180. @cindex black list, of kernel modules
  17181. Instruct the initial RAM disk as well as the @command{modprobe} command
  17182. (from the kmod package) to refuse to load @var{modules}. @var{modules}
  17183. must be a comma-separated list of module names---e.g.,
  17184. @code{usbkbd,9pnet}.
  17185. @item --repl
  17186. Start a read-eval-print loop (REPL) from the initial RAM disk before it
  17187. tries to load kernel modules and to mount the root file system. Our
  17188. marketing team calls it @dfn{boot-to-Guile}. The Schemer in you will
  17189. love it. @xref{Using Guile Interactively,,, guile, GNU Guile Reference
  17190. Manual}, for more information on Guile's REPL.
  17191. @end table
  17192. Now that you know all the features that initial RAM disks produced by
  17193. @code{base-initrd} and @code{raw-initrd} provide,
  17194. here is how to use it and customize it further.
  17195. @cindex initrd
  17196. @cindex initial RAM disk
  17197. @deffn {Scheme Procedure} raw-initrd @var{file-systems} @
  17198. [#:linux-modules '()] [#:mapped-devices '()] @
  17199. [#:helper-packages '()] [#:qemu-networking? #f] [#:volatile-root? #f]
  17200. Return a derivation that builds a raw initrd. @var{file-systems} is
  17201. a list of file systems to be mounted by the initrd, possibly in addition to
  17202. the root file system specified on the kernel command line via @code{--root}.
  17203. @var{linux-modules} is a list of kernel modules to be loaded at boot time.
  17204. @var{mapped-devices} is a list of device mappings to realize before
  17205. @var{file-systems} are mounted (@pxref{Mapped Devices}).
  17206. @var{helper-packages} is a list of packages to be copied in the initrd. It may
  17207. include @code{e2fsck/static} or other packages needed by the initrd to check
  17208. the root file system.
  17209. When @var{qemu-networking?} is true, set up networking with the standard QEMU
  17210. parameters. When @var{virtio?} is true, load additional modules so that the
  17211. initrd can be used as a QEMU guest with para-virtualized I/O drivers.
  17212. When @var{volatile-root?} is true, the root file system is writable but any changes
  17213. to it are lost.
  17214. @end deffn
  17215. @deffn {Scheme Procedure} base-initrd @var{file-systems} @
  17216. [#:mapped-devices '()] [#:qemu-networking? #f] [#:volatile-root? #f]@
  17217. [#:linux-modules '()]
  17218. Return as a file-like object a generic initrd, with kernel
  17219. modules taken from @var{linux}. @var{file-systems} is a list of file-systems to be
  17220. mounted by the initrd, possibly in addition to the root file system specified
  17221. on the kernel command line via @code{--root}. @var{mapped-devices} is a list of device
  17222. mappings to realize before @var{file-systems} are mounted.
  17223. @var{qemu-networking?} and @var{volatile-root?} behaves as in @code{raw-initrd}.
  17224. The initrd is automatically populated with all the kernel modules necessary
  17225. for @var{file-systems} and for the given options. Additional kernel
  17226. modules can be listed in @var{linux-modules}. They will be added to the initrd, and
  17227. loaded at boot time in the order in which they appear.
  17228. @end deffn
  17229. Needless to say, the initrds we produce and use embed a
  17230. statically-linked Guile, and the initialization program is a Guile
  17231. program. That gives a lot of flexibility. The
  17232. @code{expression->initrd} procedure builds such an initrd, given the
  17233. program to run in that initrd.
  17234. @deffn {Scheme Procedure} expression->initrd @var{exp} @
  17235. [#:guile %guile-static-stripped] [#:name "guile-initrd"]
  17236. Return as a file-like object a Linux initrd (a gzipped cpio archive)
  17237. containing @var{guile} and that evaluates @var{exp}, a G-expression,
  17238. upon booting. All the derivations referenced by @var{exp} are
  17239. automatically copied to the initrd.
  17240. @end deffn
  17241. @node Bootloader Configuration
  17242. @subsection Bootloader Configuration
  17243. @cindex bootloader
  17244. @cindex boot loader
  17245. The operating system supports multiple bootloaders. The bootloader is
  17246. configured using @code{bootloader-configuration} declaration. All the
  17247. fields of this structure are bootloader agnostic except for one field,
  17248. @code{bootloader} that indicates the bootloader to be configured and
  17249. installed.
  17250. Some of the bootloaders do not honor every field of
  17251. @code{bootloader-configuration}. For instance, the extlinux
  17252. bootloader does not support themes and thus ignores the @code{theme}
  17253. field.
  17254. @deftp {Data Type} bootloader-configuration
  17255. The type of a bootloader configuration declaration.
  17256. @table @asis
  17257. @item @code{bootloader}
  17258. @cindex EFI, bootloader
  17259. @cindex UEFI, bootloader
  17260. @cindex BIOS, bootloader
  17261. The bootloader to use, as a @code{bootloader} object. For now
  17262. @code{grub-bootloader}, @code{grub-efi-bootloader},
  17263. @code{extlinux-bootloader} and @code{u-boot-bootloader} are supported.
  17264. @vindex grub-efi-bootloader
  17265. @code{grub-efi-bootloader} allows to boot on modern systems using the
  17266. @dfn{Unified Extensible Firmware Interface} (UEFI). This is what you should
  17267. use if the installation image contains a @file{/sys/firmware/efi} directory
  17268. when you boot it on your system.
  17269. @vindex grub-bootloader
  17270. @code{grub-bootloader} allows you to boot in particular Intel-based machines
  17271. in ``legacy'' BIOS mode.
  17272. @cindex ARM, bootloaders
  17273. @cindex AArch64, bootloaders
  17274. Available bootloaders are described in @code{(gnu bootloader @dots{})}
  17275. modules. In particular, @code{(gnu bootloader u-boot)} contains definitions
  17276. of bootloaders for a wide range of ARM and AArch64 systems, using the
  17277. @uref{http://www.denx.de/wiki/U-Boot/, U-Boot bootloader}.
  17278. @item @code{target}
  17279. This is a string denoting the target onto which to install the
  17280. bootloader.
  17281. The interpretation depends on the bootloader in question. For
  17282. @code{grub-bootloader}, for example, it should be a device name understood by
  17283. the bootloader @command{installer} command, such as @code{/dev/sda} or
  17284. @code{(hd0)} (@pxref{Invoking grub-install,,, grub, GNU GRUB Manual}). For
  17285. @code{grub-efi-bootloader}, it should be the mount point of the EFI file
  17286. system, usually @file{/boot/efi}.
  17287. @item @code{menu-entries} (default: @code{()})
  17288. A possibly empty list of @code{menu-entry} objects (see below), denoting
  17289. entries to appear in the bootloader menu, in addition to the current
  17290. system entry and the entry pointing to previous system generations.
  17291. @item @code{default-entry} (default: @code{0})
  17292. The index of the default boot menu entry. Index 0 is for the entry of the
  17293. current system.
  17294. @item @code{timeout} (default: @code{5})
  17295. The number of seconds to wait for keyboard input before booting. Set to
  17296. 0 to boot immediately, and to -1 to wait indefinitely.
  17297. @item @code{theme} (default: @var{#f})
  17298. The bootloader theme object describing the theme to use. If no theme
  17299. is provided, some bootloaders might use a default theme, that's true
  17300. for GRUB.
  17301. @item @code{terminal-outputs} (default: @code{'gfxterm})
  17302. The output terminals used for the bootloader boot menu, as a list of
  17303. symbols. GRUB accepts the values: @code{console}, @code{serial},
  17304. @code{serial_@{0-3@}}, @code{gfxterm}, @code{vga_text},
  17305. @code{mda_text}, @code{morse}, and @code{pkmodem}. This field
  17306. corresponds to the GRUB variable @code{GRUB_TERMINAL_OUTPUT} (@pxref{Simple
  17307. configuration,,, grub,GNU GRUB manual}).
  17308. @item @code{terminal-inputs} (default: @code{'()})
  17309. The input terminals used for the bootloader boot menu, as a list of
  17310. symbols. For GRUB, the default is the native platform terminal as
  17311. determined at run-time. GRUB accepts the values: @code{console},
  17312. @code{serial}, @code{serial_@{0-3@}}, @code{at_keyboard}, and
  17313. @code{usb_keyboard}. This field corresponds to the GRUB variable
  17314. @code{GRUB_TERMINAL_INPUT} (@pxref{Simple configuration,,, grub,GNU GRUB
  17315. manual}).
  17316. @item @code{serial-unit} (default: @code{#f})
  17317. The serial unit used by the bootloader, as an integer from 0 to 3.
  17318. For GRUB, it is chosen at run-time; currently GRUB chooses 0, which
  17319. corresponds to COM1 (@pxref{Serial terminal,,, grub,GNU GRUB manual}).
  17320. @item @code{serial-speed} (default: @code{#f})
  17321. The speed of the serial interface, as an integer. For GRUB, the
  17322. default value is chosen at run-time; currently GRUB chooses
  17323. 9600@tie{}bps (@pxref{Serial terminal,,, grub,GNU GRUB manual}).
  17324. @end table
  17325. @end deftp
  17326. @cindex dual boot
  17327. @cindex boot menu
  17328. Should you want to list additional boot menu entries @i{via} the
  17329. @code{menu-entries} field above, you will need to create them with the
  17330. @code{menu-entry} form. For example, imagine you want to be able to
  17331. boot another distro (hard to imagine!), you can define a menu entry
  17332. along these lines:
  17333. @example
  17334. (menu-entry
  17335. (label "The Other Distro")
  17336. (linux "/boot/old/vmlinux-2.6.32")
  17337. (linux-arguments '("root=/dev/sda2"))
  17338. (initrd "/boot/old/initrd"))
  17339. @end example
  17340. Details below.
  17341. @deftp {Data Type} menu-entry
  17342. The type of an entry in the bootloader menu.
  17343. @table @asis
  17344. @item @code{label}
  17345. The label to show in the menu---e.g., @code{"GNU"}.
  17346. @item @code{linux}
  17347. The Linux kernel image to boot, for example:
  17348. @example
  17349. (file-append linux-libre "/bzImage")
  17350. @end example
  17351. For GRUB, it is also possible to specify a device explicitly in the
  17352. file path using GRUB's device naming convention (@pxref{Naming
  17353. convention,,, grub, GNU GRUB manual}), for example:
  17354. @example
  17355. "(hd0,msdos1)/boot/vmlinuz"
  17356. @end example
  17357. If the device is specified explicitly as above, then the @code{device}
  17358. field is ignored entirely.
  17359. @item @code{linux-arguments} (default: @code{()})
  17360. The list of extra Linux kernel command-line arguments---e.g.,
  17361. @code{("console=ttyS0")}.
  17362. @item @code{initrd}
  17363. A G-Expression or string denoting the file name of the initial RAM disk
  17364. to use (@pxref{G-Expressions}).
  17365. @item @code{device} (default: @code{#f})
  17366. The device where the kernel and initrd are to be found---i.e., for GRUB,
  17367. @dfn{root} for this menu entry (@pxref{root,,, grub, GNU GRUB manual}).
  17368. This may be a file system label (a string), a file system UUID (a
  17369. bytevector, @pxref{File Systems}), or @code{#f}, in which case
  17370. the bootloader will search the device containing the file specified by
  17371. the @code{linux} field (@pxref{search,,, grub, GNU GRUB manual}). It
  17372. must @emph{not} be an OS device name such as @file{/dev/sda1}.
  17373. @end table
  17374. @end deftp
  17375. @c FIXME: Write documentation once it's stable.
  17376. Fow now only GRUB has theme support. GRUB themes are created using
  17377. the @code{grub-theme} form, which is not documented yet.
  17378. @defvr {Scheme Variable} %default-theme
  17379. This is the default GRUB theme used by the operating system if no
  17380. @code{theme} field is specified in @code{bootloader-configuration}
  17381. record.
  17382. It comes with a fancy background image displaying the GNU and Guix
  17383. logos.
  17384. @end defvr
  17385. @node Invoking guix system
  17386. @subsection Invoking @code{guix system}
  17387. Once you have written an operating system declaration as seen in the
  17388. previous section, it can be @dfn{instantiated} using the @command{guix
  17389. system} command. The synopsis is:
  17390. @example
  17391. guix system @var{options}@dots{} @var{action} @var{file}
  17392. @end example
  17393. @var{file} must be the name of a file containing an
  17394. @code{operating-system} declaration. @var{action} specifies how the
  17395. operating system is instantiated. Currently the following values are
  17396. supported:
  17397. @table @code
  17398. @item search
  17399. Display available service type definitions that match the given regular
  17400. expressions, sorted by relevance:
  17401. @example
  17402. $ guix system search console font
  17403. name: console-fonts
  17404. location: gnu/services/base.scm:729:2
  17405. extends: shepherd-root
  17406. description: Install the given fonts on the specified ttys (fonts are
  17407. + per virtual console on GNU/Linux). The value of this service is a list
  17408. + of tty/font pairs like:
  17409. +
  17410. + '(("tty1" . "LatGrkCyr-8x16"))
  17411. relevance: 20
  17412. name: mingetty
  17413. location: gnu/services/base.scm:1048:2
  17414. extends: shepherd-root
  17415. description: Provide console login using the `mingetty' program.
  17416. relevance: 2
  17417. name: login
  17418. location: gnu/services/base.scm:775:2
  17419. extends: pam
  17420. description: Provide a console log-in service as specified by its
  17421. + configuration value, a `login-configuration' object.
  17422. relevance: 2
  17423. @dots{}
  17424. @end example
  17425. As for @command{guix package --search}, the result is written in
  17426. @code{recutils} format, which makes it easy to filter the output
  17427. (@pxref{Top, GNU recutils databases,, recutils, GNU recutils manual}).
  17428. @item reconfigure
  17429. Build the operating system described in @var{file}, activate it, and
  17430. switch to it@footnote{This action (and the related actions
  17431. @code{switch-generation} and @code{roll-back}) are usable only on
  17432. systems already running GuixSD.}.
  17433. This effects all the configuration specified in @var{file}: user
  17434. accounts, system services, global package list, setuid programs, etc.
  17435. The command starts system services specified in @var{file} that are not
  17436. currently running; if a service is currently running this command will
  17437. arrange for it to be upgraded the next time it is stopped (e.g.@: by
  17438. @code{herd stop X} or @code{herd restart X}).
  17439. This command creates a new generation whose number is one greater than
  17440. the current generation (as reported by @command{guix system
  17441. list-generations}). If that generation already exists, it will be
  17442. overwritten. This behavior mirrors that of @command{guix package}
  17443. (@pxref{Invoking guix package}).
  17444. It also adds a bootloader menu entry for the new OS configuration,
  17445. ---unless @option{--no-bootloader} is passed. For GRUB, it moves
  17446. entries for older configurations to a submenu, allowing you to choose
  17447. an older system generation at boot time should you need it.
  17448. @quotation Note
  17449. @c The paragraph below refers to the problem discussed at
  17450. @c <http://lists.gnu.org/archive/html/guix-devel/2014-08/msg00057.html>.
  17451. It is highly recommended to run @command{guix pull} once before you run
  17452. @command{guix system reconfigure} for the first time (@pxref{Invoking
  17453. guix pull}). Failing to do that you would see an older version of Guix
  17454. once @command{reconfigure} has completed.
  17455. @end quotation
  17456. @item switch-generation
  17457. @cindex generations
  17458. Switch to an existing system generation. This action atomically
  17459. switches the system profile to the specified system generation. It
  17460. also rearranges the system's existing bootloader menu entries. It
  17461. makes the menu entry for the specified system generation the default,
  17462. and it moves the entries for the other generatiors to a submenu, if
  17463. supported by the bootloader being used. The next time the system
  17464. boots, it will use the specified system generation.
  17465. The bootloader itself is not being reinstalled when using this
  17466. command. Thus, the installed bootloader is used with an updated
  17467. configuration file.
  17468. The target generation can be specified explicitly by its generation
  17469. number. For example, the following invocation would switch to system
  17470. generation 7:
  17471. @example
  17472. guix system switch-generation 7
  17473. @end example
  17474. The target generation can also be specified relative to the current
  17475. generation with the form @code{+N} or @code{-N}, where @code{+3} means
  17476. ``3 generations ahead of the current generation,'' and @code{-1} means
  17477. ``1 generation prior to the current generation.'' When specifying a
  17478. negative value such as @code{-1}, you must precede it with @code{--} to
  17479. prevent it from being parsed as an option. For example:
  17480. @example
  17481. guix system switch-generation -- -1
  17482. @end example
  17483. Currently, the effect of invoking this action is @emph{only} to switch
  17484. the system profile to an existing generation and rearrange the
  17485. bootloader menu entries. To actually start using the target system
  17486. generation, you must reboot after running this action. In the future,
  17487. it will be updated to do the same things as @command{reconfigure},
  17488. like activating and deactivating services.
  17489. This action will fail if the specified generation does not exist.
  17490. @item roll-back
  17491. @cindex rolling back
  17492. Switch to the preceding system generation. The next time the system
  17493. boots, it will use the preceding system generation. This is the inverse
  17494. of @command{reconfigure}, and it is exactly the same as invoking
  17495. @command{switch-generation} with an argument of @code{-1}.
  17496. Currently, as with @command{switch-generation}, you must reboot after
  17497. running this action to actually start using the preceding system
  17498. generation.
  17499. @item build
  17500. Build the derivation of the operating system, which includes all the
  17501. configuration files and programs needed to boot and run the system.
  17502. This action does not actually install anything.
  17503. @item init
  17504. Populate the given directory with all the files necessary to run the
  17505. operating system specified in @var{file}. This is useful for first-time
  17506. installations of GuixSD. For instance:
  17507. @example
  17508. guix system init my-os-config.scm /mnt
  17509. @end example
  17510. copies to @file{/mnt} all the store items required by the configuration
  17511. specified in @file{my-os-config.scm}. This includes configuration
  17512. files, packages, and so on. It also creates other essential files
  17513. needed for the system to operate correctly---e.g., the @file{/etc},
  17514. @file{/var}, and @file{/run} directories, and the @file{/bin/sh} file.
  17515. This command also installs bootloader on the target specified in
  17516. @file{my-os-config}, unless the @option{--no-bootloader} option was
  17517. passed.
  17518. @item vm
  17519. @cindex virtual machine
  17520. @cindex VM
  17521. @anchor{guix system vm}
  17522. Build a virtual machine that contains the operating system declared in
  17523. @var{file}, and return a script to run that virtual machine (VM).
  17524. Arguments given to the script are passed to QEMU as in the example
  17525. below, which enables networking and requests 1@tie{}GiB of RAM for the
  17526. emulated machine:
  17527. @example
  17528. $ /gnu/store/@dots{}-run-vm.sh -m 1024 -net user
  17529. @end example
  17530. The VM shares its store with the host system.
  17531. Additional file systems can be shared between the host and the VM using
  17532. the @code{--share} and @code{--expose} command-line options: the former
  17533. specifies a directory to be shared with write access, while the latter
  17534. provides read-only access to the shared directory.
  17535. The example below creates a VM in which the user's home directory is
  17536. accessible read-only, and where the @file{/exchange} directory is a
  17537. read-write mapping of @file{$HOME/tmp} on the host:
  17538. @example
  17539. guix system vm my-config.scm \
  17540. --expose=$HOME --share=$HOME/tmp=/exchange
  17541. @end example
  17542. On GNU/Linux, the default is to boot directly to the kernel; this has
  17543. the advantage of requiring only a very tiny root disk image since the
  17544. store of the host can then be mounted.
  17545. The @code{--full-boot} option forces a complete boot sequence, starting
  17546. with the bootloader. This requires more disk space since a root image
  17547. containing at least the kernel, initrd, and bootloader data files must
  17548. be created. The @code{--image-size} option can be used to specify the
  17549. size of the image.
  17550. @cindex System images, creation in various formats
  17551. @cindex Creating system images in various formats
  17552. @item vm-image
  17553. @itemx disk-image
  17554. @itemx docker-image
  17555. Return a virtual machine, disk image, or Docker image of the operating
  17556. system declared in @var{file} that stands alone. By default,
  17557. @command{guix system} estimates the size of the image needed to store
  17558. the system, but you can use the @option{--image-size} option to specify
  17559. a value. Docker images are built to contain exactly what they need, so
  17560. the @option{--image-size} option is ignored in the case of
  17561. @code{docker-image}.
  17562. You can specify the root file system type by using the
  17563. @option{--file-system-type} option. It defaults to @code{ext4}.
  17564. When using @code{vm-image}, the returned image is in qcow2 format, which
  17565. the QEMU emulator can efficiently use. @xref{Running GuixSD in a VM},
  17566. for more information on how to run the image in a virtual machine.
  17567. When using @code{disk-image}, a raw disk image is produced; it can be
  17568. copied as is to a USB stick, for instance. Assuming @code{/dev/sdc} is
  17569. the device corresponding to a USB stick, one can copy the image to it
  17570. using the following command:
  17571. @example
  17572. # dd if=$(guix system disk-image my-os.scm) of=/dev/sdc
  17573. @end example
  17574. When using @code{docker-image}, a Docker image is produced. Guix builds
  17575. the image from scratch, not from a pre-existing Docker base image. As a
  17576. result, it contains @emph{exactly} what you define in the operating
  17577. system configuration file. You can then load the image and launch a
  17578. Docker container using commands like the following:
  17579. @example
  17580. image_id="$(docker load < guixsd-docker-image.tar.gz)"
  17581. docker run -e GUIX_NEW_SYSTEM=/var/guix/profiles/system \\
  17582. --entrypoint /var/guix/profiles/system/profile/bin/guile \\
  17583. $image_id /var/guix/profiles/system/boot
  17584. @end example
  17585. This command starts a new Docker container from the specified image. It
  17586. will boot the GuixSD system in the usual manner, which means it will
  17587. start any services you have defined in the operating system
  17588. configuration. Depending on what you run in the Docker container, it
  17589. may be necessary to give the container additional permissions. For
  17590. example, if you intend to build software using Guix inside of the Docker
  17591. container, you may need to pass the @option{--privileged} option to
  17592. @code{docker run}.
  17593. @item container
  17594. Return a script to run the operating system declared in @var{file}
  17595. within a container. Containers are a set of lightweight isolation
  17596. mechanisms provided by the kernel Linux-libre. Containers are
  17597. substantially less resource-demanding than full virtual machines since
  17598. the kernel, shared objects, and other resources can be shared with the
  17599. host system; this also means they provide thinner isolation.
  17600. Currently, the script must be run as root in order to support more than
  17601. a single user and group. The container shares its store with the host
  17602. system.
  17603. As with the @code{vm} action (@pxref{guix system vm}), additional file
  17604. systems to be shared between the host and container can be specified
  17605. using the @option{--share} and @option{--expose} options:
  17606. @example
  17607. guix system container my-config.scm \
  17608. --expose=$HOME --share=$HOME/tmp=/exchange
  17609. @end example
  17610. @quotation Note
  17611. This option requires Linux-libre 3.19 or newer.
  17612. @end quotation
  17613. @end table
  17614. @var{options} can contain any of the common build options (@pxref{Common
  17615. Build Options}). In addition, @var{options} can contain one of the
  17616. following:
  17617. @table @option
  17618. @item --expression=@var{expr}
  17619. @itemx -e @var{expr}
  17620. Consider the operating-system @var{expr} evaluates to.
  17621. This is an alternative to specifying a file which evaluates to an
  17622. operating system.
  17623. This is used to generate the GuixSD installer @pxref{Building the
  17624. Installation Image}).
  17625. @item --system=@var{system}
  17626. @itemx -s @var{system}
  17627. Attempt to build for @var{system} instead of the host system type.
  17628. This works as per @command{guix build} (@pxref{Invoking guix build}).
  17629. @item --derivation
  17630. @itemx -d
  17631. Return the derivation file name of the given operating system without
  17632. building anything.
  17633. @item --file-system-type=@var{type}
  17634. @itemx -t @var{type}
  17635. For the @code{disk-image} action, create a file system of the given
  17636. @var{type} on the image.
  17637. When this option is omitted, @command{guix system} uses @code{ext4}.
  17638. @cindex ISO-9660 format
  17639. @cindex CD image format
  17640. @cindex DVD image format
  17641. @code{--file-system-type=iso9660} produces an ISO-9660 image, suitable
  17642. for burning on CDs and DVDs.
  17643. @item --image-size=@var{size}
  17644. For the @code{vm-image} and @code{disk-image} actions, create an image
  17645. of the given @var{size}. @var{size} may be a number of bytes, or it may
  17646. include a unit as a suffix (@pxref{Block size, size specifications,,
  17647. coreutils, GNU Coreutils}).
  17648. When this option is omitted, @command{guix system} computes an estimate
  17649. of the image size as a function of the size of the system declared in
  17650. @var{file}.
  17651. @item --root=@var{file}
  17652. @itemx -r @var{file}
  17653. Make @var{file} a symlink to the result, and register it as a garbage
  17654. collector root.
  17655. @item --skip-checks
  17656. Skip pre-installation safety checks.
  17657. By default, @command{guix system init} and @command{guix system
  17658. reconfigure} perform safety checks: they make sure the file systems that
  17659. appear in the @code{operating-system} declaration actually exist
  17660. (@pxref{File Systems}), and that any Linux kernel modules that may be
  17661. needed at boot time are listed in @code{initrd-modules} (@pxref{Initial
  17662. RAM Disk}). Passing this option skips these tests altogether.
  17663. @item --on-error=@var{strategy}
  17664. Apply @var{strategy} when an error occurs when reading @var{file}.
  17665. @var{strategy} may be one of the following:
  17666. @table @code
  17667. @item nothing-special
  17668. Report the error concisely and exit. This is the default strategy.
  17669. @item backtrace
  17670. Likewise, but also display a backtrace.
  17671. @item debug
  17672. Report the error and enter Guile's debugger. From there, you can run
  17673. commands such as @code{,bt} to get a backtrace, @code{,locals} to
  17674. display local variable values, and more generally inspect the state of the
  17675. program. @xref{Debug Commands,,, guile, GNU Guile Reference Manual}, for
  17676. a list of available debugging commands.
  17677. @end table
  17678. @end table
  17679. @quotation Note
  17680. All the actions above, except @code{build} and @code{init},
  17681. can use KVM support in the Linux-libre kernel. Specifically, if the
  17682. machine has hardware virtualization support, the corresponding
  17683. KVM kernel module should be loaded, and the @file{/dev/kvm} device node
  17684. must exist and be readable and writable by the user and by the
  17685. build users of the daemon (@pxref{Build Environment Setup}).
  17686. @end quotation
  17687. Once you have built, configured, re-configured, and re-re-configured
  17688. your GuixSD installation, you may find it useful to list the operating
  17689. system generations available on disk---and that you can choose from the
  17690. bootloader boot menu:
  17691. @table @code
  17692. @item list-generations
  17693. List a summary of each generation of the operating system available on
  17694. disk, in a human-readable way. This is similar to the
  17695. @option{--list-generations} option of @command{guix package}
  17696. (@pxref{Invoking guix package}).
  17697. Optionally, one can specify a pattern, with the same syntax that is used
  17698. in @command{guix package --list-generations}, to restrict the list of
  17699. generations displayed. For instance, the following command displays
  17700. generations that are up to 10 days old:
  17701. @example
  17702. $ guix system list-generations 10d
  17703. @end example
  17704. @end table
  17705. The @command{guix system} command has even more to offer! The following
  17706. sub-commands allow you to visualize how your system services relate to
  17707. each other:
  17708. @anchor{system-extension-graph}
  17709. @table @code
  17710. @item extension-graph
  17711. Emit in Dot/Graphviz format to standard output the @dfn{service
  17712. extension graph} of the operating system defined in @var{file}
  17713. (@pxref{Service Composition}, for more information on service
  17714. extensions.)
  17715. The command:
  17716. @example
  17717. $ guix system extension-graph @var{file} | dot -Tpdf > services.pdf
  17718. @end example
  17719. produces a PDF file showing the extension relations among services.
  17720. @anchor{system-shepherd-graph}
  17721. @item shepherd-graph
  17722. Emit in Dot/Graphviz format to standard output the @dfn{dependency
  17723. graph} of shepherd services of the operating system defined in
  17724. @var{file}. @xref{Shepherd Services}, for more information and for an
  17725. example graph.
  17726. @end table
  17727. @node Running GuixSD in a VM
  17728. @subsection Running GuixSD in a Virtual Machine
  17729. @cindex virtual machine
  17730. To run GuixSD in a virtual machine (VM), one can either use the
  17731. pre-built GuixSD VM image distributed at
  17732. @indicateurl{https://alpha.gnu.org/gnu/guix/guixsd-vm-image-@value{VERSION}.@var{system}.xz}
  17733. , or build their own virtual machine image using @command{guix system
  17734. vm-image} (@pxref{Invoking guix system}). The returned image is in
  17735. qcow2 format, which the @uref{http://qemu.org/, QEMU emulator} can
  17736. efficiently use.
  17737. @cindex QEMU
  17738. If you built your own image, you must copy it out of the store
  17739. (@pxref{The Store}) and give yourself permission to write to the copy
  17740. before you can use it. When invoking QEMU, you must choose a system
  17741. emulator that is suitable for your hardware platform. Here is a minimal
  17742. QEMU invocation that will boot the result of @command{guix system
  17743. vm-image} on x86_64 hardware:
  17744. @example
  17745. $ qemu-system-x86_64 \
  17746. -net user -net nic,model=virtio \
  17747. -enable-kvm -m 256 /tmp/qemu-image
  17748. @end example
  17749. Here is what each of these options means:
  17750. @table @code
  17751. @item qemu-system-x86_64
  17752. This specifies the hardware platform to emulate. This should match the
  17753. host.
  17754. @item -net user
  17755. Enable the unprivileged user-mode network stack. The guest OS can
  17756. access the host but not vice versa. This is the simplest way to get the
  17757. guest OS online.
  17758. @item -net nic,model=virtio
  17759. You must create a network interface of a given model. If you do not
  17760. create a NIC, the boot will fail. Assuming your hardware platform is
  17761. x86_64, you can get a list of available NIC models by running
  17762. @command{qemu-system-x86_64 -net nic,model=help}.
  17763. @item -enable-kvm
  17764. If your system has hardware virtualization extensions, enabling the
  17765. virtual machine support (KVM) of the Linux kernel will make things run
  17766. faster.
  17767. @item -m 256
  17768. RAM available to the guest OS, in mebibytes. Defaults to 128@tie{}MiB,
  17769. which may be insufficient for some operations.
  17770. @item /tmp/qemu-image
  17771. The file name of the qcow2 image.
  17772. @end table
  17773. The default @command{run-vm.sh} script that is returned by an invocation of
  17774. @command{guix system vm} does not add a @command{-net user} flag by default.
  17775. To get network access from within the vm add the @code{(dhcp-client-service)}
  17776. to your system definition and start the VM using
  17777. @command{`guix system vm config.scm` -net user}. An important caveat of using
  17778. @command{-net user} for networking is that @command{ping} will not work, because
  17779. it uses the ICMP protocol. You'll have to use a different command to check for
  17780. network connectivity, for example @command{guix download}.
  17781. @subsubsection Connecting Through SSH
  17782. @cindex SSH
  17783. @cindex SSH server
  17784. To enable SSH inside a VM you need to add a SSH server like @code{(dropbear-service)}
  17785. or @code{(lsh-service)} to your VM. The @code{(lsh-service}) doesn't currently
  17786. boot unsupervised. It requires you to type some characters to initialize the
  17787. randomness generator. In addition you need to forward the SSH port, 22 by
  17788. default, to the host. You can do this with
  17789. @example
  17790. `guix system vm config.scm` -net user,hostfwd=tcp::10022-:22
  17791. @end example
  17792. To connect to the VM you can run
  17793. @example
  17794. ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 10022
  17795. @end example
  17796. The @command{-p} tells @command{ssh} the port you want to connect to.
  17797. @command{-o UserKnownHostsFile=/dev/null} prevents @command{ssh} from complaining
  17798. every time you modify your @command{config.scm} file and the
  17799. @command{-o StrictHostKeyChecking=no} prevents you from having to allow a
  17800. connection to an unknown host every time you connect.
  17801. @subsubsection Using @command{virt-viewer} with Spice
  17802. As an alternative to the default @command{qemu} graphical client you can
  17803. use the @command{remote-viewer} from the @command{virt-viewer} package. To
  17804. connect pass the @command{-spice port=5930,disable-ticketing} flag to
  17805. @command{qemu}. See previous section for further information on how to do this.
  17806. Spice also allows you to do some nice stuff like share your clipboard with your
  17807. VM. To enable that you'll also have to pass the following flags to @command{qemu}:
  17808. @example
  17809. -device virtio-serial-pci,id=virtio-serial0,max_ports=16,bus=pci.0,addr=0x5
  17810. -chardev spicevmc,name=vdagent,id=vdagent
  17811. -device virtserialport,nr=1,bus=virtio-serial0.0,chardev=vdagent,
  17812. name=com.redhat.spice.0
  17813. @end example
  17814. You'll also need to add the @pxref{Miscellaneous Services, Spice service}.
  17815. @node Defining Services
  17816. @subsection Defining Services
  17817. The previous sections show the available services and how one can combine
  17818. them in an @code{operating-system} declaration. But how do we define
  17819. them in the first place? And what is a service anyway?
  17820. @menu
  17821. * Service Composition:: The model for composing services.
  17822. * Service Types and Services:: Types and services.
  17823. * Service Reference:: API reference.
  17824. * Shepherd Services:: A particular type of service.
  17825. @end menu
  17826. @node Service Composition
  17827. @subsubsection Service Composition
  17828. @cindex services
  17829. @cindex daemons
  17830. Here we define a @dfn{service} as, broadly, something that extends the
  17831. functionality of the operating system. Often a service is a process---a
  17832. @dfn{daemon}---started when the system boots: a secure shell server, a
  17833. Web server, the Guix build daemon, etc. Sometimes a service is a daemon
  17834. whose execution can be triggered by another daemon---e.g., an FTP server
  17835. started by @command{inetd} or a D-Bus service activated by
  17836. @command{dbus-daemon}. Occasionally, a service does not map to a
  17837. daemon. For instance, the ``account'' service collects user accounts
  17838. and makes sure they exist when the system runs; the ``udev'' service
  17839. collects device management rules and makes them available to the eudev
  17840. daemon; the @file{/etc} service populates the @file{/etc} directory
  17841. of the system.
  17842. @cindex service extensions
  17843. GuixSD services are connected by @dfn{extensions}. For instance, the
  17844. secure shell service @emph{extends} the Shepherd---the GuixSD
  17845. initialization system, running as PID@tie{}1---by giving it the command
  17846. lines to start and stop the secure shell daemon (@pxref{Networking
  17847. Services, @code{lsh-service}}); the UPower service extends the D-Bus
  17848. service by passing it its @file{.service} specification, and extends the
  17849. udev service by passing it device management rules (@pxref{Desktop
  17850. Services, @code{upower-service}}); the Guix daemon service extends the
  17851. Shepherd by passing it the command lines to start and stop the daemon,
  17852. and extends the account service by passing it a list of required build
  17853. user accounts (@pxref{Base Services}).
  17854. All in all, services and their ``extends'' relations form a directed
  17855. acyclic graph (DAG). If we represent services as boxes and extensions
  17856. as arrows, a typical system might provide something like this:
  17857. @image{images/service-graph,,5in,Typical service extension graph.}
  17858. @cindex system service
  17859. At the bottom, we see the @dfn{system service}, which produces the
  17860. directory containing everything to run and boot the system, as returned
  17861. by the @command{guix system build} command. @xref{Service Reference},
  17862. to learn about the other service types shown here.
  17863. @xref{system-extension-graph, the @command{guix system extension-graph}
  17864. command}, for information on how to generate this representation for a
  17865. particular operating system definition.
  17866. @cindex service types
  17867. Technically, developers can define @dfn{service types} to express these
  17868. relations. There can be any number of services of a given type on the
  17869. system---for instance, a system running two instances of the GNU secure
  17870. shell server (lsh) has two instances of @var{lsh-service-type}, with
  17871. different parameters.
  17872. The following section describes the programming interface for service
  17873. types and services.
  17874. @node Service Types and Services
  17875. @subsubsection Service Types and Services
  17876. A @dfn{service type} is a node in the DAG described above. Let us start
  17877. with a simple example, the service type for the Guix build daemon
  17878. (@pxref{Invoking guix-daemon}):
  17879. @example
  17880. (define guix-service-type
  17881. (service-type
  17882. (name 'guix)
  17883. (extensions
  17884. (list (service-extension shepherd-root-service-type guix-shepherd-service)
  17885. (service-extension account-service-type guix-accounts)
  17886. (service-extension activation-service-type guix-activation)))
  17887. (default-value (guix-configuration))))
  17888. @end example
  17889. @noindent
  17890. It defines three things:
  17891. @enumerate
  17892. @item
  17893. A name, whose sole purpose is to make inspection and debugging easier.
  17894. @item
  17895. A list of @dfn{service extensions}, where each extension designates the
  17896. target service type and a procedure that, given the parameters of the
  17897. service, returns a list of objects to extend the service of that type.
  17898. Every service type has at least one service extension. The only
  17899. exception is the @dfn{boot service type}, which is the ultimate service.
  17900. @item
  17901. Optionally, a default value for instances of this type.
  17902. @end enumerate
  17903. In this example, @var{guix-service-type} extends three services:
  17904. @table @var
  17905. @item shepherd-root-service-type
  17906. The @var{guix-shepherd-service} procedure defines how the Shepherd
  17907. service is extended. Namely, it returns a @code{<shepherd-service>}
  17908. object that defines how @command{guix-daemon} is started and stopped
  17909. (@pxref{Shepherd Services}).
  17910. @item account-service-type
  17911. This extension for this service is computed by @var{guix-accounts},
  17912. which returns a list of @code{user-group} and @code{user-account}
  17913. objects representing the build user accounts (@pxref{Invoking
  17914. guix-daemon}).
  17915. @item activation-service-type
  17916. Here @var{guix-activation} is a procedure that returns a gexp, which is
  17917. a code snippet to run at ``activation time''---e.g., when the service is
  17918. booted.
  17919. @end table
  17920. A service of this type is instantiated like this:
  17921. @example
  17922. (service guix-service-type
  17923. (guix-configuration
  17924. (build-accounts 5)
  17925. (use-substitutes? #f)))
  17926. @end example
  17927. The second argument to the @code{service} form is a value representing
  17928. the parameters of this specific service instance.
  17929. @xref{guix-configuration-type, @code{guix-configuration}}, for
  17930. information about the @code{guix-configuration} data type. When the
  17931. value is omitted, the default value specified by
  17932. @code{guix-service-type} is used:
  17933. @example
  17934. (service guix-service-type)
  17935. @end example
  17936. @var{guix-service-type} is quite simple because it extends other
  17937. services but is not extensible itself.
  17938. @c @subsubsubsection Extensible Service Types
  17939. The service type for an @emph{extensible} service looks like this:
  17940. @example
  17941. (define udev-service-type
  17942. (service-type (name 'udev)
  17943. (extensions
  17944. (list (service-extension shepherd-root-service-type
  17945. udev-shepherd-service)))
  17946. (compose concatenate) ;concatenate the list of rules
  17947. (extend (lambda (config rules)
  17948. (match config
  17949. (($ <udev-configuration> udev initial-rules)
  17950. (udev-configuration
  17951. (udev udev) ;the udev package to use
  17952. (rules (append initial-rules rules)))))))))
  17953. @end example
  17954. This is the service type for the
  17955. @uref{https://wiki.gentoo.org/wiki/Project:Eudev, eudev device
  17956. management daemon}. Compared to the previous example, in addition to an
  17957. extension of @var{shepherd-root-service-type}, we see two new fields:
  17958. @table @code
  17959. @item compose
  17960. This is the procedure to @dfn{compose} the list of extensions to
  17961. services of this type.
  17962. Services can extend the udev service by passing it lists of rules; we
  17963. compose those extensions simply by concatenating them.
  17964. @item extend
  17965. This procedure defines how the value of the service is @dfn{extended} with
  17966. the composition of the extensions.
  17967. Udev extensions are composed into a list of rules, but the udev service
  17968. value is itself a @code{<udev-configuration>} record. So here, we
  17969. extend that record by appending the list of rules it contains to the
  17970. list of contributed rules.
  17971. @item description
  17972. This is a string giving an overview of the service type. The string can
  17973. contain Texinfo markup (@pxref{Overview,,, texinfo, GNU Texinfo}). The
  17974. @command{guix system search} command searches these strings and displays
  17975. them (@pxref{Invoking guix system}).
  17976. @end table
  17977. There can be only one instance of an extensible service type such as
  17978. @var{udev-service-type}. If there were more, the
  17979. @code{service-extension} specifications would be ambiguous.
  17980. Still here? The next section provides a reference of the programming
  17981. interface for services.
  17982. @node Service Reference
  17983. @subsubsection Service Reference
  17984. We have seen an overview of service types (@pxref{Service Types and
  17985. Services}). This section provides a reference on how to manipulate
  17986. services and service types. This interface is provided by the
  17987. @code{(gnu services)} module.
  17988. @deffn {Scheme Procedure} service @var{type} [@var{value}]
  17989. Return a new service of @var{type}, a @code{<service-type>} object (see
  17990. below.) @var{value} can be any object; it represents the parameters of
  17991. this particular service instance.
  17992. When @var{value} is omitted, the default value specified by @var{type}
  17993. is used; if @var{type} does not specify a default value, an error is
  17994. raised.
  17995. For instance, this:
  17996. @example
  17997. (service openssh-service-type)
  17998. @end example
  17999. @noindent
  18000. is equivalent to this:
  18001. @example
  18002. (service openssh-service-type
  18003. (openssh-configuration))
  18004. @end example
  18005. In both cases the result is an instance of @code{openssh-service-type}
  18006. with the default configuration.
  18007. @end deffn
  18008. @deffn {Scheme Procedure} service? @var{obj}
  18009. Return true if @var{obj} is a service.
  18010. @end deffn
  18011. @deffn {Scheme Procedure} service-kind @var{service}
  18012. Return the type of @var{service}---i.e., a @code{<service-type>} object.
  18013. @end deffn
  18014. @deffn {Scheme Procedure} service-value @var{service}
  18015. Return the value associated with @var{service}. It represents its
  18016. parameters.
  18017. @end deffn
  18018. Here is an example of how a service is created and manipulated:
  18019. @example
  18020. (define s
  18021. (service nginx-service-type
  18022. (nginx-configuration
  18023. (nginx nginx)
  18024. (log-directory log-directory)
  18025. (run-directory run-directory)
  18026. (file config-file))))
  18027. (service? s)
  18028. @result{} #t
  18029. (eq? (service-kind s) nginx-service-type)
  18030. @result{} #t
  18031. @end example
  18032. The @code{modify-services} form provides a handy way to change the
  18033. parameters of some of the services of a list such as
  18034. @var{%base-services} (@pxref{Base Services, @code{%base-services}}). It
  18035. evaluates to a list of services. Of course, you could always use
  18036. standard list combinators such as @code{map} and @code{fold} to do that
  18037. (@pxref{SRFI-1, List Library,, guile, GNU Guile Reference Manual});
  18038. @code{modify-services} simply provides a more concise form for this
  18039. common pattern.
  18040. @deffn {Scheme Syntax} modify-services @var{services} @
  18041. (@var{type} @var{variable} => @var{body}) @dots{}
  18042. Modify the services listed in @var{services} according to the given
  18043. clauses. Each clause has the form:
  18044. @example
  18045. (@var{type} @var{variable} => @var{body})
  18046. @end example
  18047. where @var{type} is a service type---e.g.,
  18048. @code{guix-service-type}---and @var{variable} is an identifier that is
  18049. bound within the @var{body} to the service parameters---e.g., a
  18050. @code{guix-configuration} instance---of the original service of that
  18051. @var{type}.
  18052. The @var{body} should evaluate to the new service parameters, which will
  18053. be used to configure the new service. This new service will replace the
  18054. original in the resulting list. Because a service's service parameters
  18055. are created using @code{define-record-type*}, you can write a succinct
  18056. @var{body} that evaluates to the new service parameters by using the
  18057. @code{inherit} feature that @code{define-record-type*} provides.
  18058. @xref{Using the Configuration System}, for example usage.
  18059. @end deffn
  18060. Next comes the programming interface for service types. This is
  18061. something you want to know when writing new service definitions, but not
  18062. necessarily when simply looking for ways to customize your
  18063. @code{operating-system} declaration.
  18064. @deftp {Data Type} service-type
  18065. @cindex service type
  18066. This is the representation of a @dfn{service type} (@pxref{Service Types
  18067. and Services}).
  18068. @table @asis
  18069. @item @code{name}
  18070. This is a symbol, used only to simplify inspection and debugging.
  18071. @item @code{extensions}
  18072. A non-empty list of @code{<service-extension>} objects (see below).
  18073. @item @code{compose} (default: @code{#f})
  18074. If this is @code{#f}, then the service type denotes services that cannot
  18075. be extended---i.e., services that do not receive ``values'' from other
  18076. services.
  18077. Otherwise, it must be a one-argument procedure. The procedure is called
  18078. by @code{fold-services} and is passed a list of values collected from
  18079. extensions. It may return any single value.
  18080. @item @code{extend} (default: @code{#f})
  18081. If this is @code{#f}, services of this type cannot be extended.
  18082. Otherwise, it must be a two-argument procedure: @code{fold-services}
  18083. calls it, passing it the initial value of the service as the first
  18084. argument and the result of applying @code{compose} to the extension
  18085. values as the second argument. It must return a value that is a valid
  18086. parameter value for the service instance.
  18087. @end table
  18088. @xref{Service Types and Services}, for examples.
  18089. @end deftp
  18090. @deffn {Scheme Procedure} service-extension @var{target-type} @
  18091. @var{compute}
  18092. Return a new extension for services of type @var{target-type}.
  18093. @var{compute} must be a one-argument procedure: @code{fold-services}
  18094. calls it, passing it the value associated with the service that provides
  18095. the extension; it must return a valid value for the target service.
  18096. @end deffn
  18097. @deffn {Scheme Procedure} service-extension? @var{obj}
  18098. Return true if @var{obj} is a service extension.
  18099. @end deffn
  18100. Occasionally, you might want to simply extend an existing service. This
  18101. involves creating a new service type and specifying the extension of
  18102. interest, which can be verbose; the @code{simple-service} procedure
  18103. provides a shorthand for this.
  18104. @deffn {Scheme Procedure} simple-service @var{name} @var{target} @var{value}
  18105. Return a service that extends @var{target} with @var{value}. This works
  18106. by creating a singleton service type @var{name}, of which the returned
  18107. service is an instance.
  18108. For example, this extends mcron (@pxref{Scheduled Job Execution}) with
  18109. an additional job:
  18110. @example
  18111. (simple-service 'my-mcron-job mcron-service-type
  18112. #~(job '(next-hour (3)) "guix gc -F 2G"))
  18113. @end example
  18114. @end deffn
  18115. At the core of the service abstraction lies the @code{fold-services}
  18116. procedure, which is responsible for ``compiling'' a list of services
  18117. down to a single directory that contains everything needed to boot and
  18118. run the system---the directory shown by the @command{guix system build}
  18119. command (@pxref{Invoking guix system}). In essence, it propagates
  18120. service extensions down the service graph, updating each node parameters
  18121. on the way, until it reaches the root node.
  18122. @deffn {Scheme Procedure} fold-services @var{services} @
  18123. [#:target-type @var{system-service-type}]
  18124. Fold @var{services} by propagating their extensions down to the root of
  18125. type @var{target-type}; return the root service adjusted accordingly.
  18126. @end deffn
  18127. Lastly, the @code{(gnu services)} module also defines several essential
  18128. service types, some of which are listed below.
  18129. @defvr {Scheme Variable} system-service-type
  18130. This is the root of the service graph. It produces the system directory
  18131. as returned by the @command{guix system build} command.
  18132. @end defvr
  18133. @defvr {Scheme Variable} boot-service-type
  18134. The type of the ``boot service'', which produces the @dfn{boot script}.
  18135. The boot script is what the initial RAM disk runs when booting.
  18136. @end defvr
  18137. @defvr {Scheme Variable} etc-service-type
  18138. The type of the @file{/etc} service. This service is used to create
  18139. files under @file{/etc} and can be extended by
  18140. passing it name/file tuples such as:
  18141. @example
  18142. (list `("issue" ,(plain-file "issue" "Welcome!\n")))
  18143. @end example
  18144. In this example, the effect would be to add an @file{/etc/issue} file
  18145. pointing to the given file.
  18146. @end defvr
  18147. @defvr {Scheme Variable} setuid-program-service-type
  18148. Type for the ``setuid-program service''. This service collects lists of
  18149. executable file names, passed as gexps, and adds them to the set of
  18150. setuid-root programs on the system (@pxref{Setuid Programs}).
  18151. @end defvr
  18152. @defvr {Scheme Variable} profile-service-type
  18153. Type of the service that populates the @dfn{system profile}---i.e., the
  18154. programs under @file{/run/current-system/profile}. Other services can
  18155. extend it by passing it lists of packages to add to the system profile.
  18156. @end defvr
  18157. @node Shepherd Services
  18158. @subsubsection Shepherd Services
  18159. @cindex shepherd services
  18160. @cindex PID 1
  18161. @cindex init system
  18162. The @code{(gnu services shepherd)} module provides a way to define
  18163. services managed by the GNU@tie{}Shepherd, which is the GuixSD
  18164. initialization system---the first process that is started when the
  18165. system boots, also known as PID@tie{}1
  18166. (@pxref{Introduction,,, shepherd, The GNU Shepherd Manual}).
  18167. Services in the Shepherd can depend on each other. For instance, the
  18168. SSH daemon may need to be started after the syslog daemon has been
  18169. started, which in turn can only happen once all the file systems have
  18170. been mounted. The simple operating system defined earlier (@pxref{Using
  18171. the Configuration System}) results in a service graph like this:
  18172. @image{images/shepherd-graph,,5in,Typical shepherd service graph.}
  18173. You can actually generate such a graph for any operating system
  18174. definition using the @command{guix system shepherd-graph} command
  18175. (@pxref{system-shepherd-graph, @command{guix system shepherd-graph}}).
  18176. The @var{%shepherd-root-service} is a service object representing
  18177. PID@tie{}1, of type @var{shepherd-root-service-type}; it can be extended
  18178. by passing it lists of @code{<shepherd-service>} objects.
  18179. @deftp {Data Type} shepherd-service
  18180. The data type representing a service managed by the Shepherd.
  18181. @table @asis
  18182. @item @code{provision}
  18183. This is a list of symbols denoting what the service provides.
  18184. These are the names that may be passed to @command{herd start},
  18185. @command{herd status}, and similar commands (@pxref{Invoking herd,,,
  18186. shepherd, The GNU Shepherd Manual}). @xref{Slots of services, the
  18187. @code{provides} slot,, shepherd, The GNU Shepherd Manual}, for details.
  18188. @item @code{requirements} (default: @code{'()})
  18189. List of symbols denoting the Shepherd services this one depends on.
  18190. @item @code{respawn?} (default: @code{#t})
  18191. Whether to restart the service when it stops, for instance when the
  18192. underlying process dies.
  18193. @item @code{start}
  18194. @itemx @code{stop} (default: @code{#~(const #f)})
  18195. The @code{start} and @code{stop} fields refer to the Shepherd's
  18196. facilities to start and stop processes (@pxref{Service De- and
  18197. Constructors,,, shepherd, The GNU Shepherd Manual}). They are given as
  18198. G-expressions that get expanded in the Shepherd configuration file
  18199. (@pxref{G-Expressions}).
  18200. @item @code{actions} (default: @code{'()})
  18201. @cindex actions, of Shepherd services
  18202. This is a list of @code{shepherd-action} objects (see below) defining
  18203. @dfn{actions} supported by the service, in addition to the standard
  18204. @code{start} and @code{stop} actions. Actions listed here become available as
  18205. @command{herd} sub-commands:
  18206. @example
  18207. herd @var{action} @var{service} [@var{arguments}@dots{}]
  18208. @end example
  18209. @item @code{documentation}
  18210. A documentation string, as shown when running:
  18211. @example
  18212. herd doc @var{service-name}
  18213. @end example
  18214. where @var{service-name} is one of the symbols in @var{provision}
  18215. (@pxref{Invoking herd,,, shepherd, The GNU Shepherd Manual}).
  18216. @item @code{modules} (default: @var{%default-modules})
  18217. This is the list of modules that must be in scope when @code{start} and
  18218. @code{stop} are evaluated.
  18219. @end table
  18220. @end deftp
  18221. @deftp {Data Type} shepherd-action
  18222. This is the data type that defines additional actions implemented by a
  18223. Shepherd service (see above).
  18224. @table @code
  18225. @item name
  18226. Symbol naming the action.
  18227. @item documentation
  18228. This is a documentation string for the action. It can be viewed by running:
  18229. @example
  18230. herd doc @var{service} action @var{action}
  18231. @end example
  18232. @item procedure
  18233. This should be a gexp that evaluates to a procedure of at least one argument,
  18234. which is the ``running value'' of the service (@pxref{Slots of services,,,
  18235. shepherd, The GNU Shepherd Manual}).
  18236. @end table
  18237. The following example defines an action called @code{say-hello} that kindly
  18238. greets the user:
  18239. @example
  18240. (shepherd-action
  18241. (name 'say-hello)
  18242. (documentation "Say hi!")
  18243. (procedure #~(lambda (running . args)
  18244. (format #t "Hello, friend! arguments: ~s\n"
  18245. args)
  18246. #t)))
  18247. @end example
  18248. Assuming this action is added to the @code{example} service, then you can do:
  18249. @example
  18250. # herd say-hello example
  18251. Hello, friend! arguments: ()
  18252. # herd say-hello example a b c
  18253. Hello, friend! arguments: ("a" "b" "c")
  18254. @end example
  18255. This, as you can see, is a fairly sophisticated way to say hello.
  18256. @xref{Service Convenience,,, shepherd, The GNU Shepherd Manual}, for more
  18257. info on actions.
  18258. @end deftp
  18259. @defvr {Scheme Variable} shepherd-root-service-type
  18260. The service type for the Shepherd ``root service''---i.e., PID@tie{}1.
  18261. This is the service type that extensions target when they want to create
  18262. shepherd services (@pxref{Service Types and Services}, for an example).
  18263. Each extension must pass a list of @code{<shepherd-service>}.
  18264. @end defvr
  18265. @defvr {Scheme Variable} %shepherd-root-service
  18266. This service represents PID@tie{}1.
  18267. @end defvr
  18268. @node Documentation
  18269. @section Documentation
  18270. @cindex documentation, searching for
  18271. @cindex searching for documentation
  18272. @cindex Info, documentation format
  18273. @cindex man pages
  18274. @cindex manual pages
  18275. In most cases packages installed with Guix come with documentation.
  18276. There are two main documentation formats: ``Info'', a browseable
  18277. hypertext format used for GNU software, and ``manual pages'' (or ``man
  18278. pages''), the linear documentation format traditionally found on Unix.
  18279. Info manuals are accessed with the @command{info} command or with Emacs,
  18280. and man pages are accessed using @command{man}.
  18281. You can look for documentation of software installed on your system by
  18282. keyword. For example, the following command searches for information
  18283. about ``TLS'' in Info manuals:
  18284. @example
  18285. $ info -k TLS
  18286. "(emacs)Network Security" -- STARTTLS
  18287. "(emacs)Network Security" -- TLS
  18288. "(gnutls)Core TLS API" -- gnutls_certificate_set_verify_flags
  18289. "(gnutls)Core TLS API" -- gnutls_certificate_set_verify_function
  18290. @dots{}
  18291. @end example
  18292. @noindent
  18293. The command below searches for the same keyword in man pages:
  18294. @example
  18295. $ man -k TLS
  18296. SSL (7) - OpenSSL SSL/TLS library
  18297. certtool (1) - GnuTLS certificate tool
  18298. @dots {}
  18299. @end example
  18300. These searches are purely local to your computer so you have the
  18301. guarantee that documentation you find corresponds to what you have
  18302. actually installed, you can access it off-line, and your privacy is
  18303. respected.
  18304. Once you have these results, you can view the relevant documentation by
  18305. running, say:
  18306. @example
  18307. $ info "(gnutls)Core TLS API"
  18308. @end example
  18309. @noindent
  18310. or:
  18311. @example
  18312. $ man certtool
  18313. @end example
  18314. Info manuals contain sections and indices as well as hyperlinks like
  18315. those found in Web pages. The @command{info} reader (@pxref{Top, Info
  18316. reader,, info-stnd, Stand-alone GNU Info}) and its Emacs counterpart
  18317. (@pxref{Misc Help,,, emacs, The GNU Emacs Manual}) provide intuitive key
  18318. bindings to navigate manuals. @xref{Getting Started,,, info, Info: An
  18319. Introduction}, for an introduction to Info navigation.
  18320. @node Installing Debugging Files
  18321. @section Installing Debugging Files
  18322. @cindex debugging files
  18323. Program binaries, as produced by the GCC compilers for instance, are
  18324. typically written in the ELF format, with a section containing
  18325. @dfn{debugging information}. Debugging information is what allows the
  18326. debugger, GDB, to map binary code to source code; it is required to
  18327. debug a compiled program in good conditions.
  18328. The problem with debugging information is that is takes up a fair amount
  18329. of disk space. For example, debugging information for the GNU C Library
  18330. weighs in at more than 60 MiB. Thus, as a user, keeping all the
  18331. debugging info of all the installed programs is usually not an option.
  18332. Yet, space savings should not come at the cost of an impediment to
  18333. debugging---especially in the GNU system, which should make it easier
  18334. for users to exert their computing freedom (@pxref{GNU Distribution}).
  18335. Thankfully, the GNU Binary Utilities (Binutils) and GDB provide a
  18336. mechanism that allows users to get the best of both worlds: debugging
  18337. information can be stripped from the binaries and stored in separate
  18338. files. GDB is then able to load debugging information from those files,
  18339. when they are available (@pxref{Separate Debug Files,,, gdb, Debugging
  18340. with GDB}).
  18341. The GNU distribution takes advantage of this by storing debugging
  18342. information in the @code{lib/debug} sub-directory of a separate package
  18343. output unimaginatively called @code{debug} (@pxref{Packages with
  18344. Multiple Outputs}). Users can choose to install the @code{debug} output
  18345. of a package when they need it. For instance, the following command
  18346. installs the debugging information for the GNU C Library and for GNU
  18347. Guile:
  18348. @example
  18349. guix package -i glibc:debug guile:debug
  18350. @end example
  18351. GDB must then be told to look for debug files in the user's profile, by
  18352. setting the @code{debug-file-directory} variable (consider setting it
  18353. from the @file{~/.gdbinit} file, @pxref{Startup,,, gdb, Debugging with
  18354. GDB}):
  18355. @example
  18356. (gdb) set debug-file-directory ~/.guix-profile/lib/debug
  18357. @end example
  18358. From there on, GDB will pick up debugging information from the
  18359. @code{.debug} files under @file{~/.guix-profile/lib/debug}.
  18360. In addition, you will most likely want GDB to be able to show the source
  18361. code being debugged. To do that, you will have to unpack the source
  18362. code of the package of interest (obtained with @code{guix build
  18363. --source}, @pxref{Invoking guix build}), and to point GDB to that source
  18364. directory using the @code{directory} command (@pxref{Source Path,
  18365. @code{directory},, gdb, Debugging with GDB}).
  18366. @c XXX: keep me up-to-date
  18367. The @code{debug} output mechanism in Guix is implemented by the
  18368. @code{gnu-build-system} (@pxref{Build Systems}). Currently, it is
  18369. opt-in---debugging information is available only for the packages
  18370. with definitions explicitly declaring a @code{debug} output. This may be
  18371. changed to opt-out in the future if our build farm servers can handle
  18372. the load. To check whether a package has a @code{debug} output, use
  18373. @command{guix package --list-available} (@pxref{Invoking guix package}).
  18374. @node Security Updates
  18375. @section Security Updates
  18376. @cindex security updates
  18377. @cindex security vulnerabilities
  18378. Occasionally, important security vulnerabilities are discovered in software
  18379. packages and must be patched. Guix developers try hard to keep track of
  18380. known vulnerabilities and to apply fixes as soon as possible in the
  18381. @code{master} branch of Guix (we do not yet provide a ``stable'' branch
  18382. containing only security updates.) The @command{guix lint} tool helps
  18383. developers find out about vulnerable versions of software packages in the
  18384. distribution:
  18385. @smallexample
  18386. $ guix lint -c cve
  18387. gnu/packages/base.scm:652:2: glibc@@2.21: probably vulnerable to CVE-2015-1781, CVE-2015-7547
  18388. gnu/packages/gcc.scm:334:2: gcc@@4.9.3: probably vulnerable to CVE-2015-5276
  18389. gnu/packages/image.scm:312:2: openjpeg@@2.1.0: probably vulnerable to CVE-2016-1923, CVE-2016-1924
  18390. @dots{}
  18391. @end smallexample
  18392. @xref{Invoking guix lint}, for more information.
  18393. @quotation Note
  18394. As of version @value{VERSION}, the feature described below is considered
  18395. ``beta''.
  18396. @end quotation
  18397. Guix follows a functional
  18398. package management discipline (@pxref{Introduction}), which implies
  18399. that, when a package is changed, @emph{every package that depends on it}
  18400. must be rebuilt. This can significantly slow down the deployment of
  18401. fixes in core packages such as libc or Bash, since basically the whole
  18402. distribution would need to be rebuilt. Using pre-built binaries helps
  18403. (@pxref{Substitutes}), but deployment may still take more time than
  18404. desired.
  18405. @cindex grafts
  18406. To address this, Guix implements @dfn{grafts}, a mechanism that allows
  18407. for fast deployment of critical updates without the costs associated
  18408. with a whole-distribution rebuild. The idea is to rebuild only the
  18409. package that needs to be patched, and then to ``graft'' it onto packages
  18410. explicitly installed by the user and that were previously referring to
  18411. the original package. The cost of grafting is typically very low, and
  18412. order of magnitudes lower than a full rebuild of the dependency chain.
  18413. @cindex replacements of packages, for grafts
  18414. For instance, suppose a security update needs to be applied to Bash.
  18415. Guix developers will provide a package definition for the ``fixed''
  18416. Bash, say @var{bash-fixed}, in the usual way (@pxref{Defining
  18417. Packages}). Then, the original package definition is augmented with a
  18418. @code{replacement} field pointing to the package containing the bug fix:
  18419. @example
  18420. (define bash
  18421. (package
  18422. (name "bash")
  18423. ;; @dots{}
  18424. (replacement bash-fixed)))
  18425. @end example
  18426. From there on, any package depending directly or indirectly on Bash---as
  18427. reported by @command{guix gc --requisites} (@pxref{Invoking guix
  18428. gc})---that is installed is automatically ``rewritten'' to refer to
  18429. @var{bash-fixed} instead of @var{bash}. This grafting process takes
  18430. time proportional to the size of the package, usually less than a
  18431. minute for an ``average'' package on a recent machine. Grafting is
  18432. recursive: when an indirect dependency requires grafting, then grafting
  18433. ``propagates'' up to the package that the user is installing.
  18434. Currently, the length of the name and version of the graft and that of
  18435. the package it replaces (@var{bash-fixed} and @var{bash} in the example
  18436. above) must be equal. This restriction mostly comes from the fact that
  18437. grafting works by patching files, including binary files, directly.
  18438. Other restrictions may apply: for instance, when adding a graft to a
  18439. package providing a shared library, the original shared library and its
  18440. replacement must have the same @code{SONAME} and be binary-compatible.
  18441. The @option{--no-grafts} command-line option allows you to forcefully
  18442. avoid grafting (@pxref{Common Build Options, @option{--no-grafts}}).
  18443. Thus, the command:
  18444. @example
  18445. guix build bash --no-grafts
  18446. @end example
  18447. @noindent
  18448. returns the store file name of the original Bash, whereas:
  18449. @example
  18450. guix build bash
  18451. @end example
  18452. @noindent
  18453. returns the store file name of the ``fixed'', replacement Bash. This
  18454. allows you to distinguish between the two variants of Bash.
  18455. To verify which Bash your whole profile refers to, you can run
  18456. (@pxref{Invoking guix gc}):
  18457. @example
  18458. guix gc -R `readlink -f ~/.guix-profile` | grep bash
  18459. @end example
  18460. @noindent
  18461. @dots{} and compare the store file names that you get with those above.
  18462. Likewise for a complete GuixSD system generation:
  18463. @example
  18464. guix gc -R `guix system build my-config.scm` | grep bash
  18465. @end example
  18466. Lastly, to check which Bash running processes are using, you can use the
  18467. @command{lsof} command:
  18468. @example
  18469. lsof | grep /gnu/store/.*bash
  18470. @end example
  18471. @node Package Modules
  18472. @section Package Modules
  18473. From a programming viewpoint, the package definitions of the
  18474. GNU distribution are provided by Guile modules in the @code{(gnu packages
  18475. @dots{})} name space@footnote{Note that packages under the @code{(gnu
  18476. packages @dots{})} module name space are not necessarily ``GNU
  18477. packages''. This module naming scheme follows the usual Guile module
  18478. naming convention: @code{gnu} means that these modules are distributed
  18479. as part of the GNU system, and @code{packages} identifies modules that
  18480. define packages.} (@pxref{Modules, Guile modules,, guile, GNU Guile
  18481. Reference Manual}). For instance, the @code{(gnu packages emacs)}
  18482. module exports a variable named @code{emacs}, which is bound to a
  18483. @code{<package>} object (@pxref{Defining Packages}).
  18484. The @code{(gnu packages @dots{})} module name space is
  18485. automatically scanned for packages by the command-line tools. For
  18486. instance, when running @code{guix package -i emacs}, all the @code{(gnu
  18487. packages @dots{})} modules are scanned until one that exports a package
  18488. object whose name is @code{emacs} is found. This package search
  18489. facility is implemented in the @code{(gnu packages)} module.
  18490. @cindex customization, of packages
  18491. @cindex package module search path
  18492. Users can store package definitions in modules with different
  18493. names---e.g., @code{(my-packages emacs)}@footnote{Note that the file
  18494. name and module name must match. For instance, the @code{(my-packages
  18495. emacs)} module must be stored in a @file{my-packages/emacs.scm} file
  18496. relative to the load path specified with @option{--load-path} or
  18497. @code{GUIX_PACKAGE_PATH}. @xref{Modules and the File System,,,
  18498. guile, GNU Guile Reference Manual}, for details.}. There are two ways to make
  18499. these package definitions visible to the user interfaces:
  18500. @enumerate
  18501. @item
  18502. By adding the directory containing your package modules to the search path
  18503. with the @code{-L} flag of @command{guix package} and other commands
  18504. (@pxref{Common Build Options}), or by setting the @code{GUIX_PACKAGE_PATH}
  18505. environment variable described below.
  18506. @item
  18507. By defining a @dfn{channel} and configuring @command{guix pull} so that it
  18508. pulls from it. A channel is essentially a Git repository containing package
  18509. modules. @xref{Channels}, for more information on how to define and use
  18510. channels.
  18511. @end enumerate
  18512. @code{GUIX_PACKAGE_PATH} works similarly to other search path variables:
  18513. @defvr {Environment Variable} GUIX_PACKAGE_PATH
  18514. This is a colon-separated list of directories to search for additional
  18515. package modules. Directories listed in this variable take precedence
  18516. over the own modules of the distribution.
  18517. @end defvr
  18518. The distribution is fully @dfn{bootstrapped} and @dfn{self-contained}:
  18519. each package is built based solely on other packages in the
  18520. distribution. The root of this dependency graph is a small set of
  18521. @dfn{bootstrap binaries}, provided by the @code{(gnu packages
  18522. bootstrap)} module. For more information on bootstrapping,
  18523. @pxref{Bootstrapping}.
  18524. @node Packaging Guidelines
  18525. @section Packaging Guidelines
  18526. @cindex packages, creating
  18527. The GNU distribution is nascent and may well lack some of your favorite
  18528. packages. This section describes how you can help make the distribution
  18529. grow. @xref{Contributing}, for additional information on how you can
  18530. help.
  18531. Free software packages are usually distributed in the form of
  18532. @dfn{source code tarballs}---typically @file{tar.gz} files that contain
  18533. all the source files. Adding a package to the distribution means
  18534. essentially two things: adding a @dfn{recipe} that describes how to
  18535. build the package, including a list of other packages required to build
  18536. it, and adding @dfn{package metadata} along with that recipe, such as a
  18537. description and licensing information.
  18538. In Guix all this information is embodied in @dfn{package definitions}.
  18539. Package definitions provide a high-level view of the package. They are
  18540. written using the syntax of the Scheme programming language; in fact,
  18541. for each package we define a variable bound to the package definition,
  18542. and export that variable from a module (@pxref{Package Modules}).
  18543. However, in-depth Scheme knowledge is @emph{not} a prerequisite for
  18544. creating packages. For more information on package definitions,
  18545. @pxref{Defining Packages}.
  18546. Once a package definition is in place, stored in a file in the Guix
  18547. source tree, it can be tested using the @command{guix build} command
  18548. (@pxref{Invoking guix build}). For example, assuming the new package is
  18549. called @code{gnew}, you may run this command from the Guix build tree
  18550. (@pxref{Running Guix Before It Is Installed}):
  18551. @example
  18552. ./pre-inst-env guix build gnew --keep-failed
  18553. @end example
  18554. Using @code{--keep-failed} makes it easier to debug build failures since
  18555. it provides access to the failed build tree. Another useful
  18556. command-line option when debugging is @code{--log-file}, to access the
  18557. build log.
  18558. If the package is unknown to the @command{guix} command, it may be that
  18559. the source file contains a syntax error, or lacks a @code{define-public}
  18560. clause to export the package variable. To figure it out, you may load
  18561. the module from Guile to get more information about the actual error:
  18562. @example
  18563. ./pre-inst-env guile -c '(use-modules (gnu packages gnew))'
  18564. @end example
  18565. Once your package builds correctly, please send us a patch
  18566. (@pxref{Contributing}). Well, if you need help, we will be happy to
  18567. help you too. Once the patch is committed in the Guix repository, the
  18568. new package automatically gets built on the supported platforms by
  18569. @url{http://hydra.gnu.org/jobset/gnu/master, our continuous integration
  18570. system}.
  18571. @cindex substituter
  18572. Users can obtain the new package definition simply by running
  18573. @command{guix pull} (@pxref{Invoking guix pull}). When
  18574. @code{@value{SUBSTITUTE-SERVER}} is done building the package, installing the
  18575. package automatically downloads binaries from there
  18576. (@pxref{Substitutes}). The only place where human intervention is
  18577. needed is to review and apply the patch.
  18578. @menu
  18579. * Software Freedom:: What may go into the distribution.
  18580. * Package Naming:: What's in a name?
  18581. * Version Numbers:: When the name is not enough.
  18582. * Synopses and Descriptions:: Helping users find the right package.
  18583. * Python Modules:: A touch of British comedy.
  18584. * Perl Modules:: Little pearls.
  18585. * Java Packages:: Coffee break.
  18586. * Fonts:: Fond of fonts.
  18587. @end menu
  18588. @node Software Freedom
  18589. @subsection Software Freedom
  18590. @c Adapted from http://www.gnu.org/philosophy/philosophy.html.
  18591. @cindex free software
  18592. The GNU operating system has been developed so that users can have
  18593. freedom in their computing. GNU is @dfn{free software}, meaning that
  18594. users have the @url{http://www.gnu.org/philosophy/free-sw.html,four
  18595. essential freedoms}: to run the program, to study and change the program
  18596. in source code form, to redistribute exact copies, and to distribute
  18597. modified versions. Packages found in the GNU distribution provide only
  18598. software that conveys these four freedoms.
  18599. In addition, the GNU distribution follow the
  18600. @url{http://www.gnu.org/distros/free-system-distribution-guidelines.html,free
  18601. software distribution guidelines}. Among other things, these guidelines
  18602. reject non-free firmware, recommendations of non-free software, and
  18603. discuss ways to deal with trademarks and patents.
  18604. Some otherwise free upstream package sources contain a small and optional
  18605. subset that violates the above guidelines, for instance because this subset
  18606. is itself non-free code. When that happens, the offending items are removed
  18607. with appropriate patches or code snippets in the @code{origin} form of the
  18608. package (@pxref{Defining Packages}). This way, @code{guix
  18609. build --source} returns the ``freed'' source rather than the unmodified
  18610. upstream source.
  18611. @node Package Naming
  18612. @subsection Package Naming
  18613. @cindex package name
  18614. A package has actually two names associated with it:
  18615. First, there is the name of the @emph{Scheme variable}, the one following
  18616. @code{define-public}. By this name, the package can be made known in the
  18617. Scheme code, for instance as input to another package. Second, there is
  18618. the string in the @code{name} field of a package definition. This name
  18619. is used by package management commands such as
  18620. @command{guix package} and @command{guix build}.
  18621. Both are usually the same and correspond to the lowercase conversion of
  18622. the project name chosen upstream, with underscores replaced with
  18623. hyphens. For instance, GNUnet is available as @code{gnunet}, and
  18624. SDL_net as @code{sdl-net}.
  18625. We do not add @code{lib} prefixes for library packages, unless these are
  18626. already part of the official project name. But @pxref{Python
  18627. Modules} and @ref{Perl Modules} for special rules concerning modules for
  18628. the Python and Perl languages.
  18629. Font package names are handled differently, @pxref{Fonts}.
  18630. @node Version Numbers
  18631. @subsection Version Numbers
  18632. @cindex package version
  18633. We usually package only the latest version of a given free software
  18634. project. But sometimes, for instance for incompatible library versions,
  18635. two (or more) versions of the same package are needed. These require
  18636. different Scheme variable names. We use the name as defined
  18637. in @ref{Package Naming}
  18638. for the most recent version; previous versions use the same name, suffixed
  18639. by @code{-} and the smallest prefix of the version number that may
  18640. distinguish the two versions.
  18641. The name inside the package definition is the same for all versions of a
  18642. package and does not contain any version number.
  18643. For instance, the versions 2.24.20 and 3.9.12 of GTK+ may be packaged as follows:
  18644. @example
  18645. (define-public gtk+
  18646. (package
  18647. (name "gtk+")
  18648. (version "3.9.12")
  18649. ...))
  18650. (define-public gtk+-2
  18651. (package
  18652. (name "gtk+")
  18653. (version "2.24.20")
  18654. ...))
  18655. @end example
  18656. If we also wanted GTK+ 3.8.2, this would be packaged as
  18657. @example
  18658. (define-public gtk+-3.8
  18659. (package
  18660. (name "gtk+")
  18661. (version "3.8.2")
  18662. ...))
  18663. @end example
  18664. @c See <https://lists.gnu.org/archive/html/guix-devel/2016-01/msg00425.html>,
  18665. @c for a discussion of what follows.
  18666. @cindex version number, for VCS snapshots
  18667. Occasionally, we package snapshots of upstream's version control system
  18668. (VCS) instead of formal releases. This should remain exceptional,
  18669. because it is up to upstream developers to clarify what the stable
  18670. release is. Yet, it is sometimes necessary. So, what should we put in
  18671. the @code{version} field?
  18672. Clearly, we need to make the commit identifier of the VCS snapshot
  18673. visible in the version string, but we also need to make sure that the
  18674. version string is monotonically increasing so that @command{guix package
  18675. --upgrade} can determine which version is newer. Since commit
  18676. identifiers, notably with Git, are not monotonically increasing, we add
  18677. a revision number that we increase each time we upgrade to a newer
  18678. snapshot. The resulting version string looks like this:
  18679. @example
  18680. 2.0.11-3.cabba9e
  18681. ^ ^ ^
  18682. | | `-- upstream commit ID
  18683. | |
  18684. | `--- Guix package revision
  18685. |
  18686. latest upstream version
  18687. @end example
  18688. It is a good idea to strip commit identifiers in the @code{version}
  18689. field to, say, 7 digits. It avoids an aesthetic annoyance (assuming
  18690. aesthetics have a role to play here) as well as problems related to OS
  18691. limits such as the maximum shebang length (127 bytes for the Linux
  18692. kernel.) It is best to use the full commit identifiers in
  18693. @code{origin}s, though, to avoid ambiguities. A typical package
  18694. definition may look like this:
  18695. @example
  18696. (define my-package
  18697. (let ((commit "c3f29bc928d5900971f65965feaae59e1272a3f7")
  18698. (revision "1")) ;Guix package revision
  18699. (package
  18700. (version (git-version "0.9" revision commit))
  18701. (source (origin
  18702. (method git-fetch)
  18703. (uri (git-reference
  18704. (url "git://example.org/my-package.git")
  18705. (commit commit)))
  18706. (sha256 (base32 "1mbikn@dots{}"))
  18707. (file-name (git-file-name name version))))
  18708. ;; @dots{}
  18709. )))
  18710. @end example
  18711. @node Synopses and Descriptions
  18712. @subsection Synopses and Descriptions
  18713. @cindex package description
  18714. @cindex package synopsis
  18715. As we have seen before, each package in GNU@tie{}Guix includes a
  18716. synopsis and a description (@pxref{Defining Packages}). Synopses and
  18717. descriptions are important: They are what @command{guix package
  18718. --search} searches, and a crucial piece of information to help users
  18719. determine whether a given package suits their needs. Consequently,
  18720. packagers should pay attention to what goes into them.
  18721. Synopses must start with a capital letter and must not end with a
  18722. period. They must not start with ``a'' or ``the'', which usually does
  18723. not bring anything; for instance, prefer ``File-frobbing tool'' over ``A
  18724. tool that frobs files''. The synopsis should say what the package
  18725. is---e.g., ``Core GNU utilities (file, text, shell)''---or what it is
  18726. used for---e.g., the synopsis for GNU@tie{}grep is ``Print lines
  18727. matching a pattern''.
  18728. Keep in mind that the synopsis must be meaningful for a very wide
  18729. audience. For example, ``Manipulate alignments in the SAM format''
  18730. might make sense for a seasoned bioinformatics researcher, but might be
  18731. fairly unhelpful or even misleading to a non-specialized audience. It
  18732. is a good idea to come up with a synopsis that gives an idea of the
  18733. application domain of the package. In this example, this might give
  18734. something like ``Manipulate nucleotide sequence alignments'', which
  18735. hopefully gives the user a better idea of whether this is what they are
  18736. looking for.
  18737. Descriptions should take between five and ten lines. Use full
  18738. sentences, and avoid using acronyms without first introducing them.
  18739. Please avoid marketing phrases such as ``world-leading'',
  18740. ``industrial-strength'', and ``next-generation'', and avoid superlatives
  18741. like ``the most advanced''---they are not helpful to users looking for a
  18742. package and may even sound suspicious. Instead, try to be factual,
  18743. mentioning use cases and features.
  18744. @cindex Texinfo markup, in package descriptions
  18745. Descriptions can include Texinfo markup, which is useful to introduce
  18746. ornaments such as @code{@@code} or @code{@@dfn}, bullet lists, or
  18747. hyperlinks (@pxref{Overview,,, texinfo, GNU Texinfo}). However you
  18748. should be careful when using some characters for example @samp{@@} and
  18749. curly braces which are the basic special characters in Texinfo
  18750. (@pxref{Special Characters,,, texinfo, GNU Texinfo}). User interfaces
  18751. such as @command{guix package --show} take care of rendering it
  18752. appropriately.
  18753. Synopses and descriptions are translated by volunteers
  18754. @uref{http://translationproject.org/domain/guix-packages.html, at the
  18755. Translation Project} so that as many users as possible can read them in
  18756. their native language. User interfaces search them and display them in
  18757. the language specified by the current locale.
  18758. To allow @command{xgettext} to extract them as translatable strings,
  18759. synopses and descriptions @emph{must be literal strings}. This means
  18760. that you cannot use @code{string-append} or @code{format} to construct
  18761. these strings:
  18762. @lisp
  18763. (package
  18764. ;; @dots{}
  18765. (synopsis "This is translatable")
  18766. (description (string-append "This is " "*not*" " translatable.")))
  18767. @end lisp
  18768. Translation is a lot of work so, as a packager, please pay even more
  18769. attention to your synopses and descriptions as every change may entail
  18770. additional work for translators. In order to help them, it is possible
  18771. to make recommendations or instructions visible to them by inserting
  18772. special comments like this (@pxref{xgettext Invocation,,, gettext, GNU
  18773. Gettext}):
  18774. @example
  18775. ;; TRANSLATORS: "X11 resize-and-rotate" should not be translated.
  18776. (description "ARandR is designed to provide a simple visual front end
  18777. for the X11 resize-and-rotate (RandR) extension. @dots{}")
  18778. @end example
  18779. @node Python Modules
  18780. @subsection Python Modules
  18781. @cindex python
  18782. We currently package Python 2 and Python 3, under the Scheme variable names
  18783. @code{python-2} and @code{python} as explained in @ref{Version Numbers}.
  18784. To avoid confusion and naming clashes with other programming languages, it
  18785. seems desirable that the name of a package for a Python module contains
  18786. the word @code{python}.
  18787. Some modules are compatible with only one version of Python, others with both.
  18788. If the package Foo compiles only with Python 3, we name it
  18789. @code{python-foo}; if it compiles only with Python 2, we name it
  18790. @code{python2-foo}. If it is compatible with both versions, we create two
  18791. packages with the corresponding names.
  18792. If a project already contains the word @code{python}, we drop this;
  18793. for instance, the module python-dateutil is packaged under the names
  18794. @code{python-dateutil} and @code{python2-dateutil}. If the project name
  18795. starts with @code{py} (e.g.@: @code{pytz}), we keep it and prefix it as
  18796. described above.
  18797. @subsubsection Specifying Dependencies
  18798. @cindex inputs, for Python packages
  18799. Dependency information for Python packages is usually available in the
  18800. package source tree, with varying degrees of accuracy: in the
  18801. @file{setup.py} file, in @file{requirements.txt}, or in @file{tox.ini}.
  18802. Your mission, when writing a recipe for a Python package, is to map
  18803. these dependencies to the appropriate type of ``input'' (@pxref{package
  18804. Reference, inputs}). Although the @code{pypi} importer normally does a
  18805. good job (@pxref{Invoking guix import}), you may want to check the
  18806. following check list to determine which dependency goes where.
  18807. @itemize
  18808. @item
  18809. We currently package Python 2 with @code{setuptools} and @code{pip}
  18810. installed like Python 3.4 has per default. Thus you don't need to
  18811. specify either of these as an input. @command{guix lint} will warn you
  18812. if you do.
  18813. @item
  18814. Python dependencies required at run time go into
  18815. @code{propagated-inputs}. They are typically defined with the
  18816. @code{install_requires} keyword in @file{setup.py}, or in the
  18817. @file{requirements.txt} file.
  18818. @item
  18819. Python packages required only at build time---e.g., those listed with
  18820. the @code{setup_requires} keyword in @file{setup.py}---or only for
  18821. testing---e.g., those in @code{tests_require}---go into
  18822. @code{native-inputs}. The rationale is that (1) they do not need to be
  18823. propagated because they are not needed at run time, and (2) in a
  18824. cross-compilation context, it's the ``native'' input that we'd want.
  18825. Examples are the @code{pytest}, @code{mock}, and @code{nose} test
  18826. frameworks. Of course if any of these packages is also required at
  18827. run-time, it needs to go to @code{propagated-inputs}.
  18828. @item
  18829. Anything that does not fall in the previous categories goes to
  18830. @code{inputs}, for example programs or C libraries required for building
  18831. Python packages containing C extensions.
  18832. @item
  18833. If a Python package has optional dependencies (@code{extras_require}),
  18834. it is up to you to decide whether to add them or not, based on their
  18835. usefulness/overhead ratio (@pxref{Submitting Patches, @command{guix
  18836. size}}).
  18837. @end itemize
  18838. @node Perl Modules
  18839. @subsection Perl Modules
  18840. @cindex perl
  18841. Perl programs standing for themselves are named as any other package,
  18842. using the lowercase upstream name.
  18843. For Perl packages containing a single class, we use the lowercase class name,
  18844. replace all occurrences of @code{::} by dashes and prepend the prefix
  18845. @code{perl-}.
  18846. So the class @code{XML::Parser} becomes @code{perl-xml-parser}.
  18847. Modules containing several classes keep their lowercase upstream name and
  18848. are also prepended by @code{perl-}. Such modules tend to have the word
  18849. @code{perl} somewhere in their name, which gets dropped in favor of the
  18850. prefix. For instance, @code{libwww-perl} becomes @code{perl-libwww}.
  18851. @node Java Packages
  18852. @subsection Java Packages
  18853. @cindex java
  18854. Java programs standing for themselves are named as any other package,
  18855. using the lowercase upstream name.
  18856. To avoid confusion and naming clashes with other programming languages,
  18857. it is desirable that the name of a package for a Java package is
  18858. prefixed with @code{java-}. If a project already contains the word
  18859. @code{java}, we drop this; for instance, the package @code{ngsjava} is
  18860. packaged under the name @code{java-ngs}.
  18861. For Java packages containing a single class or a small class hierarchy,
  18862. we use the lowercase class name, replace all occurrences of @code{.} by
  18863. dashes and prepend the prefix @code{java-}. So the class
  18864. @code{apache.commons.cli} becomes package
  18865. @code{java-apache-commons-cli}.
  18866. @node Fonts
  18867. @subsection Fonts
  18868. @cindex fonts
  18869. For fonts that are in general not installed by a user for typesetting
  18870. purposes, or that are distributed as part of a larger software package,
  18871. we rely on the general packaging rules for software; for instance, this
  18872. applies to the fonts delivered as part of the X.Org system or fonts that
  18873. are part of TeX Live.
  18874. To make it easier for a user to search for fonts, names for other packages
  18875. containing only fonts are constructed as follows, independently of the
  18876. upstream package name.
  18877. The name of a package containing only one font family starts with
  18878. @code{font-}; it is followed by the foundry name and a dash @code{-}
  18879. if the foundry is known, and the font family name, in which spaces are
  18880. replaced by dashes (and as usual, all upper case letters are transformed
  18881. to lower case).
  18882. For example, the Gentium font family by SIL is packaged under the name
  18883. @code{font-sil-gentium}.
  18884. For a package containing several font families, the name of the collection
  18885. is used in the place of the font family name.
  18886. For instance, the Liberation fonts consist of three families,
  18887. Liberation Sans, Liberation Serif and Liberation Mono.
  18888. These could be packaged separately under the names
  18889. @code{font-liberation-sans} and so on; but as they are distributed together
  18890. under a common name, we prefer to package them together as
  18891. @code{font-liberation}.
  18892. In the case where several formats of the same font family or font collection
  18893. are packaged separately, a short form of the format, prepended by a dash,
  18894. is added to the package name. We use @code{-ttf} for TrueType fonts,
  18895. @code{-otf} for OpenType fonts and @code{-type1} for PostScript Type 1
  18896. fonts.
  18897. @node Bootstrapping
  18898. @section Bootstrapping
  18899. @c Adapted from the ELS 2013 paper.
  18900. @cindex bootstrapping
  18901. Bootstrapping in our context refers to how the distribution gets built
  18902. ``from nothing''. Remember that the build environment of a derivation
  18903. contains nothing but its declared inputs (@pxref{Introduction}). So
  18904. there's an obvious chicken-and-egg problem: how does the first package
  18905. get built? How does the first compiler get compiled? Note that this is
  18906. a question of interest only to the curious hacker, not to the regular
  18907. user, so you can shamelessly skip this section if you consider yourself
  18908. a ``regular user''.
  18909. @cindex bootstrap binaries
  18910. The GNU system is primarily made of C code, with libc at its core. The
  18911. GNU build system itself assumes the availability of a Bourne shell and
  18912. command-line tools provided by GNU Coreutils, Awk, Findutils, `sed', and
  18913. `grep'. Furthermore, build programs---programs that run
  18914. @code{./configure}, @code{make}, etc.---are written in Guile Scheme
  18915. (@pxref{Derivations}). Consequently, to be able to build anything at
  18916. all, from scratch, Guix relies on pre-built binaries of Guile, GCC,
  18917. Binutils, libc, and the other packages mentioned above---the
  18918. @dfn{bootstrap binaries}.
  18919. These bootstrap binaries are ``taken for granted'', though we can also
  18920. re-create them if needed (more on that later).
  18921. @unnumberedsubsec Preparing to Use the Bootstrap Binaries
  18922. @c As of Emacs 24.3, Info-mode displays the image, but since it's a
  18923. @c large image, it's hard to scroll. Oh well.
  18924. @image{images/bootstrap-graph,6in,,Dependency graph of the early bootstrap derivations}
  18925. The figure above shows the very beginning of the dependency graph of the
  18926. distribution, corresponding to the package definitions of the @code{(gnu
  18927. packages bootstrap)} module. A similar figure can be generated with
  18928. @command{guix graph} (@pxref{Invoking guix graph}), along the lines of:
  18929. @example
  18930. guix graph -t derivation \
  18931. -e '(@@@@ (gnu packages bootstrap) %bootstrap-gcc)' \
  18932. | dot -Tps > t.ps
  18933. @end example
  18934. At this level of detail, things are
  18935. slightly complex. First, Guile itself consists of an ELF executable,
  18936. along with many source and compiled Scheme files that are dynamically
  18937. loaded when it runs. This gets stored in the @file{guile-2.0.7.tar.xz}
  18938. tarball shown in this graph. This tarball is part of Guix's ``source''
  18939. distribution, and gets inserted into the store with @code{add-to-store}
  18940. (@pxref{The Store}).
  18941. But how do we write a derivation that unpacks this tarball and adds it
  18942. to the store? To solve this problem, the @code{guile-bootstrap-2.0.drv}
  18943. derivation---the first one that gets built---uses @code{bash} as its
  18944. builder, which runs @code{build-bootstrap-guile.sh}, which in turn calls
  18945. @code{tar} to unpack the tarball. Thus, @file{bash}, @file{tar},
  18946. @file{xz}, and @file{mkdir} are statically-linked binaries, also part of
  18947. the Guix source distribution, whose sole purpose is to allow the Guile
  18948. tarball to be unpacked.
  18949. Once @code{guile-bootstrap-2.0.drv} is built, we have a functioning
  18950. Guile that can be used to run subsequent build programs. Its first task
  18951. is to download tarballs containing the other pre-built binaries---this
  18952. is what the @code{.tar.xz.drv} derivations do. Guix modules such as
  18953. @code{ftp-client.scm} are used for this purpose. The
  18954. @code{module-import.drv} derivations import those modules in a directory
  18955. in the store, using the original layout. The
  18956. @code{module-import-compiled.drv} derivations compile those modules, and
  18957. write them in an output directory with the right layout. This
  18958. corresponds to the @code{#:modules} argument of
  18959. @code{build-expression->derivation} (@pxref{Derivations}).
  18960. Finally, the various tarballs are unpacked by the
  18961. derivations @code{gcc-bootstrap-0.drv}, @code{glibc-bootstrap-0.drv},
  18962. etc., at which point we have a working C tool chain.
  18963. @unnumberedsubsec Building the Build Tools
  18964. Bootstrapping is complete when we have a full tool chain that does not
  18965. depend on the pre-built bootstrap tools discussed above. This
  18966. no-dependency requirement is verified by checking whether the files of
  18967. the final tool chain contain references to the @file{/gnu/store}
  18968. directories of the bootstrap inputs. The process that leads to this
  18969. ``final'' tool chain is described by the package definitions found in
  18970. the @code{(gnu packages commencement)} module.
  18971. The @command{guix graph} command allows us to ``zoom out'' compared to
  18972. the graph above, by looking at the level of package objects instead of
  18973. individual derivations---remember that a package may translate to
  18974. several derivations, typically one derivation to download its source,
  18975. one to build the Guile modules it needs, and one to actually build the
  18976. package from source. The command:
  18977. @example
  18978. guix graph -t bag \
  18979. -e '(@@@@ (gnu packages commencement)
  18980. glibc-final-with-bootstrap-bash)' | dot -Tps > t.ps
  18981. @end example
  18982. @noindent
  18983. produces the dependency graph leading to the ``final'' C
  18984. library@footnote{You may notice the @code{glibc-intermediate} label,
  18985. suggesting that it is not @emph{quite} final, but as a good
  18986. approximation, we will consider it final.}, depicted below.
  18987. @image{images/bootstrap-packages,6in,,Dependency graph of the early packages}
  18988. @c See <http://lists.gnu.org/archive/html/gnu-system-discuss/2012-10/msg00000.html>.
  18989. The first tool that gets built with the bootstrap binaries is
  18990. GNU@tie{}Make---noted @code{make-boot0} above---which is a prerequisite
  18991. for all the following packages. From there Findutils and Diffutils get
  18992. built.
  18993. Then come the first-stage Binutils and GCC, built as pseudo cross
  18994. tools---i.e., with @code{--target} equal to @code{--host}. They are
  18995. used to build libc. Thanks to this cross-build trick, this libc is
  18996. guaranteed not to hold any reference to the initial tool chain.
  18997. From there the final Binutils and GCC (not shown above) are built.
  18998. GCC uses @code{ld}
  18999. from the final Binutils, and links programs against the just-built libc.
  19000. This tool chain is used to build the other packages used by Guix and by
  19001. the GNU Build System: Guile, Bash, Coreutils, etc.
  19002. And voilà! At this point we have the complete set of build tools that
  19003. the GNU Build System expects. These are in the @code{%final-inputs}
  19004. variable of the @code{(gnu packages commencement)} module, and are
  19005. implicitly used by any package that uses @code{gnu-build-system}
  19006. (@pxref{Build Systems, @code{gnu-build-system}}).
  19007. @unnumberedsubsec Building the Bootstrap Binaries
  19008. @cindex bootstrap binaries
  19009. Because the final tool chain does not depend on the bootstrap binaries,
  19010. those rarely need to be updated. Nevertheless, it is useful to have an
  19011. automated way to produce them, should an update occur, and this is what
  19012. the @code{(gnu packages make-bootstrap)} module provides.
  19013. The following command builds the tarballs containing the bootstrap
  19014. binaries (Guile, Binutils, GCC, libc, and a tarball containing a mixture
  19015. of Coreutils and other basic command-line tools):
  19016. @example
  19017. guix build bootstrap-tarballs
  19018. @end example
  19019. The generated tarballs are those that should be referred to in the
  19020. @code{(gnu packages bootstrap)} module mentioned at the beginning of
  19021. this section.
  19022. Still here? Then perhaps by now you've started to wonder: when do we
  19023. reach a fixed point? That is an interesting question! The answer is
  19024. unknown, but if you would like to investigate further (and have
  19025. significant computational and storage resources to do so), then let us
  19026. know.
  19027. @unnumberedsubsec Reducing the Set of Bootstrap Binaries
  19028. Our bootstrap binaries currently include GCC, Guile, etc. That's a lot
  19029. of binary code! Why is that a problem? It's a problem because these
  19030. big chunks of binary code are practically non-auditable, which makes it
  19031. hard to establish what source code produced them. Every unauditable
  19032. binary also leaves us vulnerable to compiler backdoors as described by
  19033. Ken Thompson in the 1984 paper @emph{Reflections on Trusting Trust}.
  19034. This is mitigated by the fact that our bootstrap binaries were generated
  19035. from an earlier Guix revision. Nevertheless it lacks the level of
  19036. transparency that we get in the rest of the package dependency graph,
  19037. where Guix always gives us a source-to-binary mapping. Thus, our goal
  19038. is to reduce the set of bootstrap binaries to the bare minimum.
  19039. The @uref{http://bootstrappable.org, Bootstrappable.org web site} lists
  19040. on-going projects to do that. One of these is about replacing the
  19041. bootstrap GCC with a sequence of assemblers, interpreters, and compilers
  19042. of increasing complexity, which could be built from source starting from
  19043. a simple and auditable assembler. Your help is welcome!
  19044. @node Porting
  19045. @section Porting to a New Platform
  19046. As discussed above, the GNU distribution is self-contained, and
  19047. self-containment is achieved by relying on pre-built ``bootstrap
  19048. binaries'' (@pxref{Bootstrapping}). These binaries are specific to an
  19049. operating system kernel, CPU architecture, and application binary
  19050. interface (ABI). Thus, to port the distribution to a platform that is
  19051. not yet supported, one must build those bootstrap binaries, and update
  19052. the @code{(gnu packages bootstrap)} module to use them on that platform.
  19053. Fortunately, Guix can @emph{cross compile} those bootstrap binaries.
  19054. When everything goes well, and assuming the GNU tool chain supports the
  19055. target platform, this can be as simple as running a command like this
  19056. one:
  19057. @example
  19058. guix build --target=armv5tel-linux-gnueabi bootstrap-tarballs
  19059. @end example
  19060. For this to work, the @code{glibc-dynamic-linker} procedure in
  19061. @code{(gnu packages bootstrap)} must be augmented to return the right
  19062. file name for libc's dynamic linker on that platform; likewise,
  19063. @code{system->linux-architecture} in @code{(gnu packages linux)} must be
  19064. taught about the new platform.
  19065. Once these are built, the @code{(gnu packages bootstrap)} module needs
  19066. to be updated to refer to these binaries on the target platform. That
  19067. is, the hashes and URLs of the bootstrap tarballs for the new platform
  19068. must be added alongside those of the currently supported platforms. The
  19069. bootstrap Guile tarball is treated specially: it is expected to be
  19070. available locally, and @file{gnu/local.mk} has rules to download it for
  19071. the supported architectures; a rule for the new platform must be added
  19072. as well.
  19073. In practice, there may be some complications. First, it may be that the
  19074. extended GNU triplet that specifies an ABI (like the @code{eabi} suffix
  19075. above) is not recognized by all the GNU tools. Typically, glibc
  19076. recognizes some of these, whereas GCC uses an extra @code{--with-abi}
  19077. configure flag (see @code{gcc.scm} for examples of how to handle this).
  19078. Second, some of the required packages could fail to build for that
  19079. platform. Lastly, the generated binaries could be broken for some
  19080. reason.
  19081. @c *********************************************************************
  19082. @include contributing.texi
  19083. @c *********************************************************************
  19084. @node Acknowledgments
  19085. @chapter Acknowledgments
  19086. Guix is based on the @uref{http://nixos.org/nix/, Nix package manager},
  19087. which was designed and
  19088. implemented by Eelco Dolstra, with contributions from other people (see
  19089. the @file{nix/AUTHORS} file in Guix.) Nix pioneered functional package
  19090. management, and promoted unprecedented features, such as transactional
  19091. package upgrades and rollbacks, per-user profiles, and referentially
  19092. transparent build processes. Without this work, Guix would not exist.
  19093. The Nix-based software distributions, Nixpkgs and NixOS, have also been
  19094. an inspiration for Guix.
  19095. GNU@tie{}Guix itself is a collective work with contributions from a
  19096. number of people. See the @file{AUTHORS} file in Guix for more
  19097. information on these fine people. The @file{THANKS} file lists people
  19098. who have helped by reporting bugs, taking care of the infrastructure,
  19099. providing artwork and themes, making suggestions, and more---thank you!
  19100. @c *********************************************************************
  19101. @node GNU Free Documentation License
  19102. @appendix GNU Free Documentation License
  19103. @cindex license, GNU Free Documentation License
  19104. @include fdl-1.3.texi
  19105. @c *********************************************************************
  19106. @node Concept Index
  19107. @unnumbered Concept Index
  19108. @printindex cp
  19109. @node Programming Index
  19110. @unnumbered Programming Index
  19111. @syncodeindex tp fn
  19112. @syncodeindex vr fn
  19113. @printindex fn
  19114. @bye
  19115. @c Local Variables:
  19116. @c ispell-local-dictionary: "american";
  19117. @c End: