guix.texi 716 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680
  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. @copying
  12. Copyright @copyright{} 2012, 2013, 2014, 2015, 2016, 2017 Ludovic Courtès@*
  13. Copyright @copyright{} 2013, 2014, 2016 Andreas Enge@*
  14. Copyright @copyright{} 2013 Nikita Karetnikov@*
  15. Copyright @copyright{} 2014, 2015, 2016 Alex Kost@*
  16. Copyright @copyright{} 2015, 2016 Mathieu Lirzin@*
  17. Copyright @copyright{} 2014 Pierre-Antoine Rault@*
  18. Copyright @copyright{} 2015 Taylan Ulrich Bayırlı/Kammer@*
  19. Copyright @copyright{} 2015, 2016, 2017 Leo Famulari@*
  20. Copyright @copyright{} 2015, 2016, 2017 Ricardo Wurmus@*
  21. Copyright @copyright{} 2016 Ben Woodcroft@*
  22. Copyright @copyright{} 2016 Chris Marusich@*
  23. Copyright @copyright{} 2016, 2017 Efraim Flashner@*
  24. Copyright @copyright{} 2016 John Darrington@*
  25. Copyright @copyright{} 2016 ng0@*
  26. Copyright @copyright{} 2016, 2017 Jan Nieuwenhuizen@*
  27. Copyright @copyright{} 2016 Julien Lepiller@*
  28. Copyright @copyright{} 2016 Alex ter Weele@*
  29. Copyright @copyright{} 2017 Clément Lassieur@*
  30. Copyright @copyright{} 2017 Mathieu Othacehe@*
  31. Copyright @copyright{} 2017 Federico Beffa@*
  32. Copyright @copyright{} 2017 Carlo Zancanaro@*
  33. Copyright @copyright{} 2017 Thomas Danckaert@*
  34. Copyright @copyright{} 2017 humanitiesNerd@*
  35. Copyright @copyright{} 2017 Christopher Allan Webber@*
  36. Copyright @copyright{} 2017 Marius Bakke@*
  37. Copyright @copyright{} 2017 Hartmut Goebel@*
  38. Copyright @copyright{} 2017 Maxim Cournoyer@*
  39. Copyright @copyright{} 2017 Tobias Geerinckx-Rice
  40. Permission is granted to copy, distribute and/or modify this document
  41. under the terms of the GNU Free Documentation License, Version 1.3 or
  42. any later version published by the Free Software Foundation; with no
  43. Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
  44. copy of the license is included in the section entitled ``GNU Free
  45. Documentation License''.
  46. @end copying
  47. @dircategory System administration
  48. @direntry
  49. * Guix: (guix). Manage installed software and system configuration.
  50. * guix package: (guix)Invoking guix package. Installing, removing, and upgrading packages.
  51. * guix gc: (guix)Invoking guix gc. Reclaiming unused disk space.
  52. * guix pull: (guix)Invoking guix pull. Update the list of available packages.
  53. * guix system: (guix)Invoking guix system. Manage the operating system configuration.
  54. @end direntry
  55. @dircategory Software development
  56. @direntry
  57. * guix environment: (guix)Invoking guix environment. Building development environments with Guix.
  58. * guix build: (guix)Invoking guix build. Building packages.
  59. * guix pack: (guix)Invoking guix pack. Creating binary bundles.
  60. @end direntry
  61. @titlepage
  62. @title GNU Guix Reference Manual
  63. @subtitle Using the GNU Guix Functional Package Manager
  64. @author The GNU Guix Developers
  65. @page
  66. @vskip 0pt plus 1filll
  67. Edition @value{EDITION} @*
  68. @value{UPDATED} @*
  69. @insertcopying
  70. @end titlepage
  71. @contents
  72. @c *********************************************************************
  73. @node Top
  74. @top GNU Guix
  75. This document describes GNU Guix version @value{VERSION}, a functional
  76. package management tool written for the GNU system.
  77. @menu
  78. * Introduction:: What is Guix about?
  79. * Installation:: Installing Guix.
  80. * Package Management:: Package installation, upgrade, etc.
  81. * Programming Interface:: Using Guix in Scheme.
  82. * Utilities:: Package management commands.
  83. * GNU Distribution:: Software for your friendly GNU system.
  84. * Contributing:: Your help needed!
  85. * Acknowledgments:: Thanks!
  86. * GNU Free Documentation License:: The license of this manual.
  87. * Concept Index:: Concepts.
  88. * Programming Index:: Data types, functions, and variables.
  89. @detailmenu
  90. --- The Detailed Node Listing ---
  91. Installation
  92. * Binary Installation:: Getting Guix running in no time!
  93. * Requirements:: Software needed to build and run Guix.
  94. * Running the Test Suite:: Testing Guix.
  95. * Setting Up the Daemon:: Preparing the build daemon's environment.
  96. * Invoking guix-daemon:: Running the build daemon.
  97. * Application Setup:: Application-specific setup.
  98. Setting Up the Daemon
  99. * Build Environment Setup:: Preparing the isolated build environment.
  100. * Daemon Offload Setup:: Offloading builds to remote machines.
  101. Package Management
  102. * Features:: How Guix will make your life brighter.
  103. * Invoking guix package:: Package installation, removal, etc.
  104. * Substitutes:: Downloading pre-built binaries.
  105. * Packages with Multiple Outputs:: Single source package, multiple outputs.
  106. * Invoking guix gc:: Running the garbage collector.
  107. * Invoking guix pull:: Fetching the latest Guix and distribution.
  108. * Invoking guix pack:: Creating software bundles.
  109. * Invoking guix archive:: Exporting and importing store files.
  110. Programming Interface
  111. * Defining Packages:: Defining new packages.
  112. * Build Systems:: Specifying how packages are built.
  113. * The Store:: Manipulating the package store.
  114. * Derivations:: Low-level interface to package derivations.
  115. * The Store Monad:: Purely functional interface to the store.
  116. * G-Expressions:: Manipulating build expressions.
  117. Defining Packages
  118. * package Reference :: The package data type.
  119. * origin Reference:: The origin data type.
  120. Utilities
  121. * Invoking guix build:: Building packages from the command line.
  122. * Invoking guix edit:: Editing package definitions.
  123. * Invoking guix download:: Downloading a file and printing its hash.
  124. * Invoking guix hash:: Computing the cryptographic hash of a file.
  125. * Invoking guix import:: Importing package definitions.
  126. * Invoking guix refresh:: Updating package definitions.
  127. * Invoking guix lint:: Finding errors in package definitions.
  128. * Invoking guix size:: Profiling disk usage.
  129. * Invoking guix graph:: Visualizing the graph of packages.
  130. * Invoking guix environment:: Setting up development environments.
  131. * Invoking guix publish:: Sharing substitutes.
  132. * Invoking guix challenge:: Challenging substitute servers.
  133. * Invoking guix copy:: Copying to and from a remote store.
  134. * Invoking guix container:: Process isolation.
  135. * Invoking guix weather:: Assessing substitute availability.
  136. Invoking @command{guix build}
  137. * Common Build Options:: Build options for most commands.
  138. * Package Transformation Options:: Creating variants of packages.
  139. * Additional Build Options:: Options specific to 'guix build'.
  140. * Debugging Build Failures:: Real life packaging experience.
  141. GNU Distribution
  142. * System Installation:: Installing the whole operating system.
  143. * System Configuration:: Configuring the operating system.
  144. * Documentation:: Browsing software user manuals.
  145. * Installing Debugging Files:: Feeding the debugger.
  146. * Security Updates:: Deploying security fixes quickly.
  147. * Package Modules:: Packages from the programmer's viewpoint.
  148. * Packaging Guidelines:: Growing the distribution.
  149. * Bootstrapping:: GNU/Linux built from scratch.
  150. * Porting:: Targeting another platform or kernel.
  151. System Installation
  152. * Limitations:: What you can expect.
  153. * Hardware Considerations:: Supported hardware.
  154. * USB Stick Installation:: Preparing the installation medium.
  155. * Preparing for Installation:: Networking, partitioning, etc.
  156. * Proceeding with the Installation:: The real thing.
  157. * Installing GuixSD in a VM:: GuixSD playground.
  158. * Building the Installation Image:: How this comes to be.
  159. System Configuration
  160. * Using the Configuration System:: Customizing your GNU system.
  161. * operating-system Reference:: Detail of operating-system declarations.
  162. * File Systems:: Configuring file system mounts.
  163. * Mapped Devices:: Block device extra processing.
  164. * User Accounts:: Specifying user accounts.
  165. * Locales:: Language and cultural convention settings.
  166. * Services:: Specifying system services.
  167. * Setuid Programs:: Programs running with root privileges.
  168. * X.509 Certificates:: Authenticating HTTPS servers.
  169. * Name Service Switch:: Configuring libc's name service switch.
  170. * Initial RAM Disk:: Linux-Libre bootstrapping.
  171. * Bootloader Configuration:: Configuring the boot loader.
  172. * Invoking guix system:: Instantiating a system configuration.
  173. * Running GuixSD in a VM:: How to run GuixSD in a virtual machine.
  174. * Defining Services:: Adding new service definitions.
  175. Services
  176. * Base Services:: Essential system services.
  177. * Scheduled Job Execution:: The mcron service.
  178. * Log Rotation:: The rottlog service.
  179. * Networking Services:: Network setup, SSH daemon, etc.
  180. * X Window:: Graphical display.
  181. * Printing Services:: Local and remote printer support.
  182. * Desktop Services:: D-Bus and desktop services.
  183. * Database Services:: SQL databases, key-value stores, etc.
  184. * Mail Services:: IMAP, POP3, SMTP, and all that.
  185. * Messaging Services:: Messaging services.
  186. * Monitoring Services:: Monitoring services.
  187. * Kerberos Services:: Kerberos services.
  188. * Web Services:: Web servers.
  189. * DNS Services:: DNS daemons.
  190. * VPN Services:: VPN daemons.
  191. * Network File System:: NFS related services.
  192. * Continuous Integration:: The Cuirass service.
  193. * Power management Services:: The TLP tool.
  194. * Audio Services:: The MPD.
  195. * Virtualization Services:: Virtualization services.
  196. * Miscellaneous Services:: Other services.
  197. Defining Services
  198. * Service Composition:: The model for composing services.
  199. * Service Types and Services:: Types and services.
  200. * Service Reference:: API reference.
  201. * Shepherd Services:: A particular type of service.
  202. Packaging Guidelines
  203. * Software Freedom:: What may go into the distribution.
  204. * Package Naming:: What's in a name?
  205. * Version Numbers:: When the name is not enough.
  206. * Synopses and Descriptions:: Helping users find the right package.
  207. * Python Modules:: A touch of British comedy.
  208. * Perl Modules:: Little pearls.
  209. * Java Packages:: Coffee break.
  210. * Fonts:: Fond of fonts.
  211. Contributing
  212. * Building from Git:: The latest and greatest.
  213. * Running Guix Before It Is Installed:: Hacker tricks.
  214. * The Perfect Setup:: The right tools.
  215. * Coding Style:: Hygiene of the contributor.
  216. * Submitting Patches:: Share your work.
  217. Coding Style
  218. * Programming Paradigm:: How to compose your elements.
  219. * Modules:: Where to store your code?
  220. * Data Types and Pattern Matching:: Implementing data structures.
  221. * Formatting Code:: Writing conventions.
  222. @end detailmenu
  223. @end menu
  224. @c *********************************************************************
  225. @node Introduction
  226. @chapter Introduction
  227. @cindex purpose
  228. GNU Guix@footnote{``Guix'' is pronounced like ``geeks'', or ``ɡiːks''
  229. using the international phonetic alphabet (IPA).} is a package
  230. management tool for the GNU system. Guix makes it easy for unprivileged
  231. users to install, upgrade, or remove packages, to roll back to a
  232. previous package set, to build packages from source, and generally
  233. assists with the creation and maintenance of software environments.
  234. @cindex user interfaces
  235. Guix provides a command-line package management interface
  236. (@pxref{Invoking guix package}), a set of command-line utilities
  237. (@pxref{Utilities}), as well as Scheme programming interfaces
  238. (@pxref{Programming Interface}).
  239. @cindex build daemon
  240. Its @dfn{build daemon} is responsible for building packages on behalf of
  241. users (@pxref{Setting Up the Daemon}) and for downloading pre-built
  242. binaries from authorized sources (@pxref{Substitutes}).
  243. @cindex extensibility of the distribution
  244. @cindex customization, of packages
  245. Guix includes package definitions for many GNU and non-GNU packages, all
  246. of which @uref{https://www.gnu.org/philosophy/free-sw.html, respect the
  247. user's computing freedom}. It is @emph{extensible}: users can write
  248. their own package definitions (@pxref{Defining Packages}) and make them
  249. available as independent package modules (@pxref{Package Modules}). It
  250. is also @emph{customizable}: users can @emph{derive} specialized package
  251. definitions from existing ones, including from the command line
  252. (@pxref{Package Transformation Options}).
  253. @cindex Guix System Distribution
  254. @cindex GuixSD
  255. You can install GNU@tie{}Guix on top of an existing GNU/Linux system
  256. where it complements the available tools without interference
  257. (@pxref{Installation}), or you can use it as part of the standalone
  258. @dfn{Guix System Distribution} or GuixSD (@pxref{GNU Distribution}).
  259. With GNU@tie{}GuixSD, you @emph{declare} all aspects of the operating
  260. system configuration and Guix takes care of instantiating the
  261. configuration in a transactional, reproducible, and stateless fashion
  262. (@pxref{System Configuration}).
  263. @cindex functional package management
  264. Under the hood, Guix implements the @dfn{functional package management}
  265. discipline pioneered by Nix (@pxref{Acknowledgments}).
  266. In Guix, the package build and installation process is seen
  267. as a @emph{function}, in the mathematical sense. That function takes inputs,
  268. such as build scripts, a compiler, and libraries, and
  269. returns an installed package. As a pure function, its result depends
  270. solely on its inputs---for instance, it cannot refer to software or
  271. scripts that were not explicitly passed as inputs. A build function
  272. always produces the same result when passed a given set of inputs. It
  273. cannot alter the environment of the running system in
  274. any way; for instance, it cannot create, modify, or delete files outside
  275. of its build and installation directories. This is achieved by running
  276. build processes in isolated environments (or @dfn{containers}), where only their
  277. explicit inputs are visible.
  278. @cindex store
  279. The result of package build functions is @dfn{cached} in the file
  280. system, in a special directory called @dfn{the store} (@pxref{The
  281. Store}). Each package is installed in a directory of its own in the
  282. store---by default under @file{/gnu/store}. The directory name contains
  283. a hash of all the inputs used to build that package; thus, changing an
  284. input yields a different directory name.
  285. This approach is the foundation for the salient features of Guix: support
  286. for transactional package upgrade and rollback, per-user installation, and
  287. garbage collection of packages (@pxref{Features}).
  288. @c *********************************************************************
  289. @node Installation
  290. @chapter Installation
  291. @cindex installing Guix
  292. GNU Guix is available for download from its website at
  293. @url{http://www.gnu.org/software/guix/}. This section describes the
  294. software requirements of Guix, as well as how to install it and get
  295. ready to use it.
  296. Note that this section is concerned with the installation of the package
  297. manager, which can be done on top of a running GNU/Linux system. If,
  298. instead, you want to install the complete GNU operating system,
  299. @pxref{System Installation}.
  300. @cindex foreign distro
  301. When installed on a running GNU/Linux system---thereafter called a
  302. @dfn{foreign distro}---GNU@tie{}Guix complements the available tools
  303. without interference. Its data lives exclusively in two directories,
  304. usually @file{/gnu/store} and @file{/var/guix}; other files on your
  305. system, such as @file{/etc}, are left untouched.
  306. Once installed, Guix can be updated by running @command{guix pull}
  307. (@pxref{Invoking guix pull}).
  308. @menu
  309. * Binary Installation:: Getting Guix running in no time!
  310. * Requirements:: Software needed to build and run Guix.
  311. * Running the Test Suite:: Testing Guix.
  312. * Setting Up the Daemon:: Preparing the build daemon's environment.
  313. * Invoking guix-daemon:: Running the build daemon.
  314. * Application Setup:: Application-specific setup.
  315. @end menu
  316. @node Binary Installation
  317. @section Binary Installation
  318. @cindex installing Guix from binaries
  319. This section describes how to install Guix on an arbitrary system from a
  320. self-contained tarball providing binaries for Guix and for all its
  321. dependencies. This is often quicker than installing from source, which
  322. is described in the next sections. The only requirement is to have
  323. GNU@tie{}tar and Xz.
  324. Installing goes along these lines:
  325. @enumerate
  326. @item
  327. @cindex downloading Guix binary
  328. Download the binary tarball from
  329. @indicateurl{ftp://alpha.gnu.org/gnu/guix/guix-binary-@value{VERSION}.@var{system}.tar.xz},
  330. where @var{system} is @code{x86_64-linux} for an @code{x86_64} machine
  331. already running the kernel Linux, and so on.
  332. @c The following is somewhat duplicated in ``System Installation''.
  333. Make sure to download the associated @file{.sig} file and to verify the
  334. authenticity of the tarball against it, along these lines:
  335. @example
  336. $ wget ftp://alpha.gnu.org/gnu/guix/guix-binary-@value{VERSION}.@var{system}.tar.xz.sig
  337. $ gpg --verify guix-binary-@value{VERSION}.@var{system}.tar.xz.sig
  338. @end example
  339. If that command fails because you do not have the required public key,
  340. then run this command to import it:
  341. @example
  342. $ gpg --keyserver pgp.mit.edu --recv-keys @value{OPENPGP-SIGNING-KEY-ID}
  343. @end example
  344. @noindent
  345. and rerun the @code{gpg --verify} command.
  346. @c end authentication part
  347. @item
  348. As @code{root}, run:
  349. @example
  350. # cd /tmp
  351. # tar --warning=no-timestamp -xf \
  352. guix-binary-@value{VERSION}.@var{system}.tar.xz
  353. # mv var/guix /var/ && mv gnu /
  354. @end example
  355. This creates @file{/gnu/store} (@pxref{The Store}) and @file{/var/guix}.
  356. The latter contains a ready-to-use profile for @code{root} (see next
  357. step.)
  358. Do @emph{not} unpack the tarball on a working Guix system since that
  359. would overwrite its own essential files.
  360. The @code{--warning=no-timestamp} option makes sure GNU@tie{}tar does
  361. not emit warnings about ``implausibly old time stamps'' (such
  362. warnings were triggered by GNU@tie{}tar 1.26 and older; recent
  363. versions are fine.)
  364. They stem from the fact that all the
  365. files in the archive have their modification time set to zero (which
  366. means January 1st, 1970.) This is done on purpose to make sure the
  367. archive content is independent of its creation time, thus making it
  368. reproducible.
  369. @item
  370. Make @code{root}'s profile available under @file{~/.guix-profile}:
  371. @example
  372. # ln -sf /var/guix/profiles/per-user/root/guix-profile \
  373. ~root/.guix-profile
  374. @end example
  375. Source @file{etc/profile} to augment @code{PATH} and other relevant
  376. environment variables:
  377. @example
  378. # GUIX_PROFILE=$HOME/.guix-profile \
  379. source $GUIX_PROFILE/etc/profile
  380. @end example
  381. @item
  382. Create the group and user accounts for build users as explained below
  383. (@pxref{Build Environment Setup}).
  384. @item
  385. Run the daemon, and set it to automatically start on boot.
  386. If your host distro uses the systemd init system, this can be achieved
  387. with these commands:
  388. @c Versions of systemd that supported symlinked service files are not
  389. @c yet widely deployed, so we should suggest that users copy the service
  390. @c files into place.
  391. @c
  392. @c See this thread for more information:
  393. @c http://lists.gnu.org/archive/html/guix-devel/2017-01/msg01199.html
  394. @example
  395. # cp ~root/.guix-profile/lib/systemd/system/guix-daemon.service \
  396. /etc/systemd/system/
  397. # systemctl start guix-daemon && systemctl enable guix-daemon
  398. @end example
  399. If your host distro uses the Upstart init system:
  400. @example
  401. # initctl reload-configuration
  402. # cp ~root/.guix-profile/lib/upstart/system/guix-daemon.conf /etc/init/
  403. # start guix-daemon
  404. @end example
  405. Otherwise, you can still start the daemon manually with:
  406. @example
  407. # ~root/.guix-profile/bin/guix-daemon --build-users-group=guixbuild
  408. @end example
  409. @item
  410. Make the @command{guix} command available to other users on the machine,
  411. for instance with:
  412. @example
  413. # mkdir -p /usr/local/bin
  414. # cd /usr/local/bin
  415. # ln -s /var/guix/profiles/per-user/root/guix-profile/bin/guix
  416. @end example
  417. It is also a good idea to make the Info version of this manual available
  418. there:
  419. @example
  420. # mkdir -p /usr/local/share/info
  421. # cd /usr/local/share/info
  422. # for i in /var/guix/profiles/per-user/root/guix-profile/share/info/* ;
  423. do ln -s $i ; done
  424. @end example
  425. That way, assuming @file{/usr/local/share/info} is in the search path,
  426. running @command{info guix} will open this manual (@pxref{Other Info
  427. Directories,,, texinfo, GNU Texinfo}, for more details on changing the
  428. Info search path.)
  429. @item
  430. @cindex substitutes, authorization thereof
  431. To use substitutes from @code{hydra.gnu.org} or one of its mirrors
  432. (@pxref{Substitutes}), authorize them:
  433. @example
  434. # guix archive --authorize < ~root/.guix-profile/share/guix/hydra.gnu.org.pub
  435. @end example
  436. @item
  437. Each user may need to perform a few additional steps to make their Guix
  438. environment ready for use, @pxref{Application Setup}.
  439. @end enumerate
  440. Voilà, the installation is complete!
  441. You can confirm that Guix is working by installing a sample package into
  442. the root profile:
  443. @example
  444. # guix package -i hello
  445. @end example
  446. The @code{guix} package must remain available in @code{root}'s profile,
  447. or it would become subject to garbage collection---in which case you
  448. would find yourself badly handicapped by the lack of the @command{guix}
  449. command. In other words, do not remove @code{guix} by running
  450. @code{guix package -r guix}.
  451. The binary installation tarball can be (re)produced and verified simply
  452. by running the following command in the Guix source tree:
  453. @example
  454. make guix-binary.@var{system}.tar.xz
  455. @end example
  456. @noindent
  457. ... which, in turn, runs:
  458. @example
  459. guix pack -s @var{system} --localstatedir guix
  460. @end example
  461. @xref{Invoking guix pack}, for more info on this handy tool.
  462. @node Requirements
  463. @section Requirements
  464. This section lists requirements when building Guix from source. The
  465. build procedure for Guix is the same as for other GNU software, and is
  466. not covered here. Please see the files @file{README} and @file{INSTALL}
  467. in the Guix source tree for additional details.
  468. GNU Guix depends on the following packages:
  469. @itemize
  470. @item @url{http://gnu.org/software/guile/, GNU Guile}, version 2.0.9 or
  471. later, including 2.2.x;
  472. @item @url{http://gnupg.org/, GNU libgcrypt};
  473. @item
  474. @uref{http://gnutls.org/, GnuTLS}, specifically its Guile bindings
  475. (@pxref{Guile Preparations, how to install the GnuTLS bindings for
  476. Guile,, gnutls-guile, GnuTLS-Guile});
  477. @item
  478. @c FIXME: Specify a version number once a release has been made.
  479. @uref{https://gitlab.com/guile-git/guile-git, Guile-Git}, from August
  480. 2017 or later;
  481. @item @url{http://www.gnu.org/software/make/, GNU Make}.
  482. @end itemize
  483. The following dependencies are optional:
  484. @itemize
  485. @item
  486. Installing
  487. @url{http://savannah.nongnu.org/projects/guile-json/, Guile-JSON} will
  488. allow you to use the @command{guix import pypi} command (@pxref{Invoking
  489. guix import}). It is of
  490. interest primarily for developers and not for casual users.
  491. @item
  492. @c Note: We need at least 0.10.2 for 'channel-send-eof'.
  493. Support for build offloading (@pxref{Daemon Offload Setup}) and
  494. @command{guix copy} (@pxref{Invoking guix copy}) depends on
  495. @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH},
  496. version 0.10.2 or later.
  497. @item
  498. When @url{http://zlib.net, zlib} is available, @command{guix publish}
  499. can compress build byproducts (@pxref{Invoking guix publish}).
  500. @end itemize
  501. Unless @code{--disable-daemon} was passed to @command{configure}, the
  502. following packages are also needed:
  503. @itemize
  504. @item @url{http://sqlite.org, SQLite 3};
  505. @item @url{http://www.bzip.org, libbz2};
  506. @item @url{http://gcc.gnu.org, GCC's g++}, with support for the
  507. C++11 standard.
  508. @end itemize
  509. @cindex state directory
  510. When configuring Guix on a system that already has a Guix installation,
  511. be sure to specify the same state directory as the existing installation
  512. using the @code{--localstatedir} option of the @command{configure}
  513. script (@pxref{Directory Variables, @code{localstatedir},, standards,
  514. GNU Coding Standards}). The @command{configure} script protects against
  515. unintended misconfiguration of @var{localstatedir} so you do not
  516. inadvertently corrupt your store (@pxref{The Store}).
  517. @cindex Nix, compatibility
  518. When a working installation of @url{http://nixos.org/nix/, the Nix package
  519. manager} is available, you
  520. can instead configure Guix with @code{--disable-daemon}. In that case,
  521. Nix replaces the three dependencies above.
  522. Guix is compatible with Nix, so it is possible to share the same store
  523. between both. To do so, you must pass @command{configure} not only the
  524. same @code{--with-store-dir} value, but also the same
  525. @code{--localstatedir} value. The latter is essential because it
  526. specifies where the database that stores metadata about the store is
  527. located, among other things. The default values for Nix are
  528. @code{--with-store-dir=/nix/store} and @code{--localstatedir=/nix/var}.
  529. Note that @code{--disable-daemon} is not required if
  530. your goal is to share the store with Nix.
  531. @node Running the Test Suite
  532. @section Running the Test Suite
  533. @cindex test suite
  534. After a successful @command{configure} and @code{make} run, it is a good
  535. idea to run the test suite. It can help catch issues with the setup or
  536. environment, or bugs in Guix itself---and really, reporting test
  537. failures is a good way to help improve the software. To run the test
  538. suite, type:
  539. @example
  540. make check
  541. @end example
  542. Test cases can run in parallel: you can use the @code{-j} option of
  543. GNU@tie{}make to speed things up. The first run may take a few minutes
  544. on a recent machine; subsequent runs will be faster because the store
  545. that is created for test purposes will already have various things in
  546. cache.
  547. It is also possible to run a subset of the tests by defining the
  548. @code{TESTS} makefile variable as in this example:
  549. @example
  550. make check TESTS="tests/store.scm tests/cpio.scm"
  551. @end example
  552. By default, tests results are displayed at a file level. In order to
  553. see the details of every individual test cases, it is possible to define
  554. the @code{SCM_LOG_DRIVER_FLAGS} makefile variable as in this example:
  555. @example
  556. make check TESTS="tests/base64.scm" SCM_LOG_DRIVER_FLAGS="--brief=no"
  557. @end example
  558. Upon failure, please email @email{bug-guix@@gnu.org} and attach the
  559. @file{test-suite.log} file. Please specify the Guix version being used
  560. as well as version numbers of the dependencies (@pxref{Requirements}) in
  561. your message.
  562. Guix also comes with a whole-system test suite that tests complete
  563. GuixSD operating system instances. It can only run on systems where
  564. Guix is already installed, using:
  565. @example
  566. make check-system
  567. @end example
  568. @noindent
  569. or, again, by defining @code{TESTS} to select a subset of tests to run:
  570. @example
  571. make check-system TESTS="basic mcron"
  572. @end example
  573. These system tests are defined in the @code{(gnu tests @dots{})}
  574. modules. They work by running the operating systems under test with
  575. lightweight instrumentation in a virtual machine (VM). They can be
  576. computationally intensive or rather cheap, depending on whether
  577. substitutes are available for their dependencies (@pxref{Substitutes}).
  578. Some of them require a lot of storage space to hold VM images.
  579. Again in case of test failures, please send @email{bug-guix@@gnu.org}
  580. all the details.
  581. @node Setting Up the Daemon
  582. @section Setting Up the Daemon
  583. @cindex daemon
  584. Operations such as building a package or running the garbage collector
  585. are all performed by a specialized process, the @dfn{build daemon}, on
  586. behalf of clients. Only the daemon may access the store and its
  587. associated database. Thus, any operation that manipulates the store
  588. goes through the daemon. For instance, command-line tools such as
  589. @command{guix package} and @command{guix build} communicate with the
  590. daemon (@i{via} remote procedure calls) to instruct it what to do.
  591. The following sections explain how to prepare the build daemon's
  592. environment. See also @ref{Substitutes}, for information on how to allow
  593. the daemon to download pre-built binaries.
  594. @menu
  595. * Build Environment Setup:: Preparing the isolated build environment.
  596. * Daemon Offload Setup:: Offloading builds to remote machines.
  597. @end menu
  598. @node Build Environment Setup
  599. @subsection Build Environment Setup
  600. @cindex build environment
  601. In a standard multi-user setup, Guix and its daemon---the
  602. @command{guix-daemon} program---are installed by the system
  603. administrator; @file{/gnu/store} is owned by @code{root} and
  604. @command{guix-daemon} runs as @code{root}. Unprivileged users may use
  605. Guix tools to build packages or otherwise access the store, and the
  606. daemon will do it on their behalf, ensuring that the store is kept in a
  607. consistent state, and allowing built packages to be shared among users.
  608. @cindex build users
  609. When @command{guix-daemon} runs as @code{root}, you may not want package
  610. build processes themselves to run as @code{root} too, for obvious
  611. security reasons. To avoid that, a special pool of @dfn{build users}
  612. should be created for use by build processes started by the daemon.
  613. These build users need not have a shell and a home directory: they will
  614. just be used when the daemon drops @code{root} privileges in build
  615. processes. Having several such users allows the daemon to launch
  616. distinct build processes under separate UIDs, which guarantees that they
  617. do not interfere with each other---an essential feature since builds are
  618. regarded as pure functions (@pxref{Introduction}).
  619. On a GNU/Linux system, a build user pool may be created like this (using
  620. Bash syntax and the @code{shadow} commands):
  621. @c See http://lists.gnu.org/archive/html/bug-guix/2013-01/msg00239.html
  622. @c for why `-G' is needed.
  623. @example
  624. # groupadd --system guixbuild
  625. # for i in `seq -w 1 10`;
  626. do
  627. useradd -g guixbuild -G guixbuild \
  628. -d /var/empty -s `which nologin` \
  629. -c "Guix build user $i" --system \
  630. guixbuilder$i;
  631. done
  632. @end example
  633. @noindent
  634. The number of build users determines how many build jobs may run in
  635. parallel, as specified by the @option{--max-jobs} option
  636. (@pxref{Invoking guix-daemon, @option{--max-jobs}}). To use
  637. @command{guix system vm} and related commands, you may need to add the
  638. build users to the @code{kvm} group so they can access @file{/dev/kvm},
  639. using @code{-G guixbuild,kvm} instead of @code{-G guixbuild}
  640. (@pxref{Invoking guix system}).
  641. The @code{guix-daemon} program may then be run as @code{root} with the
  642. following command@footnote{If your machine uses the systemd init system,
  643. dropping the @file{@var{prefix}/lib/systemd/system/guix-daemon.service}
  644. file in @file{/etc/systemd/system} will ensure that
  645. @command{guix-daemon} is automatically started. Similarly, if your
  646. machine uses the Upstart init system, drop the
  647. @file{@var{prefix}/lib/upstart/system/guix-daemon.conf}
  648. file in @file{/etc/init}.}:
  649. @example
  650. # guix-daemon --build-users-group=guixbuild
  651. @end example
  652. @cindex chroot
  653. @noindent
  654. This way, the daemon starts build processes in a chroot, under one of
  655. the @code{guixbuilder} users. On GNU/Linux, by default, the chroot
  656. environment contains nothing but:
  657. @c Keep this list in sync with libstore/build.cc! -----------------------
  658. @itemize
  659. @item
  660. a minimal @code{/dev} directory, created mostly independently from the
  661. host @code{/dev}@footnote{``Mostly'', because while the set of files
  662. that appear in the chroot's @code{/dev} is fixed, most of these files
  663. can only be created if the host has them.};
  664. @item
  665. the @code{/proc} directory; it only shows the processes of the container
  666. since a separate PID name space is used;
  667. @item
  668. @file{/etc/passwd} with an entry for the current user and an entry for
  669. user @file{nobody};
  670. @item
  671. @file{/etc/group} with an entry for the user's group;
  672. @item
  673. @file{/etc/hosts} with an entry that maps @code{localhost} to
  674. @code{127.0.0.1};
  675. @item
  676. a writable @file{/tmp} directory.
  677. @end itemize
  678. You can influence the directory where the daemon stores build trees
  679. @i{via} the @code{TMPDIR} environment variable. However, the build tree
  680. within the chroot is always called @file{/tmp/guix-build-@var{name}.drv-0},
  681. where @var{name} is the derivation name---e.g., @code{coreutils-8.24}.
  682. This way, the value of @code{TMPDIR} does not leak inside build
  683. environments, which avoids discrepancies in cases where build processes
  684. capture the name of their build tree.
  685. @vindex http_proxy
  686. The daemon also honors the @code{http_proxy} environment variable for
  687. HTTP downloads it performs, be it for fixed-output derivations
  688. (@pxref{Derivations}) or for substitutes (@pxref{Substitutes}).
  689. If you are installing Guix as an unprivileged user, it is still possible
  690. to run @command{guix-daemon} provided you pass @code{--disable-chroot}.
  691. However, build processes will not be isolated from one another, and not
  692. from the rest of the system. Thus, build processes may interfere with
  693. each other, and may access programs, libraries, and other files
  694. available on the system---making it much harder to view them as
  695. @emph{pure} functions.
  696. @node Daemon Offload Setup
  697. @subsection Using the Offload Facility
  698. @cindex offloading
  699. @cindex build hook
  700. When desired, the build daemon can @dfn{offload} derivation builds to
  701. other machines running Guix, using the @code{offload} @dfn{build
  702. hook}@footnote{This feature is available only when
  703. @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH} is
  704. present.}. When that
  705. feature is enabled, a list of user-specified build machines is read from
  706. @file{/etc/guix/machines.scm}; every time a build is requested, for
  707. instance via @code{guix build}, the daemon attempts to offload it to one
  708. of the machines that satisfy the constraints of the derivation, in
  709. particular its system type---e.g., @file{x86_64-linux}. Missing
  710. prerequisites for the build are copied over SSH to the target machine,
  711. which then proceeds with the build; upon success the output(s) of the
  712. build are copied back to the initial machine.
  713. The @file{/etc/guix/machines.scm} file typically looks like this:
  714. @example
  715. (list (build-machine
  716. (name "eightysix.example.org")
  717. (system "x86_64-linux")
  718. (host-key "ssh-ed25519 AAAAC3Nza@dots{}")
  719. (user "bob")
  720. (speed 2.)) ;incredibly fast!
  721. (build-machine
  722. (name "meeps.example.org")
  723. (system "mips64el-linux")
  724. (host-key "ssh-rsa AAAAB3Nza@dots{}")
  725. (user "alice")
  726. (private-key
  727. (string-append (getenv "HOME")
  728. "/.ssh/identity-for-guix"))))
  729. @end example
  730. @noindent
  731. In the example above we specify a list of two build machines, one for
  732. the @code{x86_64} architecture and one for the @code{mips64el}
  733. architecture.
  734. In fact, this file is---not surprisingly!---a Scheme file that is
  735. evaluated when the @code{offload} hook is started. Its return value
  736. must be a list of @code{build-machine} objects. While this example
  737. shows a fixed list of build machines, one could imagine, say, using
  738. DNS-SD to return a list of potential build machines discovered in the
  739. local network (@pxref{Introduction, Guile-Avahi,, guile-avahi, Using
  740. Avahi in Guile Scheme Programs}). The @code{build-machine} data type is
  741. detailed below.
  742. @deftp {Data Type} build-machine
  743. This data type represents build machines to which the daemon may offload
  744. builds. The important fields are:
  745. @table @code
  746. @item name
  747. The host name of the remote machine.
  748. @item system
  749. The system type of the remote machine---e.g., @code{"x86_64-linux"}.
  750. @item user
  751. The user account to use when connecting to the remote machine over SSH.
  752. Note that the SSH key pair must @emph{not} be passphrase-protected, to
  753. allow non-interactive logins.
  754. @item host-key
  755. This must be the machine's SSH @dfn{public host key} in OpenSSH format.
  756. This is used to authenticate the machine when we connect to it. It is a
  757. long string that looks like this:
  758. @example
  759. ssh-ed25519 AAAAC3NzaC@dots{}mde+UhL hint@@example.org
  760. @end example
  761. If the machine is running the OpenSSH daemon, @command{sshd}, the host
  762. key can be found in a file such as
  763. @file{/etc/ssh/ssh_host_ed25519_key.pub}.
  764. If the machine is running the SSH daemon of GNU@tie{}lsh,
  765. @command{lshd}, the host key is in @file{/etc/lsh/host-key.pub} or a
  766. similar file. It can be converted to the OpenSSH format using
  767. @command{lsh-export-key} (@pxref{Converting keys,,, lsh, LSH Manual}):
  768. @example
  769. $ lsh-export-key --openssh < /etc/lsh/host-key.pub
  770. ssh-rsa AAAAB3NzaC1yc2EAAAAEOp8FoQAAAQEAs1eB46LV@dots{}
  771. @end example
  772. @end table
  773. A number of optional fields may be specified:
  774. @table @asis
  775. @item @code{port} (default: @code{22})
  776. Port number of SSH server on the machine.
  777. @item @code{private-key} (default: @file{~root/.ssh/id_rsa})
  778. The SSH private key file to use when connecting to the machine, in
  779. OpenSSH format.
  780. Note that the default value is the private key @emph{of the root
  781. account}. Make sure it exists if you use the default.
  782. @item @code{compression} (default: @code{"zlib@@openssh.com,zlib"})
  783. @itemx @code{compression-level} (default: @code{3})
  784. The SSH-level compression methods and compression level requested.
  785. Note that offloading relies on SSH compression to reduce bandwidth usage
  786. when transferring files to and from build machines.
  787. @item @code{daemon-socket} (default: @code{"/var/guix/daemon-socket/socket"})
  788. File name of the Unix-domain socket @command{guix-daemon} is listening
  789. to on that machine.
  790. @item @code{parallel-builds} (default: @code{1})
  791. The number of builds that may run in parallel on the machine.
  792. @item @code{speed} (default: @code{1.0})
  793. A ``relative speed factor''. The offload scheduler will tend to prefer
  794. machines with a higher speed factor.
  795. @item @code{features} (default: @code{'()})
  796. A list of strings denoting specific features supported by the machine.
  797. An example is @code{"kvm"} for machines that have the KVM Linux modules
  798. and corresponding hardware support. Derivations can request features by
  799. name, and they will be scheduled on matching build machines.
  800. @end table
  801. @end deftp
  802. The @code{guile} command must be in the search path on the build
  803. machines. In addition, the Guix modules must be in
  804. @code{$GUILE_LOAD_PATH} on the build machine---you can check whether
  805. this is the case by running:
  806. @example
  807. ssh build-machine guile -c "'(use-modules (guix config))'"
  808. @end example
  809. There is one last thing to do once @file{machines.scm} is in place. As
  810. explained above, when offloading, files are transferred back and forth
  811. between the machine stores. For this to work, you first need to
  812. generate a key pair on each machine to allow the daemon to export signed
  813. archives of files from the store (@pxref{Invoking guix archive}):
  814. @example
  815. # guix archive --generate-key
  816. @end example
  817. @noindent
  818. Each build machine must authorize the key of the master machine so that
  819. it accepts store items it receives from the master:
  820. @example
  821. # guix archive --authorize < master-public-key.txt
  822. @end example
  823. @noindent
  824. Likewise, the master machine must authorize the key of each build machine.
  825. All the fuss with keys is here to express pairwise mutual trust
  826. relations between the master and the build machines. Concretely, when
  827. the master receives files from a build machine (and @i{vice versa}), its
  828. build daemon can make sure they are genuine, have not been tampered
  829. with, and that they are signed by an authorized key.
  830. @cindex offload test
  831. To test whether your setup is operational, run this command on the
  832. master node:
  833. @example
  834. # guix offload test
  835. @end example
  836. This will attempt to connect to each of the build machines specified in
  837. @file{/etc/guix/machines.scm}, make sure Guile and the Guix modules are
  838. available on each machine, attempt to export to the machine and import
  839. from it, and report any error in the process.
  840. If you want to test a different machine file, just specify it on the
  841. command line:
  842. @example
  843. # guix offload test machines-qualif.scm
  844. @end example
  845. Last, you can test the subset of the machines whose name matches a
  846. regular expression like this:
  847. @example
  848. # guix offload test machines.scm '\.gnu\.org$'
  849. @end example
  850. @node Invoking guix-daemon
  851. @section Invoking @command{guix-daemon}
  852. The @command{guix-daemon} program implements all the functionality to
  853. access the store. This includes launching build processes, running the
  854. garbage collector, querying the availability of a build result, etc. It
  855. is normally run as @code{root} like this:
  856. @example
  857. # guix-daemon --build-users-group=guixbuild
  858. @end example
  859. @noindent
  860. For details on how to set it up, @pxref{Setting Up the Daemon}.
  861. @cindex chroot
  862. @cindex container, build environment
  863. @cindex build environment
  864. @cindex reproducible builds
  865. By default, @command{guix-daemon} launches build processes under
  866. different UIDs, taken from the build group specified with
  867. @code{--build-users-group}. In addition, each build process is run in a
  868. chroot environment that only contains the subset of the store that the
  869. build process depends on, as specified by its derivation
  870. (@pxref{Programming Interface, derivation}), plus a set of specific
  871. system directories. By default, the latter contains @file{/dev} and
  872. @file{/dev/pts}. Furthermore, on GNU/Linux, the build environment is a
  873. @dfn{container}: in addition to having its own file system tree, it has
  874. a separate mount name space, its own PID name space, network name space,
  875. etc. This helps achieve reproducible builds (@pxref{Features}).
  876. When the daemon performs a build on behalf of the user, it creates a
  877. build directory under @file{/tmp} or under the directory specified by
  878. its @code{TMPDIR} environment variable; this directory is shared with
  879. the container for the duration of the build. Be aware that using a
  880. directory other than @file{/tmp} can affect build results---for example,
  881. with a longer directory name, a build process that uses Unix-domain
  882. sockets might hit the name length limitation for @code{sun_path}, which
  883. it would otherwise not hit.
  884. The build directory is automatically deleted upon completion, unless the
  885. build failed and the client specified @option{--keep-failed}
  886. (@pxref{Invoking guix build, @option{--keep-failed}}).
  887. The following command-line options are supported:
  888. @table @code
  889. @item --build-users-group=@var{group}
  890. Take users from @var{group} to run build processes (@pxref{Setting Up
  891. the Daemon, build users}).
  892. @item --no-substitutes
  893. @cindex substitutes
  894. Do not use substitutes for build products. That is, always build things
  895. locally instead of allowing downloads of pre-built binaries
  896. (@pxref{Substitutes}).
  897. By default substitutes are used, unless the client---such as the
  898. @command{guix package} command---is explicitly invoked with
  899. @code{--no-substitutes}.
  900. When the daemon runs with @code{--no-substitutes}, clients can still
  901. explicitly enable substitution @i{via} the @code{set-build-options}
  902. remote procedure call (@pxref{The Store}).
  903. @item --substitute-urls=@var{urls}
  904. @anchor{daemon-substitute-urls}
  905. Consider @var{urls} the default whitespace-separated list of substitute
  906. source URLs. When this option is omitted,
  907. @indicateurl{https://mirror.hydra.gnu.org https://hydra.gnu.org} is used
  908. (@code{mirror.hydra.gnu.org} is a mirror of @code{hydra.gnu.org}).
  909. This means that substitutes may be downloaded from @var{urls}, as long
  910. as they are signed by a trusted signature (@pxref{Substitutes}).
  911. @cindex build hook
  912. @item --no-build-hook
  913. Do not use the @dfn{build hook}.
  914. The build hook is a helper program that the daemon can start and to
  915. which it submits build requests. This mechanism is used to offload
  916. builds to other machines (@pxref{Daemon Offload Setup}).
  917. @item --cache-failures
  918. Cache build failures. By default, only successful builds are cached.
  919. When this option is used, @command{guix gc --list-failures} can be used
  920. to query the set of store items marked as failed; @command{guix gc
  921. --clear-failures} removes store items from the set of cached failures.
  922. @xref{Invoking guix gc}.
  923. @item --cores=@var{n}
  924. @itemx -c @var{n}
  925. Use @var{n} CPU cores to build each derivation; @code{0} means as many
  926. as available.
  927. The default value is @code{0}, but it may be overridden by clients, such
  928. as the @code{--cores} option of @command{guix build} (@pxref{Invoking
  929. guix build}).
  930. The effect is to define the @code{NIX_BUILD_CORES} environment variable
  931. in the build process, which can then use it to exploit internal
  932. parallelism---for instance, by running @code{make -j$NIX_BUILD_CORES}.
  933. @item --max-jobs=@var{n}
  934. @itemx -M @var{n}
  935. Allow at most @var{n} build jobs in parallel. The default value is
  936. @code{1}. Setting it to @code{0} means that no builds will be performed
  937. locally; instead, the daemon will offload builds (@pxref{Daemon Offload
  938. Setup}), or simply fail.
  939. @item --max-silent-time=@var{seconds}
  940. When the build or substitution process remains silent for more than
  941. @var{seconds}, terminate it and report a build failure.
  942. The default value is @code{0}, which disables the timeout.
  943. The value specified here can be overridden by clients (@pxref{Common
  944. Build Options, @code{--max-silent-time}}).
  945. @item --timeout=@var{seconds}
  946. Likewise, when the build or substitution process lasts for more than
  947. @var{seconds}, terminate it and report a build failure.
  948. The default value is @code{0}, which disables the timeout.
  949. The value specified here can be overridden by clients (@pxref{Common
  950. Build Options, @code{--timeout}}).
  951. @item --rounds=@var{N}
  952. Build each derivation @var{n} times in a row, and raise an error if
  953. consecutive build results are not bit-for-bit identical. Note that this
  954. setting can be overridden by clients such as @command{guix build}
  955. (@pxref{Invoking guix build}).
  956. When used in conjunction with @option{--keep-failed}, the differing
  957. output is kept in the store, under @file{/gnu/store/@dots{}-check}.
  958. This makes it easy to look for differences between the two results.
  959. @item --debug
  960. Produce debugging output.
  961. This is useful to debug daemon start-up issues, but then it may be
  962. overridden by clients, for example the @code{--verbosity} option of
  963. @command{guix build} (@pxref{Invoking guix build}).
  964. @item --chroot-directory=@var{dir}
  965. Add @var{dir} to the build chroot.
  966. Doing this may change the result of build processes---for instance if
  967. they use optional dependencies found in @var{dir} when it is available,
  968. and not otherwise. For that reason, it is not recommended to do so.
  969. Instead, make sure that each derivation declares all the inputs that it
  970. needs.
  971. @item --disable-chroot
  972. Disable chroot builds.
  973. Using this option is not recommended since, again, it would allow build
  974. processes to gain access to undeclared dependencies. It is necessary,
  975. though, when @command{guix-daemon} is running under an unprivileged user
  976. account.
  977. @item --disable-log-compression
  978. Disable compression of the build logs.
  979. Unless @code{--lose-logs} is used, all the build logs are kept in the
  980. @var{localstatedir}. To save space, the daemon automatically compresses
  981. them with bzip2 by default. This option disables that.
  982. @item --disable-deduplication
  983. @cindex deduplication
  984. Disable automatic file ``deduplication'' in the store.
  985. By default, files added to the store are automatically ``deduplicated'':
  986. if a newly added file is identical to another one found in the store,
  987. the daemon makes the new file a hard link to the other file. This can
  988. noticeably reduce disk usage, at the expense of slightly increased
  989. input/output load at the end of a build process. This option disables
  990. this optimization.
  991. @item --gc-keep-outputs[=yes|no]
  992. Tell whether the garbage collector (GC) must keep outputs of live
  993. derivations.
  994. When set to ``yes'', the GC will keep the outputs of any live derivation
  995. available in the store---the @code{.drv} files. The default is ``no'',
  996. meaning that derivation outputs are kept only if they are GC roots.
  997. @item --gc-keep-derivations[=yes|no]
  998. Tell whether the garbage collector (GC) must keep derivations
  999. corresponding to live outputs.
  1000. When set to ``yes'', as is the case by default, the GC keeps
  1001. derivations---i.e., @code{.drv} files---as long as at least one of their
  1002. outputs is live. This allows users to keep track of the origins of
  1003. items in their store. Setting it to ``no'' saves a bit of disk space.
  1004. Note that when both @code{--gc-keep-derivations} and
  1005. @code{--gc-keep-outputs} are used, the effect is to keep all the build
  1006. prerequisites (the sources, compiler, libraries, and other build-time
  1007. tools) of live objects in the store, regardless of whether these
  1008. prerequisites are live. This is convenient for developers since it
  1009. saves rebuilds or downloads.
  1010. @item --impersonate-linux-2.6
  1011. On Linux-based systems, impersonate Linux 2.6. This means that the
  1012. kernel's @code{uname} system call will report 2.6 as the release number.
  1013. This might be helpful to build programs that (usually wrongfully) depend
  1014. on the kernel version number.
  1015. @item --lose-logs
  1016. Do not keep build logs. By default they are kept under
  1017. @code{@var{localstatedir}/guix/log}.
  1018. @item --system=@var{system}
  1019. Assume @var{system} as the current system type. By default it is the
  1020. architecture/kernel pair found at configure time, such as
  1021. @code{x86_64-linux}.
  1022. @item --listen=@var{endpoint}
  1023. Listen for connections on @var{endpoint}. @var{endpoint} is interpreted
  1024. as the file name of a Unix-domain socket if it starts with
  1025. @code{/} (slash sign). Otherwise, @var{endpoint} is interpreted as a
  1026. host name or host name and port to listen to. Here are a few examples:
  1027. @table @code
  1028. @item --listen=/gnu/var/daemon
  1029. Listen for connections on the @file{/gnu/var/daemon} Unix-domain socket,
  1030. creating it if needed.
  1031. @item --listen=localhost
  1032. @cindex daemon, remote access
  1033. @cindex remote access to the daemon
  1034. @cindex daemon, cluster setup
  1035. @cindex clusters, daemon setup
  1036. Listen for TCP connections on the network interface corresponding to
  1037. @code{localhost}, on port 44146.
  1038. @item --listen=128.0.0.42:1234
  1039. Listen for TCP connections on the network interface corresponding to
  1040. @code{128.0.0.42}, on port 1234.
  1041. @end table
  1042. This option can be repeated multiple times, in which case
  1043. @command{guix-daemon} accepts connections on all the specified
  1044. endpoints. Users can tell client commands what endpoint to connect to
  1045. by setting the @code{GUIX_DAEMON_SOCKET} environment variable
  1046. (@pxref{The Store, @code{GUIX_DAEMON_SOCKET}}).
  1047. @quotation Note
  1048. The daemon protocol is @emph{unauthenticated and unencrypted}. Using
  1049. @code{--listen=@var{host}} is suitable on local networks, such as
  1050. clusters, where only trusted nodes may connect to the build daemon. In
  1051. other cases where remote access to the daemon is needed, we recommend
  1052. using Unix-domain sockets along with SSH.
  1053. @end quotation
  1054. When @code{--listen} is omitted, @command{guix-daemon} listens for
  1055. connections on the Unix-domain socket located at
  1056. @file{@var{localstatedir}/daemon-socket/socket}.
  1057. @end table
  1058. @node Application Setup
  1059. @section Application Setup
  1060. @cindex foreign distro
  1061. When using Guix on top of GNU/Linux distribution other than GuixSD---a
  1062. so-called @dfn{foreign distro}---a few additional steps are needed to
  1063. get everything in place. Here are some of them.
  1064. @subsection Locales
  1065. @anchor{locales-and-locpath}
  1066. @cindex locales, when not on GuixSD
  1067. @vindex LOCPATH
  1068. @vindex GUIX_LOCPATH
  1069. Packages installed @i{via} Guix will not use the locale data of the
  1070. host system. Instead, you must first install one of the locale packages
  1071. available with Guix and then define the @code{GUIX_LOCPATH} environment
  1072. variable:
  1073. @example
  1074. $ guix package -i glibc-locales
  1075. $ export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale
  1076. @end example
  1077. Note that the @code{glibc-locales} package contains data for all the
  1078. locales supported by the GNU@tie{}libc and weighs in at around
  1079. 110@tie{}MiB. Alternatively, the @code{glibc-utf8-locales} is smaller but
  1080. limited to a few UTF-8 locales.
  1081. The @code{GUIX_LOCPATH} variable plays a role similar to @code{LOCPATH}
  1082. (@pxref{Locale Names, @code{LOCPATH},, libc, The GNU C Library Reference
  1083. Manual}). There are two important differences though:
  1084. @enumerate
  1085. @item
  1086. @code{GUIX_LOCPATH} is honored only by the libc in Guix, and not by the libc
  1087. provided by foreign distros. Thus, using @code{GUIX_LOCPATH} allows you
  1088. to make sure the programs of the foreign distro will not end up loading
  1089. incompatible locale data.
  1090. @item
  1091. libc suffixes each entry of @code{GUIX_LOCPATH} with @code{/X.Y}, where
  1092. @code{X.Y} is the libc version---e.g., @code{2.22}. This means that,
  1093. should your Guix profile contain a mixture of programs linked against
  1094. different libc version, each libc version will only try to load locale
  1095. data in the right format.
  1096. @end enumerate
  1097. This is important because the locale data format used by different libc
  1098. versions may be incompatible.
  1099. @subsection Name Service Switch
  1100. @cindex name service switch, glibc
  1101. @cindex NSS (name service switch), glibc
  1102. @cindex nscd (name service caching daemon)
  1103. @cindex name service caching daemon (nscd)
  1104. When using Guix on a foreign distro, we @emph{strongly recommend} that
  1105. the system run the GNU C library's @dfn{name service cache daemon},
  1106. @command{nscd}, which should be listening on the
  1107. @file{/var/run/nscd/socket} socket. Failing to do that, applications
  1108. installed with Guix may fail to look up host names or user accounts, or
  1109. may even crash. The next paragraphs explain why.
  1110. @cindex @file{nsswitch.conf}
  1111. The GNU C library implements a @dfn{name service switch} (NSS), which is
  1112. an extensible mechanism for ``name lookups'' in general: host name
  1113. resolution, user accounts, and more (@pxref{Name Service Switch,,, libc,
  1114. The GNU C Library Reference Manual}).
  1115. @cindex Network information service (NIS)
  1116. @cindex NIS (Network information service)
  1117. Being extensible, the NSS supports @dfn{plugins}, which provide new name
  1118. lookup implementations: for example, the @code{nss-mdns} plugin allow
  1119. resolution of @code{.local} host names, the @code{nis} plugin allows
  1120. user account lookup using the Network information service (NIS), and so
  1121. on. These extra ``lookup services'' are configured system-wide in
  1122. @file{/etc/nsswitch.conf}, and all the programs running on the system
  1123. honor those settings (@pxref{NSS Configuration File,,, libc, The GNU C
  1124. Reference Manual}).
  1125. When they perform a name lookup---for instance by calling the
  1126. @code{getaddrinfo} function in C---applications first try to connect to
  1127. the nscd; on success, nscd performs name lookups on their behalf. If
  1128. the nscd is not running, then they perform the name lookup by
  1129. themselves, by loading the name lookup services into their own address
  1130. space and running it. These name lookup services---the
  1131. @file{libnss_*.so} files---are @code{dlopen}'d, but they may come from
  1132. the host system's C library, rather than from the C library the
  1133. application is linked against (the C library coming from Guix).
  1134. And this is where the problem is: if your application is linked against
  1135. Guix's C library (say, glibc 2.24) and tries to load NSS plugins from
  1136. another C library (say, @code{libnss_mdns.so} for glibc 2.22), it will
  1137. likely crash or have its name lookups fail unexpectedly.
  1138. Running @command{nscd} on the system, among other advantages, eliminates
  1139. this binary incompatibility problem because those @code{libnss_*.so}
  1140. files are loaded in the @command{nscd} process, not in applications
  1141. themselves.
  1142. @subsection X11 Fonts
  1143. @cindex fonts
  1144. The majority of graphical applications use Fontconfig to locate and
  1145. load fonts and perform X11-client-side rendering. The @code{fontconfig}
  1146. package in Guix looks for fonts in @file{$HOME/.guix-profile}
  1147. by default. Thus, to allow graphical applications installed with Guix
  1148. to display fonts, you have to install fonts with Guix as well.
  1149. Essential font packages include @code{gs-fonts}, @code{font-dejavu}, and
  1150. @code{font-gnu-freefont-ttf}.
  1151. To display text written in Chinese languages, Japanese, or Korean in
  1152. graphical applications, consider installing
  1153. @code{font-adobe-source-han-sans} or @code{font-wqy-zenhei}. The former
  1154. has multiple outputs, one per language family (@pxref{Packages with
  1155. Multiple Outputs}). For instance, the following command installs fonts
  1156. for Chinese languages:
  1157. @example
  1158. guix package -i font-adobe-source-han-sans:cn
  1159. @end example
  1160. @cindex @code{xterm}
  1161. Older programs such as @command{xterm} do not use Fontconfig and instead
  1162. rely on server-side font rendering. Such programs require to specify a
  1163. full name of a font using XLFD (X Logical Font Description), like this:
  1164. @example
  1165. -*-dejavu sans-medium-r-normal-*-*-100-*-*-*-*-*-1
  1166. @end example
  1167. To be able to use such full names for the TrueType fonts installed in
  1168. your Guix profile, you need to extend the font path of the X server:
  1169. @example
  1170. xset +fp ~/.guix-profile/share/fonts/truetype
  1171. @end example
  1172. @cindex @code{xlsfonts}
  1173. After that, you can run @code{xlsfonts} (from @code{xlsfonts} package)
  1174. to make sure your TrueType fonts are listed there.
  1175. @cindex @code{fc-cache}
  1176. @cindex font cache
  1177. After installing fonts you may have to refresh the font cache to use
  1178. them in applications. The same applies when applications installed via
  1179. Guix do not seem to find fonts. To force rebuilding of the font cache
  1180. run @code{fc-cache -f}. The @code{fc-cache} command is provided by the
  1181. @code{fontconfig} package.
  1182. @subsection X.509 Certificates
  1183. @cindex @code{nss-certs}
  1184. The @code{nss-certs} package provides X.509 certificates, which allow
  1185. programs to authenticate Web servers accessed over HTTPS.
  1186. When using Guix on a foreign distro, you can install this package and
  1187. define the relevant environment variables so that packages know where to
  1188. look for certificates. @xref{X.509 Certificates}, for detailed
  1189. information.
  1190. @subsection Emacs Packages
  1191. @cindex @code{emacs}
  1192. When you install Emacs packages with Guix, the elisp files may be placed
  1193. either in @file{$HOME/.guix-profile/share/emacs/site-lisp/} or in
  1194. sub-directories of
  1195. @file{$HOME/.guix-profile/share/emacs/site-lisp/guix.d/}. The latter
  1196. directory exists because potentially there may exist thousands of Emacs
  1197. packages and storing all their files in a single directory may be not
  1198. reliable (because of name conflicts). So we think using a separate
  1199. directory for each package is a good idea. It is very similar to how
  1200. the Emacs package system organizes the file structure (@pxref{Package
  1201. Files,,, emacs, The GNU Emacs Manual}).
  1202. By default, Emacs (installed with Guix) ``knows'' where these packages
  1203. are placed, so you do not need to perform any configuration. If, for
  1204. some reason, you want to avoid auto-loading Emacs packages installed
  1205. with Guix, you can do so by running Emacs with @code{--no-site-file}
  1206. option (@pxref{Init File,,, emacs, The GNU Emacs Manual}).
  1207. @subsection The GCC toolchain
  1208. @cindex GCC
  1209. @cindex ld-wrapper
  1210. Guix offers individual compiler packages such as @code{gcc} but if you
  1211. are in need of a complete toolchain for compiling and linking source
  1212. code what you really want is the @code{gcc-toolchain} package. This
  1213. package provides a complete GCC toolchain for C/C++ development,
  1214. including GCC itself, the GNU C Library (headers and binaries, plus
  1215. debugging symbols in the @code{debug} output), Binutils, and a linker
  1216. wrapper.
  1217. @cindex attempt to use impure library, error message
  1218. The wrapper's purpose is to inspect the @code{-L} and @code{-l} switches
  1219. passed to the linker, add corresponding @code{-rpath} arguments, and
  1220. invoke the actual linker with this new set of arguments. By default,
  1221. the linker wrapper refuses to link to libraries outside the store to
  1222. ensure ``purity''. This can be annoying when using the toolchain to
  1223. link with local libraries. To allow references to libraries outside the
  1224. store you need to define the environment variable
  1225. @code{GUIX_LD_WRAPPER_ALLOW_IMPURITIES}.
  1226. @c TODO What else?
  1227. @c *********************************************************************
  1228. @node Package Management
  1229. @chapter Package Management
  1230. @cindex packages
  1231. The purpose of GNU Guix is to allow users to easily install, upgrade, and
  1232. remove software packages, without having to know about their build
  1233. procedures or dependencies. Guix also goes beyond this obvious set of
  1234. features.
  1235. This chapter describes the main features of Guix, as well as the
  1236. package management tools it provides. Along with the command-line
  1237. interface described below (@pxref{Invoking guix package, @code{guix
  1238. package}}), you may also use Emacs Interface (@pxref{Top,,,
  1239. emacs-guix, The Emacs-Guix Reference Manual}), after installing
  1240. @code{emacs-guix} package (run @kbd{M-x guix-help} command to start
  1241. with it):
  1242. @example
  1243. guix package -i emacs-guix
  1244. @end example
  1245. @menu
  1246. * Features:: How Guix will make your life brighter.
  1247. * Invoking guix package:: Package installation, removal, etc.
  1248. * Substitutes:: Downloading pre-built binaries.
  1249. * Packages with Multiple Outputs:: Single source package, multiple outputs.
  1250. * Invoking guix gc:: Running the garbage collector.
  1251. * Invoking guix pull:: Fetching the latest Guix and distribution.
  1252. * Invoking guix pack:: Creating software bundles.
  1253. * Invoking guix archive:: Exporting and importing store files.
  1254. @end menu
  1255. @node Features
  1256. @section Features
  1257. When using Guix, each package ends up in the @dfn{package store}, in its
  1258. own directory---something that resembles
  1259. @file{/gnu/store/xxx-package-1.2}, where @code{xxx} is a base32 string.
  1260. Instead of referring to these directories, users have their own
  1261. @dfn{profile}, which points to the packages that they actually want to
  1262. use. These profiles are stored within each user's home directory, at
  1263. @code{$HOME/.guix-profile}.
  1264. For example, @code{alice} installs GCC 4.7.2. As a result,
  1265. @file{/home/alice/.guix-profile/bin/gcc} points to
  1266. @file{/gnu/store/@dots{}-gcc-4.7.2/bin/gcc}. Now, on the same machine,
  1267. @code{bob} had already installed GCC 4.8.0. The profile of @code{bob}
  1268. simply continues to point to
  1269. @file{/gnu/store/@dots{}-gcc-4.8.0/bin/gcc}---i.e., both versions of GCC
  1270. coexist on the same system without any interference.
  1271. The @command{guix package} command is the central tool to manage
  1272. packages (@pxref{Invoking guix package}). It operates on the per-user
  1273. profiles, and can be used @emph{with normal user privileges}.
  1274. @cindex transactions
  1275. The command provides the obvious install, remove, and upgrade
  1276. operations. Each invocation is actually a @emph{transaction}: either
  1277. the specified operation succeeds, or nothing happens. Thus, if the
  1278. @command{guix package} process is terminated during the transaction,
  1279. or if a power outage occurs during the transaction, then the user's
  1280. profile remains in its previous state, and remains usable.
  1281. In addition, any package transaction may be @emph{rolled back}. So, if,
  1282. for example, an upgrade installs a new version of a package that turns
  1283. out to have a serious bug, users may roll back to the previous instance
  1284. of their profile, which was known to work well. Similarly, the global
  1285. system configuration on GuixSD is subject to
  1286. transactional upgrades and roll-back
  1287. (@pxref{Using the Configuration System}).
  1288. All packages in the package store may be @emph{garbage-collected}.
  1289. Guix can determine which packages are still referenced by user
  1290. profiles, and remove those that are provably no longer referenced
  1291. (@pxref{Invoking guix gc}). Users may also explicitly remove old
  1292. generations of their profile so that the packages they refer to can be
  1293. collected.
  1294. @cindex reproducibility
  1295. @cindex reproducible builds
  1296. Finally, Guix takes a @dfn{purely functional} approach to package
  1297. management, as described in the introduction (@pxref{Introduction}).
  1298. Each @file{/gnu/store} package directory name contains a hash of all the
  1299. inputs that were used to build that package---compiler, libraries, build
  1300. scripts, etc. This direct correspondence allows users to make sure a
  1301. given package installation matches the current state of their
  1302. distribution. It also helps maximize @dfn{build reproducibility}:
  1303. thanks to the isolated build environments that are used, a given build
  1304. is likely to yield bit-identical files when performed on different
  1305. machines (@pxref{Invoking guix-daemon, container}).
  1306. @cindex substitutes
  1307. This foundation allows Guix to support @dfn{transparent binary/source
  1308. deployment}. When a pre-built binary for a @file{/gnu/store} item is
  1309. available from an external source---a @dfn{substitute}, Guix just
  1310. downloads it and unpacks it;
  1311. otherwise, it builds the package from source, locally
  1312. (@pxref{Substitutes}). Because build results are usually bit-for-bit
  1313. reproducible, users do not have to trust servers that provide
  1314. substitutes: they can force a local build and @emph{challenge} providers
  1315. (@pxref{Invoking guix challenge}).
  1316. Control over the build environment is a feature that is also useful for
  1317. developers. The @command{guix environment} command allows developers of
  1318. a package to quickly set up the right development environment for their
  1319. package, without having to manually install the dependencies of the
  1320. package into their profile (@pxref{Invoking guix environment}).
  1321. @node Invoking guix package
  1322. @section Invoking @command{guix package}
  1323. @cindex installing packages
  1324. @cindex removing packages
  1325. @cindex package installation
  1326. @cindex package removal
  1327. The @command{guix package} command is the tool that allows users to
  1328. install, upgrade, and remove packages, as well as rolling back to
  1329. previous configurations. It operates only on the user's own profile,
  1330. and works with normal user privileges (@pxref{Features}). Its syntax
  1331. is:
  1332. @example
  1333. guix package @var{options}
  1334. @end example
  1335. @cindex transactions
  1336. Primarily, @var{options} specifies the operations to be performed during
  1337. the transaction. Upon completion, a new profile is created, but
  1338. previous @dfn{generations} of the profile remain available, should the user
  1339. want to roll back.
  1340. For example, to remove @code{lua} and install @code{guile} and
  1341. @code{guile-cairo} in a single transaction:
  1342. @example
  1343. guix package -r lua -i guile guile-cairo
  1344. @end example
  1345. @command{guix package} also supports a @dfn{declarative approach}
  1346. whereby the user specifies the exact set of packages to be available and
  1347. passes it @i{via} the @option{--manifest} option
  1348. (@pxref{profile-manifest, @option{--manifest}}).
  1349. @cindex profile
  1350. For each user, a symlink to the user's default profile is automatically
  1351. created in @file{$HOME/.guix-profile}. This symlink always points to the
  1352. current generation of the user's default profile. Thus, users can add
  1353. @file{$HOME/.guix-profile/bin} to their @code{PATH} environment
  1354. variable, and so on.
  1355. @cindex search paths
  1356. If you are not using the Guix System Distribution, consider adding the
  1357. following lines to your @file{~/.bash_profile} (@pxref{Bash Startup
  1358. Files,,, bash, The GNU Bash Reference Manual}) so that newly-spawned
  1359. shells get all the right environment variable definitions:
  1360. @example
  1361. GUIX_PROFILE="$HOME/.guix-profile" \
  1362. source "$HOME/.guix-profile/etc/profile"
  1363. @end example
  1364. In a multi-user setup, user profiles are stored in a place registered as
  1365. a @dfn{garbage-collector root}, which @file{$HOME/.guix-profile} points
  1366. to (@pxref{Invoking guix gc}). That directory is normally
  1367. @code{@var{localstatedir}/profiles/per-user/@var{user}}, where
  1368. @var{localstatedir} is the value passed to @code{configure} as
  1369. @code{--localstatedir}, and @var{user} is the user name. The
  1370. @file{per-user} directory is created when @command{guix-daemon} is
  1371. started, and the @var{user} sub-directory is created by @command{guix
  1372. package}.
  1373. The @var{options} can be among the following:
  1374. @table @code
  1375. @item --install=@var{package} @dots{}
  1376. @itemx -i @var{package} @dots{}
  1377. Install the specified @var{package}s.
  1378. Each @var{package} may specify either a simple package name, such as
  1379. @code{guile}, or a package name followed by an at-sign and version number,
  1380. such as @code{guile@@1.8.8} or simply @code{guile@@1.8} (in the latter
  1381. case, the newest version prefixed by @code{1.8} is selected.)
  1382. If no version number is specified, the
  1383. newest available version will be selected. In addition, @var{package}
  1384. may contain a colon, followed by the name of one of the outputs of the
  1385. package, as in @code{gcc:doc} or @code{binutils@@2.22:lib}
  1386. (@pxref{Packages with Multiple Outputs}). Packages with a corresponding
  1387. name (and optionally version) are searched for among the GNU
  1388. distribution modules (@pxref{Package Modules}).
  1389. @cindex propagated inputs
  1390. Sometimes packages have @dfn{propagated inputs}: these are dependencies
  1391. that automatically get installed along with the required package
  1392. (@pxref{package-propagated-inputs, @code{propagated-inputs} in
  1393. @code{package} objects}, for information about propagated inputs in
  1394. package definitions).
  1395. @anchor{package-cmd-propagated-inputs}
  1396. An example is the GNU MPC library: its C header files refer to those of
  1397. the GNU MPFR library, which in turn refer to those of the GMP library.
  1398. Thus, when installing MPC, the MPFR and GMP libraries also get installed
  1399. in the profile; removing MPC also removes MPFR and GMP---unless they had
  1400. also been explicitly installed by the user.
  1401. Besides, packages sometimes rely on the definition of environment
  1402. variables for their search paths (see explanation of
  1403. @code{--search-paths} below). Any missing or possibly incorrect
  1404. environment variable definitions are reported here.
  1405. @item --install-from-expression=@var{exp}
  1406. @itemx -e @var{exp}
  1407. Install the package @var{exp} evaluates to.
  1408. @var{exp} must be a Scheme expression that evaluates to a
  1409. @code{<package>} object. This option is notably useful to disambiguate
  1410. between same-named variants of a package, with expressions such as
  1411. @code{(@@ (gnu packages base) guile-final)}.
  1412. Note that this option installs the first output of the specified
  1413. package, which may be insufficient when needing a specific output of a
  1414. multiple-output package.
  1415. @item --install-from-file=@var{file}
  1416. @itemx -f @var{file}
  1417. Install the package that the code within @var{file} evaluates to.
  1418. As an example, @var{file} might contain a definition like this
  1419. (@pxref{Defining Packages}):
  1420. @example
  1421. @verbatiminclude package-hello.scm
  1422. @end example
  1423. Developers may find it useful to include such a @file{guix.scm} file
  1424. in the root of their project source tree that can be used to test
  1425. development snapshots and create reproducible development environments
  1426. (@pxref{Invoking guix environment}).
  1427. @item --remove=@var{package} @dots{}
  1428. @itemx -r @var{package} @dots{}
  1429. Remove the specified @var{package}s.
  1430. As for @code{--install}, each @var{package} may specify a version number
  1431. and/or output name in addition to the package name. For instance,
  1432. @code{-r glibc:debug} would remove the @code{debug} output of
  1433. @code{glibc}.
  1434. @item --upgrade[=@var{regexp} @dots{}]
  1435. @itemx -u [@var{regexp} @dots{}]
  1436. @cindex upgrading packages
  1437. Upgrade all the installed packages. If one or more @var{regexp}s are
  1438. specified, upgrade only installed packages whose name matches a
  1439. @var{regexp}. Also see the @code{--do-not-upgrade} option below.
  1440. Note that this upgrades package to the latest version of packages found
  1441. in the distribution currently installed. To update your distribution,
  1442. you should regularly run @command{guix pull} (@pxref{Invoking guix
  1443. pull}).
  1444. @item --do-not-upgrade[=@var{regexp} @dots{}]
  1445. When used together with the @code{--upgrade} option, do @emph{not}
  1446. upgrade any packages whose name matches a @var{regexp}. For example, to
  1447. upgrade all packages in the current profile except those containing the
  1448. substring ``emacs'':
  1449. @example
  1450. $ guix package --upgrade . --do-not-upgrade emacs
  1451. @end example
  1452. @item @anchor{profile-manifest}--manifest=@var{file}
  1453. @itemx -m @var{file}
  1454. @cindex profile declaration
  1455. @cindex profile manifest
  1456. Create a new generation of the profile from the manifest object
  1457. returned by the Scheme code in @var{file}.
  1458. This allows you to @emph{declare} the profile's contents rather than
  1459. constructing it through a sequence of @code{--install} and similar
  1460. commands. The advantage is that @var{file} can be put under version
  1461. control, copied to different machines to reproduce the same profile, and
  1462. so on.
  1463. @c FIXME: Add reference to (guix profile) documentation when available.
  1464. @var{file} must return a @dfn{manifest} object, which is roughly a list
  1465. of packages:
  1466. @findex packages->manifest
  1467. @example
  1468. (use-package-modules guile emacs)
  1469. (packages->manifest
  1470. (list emacs
  1471. guile-2.0
  1472. ;; Use a specific package output.
  1473. (list guile-2.0 "debug")))
  1474. @end example
  1475. @findex specifications->manifest
  1476. In this example we have to know which modules define the @code{emacs}
  1477. and @code{guile-2.0} variables to provide the right
  1478. @code{use-package-modules} line, which can be cumbersome. We can
  1479. instead provide regular package specifications and let
  1480. @code{specifications->manifest} look up the corresponding package
  1481. objects, like this:
  1482. @example
  1483. (specifications->manifest
  1484. '("emacs" "guile@@2.2" "guile@@2.2:debug"))
  1485. @end example
  1486. @item --roll-back
  1487. @cindex rolling back
  1488. @cindex undoing transactions
  1489. @cindex transactions, undoing
  1490. Roll back to the previous @dfn{generation} of the profile---i.e., undo
  1491. the last transaction.
  1492. When combined with options such as @code{--install}, roll back occurs
  1493. before any other actions.
  1494. When rolling back from the first generation that actually contains
  1495. installed packages, the profile is made to point to the @dfn{zeroth
  1496. generation}, which contains no files apart from its own metadata.
  1497. After having rolled back, installing, removing, or upgrading packages
  1498. overwrites previous future generations. Thus, the history of the
  1499. generations in a profile is always linear.
  1500. @item --switch-generation=@var{pattern}
  1501. @itemx -S @var{pattern}
  1502. @cindex generations
  1503. Switch to a particular generation defined by @var{pattern}.
  1504. @var{pattern} may be either a generation number or a number prefixed
  1505. with ``+'' or ``-''. The latter means: move forward/backward by a
  1506. specified number of generations. For example, if you want to return to
  1507. the latest generation after @code{--roll-back}, use
  1508. @code{--switch-generation=+1}.
  1509. The difference between @code{--roll-back} and
  1510. @code{--switch-generation=-1} is that @code{--switch-generation} will
  1511. not make a zeroth generation, so if a specified generation does not
  1512. exist, the current generation will not be changed.
  1513. @item --search-paths[=@var{kind}]
  1514. @cindex search paths
  1515. Report environment variable definitions, in Bash syntax, that may be
  1516. needed in order to use the set of installed packages. These environment
  1517. variables are used to specify @dfn{search paths} for files used by some
  1518. of the installed packages.
  1519. For example, GCC needs the @code{CPATH} and @code{LIBRARY_PATH}
  1520. environment variables to be defined so it can look for headers and
  1521. libraries in the user's profile (@pxref{Environment Variables,,, gcc,
  1522. Using the GNU Compiler Collection (GCC)}). If GCC and, say, the C
  1523. library are installed in the profile, then @code{--search-paths} will
  1524. suggest setting these variables to @code{@var{profile}/include} and
  1525. @code{@var{profile}/lib}, respectively.
  1526. The typical use case is to define these environment variables in the
  1527. shell:
  1528. @example
  1529. $ eval `guix package --search-paths`
  1530. @end example
  1531. @var{kind} may be one of @code{exact}, @code{prefix}, or @code{suffix},
  1532. meaning that the returned environment variable definitions will either
  1533. be exact settings, or prefixes or suffixes of the current value of these
  1534. variables. When omitted, @var{kind} defaults to @code{exact}.
  1535. This option can also be used to compute the @emph{combined} search paths
  1536. of several profiles. Consider this example:
  1537. @example
  1538. $ guix package -p foo -i guile
  1539. $ guix package -p bar -i guile-json
  1540. $ guix package -p foo -p bar --search-paths
  1541. @end example
  1542. The last command above reports about the @code{GUILE_LOAD_PATH}
  1543. variable, even though, taken individually, neither @file{foo} nor
  1544. @file{bar} would lead to that recommendation.
  1545. @item --profile=@var{profile}
  1546. @itemx -p @var{profile}
  1547. Use @var{profile} instead of the user's default profile.
  1548. @item --verbose
  1549. Produce verbose output. In particular, emit the build log of the
  1550. environment on the standard error port.
  1551. @item --bootstrap
  1552. Use the bootstrap Guile to build the profile. This option is only
  1553. useful to distribution developers.
  1554. @end table
  1555. In addition to these actions, @command{guix package} supports the
  1556. following options to query the current state of a profile, or the
  1557. availability of packages:
  1558. @table @option
  1559. @item --search=@var{regexp}
  1560. @itemx -s @var{regexp}
  1561. @cindex searching for packages
  1562. List the available packages whose name, synopsis, or description matches
  1563. @var{regexp}, sorted by relevance. Print all the metadata of matching packages in
  1564. @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils,
  1565. GNU recutils manual}).
  1566. This allows specific fields to be extracted using the @command{recsel}
  1567. command, for instance:
  1568. @example
  1569. $ guix package -s malloc | recsel -p name,version,relevance
  1570. name: jemalloc
  1571. version: 4.5.0
  1572. relevance: 6
  1573. name: glibc
  1574. version: 2.25
  1575. relevance: 1
  1576. name: libgc
  1577. version: 7.6.0
  1578. relevance: 1
  1579. @end example
  1580. Similarly, to show the name of all the packages available under the
  1581. terms of the GNU@tie{}LGPL version 3:
  1582. @example
  1583. $ guix package -s "" | recsel -p name -e 'license ~ "LGPL 3"'
  1584. name: elfutils
  1585. name: gmp
  1586. @dots{}
  1587. @end example
  1588. It is also possible to refine search results using several @code{-s}
  1589. flags. For example, the following command returns a list of board
  1590. games:
  1591. @example
  1592. $ guix package -s '\<board\>' -s game | recsel -p name
  1593. name: gnubg
  1594. @dots{}
  1595. @end example
  1596. If we were to omit @code{-s game}, we would also get software packages
  1597. that deal with printed circuit boards; removing the angle brackets
  1598. around @code{board} would further add packages that have to do with
  1599. keyboards.
  1600. And now for a more elaborate example. The following command searches
  1601. for cryptographic libraries, filters out Haskell, Perl, Python, and Ruby
  1602. libraries, and prints the name and synopsis of the matching packages:
  1603. @example
  1604. $ guix package -s crypto -s library | \
  1605. recsel -e '! (name ~ "^(ghc|perl|python|ruby)")' -p name,synopsis
  1606. @end example
  1607. @noindent
  1608. @xref{Selection Expressions,,, recutils, GNU recutils manual}, for more
  1609. information on @dfn{selection expressions} for @code{recsel -e}.
  1610. @item --show=@var{package}
  1611. Show details about @var{package}, taken from the list of available packages, in
  1612. @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils, GNU
  1613. recutils manual}).
  1614. @example
  1615. $ guix package --show=python | recsel -p name,version
  1616. name: python
  1617. version: 2.7.6
  1618. name: python
  1619. version: 3.3.5
  1620. @end example
  1621. You may also specify the full name of a package to only get details about a
  1622. specific version of it:
  1623. @example
  1624. $ guix package --show=python@@3.4 | recsel -p name,version
  1625. name: python
  1626. version: 3.4.3
  1627. @end example
  1628. @item --list-installed[=@var{regexp}]
  1629. @itemx -I [@var{regexp}]
  1630. List the currently installed packages in the specified profile, with the
  1631. most recently installed packages shown last. When @var{regexp} is
  1632. specified, list only installed packages whose name matches @var{regexp}.
  1633. For each installed package, print the following items, separated by
  1634. tabs: the package name, its version string, the part of the package that
  1635. is installed (for instance, @code{out} for the default output,
  1636. @code{include} for its headers, etc.), and the path of this package in
  1637. the store.
  1638. @item --list-available[=@var{regexp}]
  1639. @itemx -A [@var{regexp}]
  1640. List packages currently available in the distribution for this system
  1641. (@pxref{GNU Distribution}). When @var{regexp} is specified, list only
  1642. installed packages whose name matches @var{regexp}.
  1643. For each package, print the following items separated by tabs: its name,
  1644. its version string, the parts of the package (@pxref{Packages with
  1645. Multiple Outputs}), and the source location of its definition.
  1646. @item --list-generations[=@var{pattern}]
  1647. @itemx -l [@var{pattern}]
  1648. @cindex generations
  1649. Return a list of generations along with their creation dates; for each
  1650. generation, show the installed packages, with the most recently
  1651. installed packages shown last. Note that the zeroth generation is never
  1652. shown.
  1653. For each installed package, print the following items, separated by
  1654. tabs: the name of a package, its version string, the part of the package
  1655. that is installed (@pxref{Packages with Multiple Outputs}), and the
  1656. location of this package in the store.
  1657. When @var{pattern} is used, the command returns only matching
  1658. generations. Valid patterns include:
  1659. @itemize
  1660. @item @emph{Integers and comma-separated integers}. Both patterns denote
  1661. generation numbers. For instance, @code{--list-generations=1} returns
  1662. the first one.
  1663. And @code{--list-generations=1,8,2} outputs three generations in the
  1664. specified order. Neither spaces nor trailing commas are allowed.
  1665. @item @emph{Ranges}. @code{--list-generations=2..9} prints the
  1666. specified generations and everything in between. Note that the start of
  1667. a range must be smaller than its end.
  1668. It is also possible to omit the endpoint. For example,
  1669. @code{--list-generations=2..}, returns all generations starting from the
  1670. second one.
  1671. @item @emph{Durations}. You can also get the last @emph{N}@tie{}days, weeks,
  1672. or months by passing an integer along with the first letter of the
  1673. duration. For example, @code{--list-generations=20d} lists generations
  1674. that are up to 20 days old.
  1675. @end itemize
  1676. @item --delete-generations[=@var{pattern}]
  1677. @itemx -d [@var{pattern}]
  1678. When @var{pattern} is omitted, delete all generations except the current
  1679. one.
  1680. This command accepts the same patterns as @option{--list-generations}.
  1681. When @var{pattern} is specified, delete the matching generations. When
  1682. @var{pattern} specifies a duration, generations @emph{older} than the
  1683. specified duration match. For instance, @code{--delete-generations=1m}
  1684. deletes generations that are more than one month old.
  1685. If the current generation matches, it is @emph{not} deleted. Also, the
  1686. zeroth generation is never deleted.
  1687. Note that deleting generations prevents rolling back to them.
  1688. Consequently, this command must be used with care.
  1689. @end table
  1690. Finally, since @command{guix package} may actually start build
  1691. processes, it supports all the common build options (@pxref{Common Build
  1692. Options}). It also supports package transformation options, such as
  1693. @option{--with-source} (@pxref{Package Transformation Options}).
  1694. However, note that package transformations are lost when upgrading; to
  1695. preserve transformations across upgrades, you should define your own
  1696. package variant in a Guile module and add it to @code{GUIX_PACKAGE_PATH}
  1697. (@pxref{Defining Packages}).
  1698. @node Substitutes
  1699. @section Substitutes
  1700. @cindex substitutes
  1701. @cindex pre-built binaries
  1702. Guix supports transparent source/binary deployment, which means that it
  1703. can either build things locally, or download pre-built items from a
  1704. server. We call these pre-built items @dfn{substitutes}---they are
  1705. substitutes for local build results. In many cases, downloading a
  1706. substitute is much faster than building things locally.
  1707. Substitutes can be anything resulting from a derivation build
  1708. (@pxref{Derivations}). Of course, in the common case, they are
  1709. pre-built package binaries, but source tarballs, for instance, which
  1710. also result from derivation builds, can be available as substitutes.
  1711. The @code{hydra.gnu.org} server is a front-end to a build farm that
  1712. builds packages from the GNU distribution continuously for some
  1713. architectures, and makes them available as substitutes. This is the
  1714. default source of substitutes; it can be overridden by passing the
  1715. @option{--substitute-urls} option either to @command{guix-daemon}
  1716. (@pxref{daemon-substitute-urls,, @code{guix-daemon --substitute-urls}})
  1717. or to client tools such as @command{guix package}
  1718. (@pxref{client-substitute-urls,, client @option{--substitute-urls}
  1719. option}).
  1720. Substitute URLs can be either HTTP or HTTPS.
  1721. HTTPS is recommended because communications are encrypted; conversely,
  1722. using HTTP makes all communications visible to an eavesdropper, who
  1723. could use the information gathered to determine, for instance, whether
  1724. your system has unpatched security vulnerabilities.
  1725. @cindex security
  1726. @cindex digital signatures
  1727. @cindex substitutes, authorization thereof
  1728. @cindex access control list (ACL), for substitutes
  1729. @cindex ACL (access control list), for substitutes
  1730. To allow Guix to download substitutes from @code{hydra.gnu.org} or a
  1731. mirror thereof, you
  1732. must add its public key to the access control list (ACL) of archive
  1733. imports, using the @command{guix archive} command (@pxref{Invoking guix
  1734. archive}). Doing so implies that you trust @code{hydra.gnu.org} to not
  1735. be compromised and to serve genuine substitutes.
  1736. This public key is installed along with Guix, in
  1737. @code{@var{prefix}/share/guix/hydra.gnu.org.pub}, where @var{prefix} is
  1738. the installation prefix of Guix. If you installed Guix from source,
  1739. make sure you checked the GPG signature of
  1740. @file{guix-@value{VERSION}.tar.gz}, which contains this public key file.
  1741. Then, you can run something like this:
  1742. @example
  1743. # guix archive --authorize < hydra.gnu.org.pub
  1744. @end example
  1745. Once this is in place, the output of a command like @code{guix build}
  1746. should change from something like:
  1747. @example
  1748. $ guix build emacs --dry-run
  1749. The following derivations would be built:
  1750. /gnu/store/yr7bnx8xwcayd6j95r2clmkdl1qh688w-emacs-24.3.drv
  1751. /gnu/store/x8qsh1hlhgjx6cwsjyvybnfv2i37z23w-dbus-1.6.4.tar.gz.drv
  1752. /gnu/store/1ixwp12fl950d15h2cj11c73733jay0z-alsa-lib-1.0.27.1.tar.bz2.drv
  1753. /gnu/store/nlma1pw0p603fpfiqy7kn4zm105r5dmw-util-linux-2.21.drv
  1754. @dots{}
  1755. @end example
  1756. @noindent
  1757. to something like:
  1758. @example
  1759. $ guix build emacs --dry-run
  1760. The following files would be downloaded:
  1761. /gnu/store/pk3n22lbq6ydamyymqkkz7i69wiwjiwi-emacs-24.3
  1762. /gnu/store/2ygn4ncnhrpr61rssa6z0d9x22si0va3-libjpeg-8d
  1763. /gnu/store/71yz6lgx4dazma9dwn2mcjxaah9w77jq-cairo-1.12.16
  1764. /gnu/store/7zdhgp0n1518lvfn8mb96sxqfmvqrl7v-libxrender-0.9.7
  1765. @dots{}
  1766. @end example
  1767. @noindent
  1768. This indicates that substitutes from @code{hydra.gnu.org} are usable and
  1769. will be downloaded, when possible, for future builds.
  1770. Guix detects and raises an error when attempting to use a substitute
  1771. that has been tampered with. Likewise, it ignores substitutes that are
  1772. not signed, or that are not signed by one of the keys listed in the ACL.
  1773. There is one exception though: if an unauthorized server provides
  1774. substitutes that are @emph{bit-for-bit identical} to those provided by
  1775. an authorized server, then the unauthorized server becomes eligible for
  1776. downloads. For example, assume we have chosen two substitute servers
  1777. with this option:
  1778. @example
  1779. --substitute-urls="https://a.example.org https://b.example.org"
  1780. @end example
  1781. @noindent
  1782. @cindex reproducible builds
  1783. If the ACL contains only the key for @code{b.example.org}, and if
  1784. @code{a.example.org} happens to serve the @emph{exact same} substitutes,
  1785. then Guix will download substitutes from @code{a.example.org} because it
  1786. comes first in the list and can be considered a mirror of
  1787. @code{b.example.org}. In practice, independent build machines usually
  1788. produce the same binaries, thanks to bit-reproducible builds (see
  1789. below).
  1790. @vindex http_proxy
  1791. Substitutes are downloaded over HTTP or HTTPS.
  1792. The @code{http_proxy} environment
  1793. variable can be set in the environment of @command{guix-daemon} and is
  1794. honored for downloads of substitutes. Note that the value of
  1795. @code{http_proxy} in the environment where @command{guix build},
  1796. @command{guix package}, and other client commands are run has
  1797. @emph{absolutely no effect}.
  1798. When using HTTPS, the server's X.509 certificate is @emph{not} validated
  1799. (in other words, the server is not authenticated), contrary to what
  1800. HTTPS clients such as Web browsers usually do. This is because Guix
  1801. authenticates substitute information itself, as explained above, which
  1802. is what we care about (whereas X.509 certificates are about
  1803. authenticating bindings between domain names and public keys.)
  1804. You can get statistics on the substitutes provided by a server using the
  1805. @command{guix weather} command (@pxref{Invoking guix weather}).
  1806. The substitute mechanism can be disabled globally by running
  1807. @code{guix-daemon} with @code{--no-substitutes} (@pxref{Invoking
  1808. guix-daemon}). It can also be disabled temporarily by passing the
  1809. @code{--no-substitutes} option to @command{guix package}, @command{guix
  1810. build}, and other command-line tools.
  1811. @unnumberedsubsec On Trusting Binaries
  1812. Today, each individual's control over their own computing is at the
  1813. mercy of institutions, corporations, and groups with enough power and
  1814. determination to subvert the computing infrastructure and exploit its
  1815. weaknesses. While using @code{hydra.gnu.org} substitutes can be
  1816. convenient, we encourage users to also build on their own, or even run
  1817. their own build farm, such that @code{hydra.gnu.org} is less of an
  1818. interesting target. One way to help is by publishing the software you
  1819. build using @command{guix publish} so that others have one more choice
  1820. of server to download substitutes from (@pxref{Invoking guix publish}).
  1821. Guix has the foundations to maximize build reproducibility
  1822. (@pxref{Features}). In most cases, independent builds of a given
  1823. package or derivation should yield bit-identical results. Thus, through
  1824. a diverse set of independent package builds, we can strengthen the
  1825. integrity of our systems. The @command{guix challenge} command aims to
  1826. help users assess substitute servers, and to assist developers in
  1827. finding out about non-deterministic package builds (@pxref{Invoking guix
  1828. challenge}). Similarly, the @option{--check} option of @command{guix
  1829. build} allows users to check whether previously-installed substitutes
  1830. are genuine by rebuilding them locally (@pxref{build-check,
  1831. @command{guix build --check}}).
  1832. In the future, we want Guix to have support to publish and retrieve
  1833. binaries to/from other users, in a peer-to-peer fashion. If you would
  1834. like to discuss this project, join us on @email{guix-devel@@gnu.org}.
  1835. @node Packages with Multiple Outputs
  1836. @section Packages with Multiple Outputs
  1837. @cindex multiple-output packages
  1838. @cindex package outputs
  1839. @cindex outputs
  1840. Often, packages defined in Guix have a single @dfn{output}---i.e., the
  1841. source package leads to exactly one directory in the store. When running
  1842. @command{guix package -i glibc}, one installs the default output of the
  1843. GNU libc package; the default output is called @code{out}, but its name
  1844. can be omitted as shown in this command. In this particular case, the
  1845. default output of @code{glibc} contains all the C header files, shared
  1846. libraries, static libraries, Info documentation, and other supporting
  1847. files.
  1848. Sometimes it is more appropriate to separate the various types of files
  1849. produced from a single source package into separate outputs. For
  1850. instance, the GLib C library (used by GTK+ and related packages)
  1851. installs more than 20 MiB of reference documentation as HTML pages.
  1852. To save space for users who do not need it, the documentation goes to a
  1853. separate output, called @code{doc}. To install the main GLib output,
  1854. which contains everything but the documentation, one would run:
  1855. @example
  1856. guix package -i glib
  1857. @end example
  1858. @cindex documentation
  1859. The command to install its documentation is:
  1860. @example
  1861. guix package -i glib:doc
  1862. @end example
  1863. Some packages install programs with different ``dependency footprints''.
  1864. For instance, the WordNet package installs both command-line tools and
  1865. graphical user interfaces (GUIs). The former depend solely on the C
  1866. library, whereas the latter depend on Tcl/Tk and the underlying X
  1867. libraries. In this case, we leave the command-line tools in the default
  1868. output, whereas the GUIs are in a separate output. This allows users
  1869. who do not need the GUIs to save space. The @command{guix size} command
  1870. can help find out about such situations (@pxref{Invoking guix size}).
  1871. @command{guix graph} can also be helpful (@pxref{Invoking guix graph}).
  1872. There are several such multiple-output packages in the GNU distribution.
  1873. Other conventional output names include @code{lib} for libraries and
  1874. possibly header files, @code{bin} for stand-alone programs, and
  1875. @code{debug} for debugging information (@pxref{Installing Debugging
  1876. Files}). The outputs of a packages are listed in the third column of
  1877. the output of @command{guix package --list-available} (@pxref{Invoking
  1878. guix package}).
  1879. @node Invoking guix gc
  1880. @section Invoking @command{guix gc}
  1881. @cindex garbage collector
  1882. @cindex disk space
  1883. Packages that are installed, but not used, may be @dfn{garbage-collected}.
  1884. The @command{guix gc} command allows users to explicitly run the garbage
  1885. collector to reclaim space from the @file{/gnu/store} directory. It is
  1886. the @emph{only} way to remove files from @file{/gnu/store}---removing
  1887. files or directories manually may break it beyond repair!
  1888. The garbage collector has a set of known @dfn{roots}: any file under
  1889. @file{/gnu/store} reachable from a root is considered @dfn{live} and
  1890. cannot be deleted; any other file is considered @dfn{dead} and may be
  1891. deleted. The set of garbage collector roots includes default user
  1892. profiles, and may be augmented with @command{guix build --root}, for
  1893. example (@pxref{Invoking guix build}).
  1894. Prior to running @code{guix gc --collect-garbage} to make space, it is
  1895. often useful to remove old generations from user profiles; that way, old
  1896. package builds referenced by those generations can be reclaimed. This
  1897. is achieved by running @code{guix package --delete-generations}
  1898. (@pxref{Invoking guix package}).
  1899. Our recommendation is to run a garbage collection periodically, or when
  1900. you are short on disk space. For instance, to guarantee that at least
  1901. 5@tie{}GB are available on your disk, simply run:
  1902. @example
  1903. guix gc -F 5G
  1904. @end example
  1905. It is perfectly safe to run as a non-interactive periodic job
  1906. (@pxref{Scheduled Job Execution}, for how to set up such a job on
  1907. GuixSD). Running @command{guix gc} with no arguments will collect as
  1908. much garbage as it can, but that is often inconvenient: you may find
  1909. yourself having to rebuild or re-download software that is ``dead'' from
  1910. the GC viewpoint but that is necessary to build other pieces of
  1911. software---e.g., the compiler tool chain.
  1912. The @command{guix gc} command has three modes of operation: it can be
  1913. used to garbage-collect any dead files (the default), to delete specific
  1914. files (the @code{--delete} option), to print garbage-collector
  1915. information, or for more advanced queries. The garbage collection
  1916. options are as follows:
  1917. @table @code
  1918. @item --collect-garbage[=@var{min}]
  1919. @itemx -C [@var{min}]
  1920. Collect garbage---i.e., unreachable @file{/gnu/store} files and
  1921. sub-directories. This is the default operation when no option is
  1922. specified.
  1923. When @var{min} is given, stop once @var{min} bytes have been collected.
  1924. @var{min} may be a number of bytes, or it may include a unit as a
  1925. suffix, such as @code{MiB} for mebibytes and @code{GB} for gigabytes
  1926. (@pxref{Block size, size specifications,, coreutils, GNU Coreutils}).
  1927. When @var{min} is omitted, collect all the garbage.
  1928. @item --free-space=@var{free}
  1929. @itemx -F @var{free}
  1930. Collect garbage until @var{free} space is available under
  1931. @file{/gnu/store}, if possible; @var{free} denotes storage space, such
  1932. as @code{500MiB}, as described above.
  1933. When @var{free} or more is already available in @file{/gnu/store}, do
  1934. nothing and exit immediately.
  1935. @item --delete
  1936. @itemx -d
  1937. Attempt to delete all the store files and directories specified as
  1938. arguments. This fails if some of the files are not in the store, or if
  1939. they are still live.
  1940. @item --list-failures
  1941. List store items corresponding to cached build failures.
  1942. This prints nothing unless the daemon was started with
  1943. @option{--cache-failures} (@pxref{Invoking guix-daemon,
  1944. @option{--cache-failures}}).
  1945. @item --clear-failures
  1946. Remove the specified store items from the failed-build cache.
  1947. Again, this option only makes sense when the daemon is started with
  1948. @option{--cache-failures}. Otherwise, it does nothing.
  1949. @item --list-dead
  1950. Show the list of dead files and directories still present in the
  1951. store---i.e., files and directories no longer reachable from any root.
  1952. @item --list-live
  1953. Show the list of live store files and directories.
  1954. @end table
  1955. In addition, the references among existing store files can be queried:
  1956. @table @code
  1957. @item --references
  1958. @itemx --referrers
  1959. @cindex package dependencies
  1960. List the references (respectively, the referrers) of store files given
  1961. as arguments.
  1962. @item --requisites
  1963. @itemx -R
  1964. @cindex closure
  1965. List the requisites of the store files passed as arguments. Requisites
  1966. include the store files themselves, their references, and the references
  1967. of these, recursively. In other words, the returned list is the
  1968. @dfn{transitive closure} of the store files.
  1969. @xref{Invoking guix size}, for a tool to profile the size of the closure
  1970. of an element. @xref{Invoking guix graph}, for a tool to visualize
  1971. the graph of references.
  1972. @end table
  1973. Lastly, the following options allow you to check the integrity of the
  1974. store and to control disk usage.
  1975. @table @option
  1976. @item --verify[=@var{options}]
  1977. @cindex integrity, of the store
  1978. @cindex integrity checking
  1979. Verify the integrity of the store.
  1980. By default, make sure that all the store items marked as valid in the
  1981. database of the daemon actually exist in @file{/gnu/store}.
  1982. When provided, @var{options} must be a comma-separated list containing one
  1983. or more of @code{contents} and @code{repair}.
  1984. When passing @option{--verify=contents}, the daemon computes the
  1985. content hash of each store item and compares it against its hash in the
  1986. database. Hash mismatches are reported as data corruptions. Because it
  1987. traverses @emph{all the files in the store}, this command can take a
  1988. long time, especially on systems with a slow disk drive.
  1989. @cindex repairing the store
  1990. @cindex corruption, recovering from
  1991. Using @option{--verify=repair} or @option{--verify=contents,repair}
  1992. causes the daemon to try to repair corrupt store items by fetching
  1993. substitutes for them (@pxref{Substitutes}). Because repairing is not
  1994. atomic, and thus potentially dangerous, it is available only to the
  1995. system administrator. A lightweight alternative, when you know exactly
  1996. which items in the store are corrupt, is @command{guix build --repair}
  1997. (@pxref{Invoking guix build}).
  1998. @item --optimize
  1999. @cindex deduplication
  2000. Optimize the store by hard-linking identical files---this is
  2001. @dfn{deduplication}.
  2002. The daemon performs deduplication after each successful build or archive
  2003. import, unless it was started with @code{--disable-deduplication}
  2004. (@pxref{Invoking guix-daemon, @code{--disable-deduplication}}). Thus,
  2005. this option is primarily useful when the daemon was running with
  2006. @code{--disable-deduplication}.
  2007. @end table
  2008. @node Invoking guix pull
  2009. @section Invoking @command{guix pull}
  2010. @cindex upgrading Guix
  2011. @cindex updating Guix
  2012. @cindex @command{guix pull}
  2013. @cindex pull
  2014. Packages are installed or upgraded to the latest version available in
  2015. the distribution currently available on your local machine. To update
  2016. that distribution, along with the Guix tools, you must run @command{guix
  2017. pull}: the command downloads the latest Guix source code and package
  2018. descriptions, and deploys it. Source code is downloaded from a
  2019. @uref{https://git-scm.com, Git} repository.
  2020. On completion, @command{guix package} will use packages and package
  2021. versions from this just-retrieved copy of Guix. Not only that, but all
  2022. the Guix commands and Scheme modules will also be taken from that latest
  2023. version. New @command{guix} sub-commands added by the update also
  2024. become available.
  2025. Any user can update their Guix copy using @command{guix pull}, and the
  2026. effect is limited to the user who run @command{guix pull}. For
  2027. instance, when user @code{root} runs @command{guix pull}, this has no
  2028. effect on the version of Guix that user @code{alice} sees, and vice
  2029. versa@footnote{Under the hood, @command{guix pull} updates the
  2030. @file{~/.config/guix/latest} symbolic link to point to the latest Guix,
  2031. and the @command{guix} command loads code from there. Currently, the
  2032. only way to roll back an invocation of @command{guix pull} is to
  2033. manually update this symlink to point to the previous Guix.}.
  2034. The @command{guix pull} command is usually invoked with no arguments,
  2035. but it supports the following options:
  2036. @table @code
  2037. @item --verbose
  2038. Produce verbose output, writing build logs to the standard error output.
  2039. @item --url=@var{url}
  2040. Download Guix from the Git repository at @var{url}.
  2041. @vindex GUIX_PULL_URL
  2042. By default, the source is taken from its canonical Git repository at
  2043. @code{gnu.org}, for the stable branch of Guix. To use a different source,
  2044. set the @code{GUIX_PULL_URL} environment variable.
  2045. @item --commit=@var{commit}
  2046. Deploy @var{commit}, a valid Git commit ID represented as a hexadecimal
  2047. string.
  2048. @item --branch=@var{branch}
  2049. Deploy the tip of @var{branch}, the name of a Git branch available on
  2050. the repository at @var{url}.
  2051. @item --bootstrap
  2052. Use the bootstrap Guile to build the latest Guix. This option is only
  2053. useful to Guix developers.
  2054. @end table
  2055. In addition, @command{guix pull} supports all the common build options
  2056. (@pxref{Common Build Options}).
  2057. @node Invoking guix pack
  2058. @section Invoking @command{guix pack}
  2059. Occasionally you want to pass software to people who are not (yet!)
  2060. lucky enough to be using Guix. You'd tell them to run @command{guix
  2061. package -i @var{something}}, but that's not possible in this case. This
  2062. is where @command{guix pack} comes in.
  2063. @cindex pack
  2064. @cindex bundle
  2065. @cindex application bundle
  2066. @cindex software bundle
  2067. The @command{guix pack} command creates a shrink-wrapped @dfn{pack} or
  2068. @dfn{software bundle}: it creates a tarball or some other archive
  2069. containing the binaries of the software you're interested in, and all
  2070. its dependencies. The resulting archive can be used on any machine that
  2071. does not have Guix, and people can run the exact same binaries as those
  2072. you have with Guix. The pack itself is created in a bit-reproducible
  2073. fashion, so anyone can verify that it really contains the build results
  2074. that you pretend to be shipping.
  2075. For example, to create a bundle containing Guile, Emacs, Geiser, and all
  2076. their dependencies, you can run:
  2077. @example
  2078. $ guix pack guile emacs geiser
  2079. @dots{}
  2080. /gnu/store/@dots{}-pack.tar.gz
  2081. @end example
  2082. The result here is a tarball containing a @file{/gnu/store} directory
  2083. with all the relevant packages. The resulting tarball contains a
  2084. @dfn{profile} with the three packages of interest; the profile is the
  2085. same as would be created by @command{guix package -i}. It is this
  2086. mechanism that is used to create Guix's own standalone binary tarball
  2087. (@pxref{Binary Installation}).
  2088. Users of this pack would have to run
  2089. @file{/gnu/store/@dots{}-profile/bin/guile} to run Guile, which you may
  2090. find inconvenient. To work around it, you can create, say, a
  2091. @file{/opt/gnu/bin} symlink to the profile:
  2092. @example
  2093. guix pack -S /opt/gnu/bin=bin guile emacs geiser
  2094. @end example
  2095. @noindent
  2096. That way, users can happily type @file{/opt/gnu/bin/guile} and enjoy.
  2097. Alternatively, you can produce a pack in the Docker image format using
  2098. the following command:
  2099. @example
  2100. guix pack -f docker guile emacs geiser
  2101. @end example
  2102. @noindent
  2103. The result is a tarball that can be passed to the @command{docker load}
  2104. command. See the
  2105. @uref{https://docs.docker.com/engine/reference/commandline/load/, Docker
  2106. documentation} for more information.
  2107. Several command-line options allow you to customize your pack:
  2108. @table @code
  2109. @item --format=@var{format}
  2110. @itemx -f @var{format}
  2111. Produce a pack in the given @var{format}.
  2112. The available formats are:
  2113. @table @code
  2114. @item tarball
  2115. This is the default format. It produces a tarball containing all the
  2116. specified binaries and symlinks.
  2117. @item docker
  2118. This produces a tarball that follows the
  2119. @uref{https://github.com/docker/docker/blob/master/image/spec/v1.2.md,
  2120. Docker Image Specification}.
  2121. @end table
  2122. @item --expression=@var{expr}
  2123. @itemx -e @var{expr}
  2124. Consider the package @var{expr} evaluates to.
  2125. This has the same purpose as the same-named option in @command{guix
  2126. build} (@pxref{Additional Build Options, @code{--expression} in
  2127. @command{guix build}}).
  2128. @item --system=@var{system}
  2129. @itemx -s @var{system}
  2130. Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
  2131. the system type of the build host.
  2132. @item --target=@var{triplet}
  2133. @cindex cross-compilation
  2134. Cross-build for @var{triplet}, which must be a valid GNU triplet, such
  2135. as @code{"mips64el-linux-gnu"} (@pxref{Specifying target triplets, GNU
  2136. configuration triplets,, autoconf, Autoconf}).
  2137. @item --compression=@var{tool}
  2138. @itemx -C @var{tool}
  2139. Compress the resulting tarball using @var{tool}---one of @code{gzip},
  2140. @code{bzip2}, @code{xz}, @code{lzip}, or @code{none} for no compression.
  2141. @item --symlink=@var{spec}
  2142. @itemx -S @var{spec}
  2143. Add the symlinks specified by @var{spec} to the pack. This option can
  2144. appear several times.
  2145. @var{spec} has the form @code{@var{source}=@var{target}}, where
  2146. @var{source} is the symlink that will be created and @var{target} is the
  2147. symlink target.
  2148. For instance, @code{-S /opt/gnu/bin=bin} creates a @file{/opt/gnu/bin}
  2149. symlink pointing to the @file{bin} sub-directory of the profile.
  2150. @item --localstatedir
  2151. Include the ``local state directory'', @file{/var/guix}, in the
  2152. resulting pack.
  2153. @file{/var/guix} contains the store database (@pxref{The Store}) as well
  2154. as garbage-collector roots (@pxref{Invoking guix gc}). Providing it in
  2155. the pack means that the store is ``complete'' and manageable by Guix;
  2156. not providing it pack means that the store is ``dead'': items cannot be
  2157. added to it or removed from it after extraction of the pack.
  2158. One use case for this is the Guix self-contained binary tarball
  2159. (@pxref{Binary Installation}).
  2160. @end table
  2161. In addition, @command{guix pack} supports all the common build options
  2162. (@pxref{Common Build Options}) and all the package transformation
  2163. options (@pxref{Package Transformation Options}).
  2164. @node Invoking guix archive
  2165. @section Invoking @command{guix archive}
  2166. @cindex @command{guix archive}
  2167. @cindex archive
  2168. The @command{guix archive} command allows users to @dfn{export} files
  2169. from the store into a single archive, and to later @dfn{import} them.
  2170. In particular, it allows store files to be transferred from one machine
  2171. to the store on another machine.
  2172. @cindex exporting store items
  2173. To export store files as an archive to standard output, run:
  2174. @example
  2175. guix archive --export @var{options} @var{specifications}...
  2176. @end example
  2177. @var{specifications} may be either store file names or package
  2178. specifications, as for @command{guix package} (@pxref{Invoking guix
  2179. package}). For instance, the following command creates an archive
  2180. containing the @code{gui} output of the @code{git} package and the main
  2181. output of @code{emacs}:
  2182. @example
  2183. guix archive --export git:gui /gnu/store/...-emacs-24.3 > great.nar
  2184. @end example
  2185. If the specified packages are not built yet, @command{guix archive}
  2186. automatically builds them. The build process may be controlled with the
  2187. common build options (@pxref{Common Build Options}).
  2188. To transfer the @code{emacs} package to a machine connected over SSH,
  2189. one would run:
  2190. @example
  2191. guix archive --export -r emacs | ssh the-machine guix archive --import
  2192. @end example
  2193. @noindent
  2194. Similarly, a complete user profile may be transferred from one machine
  2195. to another like this:
  2196. @example
  2197. guix archive --export -r $(readlink -f ~/.guix-profile) | \
  2198. ssh the-machine guix-archive --import
  2199. @end example
  2200. @noindent
  2201. However, note that, in both examples, all of @code{emacs} and the
  2202. profile as well as all of their dependencies are transferred (due to
  2203. @code{-r}), regardless of what is already available in the store on the
  2204. target machine. The @code{--missing} option can help figure out which
  2205. items are missing from the target store. The @command{guix copy}
  2206. command simplifies and optimizes this whole process, so this is probably
  2207. what you should use in this case (@pxref{Invoking guix copy}).
  2208. @cindex nar, archive format
  2209. @cindex normalized archive (nar)
  2210. Archives are stored in the ``normalized archive'' or ``nar'' format, which is
  2211. comparable in spirit to `tar', but with differences
  2212. that make it more appropriate for our purposes. First, rather than
  2213. recording all Unix metadata for each file, the nar format only mentions
  2214. the file type (regular, directory, or symbolic link); Unix permissions
  2215. and owner/group are dismissed. Second, the order in which directory
  2216. entries are stored always follows the order of file names according to
  2217. the C locale collation order. This makes archive production fully
  2218. deterministic.
  2219. When exporting, the daemon digitally signs the contents of the archive,
  2220. and that digital signature is appended. When importing, the daemon
  2221. verifies the signature and rejects the import in case of an invalid
  2222. signature or if the signing key is not authorized.
  2223. @c FIXME: Add xref to daemon doc about signatures.
  2224. The main options are:
  2225. @table @code
  2226. @item --export
  2227. Export the specified store files or packages (see below.) Write the
  2228. resulting archive to the standard output.
  2229. Dependencies are @emph{not} included in the output, unless
  2230. @code{--recursive} is passed.
  2231. @item -r
  2232. @itemx --recursive
  2233. When combined with @code{--export}, this instructs @command{guix
  2234. archive} to include dependencies of the given items in the archive.
  2235. Thus, the resulting archive is self-contained: it contains the closure
  2236. of the exported store items.
  2237. @item --import
  2238. Read an archive from the standard input, and import the files listed
  2239. therein into the store. Abort if the archive has an invalid digital
  2240. signature, or if it is signed by a public key not among the authorized
  2241. keys (see @code{--authorize} below.)
  2242. @item --missing
  2243. Read a list of store file names from the standard input, one per line,
  2244. and write on the standard output the subset of these files missing from
  2245. the store.
  2246. @item --generate-key[=@var{parameters}]
  2247. @cindex signing, archives
  2248. Generate a new key pair for the daemon. This is a prerequisite before
  2249. archives can be exported with @code{--export}. Note that this operation
  2250. usually takes time, because it needs to gather enough entropy to
  2251. generate the key pair.
  2252. The generated key pair is typically stored under @file{/etc/guix}, in
  2253. @file{signing-key.pub} (public key) and @file{signing-key.sec} (private
  2254. key, which must be kept secret.) When @var{parameters} is omitted,
  2255. an ECDSA key using the Ed25519 curve is generated, or, for Libgcrypt
  2256. versions before 1.6.0, it is a 4096-bit RSA key.
  2257. Alternatively, @var{parameters} can specify
  2258. @code{genkey} parameters suitable for Libgcrypt (@pxref{General
  2259. public-key related Functions, @code{gcry_pk_genkey},, gcrypt, The
  2260. Libgcrypt Reference Manual}).
  2261. @item --authorize
  2262. @cindex authorizing, archives
  2263. Authorize imports signed by the public key passed on standard input.
  2264. The public key must be in ``s-expression advanced format''---i.e., the
  2265. same format as the @file{signing-key.pub} file.
  2266. The list of authorized keys is kept in the human-editable file
  2267. @file{/etc/guix/acl}. The file contains
  2268. @url{http://people.csail.mit.edu/rivest/Sexp.txt, ``advanced-format
  2269. s-expressions''} and is structured as an access-control list in the
  2270. @url{http://theworld.com/~cme/spki.txt, Simple Public-Key Infrastructure
  2271. (SPKI)}.
  2272. @item --extract=@var{directory}
  2273. @itemx -x @var{directory}
  2274. Read a single-item archive as served by substitute servers
  2275. (@pxref{Substitutes}) and extract it to @var{directory}. This is a
  2276. low-level operation needed in only very narrow use cases; see below.
  2277. For example, the following command extracts the substitute for Emacs
  2278. served by @code{hydra.gnu.org} to @file{/tmp/emacs}:
  2279. @example
  2280. $ wget -O - \
  2281. https://hydra.gnu.org/nar/@dots{}-emacs-24.5 \
  2282. | bunzip2 | guix archive -x /tmp/emacs
  2283. @end example
  2284. Single-item archives are different from multiple-item archives produced
  2285. by @command{guix archive --export}; they contain a single store item,
  2286. and they do @emph{not} embed a signature. Thus this operation does
  2287. @emph{no} signature verification and its output should be considered
  2288. unsafe.
  2289. The primary purpose of this operation is to facilitate inspection of
  2290. archive contents coming from possibly untrusted substitute servers.
  2291. @end table
  2292. @c *********************************************************************
  2293. @node Programming Interface
  2294. @chapter Programming Interface
  2295. GNU Guix provides several Scheme programming interfaces (APIs) to
  2296. define, build, and query packages. The first interface allows users to
  2297. write high-level package definitions. These definitions refer to
  2298. familiar packaging concepts, such as the name and version of a package,
  2299. its build system, and its dependencies. These definitions can then be
  2300. turned into concrete build actions.
  2301. Build actions are performed by the Guix daemon, on behalf of users. In a
  2302. standard setup, the daemon has write access to the store---the
  2303. @file{/gnu/store} directory---whereas users do not. The recommended
  2304. setup also has the daemon perform builds in chroots, under a specific
  2305. build users, to minimize interference with the rest of the system.
  2306. @cindex derivation
  2307. Lower-level APIs are available to interact with the daemon and the
  2308. store. To instruct the daemon to perform a build action, users actually
  2309. provide it with a @dfn{derivation}. A derivation is a low-level
  2310. representation of the build actions to be taken, and the environment in
  2311. which they should occur---derivations are to package definitions what
  2312. assembly is to C programs. The term ``derivation'' comes from the fact
  2313. that build results @emph{derive} from them.
  2314. This chapter describes all these APIs in turn, starting from high-level
  2315. package definitions.
  2316. @menu
  2317. * Defining Packages:: Defining new packages.
  2318. * Build Systems:: Specifying how packages are built.
  2319. * The Store:: Manipulating the package store.
  2320. * Derivations:: Low-level interface to package derivations.
  2321. * The Store Monad:: Purely functional interface to the store.
  2322. * G-Expressions:: Manipulating build expressions.
  2323. @end menu
  2324. @node Defining Packages
  2325. @section Defining Packages
  2326. The high-level interface to package definitions is implemented in the
  2327. @code{(guix packages)} and @code{(guix build-system)} modules. As an
  2328. example, the package definition, or @dfn{recipe}, for the GNU Hello
  2329. package looks like this:
  2330. @example
  2331. (define-module (gnu packages hello)
  2332. #:use-module (guix packages)
  2333. #:use-module (guix download)
  2334. #:use-module (guix build-system gnu)
  2335. #:use-module (guix licenses)
  2336. #:use-module (gnu packages gawk))
  2337. (define-public hello
  2338. (package
  2339. (name "hello")
  2340. (version "2.10")
  2341. (source (origin
  2342. (method url-fetch)
  2343. (uri (string-append "mirror://gnu/hello/hello-" version
  2344. ".tar.gz"))
  2345. (sha256
  2346. (base32
  2347. "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
  2348. (build-system gnu-build-system)
  2349. (arguments '(#:configure-flags '("--enable-silent-rules")))
  2350. (inputs `(("gawk" ,gawk)))
  2351. (synopsis "Hello, GNU world: An example GNU package")
  2352. (description "Guess what GNU Hello prints!")
  2353. (home-page "http://www.gnu.org/software/hello/")
  2354. (license gpl3+)))
  2355. @end example
  2356. @noindent
  2357. Without being a Scheme expert, the reader may have guessed the meaning
  2358. of the various fields here. This expression binds the variable
  2359. @code{hello} to a @code{<package>} object, which is essentially a record
  2360. (@pxref{SRFI-9, Scheme records,, guile, GNU Guile Reference Manual}).
  2361. This package object can be inspected using procedures found in the
  2362. @code{(guix packages)} module; for instance, @code{(package-name hello)}
  2363. returns---surprise!---@code{"hello"}.
  2364. With luck, you may be able to import part or all of the definition of
  2365. the package you are interested in from another repository, using the
  2366. @code{guix import} command (@pxref{Invoking guix import}).
  2367. In the example above, @var{hello} is defined in a module of its own,
  2368. @code{(gnu packages hello)}. Technically, this is not strictly
  2369. necessary, but it is convenient to do so: all the packages defined in
  2370. modules under @code{(gnu packages @dots{})} are automatically known to
  2371. the command-line tools (@pxref{Package Modules}).
  2372. There are a few points worth noting in the above package definition:
  2373. @itemize
  2374. @item
  2375. The @code{source} field of the package is an @code{<origin>} object
  2376. (@pxref{origin Reference}, for the complete reference).
  2377. Here, the @code{url-fetch} method from @code{(guix download)} is used,
  2378. meaning that the source is a file to be downloaded over FTP or HTTP.
  2379. The @code{mirror://gnu} prefix instructs @code{url-fetch} to use one of
  2380. the GNU mirrors defined in @code{(guix download)}.
  2381. The @code{sha256} field specifies the expected SHA256 hash of the file
  2382. being downloaded. It is mandatory, and allows Guix to check the
  2383. integrity of the file. The @code{(base32 @dots{})} form introduces the
  2384. base32 representation of the hash. You can obtain this information with
  2385. @code{guix download} (@pxref{Invoking guix download}) and @code{guix
  2386. hash} (@pxref{Invoking guix hash}).
  2387. @cindex patches
  2388. When needed, the @code{origin} form can also have a @code{patches} field
  2389. listing patches to be applied, and a @code{snippet} field giving a
  2390. Scheme expression to modify the source code.
  2391. @item
  2392. @cindex GNU Build System
  2393. The @code{build-system} field specifies the procedure to build the
  2394. package (@pxref{Build Systems}). Here, @var{gnu-build-system}
  2395. represents the familiar GNU Build System, where packages may be
  2396. configured, built, and installed with the usual @code{./configure &&
  2397. make && make check && make install} command sequence.
  2398. @item
  2399. The @code{arguments} field specifies options for the build system
  2400. (@pxref{Build Systems}). Here it is interpreted by
  2401. @var{gnu-build-system} as a request run @file{configure} with the
  2402. @code{--enable-silent-rules} flag.
  2403. @cindex quote
  2404. @cindex quoting
  2405. @findex '
  2406. @findex quote
  2407. What about these quote (@code{'}) characters? They are Scheme syntax to
  2408. introduce a literal list; @code{'} is synonymous with @code{quote}.
  2409. @xref{Expression Syntax, quoting,, guile, GNU Guile Reference Manual},
  2410. for details. Here the value of the @code{arguments} field is a list of
  2411. arguments passed to the build system down the road, as with @code{apply}
  2412. (@pxref{Fly Evaluation, @code{apply},, guile, GNU Guile Reference
  2413. Manual}).
  2414. The hash-colon (@code{#:}) sequence defines a Scheme @dfn{keyword}
  2415. (@pxref{Keywords,,, guile, GNU Guile Reference Manual}), and
  2416. @code{#:configure-flags} is a keyword used to pass a keyword argument
  2417. to the build system (@pxref{Coding With Keywords,,, guile, GNU Guile
  2418. Reference Manual}).
  2419. @item
  2420. The @code{inputs} field specifies inputs to the build process---i.e.,
  2421. build-time or run-time dependencies of the package. Here, we define an
  2422. input called @code{"gawk"} whose value is that of the @var{gawk}
  2423. variable; @var{gawk} is itself bound to a @code{<package>} object.
  2424. @cindex backquote (quasiquote)
  2425. @findex `
  2426. @findex quasiquote
  2427. @cindex comma (unquote)
  2428. @findex ,
  2429. @findex unquote
  2430. @findex ,@@
  2431. @findex unquote-splicing
  2432. Again, @code{`} (a backquote, synonymous with @code{quasiquote}) allows
  2433. us to introduce a literal list in the @code{inputs} field, while
  2434. @code{,} (a comma, synonymous with @code{unquote}) allows us to insert a
  2435. value in that list (@pxref{Expression Syntax, unquote,, guile, GNU Guile
  2436. Reference Manual}).
  2437. Note that GCC, Coreutils, Bash, and other essential tools do not need to
  2438. be specified as inputs here. Instead, @var{gnu-build-system} takes care
  2439. of ensuring that they are present (@pxref{Build Systems}).
  2440. However, any other dependencies need to be specified in the
  2441. @code{inputs} field. Any dependency not specified here will simply be
  2442. unavailable to the build process, possibly leading to a build failure.
  2443. @end itemize
  2444. @xref{package Reference}, for a full description of possible fields.
  2445. Once a package definition is in place, the
  2446. package may actually be built using the @code{guix build} command-line
  2447. tool (@pxref{Invoking guix build}), troubleshooting any build failures
  2448. you encounter (@pxref{Debugging Build Failures}). You can easily jump back to the
  2449. package definition using the @command{guix edit} command
  2450. (@pxref{Invoking guix edit}).
  2451. @xref{Packaging Guidelines}, for
  2452. more information on how to test package definitions, and
  2453. @ref{Invoking guix lint}, for information on how to check a definition
  2454. for style conformance.
  2455. @vindex GUIX_PACKAGE_PATH
  2456. Lastly, @pxref{Package Modules}, for information
  2457. on how to extend the distribution by adding your own package definitions
  2458. to @code{GUIX_PACKAGE_PATH}.
  2459. Finally, updating the package definition to a new upstream version
  2460. can be partly automated by the @command{guix refresh} command
  2461. (@pxref{Invoking guix refresh}).
  2462. Behind the scenes, a derivation corresponding to the @code{<package>}
  2463. object is first computed by the @code{package-derivation} procedure.
  2464. That derivation is stored in a @code{.drv} file under @file{/gnu/store}.
  2465. The build actions it prescribes may then be realized by using the
  2466. @code{build-derivations} procedure (@pxref{The Store}).
  2467. @deffn {Scheme Procedure} package-derivation @var{store} @var{package} [@var{system}]
  2468. Return the @code{<derivation>} object of @var{package} for @var{system}
  2469. (@pxref{Derivations}).
  2470. @var{package} must be a valid @code{<package>} object, and @var{system}
  2471. must be a string denoting the target system type---e.g.,
  2472. @code{"x86_64-linux"} for an x86_64 Linux-based GNU system. @var{store}
  2473. must be a connection to the daemon, which operates on the store
  2474. (@pxref{The Store}).
  2475. @end deffn
  2476. @noindent
  2477. @cindex cross-compilation
  2478. Similarly, it is possible to compute a derivation that cross-builds a
  2479. package for some other system:
  2480. @deffn {Scheme Procedure} package-cross-derivation @var{store} @
  2481. @var{package} @var{target} [@var{system}]
  2482. Return the @code{<derivation>} object of @var{package} cross-built from
  2483. @var{system} to @var{target}.
  2484. @var{target} must be a valid GNU triplet denoting the target hardware
  2485. and operating system, such as @code{"mips64el-linux-gnu"}
  2486. (@pxref{Configuration Names, GNU configuration triplets,, configure, GNU
  2487. Configure and Build System}).
  2488. @end deffn
  2489. @cindex package transformations
  2490. @cindex input rewriting
  2491. @cindex dependency tree rewriting
  2492. Packages can be manipulated in arbitrary ways. An example of a useful
  2493. transformation is @dfn{input rewriting}, whereby the dependency tree of
  2494. a package is rewritten by replacing specific inputs by others:
  2495. @deffn {Scheme Procedure} package-input-rewriting @var{replacements} @
  2496. [@var{rewrite-name}]
  2497. Return a procedure that, when passed a package, replaces its direct and
  2498. indirect dependencies (but not its implicit inputs) according to
  2499. @var{replacements}. @var{replacements} is a list of package pairs; the
  2500. first element of each pair is the package to replace, and the second one
  2501. is the replacement.
  2502. Optionally, @var{rewrite-name} is a one-argument procedure that takes
  2503. the name of a package and returns its new name after rewrite.
  2504. @end deffn
  2505. @noindent
  2506. Consider this example:
  2507. @example
  2508. (define libressl-instead-of-openssl
  2509. ;; This is a procedure to replace OPENSSL by LIBRESSL,
  2510. ;; recursively.
  2511. (package-input-rewriting `((,openssl . ,libressl))))
  2512. (define git-with-libressl
  2513. (libressl-instead-of-openssl git))
  2514. @end example
  2515. @noindent
  2516. Here we first define a rewriting procedure that replaces @var{openssl}
  2517. with @var{libressl}. Then we use it to define a @dfn{variant} of the
  2518. @var{git} package that uses @var{libressl} instead of @var{openssl}.
  2519. This is exactly what the @option{--with-input} command-line option does
  2520. (@pxref{Package Transformation Options, @option{--with-input}}).
  2521. A more generic procedure to rewrite a package dependency graph is
  2522. @code{package-mapping}: it supports arbitrary changes to nodes in the
  2523. graph.
  2524. @deffn {Scheme Procedure} package-mapping @var{proc} [@var{cut?}]
  2525. Return a procedure that, given a package, applies @var{proc} to all the packages
  2526. depended on and returns the resulting package. The procedure stops recursion
  2527. when @var{cut?} returns true for a given package.
  2528. @end deffn
  2529. @menu
  2530. * package Reference :: The package data type.
  2531. * origin Reference:: The origin data type.
  2532. @end menu
  2533. @node package Reference
  2534. @subsection @code{package} Reference
  2535. This section summarizes all the options available in @code{package}
  2536. declarations (@pxref{Defining Packages}).
  2537. @deftp {Data Type} package
  2538. This is the data type representing a package recipe.
  2539. @table @asis
  2540. @item @code{name}
  2541. The name of the package, as a string.
  2542. @item @code{version}
  2543. The version of the package, as a string.
  2544. @item @code{source}
  2545. An object telling how the source code for the package should be
  2546. acquired. Most of the time, this is an @code{origin} object, which
  2547. denotes a file fetched from the Internet (@pxref{origin Reference}). It
  2548. can also be any other ``file-like'' object such as a @code{local-file},
  2549. which denotes a file from the local file system (@pxref{G-Expressions,
  2550. @code{local-file}}).
  2551. @item @code{build-system}
  2552. The build system that should be used to build the package (@pxref{Build
  2553. Systems}).
  2554. @item @code{arguments} (default: @code{'()})
  2555. The arguments that should be passed to the build system. This is a
  2556. list, typically containing sequential keyword-value pairs.
  2557. @item @code{inputs} (default: @code{'()})
  2558. @itemx @code{native-inputs} (default: @code{'()})
  2559. @itemx @code{propagated-inputs} (default: @code{'()})
  2560. @cindex inputs, of packages
  2561. These fields list dependencies of the package. Each one is a list of
  2562. tuples, where each tuple has a label for the input (a string) as its
  2563. first element, a package, origin, or derivation as its second element,
  2564. and optionally the name of the output thereof that should be used, which
  2565. defaults to @code{"out"} (@pxref{Packages with Multiple Outputs}, for
  2566. more on package outputs). For example, the list below specifies three
  2567. inputs:
  2568. @example
  2569. `(("libffi" ,libffi)
  2570. ("libunistring" ,libunistring)
  2571. ("glib:bin" ,glib "bin")) ;the "bin" output of Glib
  2572. @end example
  2573. @cindex cross compilation, package dependencies
  2574. The distinction between @code{native-inputs} and @code{inputs} is
  2575. necessary when considering cross-compilation. When cross-compiling,
  2576. dependencies listed in @code{inputs} are built for the @emph{target}
  2577. architecture; conversely, dependencies listed in @code{native-inputs}
  2578. are built for the architecture of the @emph{build} machine.
  2579. @code{native-inputs} is typically used to list tools needed at
  2580. build time, but not at run time, such as Autoconf, Automake, pkg-config,
  2581. Gettext, or Bison. @command{guix lint} can report likely mistakes in
  2582. this area (@pxref{Invoking guix lint}).
  2583. @anchor{package-propagated-inputs}
  2584. Lastly, @code{propagated-inputs} is similar to @code{inputs}, but the
  2585. specified packages will be automatically installed alongside the package
  2586. they belong to (@pxref{package-cmd-propagated-inputs, @command{guix
  2587. package}}, for information on how @command{guix package} deals with
  2588. propagated inputs.)
  2589. For example this is necessary when a C/C++ library needs headers of
  2590. another library to compile, or when a pkg-config file refers to another
  2591. one @i{via} its @code{Requires} field.
  2592. Another example where @code{propagated-inputs} is useful is for languages
  2593. that lack a facility to record the run-time search path akin to the
  2594. @code{RUNPATH} of ELF files; this includes Guile, Python, Perl, and
  2595. more. To ensure that libraries written in those languages can find
  2596. library code they depend on at run time, run-time dependencies must be
  2597. listed in @code{propagated-inputs} rather than @code{inputs}.
  2598. @item @code{self-native-input?} (default: @code{#f})
  2599. This is a Boolean field telling whether the package should use itself as
  2600. a native input when cross-compiling.
  2601. @item @code{outputs} (default: @code{'("out")})
  2602. The list of output names of the package. @xref{Packages with Multiple
  2603. Outputs}, for typical uses of additional outputs.
  2604. @item @code{native-search-paths} (default: @code{'()})
  2605. @itemx @code{search-paths} (default: @code{'()})
  2606. A list of @code{search-path-specification} objects describing
  2607. search-path environment variables honored by the package.
  2608. @item @code{replacement} (default: @code{#f})
  2609. This must be either @code{#f} or a package object that will be used as a
  2610. @dfn{replacement} for this package. @xref{Security Updates, grafts},
  2611. for details.
  2612. @item @code{synopsis}
  2613. A one-line description of the package.
  2614. @item @code{description}
  2615. A more elaborate description of the package.
  2616. @item @code{license}
  2617. @cindex license, of packages
  2618. The license of the package; a value from @code{(guix licenses)},
  2619. or a list of such values.
  2620. @item @code{home-page}
  2621. The URL to the home-page of the package, as a string.
  2622. @item @code{supported-systems} (default: @var{%supported-systems})
  2623. The list of systems supported by the package, as strings of the form
  2624. @code{architecture-kernel}, for example @code{"x86_64-linux"}.
  2625. @item @code{maintainers} (default: @code{'()})
  2626. The list of maintainers of the package, as @code{maintainer} objects.
  2627. @item @code{location} (default: source location of the @code{package} form)
  2628. The source location of the package. It is useful to override this when
  2629. inheriting from another package, in which case this field is not
  2630. automatically corrected.
  2631. @end table
  2632. @end deftp
  2633. @node origin Reference
  2634. @subsection @code{origin} Reference
  2635. This section summarizes all the options available in @code{origin}
  2636. declarations (@pxref{Defining Packages}).
  2637. @deftp {Data Type} origin
  2638. This is the data type representing a source code origin.
  2639. @table @asis
  2640. @item @code{uri}
  2641. An object containing the URI of the source. The object type depends on
  2642. the @code{method} (see below). For example, when using the
  2643. @var{url-fetch} method of @code{(guix download)}, the valid @code{uri}
  2644. values are: a URL represented as a string, or a list thereof.
  2645. @item @code{method}
  2646. A procedure that handles the URI.
  2647. Examples include:
  2648. @table @asis
  2649. @item @var{url-fetch} from @code{(guix download)}
  2650. download a file from the HTTP, HTTPS, or FTP URL specified in the
  2651. @code{uri} field;
  2652. @vindex git-fetch
  2653. @item @var{git-fetch} from @code{(guix git-download)}
  2654. clone the Git version control repository, and check out the revision
  2655. specified in the @code{uri} field as a @code{git-reference} object; a
  2656. @code{git-reference} looks like this:
  2657. @example
  2658. (git-reference
  2659. (url "git://git.debian.org/git/pkg-shadow/shadow")
  2660. (commit "v4.1.5.1"))
  2661. @end example
  2662. @end table
  2663. @item @code{sha256}
  2664. A bytevector containing the SHA-256 hash of the source. Typically the
  2665. @code{base32} form is used here to generate the bytevector from a
  2666. base-32 string.
  2667. You can obtain this information using @code{guix download}
  2668. (@pxref{Invoking guix download}) or @code{guix hash} (@pxref{Invoking
  2669. guix hash}).
  2670. @item @code{file-name} (default: @code{#f})
  2671. The file name under which the source code should be saved. When this is
  2672. @code{#f}, a sensible default value will be used in most cases. In case
  2673. the source is fetched from a URL, the file name from the URL will be
  2674. used. For version control checkouts, it is recommended to provide the
  2675. file name explicitly because the default is not very descriptive.
  2676. @item @code{patches} (default: @code{'()})
  2677. A list of file names, origins, or file-like objects (@pxref{G-Expressions,
  2678. file-like objects}) pointing to patches to be applied to the source.
  2679. This list of patches must be unconditional. In particular, it cannot
  2680. depend on the value of @code{%current-system} or
  2681. @code{%current-target-system}.
  2682. @item @code{snippet} (default: @code{#f})
  2683. A G-expression (@pxref{G-Expressions}) or S-expression that will be run
  2684. in the source directory. This is a convenient way to modify the source,
  2685. sometimes more convenient than a patch.
  2686. @item @code{patch-flags} (default: @code{'("-p1")})
  2687. A list of command-line flags that should be passed to the @code{patch}
  2688. command.
  2689. @item @code{patch-inputs} (default: @code{#f})
  2690. Input packages or derivations to the patching process. When this is
  2691. @code{#f}, the usual set of inputs necessary for patching are provided,
  2692. such as GNU@tie{}Patch.
  2693. @item @code{modules} (default: @code{'()})
  2694. A list of Guile modules that should be loaded during the patching
  2695. process and while running the code in the @code{snippet} field.
  2696. @item @code{patch-guile} (default: @code{#f})
  2697. The Guile package that should be used in the patching process. When
  2698. this is @code{#f}, a sensible default is used.
  2699. @end table
  2700. @end deftp
  2701. @node Build Systems
  2702. @section Build Systems
  2703. @cindex build system
  2704. Each package definition specifies a @dfn{build system} and arguments for
  2705. that build system (@pxref{Defining Packages}). This @code{build-system}
  2706. field represents the build procedure of the package, as well as implicit
  2707. dependencies of that build procedure.
  2708. Build systems are @code{<build-system>} objects. The interface to
  2709. create and manipulate them is provided by the @code{(guix build-system)}
  2710. module, and actual build systems are exported by specific modules.
  2711. @cindex bag (low-level package representation)
  2712. Under the hood, build systems first compile package objects to
  2713. @dfn{bags}. A @dfn{bag} is like a package, but with less
  2714. ornamentation---in other words, a bag is a lower-level representation of
  2715. a package, which includes all the inputs of that package, including some
  2716. that were implicitly added by the build system. This intermediate
  2717. representation is then compiled to a derivation (@pxref{Derivations}).
  2718. Build systems accept an optional list of @dfn{arguments}. In package
  2719. definitions, these are passed @i{via} the @code{arguments} field
  2720. (@pxref{Defining Packages}). They are typically keyword arguments
  2721. (@pxref{Optional Arguments, keyword arguments in Guile,, guile, GNU
  2722. Guile Reference Manual}). The value of these arguments is usually
  2723. evaluated in the @dfn{build stratum}---i.e., by a Guile process launched
  2724. by the daemon (@pxref{Derivations}).
  2725. The main build system is @var{gnu-build-system}, which implements the
  2726. standard build procedure for GNU and many other packages. It
  2727. is provided by the @code{(guix build-system gnu)} module.
  2728. @defvr {Scheme Variable} gnu-build-system
  2729. @var{gnu-build-system} represents the GNU Build System, and variants
  2730. thereof (@pxref{Configuration, configuration and makefile conventions,,
  2731. standards, GNU Coding Standards}).
  2732. @cindex build phases
  2733. In a nutshell, packages using it are configured, built, and installed with
  2734. the usual @code{./configure && make && make check && make install}
  2735. command sequence. In practice, a few additional steps are often needed.
  2736. All these steps are split up in separate @dfn{phases},
  2737. notably@footnote{Please see the @code{(guix build gnu-build-system)}
  2738. modules for more details about the build phases.}:
  2739. @table @code
  2740. @item unpack
  2741. Unpack the source tarball, and change the current directory to the
  2742. extracted source tree. If the source is actually a directory, copy it
  2743. to the build tree, and enter that directory.
  2744. @item patch-source-shebangs
  2745. Patch shebangs encountered in source files so they refer to the right
  2746. store file names. For instance, this changes @code{#!/bin/sh} to
  2747. @code{#!/gnu/store/@dots{}-bash-4.3/bin/sh}.
  2748. @item configure
  2749. Run the @file{configure} script with a number of default options, such
  2750. as @code{--prefix=/gnu/store/@dots{}}, as well as the options specified
  2751. by the @code{#:configure-flags} argument.
  2752. @item build
  2753. Run @code{make} with the list of flags specified with
  2754. @code{#:make-flags}. If the @code{#:parallel-build?} argument is true
  2755. (the default), build with @code{make -j}.
  2756. @item check
  2757. Run @code{make check}, or some other target specified with
  2758. @code{#:test-target}, unless @code{#:tests? #f} is passed. If the
  2759. @code{#:parallel-tests?} argument is true (the default), run @code{make
  2760. check -j}.
  2761. @item install
  2762. Run @code{make install} with the flags listed in @code{#:make-flags}.
  2763. @item patch-shebangs
  2764. Patch shebangs on the installed executable files.
  2765. @item strip
  2766. Strip debugging symbols from ELF files (unless @code{#:strip-binaries?}
  2767. is false), copying them to the @code{debug} output when available
  2768. (@pxref{Installing Debugging Files}).
  2769. @end table
  2770. @vindex %standard-phases
  2771. The build-side module @code{(guix build gnu-build-system)} defines
  2772. @var{%standard-phases} as the default list of build phases.
  2773. @var{%standard-phases} is a list of symbol/procedure pairs, where the
  2774. procedure implements the actual phase.
  2775. The list of phases used for a particular package can be changed with the
  2776. @code{#:phases} parameter. For instance, passing:
  2777. @example
  2778. #:phases (modify-phases %standard-phases (delete 'configure))
  2779. @end example
  2780. means that all the phases described above will be used, except the
  2781. @code{configure} phase.
  2782. In addition, this build system ensures that the ``standard'' environment
  2783. for GNU packages is available. This includes tools such as GCC, libc,
  2784. Coreutils, Bash, Make, Diffutils, grep, and sed (see the @code{(guix
  2785. build-system gnu)} module for a complete list). We call these the
  2786. @dfn{implicit inputs} of a package, because package definitions do not
  2787. have to mention them.
  2788. @end defvr
  2789. Other @code{<build-system>} objects are defined to support other
  2790. conventions and tools used by free software packages. They inherit most
  2791. of @var{gnu-build-system}, and differ mainly in the set of inputs
  2792. implicitly added to the build process, and in the list of phases
  2793. executed. Some of these build systems are listed below.
  2794. @defvr {Scheme Variable} ant-build-system
  2795. This variable is exported by @code{(guix build-system ant)}. It
  2796. implements the build procedure for Java packages that can be built with
  2797. @url{http://ant.apache.org/, Ant build tool}.
  2798. It adds both @code{ant} and the @dfn{Java Development Kit} (JDK) as
  2799. provided by the @code{icedtea} package to the set of inputs. Different
  2800. packages can be specified with the @code{#:ant} and @code{#:jdk}
  2801. parameters, respectively.
  2802. When the original package does not provide a suitable Ant build file,
  2803. the parameter @code{#:jar-name} can be used to generate a minimal Ant
  2804. build file @file{build.xml} with tasks to build the specified jar
  2805. archive. In this case the parameter @code{#:source-dir} can be used to
  2806. specify the source sub-directory, defaulting to ``src''.
  2807. The @code{#:main-class} parameter can be used with the minimal ant
  2808. buildfile to specify the main class of the resulting jar. This makes the
  2809. jar file executable. The @code{#:test-include} parameter can be used to
  2810. specify the list of junit tests to run. It defaults to
  2811. @code{(list "**/*Test.java")}. The @code{#:test-exclude} can be used to
  2812. disable some tests. It defaults to @code{(list "**/Abstract*.java")},
  2813. because abstract classes cannot be run as tests.
  2814. The parameter @code{#:build-target} can be used to specify the Ant task
  2815. that should be run during the @code{build} phase. By default the
  2816. ``jar'' task will be run.
  2817. @end defvr
  2818. @defvr {Scheme Variable} asdf-build-system/source
  2819. @defvrx {Scheme Variable} asdf-build-system/sbcl
  2820. @defvrx {Scheme Variable} asdf-build-system/ecl
  2821. These variables, exported by @code{(guix build-system asdf)}, implement
  2822. build procedures for Common Lisp packages using
  2823. @url{https://common-lisp.net/project/asdf/, ``ASDF''}. ASDF is a system
  2824. definition facility for Common Lisp programs and libraries.
  2825. The @code{asdf-build-system/source} system installs the packages in
  2826. source form, and can be loaded using any common lisp implementation, via
  2827. ASDF. The others, such as @code{asdf-build-system/sbcl}, install binary
  2828. systems in the format which a particular implementation understands.
  2829. These build systems can also be used to produce executable programs, or
  2830. lisp images which contain a set of packages pre-loaded.
  2831. The build system uses naming conventions. For binary packages, the
  2832. package name should be prefixed with the lisp implementation, such as
  2833. @code{sbcl-} for @code{asdf-build-system/sbcl}.
  2834. Additionally, the corresponding source package should be labeled using
  2835. the same convention as python packages (see @ref{Python Modules}), using
  2836. the @code{cl-} prefix.
  2837. For binary packages, each system should be defined as a Guix package.
  2838. If one package @code{origin} contains several systems, package variants
  2839. can be created in order to build all the systems. Source packages,
  2840. which use @code{asdf-build-system/source}, may contain several systems.
  2841. In order to create executable programs and images, the build-side
  2842. procedures @code{build-program} and @code{build-image} can be used.
  2843. They should be called in a build phase after the @code{create-symlinks}
  2844. phase, so that the system which was just built can be used within the
  2845. resulting image. @code{build-program} requires a list of Common Lisp
  2846. expressions to be passed as the @code{#:entry-program} argument.
  2847. If the system is not defined within its own @code{.asd} file of the same
  2848. name, then the @code{#:asd-file} parameter should be used to specify
  2849. which file the system is defined in. Furthermore, if the package
  2850. defines a system for its tests in a separate file, it will be loaded
  2851. before the tests are run if it is specified by the
  2852. @code{#:test-asd-file} parameter. If it is not set, the files
  2853. @code{<system>-tests.asd}, @code{<system>-test.asd}, @code{tests.asd},
  2854. and @code{test.asd} will be tried if they exist.
  2855. If for some reason the package must be named in a different way than the
  2856. naming conventions suggest, the @code{#:asd-system-name} parameter can
  2857. be used to specify the name of the system.
  2858. @end defvr
  2859. @defvr {Scheme Variable} cargo-build-system
  2860. @cindex Rust programming language
  2861. @cindex Cargo (Rust build system)
  2862. This variable is exported by @code{(guix build-system cargo)}. It
  2863. supports builds of packages using Cargo, the build tool of the
  2864. @uref{https://www.rust-lang.org, Rust programming language}.
  2865. In its @code{configure} phase, this build system replaces dependencies
  2866. specified in the @file{Carto.toml} file with inputs to the Guix package.
  2867. The @code{install} phase installs the binaries, and it also installs the
  2868. source code and @file{Cargo.toml} file.
  2869. @end defvr
  2870. @defvr {Scheme Variable} cmake-build-system
  2871. This variable is exported by @code{(guix build-system cmake)}. It
  2872. implements the build procedure for packages using the
  2873. @url{http://www.cmake.org, CMake build tool}.
  2874. It automatically adds the @code{cmake} package to the set of inputs.
  2875. Which package is used can be specified with the @code{#:cmake}
  2876. parameter.
  2877. The @code{#:configure-flags} parameter is taken as a list of flags
  2878. passed to the @command{cmake} command. The @code{#:build-type}
  2879. parameter specifies in abstract terms the flags passed to the compiler;
  2880. it defaults to @code{"RelWithDebInfo"} (short for ``release mode with
  2881. debugging information''), which roughly means that code is compiled with
  2882. @code{-O2 -g}, as is the case for Autoconf-based packages by default.
  2883. @end defvr
  2884. @defvr {Scheme Variable} glib-or-gtk-build-system
  2885. This variable is exported by @code{(guix build-system glib-or-gtk)}. It
  2886. is intended for use with packages making use of GLib or GTK+.
  2887. This build system adds the following two phases to the ones defined by
  2888. @var{gnu-build-system}:
  2889. @table @code
  2890. @item glib-or-gtk-wrap
  2891. The phase @code{glib-or-gtk-wrap} ensures that programs in
  2892. @file{bin/} are able to find GLib ``schemas'' and
  2893. @uref{https://developer.gnome.org/gtk3/stable/gtk-running.html, GTK+
  2894. modules}. This is achieved by wrapping the programs in launch scripts
  2895. that appropriately set the @code{XDG_DATA_DIRS} and @code{GTK_PATH}
  2896. environment variables.
  2897. It is possible to exclude specific package outputs from that wrapping
  2898. process by listing their names in the
  2899. @code{#:glib-or-gtk-wrap-excluded-outputs} parameter. This is useful
  2900. when an output is known not to contain any GLib or GTK+ binaries, and
  2901. where wrapping would gratuitously add a dependency of that output on
  2902. GLib and GTK+.
  2903. @item glib-or-gtk-compile-schemas
  2904. The phase @code{glib-or-gtk-compile-schemas} makes sure that all
  2905. @uref{https://developer.gnome.org/gio/stable/glib-compile-schemas.html,
  2906. GSettings schemas} of GLib are compiled. Compilation is performed by the
  2907. @command{glib-compile-schemas} program. It is provided by the package
  2908. @code{glib:bin} which is automatically imported by the build system.
  2909. The @code{glib} package providing @command{glib-compile-schemas} can be
  2910. specified with the @code{#:glib} parameter.
  2911. @end table
  2912. Both phases are executed after the @code{install} phase.
  2913. @end defvr
  2914. @defvr {Scheme Variable} minify-build-system
  2915. This variable is exported by @code{(guix build-system minify)}. It
  2916. implements a minification procedure for simple JavaScript packages.
  2917. It adds @code{uglify-js} to the set of inputs and uses it to compress
  2918. all JavaScript files in the @file{src} directory. A different minifier
  2919. package can be specified with the @code{#:uglify-js} parameter, but it
  2920. is expected that the package writes the minified code to the standard
  2921. output.
  2922. When the input JavaScript files are not all located in the @file{src}
  2923. directory, the parameter @code{#:javascript-files} can be used to
  2924. specify a list of file names to feed to the minifier.
  2925. @end defvr
  2926. @defvr {Scheme Variable} ocaml-build-system
  2927. This variable is exported by @code{(guix build-system ocaml)}. It implements
  2928. a build procedure for @uref{https://ocaml.org, OCaml} packages, which consists
  2929. of choosing the correct set of commands to run for each package. OCaml
  2930. packages can expect many different commands to be run. This build system will
  2931. try some of them.
  2932. When the package has a @file{setup.ml} file present at the top-level, it will
  2933. run @code{ocaml setup.ml -configure}, @code{ocaml setup.ml -build} and
  2934. @code{ocaml setup.ml -install}. The build system will assume that this file
  2935. was generated by @uref{http://oasis.forge.ocamlcore.org/, OASIS} and will take
  2936. care of setting the prefix and enabling tests if they are not disabled. You
  2937. can pass configure and build flags with the @code{#:configure-flags} and
  2938. @code{#:build-flags}. The @code{#:test-flags} key can be passed to change the
  2939. set of flags used to enable tests. The @code{#:use-make?} key can be used to
  2940. bypass this system in the build and install phases.
  2941. When the package has a @file{configure} file, it is assumed that it is a
  2942. hand-made configure script that requires a different argument format than
  2943. in the @code{gnu-build-system}. You can add more flags with the
  2944. @code{#:configure-flags} key.
  2945. When the package has a @file{Makefile} file (or @code{#:use-make?} is
  2946. @code{#t}), it will be used and more flags can be passed to the build and
  2947. install phases with the @code{#:make-flags} key.
  2948. Finally, some packages do not have these files and use a somewhat standard
  2949. location for its build system. In that case, the build system will run
  2950. @code{ocaml pkg/pkg.ml} or @code{ocaml pkg/build.ml} and take care of
  2951. providing the path to the required findlib module. Additional flags can
  2952. be passed via the @code{#:build-flags} key. Install is taken care of by
  2953. @command{opam-installer}. In this case, the @code{opam} package must
  2954. be added to the @code{native-inputs} field of the package definition.
  2955. Note that most OCaml packages assume they will be installed in the same
  2956. directory as OCaml, which is not what we want in guix. In particular, they
  2957. will install @file{.so} files in their module's directory, which is usually
  2958. fine because it is in the OCaml compiler directory. In guix though, these
  2959. libraries cannot be found and we use @code{CAML_LD_LIBRARY_PATH}. This
  2960. variable points to @file{lib/ocaml/site-lib/stubslibs} and this is where
  2961. @file{.so} libraries should be installed.
  2962. @end defvr
  2963. @defvr {Scheme Variable} python-build-system
  2964. This variable is exported by @code{(guix build-system python)}. It
  2965. implements the more or less standard build procedure used by Python
  2966. packages, which consists in running @code{python setup.py build} and
  2967. then @code{python setup.py install --prefix=/gnu/store/@dots{}}.
  2968. For packages that install stand-alone Python programs under @code{bin/},
  2969. it takes care of wrapping these programs so that their @code{PYTHONPATH}
  2970. environment variable points to all the Python libraries they depend on.
  2971. Which Python package is used to perform the build can be specified with
  2972. the @code{#:python} parameter. This is a useful way to force a package
  2973. to be built for a specific version of the Python interpreter, which
  2974. might be necessary if the package is only compatible with a single
  2975. interpreter version.
  2976. By default guix calls @code{setup.py} under control of
  2977. @code{setuptools}, much like @command{pip} does. Some packages are not
  2978. compatible with setuptools (and pip), thus you can disable this by
  2979. setting the @code{#:use-setuptools} parameter to @code{#f}.
  2980. @end defvr
  2981. @defvr {Scheme Variable} perl-build-system
  2982. This variable is exported by @code{(guix build-system perl)}. It
  2983. implements the standard build procedure for Perl packages, which either
  2984. consists in running @code{perl Build.PL --prefix=/gnu/store/@dots{}},
  2985. followed by @code{Build} and @code{Build install}; or in running
  2986. @code{perl Makefile.PL PREFIX=/gnu/store/@dots{}}, followed by
  2987. @code{make} and @code{make install}, depending on which of
  2988. @code{Build.PL} or @code{Makefile.PL} is present in the package
  2989. distribution. Preference is given to the former if both @code{Build.PL}
  2990. and @code{Makefile.PL} exist in the package distribution. This
  2991. preference can be reversed by specifying @code{#t} for the
  2992. @code{#:make-maker?} parameter.
  2993. The initial @code{perl Makefile.PL} or @code{perl Build.PL} invocation
  2994. passes flags specified by the @code{#:make-maker-flags} or
  2995. @code{#:module-build-flags} parameter, respectively.
  2996. Which Perl package is used can be specified with @code{#:perl}.
  2997. @end defvr
  2998. @defvr {Scheme Variable} r-build-system
  2999. This variable is exported by @code{(guix build-system r)}. It
  3000. implements the build procedure used by @uref{http://r-project.org, R}
  3001. packages, which essentially is little more than running @code{R CMD
  3002. INSTALL --library=/gnu/store/@dots{}} in an environment where
  3003. @code{R_LIBS_SITE} contains the paths to all R package inputs. Tests
  3004. are run after installation using the R function
  3005. @code{tools::testInstalledPackage}.
  3006. @end defvr
  3007. @defvr {Scheme Variable} texlive-build-system
  3008. This variable is exported by @code{(guix build-system texlive)}. It is
  3009. used to build TeX packages in batch mode with a specified engine. The
  3010. build system sets the @code{TEXINPUTS} variable to find all TeX source
  3011. files in the inputs.
  3012. By default it runs @code{luatex} on all files ending on @code{ins}. A
  3013. different engine and format can be specified with the
  3014. @code{#:tex-format} argument. Different build targets can be specified
  3015. with the @code{#:build-targets} argument, which expects a list of file
  3016. names. The build system adds only @code{texlive-bin} and
  3017. @code{texlive-latex-base} (both from @code{(gnu packages tex}) to the
  3018. inputs. Both can be overridden with the arguments @code{#:texlive-bin}
  3019. and @code{#:texlive-latex-base}, respectively.
  3020. The @code{#:tex-directory} parameter tells the build system where to
  3021. install the built files under the texmf tree.
  3022. @end defvr
  3023. @defvr {Scheme Variable} ruby-build-system
  3024. This variable is exported by @code{(guix build-system ruby)}. It
  3025. implements the RubyGems build procedure used by Ruby packages, which
  3026. involves running @code{gem build} followed by @code{gem install}.
  3027. The @code{source} field of a package that uses this build system
  3028. typically references a gem archive, since this is the format that Ruby
  3029. developers use when releasing their software. The build system unpacks
  3030. the gem archive, potentially patches the source, runs the test suite,
  3031. repackages the gem, and installs it. Additionally, directories and
  3032. tarballs may be referenced to allow building unreleased gems from Git or
  3033. a traditional source release tarball.
  3034. Which Ruby package is used can be specified with the @code{#:ruby}
  3035. parameter. A list of additional flags to be passed to the @command{gem}
  3036. command can be specified with the @code{#:gem-flags} parameter.
  3037. @end defvr
  3038. @defvr {Scheme Variable} waf-build-system
  3039. This variable is exported by @code{(guix build-system waf)}. It
  3040. implements a build procedure around the @code{waf} script. The common
  3041. phases---@code{configure}, @code{build}, and @code{install}---are
  3042. implemented by passing their names as arguments to the @code{waf}
  3043. script.
  3044. The @code{waf} script is executed by the Python interpreter. Which
  3045. Python package is used to run the script can be specified with the
  3046. @code{#:python} parameter.
  3047. @end defvr
  3048. @defvr {Scheme Variable} haskell-build-system
  3049. This variable is exported by @code{(guix build-system haskell)}. It
  3050. implements the Cabal build procedure used by Haskell packages, which
  3051. involves running @code{runhaskell Setup.hs configure
  3052. --prefix=/gnu/store/@dots{}} and @code{runhaskell Setup.hs build}.
  3053. Instead of installing the package by running @code{runhaskell Setup.hs
  3054. install}, to avoid trying to register libraries in the read-only
  3055. compiler store directory, the build system uses @code{runhaskell
  3056. Setup.hs copy}, followed by @code{runhaskell Setup.hs register}. In
  3057. addition, the build system generates the package documentation by
  3058. running @code{runhaskell Setup.hs haddock}, unless @code{#:haddock? #f}
  3059. is passed. Optional Haddock parameters can be passed with the help of
  3060. the @code{#:haddock-flags} parameter. If the file @code{Setup.hs} is
  3061. not found, the build system looks for @code{Setup.lhs} instead.
  3062. Which Haskell compiler is used can be specified with the @code{#:haskell}
  3063. parameter which defaults to @code{ghc}.
  3064. @end defvr
  3065. @defvr {Scheme Variable} dub-build-system
  3066. This variable is exported by @code{(guix build-system dub)}. It
  3067. implements the Dub build procedure used by D packages, which
  3068. involves running @code{dub build} and @code{dub run}.
  3069. Installation is done by copying the files manually.
  3070. Which D compiler is used can be specified with the @code{#:ldc}
  3071. parameter which defaults to @code{ldc}.
  3072. @end defvr
  3073. @defvr {Scheme Variable} emacs-build-system
  3074. This variable is exported by @code{(guix build-system emacs)}. It
  3075. implements an installation procedure similar to the packaging system
  3076. of Emacs itself (@pxref{Packages,,, emacs, The GNU Emacs Manual}).
  3077. It first creates the @code{@var{package}-autoloads.el} file, then it
  3078. byte compiles all Emacs Lisp files. Differently from the Emacs
  3079. packaging system, the Info documentation files are moved to the standard
  3080. documentation directory and the @file{dir} file is deleted. Each
  3081. package is installed in its own directory under
  3082. @file{share/emacs/site-lisp/guix.d}.
  3083. @end defvr
  3084. @defvr {Scheme Variable} font-build-system
  3085. This variable is exported by @code{(guix build-system font)}. It
  3086. implements an installation procedure for font packages where upstream
  3087. provides pre-compiled TrueType, OpenType, etc. font files that merely
  3088. need to be copied into place. It copies font files to standard
  3089. locations in the output directory.
  3090. @end defvr
  3091. @defvr {Scheme Variable} meson-build-system
  3092. This variable is exported by @code{(guix build-system meson)}. It
  3093. implements the build procedure for packages that use
  3094. @url{http://mesonbuild.com, Meson} as their build system.
  3095. It adds both Meson and @uref{https://ninja-build.org/, Ninja} to the set
  3096. of inputs, and they can be changed with the parameters @code{#:meson}
  3097. and @code{#:ninja} if needed. The default Meson is
  3098. @code{meson-for-build}, which is special because it doesn't clear the
  3099. @code{RUNPATH} of binaries and libraries when they are installed.
  3100. This build system is an extension of @var{gnu-build-system}, but with the
  3101. following phases changed to some specific for Meson:
  3102. @table @code
  3103. @item configure
  3104. The phase runs @code{meson} with the flags specified in
  3105. @code{#:configure-flags}. The flag @code{--build-type} is always set to
  3106. @code{plain} unless something else is specified in @code{#:build-type}.
  3107. @item build
  3108. The phase runs @code{ninja} to build the package in parallel by default, but
  3109. this can be changed with @code{#:parallel-build?}.
  3110. @item check
  3111. The phase runs @code{ninja} with the target specified in @code{#:test-target},
  3112. which is @code{"test"} by default.
  3113. @item install
  3114. The phase runs @code{ninja install} and can not be changed.
  3115. @end table
  3116. Apart from that, the build system also adds the following phases:
  3117. @table @code
  3118. @item fix-runpath
  3119. This phase tries to locate the local directories in the package being build,
  3120. which has libraries that some of the binaries need. If any are found, they will
  3121. be added to the programs @code{RUNPATH}. It is needed because
  3122. @code{meson-for-build} keeps the @code{RUNPATH} of binaries and libraries from
  3123. when they are build, but often that is not the @code{RUNPATH} we want.
  3124. Therefor it is also shrinked to the minimum needed by the program.
  3125. @item glib-or-gtk-wrap
  3126. This phase is the phase provided by @code{glib-or-gtk-build-system}, and it
  3127. is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
  3128. @item glib-or-gtk-compile-schemas
  3129. This phase is the phase provided by @code{glib-or-gtk-build-system}, and it
  3130. is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
  3131. @end table
  3132. @end defvr
  3133. Lastly, for packages that do not need anything as sophisticated, a
  3134. ``trivial'' build system is provided. It is trivial in the sense that
  3135. it provides basically no support: it does not pull any implicit inputs,
  3136. and does not have a notion of build phases.
  3137. @defvr {Scheme Variable} trivial-build-system
  3138. This variable is exported by @code{(guix build-system trivial)}.
  3139. This build system requires a @code{#:builder} argument. This argument
  3140. must be a Scheme expression that builds the package output(s)---as
  3141. with @code{build-expression->derivation} (@pxref{Derivations,
  3142. @code{build-expression->derivation}}).
  3143. @end defvr
  3144. @node The Store
  3145. @section The Store
  3146. @cindex store
  3147. @cindex store items
  3148. @cindex store paths
  3149. Conceptually, the @dfn{store} is the place where derivations that have
  3150. been built successfully are stored---by default, @file{/gnu/store}.
  3151. Sub-directories in the store are referred to as @dfn{store items} or
  3152. sometimes @dfn{store paths}. The store has an associated database that
  3153. contains information such as the store paths referred to by each store
  3154. path, and the list of @emph{valid} store items---results of successful
  3155. builds. This database resides in @file{@var{localstatedir}/guix/db},
  3156. where @var{localstatedir} is the state directory specified @i{via}
  3157. @option{--localstatedir} at configure time, usually @file{/var}.
  3158. The store is @emph{always} accessed by the daemon on behalf of its clients
  3159. (@pxref{Invoking guix-daemon}). To manipulate the store, clients
  3160. connect to the daemon over a Unix-domain socket, send requests to it,
  3161. and read the result---these are remote procedure calls, or RPCs.
  3162. @quotation Note
  3163. Users must @emph{never} modify files under @file{/gnu/store} directly.
  3164. This would lead to inconsistencies and break the immutability
  3165. assumptions of Guix's functional model (@pxref{Introduction}).
  3166. @xref{Invoking guix gc, @command{guix gc --verify}}, for information on
  3167. how to check the integrity of the store and attempt recovery from
  3168. accidental modifications.
  3169. @end quotation
  3170. The @code{(guix store)} module provides procedures to connect to the
  3171. daemon, and to perform RPCs. These are described below. By default,
  3172. @code{open-connection}, and thus all the @command{guix} commands,
  3173. connect to the local daemon or to the URI specified by the
  3174. @code{GUIX_DAEMON_SOCKET} environment variable.
  3175. @defvr {Environment Variable} GUIX_DAEMON_SOCKET
  3176. When set, the value of this variable should be a file name or a URI
  3177. designating the daemon endpoint. When it is a file name, it denotes a
  3178. Unix-domain socket to connect to. In addition to file names, the
  3179. supported URI schemes are:
  3180. @table @code
  3181. @item file
  3182. @itemx unix
  3183. These are for Unix-domain sockets.
  3184. @code{file:///var/guix/daemon-socket/socket} is equivalent to
  3185. @file{/var/guix/daemon-socket/socket}.
  3186. @item guix
  3187. @cindex daemon, remote access
  3188. @cindex remote access to the daemon
  3189. @cindex daemon, cluster setup
  3190. @cindex clusters, daemon setup
  3191. These URIs denote connections over TCP/IP, without encryption nor
  3192. authentication of the remote host. The URI must specify the host name
  3193. and optionally a port number (by default port 44146 is used):
  3194. @example
  3195. guix://master.guix.example.org:1234
  3196. @end example
  3197. This setup is suitable on local networks, such as clusters, where only
  3198. trusted nodes may connect to the build daemon at
  3199. @code{master.guix.example.org}.
  3200. The @code{--listen} option of @command{guix-daemon} can be used to
  3201. instruct it to listen for TCP connections (@pxref{Invoking guix-daemon,
  3202. @code{--listen}}).
  3203. @item ssh
  3204. @cindex SSH access to build daemons
  3205. These URIs allow you to connect to a remote daemon over
  3206. SSH@footnote{This feature requires Guile-SSH (@pxref{Requirements}).}.
  3207. A typical URL might look like this:
  3208. @example
  3209. ssh://charlie@@guix.example.org:22
  3210. @end example
  3211. As for @command{guix copy}, the usual OpenSSH client configuration files
  3212. are honored (@pxref{Invoking guix copy}).
  3213. @end table
  3214. Additional URI schemes may be supported in the future.
  3215. @c XXX: Remove this note when the protocol incurs fewer round trips
  3216. @c and when (guix derivations) no longer relies on file system access.
  3217. @quotation Note
  3218. The ability to connect to remote build daemons is considered
  3219. experimental as of @value{VERSION}. Please get in touch with us to
  3220. share any problems or suggestions you may have (@pxref{Contributing}).
  3221. @end quotation
  3222. @end defvr
  3223. @deffn {Scheme Procedure} open-connection [@var{uri}] [#:reserve-space? #t]
  3224. Connect to the daemon over the Unix-domain socket at @var{uri} (a string). When
  3225. @var{reserve-space?} is true, instruct it to reserve a little bit of
  3226. extra space on the file system so that the garbage collector can still
  3227. operate should the disk become full. Return a server object.
  3228. @var{file} defaults to @var{%default-socket-path}, which is the normal
  3229. location given the options that were passed to @command{configure}.
  3230. @end deffn
  3231. @deffn {Scheme Procedure} close-connection @var{server}
  3232. Close the connection to @var{server}.
  3233. @end deffn
  3234. @defvr {Scheme Variable} current-build-output-port
  3235. This variable is bound to a SRFI-39 parameter, which refers to the port
  3236. where build and error logs sent by the daemon should be written.
  3237. @end defvr
  3238. Procedures that make RPCs all take a server object as their first
  3239. argument.
  3240. @deffn {Scheme Procedure} valid-path? @var{server} @var{path}
  3241. @cindex invalid store items
  3242. Return @code{#t} when @var{path} designates a valid store item and
  3243. @code{#f} otherwise (an invalid item may exist on disk but still be
  3244. invalid, for instance because it is the result of an aborted or failed
  3245. build.)
  3246. A @code{&nix-protocol-error} condition is raised if @var{path} is not
  3247. prefixed by the store directory (@file{/gnu/store}).
  3248. @end deffn
  3249. @deffn {Scheme Procedure} add-text-to-store @var{server} @var{name} @var{text} [@var{references}]
  3250. Add @var{text} under file @var{name} in the store, and return its store
  3251. path. @var{references} is the list of store paths referred to by the
  3252. resulting store path.
  3253. @end deffn
  3254. @deffn {Scheme Procedure} build-derivations @var{server} @var{derivations}
  3255. Build @var{derivations} (a list of @code{<derivation>} objects or
  3256. derivation paths), and return when the worker is done building them.
  3257. Return @code{#t} on success.
  3258. @end deffn
  3259. Note that the @code{(guix monads)} module provides a monad as well as
  3260. monadic versions of the above procedures, with the goal of making it
  3261. more convenient to work with code that accesses the store (@pxref{The
  3262. Store Monad}).
  3263. @c FIXME
  3264. @i{This section is currently incomplete.}
  3265. @node Derivations
  3266. @section Derivations
  3267. @cindex derivations
  3268. Low-level build actions and the environment in which they are performed
  3269. are represented by @dfn{derivations}. A derivation contains the
  3270. following pieces of information:
  3271. @itemize
  3272. @item
  3273. The outputs of the derivation---derivations produce at least one file or
  3274. directory in the store, but may produce more.
  3275. @item
  3276. The inputs of the derivations, which may be other derivations or plain
  3277. files in the store (patches, build scripts, etc.)
  3278. @item
  3279. The system type targeted by the derivation---e.g., @code{x86_64-linux}.
  3280. @item
  3281. The file name of a build script in the store, along with the arguments
  3282. to be passed.
  3283. @item
  3284. A list of environment variables to be defined.
  3285. @end itemize
  3286. @cindex derivation path
  3287. Derivations allow clients of the daemon to communicate build actions to
  3288. the store. They exist in two forms: as an in-memory representation,
  3289. both on the client- and daemon-side, and as files in the store whose
  3290. name end in @code{.drv}---these files are referred to as @dfn{derivation
  3291. paths}. Derivations paths can be passed to the @code{build-derivations}
  3292. procedure to perform the build actions they prescribe (@pxref{The
  3293. Store}).
  3294. The @code{(guix derivations)} module provides a representation of
  3295. derivations as Scheme objects, along with procedures to create and
  3296. otherwise manipulate derivations. The lowest-level primitive to create
  3297. a derivation is the @code{derivation} procedure:
  3298. @deffn {Scheme Procedure} derivation @var{store} @var{name} @var{builder} @
  3299. @var{args} [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
  3300. [#:recursive? #f] [#:inputs '()] [#:env-vars '()] @
  3301. [#:system (%current-system)] [#:references-graphs #f] @
  3302. [#:allowed-references #f] [#:disallowed-references #f] @
  3303. [#:leaked-env-vars #f] [#:local-build? #f] @
  3304. [#:substitutable? #t]
  3305. Build a derivation with the given arguments, and return the resulting
  3306. @code{<derivation>} object.
  3307. When @var{hash} and @var{hash-algo} are given, a
  3308. @dfn{fixed-output derivation} is created---i.e., one whose result is
  3309. known in advance, such as a file download. If, in addition,
  3310. @var{recursive?} is true, then that fixed output may be an executable
  3311. file or a directory and @var{hash} must be the hash of an archive
  3312. containing this output.
  3313. When @var{references-graphs} is true, it must be a list of file
  3314. name/store path pairs. In that case, the reference graph of each store
  3315. path is exported in the build environment in the corresponding file, in
  3316. a simple text format.
  3317. When @var{allowed-references} is true, it must be a list of store items
  3318. or outputs that the derivation's output may refer to. Likewise,
  3319. @var{disallowed-references}, if true, must be a list of things the
  3320. outputs may @emph{not} refer to.
  3321. When @var{leaked-env-vars} is true, it must be a list of strings
  3322. denoting environment variables that are allowed to ``leak'' from the
  3323. daemon's environment to the build environment. This is only applicable
  3324. to fixed-output derivations---i.e., when @var{hash} is true. The main
  3325. use is to allow variables such as @code{http_proxy} to be passed to
  3326. derivations that download files.
  3327. When @var{local-build?} is true, declare that the derivation is not a
  3328. good candidate for offloading and should rather be built locally
  3329. (@pxref{Daemon Offload Setup}). This is the case for small derivations
  3330. where the costs of data transfers would outweigh the benefits.
  3331. When @var{substitutable?} is false, declare that substitutes of the
  3332. derivation's output should not be used (@pxref{Substitutes}). This is
  3333. useful, for instance, when building packages that capture details of the
  3334. host CPU instruction set.
  3335. @end deffn
  3336. @noindent
  3337. Here's an example with a shell script as its builder, assuming
  3338. @var{store} is an open connection to the daemon, and @var{bash} points
  3339. to a Bash executable in the store:
  3340. @lisp
  3341. (use-modules (guix utils)
  3342. (guix store)
  3343. (guix derivations))
  3344. (let ((builder ; add the Bash script to the store
  3345. (add-text-to-store store "my-builder.sh"
  3346. "echo hello world > $out\n" '())))
  3347. (derivation store "foo"
  3348. bash `("-e" ,builder)
  3349. #:inputs `((,bash) (,builder))
  3350. #:env-vars '(("HOME" . "/homeless"))))
  3351. @result{} #<derivation /gnu/store/@dots{}-foo.drv => /gnu/store/@dots{}-foo>
  3352. @end lisp
  3353. As can be guessed, this primitive is cumbersome to use directly. A
  3354. better approach is to write build scripts in Scheme, of course! The
  3355. best course of action for that is to write the build code as a
  3356. ``G-expression'', and to pass it to @code{gexp->derivation}. For more
  3357. information, @pxref{G-Expressions}.
  3358. Once upon a time, @code{gexp->derivation} did not exist and constructing
  3359. derivations with build code written in Scheme was achieved with
  3360. @code{build-expression->derivation}, documented below. This procedure
  3361. is now deprecated in favor of the much nicer @code{gexp->derivation}.
  3362. @deffn {Scheme Procedure} build-expression->derivation @var{store} @
  3363. @var{name} @var{exp} @
  3364. [#:system (%current-system)] [#:inputs '()] @
  3365. [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
  3366. [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
  3367. [#:references-graphs #f] [#:allowed-references #f] @
  3368. [#:disallowed-references #f] @
  3369. [#:local-build? #f] [#:substitutable? #t] [#:guile-for-build #f]
  3370. Return a derivation that executes Scheme expression @var{exp} as a
  3371. builder for derivation @var{name}. @var{inputs} must be a list of
  3372. @code{(name drv-path sub-drv)} tuples; when @var{sub-drv} is omitted,
  3373. @code{"out"} is assumed. @var{modules} is a list of names of Guile
  3374. modules from the current search path to be copied in the store,
  3375. compiled, and made available in the load path during the execution of
  3376. @var{exp}---e.g., @code{((guix build utils) (guix build
  3377. gnu-build-system))}.
  3378. @var{exp} is evaluated in an environment where @code{%outputs} is bound
  3379. to a list of output/path pairs, and where @code{%build-inputs} is bound
  3380. to a list of string/output-path pairs made from @var{inputs}.
  3381. Optionally, @var{env-vars} is a list of string pairs specifying the name
  3382. and value of environment variables visible to the builder. The builder
  3383. terminates by passing the result of @var{exp} to @code{exit}; thus, when
  3384. @var{exp} returns @code{#f}, the build is considered to have failed.
  3385. @var{exp} is built using @var{guile-for-build} (a derivation). When
  3386. @var{guile-for-build} is omitted or is @code{#f}, the value of the
  3387. @code{%guile-for-build} fluid is used instead.
  3388. See the @code{derivation} procedure for the meaning of
  3389. @var{references-graphs}, @var{allowed-references},
  3390. @var{disallowed-references}, @var{local-build?}, and
  3391. @var{substitutable?}.
  3392. @end deffn
  3393. @noindent
  3394. Here's an example of a single-output derivation that creates a directory
  3395. containing one file:
  3396. @lisp
  3397. (let ((builder '(let ((out (assoc-ref %outputs "out")))
  3398. (mkdir out) ; create /gnu/store/@dots{}-goo
  3399. (call-with-output-file (string-append out "/test")
  3400. (lambda (p)
  3401. (display '(hello guix) p))))))
  3402. (build-expression->derivation store "goo" builder))
  3403. @result{} #<derivation /gnu/store/@dots{}-goo.drv => @dots{}>
  3404. @end lisp
  3405. @node The Store Monad
  3406. @section The Store Monad
  3407. @cindex monad
  3408. The procedures that operate on the store described in the previous
  3409. sections all take an open connection to the build daemon as their first
  3410. argument. Although the underlying model is functional, they either have
  3411. side effects or depend on the current state of the store.
  3412. The former is inconvenient: the connection to the build daemon has to be
  3413. carried around in all those functions, making it impossible to compose
  3414. functions that do not take that parameter with functions that do. The
  3415. latter can be problematic: since store operations have side effects
  3416. and/or depend on external state, they have to be properly sequenced.
  3417. @cindex monadic values
  3418. @cindex monadic functions
  3419. This is where the @code{(guix monads)} module comes in. This module
  3420. provides a framework for working with @dfn{monads}, and a particularly
  3421. useful monad for our uses, the @dfn{store monad}. Monads are a
  3422. construct that allows two things: associating ``context'' with values
  3423. (in our case, the context is the store), and building sequences of
  3424. computations (here computations include accesses to the store). Values
  3425. in a monad---values that carry this additional context---are called
  3426. @dfn{monadic values}; procedures that return such values are called
  3427. @dfn{monadic procedures}.
  3428. Consider this ``normal'' procedure:
  3429. @example
  3430. (define (sh-symlink store)
  3431. ;; Return a derivation that symlinks the 'bash' executable.
  3432. (let* ((drv (package-derivation store bash))
  3433. (out (derivation->output-path drv))
  3434. (sh (string-append out "/bin/bash")))
  3435. (build-expression->derivation store "sh"
  3436. `(symlink ,sh %output))))
  3437. @end example
  3438. Using @code{(guix monads)} and @code{(guix gexp)}, it may be rewritten
  3439. as a monadic function:
  3440. @example
  3441. (define (sh-symlink)
  3442. ;; Same, but return a monadic value.
  3443. (mlet %store-monad ((drv (package->derivation bash)))
  3444. (gexp->derivation "sh"
  3445. #~(symlink (string-append #$drv "/bin/bash")
  3446. #$output))))
  3447. @end example
  3448. There are several things to note in the second version: the @code{store}
  3449. parameter is now implicit and is ``threaded'' in the calls to the
  3450. @code{package->derivation} and @code{gexp->derivation} monadic
  3451. procedures, and the monadic value returned by @code{package->derivation}
  3452. is @dfn{bound} using @code{mlet} instead of plain @code{let}.
  3453. As it turns out, the call to @code{package->derivation} can even be
  3454. omitted since it will take place implicitly, as we will see later
  3455. (@pxref{G-Expressions}):
  3456. @example
  3457. (define (sh-symlink)
  3458. (gexp->derivation "sh"
  3459. #~(symlink (string-append #$bash "/bin/bash")
  3460. #$output)))
  3461. @end example
  3462. @c See
  3463. @c <https://syntaxexclamation.wordpress.com/2014/06/26/escaping-continuations/>
  3464. @c for the funny quote.
  3465. Calling the monadic @code{sh-symlink} has no effect. As someone once
  3466. said, ``you exit a monad like you exit a building on fire: by running''.
  3467. So, to exit the monad and get the desired effect, one must use
  3468. @code{run-with-store}:
  3469. @example
  3470. (run-with-store (open-connection) (sh-symlink))
  3471. @result{} /gnu/store/...-sh-symlink
  3472. @end example
  3473. Note that the @code{(guix monad-repl)} module extends the Guile REPL with
  3474. new ``meta-commands'' to make it easier to deal with monadic procedures:
  3475. @code{run-in-store}, and @code{enter-store-monad}. The former is used
  3476. to ``run'' a single monadic value through the store:
  3477. @example
  3478. scheme@@(guile-user)> ,run-in-store (package->derivation hello)
  3479. $1 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
  3480. @end example
  3481. The latter enters a recursive REPL, where all the return values are
  3482. automatically run through the store:
  3483. @example
  3484. scheme@@(guile-user)> ,enter-store-monad
  3485. store-monad@@(guile-user) [1]> (package->derivation hello)
  3486. $2 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
  3487. store-monad@@(guile-user) [1]> (text-file "foo" "Hello!")
  3488. $3 = "/gnu/store/@dots{}-foo"
  3489. store-monad@@(guile-user) [1]> ,q
  3490. scheme@@(guile-user)>
  3491. @end example
  3492. @noindent
  3493. Note that non-monadic values cannot be returned in the
  3494. @code{store-monad} REPL.
  3495. The main syntactic forms to deal with monads in general are provided by
  3496. the @code{(guix monads)} module and are described below.
  3497. @deffn {Scheme Syntax} with-monad @var{monad} @var{body} ...
  3498. Evaluate any @code{>>=} or @code{return} forms in @var{body} as being
  3499. in @var{monad}.
  3500. @end deffn
  3501. @deffn {Scheme Syntax} return @var{val}
  3502. Return a monadic value that encapsulates @var{val}.
  3503. @end deffn
  3504. @deffn {Scheme Syntax} >>= @var{mval} @var{mproc} ...
  3505. @dfn{Bind} monadic value @var{mval}, passing its ``contents'' to monadic
  3506. procedures @var{mproc}@dots{}@footnote{This operation is commonly
  3507. referred to as ``bind'', but that name denotes an unrelated procedure in
  3508. Guile. Thus we use this somewhat cryptic symbol inherited from the
  3509. Haskell language.}. There can be one @var{mproc} or several of them, as
  3510. in this example:
  3511. @example
  3512. (run-with-state
  3513. (with-monad %state-monad
  3514. (>>= (return 1)
  3515. (lambda (x) (return (+ 1 x)))
  3516. (lambda (x) (return (* 2 x)))))
  3517. 'some-state)
  3518. @result{} 4
  3519. @result{} some-state
  3520. @end example
  3521. @end deffn
  3522. @deffn {Scheme Syntax} mlet @var{monad} ((@var{var} @var{mval}) ...) @
  3523. @var{body} ...
  3524. @deffnx {Scheme Syntax} mlet* @var{monad} ((@var{var} @var{mval}) ...) @
  3525. @var{body} ...
  3526. Bind the variables @var{var} to the monadic values @var{mval} in
  3527. @var{body}, which is a sequence of expressions. As with the bind
  3528. operator, this can be thought of as ``unpacking'' the raw, non-monadic
  3529. value ``contained'' in @var{mval} and making @var{var} refer to that
  3530. raw, non-monadic value within the scope of the @var{body}. The form
  3531. (@var{var} -> @var{val}) binds @var{var} to the ``normal'' value
  3532. @var{val}, as per @code{let}. The binding operations occur in sequence
  3533. from left to right. The last expression of @var{body} must be a monadic
  3534. expression, and its result will become the result of the @code{mlet} or
  3535. @code{mlet*} when run in the @var{monad}.
  3536. @code{mlet*} is to @code{mlet} what @code{let*} is to @code{let}
  3537. (@pxref{Local Bindings,,, guile, GNU Guile Reference Manual}).
  3538. @end deffn
  3539. @deffn {Scheme System} mbegin @var{monad} @var{mexp} ...
  3540. Bind @var{mexp} and the following monadic expressions in sequence,
  3541. returning the result of the last expression. Every expression in the
  3542. sequence must be a monadic expression.
  3543. This is akin to @code{mlet}, except that the return values of the
  3544. monadic expressions are ignored. In that sense, it is analogous to
  3545. @code{begin}, but applied to monadic expressions.
  3546. @end deffn
  3547. @deffn {Scheme System} mwhen @var{condition} @var{mexp0} @var{mexp*} ...
  3548. When @var{condition} is true, evaluate the sequence of monadic
  3549. expressions @var{mexp0}..@var{mexp*} as in an @code{mbegin}. When
  3550. @var{condition} is false, return @code{*unspecified*} in the current
  3551. monad. Every expression in the sequence must be a monadic expression.
  3552. @end deffn
  3553. @deffn {Scheme System} munless @var{condition} @var{mexp0} @var{mexp*} ...
  3554. When @var{condition} is false, evaluate the sequence of monadic
  3555. expressions @var{mexp0}..@var{mexp*} as in an @code{mbegin}. When
  3556. @var{condition} is true, return @code{*unspecified*} in the current
  3557. monad. Every expression in the sequence must be a monadic expression.
  3558. @end deffn
  3559. @cindex state monad
  3560. The @code{(guix monads)} module provides the @dfn{state monad}, which
  3561. allows an additional value---the state---to be @emph{threaded} through
  3562. monadic procedure calls.
  3563. @defvr {Scheme Variable} %state-monad
  3564. The state monad. Procedures in the state monad can access and change
  3565. the state that is threaded.
  3566. Consider the example below. The @code{square} procedure returns a value
  3567. in the state monad. It returns the square of its argument, but also
  3568. increments the current state value:
  3569. @example
  3570. (define (square x)
  3571. (mlet %state-monad ((count (current-state)))
  3572. (mbegin %state-monad
  3573. (set-current-state (+ 1 count))
  3574. (return (* x x)))))
  3575. (run-with-state (sequence %state-monad (map square (iota 3))) 0)
  3576. @result{} (0 1 4)
  3577. @result{} 3
  3578. @end example
  3579. When ``run'' through @var{%state-monad}, we obtain that additional state
  3580. value, which is the number of @code{square} calls.
  3581. @end defvr
  3582. @deffn {Monadic Procedure} current-state
  3583. Return the current state as a monadic value.
  3584. @end deffn
  3585. @deffn {Monadic Procedure} set-current-state @var{value}
  3586. Set the current state to @var{value} and return the previous state as a
  3587. monadic value.
  3588. @end deffn
  3589. @deffn {Monadic Procedure} state-push @var{value}
  3590. Push @var{value} to the current state, which is assumed to be a list,
  3591. and return the previous state as a monadic value.
  3592. @end deffn
  3593. @deffn {Monadic Procedure} state-pop
  3594. Pop a value from the current state and return it as a monadic value.
  3595. The state is assumed to be a list.
  3596. @end deffn
  3597. @deffn {Scheme Procedure} run-with-state @var{mval} [@var{state}]
  3598. Run monadic value @var{mval} starting with @var{state} as the initial
  3599. state. Return two values: the resulting value, and the resulting state.
  3600. @end deffn
  3601. The main interface to the store monad, provided by the @code{(guix
  3602. store)} module, is as follows.
  3603. @defvr {Scheme Variable} %store-monad
  3604. The store monad---an alias for @var{%state-monad}.
  3605. Values in the store monad encapsulate accesses to the store. When its
  3606. effect is needed, a value of the store monad must be ``evaluated'' by
  3607. passing it to the @code{run-with-store} procedure (see below.)
  3608. @end defvr
  3609. @deffn {Scheme Procedure} run-with-store @var{store} @var{mval} [#:guile-for-build] [#:system (%current-system)]
  3610. Run @var{mval}, a monadic value in the store monad, in @var{store}, an
  3611. open store connection.
  3612. @end deffn
  3613. @deffn {Monadic Procedure} text-file @var{name} @var{text} [@var{references}]
  3614. Return as a monadic value the absolute file name in the store of the file
  3615. containing @var{text}, a string. @var{references} is a list of store items that the
  3616. resulting text file refers to; it defaults to the empty list.
  3617. @end deffn
  3618. @deffn {Monadic Procedure} interned-file @var{file} [@var{name}] @
  3619. [#:recursive? #t] [#:select? (const #t)]
  3620. Return the name of @var{file} once interned in the store. Use
  3621. @var{name} as its store name, or the basename of @var{file} if
  3622. @var{name} is omitted.
  3623. When @var{recursive?} is true, the contents of @var{file} are added
  3624. recursively; if @var{file} designates a flat file and @var{recursive?}
  3625. is true, its contents are added, and its permission bits are kept.
  3626. When @var{recursive?} is true, call @code{(@var{select?} @var{file}
  3627. @var{stat})} for each directory entry, where @var{file} is the entry's
  3628. absolute file name and @var{stat} is the result of @code{lstat}; exclude
  3629. entries for which @var{select?} does not return true.
  3630. The example below adds a file to the store, under two different names:
  3631. @example
  3632. (run-with-store (open-connection)
  3633. (mlet %store-monad ((a (interned-file "README"))
  3634. (b (interned-file "README" "LEGU-MIN")))
  3635. (return (list a b))))
  3636. @result{} ("/gnu/store/rwm@dots{}-README" "/gnu/store/44i@dots{}-LEGU-MIN")
  3637. @end example
  3638. @end deffn
  3639. The @code{(guix packages)} module exports the following package-related
  3640. monadic procedures:
  3641. @deffn {Monadic Procedure} package-file @var{package} [@var{file}] @
  3642. [#:system (%current-system)] [#:target #f] @
  3643. [#:output "out"]
  3644. Return as a monadic
  3645. value in the absolute file name of @var{file} within the @var{output}
  3646. directory of @var{package}. When @var{file} is omitted, return the name
  3647. of the @var{output} directory of @var{package}. When @var{target} is
  3648. true, use it as a cross-compilation target triplet.
  3649. @end deffn
  3650. @deffn {Monadic Procedure} package->derivation @var{package} [@var{system}]
  3651. @deffnx {Monadic Procedure} package->cross-derivation @var{package} @
  3652. @var{target} [@var{system}]
  3653. Monadic version of @code{package-derivation} and
  3654. @code{package-cross-derivation} (@pxref{Defining Packages}).
  3655. @end deffn
  3656. @node G-Expressions
  3657. @section G-Expressions
  3658. @cindex G-expression
  3659. @cindex build code quoting
  3660. So we have ``derivations'', which represent a sequence of build actions
  3661. to be performed to produce an item in the store (@pxref{Derivations}).
  3662. These build actions are performed when asking the daemon to actually
  3663. build the derivations; they are run by the daemon in a container
  3664. (@pxref{Invoking guix-daemon}).
  3665. @cindex strata of code
  3666. It should come as no surprise that we like to write these build actions
  3667. in Scheme. When we do that, we end up with two @dfn{strata} of Scheme
  3668. code@footnote{The term @dfn{stratum} in this context was coined by
  3669. Manuel Serrano et al.@: in the context of their work on Hop. Oleg
  3670. Kiselyov, who has written insightful
  3671. @url{http://okmij.org/ftp/meta-programming/#meta-scheme, essays and code
  3672. on this topic}, refers to this kind of code generation as
  3673. @dfn{staging}.}: the ``host code''---code that defines packages, talks
  3674. to the daemon, etc.---and the ``build code''---code that actually
  3675. performs build actions, such as making directories, invoking
  3676. @command{make}, etc.
  3677. To describe a derivation and its build actions, one typically needs to
  3678. embed build code inside host code. It boils down to manipulating build
  3679. code as data, and the homoiconicity of Scheme---code has a direct
  3680. representation as data---comes in handy for that. But we need more than
  3681. the normal @code{quasiquote} mechanism in Scheme to construct build
  3682. expressions.
  3683. The @code{(guix gexp)} module implements @dfn{G-expressions}, a form of
  3684. S-expressions adapted to build expressions. G-expressions, or
  3685. @dfn{gexps}, consist essentially of three syntactic forms: @code{gexp},
  3686. @code{ungexp}, and @code{ungexp-splicing} (or simply: @code{#~},
  3687. @code{#$}, and @code{#$@@}), which are comparable to
  3688. @code{quasiquote}, @code{unquote}, and @code{unquote-splicing},
  3689. respectively (@pxref{Expression Syntax, @code{quasiquote},, guile,
  3690. GNU Guile Reference Manual}). However, there are major differences:
  3691. @itemize
  3692. @item
  3693. Gexps are meant to be written to a file and run or manipulated by other
  3694. processes.
  3695. @item
  3696. When a high-level object such as a package or derivation is unquoted
  3697. inside a gexp, the result is as if its output file name had been
  3698. introduced.
  3699. @item
  3700. Gexps carry information about the packages or derivations they refer to,
  3701. and these dependencies are automatically added as inputs to the build
  3702. processes that use them.
  3703. @end itemize
  3704. @cindex lowering, of high-level objects in gexps
  3705. This mechanism is not limited to package and derivation
  3706. objects: @dfn{compilers} able to ``lower'' other high-level objects to
  3707. derivations or files in the store can be defined,
  3708. such that these objects can also be inserted
  3709. into gexps. For example, a useful type of high-level objects that can be
  3710. inserted in a gexp is ``file-like objects'', which make it easy to
  3711. add files to the store and to refer to them in
  3712. derivations and such (see @code{local-file} and @code{plain-file}
  3713. below.)
  3714. To illustrate the idea, here is an example of a gexp:
  3715. @example
  3716. (define build-exp
  3717. #~(begin
  3718. (mkdir #$output)
  3719. (chdir #$output)
  3720. (symlink (string-append #$coreutils "/bin/ls")
  3721. "list-files")))
  3722. @end example
  3723. This gexp can be passed to @code{gexp->derivation}; we obtain a
  3724. derivation that builds a directory containing exactly one symlink to
  3725. @file{/gnu/store/@dots{}-coreutils-8.22/bin/ls}:
  3726. @example
  3727. (gexp->derivation "the-thing" build-exp)
  3728. @end example
  3729. As one would expect, the @code{"/gnu/store/@dots{}-coreutils-8.22"} string is
  3730. substituted to the reference to the @var{coreutils} package in the
  3731. actual build code, and @var{coreutils} is automatically made an input to
  3732. the derivation. Likewise, @code{#$output} (equivalent to @code{(ungexp
  3733. output)}) is replaced by a string containing the directory name of the
  3734. output of the derivation.
  3735. @cindex cross compilation
  3736. In a cross-compilation context, it is useful to distinguish between
  3737. references to the @emph{native} build of a package---that can run on the
  3738. host---versus references to cross builds of a package. To that end, the
  3739. @code{#+} plays the same role as @code{#$}, but is a reference to a
  3740. native package build:
  3741. @example
  3742. (gexp->derivation "vi"
  3743. #~(begin
  3744. (mkdir #$output)
  3745. (system* (string-append #+coreutils "/bin/ln")
  3746. "-s"
  3747. (string-append #$emacs "/bin/emacs")
  3748. (string-append #$output "/bin/vi")))
  3749. #:target "mips64el-linux-gnu")
  3750. @end example
  3751. @noindent
  3752. In the example above, the native build of @var{coreutils} is used, so
  3753. that @command{ln} can actually run on the host; but then the
  3754. cross-compiled build of @var{emacs} is referenced.
  3755. @cindex imported modules, for gexps
  3756. @findex with-imported-modules
  3757. Another gexp feature is @dfn{imported modules}: sometimes you want to be
  3758. able to use certain Guile modules from the ``host environment'' in the
  3759. gexp, so those modules should be imported in the ``build environment''.
  3760. The @code{with-imported-modules} form allows you to express that:
  3761. @example
  3762. (let ((build (with-imported-modules '((guix build utils))
  3763. #~(begin
  3764. (use-modules (guix build utils))
  3765. (mkdir-p (string-append #$output "/bin"))))))
  3766. (gexp->derivation "empty-dir"
  3767. #~(begin
  3768. #$build
  3769. (display "success!\n")
  3770. #t)))
  3771. @end example
  3772. @noindent
  3773. In this example, the @code{(guix build utils)} module is automatically
  3774. pulled into the isolated build environment of our gexp, such that
  3775. @code{(use-modules (guix build utils))} works as expected.
  3776. @cindex module closure
  3777. @findex source-module-closure
  3778. Usually you want the @emph{closure} of the module to be imported---i.e.,
  3779. the module itself and all the modules it depends on---rather than just
  3780. the module; failing to do that, attempts to use the module will fail
  3781. because of missing dependent modules. The @code{source-module-closure}
  3782. procedure computes the closure of a module by looking at its source file
  3783. headers, which comes in handy in this case:
  3784. @example
  3785. (use-modules (guix modules)) ;for 'source-module-closure'
  3786. (with-imported-modules (source-module-closure
  3787. '((guix build utils)
  3788. (gnu build vm)))
  3789. (gexp->derivation "something-with-vms"
  3790. #~(begin
  3791. (use-modules (guix build utils)
  3792. (gnu build vm))
  3793. @dots{})))
  3794. @end example
  3795. The syntactic form to construct gexps is summarized below.
  3796. @deffn {Scheme Syntax} #~@var{exp}
  3797. @deffnx {Scheme Syntax} (gexp @var{exp})
  3798. Return a G-expression containing @var{exp}. @var{exp} may contain one
  3799. or more of the following forms:
  3800. @table @code
  3801. @item #$@var{obj}
  3802. @itemx (ungexp @var{obj})
  3803. Introduce a reference to @var{obj}. @var{obj} may have one of the
  3804. supported types, for example a package or a
  3805. derivation, in which case the @code{ungexp} form is replaced by its
  3806. output file name---e.g., @code{"/gnu/store/@dots{}-coreutils-8.22}.
  3807. If @var{obj} is a list, it is traversed and references to supported
  3808. objects are substituted similarly.
  3809. If @var{obj} is another gexp, its contents are inserted and its
  3810. dependencies are added to those of the containing gexp.
  3811. If @var{obj} is another kind of object, it is inserted as is.
  3812. @item #$@var{obj}:@var{output}
  3813. @itemx (ungexp @var{obj} @var{output})
  3814. This is like the form above, but referring explicitly to the
  3815. @var{output} of @var{obj}---this is useful when @var{obj} produces
  3816. multiple outputs (@pxref{Packages with Multiple Outputs}).
  3817. @item #+@var{obj}
  3818. @itemx #+@var{obj}:output
  3819. @itemx (ungexp-native @var{obj})
  3820. @itemx (ungexp-native @var{obj} @var{output})
  3821. Same as @code{ungexp}, but produces a reference to the @emph{native}
  3822. build of @var{obj} when used in a cross compilation context.
  3823. @item #$output[:@var{output}]
  3824. @itemx (ungexp output [@var{output}])
  3825. Insert a reference to derivation output @var{output}, or to the main
  3826. output when @var{output} is omitted.
  3827. This only makes sense for gexps passed to @code{gexp->derivation}.
  3828. @item #$@@@var{lst}
  3829. @itemx (ungexp-splicing @var{lst})
  3830. Like the above, but splices the contents of @var{lst} inside the
  3831. containing list.
  3832. @item #+@@@var{lst}
  3833. @itemx (ungexp-native-splicing @var{lst})
  3834. Like the above, but refers to native builds of the objects listed in
  3835. @var{lst}.
  3836. @end table
  3837. G-expressions created by @code{gexp} or @code{#~} are run-time objects
  3838. of the @code{gexp?} type (see below.)
  3839. @end deffn
  3840. @deffn {Scheme Syntax} with-imported-modules @var{modules} @var{body}@dots{}
  3841. Mark the gexps defined in @var{body}@dots{} as requiring @var{modules}
  3842. in their execution environment.
  3843. Each item in @var{modules} can be the name of a module, such as
  3844. @code{(guix build utils)}, or it can be a module name, followed by an
  3845. arrow, followed by a file-like object:
  3846. @example
  3847. `((guix build utils)
  3848. (guix gcrypt)
  3849. ((guix config) => ,(scheme-file "config.scm"
  3850. #~(define-module @dots{}))))
  3851. @end example
  3852. @noindent
  3853. In the example above, the first two modules are taken from the search
  3854. path, and the last one is created from the given file-like object.
  3855. This form has @emph{lexical} scope: it has an effect on the gexps
  3856. directly defined in @var{body}@dots{}, but not on those defined, say, in
  3857. procedures called from @var{body}@dots{}.
  3858. @end deffn
  3859. @deffn {Scheme Procedure} gexp? @var{obj}
  3860. Return @code{#t} if @var{obj} is a G-expression.
  3861. @end deffn
  3862. G-expressions are meant to be written to disk, either as code building
  3863. some derivation, or as plain files in the store. The monadic procedures
  3864. below allow you to do that (@pxref{The Store Monad}, for more
  3865. information about monads.)
  3866. @deffn {Monadic Procedure} gexp->derivation @var{name} @var{exp} @
  3867. [#:system (%current-system)] [#:target #f] [#:graft? #t] @
  3868. [#:hash #f] [#:hash-algo #f] @
  3869. [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
  3870. [#:module-path @var{%load-path}] @
  3871. [#:references-graphs #f] [#:allowed-references #f] @
  3872. [#:disallowed-references #f] @
  3873. [#:leaked-env-vars #f] @
  3874. [#:script-name (string-append @var{name} "-builder")] @
  3875. [#:local-build? #f] [#:substitutable? #t] [#:guile-for-build #f]
  3876. Return a derivation @var{name} that runs @var{exp} (a gexp) with
  3877. @var{guile-for-build} (a derivation) on @var{system}; @var{exp} is
  3878. stored in a file called @var{script-name}. When @var{target} is true,
  3879. it is used as the cross-compilation target triplet for packages referred
  3880. to by @var{exp}.
  3881. @var{modules} is deprecated in favor of @code{with-imported-modules}.
  3882. Its meaning is to
  3883. make @var{modules} available in the evaluation context of @var{exp};
  3884. @var{modules} is a list of names of Guile modules searched in
  3885. @var{module-path} to be copied in the store, compiled, and made available in
  3886. the load path during the execution of @var{exp}---e.g., @code{((guix
  3887. build utils) (guix build gnu-build-system))}.
  3888. @var{graft?} determines whether packages referred to by @var{exp} should be grafted when
  3889. applicable.
  3890. When @var{references-graphs} is true, it must be a list of tuples of one of the
  3891. following forms:
  3892. @example
  3893. (@var{file-name} @var{package})
  3894. (@var{file-name} @var{package} @var{output})
  3895. (@var{file-name} @var{derivation})
  3896. (@var{file-name} @var{derivation} @var{output})
  3897. (@var{file-name} @var{store-item})
  3898. @end example
  3899. The right-hand-side of each element of @var{references-graphs} is automatically made
  3900. an input of the build process of @var{exp}. In the build environment, each
  3901. @var{file-name} contains the reference graph of the corresponding item, in a simple
  3902. text format.
  3903. @var{allowed-references} must be either @code{#f} or a list of output names and packages.
  3904. In the latter case, the list denotes store items that the result is allowed to
  3905. refer to. Any reference to another store item will lead to a build error.
  3906. Similarly for @var{disallowed-references}, which can list items that must not be
  3907. referenced by the outputs.
  3908. The other arguments are as for @code{derivation} (@pxref{Derivations}).
  3909. @end deffn
  3910. @cindex file-like objects
  3911. The @code{local-file}, @code{plain-file}, @code{computed-file},
  3912. @code{program-file}, and @code{scheme-file} procedures below return
  3913. @dfn{file-like objects}. That is, when unquoted in a G-expression,
  3914. these objects lead to a file in the store. Consider this G-expression:
  3915. @example
  3916. #~(system* #$(file-append glibc "/sbin/nscd") "-f"
  3917. #$(local-file "/tmp/my-nscd.conf"))
  3918. @end example
  3919. The effect here is to ``intern'' @file{/tmp/my-nscd.conf} by copying it
  3920. to the store. Once expanded, for instance @i{via}
  3921. @code{gexp->derivation}, the G-expression refers to that copy under
  3922. @file{/gnu/store}; thus, modifying or removing the file in @file{/tmp}
  3923. does not have any effect on what the G-expression does.
  3924. @code{plain-file} can be used similarly; it differs in that the file
  3925. content is directly passed as a string.
  3926. @deffn {Scheme Procedure} local-file @var{file} [@var{name}] @
  3927. [#:recursive? #f] [#:select? (const #t)]
  3928. Return an object representing local file @var{file} to add to the store; this
  3929. object can be used in a gexp. If @var{file} is a relative file name, it is looked
  3930. up relative to the source file where this form appears. @var{file} will be added to
  3931. the store under @var{name}--by default the base name of @var{file}.
  3932. When @var{recursive?} is true, the contents of @var{file} are added recursively; if @var{file}
  3933. designates a flat file and @var{recursive?} is true, its contents are added, and its
  3934. permission bits are kept.
  3935. When @var{recursive?} is true, call @code{(@var{select?} @var{file}
  3936. @var{stat})} for each directory entry, where @var{file} is the entry's
  3937. absolute file name and @var{stat} is the result of @code{lstat}; exclude
  3938. entries for which @var{select?} does not return true.
  3939. This is the declarative counterpart of the @code{interned-file} monadic
  3940. procedure (@pxref{The Store Monad, @code{interned-file}}).
  3941. @end deffn
  3942. @deffn {Scheme Procedure} plain-file @var{name} @var{content}
  3943. Return an object representing a text file called @var{name} with the given
  3944. @var{content} (a string) to be added to the store.
  3945. This is the declarative counterpart of @code{text-file}.
  3946. @end deffn
  3947. @deffn {Scheme Procedure} computed-file @var{name} @var{gexp} @
  3948. [#:options '(#:local-build? #t)]
  3949. Return an object representing the store item @var{name}, a file or
  3950. directory computed by @var{gexp}. @var{options}
  3951. is a list of additional arguments to pass to @code{gexp->derivation}.
  3952. This is the declarative counterpart of @code{gexp->derivation}.
  3953. @end deffn
  3954. @deffn {Monadic Procedure} gexp->script @var{name} @var{exp}
  3955. Return an executable script @var{name} that runs @var{exp} using
  3956. @var{guile}, with @var{exp}'s imported modules in its search path.
  3957. The example below builds a script that simply invokes the @command{ls}
  3958. command:
  3959. @example
  3960. (use-modules (guix gexp) (gnu packages base))
  3961. (gexp->script "list-files"
  3962. #~(execl #$(file-append coreutils "/bin/ls")
  3963. "ls"))
  3964. @end example
  3965. When ``running'' it through the store (@pxref{The Store Monad,
  3966. @code{run-with-store}}), we obtain a derivation that produces an
  3967. executable file @file{/gnu/store/@dots{}-list-files} along these lines:
  3968. @example
  3969. #!/gnu/store/@dots{}-guile-2.0.11/bin/guile -ds
  3970. !#
  3971. (execl "/gnu/store/@dots{}-coreutils-8.22"/bin/ls" "ls")
  3972. @end example
  3973. @end deffn
  3974. @deffn {Scheme Procedure} program-file @var{name} @var{exp} @
  3975. [#:guile #f]
  3976. Return an object representing the executable store item @var{name} that
  3977. runs @var{gexp}. @var{guile} is the Guile package used to execute that
  3978. script.
  3979. This is the declarative counterpart of @code{gexp->script}.
  3980. @end deffn
  3981. @deffn {Monadic Procedure} gexp->file @var{name} @var{exp} @
  3982. [#:set-load-path? #t]
  3983. Return a derivation that builds a file @var{name} containing @var{exp}.
  3984. When @var{set-load-path?} is true, emit code in the resulting file to
  3985. set @code{%load-path} and @code{%load-compiled-path} to honor
  3986. @var{exp}'s imported modules.
  3987. The resulting file holds references to all the dependencies of @var{exp}
  3988. or a subset thereof.
  3989. @end deffn
  3990. @deffn {Scheme Procedure} scheme-file @var{name} @var{exp}
  3991. Return an object representing the Scheme file @var{name} that contains
  3992. @var{exp}.
  3993. This is the declarative counterpart of @code{gexp->file}.
  3994. @end deffn
  3995. @deffn {Monadic Procedure} text-file* @var{name} @var{text} @dots{}
  3996. Return as a monadic value a derivation that builds a text file
  3997. containing all of @var{text}. @var{text} may list, in addition to
  3998. strings, objects of any type that can be used in a gexp: packages,
  3999. derivations, local file objects, etc. The resulting store file holds
  4000. references to all these.
  4001. This variant should be preferred over @code{text-file} anytime the file
  4002. to create will reference items from the store. This is typically the
  4003. case when building a configuration file that embeds store file names,
  4004. like this:
  4005. @example
  4006. (define (profile.sh)
  4007. ;; Return the name of a shell script in the store that
  4008. ;; initializes the 'PATH' environment variable.
  4009. (text-file* "profile.sh"
  4010. "export PATH=" coreutils "/bin:"
  4011. grep "/bin:" sed "/bin\n"))
  4012. @end example
  4013. In this example, the resulting @file{/gnu/store/@dots{}-profile.sh} file
  4014. will reference @var{coreutils}, @var{grep}, and @var{sed}, thereby
  4015. preventing them from being garbage-collected during its lifetime.
  4016. @end deffn
  4017. @deffn {Scheme Procedure} mixed-text-file @var{name} @var{text} @dots{}
  4018. Return an object representing store file @var{name} containing
  4019. @var{text}. @var{text} is a sequence of strings and file-like objects,
  4020. as in:
  4021. @example
  4022. (mixed-text-file "profile"
  4023. "export PATH=" coreutils "/bin:" grep "/bin")
  4024. @end example
  4025. This is the declarative counterpart of @code{text-file*}.
  4026. @end deffn
  4027. @deffn {Scheme Procedure} file-append @var{obj} @var{suffix} @dots{}
  4028. Return a file-like object that expands to the concatenation of @var{obj}
  4029. and @var{suffix}, where @var{obj} is a lowerable object and each
  4030. @var{suffix} is a string.
  4031. As an example, consider this gexp:
  4032. @example
  4033. (gexp->script "run-uname"
  4034. #~(system* #$(file-append coreutils
  4035. "/bin/uname")))
  4036. @end example
  4037. The same effect could be achieved with:
  4038. @example
  4039. (gexp->script "run-uname"
  4040. #~(system* (string-append #$coreutils
  4041. "/bin/uname")))
  4042. @end example
  4043. There is one difference though: in the @code{file-append} case, the
  4044. resulting script contains the absolute file name as a string, whereas in
  4045. the second case, the resulting script contains a @code{(string-append
  4046. @dots{})} expression to construct the file name @emph{at run time}.
  4047. @end deffn
  4048. Of course, in addition to gexps embedded in ``host'' code, there are
  4049. also modules containing build tools. To make it clear that they are
  4050. meant to be used in the build stratum, these modules are kept in the
  4051. @code{(guix build @dots{})} name space.
  4052. @cindex lowering, of high-level objects in gexps
  4053. Internally, high-level objects are @dfn{lowered}, using their compiler,
  4054. to either derivations or store items. For instance, lowering a package
  4055. yields a derivation, and lowering a @code{plain-file} yields a store
  4056. item. This is achieved using the @code{lower-object} monadic procedure.
  4057. @deffn {Monadic Procedure} lower-object @var{obj} [@var{system}] @
  4058. [#:target #f]
  4059. Return as a value in @var{%store-monad} the derivation or store item
  4060. corresponding to @var{obj} for @var{system}, cross-compiling for
  4061. @var{target} if @var{target} is true. @var{obj} must be an object that
  4062. has an associated gexp compiler, such as a @code{<package>}.
  4063. @end deffn
  4064. @c *********************************************************************
  4065. @node Utilities
  4066. @chapter Utilities
  4067. This section describes Guix command-line utilities. Some of them are
  4068. primarily targeted at developers and users who write new package
  4069. definitions, while others are more generally useful. They complement
  4070. the Scheme programming interface of Guix in a convenient way.
  4071. @menu
  4072. * Invoking guix build:: Building packages from the command line.
  4073. * Invoking guix edit:: Editing package definitions.
  4074. * Invoking guix download:: Downloading a file and printing its hash.
  4075. * Invoking guix hash:: Computing the cryptographic hash of a file.
  4076. * Invoking guix import:: Importing package definitions.
  4077. * Invoking guix refresh:: Updating package definitions.
  4078. * Invoking guix lint:: Finding errors in package definitions.
  4079. * Invoking guix size:: Profiling disk usage.
  4080. * Invoking guix graph:: Visualizing the graph of packages.
  4081. * Invoking guix environment:: Setting up development environments.
  4082. * Invoking guix publish:: Sharing substitutes.
  4083. * Invoking guix challenge:: Challenging substitute servers.
  4084. * Invoking guix copy:: Copying to and from a remote store.
  4085. * Invoking guix container:: Process isolation.
  4086. * Invoking guix weather:: Assessing substitute availability.
  4087. @end menu
  4088. @node Invoking guix build
  4089. @section Invoking @command{guix build}
  4090. @cindex package building
  4091. @cindex @command{guix build}
  4092. The @command{guix build} command builds packages or derivations and
  4093. their dependencies, and prints the resulting store paths. Note that it
  4094. does not modify the user's profile---this is the job of the
  4095. @command{guix package} command (@pxref{Invoking guix package}). Thus,
  4096. it is mainly useful for distribution developers.
  4097. The general syntax is:
  4098. @example
  4099. guix build @var{options} @var{package-or-derivation}@dots{}
  4100. @end example
  4101. As an example, the following command builds the latest versions of Emacs
  4102. and of Guile, displays their build logs, and finally displays the
  4103. resulting directories:
  4104. @example
  4105. guix build emacs guile
  4106. @end example
  4107. Similarly, the following command builds all the available packages:
  4108. @example
  4109. guix build --quiet --keep-going \
  4110. `guix package -A | cut -f1,2 --output-delimiter=@@`
  4111. @end example
  4112. @var{package-or-derivation} may be either the name of a package found in
  4113. the software distribution such as @code{coreutils} or
  4114. @code{coreutils@@8.20}, or a derivation such as
  4115. @file{/gnu/store/@dots{}-coreutils-8.19.drv}. In the former case, a
  4116. package with the corresponding name (and optionally version) is searched
  4117. for among the GNU distribution modules (@pxref{Package Modules}).
  4118. Alternatively, the @code{--expression} option may be used to specify a
  4119. Scheme expression that evaluates to a package; this is useful when
  4120. disambiguating among several same-named packages or package variants is
  4121. needed.
  4122. There may be zero or more @var{options}. The available options are
  4123. described in the subsections below.
  4124. @menu
  4125. * Common Build Options:: Build options for most commands.
  4126. * Package Transformation Options:: Creating variants of packages.
  4127. * Additional Build Options:: Options specific to 'guix build'.
  4128. * Debugging Build Failures:: Real life packaging experience.
  4129. @end menu
  4130. @node Common Build Options
  4131. @subsection Common Build Options
  4132. A number of options that control the build process are common to
  4133. @command{guix build} and other commands that can spawn builds, such as
  4134. @command{guix package} or @command{guix archive}. These are the
  4135. following:
  4136. @table @code
  4137. @item --load-path=@var{directory}
  4138. @itemx -L @var{directory}
  4139. Add @var{directory} to the front of the package module search path
  4140. (@pxref{Package Modules}).
  4141. This allows users to define their own packages and make them visible to
  4142. the command-line tools.
  4143. @item --keep-failed
  4144. @itemx -K
  4145. Keep the build tree of failed builds. Thus, if a build fails, its build
  4146. tree is kept under @file{/tmp}, in a directory whose name is shown at
  4147. the end of the build log. This is useful when debugging build issues.
  4148. @xref{Debugging Build Failures}, for tips and tricks on how to debug
  4149. build issues.
  4150. @item --keep-going
  4151. @itemx -k
  4152. Keep going when some of the derivations fail to build; return only once
  4153. all the builds have either completed or failed.
  4154. The default behavior is to stop as soon as one of the specified
  4155. derivations has failed.
  4156. @item --dry-run
  4157. @itemx -n
  4158. Do not build the derivations.
  4159. @item --fallback
  4160. When substituting a pre-built binary fails, fall back to building
  4161. packages locally.
  4162. @item --substitute-urls=@var{urls}
  4163. @anchor{client-substitute-urls}
  4164. Consider @var{urls} the whitespace-separated list of substitute source
  4165. URLs, overriding the default list of URLs of @command{guix-daemon}
  4166. (@pxref{daemon-substitute-urls,, @command{guix-daemon} URLs}).
  4167. This means that substitutes may be downloaded from @var{urls}, provided
  4168. they are signed by a key authorized by the system administrator
  4169. (@pxref{Substitutes}).
  4170. When @var{urls} is the empty string, substitutes are effectively
  4171. disabled.
  4172. @item --no-substitutes
  4173. Do not use substitutes for build products. That is, always build things
  4174. locally instead of allowing downloads of pre-built binaries
  4175. (@pxref{Substitutes}).
  4176. @item --no-grafts
  4177. Do not ``graft'' packages. In practice, this means that package updates
  4178. available as grafts are not applied. @xref{Security Updates}, for more
  4179. information on grafts.
  4180. @item --rounds=@var{n}
  4181. Build each derivation @var{n} times in a row, and raise an error if
  4182. consecutive build results are not bit-for-bit identical.
  4183. This is a useful way to detect non-deterministic builds processes.
  4184. Non-deterministic build processes are a problem because they make it
  4185. practically impossible for users to @emph{verify} whether third-party
  4186. binaries are genuine. @xref{Invoking guix challenge}, for more.
  4187. Note that, currently, the differing build results are not kept around,
  4188. so you will have to manually investigate in case of an error---e.g., by
  4189. stashing one of the build results with @code{guix archive --export}
  4190. (@pxref{Invoking guix archive}), then rebuilding, and finally comparing
  4191. the two results.
  4192. @item --no-build-hook
  4193. Do not attempt to offload builds @i{via} the ``build hook'' of the daemon
  4194. (@pxref{Daemon Offload Setup}). That is, always build things locally
  4195. instead of offloading builds to remote machines.
  4196. @item --max-silent-time=@var{seconds}
  4197. When the build or substitution process remains silent for more than
  4198. @var{seconds}, terminate it and report a build failure.
  4199. By default, the daemon's setting is honored (@pxref{Invoking
  4200. guix-daemon, @code{--max-silent-time}}).
  4201. @item --timeout=@var{seconds}
  4202. Likewise, when the build or substitution process lasts for more than
  4203. @var{seconds}, terminate it and report a build failure.
  4204. By default, the daemon's setting is honored (@pxref{Invoking
  4205. guix-daemon, @code{--timeout}}).
  4206. @item --verbosity=@var{level}
  4207. Use the given verbosity level. @var{level} must be an integer between 0
  4208. and 5; higher means more verbose output. Setting a level of 4 or more
  4209. may be helpful when debugging setup issues with the build daemon.
  4210. @item --cores=@var{n}
  4211. @itemx -c @var{n}
  4212. Allow the use of up to @var{n} CPU cores for the build. The special
  4213. value @code{0} means to use as many CPU cores as available.
  4214. @item --max-jobs=@var{n}
  4215. @itemx -M @var{n}
  4216. Allow at most @var{n} build jobs in parallel. @xref{Invoking
  4217. guix-daemon, @code{--max-jobs}}, for details about this option and the
  4218. equivalent @command{guix-daemon} option.
  4219. @end table
  4220. Behind the scenes, @command{guix build} is essentially an interface to
  4221. the @code{package-derivation} procedure of the @code{(guix packages)}
  4222. module, and to the @code{build-derivations} procedure of the @code{(guix
  4223. derivations)} module.
  4224. In addition to options explicitly passed on the command line,
  4225. @command{guix build} and other @command{guix} commands that support
  4226. building honor the @code{GUIX_BUILD_OPTIONS} environment variable.
  4227. @defvr {Environment Variable} GUIX_BUILD_OPTIONS
  4228. Users can define this variable to a list of command line options that
  4229. will automatically be used by @command{guix build} and other
  4230. @command{guix} commands that can perform builds, as in the example
  4231. below:
  4232. @example
  4233. $ export GUIX_BUILD_OPTIONS="--no-substitutes -c 2 -L /foo/bar"
  4234. @end example
  4235. These options are parsed independently, and the result is appended to
  4236. the parsed command-line options.
  4237. @end defvr
  4238. @node Package Transformation Options
  4239. @subsection Package Transformation Options
  4240. @cindex package variants
  4241. Another set of command-line options supported by @command{guix build}
  4242. and also @command{guix package} are @dfn{package transformation
  4243. options}. These are options that make it possible to define @dfn{package
  4244. variants}---for instance, packages built from different source code.
  4245. This is a convenient way to create customized packages on the fly
  4246. without having to type in the definitions of package variants
  4247. (@pxref{Defining Packages}).
  4248. @table @code
  4249. @item --with-source=@var{source}
  4250. Use @var{source} as the source of the corresponding package.
  4251. @var{source} must be a file name or a URL, as for @command{guix
  4252. download} (@pxref{Invoking guix download}).
  4253. The ``corresponding package'' is taken to be the one specified on the
  4254. command line the name of which matches the base of @var{source}---e.g.,
  4255. if @var{source} is @code{/src/guile-2.0.10.tar.gz}, the corresponding
  4256. package is @code{guile}. Likewise, the version string is inferred from
  4257. @var{source}; in the previous example, it is @code{2.0.10}.
  4258. This option allows users to try out versions of packages other than the
  4259. one provided by the distribution. The example below downloads
  4260. @file{ed-1.7.tar.gz} from a GNU mirror and uses that as the source for
  4261. the @code{ed} package:
  4262. @example
  4263. guix build ed --with-source=mirror://gnu/ed/ed-1.7.tar.gz
  4264. @end example
  4265. As a developer, @code{--with-source} makes it easy to test release
  4266. candidates:
  4267. @example
  4268. guix build guile --with-source=../guile-2.0.9.219-e1bb7.tar.xz
  4269. @end example
  4270. @dots{} or to build from a checkout in a pristine environment:
  4271. @example
  4272. $ git clone git://git.sv.gnu.org/guix.git
  4273. $ guix build guix --with-source=./guix
  4274. @end example
  4275. @item --with-input=@var{package}=@var{replacement}
  4276. Replace dependency on @var{package} by a dependency on
  4277. @var{replacement}. @var{package} must be a package name, and
  4278. @var{replacement} must be a package specification such as @code{guile}
  4279. or @code{guile@@1.8}.
  4280. For instance, the following command builds Guix, but replaces its
  4281. dependency on the current stable version of Guile with a dependency on
  4282. the legacy version of Guile, @code{guile@@2.0}:
  4283. @example
  4284. guix build --with-input=guile=guile@@2.0 guix
  4285. @end example
  4286. This is a recursive, deep replacement. So in this example, both
  4287. @code{guix} and its dependency @code{guile-json} (which also depends on
  4288. @code{guile}) get rebuilt against @code{guile@@2.0}.
  4289. This is implemented using the @code{package-input-rewriting} Scheme
  4290. procedure (@pxref{Defining Packages, @code{package-input-rewriting}}).
  4291. @item --with-graft=@var{package}=@var{replacement}
  4292. This is similar to @code{--with-input} but with an important difference:
  4293. instead of rebuilding the whole dependency chain, @var{replacement} is
  4294. built and then @dfn{grafted} onto the binaries that were initially
  4295. referring to @var{package}. @xref{Security Updates}, for more
  4296. information on grafts.
  4297. For example, the command below grafts version 3.5.4 of GnuTLS onto Wget
  4298. and all its dependencies, replacing references to the version of GnuTLS
  4299. they currently refer to:
  4300. @example
  4301. guix build --with-graft=gnutls=gnutls@@3.5.4 wget
  4302. @end example
  4303. This has the advantage of being much faster than rebuilding everything.
  4304. But there is a caveat: it works if and only if @var{package} and
  4305. @var{replacement} are strictly compatible---for example, if they provide
  4306. a library, the application binary interface (ABI) of those libraries
  4307. must be compatible. If @var{replacement} is somehow incompatible with
  4308. @var{package}, then the resulting package may be unusable. Use with
  4309. care!
  4310. @end table
  4311. @node Additional Build Options
  4312. @subsection Additional Build Options
  4313. The command-line options presented below are specific to @command{guix
  4314. build}.
  4315. @table @code
  4316. @item --quiet
  4317. @itemx -q
  4318. Build quietly, without displaying the build log. Upon completion, the
  4319. build log is kept in @file{/var} (or similar) and can always be
  4320. retrieved using the @option{--log-file} option.
  4321. @item --file=@var{file}
  4322. @itemx -f @var{file}
  4323. Build the package or derivation that the code within @var{file}
  4324. evaluates to.
  4325. As an example, @var{file} might contain a package definition like this
  4326. (@pxref{Defining Packages}):
  4327. @example
  4328. @verbatiminclude package-hello.scm
  4329. @end example
  4330. @item --expression=@var{expr}
  4331. @itemx -e @var{expr}
  4332. Build the package or derivation @var{expr} evaluates to.
  4333. For example, @var{expr} may be @code{(@@ (gnu packages guile)
  4334. guile-1.8)}, which unambiguously designates this specific variant of
  4335. version 1.8 of Guile.
  4336. Alternatively, @var{expr} may be a G-expression, in which case it is used
  4337. as a build program passed to @code{gexp->derivation}
  4338. (@pxref{G-Expressions}).
  4339. Lastly, @var{expr} may refer to a zero-argument monadic procedure
  4340. (@pxref{The Store Monad}). The procedure must return a derivation as a
  4341. monadic value, which is then passed through @code{run-with-store}.
  4342. @item --source
  4343. @itemx -S
  4344. Build the source derivations of the packages, rather than the packages
  4345. themselves.
  4346. For instance, @code{guix build -S gcc} returns something like
  4347. @file{/gnu/store/@dots{}-gcc-4.7.2.tar.bz2}, which is the GCC
  4348. source tarball.
  4349. The returned source tarball is the result of applying any patches and
  4350. code snippets specified in the package @code{origin} (@pxref{Defining
  4351. Packages}).
  4352. @item --sources
  4353. Fetch and return the source of @var{package-or-derivation} and all their
  4354. dependencies, recursively. This is a handy way to obtain a local copy
  4355. of all the source code needed to build @var{packages}, allowing you to
  4356. eventually build them even without network access. It is an extension
  4357. of the @code{--source} option and can accept one of the following
  4358. optional argument values:
  4359. @table @code
  4360. @item package
  4361. This value causes the @code{--sources} option to behave in the same way
  4362. as the @code{--source} option.
  4363. @item all
  4364. Build the source derivations of all packages, including any source that
  4365. might be listed as @code{inputs}. This is the default value.
  4366. @example
  4367. $ guix build --sources tzdata
  4368. The following derivations will be built:
  4369. /gnu/store/@dots{}-tzdata2015b.tar.gz.drv
  4370. /gnu/store/@dots{}-tzcode2015b.tar.gz.drv
  4371. @end example
  4372. @item transitive
  4373. Build the source derivations of all packages, as well of all transitive
  4374. inputs to the packages. This can be used e.g. to
  4375. prefetch package source for later offline building.
  4376. @example
  4377. $ guix build --sources=transitive tzdata
  4378. The following derivations will be built:
  4379. /gnu/store/@dots{}-tzcode2015b.tar.gz.drv
  4380. /gnu/store/@dots{}-findutils-4.4.2.tar.xz.drv
  4381. /gnu/store/@dots{}-grep-2.21.tar.xz.drv
  4382. /gnu/store/@dots{}-coreutils-8.23.tar.xz.drv
  4383. /gnu/store/@dots{}-make-4.1.tar.xz.drv
  4384. /gnu/store/@dots{}-bash-4.3.tar.xz.drv
  4385. @dots{}
  4386. @end example
  4387. @end table
  4388. @item --system=@var{system}
  4389. @itemx -s @var{system}
  4390. Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
  4391. the system type of the build host.
  4392. An example use of this is on Linux-based systems, which can emulate
  4393. different personalities. For instance, passing
  4394. @code{--system=i686-linux} on an @code{x86_64-linux} system allows users
  4395. to build packages in a complete 32-bit environment.
  4396. @item --target=@var{triplet}
  4397. @cindex cross-compilation
  4398. Cross-build for @var{triplet}, which must be a valid GNU triplet, such
  4399. as @code{"mips64el-linux-gnu"} (@pxref{Specifying target triplets, GNU
  4400. configuration triplets,, autoconf, Autoconf}).
  4401. @anchor{build-check}
  4402. @item --check
  4403. @cindex determinism, checking
  4404. @cindex reproducibility, checking
  4405. Rebuild @var{package-or-derivation}, which are already available in the
  4406. store, and raise an error if the build results are not bit-for-bit
  4407. identical.
  4408. This mechanism allows you to check whether previously installed
  4409. substitutes are genuine (@pxref{Substitutes}), or whether the build result
  4410. of a package is deterministic. @xref{Invoking guix challenge}, for more
  4411. background information and tools.
  4412. When used in conjunction with @option{--keep-failed}, the differing
  4413. output is kept in the store, under @file{/gnu/store/@dots{}-check}.
  4414. This makes it easy to look for differences between the two results.
  4415. @item --repair
  4416. @cindex repairing store items
  4417. @cindex corruption, recovering from
  4418. Attempt to repair the specified store items, if they are corrupt, by
  4419. re-downloading or rebuilding them.
  4420. This operation is not atomic and thus restricted to @code{root}.
  4421. @item --derivations
  4422. @itemx -d
  4423. Return the derivation paths, not the output paths, of the given
  4424. packages.
  4425. @item --root=@var{file}
  4426. @itemx -r @var{file}
  4427. Make @var{file} a symlink to the result, and register it as a garbage
  4428. collector root.
  4429. @item --log-file
  4430. Return the build log file names or URLs for the given
  4431. @var{package-or-derivation}, or raise an error if build logs are
  4432. missing.
  4433. This works regardless of how packages or derivations are specified. For
  4434. instance, the following invocations are equivalent:
  4435. @example
  4436. guix build --log-file `guix build -d guile`
  4437. guix build --log-file `guix build guile`
  4438. guix build --log-file guile
  4439. guix build --log-file -e '(@@ (gnu packages guile) guile-2.0)'
  4440. @end example
  4441. If a log is unavailable locally, and unless @code{--no-substitutes} is
  4442. passed, the command looks for a corresponding log on one of the
  4443. substitute servers (as specified with @code{--substitute-urls}.)
  4444. So for instance, imagine you want to see the build log of GDB on MIPS,
  4445. but you are actually on an @code{x86_64} machine:
  4446. @example
  4447. $ guix build --log-file gdb -s mips64el-linux
  4448. https://hydra.gnu.org/log/@dots{}-gdb-7.10
  4449. @end example
  4450. You can freely access a huge library of build logs!
  4451. @end table
  4452. @node Debugging Build Failures
  4453. @subsection Debugging Build Failures
  4454. @cindex build failures, debugging
  4455. When defining a new package (@pxref{Defining Packages}), you will
  4456. probably find yourself spending some time debugging and tweaking the
  4457. build until it succeeds. To do that, you need to operate the build
  4458. commands yourself in an environment as close as possible to the one the
  4459. build daemon uses.
  4460. To that end, the first thing to do is to use the @option{--keep-failed}
  4461. or @option{-K} option of @command{guix build}, which will keep the
  4462. failed build tree in @file{/tmp} or whatever directory you specified as
  4463. @code{TMPDIR} (@pxref{Invoking guix build, @code{--keep-failed}}).
  4464. From there on, you can @command{cd} to the failed build tree and source
  4465. the @file{environment-variables} file, which contains all the
  4466. environment variable definitions that were in place when the build
  4467. failed. So let's say you're debugging a build failure in package
  4468. @code{foo}; a typical session would look like this:
  4469. @example
  4470. $ guix build foo -K
  4471. @dots{} @i{build fails}
  4472. $ cd /tmp/guix-build-foo.drv-0
  4473. $ source ./environment-variables
  4474. $ cd foo-1.2
  4475. @end example
  4476. Now, you can invoke commands as if you were the daemon (almost) and
  4477. troubleshoot your build process.
  4478. Sometimes it happens that, for example, a package's tests pass when you
  4479. run them manually but they fail when the daemon runs them. This can
  4480. happen because the daemon runs builds in containers where, unlike in our
  4481. environment above, network access is missing, @file{/bin/sh} does not
  4482. exist, etc. (@pxref{Build Environment Setup}).
  4483. In such cases, you may need to run inspect the build process from within
  4484. a container similar to the one the build daemon creates:
  4485. @example
  4486. $ guix build -K foo
  4487. @dots{}
  4488. $ cd /tmp/guix-build-foo.drv-0
  4489. $ guix environment --no-grafts -C foo --ad-hoc strace gdb
  4490. [env]# source ./environment-variables
  4491. [env]# cd foo-1.2
  4492. @end example
  4493. Here, @command{guix environment -C} creates a container and spawns a new
  4494. shell in it (@pxref{Invoking guix environment}). The @command{--ad-hoc
  4495. strace gdb} part adds the @command{strace} and @command{gdb} commands to
  4496. the container, which would may find handy while debugging. The
  4497. @option{--no-grafts} option makes sure we get the exact same
  4498. environment, with ungrafted packages (@pxref{Security Updates}, for more
  4499. info on grafts).
  4500. To get closer to a container like that used by the build daemon, we can
  4501. remove @file{/bin/sh}:
  4502. @example
  4503. [env]# rm /bin/sh
  4504. @end example
  4505. (Don't worry, this is harmless: this is all happening in the throw-away
  4506. container created by @command{guix environment}.)
  4507. The @command{strace} command is probably not in the search path, but we
  4508. can run:
  4509. @example
  4510. [env]# $GUIX_ENVIRONMENT/bin/strace -f -o log make check
  4511. @end example
  4512. In this way, not only you will have reproduced the environment variables
  4513. the daemon uses, you will also be running the build process in a container
  4514. similar to the one the daemon uses.
  4515. @node Invoking guix edit
  4516. @section Invoking @command{guix edit}
  4517. @cindex @command{guix edit}
  4518. @cindex package definition, editing
  4519. So many packages, so many source files! The @command{guix edit} command
  4520. facilitates the life of users and packagers by pointing their editor at
  4521. the source file containing the definition of the specified packages.
  4522. For instance:
  4523. @example
  4524. guix edit gcc@@4.9 vim
  4525. @end example
  4526. @noindent
  4527. launches the program specified in the @code{VISUAL} or in the
  4528. @code{EDITOR} environment variable to view the recipe of GCC@tie{}4.9.3
  4529. and that of Vim.
  4530. If you are using a Guix Git checkout (@pxref{Building from Git}), or
  4531. have created your own packages on @code{GUIX_PACKAGE_PATH}
  4532. (@pxref{Defining Packages}), you will be able to edit the package
  4533. recipes. Otherwise, you will be able to examine the read-only recipes
  4534. for packages currently in the store.
  4535. @node Invoking guix download
  4536. @section Invoking @command{guix download}
  4537. @cindex @command{guix download}
  4538. @cindex downloading package sources
  4539. When writing a package definition, developers typically need to download
  4540. a source tarball, compute its SHA256 hash, and write that
  4541. hash in the package definition (@pxref{Defining Packages}). The
  4542. @command{guix download} tool helps with this task: it downloads a file
  4543. from the given URI, adds it to the store, and prints both its file name
  4544. in the store and its SHA256 hash.
  4545. The fact that the downloaded file is added to the store saves bandwidth:
  4546. when the developer eventually tries to build the newly defined package
  4547. with @command{guix build}, the source tarball will not have to be
  4548. downloaded again because it is already in the store. It is also a
  4549. convenient way to temporarily stash files, which may be deleted
  4550. eventually (@pxref{Invoking guix gc}).
  4551. The @command{guix download} command supports the same URIs as used in
  4552. package definitions. In particular, it supports @code{mirror://} URIs.
  4553. @code{https} URIs (HTTP over TLS) are supported @emph{provided} the
  4554. Guile bindings for GnuTLS are available in the user's environment; when
  4555. they are not available, an error is raised. @xref{Guile Preparations,
  4556. how to install the GnuTLS bindings for Guile,, gnutls-guile,
  4557. GnuTLS-Guile}, for more information.
  4558. @command{guix download} verifies HTTPS server certificates by loading
  4559. the certificates of X.509 authorities from the directory pointed to by
  4560. the @code{SSL_CERT_DIR} environment variable (@pxref{X.509
  4561. Certificates}), unless @option{--no-check-certificate} is used.
  4562. The following options are available:
  4563. @table @code
  4564. @item --format=@var{fmt}
  4565. @itemx -f @var{fmt}
  4566. Write the hash in the format specified by @var{fmt}. For more
  4567. information on the valid values for @var{fmt}, @pxref{Invoking guix hash}.
  4568. @item --no-check-certificate
  4569. Do not validate the X.509 certificates of HTTPS servers.
  4570. When using this option, you have @emph{absolutely no guarantee} that you
  4571. are communicating with the authentic server responsible for the given
  4572. URL, which makes you vulnerable to ``man-in-the-middle'' attacks.
  4573. @item --output=@var{file}
  4574. @itemx -o @var{file}
  4575. Save the downloaded file to @var{file} instead of adding it to the
  4576. store.
  4577. @end table
  4578. @node Invoking guix hash
  4579. @section Invoking @command{guix hash}
  4580. @cindex @command{guix hash}
  4581. The @command{guix hash} command computes the SHA256 hash of a file.
  4582. It is primarily a convenience tool for anyone contributing to the
  4583. distribution: it computes the cryptographic hash of a file, which can be
  4584. used in the definition of a package (@pxref{Defining Packages}).
  4585. The general syntax is:
  4586. @example
  4587. guix hash @var{option} @var{file}
  4588. @end example
  4589. When @var{file} is @code{-} (a hyphen), @command{guix hash} computes the
  4590. hash of data read from standard input. @command{guix hash} has the
  4591. following options:
  4592. @table @code
  4593. @item --format=@var{fmt}
  4594. @itemx -f @var{fmt}
  4595. Write the hash in the format specified by @var{fmt}.
  4596. Supported formats: @code{nix-base32}, @code{base32}, @code{base16}
  4597. (@code{hex} and @code{hexadecimal} can be used as well).
  4598. If the @option{--format} option is not specified, @command{guix hash}
  4599. will output the hash in @code{nix-base32}. This representation is used
  4600. in the definitions of packages.
  4601. @item --recursive
  4602. @itemx -r
  4603. Compute the hash on @var{file} recursively.
  4604. In this case, the hash is computed on an archive containing @var{file},
  4605. including its children if it is a directory. Some of the metadata of
  4606. @var{file} is part of the archive; for instance, when @var{file} is a
  4607. regular file, the hash is different depending on whether @var{file} is
  4608. executable or not. Metadata such as time stamps has no impact on the
  4609. hash (@pxref{Invoking guix archive}).
  4610. @c FIXME: Replace xref above with xref to an ``Archive'' section when
  4611. @c it exists.
  4612. @item --exclude-vcs
  4613. @itemx -x
  4614. When combined with @option{--recursive}, exclude version control system
  4615. directories (@file{.bzr}, @file{.git}, @file{.hg}, etc.)
  4616. @vindex git-fetch
  4617. As an example, here is how you would compute the hash of a Git checkout,
  4618. which is useful when using the @code{git-fetch} method (@pxref{origin
  4619. Reference}):
  4620. @example
  4621. $ git clone http://example.org/foo.git
  4622. $ cd foo
  4623. $ guix hash -rx .
  4624. @end example
  4625. @end table
  4626. @node Invoking guix import
  4627. @section Invoking @command{guix import}
  4628. @cindex importing packages
  4629. @cindex package import
  4630. @cindex package conversion
  4631. @cindex Invoking @command{guix import}
  4632. The @command{guix import} command is useful for people who would like to
  4633. add a package to the distribution with as little work as
  4634. possible---a legitimate demand. The command knows of a few
  4635. repositories from which it can ``import'' package metadata. The result
  4636. is a package definition, or a template thereof, in the format we know
  4637. (@pxref{Defining Packages}).
  4638. The general syntax is:
  4639. @example
  4640. guix import @var{importer} @var{options}@dots{}
  4641. @end example
  4642. @var{importer} specifies the source from which to import package
  4643. metadata, and @var{options} specifies a package identifier and other
  4644. options specific to @var{importer}. Currently, the available
  4645. ``importers'' are:
  4646. @table @code
  4647. @item gnu
  4648. Import metadata for the given GNU package. This provides a template
  4649. for the latest version of that GNU package, including the hash of its
  4650. source tarball, and its canonical synopsis and description.
  4651. Additional information such as the package dependencies and its
  4652. license needs to be figured out manually.
  4653. For example, the following command returns a package definition for
  4654. GNU@tie{}Hello:
  4655. @example
  4656. guix import gnu hello
  4657. @end example
  4658. Specific command-line options are:
  4659. @table @code
  4660. @item --key-download=@var{policy}
  4661. As for @code{guix refresh}, specify the policy to handle missing OpenPGP
  4662. keys when verifying the package signature. @xref{Invoking guix
  4663. refresh, @code{--key-download}}.
  4664. @end table
  4665. @item pypi
  4666. @cindex pypi
  4667. Import metadata from the @uref{https://pypi.python.org/, Python Package
  4668. Index}@footnote{This functionality requires Guile-JSON to be installed.
  4669. @xref{Requirements}.}. Information is taken from the JSON-formatted
  4670. description available at @code{pypi.python.org} and usually includes all
  4671. the relevant information, including package dependencies. For maximum
  4672. efficiency, it is recommended to install the @command{unzip} utility, so
  4673. that the importer can unzip Python wheels and gather data from them.
  4674. The command below imports metadata for the @code{itsdangerous} Python
  4675. package:
  4676. @example
  4677. guix import pypi itsdangerous
  4678. @end example
  4679. @item gem
  4680. @cindex gem
  4681. Import metadata from @uref{https://rubygems.org/,
  4682. RubyGems}@footnote{This functionality requires Guile-JSON to be
  4683. installed. @xref{Requirements}.}. Information is taken from the
  4684. JSON-formatted description available at @code{rubygems.org} and includes
  4685. most relevant information, including runtime dependencies. There are
  4686. some caveats, however. The metadata doesn't distinguish between
  4687. synopses and descriptions, so the same string is used for both fields.
  4688. Additionally, the details of non-Ruby dependencies required to build
  4689. native extensions is unavailable and left as an exercise to the
  4690. packager.
  4691. The command below imports metadata for the @code{rails} Ruby package:
  4692. @example
  4693. guix import gem rails
  4694. @end example
  4695. @item cpan
  4696. @cindex CPAN
  4697. Import metadata from @uref{https://www.metacpan.org/, MetaCPAN}@footnote{This
  4698. functionality requires Guile-JSON to be installed.
  4699. @xref{Requirements}.}.
  4700. Information is taken from the JSON-formatted metadata provided through
  4701. @uref{https://api.metacpan.org/, MetaCPAN's API} and includes most
  4702. relevant information, such as module dependencies. License information
  4703. should be checked closely. If Perl is available in the store, then the
  4704. @code{corelist} utility will be used to filter core modules out of the
  4705. list of dependencies.
  4706. The command command below imports metadata for the @code{Acme::Boolean}
  4707. Perl module:
  4708. @example
  4709. guix import cpan Acme::Boolean
  4710. @end example
  4711. @item cran
  4712. @cindex CRAN
  4713. @cindex Bioconductor
  4714. Import metadata from @uref{http://cran.r-project.org/, CRAN}, the
  4715. central repository for the @uref{http://r-project.org, GNU@tie{}R
  4716. statistical and graphical environment}.
  4717. Information is extracted from the @code{DESCRIPTION} file of the package.
  4718. The command command below imports metadata for the @code{Cairo}
  4719. R package:
  4720. @example
  4721. guix import cran Cairo
  4722. @end example
  4723. When @code{--recursive} is added, the importer will traverse the
  4724. dependency graph of the given upstream package recursively and generate
  4725. package expressions for all those packages that are not yet in Guix.
  4726. When @code{--archive=bioconductor} is added, metadata is imported from
  4727. @uref{http://www.bioconductor.org/, Bioconductor}, a repository of R
  4728. packages for for the analysis and comprehension of high-throughput
  4729. genomic data in bioinformatics.
  4730. Information is extracted from the @code{DESCRIPTION} file of a package
  4731. published on the web interface of the Bioconductor SVN repository.
  4732. The command below imports metadata for the @code{GenomicRanges}
  4733. R package:
  4734. @example
  4735. guix import cran --archive=bioconductor GenomicRanges
  4736. @end example
  4737. @item texlive
  4738. @cindex TeX Live
  4739. @cindex CTAN
  4740. Import metadata from @uref{http://www.ctan.org/, CTAN}, the
  4741. comprehensive TeX archive network for TeX packages that are part of the
  4742. @uref{https://www.tug.org/texlive/, TeX Live distribution}.
  4743. Information about the package is obtained through the XML API provided
  4744. by CTAN, while the source code is downloaded from the SVN repository of
  4745. the Tex Live project. This is done because the CTAN does not keep
  4746. versioned archives.
  4747. The command command below imports metadata for the @code{fontspec}
  4748. TeX package:
  4749. @example
  4750. guix import texlive fontspec
  4751. @end example
  4752. When @code{--archive=DIRECTORY} is added, the source code is downloaded
  4753. not from the @file{latex} sub-directory of the @file{texmf-dist/source}
  4754. tree in the TeX Live SVN repository, but from the specified sibling
  4755. directory under the same root.
  4756. The command below imports metadata for the @code{ifxetex} package from
  4757. CTAN while fetching the sources from the directory
  4758. @file{texmf/source/generic}:
  4759. @example
  4760. guix import texlive --archive=generic ifxetex
  4761. @end example
  4762. @item json
  4763. @cindex JSON, import
  4764. Import package metadata from a local JSON file@footnote{This
  4765. functionality requires Guile-JSON to be installed.
  4766. @xref{Requirements}.}. Consider the following example package
  4767. definition in JSON format:
  4768. @example
  4769. @{
  4770. "name": "hello",
  4771. "version": "2.10",
  4772. "source": "mirror://gnu/hello/hello-2.10.tar.gz",
  4773. "build-system": "gnu",
  4774. "home-page": "https://www.gnu.org/software/hello/",
  4775. "synopsis": "Hello, GNU world: An example GNU package",
  4776. "description": "GNU Hello prints a greeting.",
  4777. "license": "GPL-3.0+",
  4778. "native-inputs": ["gcc@@6"]
  4779. @}
  4780. @end example
  4781. The field names are the same as for the @code{<package>} record
  4782. (@xref{Defining Packages}). References to other packages are provided
  4783. as JSON lists of quoted package specification strings such as
  4784. @code{guile} or @code{guile@@2.0}.
  4785. The importer also supports a more explicit source definition using the
  4786. common fields for @code{<origin>} records:
  4787. @example
  4788. @{
  4789. @dots{}
  4790. "source": @{
  4791. "method": "url-fetch",
  4792. "uri": "mirror://gnu/hello/hello-2.10.tar.gz",
  4793. "sha256": @{
  4794. "base32": "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"
  4795. @}
  4796. @}
  4797. @dots{}
  4798. @}
  4799. @end example
  4800. The command below reads metadata from the JSON file @code{hello.json}
  4801. and outputs a package expression:
  4802. @example
  4803. guix import json hello.json
  4804. @end example
  4805. @item nix
  4806. Import metadata from a local copy of the source of the
  4807. @uref{http://nixos.org/nixpkgs/, Nixpkgs distribution}@footnote{This
  4808. relies on the @command{nix-instantiate} command of
  4809. @uref{http://nixos.org/nix/, Nix}.}. Package definitions in Nixpkgs are
  4810. typically written in a mixture of Nix-language and Bash code. This
  4811. command only imports the high-level package structure that is written in
  4812. the Nix language. It normally includes all the basic fields of a
  4813. package definition.
  4814. When importing a GNU package, the synopsis and descriptions are replaced
  4815. by their canonical upstream variant.
  4816. Usually, you will first need to do:
  4817. @example
  4818. export NIX_REMOTE=daemon
  4819. @end example
  4820. @noindent
  4821. so that @command{nix-instantiate} does not try to open the Nix database.
  4822. As an example, the command below imports the package definition of
  4823. LibreOffice (more precisely, it imports the definition of the package
  4824. bound to the @code{libreoffice} top-level attribute):
  4825. @example
  4826. guix import nix ~/path/to/nixpkgs libreoffice
  4827. @end example
  4828. @item hackage
  4829. @cindex hackage
  4830. Import metadata from the Haskell community's central package archive
  4831. @uref{https://hackage.haskell.org/, Hackage}. Information is taken from
  4832. Cabal files and includes all the relevant information, including package
  4833. dependencies.
  4834. Specific command-line options are:
  4835. @table @code
  4836. @item --stdin
  4837. @itemx -s
  4838. Read a Cabal file from standard input.
  4839. @item --no-test-dependencies
  4840. @itemx -t
  4841. Do not include dependencies required only by the test suites.
  4842. @item --cabal-environment=@var{alist}
  4843. @itemx -e @var{alist}
  4844. @var{alist} is a Scheme alist defining the environment in which the
  4845. Cabal conditionals are evaluated. The accepted keys are: @code{os},
  4846. @code{arch}, @code{impl} and a string representing the name of a flag.
  4847. The value associated with a flag has to be either the symbol
  4848. @code{true} or @code{false}. The value associated with other keys
  4849. has to conform to the Cabal file format definition. The default value
  4850. associated with the keys @code{os}, @code{arch} and @code{impl} is
  4851. @samp{linux}, @samp{x86_64} and @samp{ghc}, respectively.
  4852. @end table
  4853. The command below imports metadata for the latest version of the
  4854. @code{HTTP} Haskell package without including test dependencies and
  4855. specifying the value of the flag @samp{network-uri} as @code{false}:
  4856. @example
  4857. guix import hackage -t -e "'((\"network-uri\" . false))" HTTP
  4858. @end example
  4859. A specific package version may optionally be specified by following the
  4860. package name by an at-sign and a version number as in the following example:
  4861. @example
  4862. guix import hackage mtl@@2.1.3.1
  4863. @end example
  4864. @item stackage
  4865. @cindex stackage
  4866. The @code{stackage} importer is a wrapper around the @code{hackage} one.
  4867. It takes a package name, looks up the package version included in a
  4868. long-term support (LTS) @uref{https://www.stackage.org, Stackage}
  4869. release and uses the @code{hackage} importer to retrieve its metadata.
  4870. Note that it is up to you to select an LTS release compatible with the
  4871. GHC compiler used by Guix.
  4872. Specific command-line options are:
  4873. @table @code
  4874. @item --no-test-dependencies
  4875. @itemx -t
  4876. Do not include dependencies required only by the test suites.
  4877. @item --lts-version=@var{version}
  4878. @itemx -r @var{version}
  4879. @var{version} is the desired LTS release version. If omitted the latest
  4880. release is used.
  4881. @end table
  4882. The command below imports metadata for the @code{HTTP} Haskell package
  4883. included in the LTS Stackage release version 7.18:
  4884. @example
  4885. guix import stackage --lts-version=7.18 HTTP
  4886. @end example
  4887. @item elpa
  4888. @cindex elpa
  4889. Import metadata from an Emacs Lisp Package Archive (ELPA) package
  4890. repository (@pxref{Packages,,, emacs, The GNU Emacs Manual}).
  4891. Specific command-line options are:
  4892. @table @code
  4893. @item --archive=@var{repo}
  4894. @itemx -a @var{repo}
  4895. @var{repo} identifies the archive repository from which to retrieve the
  4896. information. Currently the supported repositories and their identifiers
  4897. are:
  4898. @itemize -
  4899. @item
  4900. @uref{http://elpa.gnu.org/packages, GNU}, selected by the @code{gnu}
  4901. identifier. This is the default.
  4902. Packages from @code{elpa.gnu.org} are signed with one of the keys
  4903. contained in the GnuPG keyring at
  4904. @file{share/emacs/25.1/etc/package-keyring.gpg} (or similar) in the
  4905. @code{emacs} package (@pxref{Package Installation, ELPA package
  4906. signatures,, emacs, The GNU Emacs Manual}).
  4907. @item
  4908. @uref{http://stable.melpa.org/packages, MELPA-Stable}, selected by the
  4909. @code{melpa-stable} identifier.
  4910. @item
  4911. @uref{http://melpa.org/packages, MELPA}, selected by the @code{melpa}
  4912. identifier.
  4913. @end itemize
  4914. @end table
  4915. @item crate
  4916. @cindex crate
  4917. Import metadata from the crates.io Rust package repository
  4918. @uref{https://crates.io, crates.io}.
  4919. @end table
  4920. The structure of the @command{guix import} code is modular. It would be
  4921. useful to have more importers for other package formats, and your help
  4922. is welcome here (@pxref{Contributing}).
  4923. @node Invoking guix refresh
  4924. @section Invoking @command{guix refresh}
  4925. @cindex @command {guix refresh}
  4926. The primary audience of the @command{guix refresh} command is developers
  4927. of the GNU software distribution. By default, it reports any packages
  4928. provided by the distribution that are outdated compared to the latest
  4929. upstream version, like this:
  4930. @example
  4931. $ guix refresh
  4932. gnu/packages/gettext.scm:29:13: gettext would be upgraded from 0.18.1.1 to 0.18.2.1
  4933. gnu/packages/glib.scm:77:12: glib would be upgraded from 2.34.3 to 2.37.0
  4934. @end example
  4935. Alternately, one can specify packages to consider, in which case a
  4936. warning is emitted for packages that lack an updater:
  4937. @example
  4938. $ guix refresh coreutils guile guile-ssh
  4939. gnu/packages/ssh.scm:205:2: warning: no updater for guile-ssh
  4940. gnu/packages/guile.scm:136:12: guile would be upgraded from 2.0.12 to 2.0.13
  4941. @end example
  4942. @command{guix refresh} browses the upstream repository of each package and determines
  4943. the highest version number of the releases therein. The command
  4944. knows how to update specific types of packages: GNU packages, ELPA
  4945. packages, etc.---see the documentation for @option{--type} below. There
  4946. are many packages, though, for which it lacks a method to determine
  4947. whether a new upstream release is available. However, the mechanism is
  4948. extensible, so feel free to get in touch with us to add a new method!
  4949. When passed @code{--update}, it modifies distribution source files to
  4950. update the version numbers and source tarball hashes of those package
  4951. recipes (@pxref{Defining Packages}). This is achieved by downloading
  4952. each package's latest source tarball and its associated OpenPGP
  4953. signature, authenticating the downloaded tarball against its signature
  4954. using @command{gpg}, and finally computing its hash. When the public
  4955. key used to sign the tarball is missing from the user's keyring, an
  4956. attempt is made to automatically retrieve it from a public key server;
  4957. when this is successful, the key is added to the user's keyring; otherwise,
  4958. @command{guix refresh} reports an error.
  4959. The following options are supported:
  4960. @table @code
  4961. @item --expression=@var{expr}
  4962. @itemx -e @var{expr}
  4963. Consider the package @var{expr} evaluates to.
  4964. This is useful to precisely refer to a package, as in this example:
  4965. @example
  4966. guix refresh -l -e '(@@@@ (gnu packages commencement) glibc-final)'
  4967. @end example
  4968. This command lists the dependents of the ``final'' libc (essentially all
  4969. the packages.)
  4970. @item --update
  4971. @itemx -u
  4972. Update distribution source files (package recipes) in place. This is
  4973. usually run from a checkout of the Guix source tree (@pxref{Running
  4974. Guix Before It Is Installed}):
  4975. @example
  4976. $ ./pre-inst-env guix refresh -s non-core -u
  4977. @end example
  4978. @xref{Defining Packages}, for more information on package definitions.
  4979. @item --select=[@var{subset}]
  4980. @itemx -s @var{subset}
  4981. Select all the packages in @var{subset}, one of @code{core} or
  4982. @code{non-core}.
  4983. The @code{core} subset refers to all the packages at the core of the
  4984. distribution---i.e., packages that are used to build ``everything
  4985. else''. This includes GCC, libc, Binutils, Bash, etc. Usually,
  4986. changing one of these packages in the distribution entails a rebuild of
  4987. all the others. Thus, such updates are an inconvenience to users in
  4988. terms of build time or bandwidth used to achieve the upgrade.
  4989. The @code{non-core} subset refers to the remaining packages. It is
  4990. typically useful in cases where an update of the core packages would be
  4991. inconvenient.
  4992. @item --manifest=@var{file}
  4993. @itemx -m @var{file}
  4994. Select all the packages from the manifest in @var{file}. This is useful to
  4995. check if any packages of the user manifest can be updated.
  4996. @item --type=@var{updater}
  4997. @itemx -t @var{updater}
  4998. Select only packages handled by @var{updater} (may be a comma-separated
  4999. list of updaters). Currently, @var{updater} may be one of:
  5000. @table @code
  5001. @item gnu
  5002. the updater for GNU packages;
  5003. @item gnome
  5004. the updater for GNOME packages;
  5005. @item kde
  5006. the updater for KDE packages;
  5007. @item xorg
  5008. the updater for X.org packages;
  5009. @item kernel.org
  5010. the updater for packages hosted on kernel.org;
  5011. @item elpa
  5012. the updater for @uref{http://elpa.gnu.org/, ELPA} packages;
  5013. @item cran
  5014. the updater for @uref{http://cran.r-project.org/, CRAN} packages;
  5015. @item bioconductor
  5016. the updater for @uref{http://www.bioconductor.org/, Bioconductor} R packages;
  5017. @item cpan
  5018. the updater for @uref{http://www.cpan.org/, CPAN} packages;
  5019. @item pypi
  5020. the updater for @uref{https://pypi.python.org, PyPI} packages.
  5021. @item gem
  5022. the updater for @uref{https://rubygems.org, RubyGems} packages.
  5023. @item github
  5024. the updater for @uref{https://github.com, GitHub} packages.
  5025. @item hackage
  5026. the updater for @uref{https://hackage.haskell.org, Hackage} packages.
  5027. @item stackage
  5028. the updater for @uref{https://www.stackage.org, Stackage} packages.
  5029. @item crate
  5030. the updater for @uref{https://crates.io, Crates} packages.
  5031. @end table
  5032. For instance, the following command only checks for updates of Emacs
  5033. packages hosted at @code{elpa.gnu.org} and for updates of CRAN packages:
  5034. @example
  5035. $ guix refresh --type=elpa,cran
  5036. gnu/packages/statistics.scm:819:13: r-testthat would be upgraded from 0.10.0 to 0.11.0
  5037. gnu/packages/emacs.scm:856:13: emacs-auctex would be upgraded from 11.88.6 to 11.88.9
  5038. @end example
  5039. @end table
  5040. In addition, @command{guix refresh} can be passed one or more package
  5041. names, as in this example:
  5042. @example
  5043. $ ./pre-inst-env guix refresh -u emacs idutils gcc@@4.8
  5044. @end example
  5045. @noindent
  5046. The command above specifically updates the @code{emacs} and
  5047. @code{idutils} packages. The @code{--select} option would have no
  5048. effect in this case.
  5049. When considering whether to upgrade a package, it is sometimes
  5050. convenient to know which packages would be affected by the upgrade and
  5051. should be checked for compatibility. For this the following option may
  5052. be used when passing @command{guix refresh} one or more package names:
  5053. @table @code
  5054. @item --list-updaters
  5055. @itemx -L
  5056. List available updaters and exit (see @option{--type} above.)
  5057. For each updater, display the fraction of packages it covers; at the
  5058. end, display the fraction of packages covered by all these updaters.
  5059. @item --list-dependent
  5060. @itemx -l
  5061. List top-level dependent packages that would need to be rebuilt as a
  5062. result of upgrading one or more packages.
  5063. @xref{Invoking guix graph, the @code{reverse-package} type of
  5064. @command{guix graph}}, for information on how to visualize the list of
  5065. dependents of a package.
  5066. @end table
  5067. Be aware that the @code{--list-dependent} option only
  5068. @emph{approximates} the rebuilds that would be required as a result of
  5069. an upgrade. More rebuilds might be required under some circumstances.
  5070. @example
  5071. $ guix refresh --list-dependent flex
  5072. Building the following 120 packages would ensure 213 dependent packages are rebuilt:
  5073. hop@@2.4.0 geiser@@0.4 notmuch@@0.18 mu@@0.9.9.5 cflow@@1.4 idutils@@4.6 @dots{}
  5074. @end example
  5075. The command above lists a set of packages that could be built to check
  5076. for compatibility with an upgraded @code{flex} package.
  5077. The following options can be used to customize GnuPG operation:
  5078. @table @code
  5079. @item --gpg=@var{command}
  5080. Use @var{command} as the GnuPG 2.x command. @var{command} is searched
  5081. for in @code{$PATH}.
  5082. @item --key-download=@var{policy}
  5083. Handle missing OpenPGP keys according to @var{policy}, which may be one
  5084. of:
  5085. @table @code
  5086. @item always
  5087. Always download missing OpenPGP keys from the key server, and add them
  5088. to the user's GnuPG keyring.
  5089. @item never
  5090. Never try to download missing OpenPGP keys. Instead just bail out.
  5091. @item interactive
  5092. When a package signed with an unknown OpenPGP key is encountered, ask
  5093. the user whether to download it or not. This is the default behavior.
  5094. @end table
  5095. @item --key-server=@var{host}
  5096. Use @var{host} as the OpenPGP key server when importing a public key.
  5097. @end table
  5098. The @code{github} updater uses the
  5099. @uref{https://developer.github.com/v3/, GitHub API} to query for new
  5100. releases. When used repeatedly e.g. when refreshing all packages,
  5101. GitHub will eventually refuse to answer any further API requests. By
  5102. default 60 API requests per hour are allowed, and a full refresh on all
  5103. GitHub packages in Guix requires more than this. Authentication with
  5104. GitHub through the use of an API token alleviates these limits. To use
  5105. an API token, set the environment variable @code{GUIX_GITHUB_TOKEN} to a
  5106. token procured from @uref{https://github.com/settings/tokens} or
  5107. otherwise.
  5108. @node Invoking guix lint
  5109. @section Invoking @command{guix lint}
  5110. @cindex @command{guix lint}
  5111. @cindex package, checking for errors
  5112. The @command{guix lint} command is meant to help package developers avoid
  5113. common errors and use a consistent style. It runs a number of checks on
  5114. a given set of packages in order to find common mistakes in their
  5115. definitions. Available @dfn{checkers} include (see
  5116. @code{--list-checkers} for a complete list):
  5117. @table @code
  5118. @item synopsis
  5119. @itemx description
  5120. Validate certain typographical and stylistic rules about package
  5121. descriptions and synopses.
  5122. @item inputs-should-be-native
  5123. Identify inputs that should most likely be native inputs.
  5124. @item source
  5125. @itemx home-page
  5126. @itemx mirror-url
  5127. @itemx source-file-name
  5128. Probe @code{home-page} and @code{source} URLs and report those that are
  5129. invalid. Suggest a @code{mirror://} URL when applicable. Check that
  5130. the source file name is meaningful, e.g. is not
  5131. just a version number or ``git-checkout'', without a declared
  5132. @code{file-name} (@pxref{origin Reference}).
  5133. @item cve
  5134. @cindex security vulnerabilities
  5135. @cindex CVE, Common Vulnerabilities and Exposures
  5136. Report known vulnerabilities found in the Common Vulnerabilities and
  5137. Exposures (CVE) databases of the current and past year
  5138. @uref{https://nvd.nist.gov/download.cfm#CVE_FEED, published by the US
  5139. NIST}.
  5140. To view information about a particular vulnerability, visit pages such as:
  5141. @itemize
  5142. @item
  5143. @indicateurl{https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-YYYY-ABCD}
  5144. @item
  5145. @indicateurl{https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-YYYY-ABCD}
  5146. @end itemize
  5147. @noindent
  5148. where @code{CVE-YYYY-ABCD} is the CVE identifier---e.g.,
  5149. @code{CVE-2015-7554}.
  5150. Package developers can specify in package recipes the
  5151. @uref{https://nvd.nist.gov/cpe.cfm,Common Platform Enumeration (CPE)}
  5152. name and version of the package when they differ from the name that Guix
  5153. uses, as in this example:
  5154. @example
  5155. (package
  5156. (name "grub")
  5157. ;; @dots{}
  5158. ;; CPE calls this package "grub2".
  5159. (properties '((cpe-name . "grub2"))))
  5160. @end example
  5161. @item formatting
  5162. Warn about obvious source code formatting issues: trailing white space,
  5163. use of tabulations, etc.
  5164. @end table
  5165. The general syntax is:
  5166. @example
  5167. guix lint @var{options} @var{package}@dots{}
  5168. @end example
  5169. If no package is given on the command line, then all packages are checked.
  5170. The @var{options} may be zero or more of the following:
  5171. @table @code
  5172. @item --list-checkers
  5173. @itemx -l
  5174. List and describe all the available checkers that will be run on packages
  5175. and exit.
  5176. @item --checkers
  5177. @itemx -c
  5178. Only enable the checkers specified in a comma-separated list using the
  5179. names returned by @code{--list-checkers}.
  5180. @end table
  5181. @node Invoking guix size
  5182. @section Invoking @command{guix size}
  5183. @cindex size
  5184. @cindex package size
  5185. @cindex closure
  5186. @cindex @command{guix size}
  5187. The @command{guix size} command helps package developers profile the
  5188. disk usage of packages. It is easy to overlook the impact of an
  5189. additional dependency added to a package, or the impact of using a
  5190. single output for a package that could easily be split (@pxref{Packages
  5191. with Multiple Outputs}). Such are the typical issues that
  5192. @command{guix size} can highlight.
  5193. The command can be passed a package specification such as @code{gcc@@4.8}
  5194. or @code{guile:debug}, or a file name in the store. Consider this
  5195. example:
  5196. @example
  5197. $ guix size coreutils
  5198. store item total self
  5199. /gnu/store/@dots{}-coreutils-8.23 70.0 13.9 19.8%
  5200. /gnu/store/@dots{}-gmp-6.0.0a 55.3 2.5 3.6%
  5201. /gnu/store/@dots{}-acl-2.2.52 53.7 0.5 0.7%
  5202. /gnu/store/@dots{}-attr-2.4.46 53.2 0.3 0.5%
  5203. /gnu/store/@dots{}-gcc-4.8.4-lib 52.9 15.7 22.4%
  5204. /gnu/store/@dots{}-glibc-2.21 37.2 37.2 53.1%
  5205. @end example
  5206. @cindex closure
  5207. The store items listed here constitute the @dfn{transitive closure} of
  5208. Coreutils---i.e., Coreutils and all its dependencies, recursively---as
  5209. would be returned by:
  5210. @example
  5211. $ guix gc -R /gnu/store/@dots{}-coreutils-8.23
  5212. @end example
  5213. Here the output shows three columns next to store items. The first column,
  5214. labeled ``total'', shows the size in mebibytes (MiB) of the closure of
  5215. the store item---that is, its own size plus the size of all its
  5216. dependencies. The next column, labeled ``self'', shows the size of the
  5217. item itself. The last column shows the ratio of the size of the item
  5218. itself to the space occupied by all the items listed here.
  5219. In this example, we see that the closure of Coreutils weighs in at
  5220. 70@tie{}MiB, half of which is taken by libc. (That libc represents a
  5221. large fraction of the closure is not a problem @i{per se} because it is
  5222. always available on the system anyway.)
  5223. When the package passed to @command{guix size} is available in the
  5224. store, @command{guix size} queries the daemon to determine its
  5225. dependencies, and measures its size in the store, similar to @command{du
  5226. -ms --apparent-size} (@pxref{du invocation,,, coreutils, GNU
  5227. Coreutils}).
  5228. When the given package is @emph{not} in the store, @command{guix size}
  5229. reports information based on the available substitutes
  5230. (@pxref{Substitutes}). This makes it possible it to profile disk usage of
  5231. store items that are not even on disk, only available remotely.
  5232. You can also specify several package names:
  5233. @example
  5234. $ guix size coreutils grep sed bash
  5235. store item total self
  5236. /gnu/store/@dots{}-coreutils-8.24 77.8 13.8 13.4%
  5237. /gnu/store/@dots{}-grep-2.22 73.1 0.8 0.8%
  5238. /gnu/store/@dots{}-bash-4.3.42 72.3 4.7 4.6%
  5239. /gnu/store/@dots{}-readline-6.3 67.6 1.2 1.2%
  5240. @dots{}
  5241. total: 102.3 MiB
  5242. @end example
  5243. @noindent
  5244. In this example we see that the combination of the four packages takes
  5245. 102.3@tie{}MiB in total, which is much less than the sum of each closure
  5246. since they have a lot of dependencies in common.
  5247. The available options are:
  5248. @table @option
  5249. @item --substitute-urls=@var{urls}
  5250. Use substitute information from @var{urls}.
  5251. @xref{client-substitute-urls, the same option for @code{guix build}}.
  5252. @item --sort=@var{key}
  5253. Sort lines according to @var{key}, one of the following options:
  5254. @table @code
  5255. @item self
  5256. the size of each item (the default);
  5257. @item closure
  5258. the total size of the item's closure.
  5259. @end table
  5260. @item --map-file=@var{file}
  5261. Write a graphical map of disk usage in PNG format to @var{file}.
  5262. For the example above, the map looks like this:
  5263. @image{images/coreutils-size-map,5in,, map of Coreutils disk usage
  5264. produced by @command{guix size}}
  5265. This option requires that
  5266. @uref{http://wingolog.org/software/guile-charting/, Guile-Charting} be
  5267. installed and visible in Guile's module search path. When that is not
  5268. the case, @command{guix size} fails as it tries to load it.
  5269. @item --system=@var{system}
  5270. @itemx -s @var{system}
  5271. Consider packages for @var{system}---e.g., @code{x86_64-linux}.
  5272. @end table
  5273. @node Invoking guix graph
  5274. @section Invoking @command{guix graph}
  5275. @cindex DAG
  5276. @cindex @command{guix graph}
  5277. @cindex package dependencies
  5278. Packages and their dependencies form a @dfn{graph}, specifically a
  5279. directed acyclic graph (DAG). It can quickly become difficult to have a
  5280. mental model of the package DAG, so the @command{guix graph} command
  5281. provides a visual representation of the DAG. By default,
  5282. @command{guix graph} emits a DAG representation in the input format of
  5283. @uref{http://www.graphviz.org/, Graphviz}, so its output can be passed
  5284. directly to the @command{dot} command of Graphviz. It can also emit an
  5285. HTML page with embedded JavaScript code to display a ``chord diagram''
  5286. in a Web browser, using the @uref{https://d3js.org/, d3.js} library, or
  5287. emit Cypher queries to construct a graph in a graph database supporting
  5288. the @uref{http://www.opencypher.org/, openCypher} query language.
  5289. The general syntax is:
  5290. @example
  5291. guix graph @var{options} @var{package}@dots{}
  5292. @end example
  5293. For example, the following command generates a PDF file representing the
  5294. package DAG for the GNU@tie{}Core Utilities, showing its build-time
  5295. dependencies:
  5296. @example
  5297. guix graph coreutils | dot -Tpdf > dag.pdf
  5298. @end example
  5299. The output looks like this:
  5300. @image{images/coreutils-graph,2in,,Dependency graph of the GNU Coreutils}
  5301. Nice little graph, no?
  5302. But there is more than one graph! The one above is concise: it is the
  5303. graph of package objects, omitting implicit inputs such as GCC, libc,
  5304. grep, etc. It is often useful to have such a concise graph, but
  5305. sometimes one may want to see more details. @command{guix graph} supports
  5306. several types of graphs, allowing you to choose the level of detail:
  5307. @table @code
  5308. @item package
  5309. This is the default type used in the example above. It shows the DAG of
  5310. package objects, excluding implicit dependencies. It is concise, but
  5311. filters out many details.
  5312. @item reverse-package
  5313. This shows the @emph{reverse} DAG of packages. For example:
  5314. @example
  5315. guix graph --type=reverse-package ocaml
  5316. @end example
  5317. ... yields the graph of packages that depend on OCaml.
  5318. Note that for core packages this can yield huge graphs. If all you want
  5319. is to know the number of packages that depend on a given package, use
  5320. @command{guix refresh --list-dependent} (@pxref{Invoking guix refresh,
  5321. @option{--list-dependent}}).
  5322. @item bag-emerged
  5323. This is the package DAG, @emph{including} implicit inputs.
  5324. For instance, the following command:
  5325. @example
  5326. guix graph --type=bag-emerged coreutils | dot -Tpdf > dag.pdf
  5327. @end example
  5328. ... yields this bigger graph:
  5329. @image{images/coreutils-bag-graph,,5in,Detailed dependency graph of the GNU Coreutils}
  5330. At the bottom of the graph, we see all the implicit inputs of
  5331. @var{gnu-build-system} (@pxref{Build Systems, @code{gnu-build-system}}).
  5332. Now, note that the dependencies of these implicit inputs---that is, the
  5333. @dfn{bootstrap dependencies} (@pxref{Bootstrapping})---are not shown
  5334. here, for conciseness.
  5335. @item bag
  5336. Similar to @code{bag-emerged}, but this time including all the bootstrap
  5337. dependencies.
  5338. @item bag-with-origins
  5339. Similar to @code{bag}, but also showing origins and their dependencies.
  5340. @item derivations
  5341. This is the most detailed representation: It shows the DAG of
  5342. derivations (@pxref{Derivations}) and plain store items. Compared to
  5343. the above representation, many additional nodes are visible, including
  5344. build scripts, patches, Guile modules, etc.
  5345. For this type of graph, it is also possible to pass a @file{.drv} file
  5346. name instead of a package name, as in:
  5347. @example
  5348. guix graph -t derivation `guix system build -d my-config.scm`
  5349. @end example
  5350. @end table
  5351. All the types above correspond to @emph{build-time dependencies}. The
  5352. following graph type represents the @emph{run-time dependencies}:
  5353. @table @code
  5354. @item references
  5355. This is the graph of @dfn{references} of a package output, as returned
  5356. by @command{guix gc --references} (@pxref{Invoking guix gc}).
  5357. If the given package output is not available in the store, @command{guix
  5358. graph} attempts to obtain dependency information from substitutes.
  5359. Here you can also pass a store file name instead of a package name. For
  5360. example, the command below produces the reference graph of your profile
  5361. (which can be big!):
  5362. @example
  5363. guix graph -t references `readlink -f ~/.guix-profile`
  5364. @end example
  5365. @item referrers
  5366. This is the graph of the @dfn{referrers} of a store item, as returned by
  5367. @command{guix gc --referrers} (@pxref{Invoking guix gc}).
  5368. This relies exclusively on local information from your store. For
  5369. instance, let us suppose that the current Inkscape is available in 10
  5370. profiles on your machine; @command{guix graph -t referrers inkscape}
  5371. will show a graph rooted at Inkscape and with those 10 profiles linked
  5372. to it.
  5373. It can help determine what is preventing a store item from being garbage
  5374. collected.
  5375. @end table
  5376. The available options are the following:
  5377. @table @option
  5378. @item --type=@var{type}
  5379. @itemx -t @var{type}
  5380. Produce a graph output of @var{type}, where @var{type} must be one of
  5381. the values listed above.
  5382. @item --list-types
  5383. List the supported graph types.
  5384. @item --backend=@var{backend}
  5385. @itemx -b @var{backend}
  5386. Produce a graph using the selected @var{backend}.
  5387. @item --list-backends
  5388. List the supported graph backends.
  5389. Currently, the available backends are Graphviz and d3.js.
  5390. @item --expression=@var{expr}
  5391. @itemx -e @var{expr}
  5392. Consider the package @var{expr} evaluates to.
  5393. This is useful to precisely refer to a package, as in this example:
  5394. @example
  5395. guix graph -e '(@@@@ (gnu packages commencement) gnu-make-final)'
  5396. @end example
  5397. @end table
  5398. @node Invoking guix environment
  5399. @section Invoking @command{guix environment}
  5400. @cindex reproducible build environments
  5401. @cindex development environments
  5402. @cindex @command{guix environment}
  5403. @cindex environment, package build environment
  5404. The purpose of @command{guix environment} is to assist hackers in
  5405. creating reproducible development environments without polluting their
  5406. package profile. The @command{guix environment} tool takes one or more
  5407. packages, builds all of their inputs, and creates a shell
  5408. environment to use them.
  5409. The general syntax is:
  5410. @example
  5411. guix environment @var{options} @var{package}@dots{}
  5412. @end example
  5413. The following example spawns a new shell set up for the development of
  5414. GNU@tie{}Guile:
  5415. @example
  5416. guix environment guile
  5417. @end example
  5418. If the needed dependencies are not built yet, @command{guix environment}
  5419. automatically builds them. The environment of the new shell is an augmented
  5420. version of the environment that @command{guix environment} was run in.
  5421. It contains the necessary search paths for building the given package
  5422. added to the existing environment variables. To create a ``pure''
  5423. environment, in which the original environment variables have been unset,
  5424. use the @code{--pure} option@footnote{Users sometimes wrongfully augment
  5425. environment variables such as @code{PATH} in their @file{~/.bashrc}
  5426. file. As a consequence, when @code{guix environment} launches it, Bash
  5427. may read @file{~/.bashrc}, thereby introducing ``impurities'' in these
  5428. environment variables. It is an error to define such environment
  5429. variables in @file{.bashrc}; instead, they should be defined in
  5430. @file{.bash_profile}, which is sourced only by log-in shells.
  5431. @xref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}, for
  5432. details on Bash start-up files.}.
  5433. @vindex GUIX_ENVIRONMENT
  5434. @command{guix environment} defines the @code{GUIX_ENVIRONMENT}
  5435. variable in the shell it spawns; its value is the file name of the
  5436. profile of this environment. This allows users to, say, define a
  5437. specific prompt for development environments in their @file{.bashrc}
  5438. (@pxref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}):
  5439. @example
  5440. if [ -n "$GUIX_ENVIRONMENT" ]
  5441. then
  5442. export PS1="\u@@\h \w [dev]\$ "
  5443. fi
  5444. @end example
  5445. @noindent
  5446. ... or to browse the profile:
  5447. @example
  5448. $ ls "$GUIX_ENVIRONMENT/bin"
  5449. @end example
  5450. Additionally, more than one package may be specified, in which case the
  5451. union of the inputs for the given packages are used. For example, the
  5452. command below spawns a shell where all of the dependencies of both Guile
  5453. and Emacs are available:
  5454. @example
  5455. guix environment guile emacs
  5456. @end example
  5457. Sometimes an interactive shell session is not desired. An arbitrary
  5458. command may be invoked by placing the @code{--} token to separate the
  5459. command from the rest of the arguments:
  5460. @example
  5461. guix environment guile -- make -j4
  5462. @end example
  5463. In other situations, it is more convenient to specify the list of
  5464. packages needed in the environment. For example, the following command
  5465. runs @command{python} from an environment containing Python@tie{}2.7 and
  5466. NumPy:
  5467. @example
  5468. guix environment --ad-hoc python2-numpy python-2.7 -- python
  5469. @end example
  5470. Furthermore, one might want the dependencies of a package and also some
  5471. additional packages that are not build-time or runtime dependencies, but
  5472. are useful when developing nonetheless. Because of this, the
  5473. @code{--ad-hoc} flag is positional. Packages appearing before
  5474. @code{--ad-hoc} are interpreted as packages whose dependencies will be
  5475. added to the environment. Packages appearing after are interpreted as
  5476. packages that will be added to the environment directly. For example,
  5477. the following command creates a Guix development environment that
  5478. additionally includes Git and strace:
  5479. @example
  5480. guix environment guix --ad-hoc git strace
  5481. @end example
  5482. Sometimes it is desirable to isolate the environment as much as
  5483. possible, for maximal purity and reproducibility. In particular, when
  5484. using Guix on a host distro that is not GuixSD, it is desirable to
  5485. prevent access to @file{/usr/bin} and other system-wide resources from
  5486. the development environment. For example, the following command spawns
  5487. a Guile REPL in a ``container'' where only the store and the current
  5488. working directory are mounted:
  5489. @example
  5490. guix environment --ad-hoc --container guile -- guile
  5491. @end example
  5492. @quotation Note
  5493. The @code{--container} option requires Linux-libre 3.19 or newer.
  5494. @end quotation
  5495. The available options are summarized below.
  5496. @table @code
  5497. @item --root=@var{file}
  5498. @itemx -r @var{file}
  5499. @cindex persistent environment
  5500. @cindex garbage collector root, for environments
  5501. Make @var{file} a symlink to the profile for this environment, and
  5502. register it as a garbage collector root.
  5503. This is useful if you want to protect your environment from garbage
  5504. collection, to make it ``persistent''.
  5505. When this option is omitted, the environment is protected from garbage
  5506. collection only for the duration of the @command{guix environment}
  5507. session. This means that next time you recreate the same environment,
  5508. you could have to rebuild or re-download packages.
  5509. @item --expression=@var{expr}
  5510. @itemx -e @var{expr}
  5511. Create an environment for the package or list of packages that
  5512. @var{expr} evaluates to.
  5513. For example, running:
  5514. @example
  5515. guix environment -e '(@@ (gnu packages maths) petsc-openmpi)'
  5516. @end example
  5517. starts a shell with the environment for this specific variant of the
  5518. PETSc package.
  5519. Running:
  5520. @example
  5521. guix environment --ad-hoc -e '(@@ (gnu) %base-packages)'
  5522. @end example
  5523. starts a shell with all the GuixSD base packages available.
  5524. The above commands only use the default output of the given packages.
  5525. To select other outputs, two element tuples can be specified:
  5526. @example
  5527. guix environment --ad-hoc -e '(list (@ (gnu packages bash) bash) "include")'
  5528. @end example
  5529. @item --load=@var{file}
  5530. @itemx -l @var{file}
  5531. Create an environment for the package or list of packages that the code
  5532. within @var{file} evaluates to.
  5533. As an example, @var{file} might contain a definition like this
  5534. (@pxref{Defining Packages}):
  5535. @example
  5536. @verbatiminclude environment-gdb.scm
  5537. @end example
  5538. @item --ad-hoc
  5539. Include all specified packages in the resulting environment, as if an
  5540. @i{ad hoc} package were defined with them as inputs. This option is
  5541. useful for quickly creating an environment without having to write a
  5542. package expression to contain the desired inputs.
  5543. For instance, the command:
  5544. @example
  5545. guix environment --ad-hoc guile guile-sdl -- guile
  5546. @end example
  5547. runs @command{guile} in an environment where Guile and Guile-SDL are
  5548. available.
  5549. Note that this example implicitly asks for the default output of
  5550. @code{guile} and @code{guile-sdl}, but it is possible to ask for a
  5551. specific output---e.g., @code{glib:bin} asks for the @code{bin} output
  5552. of @code{glib} (@pxref{Packages with Multiple Outputs}).
  5553. This option may be composed with the default behavior of @command{guix
  5554. environment}. Packages appearing before @code{--ad-hoc} are interpreted
  5555. as packages whose dependencies will be added to the environment, the
  5556. default behavior. Packages appearing after are interpreted as packages
  5557. that will be added to the environment directly.
  5558. @item --pure
  5559. Unset existing environment variables when building the new environment.
  5560. This has the effect of creating an environment in which search paths
  5561. only contain package inputs.
  5562. @item --search-paths
  5563. Display the environment variable definitions that make up the
  5564. environment.
  5565. @item --system=@var{system}
  5566. @itemx -s @var{system}
  5567. Attempt to build for @var{system}---e.g., @code{i686-linux}.
  5568. @item --container
  5569. @itemx -C
  5570. @cindex container
  5571. Run @var{command} within an isolated container. The current working
  5572. directory outside the container is mapped inside the container.
  5573. Additionally, a dummy home directory is created that matches the current
  5574. user's home directory, and @file{/etc/passwd} is configured accordingly.
  5575. The spawned process runs as the current user outside the container, but
  5576. has root privileges in the context of the container.
  5577. @item --network
  5578. @itemx -N
  5579. For containers, share the network namespace with the host system.
  5580. Containers created without this flag only have access to the loopback
  5581. device.
  5582. @item --expose=@var{source}[=@var{target}]
  5583. For containers, expose the file system @var{source} from the host system
  5584. as the read-only file system @var{target} within the container. If
  5585. @var{target} is not specified, @var{source} is used as the target mount
  5586. point in the container.
  5587. The example below spawns a Guile REPL in a container in which the user's
  5588. home directory is accessible read-only via the @file{/exchange}
  5589. directory:
  5590. @example
  5591. guix environment --container --expose=$HOME=/exchange --ad-hoc guile -- guile
  5592. @end example
  5593. @item --share=@var{source}[=@var{target}]
  5594. For containers, share the file system @var{source} from the host system
  5595. as the writable file system @var{target} within the container. If
  5596. @var{target} is not specified, @var{source} is used as the target mount
  5597. point in the container.
  5598. The example below spawns a Guile REPL in a container in which the user's
  5599. home directory is accessible for both reading and writing via the
  5600. @file{/exchange} directory:
  5601. @example
  5602. guix environment --container --share=$HOME=/exchange --ad-hoc guile -- guile
  5603. @end example
  5604. @end table
  5605. @command{guix environment}
  5606. also supports all of the common build options that @command{guix
  5607. build} supports (@pxref{Common Build Options}).
  5608. @node Invoking guix publish
  5609. @section Invoking @command{guix publish}
  5610. @cindex @command{guix publish}
  5611. The purpose of @command{guix publish} is to enable users to easily share
  5612. their store with others, who can then use it as a substitute server
  5613. (@pxref{Substitutes}).
  5614. When @command{guix publish} runs, it spawns an HTTP server which allows
  5615. anyone with network access to obtain substitutes from it. This means
  5616. that any machine running Guix can also act as if it were a build farm,
  5617. since the HTTP interface is compatible with Hydra, the software behind
  5618. the @code{hydra.gnu.org} build farm.
  5619. For security, each substitute is signed, allowing recipients to check
  5620. their authenticity and integrity (@pxref{Substitutes}). Because
  5621. @command{guix publish} uses the signing key of the system, which is only
  5622. readable by the system administrator, it must be started as root; the
  5623. @code{--user} option makes it drop root privileges early on.
  5624. The signing key pair must be generated before @command{guix publish} is
  5625. launched, using @command{guix archive --generate-key} (@pxref{Invoking
  5626. guix archive}).
  5627. The general syntax is:
  5628. @example
  5629. guix publish @var{options}@dots{}
  5630. @end example
  5631. Running @command{guix publish} without any additional arguments will
  5632. spawn an HTTP server on port 8080:
  5633. @example
  5634. guix publish
  5635. @end example
  5636. Once a publishing server has been authorized (@pxref{Invoking guix
  5637. archive}), the daemon may download substitutes from it:
  5638. @example
  5639. guix-daemon --substitute-urls=http://example.org:8080
  5640. @end example
  5641. By default, @command{guix publish} compresses archives on the fly as it
  5642. serves them. This ``on-the-fly'' mode is convenient in that it requires
  5643. no setup and is immediately available. However, when serving lots of
  5644. clients, we recommend using the @option{--cache} option, which enables
  5645. caching of the archives before they are sent to clients---see below for
  5646. details. The @command{guix weather} command provides a handy way to
  5647. check what a server provides (@pxref{Invoking guix weather}).
  5648. As a bonus, @command{guix publish} also serves as a content-addressed
  5649. mirror for source files referenced in @code{origin} records
  5650. (@pxref{origin Reference}). For instance, assuming @command{guix
  5651. publish} is running on @code{example.org}, the following URL returns the
  5652. raw @file{hello-2.10.tar.gz} file with the given SHA256 hash
  5653. (represented in @code{nix-base32} format, @pxref{Invoking guix hash}):
  5654. @example
  5655. http://example.org/file/hello-2.10.tar.gz/sha256/0ssi1@dots{}ndq1i
  5656. @end example
  5657. Obviously, these URLs only work for files that are in the store; in
  5658. other cases, they return 404 (``Not Found'').
  5659. The following options are available:
  5660. @table @code
  5661. @item --port=@var{port}
  5662. @itemx -p @var{port}
  5663. Listen for HTTP requests on @var{port}.
  5664. @item --listen=@var{host}
  5665. Listen on the network interface for @var{host}. The default is to
  5666. accept connections from any interface.
  5667. @item --user=@var{user}
  5668. @itemx -u @var{user}
  5669. Change privileges to @var{user} as soon as possible---i.e., once the
  5670. server socket is open and the signing key has been read.
  5671. @item --compression[=@var{level}]
  5672. @itemx -C [@var{level}]
  5673. Compress data using the given @var{level}. When @var{level} is zero,
  5674. disable compression. The range 1 to 9 corresponds to different gzip
  5675. compression levels: 1 is the fastest, and 9 is the best (CPU-intensive).
  5676. The default is 3.
  5677. Unless @option{--cache} is used, compression occurs on the fly and
  5678. the compressed streams are not
  5679. cached. Thus, to reduce load on the machine that runs @command{guix
  5680. publish}, it may be a good idea to choose a low compression level, to
  5681. run @command{guix publish} behind a caching proxy, or to use
  5682. @option{--cache}. Using @option{--cache} has the advantage that it
  5683. allows @command{guix publish} to add @code{Content-Length} HTTP header
  5684. to its responses.
  5685. @item --cache=@var{directory}
  5686. @itemx -c @var{directory}
  5687. Cache archives and meta-data (@code{.narinfo} URLs) to @var{directory}
  5688. and only serve archives that are in cache.
  5689. When this option is omitted, archives and meta-data are created
  5690. on-the-fly. This can reduce the available bandwidth, especially when
  5691. compression is enabled, since this may become CPU-bound. Another
  5692. drawback of the default mode is that the length of archives is not known
  5693. in advance, so @command{guix publish} does not add a
  5694. @code{Content-Length} HTTP header to its responses, which in turn
  5695. prevents clients from knowing the amount of data being downloaded.
  5696. Conversely, when @option{--cache} is used, the first request for a store
  5697. item (@i{via} a @code{.narinfo} URL) returns 404 and triggers a
  5698. background process to @dfn{bake} the archive---computing its
  5699. @code{.narinfo} and compressing the archive, if needed. Once the
  5700. archive is cached in @var{directory}, subsequent requests succeed and
  5701. are served directly from the cache, which guarantees that clients get
  5702. the best possible bandwidth.
  5703. The ``baking'' process is performed by worker threads. By default, one
  5704. thread per CPU core is created, but this can be customized. See
  5705. @option{--workers} below.
  5706. When @option{--ttl} is used, cached entries are automatically deleted
  5707. when they have expired.
  5708. @item --workers=@var{N}
  5709. When @option{--cache} is used, request the allocation of @var{N} worker
  5710. threads to ``bake'' archives.
  5711. @item --ttl=@var{ttl}
  5712. Produce @code{Cache-Control} HTTP headers that advertise a time-to-live
  5713. (TTL) of @var{ttl}. @var{ttl} must denote a duration: @code{5d} means 5
  5714. days, @code{1m} means 1 month, and so on.
  5715. This allows the user's Guix to keep substitute information in cache for
  5716. @var{ttl}. However, note that @code{guix publish} does not itself
  5717. guarantee that the store items it provides will indeed remain available
  5718. for as long as @var{ttl}.
  5719. Additionally, when @option{--cache} is used, cached entries that have
  5720. not been accessed for @var{ttl} and that no longer have a corresponding
  5721. item in the store, may be deleted.
  5722. @item --nar-path=@var{path}
  5723. Use @var{path} as the prefix for the URLs of ``nar'' files
  5724. (@pxref{Invoking guix archive, normalized archives}).
  5725. By default, nars are served at a URL such as
  5726. @code{/nar/gzip/@dots{}-coreutils-8.25}. This option allows you to
  5727. change the @code{/nar} part to @var{path}.
  5728. @item --public-key=@var{file}
  5729. @itemx --private-key=@var{file}
  5730. Use the specific @var{file}s as the public/private key pair used to sign
  5731. the store items being published.
  5732. The files must correspond to the same key pair (the private key is used
  5733. for signing and the public key is merely advertised in the signature
  5734. metadata). They must contain keys in the canonical s-expression format
  5735. as produced by @command{guix archive --generate-key} (@pxref{Invoking
  5736. guix archive}). By default, @file{/etc/guix/signing-key.pub} and
  5737. @file{/etc/guix/signing-key.sec} are used.
  5738. @item --repl[=@var{port}]
  5739. @itemx -r [@var{port}]
  5740. Spawn a Guile REPL server (@pxref{REPL Servers,,, guile, GNU Guile
  5741. Reference Manual}) on @var{port} (37146 by default). This is used
  5742. primarily for debugging a running @command{guix publish} server.
  5743. @end table
  5744. Enabling @command{guix publish} on a GuixSD system is a one-liner: just
  5745. instantiate a @code{guix-publish-service-type} service in the @code{services} field
  5746. of the @code{operating-system} declaration (@pxref{guix-publish-service-type,
  5747. @code{guix-publish-service-type}}).
  5748. If you are instead running Guix on a ``foreign distro'', follow these
  5749. instructions:”
  5750. @itemize
  5751. @item
  5752. If your host distro uses the systemd init system:
  5753. @example
  5754. # ln -s ~root/.guix-profile/lib/systemd/system/guix-publish.service \
  5755. /etc/systemd/system/
  5756. # systemctl start guix-publish && systemctl enable guix-publish
  5757. @end example
  5758. @item
  5759. If your host distro uses the Upstart init system:
  5760. @example
  5761. # ln -s ~root/.guix-profile/lib/upstart/system/guix-publish.conf /etc/init/
  5762. # start guix-publish
  5763. @end example
  5764. @item
  5765. Otherwise, proceed similarly with your distro's init system.
  5766. @end itemize
  5767. @node Invoking guix challenge
  5768. @section Invoking @command{guix challenge}
  5769. @cindex reproducible builds
  5770. @cindex verifiable builds
  5771. @cindex @command{guix challenge}
  5772. @cindex challenge
  5773. Do the binaries provided by this server really correspond to the source
  5774. code it claims to build? Is a package build process deterministic?
  5775. These are the questions the @command{guix challenge} command attempts to
  5776. answer.
  5777. The former is obviously an important question: Before using a substitute
  5778. server (@pxref{Substitutes}), one had better @emph{verify} that it
  5779. provides the right binaries, and thus @emph{challenge} it. The latter
  5780. is what enables the former: If package builds are deterministic, then
  5781. independent builds of the package should yield the exact same result,
  5782. bit for bit; if a server provides a binary different from the one
  5783. obtained locally, it may be either corrupt or malicious.
  5784. We know that the hash that shows up in @file{/gnu/store} file names is
  5785. the hash of all the inputs of the process that built the file or
  5786. directory---compilers, libraries, build scripts,
  5787. etc. (@pxref{Introduction}). Assuming deterministic build processes,
  5788. one store file name should map to exactly one build output.
  5789. @command{guix challenge} checks whether there is, indeed, a single
  5790. mapping by comparing the build outputs of several independent builds of
  5791. any given store item.
  5792. The command output looks like this:
  5793. @smallexample
  5794. $ guix challenge --substitute-urls="https://hydra.gnu.org https://guix.example.org"
  5795. updating list of substitutes from 'https://hydra.gnu.org'... 100.0%
  5796. updating list of substitutes from 'https://guix.example.org'... 100.0%
  5797. /gnu/store/@dots{}-openssl-1.0.2d contents differ:
  5798. local hash: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q
  5799. https://hydra.gnu.org/nar/@dots{}-openssl-1.0.2d: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q
  5800. https://guix.example.org/nar/@dots{}-openssl-1.0.2d: 1zy4fmaaqcnjrzzajkdn3f5gmjk754b43qkq47llbyak9z0qjyim
  5801. /gnu/store/@dots{}-git-2.5.0 contents differ:
  5802. local hash: 00p3bmryhjxrhpn2gxs2fy0a15lnip05l97205pgbk5ra395hyha
  5803. https://hydra.gnu.org/nar/@dots{}-git-2.5.0: 069nb85bv4d4a6slrwjdy8v1cn4cwspm3kdbmyb81d6zckj3nq9f
  5804. https://guix.example.org/nar/@dots{}-git-2.5.0: 0mdqa9w1p6cmli6976v4wi0sw9r4p5prkj7lzfd1877wk11c9c73
  5805. /gnu/store/@dots{}-pius-2.1.1 contents differ:
  5806. local hash: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax
  5807. https://hydra.gnu.org/nar/@dots{}-pius-2.1.1: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax
  5808. https://guix.example.org/nar/@dots{}-pius-2.1.1: 1cy25x1a4fzq5rk0pmvc8xhwyffnqz95h2bpvqsz2mpvlbccy0gs
  5809. @end smallexample
  5810. @noindent
  5811. In this example, @command{guix challenge} first scans the store to
  5812. determine the set of locally-built derivations---as opposed to store
  5813. items that were downloaded from a substitute server---and then queries
  5814. all the substitute servers. It then reports those store items for which
  5815. the servers obtained a result different from the local build.
  5816. @cindex non-determinism, in package builds
  5817. As an example, @code{guix.example.org} always gets a different answer.
  5818. Conversely, @code{hydra.gnu.org} agrees with local builds, except in the
  5819. case of Git. This might indicate that the build process of Git is
  5820. non-deterministic, meaning that its output varies as a function of
  5821. various things that Guix does not fully control, in spite of building
  5822. packages in isolated environments (@pxref{Features}). Most common
  5823. sources of non-determinism include the addition of timestamps in build
  5824. results, the inclusion of random numbers, and directory listings sorted
  5825. by inode number. See @uref{https://reproducible-builds.org/docs/}, for
  5826. more information.
  5827. To find out what is wrong with this Git binary, we can do something along
  5828. these lines (@pxref{Invoking guix archive}):
  5829. @example
  5830. $ wget -q -O - https://hydra.gnu.org/nar/@dots{}-git-2.5.0 \
  5831. | guix archive -x /tmp/git
  5832. $ diff -ur --no-dereference /gnu/store/@dots{}-git.2.5.0 /tmp/git
  5833. @end example
  5834. This command shows the difference between the files resulting from the
  5835. local build, and the files resulting from the build on
  5836. @code{hydra.gnu.org} (@pxref{Overview, Comparing and Merging Files,,
  5837. diffutils, Comparing and Merging Files}). The @command{diff} command
  5838. works great for text files. When binary files differ, a better option
  5839. is @uref{https://diffoscope.org/, Diffoscope}, a tool that helps
  5840. visualize differences for all kinds of files.
  5841. Once you have done that work, you can tell whether the differences are due
  5842. to a non-deterministic build process or to a malicious server. We try
  5843. hard to remove sources of non-determinism in packages to make it easier
  5844. to verify substitutes, but of course, this is a process that
  5845. involves not just Guix, but a large part of the free software community.
  5846. In the meantime, @command{guix challenge} is one tool to help address
  5847. the problem.
  5848. If you are writing packages for Guix, you are encouraged to check
  5849. whether @code{hydra.gnu.org} and other substitute servers obtain the
  5850. same build result as you did with:
  5851. @example
  5852. $ guix challenge @var{package}
  5853. @end example
  5854. @noindent
  5855. where @var{package} is a package specification such as
  5856. @code{guile@@2.0} or @code{glibc:debug}.
  5857. The general syntax is:
  5858. @example
  5859. guix challenge @var{options} [@var{packages}@dots{}]
  5860. @end example
  5861. When a difference is found between the hash of a locally-built item and
  5862. that of a server-provided substitute, or among substitutes provided by
  5863. different servers, the command displays it as in the example above and
  5864. its exit code is 2 (other non-zero exit codes denote other kinds of
  5865. errors.)
  5866. The one option that matters is:
  5867. @table @code
  5868. @item --substitute-urls=@var{urls}
  5869. Consider @var{urls} the whitespace-separated list of substitute source
  5870. URLs to compare to.
  5871. @item --verbose
  5872. @itemx -v
  5873. Show details about matches (identical contents) in addition to
  5874. information about mismatches.
  5875. @end table
  5876. @node Invoking guix copy
  5877. @section Invoking @command{guix copy}
  5878. @cindex copy, of store items, over SSH
  5879. @cindex SSH, copy of store items
  5880. @cindex sharing store items across machines
  5881. @cindex transferring store items across machines
  5882. The @command{guix copy} command copies items from the store of one
  5883. machine to that of another machine over a secure shell (SSH)
  5884. connection@footnote{This command is available only when Guile-SSH was
  5885. found. @xref{Requirements}, for details.}. For example, the following
  5886. command copies the @code{coreutils} package, the user's profile, and all
  5887. their dependencies over to @var{host}, logged in as @var{user}:
  5888. @example
  5889. guix copy --to=@var{user}@@@var{host} \
  5890. coreutils `readlink -f ~/.guix-profile`
  5891. @end example
  5892. If some of the items to be copied are already present on @var{host},
  5893. they are not actually sent.
  5894. The command below retrieves @code{libreoffice} and @code{gimp} from
  5895. @var{host}, assuming they are available there:
  5896. @example
  5897. guix copy --from=@var{host} libreoffice gimp
  5898. @end example
  5899. The SSH connection is established using the Guile-SSH client, which is
  5900. compatible with OpenSSH: it honors @file{~/.ssh/known_hosts} and
  5901. @file{~/.ssh/config}, and uses the SSH agent for authentication.
  5902. The key used to sign items that are sent must be accepted by the remote
  5903. machine. Likewise, the key used by the remote machine to sign items you
  5904. are retrieving must be in @file{/etc/guix/acl} so it is accepted by your
  5905. own daemon. @xref{Invoking guix archive}, for more information about
  5906. store item authentication.
  5907. The general syntax is:
  5908. @example
  5909. guix copy [--to=@var{spec}|--from=@var{spec}] @var{items}@dots{}
  5910. @end example
  5911. You must always specify one of the following options:
  5912. @table @code
  5913. @item --to=@var{spec}
  5914. @itemx --from=@var{spec}
  5915. Specify the host to send to or receive from. @var{spec} must be an SSH
  5916. spec such as @code{example.org}, @code{charlie@@example.org}, or
  5917. @code{charlie@@example.org:2222}.
  5918. @end table
  5919. The @var{items} can be either package names, such as @code{gimp}, or
  5920. store items, such as @file{/gnu/store/@dots{}-idutils-4.6}.
  5921. When specifying the name of a package to send, it is first built if
  5922. needed, unless @option{--dry-run} was specified. Common build options
  5923. are supported (@pxref{Common Build Options}).
  5924. @node Invoking guix container
  5925. @section Invoking @command{guix container}
  5926. @cindex container
  5927. @cindex @command{guix container}
  5928. @quotation Note
  5929. As of version @value{VERSION}, this tool is experimental. The interface
  5930. is subject to radical change in the future.
  5931. @end quotation
  5932. The purpose of @command{guix container} is to manipulate processes
  5933. running within an isolated environment, commonly known as a
  5934. ``container'', typically created by the @command{guix environment}
  5935. (@pxref{Invoking guix environment}) and @command{guix system container}
  5936. (@pxref{Invoking guix system}) commands.
  5937. The general syntax is:
  5938. @example
  5939. guix container @var{action} @var{options}@dots{}
  5940. @end example
  5941. @var{action} specifies the operation to perform with a container, and
  5942. @var{options} specifies the context-specific arguments for the action.
  5943. The following actions are available:
  5944. @table @code
  5945. @item exec
  5946. Execute a command within the context of a running container.
  5947. The syntax is:
  5948. @example
  5949. guix container exec @var{pid} @var{program} @var{arguments}@dots{}
  5950. @end example
  5951. @var{pid} specifies the process ID of the running container.
  5952. @var{program} specifies an executable file name within the root file
  5953. system of the container. @var{arguments} are the additional options that
  5954. will be passed to @var{program}.
  5955. The following command launches an interactive login shell inside a
  5956. GuixSD container, started by @command{guix system container}, and whose
  5957. process ID is 9001:
  5958. @example
  5959. guix container exec 9001 /run/current-system/profile/bin/bash --login
  5960. @end example
  5961. Note that the @var{pid} cannot be the parent process of a container. It
  5962. must be PID 1 of the container or one of its child processes.
  5963. @end table
  5964. @node Invoking guix weather
  5965. @section Invoking @command{guix weather}
  5966. Occasionally you're grumpy because substitutes are lacking and you end
  5967. up building packages by yourself (@pxref{Substitutes}). The
  5968. @command{guix weather} command reports on substitute availability on the
  5969. specified servers so you can have an idea of whether you'll be grumpy
  5970. today. It can sometimes be useful info as a user, but it is primarily
  5971. useful to people running @command{guix publish} (@pxref{Invoking guix
  5972. publish}).
  5973. @cindex statistics, for substitutes
  5974. @cindex availability of substitutes
  5975. @cindex substitute availability
  5976. @cindex weather, substitute availability
  5977. Here's a sample run:
  5978. @example
  5979. $ guix weather --substitute-urls=https://guix.example.org
  5980. computing 5,872 package derivations for x86_64-linux...
  5981. looking for 6,128 store items on https://guix.example.org..
  5982. updating list of substitutes from 'https://guix.example.org'... 100.0%
  5983. https://guix.example.org
  5984. 43.4% substitutes available (2,658 out of 6,128)
  5985. 7,032.5 MiB of nars (compressed)
  5986. 19,824.2 MiB on disk (uncompressed)
  5987. 0.030 seconds per request (182.9 seconds in total)
  5988. 33.5 requests per second
  5989. @end example
  5990. As you can see, it reports the fraction of all the packages for which
  5991. substitutes are available on the server---regardless of whether
  5992. substitutes are enabled, and regardless of whether this server's signing
  5993. key is authorized. It also reports the size of the compressed archives
  5994. (``nars'') provided by the server, the size the corresponding store
  5995. items occupy in the store (assuming deduplication is turned off), and
  5996. the server's throughput.
  5997. To achieve that, @command{guix weather} queries over HTTP(S) meta-data
  5998. (@dfn{narinfos}) for all the relevant store items. Like @command{guix
  5999. challenge}, it ignores signatures on those substitutes, which is
  6000. innocuous since the command only gathers statistics and cannot install
  6001. those substitutes.
  6002. Among other things, it is possible to query specific system types and
  6003. specific package sets. The available options are listed below.
  6004. @table @code
  6005. @item --substitute-urls=@var{urls}
  6006. @var{urls} is the space-separated list of substitute server URLs to
  6007. query. When this option is omitted, the default set of substitute
  6008. servers is queried.
  6009. @item --system=@var{system}
  6010. @itemx -s @var{system}
  6011. Query substitutes for @var{system}---e.g., @code{aarch64-linux}. This
  6012. option can be repeated, in which case @command{guix weather} will query
  6013. substitutes for several system types.
  6014. @item --manifest=@var{file}
  6015. Instead of querying substitutes for all the packages, only ask for those
  6016. specified in @var{file}. @var{file} must contain a @dfn{manifest}, as
  6017. with the @code{-m} option of @command{guix package} (@pxref{Invoking
  6018. guix package}).
  6019. @end table
  6020. @c *********************************************************************
  6021. @node GNU Distribution
  6022. @chapter GNU Distribution
  6023. @cindex Guix System Distribution
  6024. @cindex GuixSD
  6025. Guix comes with a distribution of the GNU system consisting entirely of
  6026. free software@footnote{The term ``free'' here refers to the
  6027. @url{http://www.gnu.org/philosophy/free-sw.html,freedom provided to
  6028. users of that software}.}. The
  6029. distribution can be installed on its own (@pxref{System Installation}),
  6030. but it is also possible to install Guix as a package manager on top of
  6031. an installed GNU/Linux system (@pxref{Installation}). To distinguish
  6032. between the two, we refer to the standalone distribution as the Guix
  6033. System Distribution, or GuixSD.
  6034. The distribution provides core GNU packages such as GNU libc, GCC, and
  6035. Binutils, as well as many GNU and non-GNU applications. The complete
  6036. list of available packages can be browsed
  6037. @url{http://www.gnu.org/software/guix/packages,on-line} or by
  6038. running @command{guix package} (@pxref{Invoking guix package}):
  6039. @example
  6040. guix package --list-available
  6041. @end example
  6042. Our goal is to provide a practical 100% free software distribution of
  6043. Linux-based and other variants of GNU, with a focus on the promotion and
  6044. tight integration of GNU components, and an emphasis on programs and
  6045. tools that help users exert that freedom.
  6046. Packages are currently available on the following platforms:
  6047. @table @code
  6048. @item x86_64-linux
  6049. Intel/AMD @code{x86_64} architecture, Linux-Libre kernel;
  6050. @item i686-linux
  6051. Intel 32-bit architecture (IA32), Linux-Libre kernel;
  6052. @item armhf-linux
  6053. ARMv7-A architecture with hard float, Thumb-2 and NEON,
  6054. using the EABI hard-float application binary interface (ABI),
  6055. and Linux-Libre kernel.
  6056. @item aarch64-linux
  6057. little-endian 64-bit ARMv8-A processors, Linux-Libre kernel. This is
  6058. currently in an experimental stage, with limited support.
  6059. @xref{Contributing}, for how to help!
  6060. @item mips64el-linux
  6061. little-endian 64-bit MIPS processors, specifically the Loongson series,
  6062. n32 ABI, and Linux-Libre kernel.
  6063. @end table
  6064. GuixSD itself is currently only available on @code{i686} and @code{x86_64}.
  6065. @noindent
  6066. For information on porting to other architectures or kernels,
  6067. @pxref{Porting}.
  6068. @menu
  6069. * System Installation:: Installing the whole operating system.
  6070. * System Configuration:: Configuring the operating system.
  6071. * Documentation:: Browsing software user manuals.
  6072. * Installing Debugging Files:: Feeding the debugger.
  6073. * Security Updates:: Deploying security fixes quickly.
  6074. * Package Modules:: Packages from the programmer's viewpoint.
  6075. * Packaging Guidelines:: Growing the distribution.
  6076. * Bootstrapping:: GNU/Linux built from scratch.
  6077. * Porting:: Targeting another platform or kernel.
  6078. @end menu
  6079. Building this distribution is a cooperative effort, and you are invited
  6080. to join! @xref{Contributing}, for information about how you can help.
  6081. @node System Installation
  6082. @section System Installation
  6083. @cindex installing GuixSD
  6084. @cindex Guix System Distribution
  6085. This section explains how to install the Guix System Distribution (GuixSD)
  6086. on a machine. The Guix package manager can
  6087. also be installed on top of a running GNU/Linux system,
  6088. @pxref{Installation}.
  6089. @ifinfo
  6090. @quotation Note
  6091. @c This paragraph is for people reading this from tty2 of the
  6092. @c installation image.
  6093. You are reading this documentation with an Info reader. For details on
  6094. how to use it, hit the @key{RET} key (``return'' or ``enter'') on the
  6095. link that follows: @pxref{Top, Info reader,, info-stnd, Stand-alone GNU
  6096. Info}. Hit @kbd{l} afterwards to come back here.
  6097. Alternately, run @command{info info} in another tty to keep the manual
  6098. available.
  6099. @end quotation
  6100. @end ifinfo
  6101. @menu
  6102. * Limitations:: What you can expect.
  6103. * Hardware Considerations:: Supported hardware.
  6104. * USB Stick Installation:: Preparing the installation medium.
  6105. * DVD Installation:: Preparing the installation medium.
  6106. * Preparing for Installation:: Networking, partitioning, etc.
  6107. * Proceeding with the Installation:: The real thing.
  6108. * Installing GuixSD in a VM:: GuixSD playground.
  6109. * Building the Installation Image:: How this comes to be.
  6110. @end menu
  6111. @node Limitations
  6112. @subsection Limitations
  6113. As of version @value{VERSION}, the Guix System Distribution (GuixSD) is
  6114. not production-ready. It may contain bugs and lack important
  6115. features. Thus, if you are looking for a stable production system that
  6116. respects your freedom as a computer user, a good solution at this point
  6117. is to consider @url{http://www.gnu.org/distros/free-distros.html, one of
  6118. the more established GNU/Linux distributions}. We hope you can soon switch
  6119. to the GuixSD without fear, of course. In the meantime, you can
  6120. also keep using your distribution and try out the package manager on top
  6121. of it (@pxref{Installation}).
  6122. Before you proceed with the installation, be aware of the following
  6123. noteworthy limitations applicable to version @value{VERSION}:
  6124. @itemize
  6125. @item
  6126. The installation process does not include a graphical user interface and
  6127. requires familiarity with GNU/Linux (see the following subsections to
  6128. get a feel of what that means.)
  6129. @item
  6130. Support for the Logical Volume Manager (LVM) is missing.
  6131. @item
  6132. More and more system services are provided (@pxref{Services}), but some
  6133. may be missing.
  6134. @item
  6135. More than 5,300 packages are available, but you may
  6136. occasionally find that a useful package is missing.
  6137. @item
  6138. GNOME, Xfce, LXDE, and Enlightenment are available (@pxref{Desktop Services}),
  6139. as well as a number of X11 window managers. However, some graphical
  6140. applications may be missing, as well as KDE.
  6141. @end itemize
  6142. You have been warned! But more than a disclaimer, this is an invitation
  6143. to report issues (and success stories!), and to join us in improving it.
  6144. @xref{Contributing}, for more info.
  6145. @node Hardware Considerations
  6146. @subsection Hardware Considerations
  6147. @cindex hardware support on GuixSD
  6148. GNU@tie{}GuixSD focuses on respecting the user's computing freedom. It
  6149. builds around the kernel Linux-libre, which means that only hardware for
  6150. which free software drivers and firmware exist is supported. Nowadays,
  6151. a wide range of off-the-shelf hardware is supported on
  6152. GNU/Linux-libre---from keyboards to graphics cards to scanners and
  6153. Ethernet controllers. Unfortunately, there are still areas where
  6154. hardware vendors deny users control over their own computing, and such
  6155. hardware is not supported on GuixSD.
  6156. @cindex WiFi, hardware support
  6157. One of the main areas where free drivers or firmware are lacking is WiFi
  6158. devices. WiFi devices known to work include those using Atheros chips
  6159. (AR9271 and AR7010), which corresponds to the @code{ath9k} Linux-libre
  6160. driver, and those using Broadcom/AirForce chips (BCM43xx with
  6161. Wireless-Core Revision 5), which corresponds to the @code{b43-open}
  6162. Linux-libre driver. Free firmware exists for both and is available
  6163. out-of-the-box on GuixSD, as part of @var{%base-firmware}
  6164. (@pxref{operating-system Reference, @code{firmware}}).
  6165. @cindex RYF, Respects Your Freedom
  6166. The @uref{https://www.fsf.org/, Free Software Foundation} runs
  6167. @uref{https://www.fsf.org/ryf, @dfn{Respects Your Freedom}} (RYF), a
  6168. certification program for hardware products that respect your freedom
  6169. and your privacy and ensure that you have control over your device. We
  6170. encourage you to check the list of RYF-certified devices.
  6171. Another useful resource is the @uref{https://www.h-node.org/, H-Node}
  6172. web site. It contains a catalog of hardware devices with information
  6173. about their support in GNU/Linux.
  6174. @node USB Stick Installation
  6175. @subsection USB Stick Installation
  6176. An installation image for USB sticks can be downloaded from
  6177. @indicateurl{ftp://alpha.gnu.org/gnu/guix/guixsd-install-@value{VERSION}.@var{system}.xz},
  6178. where @var{system} is one of:
  6179. @table @code
  6180. @item x86_64-linux
  6181. for a GNU/Linux system on Intel/AMD-compatible 64-bit CPUs;
  6182. @item i686-linux
  6183. for a 32-bit GNU/Linux system on Intel-compatible CPUs.
  6184. @end table
  6185. @c start duplication of authentication part from ``Binary Installation''
  6186. Make sure to download the associated @file{.sig} file and to verify the
  6187. authenticity of the image against it, along these lines:
  6188. @example
  6189. $ wget ftp://alpha.gnu.org/gnu/guix/guixsd-install-@value{VERSION}.@var{system}.xz.sig
  6190. $ gpg --verify guixsd-install-@value{VERSION}.@var{system}.xz.sig
  6191. @end example
  6192. If that command fails because you do not have the required public key,
  6193. then run this command to import it:
  6194. @example
  6195. $ gpg --keyserver pgp.mit.edu --recv-keys @value{OPENPGP-SIGNING-KEY-ID}
  6196. @end example
  6197. @noindent
  6198. and rerun the @code{gpg --verify} command.
  6199. @c end duplication
  6200. This image contains the tools necessary for an installation.
  6201. It is meant to be copied @emph{as is} to a large-enough USB stick or DVD.
  6202. To copy the image to a USB stick, follow these steps:
  6203. @enumerate
  6204. @item
  6205. Decompress the image using the @command{xz} command:
  6206. @example
  6207. xz -d guixsd-install-@value{VERSION}.@var{system}.xz
  6208. @end example
  6209. @item
  6210. Insert a USB stick of 1@tie{}GiB or more into your machine, and determine
  6211. its device name. Assuming that the USB stick is known as @file{/dev/sdX},
  6212. copy the image with:
  6213. @example
  6214. dd if=guixsd-install-@value{VERSION}.x86_64 of=/dev/sdX
  6215. sync
  6216. @end example
  6217. Access to @file{/dev/sdX} usually requires root privileges.
  6218. @end enumerate
  6219. Once this is done, you should be able to reboot the system and boot from
  6220. the USB stick. The latter usually requires you to get in the BIOS or
  6221. UEFI boot menu, where you can choose to boot from the USB stick.
  6222. @xref{Installing GuixSD in a VM}, if, instead, you would like to install
  6223. GuixSD in a virtual machine (VM).
  6224. @node DVD Installation
  6225. @subsection DVD Installation
  6226. An installation image for DVDs can be downloaded from
  6227. @indicateurl{ftp://alpha.gnu.org/gnu/guix/guixsd-install-@value{VERSION}.@var{system}.xz},
  6228. where @var{system} is one of:
  6229. @table @code
  6230. @item x86_64-linux
  6231. for a GNU/Linux system on Intel/AMD-compatible 64-bit CPUs;
  6232. @item i686-linux
  6233. for a 32-bit GNU/Linux system on Intel-compatible CPUs.
  6234. @end table
  6235. @c start duplication of authentication part from ``Binary Installation''
  6236. Make sure to download the associated @file{.sig} file and to verify the
  6237. authenticity of the image against it, along these lines:
  6238. @example
  6239. $ wget ftp://alpha.gnu.org/gnu/guix/guixsd-install-@value{VERSION}.@var{system}.xz.sig
  6240. $ gpg --verify guixsd-install-@value{VERSION}.@var{system}.xz.sig
  6241. @end example
  6242. If that command fails because you do not have the required public key,
  6243. then run this command to import it:
  6244. @example
  6245. $ gpg --keyserver pgp.mit.edu --recv-keys @value{OPENPGP-SIGNING-KEY-ID}
  6246. @end example
  6247. @noindent
  6248. and rerun the @code{gpg --verify} command.
  6249. @c end duplication
  6250. This image contains the tools necessary for an installation.
  6251. It is meant to be copied @emph{as is} to a large-enough USB stick or DVD.
  6252. To copy the image to a DVD, follow these steps:
  6253. @enumerate
  6254. @item
  6255. Decompress the image using the @command{xz} command:
  6256. @example
  6257. xz -d guixsd-install-@value{VERSION}.@var{system}.xz
  6258. @end example
  6259. @item
  6260. Insert a blank DVD into your machine, and determine
  6261. its device name. Assuming that the DVD drive is known as @file{/dev/srX},
  6262. copy the image with:
  6263. @example
  6264. growisofs -dvd-compat -Z /dev/srX=guixsd-install-@value{VERSION}.x86_64
  6265. @end example
  6266. Access to @file{/dev/srX} usually requires root privileges.
  6267. @end enumerate
  6268. Once this is done, you should be able to reboot the system and boot from
  6269. the DVD. The latter usually requires you to get in the BIOS or
  6270. UEFI boot menu, where you can choose to boot from the DVD.
  6271. @xref{Installing GuixSD in a VM}, if, instead, you would like to install
  6272. GuixSD in a virtual machine (VM).
  6273. @node Preparing for Installation
  6274. @subsection Preparing for Installation
  6275. Once you have successfully booted your computer using the installation medium,
  6276. you should end up with a root prompt. Several console TTYs are configured
  6277. and can be used to run commands as root. TTY2 shows this documentation,
  6278. browsable using the Info reader commands (@pxref{Top,,, info-stnd,
  6279. Stand-alone GNU Info}). The installation system runs the GPM mouse
  6280. daemon, which allows you to select text with the left mouse button and
  6281. to paste it with the middle button.
  6282. @quotation Note
  6283. Installation requires access to the Internet so that any missing
  6284. dependencies of your system configuration can be downloaded. See the
  6285. ``Networking'' section below.
  6286. @end quotation
  6287. The installation system includes many common tools needed for this task.
  6288. But it is also a full-blown GuixSD system, which means that you can
  6289. install additional packages, should you need it, using @command{guix
  6290. package} (@pxref{Invoking guix package}).
  6291. @subsubsection Keyboard Layout
  6292. @cindex keyboard layout
  6293. The installation image uses the US qwerty keyboard layout. If you want
  6294. to change it, you can use the @command{loadkeys} command. For example,
  6295. the following command selects the Dvorak keyboard layout:
  6296. @example
  6297. loadkeys dvorak
  6298. @end example
  6299. See the files under @file{/run/current-system/profile/share/keymaps} for
  6300. a list of available keyboard layouts. Run @command{man loadkeys} for
  6301. more information.
  6302. @subsubsection Networking
  6303. Run the following command see what your network interfaces are called:
  6304. @example
  6305. ifconfig -a
  6306. @end example
  6307. @noindent
  6308. @dots{} or, using the GNU/Linux-specific @command{ip} command:
  6309. @example
  6310. ip a
  6311. @end example
  6312. @c http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-net_id.c#n20
  6313. Wired interfaces have a name starting with @samp{e}; for example, the
  6314. interface corresponding to the first on-board Ethernet controller is
  6315. called @samp{eno1}. Wireless interfaces have a name starting with
  6316. @samp{w}, like @samp{w1p2s0}.
  6317. @table @asis
  6318. @item Wired connection
  6319. To configure a wired network run the following command, substituting
  6320. @var{interface} with the name of the wired interface you want to use.
  6321. @example
  6322. ifconfig @var{interface} up
  6323. @end example
  6324. @item Wireless connection
  6325. @cindex wireless
  6326. @cindex WiFi
  6327. To configure wireless networking, you can create a configuration file
  6328. for the @command{wpa_supplicant} configuration tool (its location is not
  6329. important) using one of the available text editors such as
  6330. @command{zile}:
  6331. @example
  6332. zile wpa_supplicant.conf
  6333. @end example
  6334. As an example, the following stanza can go to this file and will work
  6335. for many wireless networks, provided you give the actual SSID and
  6336. passphrase for the network you are connecting to:
  6337. @example
  6338. network=@{
  6339. ssid="@var{my-ssid}"
  6340. key_mgmt=WPA-PSK
  6341. psk="the network's secret passphrase"
  6342. @}
  6343. @end example
  6344. Start the wireless service and run it in the background with the
  6345. following command (substitute @var{interface} with the name of the
  6346. network interface you want to use):
  6347. @example
  6348. wpa_supplicant -c wpa_supplicant.conf -i @var{interface} -B
  6349. @end example
  6350. Run @command{man wpa_supplicant} for more information.
  6351. @end table
  6352. @cindex DHCP
  6353. At this point, you need to acquire an IP address. On a network where IP
  6354. addresses are automatically assigned @i{via} DHCP, you can run:
  6355. @example
  6356. dhclient -v @var{interface}
  6357. @end example
  6358. Try to ping a server to see if networking is up and running:
  6359. @example
  6360. ping -c 3 gnu.org
  6361. @end example
  6362. Setting up network access is almost always a requirement because the
  6363. image does not contain all the software and tools that may be needed.
  6364. @cindex installing over SSH
  6365. If you want to, you can continue the installation remotely by starting
  6366. an SSH server:
  6367. @example
  6368. herd start ssh-daemon
  6369. @end example
  6370. Make sure to either set a password with @command{passwd}, or configure
  6371. OpenSSH public key authentication before logging in.
  6372. @subsubsection Disk Partitioning
  6373. Unless this has already been done, the next step is to partition, and
  6374. then format the target partition(s).
  6375. The installation image includes several partitioning tools, including
  6376. Parted (@pxref{Overview,,, parted, GNU Parted User Manual}),
  6377. @command{fdisk}, and @command{cfdisk}. Run it and set up your disk with
  6378. the partition layout you want:
  6379. @example
  6380. cfdisk
  6381. @end example
  6382. If your disk uses the GUID Partition Table (GPT) format and you plan to
  6383. install BIOS-based GRUB (which is the default), make sure a BIOS Boot
  6384. Partition is available (@pxref{BIOS installation,,, grub, GNU GRUB
  6385. manual}).
  6386. @cindex EFI, installation
  6387. @cindex UEFI, installation
  6388. @cindex ESP, EFI system partition
  6389. If you instead wish to use EFI-based GRUB, a FAT32 @dfn{EFI System Partition}
  6390. (ESP) is required. This partition should be mounted at @file{/boot/efi} and
  6391. must have the @code{esp} flag set. E.g., for @command{parted}:
  6392. @example
  6393. parted /dev/sda set 1 esp on
  6394. @end example
  6395. Once you are done partitioning the target hard disk drive, you have to
  6396. create a file system on the relevant partition(s)@footnote{Currently
  6397. GuixSD only supports ext4 and btrfs file systems. In particular, code
  6398. that reads partition UUIDs and labels only works for these file system
  6399. types.}. For the ESP, if you have one and assuming it is
  6400. @file{/dev/sda2}, run:
  6401. @example
  6402. mkfs.fat -F32 /dev/sda2
  6403. @end example
  6404. Preferably, assign partitions a label so that you can easily and
  6405. reliably refer to them in @code{file-system} declarations (@pxref{File
  6406. Systems}). This is typically done using the @code{-L} option of
  6407. @command{mkfs.ext4} and related commands. So, assuming the target root
  6408. partition lives at @file{/dev/sda1}, a file system with the label
  6409. @code{my-root} can be created with:
  6410. @example
  6411. mkfs.ext4 -L my-root /dev/sda1
  6412. @end example
  6413. @cindex encrypted disk
  6414. If you are instead planning to encrypt the root partition, you can use
  6415. the Cryptsetup/LUKS utilities to do that (see @inlinefmtifelse{html,
  6416. @uref{https://linux.die.net/man/8/cryptsetup, @code{man cryptsetup}},
  6417. @code{man cryptsetup}} for more information.) Assuming you want to
  6418. store the root partition on @file{/dev/sda1}, the command sequence would
  6419. be along these lines:
  6420. @example
  6421. cryptsetup luksFormat /dev/sda1
  6422. cryptsetup open --type luks /dev/sda1 my-partition
  6423. mkfs.ext4 -L my-root /dev/mapper/my-partition
  6424. @end example
  6425. Once that is done, mount the target root partition under @file{/mnt}
  6426. with a command like (again, assuming @code{my-root} is the label of the
  6427. root partition):
  6428. @example
  6429. mount LABEL=my-root /mnt
  6430. @end example
  6431. Also mount any other partitions you would like to use on the target
  6432. system relative to this path. If you have @file{/boot} on a separate
  6433. partition for example, mount it at @file{/mnt/boot} now so it is found
  6434. by @code{guix system init} afterwards.
  6435. Finally, if you plan to use one or more swap partitions (@pxref{Memory
  6436. Concepts, swap space,, libc, The GNU C Library Reference Manual}), make
  6437. sure to initialize them with @command{mkswap}. Assuming you have one
  6438. swap partition on @file{/dev/sda2}, you would run:
  6439. @example
  6440. mkswap /dev/sda2
  6441. swapon /dev/sda2
  6442. @end example
  6443. Alternatively, you may use a swap file. For example, assuming that in
  6444. the new system you want to use the file @file{/swapfile} as a swap file,
  6445. you would run@footnote{This example will work for many types of file
  6446. systems (e.g., ext4). However, for copy-on-write file systems (e.g.,
  6447. btrfs), the required steps may be different. For details, see the
  6448. manual pages for @command{mkswap} and @command{swapon}.}:
  6449. @example
  6450. # This is 10 GiB of swap space. Adjust "count" to change the size.
  6451. dd if=/dev/zero of=/mnt/swapfile bs=1MiB count=10240
  6452. # For security, make the file readable and writable only by root.
  6453. chmod 600 /mnt/swapfile
  6454. mkswap /mnt/swapfile
  6455. swapon /mnt/swapfile
  6456. @end example
  6457. Note that if you have encrypted the root partition and created a swap
  6458. file in its file system as described above, then the encryption also
  6459. protects the swap file, just like any other file in that file system.
  6460. @node Proceeding with the Installation
  6461. @subsection Proceeding with the Installation
  6462. With the target partitions ready and the target root mounted on
  6463. @file{/mnt}, we're ready to go. First, run:
  6464. @example
  6465. herd start cow-store /mnt
  6466. @end example
  6467. This makes @file{/gnu/store} copy-on-write, such that packages added to it
  6468. during the installation phase are written to the target disk on @file{/mnt}
  6469. rather than kept in memory. This is necessary because the first phase of
  6470. the @command{guix system init} command (see below) entails downloads or
  6471. builds to @file{/gnu/store} which, initially, is an in-memory file system.
  6472. Next, you have to edit a file and
  6473. provide the declaration of the operating system to be installed. To
  6474. that end, the installation system comes with three text editors: GNU nano
  6475. (@pxref{Top,,, nano, GNU nano Manual}), GNU Zile (an Emacs clone), and
  6476. nvi (a clone of the original BSD @command{vi} editor).
  6477. We strongly recommend storing that file on the target root file system, say,
  6478. as @file{/mnt/etc/config.scm}. Failing to do that, you will have lost your
  6479. configuration file once you have rebooted into the newly-installed system.
  6480. @xref{Using the Configuration System}, for an overview of the
  6481. configuration file. The example configurations discussed in that
  6482. section are available under @file{/etc/configuration} in the
  6483. installation image. Thus, to get started with a system configuration
  6484. providing a graphical display server (a ``desktop'' system), you can run
  6485. something along these lines:
  6486. @example
  6487. # mkdir /mnt/etc
  6488. # cp /etc/configuration/desktop.scm /mnt/etc/config.scm
  6489. # zile /mnt/etc/config.scm
  6490. @end example
  6491. You should pay attention to what your configuration file contains, and
  6492. in particular:
  6493. @itemize
  6494. @item
  6495. Make sure the @code{grub-configuration} form refers to the target you
  6496. want to install GRUB on. It should mention @code{grub-bootloader} if
  6497. you are installing GRUB in the legacy way, or @code{grub-efi-bootloader}
  6498. for newer UEFI systems. For legacy systems, the @code{target} field
  6499. names a device, like @code{/dev/sda}; for UEFI systems it names a path
  6500. to a mounted EFI partition, like @code{/boot/efi}, and do make sure the
  6501. path is actually mounted.
  6502. @item
  6503. Be sure that your partition labels match the value of their respective
  6504. @code{device} fields in your @code{file-system} configuration, assuming
  6505. your @code{file-system} configuration sets the value of @code{title} to
  6506. @code{'label}.
  6507. @item
  6508. If there are encrypted or RAID partitions, make sure to add a
  6509. @code{mapped-devices} field to describe them (@pxref{Mapped Devices}).
  6510. @end itemize
  6511. Once you are done preparing the configuration file, the new system must
  6512. be initialized (remember that the target root file system is mounted
  6513. under @file{/mnt}):
  6514. @example
  6515. guix system init /mnt/etc/config.scm /mnt
  6516. @end example
  6517. @noindent
  6518. This copies all the necessary files and installs GRUB on
  6519. @file{/dev/sdX}, unless you pass the @option{--no-bootloader} option. For
  6520. more information, @pxref{Invoking guix system}. This command may trigger
  6521. downloads or builds of missing packages, which can take some time.
  6522. Once that command has completed---and hopefully succeeded!---you can run
  6523. @command{reboot} and boot into the new system. The @code{root} password
  6524. in the new system is initially empty; other users' passwords need to be
  6525. initialized by running the @command{passwd} command as @code{root},
  6526. unless your configuration specifies otherwise
  6527. (@pxref{user-account-password, user account passwords}).
  6528. @cindex upgrading GuixSD
  6529. From then on, you can update GuixSD whenever you want by running
  6530. @command{guix pull} as @code{root} (@pxref{Invoking guix pull}), and
  6531. then running @command{guix system reconfigure} to build a new system
  6532. generation with the latest packages and services (@pxref{Invoking guix
  6533. system}). We recommend doing that regularly so that your system
  6534. includes the latest security updates (@pxref{Security Updates}).
  6535. Join us on @code{#guix} on the Freenode IRC network or on
  6536. @file{guix-devel@@gnu.org} to share your experience---good or not so
  6537. good.
  6538. @node Installing GuixSD in a VM
  6539. @subsection Installing GuixSD in a Virtual Machine
  6540. @cindex virtual machine, GuixSD installation
  6541. @cindex virtual private server (VPS)
  6542. @cindex VPS (virtual private server)
  6543. If you'd like to install GuixSD in a virtual machine (VM) or on a
  6544. virtual private server (VPS) rather than on your beloved machine, this
  6545. section is for you.
  6546. To boot a @uref{http://qemu.org/,QEMU} VM for installing GuixSD in a
  6547. disk image, follow these steps:
  6548. @enumerate
  6549. @item
  6550. First, retrieve and decompress the GuixSD installation image as
  6551. described previously (@pxref{USB Stick Installation}).
  6552. @item
  6553. Create a disk image that will hold the installed system. To make a
  6554. qcow2-formatted disk image, use the @command{qemu-img} command:
  6555. @example
  6556. qemu-img create -f qcow2 guixsd.img 50G
  6557. @end example
  6558. The resulting file will be much smaller than 50 GB (typically less than
  6559. 1 MB), but it will grow as the virtualized storage device is filled up.
  6560. @item
  6561. Boot the USB installation image in an VM:
  6562. @example
  6563. qemu-system-x86_64 -m 1024 -smp 1 \
  6564. -net user -net nic,model=virtio -boot menu=on \
  6565. -drive file=guixsd-install-@value{VERSION}.@var{system} \
  6566. -drive file=guixsd.img
  6567. @end example
  6568. The ordering of the drives matters.
  6569. In the VM console, quickly press the @kbd{F12} key to enter the boot
  6570. menu. Then press the @kbd{2} key and the @kbd{RET} key to validate your
  6571. selection.
  6572. @item
  6573. You're now root in the VM, proceed with the installation process.
  6574. @xref{Preparing for Installation}, and follow the instructions.
  6575. @end enumerate
  6576. Once installation is complete, you can boot the system that's on your
  6577. @file{guixsd.img} image. @xref{Running GuixSD in a VM}, for how to do
  6578. that.
  6579. @node Building the Installation Image
  6580. @subsection Building the Installation Image
  6581. @cindex installation image
  6582. The installation image described above was built using the @command{guix
  6583. system} command, specifically:
  6584. @example
  6585. guix system disk-image gnu/system/install.scm
  6586. @end example
  6587. Have a look at @file{gnu/system/install.scm} in the source tree,
  6588. and see also @ref{Invoking guix system} for more information
  6589. about the installation image.
  6590. @node System Configuration
  6591. @section System Configuration
  6592. @cindex system configuration
  6593. The Guix System Distribution supports a consistent whole-system configuration
  6594. mechanism. By that we mean that all aspects of the global system
  6595. configuration---such as the available system services, timezone and
  6596. locale settings, user accounts---are declared in a single place. Such
  6597. a @dfn{system configuration} can be @dfn{instantiated}---i.e., effected.
  6598. One of the advantages of putting all the system configuration under the
  6599. control of Guix is that it supports transactional system upgrades, and
  6600. makes it possible to roll back to a previous system instantiation,
  6601. should something go wrong with the new one (@pxref{Features}). Another
  6602. advantage is that it makes it easy to replicate the exact same configuration
  6603. across different machines, or at different points in time, without
  6604. having to resort to additional administration tools layered on top of
  6605. the own tools of the system.
  6606. @c Yes, we're talking of Puppet, Chef, & co. here. ↑
  6607. This section describes this mechanism. First we focus on the system
  6608. administrator's viewpoint---explaining how the system is configured and
  6609. instantiated. Then we show how this mechanism can be extended, for
  6610. instance to support new system services.
  6611. @menu
  6612. * Using the Configuration System:: Customizing your GNU system.
  6613. * operating-system Reference:: Detail of operating-system declarations.
  6614. * File Systems:: Configuring file system mounts.
  6615. * Mapped Devices:: Block device extra processing.
  6616. * User Accounts:: Specifying user accounts.
  6617. * Locales:: Language and cultural convention settings.
  6618. * Services:: Specifying system services.
  6619. * Setuid Programs:: Programs running with root privileges.
  6620. * X.509 Certificates:: Authenticating HTTPS servers.
  6621. * Name Service Switch:: Configuring libc's name service switch.
  6622. * Initial RAM Disk:: Linux-Libre bootstrapping.
  6623. * Bootloader Configuration:: Configuring the boot loader.
  6624. * Invoking guix system:: Instantiating a system configuration.
  6625. * Running GuixSD in a VM:: How to run GuixSD in a virtual machine.
  6626. * Defining Services:: Adding new service definitions.
  6627. @end menu
  6628. @node Using the Configuration System
  6629. @subsection Using the Configuration System
  6630. The operating system is configured by providing an
  6631. @code{operating-system} declaration in a file that can then be passed to
  6632. the @command{guix system} command (@pxref{Invoking guix system}). A
  6633. simple setup, with the default system services, the default Linux-Libre
  6634. kernel, initial RAM disk, and boot loader looks like this:
  6635. @findex operating-system
  6636. @lisp
  6637. @include os-config-bare-bones.texi
  6638. @end lisp
  6639. This example should be self-describing. Some of the fields defined
  6640. above, such as @code{host-name} and @code{bootloader}, are mandatory.
  6641. Others, such as @code{packages} and @code{services}, can be omitted, in
  6642. which case they get a default value.
  6643. Below we discuss the effect of some of the most important fields
  6644. (@pxref{operating-system Reference}, for details about all the available
  6645. fields), and how to @dfn{instantiate} the operating system using
  6646. @command{guix system}.
  6647. @unnumberedsubsubsec Globally-Visible Packages
  6648. @vindex %base-packages
  6649. The @code{packages} field lists packages that will be globally visible
  6650. on the system, for all user accounts---i.e., in every user's @code{PATH}
  6651. environment variable---in addition to the per-user profiles
  6652. (@pxref{Invoking guix package}). The @var{%base-packages} variable
  6653. provides all the tools one would expect for basic user and administrator
  6654. tasks---including the GNU Core Utilities, the GNU Networking Utilities,
  6655. the GNU Zile lightweight text editor, @command{find}, @command{grep},
  6656. etc. The example above adds GNU@tie{}Screen and OpenSSH to those,
  6657. taken from the @code{(gnu packages screen)} and @code{(gnu packages ssh)}
  6658. modules (@pxref{Package Modules}). The
  6659. @code{(list package output)} syntax can be used to add a specific output
  6660. of a package:
  6661. @lisp
  6662. (use-modules (gnu packages))
  6663. (use-modules (gnu packages dns))
  6664. (operating-system
  6665. ;; ...
  6666. (packages (cons (list bind "utils")
  6667. %base-packages)))
  6668. @end lisp
  6669. @findex specification->package
  6670. Referring to packages by variable name, like @var{tcpdump} above, has
  6671. the advantage of being unambiguous; it also allows typos and such to be
  6672. diagnosed right away as ``unbound variables''. The downside is that one
  6673. needs to know which module defines which package, and to augment the
  6674. @code{use-package-modules} line accordingly. To avoid that, one can use
  6675. the @code{specification->package} procedure of the @code{(gnu packages)}
  6676. module, which returns the best package for a given name or name and
  6677. version:
  6678. @lisp
  6679. (use-modules (gnu packages))
  6680. (operating-system
  6681. ;; ...
  6682. (packages (append (map specification->package
  6683. '("tcpdump" "htop" "gnupg@@2.0"))
  6684. %base-packages)))
  6685. @end lisp
  6686. @unnumberedsubsubsec System Services
  6687. @cindex services
  6688. @vindex %base-services
  6689. The @code{services} field lists @dfn{system services} to be made
  6690. available when the system starts (@pxref{Services}).
  6691. The @code{operating-system} declaration above specifies that, in
  6692. addition to the basic services, we want the @command{lshd} secure shell
  6693. daemon listening on port 2222 (@pxref{Networking Services,
  6694. @code{lsh-service}}). Under the hood,
  6695. @code{lsh-service} arranges so that @code{lshd} is started with the
  6696. right command-line options, possibly with supporting configuration files
  6697. generated as needed (@pxref{Defining Services}).
  6698. @cindex customization, of services
  6699. @findex modify-services
  6700. Occasionally, instead of using the base services as is, you will want to
  6701. customize them. To do this, use @code{modify-services} (@pxref{Service
  6702. Reference, @code{modify-services}}) to modify the list.
  6703. For example, suppose you want to modify @code{guix-daemon} and Mingetty
  6704. (the console log-in) in the @var{%base-services} list (@pxref{Base
  6705. Services, @code{%base-services}}). To do that, you can write the
  6706. following in your operating system declaration:
  6707. @lisp
  6708. (define %my-services
  6709. ;; My very own list of services.
  6710. (modify-services %base-services
  6711. (guix-service-type config =>
  6712. (guix-configuration
  6713. (inherit config)
  6714. (use-substitutes? #f)
  6715. (extra-options '("--gc-keep-derivations"))))
  6716. (mingetty-service-type config =>
  6717. (mingetty-configuration
  6718. (inherit config)))))
  6719. (operating-system
  6720. ;; @dots{}
  6721. (services %my-services))
  6722. @end lisp
  6723. This changes the configuration---i.e., the service parameters---of the
  6724. @code{guix-service-type} instance, and that of all the
  6725. @code{mingetty-service-type} instances in the @var{%base-services} list.
  6726. Observe how this is accomplished: first, we arrange for the original
  6727. configuration to be bound to the identifier @code{config} in the
  6728. @var{body}, and then we write the @var{body} so that it evaluates to the
  6729. desired configuration. In particular, notice how we use @code{inherit}
  6730. to create a new configuration which has the same values as the old
  6731. configuration, but with a few modifications.
  6732. @cindex encrypted disk
  6733. The configuration for a typical ``desktop'' usage, with an encrypted
  6734. root partition, the X11 display
  6735. server, GNOME and Xfce (users can choose which of these desktop
  6736. environments to use at the log-in screen by pressing @kbd{F1}), network
  6737. management, power management, and more, would look like this:
  6738. @lisp
  6739. @include os-config-desktop.texi
  6740. @end lisp
  6741. A graphical UEFI system with a choice of lightweight window managers
  6742. instead of full-blown desktop environments would look like this:
  6743. @lisp
  6744. @include os-config-lightweight-desktop.texi
  6745. @end lisp
  6746. @xref{Desktop Services}, for the exact list of services provided by
  6747. @var{%desktop-services}. @xref{X.509 Certificates}, for background
  6748. information about the @code{nss-certs} package that is used here.
  6749. Again, @var{%desktop-services} is just a list of service objects. If
  6750. you want to remove services from there, you can do so using the
  6751. procedures for list filtering (@pxref{SRFI-1 Filtering and
  6752. Partitioning,,, guile, GNU Guile Reference Manual}). For instance, the
  6753. following expression returns a list that contains all the services in
  6754. @var{%desktop-services} minus the Avahi service:
  6755. @example
  6756. (remove (lambda (service)
  6757. (eq? (service-kind service) avahi-service-type))
  6758. %desktop-services)
  6759. @end example
  6760. @unnumberedsubsubsec Instantiating the System
  6761. Assuming the @code{operating-system} declaration
  6762. is stored in the @file{my-system-config.scm}
  6763. file, the @command{guix system reconfigure my-system-config.scm} command
  6764. instantiates that configuration, and makes it the default GRUB boot
  6765. entry (@pxref{Invoking guix system}).
  6766. The normal way to change the system configuration is by updating this
  6767. file and re-running @command{guix system reconfigure}. One should never
  6768. have to touch files in @file{/etc} or to run commands that modify the
  6769. system state such as @command{useradd} or @command{grub-install}. In
  6770. fact, you must avoid that since that would not only void your warranty
  6771. but also prevent you from rolling back to previous versions of your
  6772. system, should you ever need to.
  6773. @cindex roll-back, of the operating system
  6774. Speaking of roll-back, each time you run @command{guix system
  6775. reconfigure}, a new @dfn{generation} of the system is created---without
  6776. modifying or deleting previous generations. Old system generations get
  6777. an entry in the bootloader boot menu, allowing you to boot them in case
  6778. something went wrong with the latest generation. Reassuring, no? The
  6779. @command{guix system list-generations} command lists the system
  6780. generations available on disk. It is also possible to roll back the
  6781. system via the commands @command{guix system roll-back} and
  6782. @command{guix system switch-generation}.
  6783. Although the command @command{guix system reconfigure} will not modify
  6784. previous generations, must take care when the current generation is not
  6785. the latest (e.g., after invoking @command{guix system roll-back}), since
  6786. the operation might overwrite a later generation (@pxref{Invoking guix
  6787. system}).
  6788. @unnumberedsubsubsec The Programming Interface
  6789. At the Scheme level, the bulk of an @code{operating-system} declaration
  6790. is instantiated with the following monadic procedure (@pxref{The Store
  6791. Monad}):
  6792. @deffn {Monadic Procedure} operating-system-derivation os
  6793. Return a derivation that builds @var{os}, an @code{operating-system}
  6794. object (@pxref{Derivations}).
  6795. The output of the derivation is a single directory that refers to all
  6796. the packages, configuration files, and other supporting files needed to
  6797. instantiate @var{os}.
  6798. @end deffn
  6799. This procedure is provided by the @code{(gnu system)} module. Along
  6800. with @code{(gnu services)} (@pxref{Services}), this module contains the
  6801. guts of GuixSD. Make sure to visit it!
  6802. @node operating-system Reference
  6803. @subsection @code{operating-system} Reference
  6804. This section summarizes all the options available in
  6805. @code{operating-system} declarations (@pxref{Using the Configuration
  6806. System}).
  6807. @deftp {Data Type} operating-system
  6808. This is the data type representing an operating system configuration.
  6809. By that, we mean all the global system configuration, not per-user
  6810. configuration (@pxref{Using the Configuration System}).
  6811. @table @asis
  6812. @item @code{kernel} (default: @var{linux-libre})
  6813. The package object of the operating system kernel to use@footnote{Currently
  6814. only the Linux-libre kernel is supported. In the future, it will be
  6815. possible to use the GNU@tie{}Hurd.}.
  6816. @item @code{kernel-arguments} (default: @code{'()})
  6817. List of strings or gexps representing additional arguments to pass on
  6818. the command-line of the kernel---e.g., @code{("console=ttyS0")}.
  6819. @item @code{bootloader}
  6820. The system bootloader configuration object. @xref{Bootloader Configuration}.
  6821. @item @code{initrd} (default: @code{base-initrd})
  6822. @cindex initrd
  6823. @cindex initial RAM disk
  6824. A two-argument monadic procedure that returns an initial RAM disk for
  6825. the Linux kernel. @xref{Initial RAM Disk}.
  6826. @item @code{firmware} (default: @var{%base-firmware})
  6827. @cindex firmware
  6828. List of firmware packages loadable by the operating system kernel.
  6829. The default includes firmware needed for Atheros- and Broadcom-based
  6830. WiFi devices (Linux-libre modules @code{ath9k} and @code{b43-open},
  6831. respectively). @xref{Hardware Considerations}, for more info on
  6832. supported hardware.
  6833. @item @code{host-name}
  6834. The host name.
  6835. @item @code{hosts-file}
  6836. @cindex hosts file
  6837. A file-like object (@pxref{G-Expressions, file-like objects}) for use as
  6838. @file{/etc/hosts} (@pxref{Host Names,,, libc, The GNU C Library
  6839. Reference Manual}). The default is a file with entries for
  6840. @code{localhost} and @var{host-name}.
  6841. @item @code{mapped-devices} (default: @code{'()})
  6842. A list of mapped devices. @xref{Mapped Devices}.
  6843. @item @code{file-systems}
  6844. A list of file systems. @xref{File Systems}.
  6845. @item @code{swap-devices} (default: @code{'()})
  6846. @cindex swap devices
  6847. A list of strings identifying devices or files to be used for ``swap
  6848. space'' (@pxref{Memory Concepts,,, libc, The GNU C Library Reference
  6849. Manual}). For example, @code{'("/dev/sda3")} or @code{'("/swapfile")}.
  6850. It is possible to specify a swap file in a file system on a mapped
  6851. device, provided that the necessary device mapping and file system are
  6852. also specified. @xref{Mapped Devices} and @ref{File Systems}.
  6853. @item @code{users} (default: @code{%base-user-accounts})
  6854. @itemx @code{groups} (default: @var{%base-groups})
  6855. List of user accounts and groups. @xref{User Accounts}.
  6856. @item @code{skeletons} (default: @code{(default-skeletons)})
  6857. A list target file name/file-like object tuples (@pxref{G-Expressions,
  6858. file-like objects}). These are the skeleton files that will be added to
  6859. the home directory of newly-created user accounts.
  6860. For instance, a valid value may look like this:
  6861. @example
  6862. `((".bashrc" ,(plain-file "bashrc" "echo Hello\n"))
  6863. (".guile" ,(plain-file "guile"
  6864. "(use-modules (ice-9 readline))
  6865. (activate-readline)")))
  6866. @end example
  6867. @item @code{issue} (default: @var{%default-issue})
  6868. A string denoting the contents of the @file{/etc/issue} file, which is
  6869. displayed when users log in on a text console.
  6870. @item @code{packages} (default: @var{%base-packages})
  6871. The set of packages installed in the global profile, which is accessible
  6872. at @file{/run/current-system/profile}.
  6873. The default set includes core utilities and it is good practice to
  6874. install non-core utilities in user profiles (@pxref{Invoking guix
  6875. package}).
  6876. @item @code{timezone}
  6877. A timezone identifying string---e.g., @code{"Europe/Paris"}.
  6878. You can run the @command{tzselect} command to find out which timezone
  6879. string corresponds to your region. Choosing an invalid timezone name
  6880. causes @command{guix system} to fail.
  6881. @item @code{locale} (default: @code{"en_US.utf8"})
  6882. The name of the default locale (@pxref{Locale Names,,, libc, The GNU C
  6883. Library Reference Manual}). @xref{Locales}, for more information.
  6884. @item @code{locale-definitions} (default: @var{%default-locale-definitions})
  6885. The list of locale definitions to be compiled and that may be used at
  6886. run time. @xref{Locales}.
  6887. @item @code{locale-libcs} (default: @code{(list @var{glibc})})
  6888. The list of GNU@tie{}libc packages whose locale data and tools are used
  6889. to build the locale definitions. @xref{Locales}, for compatibility
  6890. considerations that justify this option.
  6891. @item @code{name-service-switch} (default: @var{%default-nss})
  6892. Configuration of the libc name service switch (NSS)---a
  6893. @code{<name-service-switch>} object. @xref{Name Service Switch}, for
  6894. details.
  6895. @item @code{services} (default: @var{%base-services})
  6896. A list of service objects denoting system services. @xref{Services}.
  6897. @item @code{pam-services} (default: @code{(base-pam-services)})
  6898. @cindex PAM
  6899. @cindex pluggable authentication modules
  6900. Linux @dfn{pluggable authentication module} (PAM) services.
  6901. @c FIXME: Add xref to PAM services section.
  6902. @item @code{setuid-programs} (default: @var{%setuid-programs})
  6903. List of string-valued G-expressions denoting setuid programs.
  6904. @xref{Setuid Programs}.
  6905. @item @code{sudoers-file} (default: @var{%sudoers-specification})
  6906. @cindex sudoers file
  6907. The contents of the @file{/etc/sudoers} file as a file-like object
  6908. (@pxref{G-Expressions, @code{local-file} and @code{plain-file}}).
  6909. This file specifies which users can use the @command{sudo} command, what
  6910. they are allowed to do, and what privileges they may gain. The default
  6911. is that only @code{root} and members of the @code{wheel} group may use
  6912. @code{sudo}.
  6913. @end table
  6914. @end deftp
  6915. @node File Systems
  6916. @subsection File Systems
  6917. The list of file systems to be mounted is specified in the
  6918. @code{file-systems} field of the operating system declaration
  6919. (@pxref{Using the Configuration System}). Each file system is declared
  6920. using the @code{file-system} form, like this:
  6921. @example
  6922. (file-system
  6923. (mount-point "/home")
  6924. (device "/dev/sda3")
  6925. (type "ext4"))
  6926. @end example
  6927. As usual, some of the fields are mandatory---those shown in the example
  6928. above---while others can be omitted. These are described below.
  6929. @deftp {Data Type} file-system
  6930. Objects of this type represent file systems to be mounted. They
  6931. contain the following members:
  6932. @table @asis
  6933. @item @code{type}
  6934. This is a string specifying the type of the file system---e.g.,
  6935. @code{"ext4"}.
  6936. @item @code{mount-point}
  6937. This designates the place where the file system is to be mounted.
  6938. @item @code{device}
  6939. This names the ``source'' of the file system. By default it is the name
  6940. of a node under @file{/dev}, but its meaning depends on the @code{title}
  6941. field described below.
  6942. @item @code{title} (default: @code{'device})
  6943. This is a symbol that specifies how the @code{device} field is to be
  6944. interpreted.
  6945. When it is the symbol @code{device}, then the @code{device} field is
  6946. interpreted as a file name; when it is @code{label}, then @code{device}
  6947. is interpreted as a partition label name; when it is @code{uuid},
  6948. @code{device} is interpreted as a partition unique identifier (UUID).
  6949. UUIDs may be converted from their string representation (as shown by the
  6950. @command{tune2fs -l} command) using the @code{uuid} form@footnote{The
  6951. @code{uuid} form expects 16-byte UUIDs as defined in
  6952. @uref{https://tools.ietf.org/html/rfc4122, RFC@tie{}4122}. This is the
  6953. form of UUID used by the ext2 family of file systems and others, but it
  6954. is different from ``UUIDs'' found in FAT file systems, for instance.},
  6955. like this:
  6956. @example
  6957. (file-system
  6958. (mount-point "/home")
  6959. (type "ext4")
  6960. (title 'uuid)
  6961. (device (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb")))
  6962. @end example
  6963. The @code{label} and @code{uuid} options offer a way to refer to disk
  6964. partitions without having to hard-code their actual device
  6965. name@footnote{Note that, while it is tempting to use
  6966. @file{/dev/disk/by-uuid} and similar device names to achieve the same
  6967. result, this is not recommended: These special device nodes are created
  6968. by the udev daemon and may be unavailable at the time the device is
  6969. mounted.}.
  6970. However, when the source of a file system is a mapped device (@pxref{Mapped
  6971. Devices}), its @code{device} field @emph{must} refer to the mapped
  6972. device name---e.g., @file{/dev/mapper/root-partition}---and consequently
  6973. @code{title} must be set to @code{'device}. This is required so that
  6974. the system knows that mounting the file system depends on having the
  6975. corresponding device mapping established.
  6976. @item @code{flags} (default: @code{'()})
  6977. This is a list of symbols denoting mount flags. Recognized flags
  6978. include @code{read-only}, @code{bind-mount}, @code{no-dev} (disallow
  6979. access to special files), @code{no-suid} (ignore setuid and setgid
  6980. bits), and @code{no-exec} (disallow program execution.)
  6981. @item @code{options} (default: @code{#f})
  6982. This is either @code{#f}, or a string denoting mount options.
  6983. @item @code{mount?} (default: @code{#t})
  6984. This value indicates whether to automatically mount the file system when
  6985. the system is brought up. When set to @code{#f}, the file system gets
  6986. an entry in @file{/etc/fstab} (read by the @command{mount} command) but
  6987. is not automatically mounted.
  6988. @item @code{needed-for-boot?} (default: @code{#f})
  6989. This Boolean value indicates whether the file system is needed when
  6990. booting. If that is true, then the file system is mounted when the
  6991. initial RAM disk (initrd) is loaded. This is always the case, for
  6992. instance, for the root file system.
  6993. @item @code{check?} (default: @code{#t})
  6994. This Boolean indicates whether the file system needs to be checked for
  6995. errors before being mounted.
  6996. @item @code{create-mount-point?} (default: @code{#f})
  6997. When true, the mount point is created if it does not exist yet.
  6998. @item @code{dependencies} (default: @code{'()})
  6999. This is a list of @code{<file-system>} or @code{<mapped-device>} objects
  7000. representing file systems that must be mounted or mapped devices that
  7001. must be opened before (and unmounted or closed after) this one.
  7002. As an example, consider a hierarchy of mounts: @file{/sys/fs/cgroup} is
  7003. a dependency of @file{/sys/fs/cgroup/cpu} and
  7004. @file{/sys/fs/cgroup/memory}.
  7005. Another example is a file system that depends on a mapped device, for
  7006. example for an encrypted partition (@pxref{Mapped Devices}).
  7007. @end table
  7008. @end deftp
  7009. The @code{(gnu system file-systems)} exports the following useful
  7010. variables.
  7011. @defvr {Scheme Variable} %base-file-systems
  7012. These are essential file systems that are required on normal systems,
  7013. such as @var{%pseudo-terminal-file-system} and @var{%immutable-store} (see
  7014. below.) Operating system declarations should always contain at least
  7015. these.
  7016. @end defvr
  7017. @defvr {Scheme Variable} %pseudo-terminal-file-system
  7018. This is the file system to be mounted as @file{/dev/pts}. It supports
  7019. @dfn{pseudo-terminals} created @i{via} @code{openpty} and similar
  7020. functions (@pxref{Pseudo-Terminals,,, libc, The GNU C Library Reference
  7021. Manual}). Pseudo-terminals are used by terminal emulators such as
  7022. @command{xterm}.
  7023. @end defvr
  7024. @defvr {Scheme Variable} %shared-memory-file-system
  7025. This file system is mounted as @file{/dev/shm} and is used to support
  7026. memory sharing across processes (@pxref{Memory-mapped I/O,
  7027. @code{shm_open},, libc, The GNU C Library Reference Manual}).
  7028. @end defvr
  7029. @defvr {Scheme Variable} %immutable-store
  7030. This file system performs a read-only ``bind mount'' of
  7031. @file{/gnu/store}, making it read-only for all the users including
  7032. @code{root}. This prevents against accidental modification by software
  7033. running as @code{root} or by system administrators.
  7034. The daemon itself is still able to write to the store: it remounts it
  7035. read-write in its own ``name space.''
  7036. @end defvr
  7037. @defvr {Scheme Variable} %binary-format-file-system
  7038. The @code{binfmt_misc} file system, which allows handling of arbitrary
  7039. executable file types to be delegated to user space. This requires the
  7040. @code{binfmt.ko} kernel module to be loaded.
  7041. @end defvr
  7042. @defvr {Scheme Variable} %fuse-control-file-system
  7043. The @code{fusectl} file system, which allows unprivileged users to mount
  7044. and unmount user-space FUSE file systems. This requires the
  7045. @code{fuse.ko} kernel module to be loaded.
  7046. @end defvr
  7047. @node Mapped Devices
  7048. @subsection Mapped Devices
  7049. @cindex device mapping
  7050. @cindex mapped devices
  7051. The Linux kernel has a notion of @dfn{device mapping}: a block device,
  7052. such as a hard disk partition, can be @dfn{mapped} into another device,
  7053. usually in @code{/dev/mapper/},
  7054. with additional processing over the data that flows through
  7055. it@footnote{Note that the GNU@tie{}Hurd makes no difference between the
  7056. concept of a ``mapped device'' and that of a file system: both boil down
  7057. to @emph{translating} input/output operations made on a file to
  7058. operations on its backing store. Thus, the Hurd implements mapped
  7059. devices, like file systems, using the generic @dfn{translator} mechanism
  7060. (@pxref{Translators,,, hurd, The GNU Hurd Reference Manual}).}. A
  7061. typical example is encryption device mapping: all writes to the mapped
  7062. device are encrypted, and all reads are deciphered, transparently.
  7063. Guix extends this notion by considering any device or set of devices that
  7064. are @dfn{transformed} in some way to create a new device; for instance,
  7065. RAID devices are obtained by @dfn{assembling} several other devices, such
  7066. as hard disks or partitions, into a new one that behaves as one partition.
  7067. Other examples, not yet implemented, are LVM logical volumes.
  7068. Mapped devices are declared using the @code{mapped-device} form,
  7069. defined as follows; for examples, see below.
  7070. @deftp {Data Type} mapped-device
  7071. Objects of this type represent device mappings that will be made when
  7072. the system boots up.
  7073. @table @code
  7074. @item source
  7075. This is either a string specifying the name of the block device to be mapped,
  7076. such as @code{"/dev/sda3"}, or a list of such strings when several devices
  7077. need to be assembled for creating a new one.
  7078. @item target
  7079. This string specifies the name of the resulting mapped device. For
  7080. kernel mappers such as encrypted devices of type @code{luks-device-mapping},
  7081. specifying @code{"my-partition"} leads to the creation of
  7082. the @code{"/dev/mapper/my-partition"} device.
  7083. For RAID devices of type @code{raid-device-mapping}, the full device name
  7084. such as @code{"/dev/md0"} needs to be given.
  7085. @item type
  7086. This must be a @code{mapped-device-kind} object, which specifies how
  7087. @var{source} is mapped to @var{target}.
  7088. @end table
  7089. @end deftp
  7090. @defvr {Scheme Variable} luks-device-mapping
  7091. This defines LUKS block device encryption using the @command{cryptsetup}
  7092. command from the package with the same name. It relies on the
  7093. @code{dm-crypt} Linux kernel module.
  7094. @end defvr
  7095. @defvr {Scheme Variable} raid-device-mapping
  7096. This defines a RAID device, which is assembled using the @code{mdadm}
  7097. command from the package with the same name. It requires a Linux kernel
  7098. module for the appropriate RAID level to be loaded, such as @code{raid456}
  7099. for RAID-4, RAID-5 or RAID-6, or @code{raid10} for RAID-10.
  7100. @end defvr
  7101. @cindex disk encryption
  7102. @cindex LUKS
  7103. The following example specifies a mapping from @file{/dev/sda3} to
  7104. @file{/dev/mapper/home} using LUKS---the
  7105. @url{https://gitlab.com/cryptsetup/cryptsetup,Linux Unified Key Setup}, a
  7106. standard mechanism for disk encryption.
  7107. The @file{/dev/mapper/home}
  7108. device can then be used as the @code{device} of a @code{file-system}
  7109. declaration (@pxref{File Systems}).
  7110. @example
  7111. (mapped-device
  7112. (source "/dev/sda3")
  7113. (target "home")
  7114. (type luks-device-mapping))
  7115. @end example
  7116. Alternatively, to become independent of device numbering, one may obtain
  7117. the LUKS UUID (@dfn{unique identifier}) of the source device by a
  7118. command like:
  7119. @example
  7120. cryptsetup luksUUID /dev/sda3
  7121. @end example
  7122. and use it as follows:
  7123. @example
  7124. (mapped-device
  7125. (source (uuid "cb67fc72-0d54-4c88-9d4b-b225f30b0f44"))
  7126. (target "home")
  7127. (type luks-device-mapping))
  7128. @end example
  7129. @cindex swap encryption
  7130. It is also desirable to encrypt swap space, since swap space may contain
  7131. sensitive data. One way to accomplish that is to use a swap file in a
  7132. file system on a device mapped via LUKS encryption. In this way, the
  7133. swap file is encrypted because the entire device is encrypted.
  7134. @xref{Preparing for Installation,,Disk Partitioning}, for an example.
  7135. A RAID device formed of the partitions @file{/dev/sda1} and @file{/dev/sdb1}
  7136. may be declared as follows:
  7137. @example
  7138. (mapped-device
  7139. (source (list "/dev/sda1" "/dev/sdb1"))
  7140. (target "/dev/md0")
  7141. (type raid-device-mapping))
  7142. @end example
  7143. The @file{/dev/md0} device can then be used as the @code{device} of a
  7144. @code{file-system} declaration (@pxref{File Systems}).
  7145. Note that the RAID level need not be given; it is chosen during the
  7146. initial creation and formatting of the RAID device and is determined
  7147. automatically later.
  7148. @node User Accounts
  7149. @subsection User Accounts
  7150. @cindex users
  7151. @cindex accounts
  7152. @cindex user accounts
  7153. User accounts and groups are entirely managed through the
  7154. @code{operating-system} declaration. They are specified with the
  7155. @code{user-account} and @code{user-group} forms:
  7156. @example
  7157. (user-account
  7158. (name "alice")
  7159. (group "users")
  7160. (supplementary-groups '("wheel" ;allow use of sudo, etc.
  7161. "audio" ;sound card
  7162. "video" ;video devices such as webcams
  7163. "cdrom")) ;the good ol' CD-ROM
  7164. (comment "Bob's sister")
  7165. (home-directory "/home/alice"))
  7166. @end example
  7167. When booting or upon completion of @command{guix system reconfigure},
  7168. the system ensures that only the user accounts and groups specified in
  7169. the @code{operating-system} declaration exist, and with the specified
  7170. properties. Thus, account or group creations or modifications made by
  7171. directly invoking commands such as @command{useradd} are lost upon
  7172. reconfiguration or reboot. This ensures that the system remains exactly
  7173. as declared.
  7174. @deftp {Data Type} user-account
  7175. Objects of this type represent user accounts. The following members may
  7176. be specified:
  7177. @table @asis
  7178. @item @code{name}
  7179. The name of the user account.
  7180. @item @code{group}
  7181. @cindex groups
  7182. This is the name (a string) or identifier (a number) of the user group
  7183. this account belongs to.
  7184. @item @code{supplementary-groups} (default: @code{'()})
  7185. Optionally, this can be defined as a list of group names that this
  7186. account belongs to.
  7187. @item @code{uid} (default: @code{#f})
  7188. This is the user ID for this account (a number), or @code{#f}. In the
  7189. latter case, a number is automatically chosen by the system when the
  7190. account is created.
  7191. @item @code{comment} (default: @code{""})
  7192. A comment about the account, such as the account owner's full name.
  7193. @item @code{home-directory}
  7194. This is the name of the home directory for the account.
  7195. @item @code{create-home-directory?} (default: @code{#t})
  7196. Indicates whether the home directory of this account should be created
  7197. if it does not exist yet.
  7198. @item @code{shell} (default: Bash)
  7199. This is a G-expression denoting the file name of a program to be used as
  7200. the shell (@pxref{G-Expressions}).
  7201. @item @code{system?} (default: @code{#f})
  7202. This Boolean value indicates whether the account is a ``system''
  7203. account. System accounts are sometimes treated specially; for instance,
  7204. graphical login managers do not list them.
  7205. @anchor{user-account-password}
  7206. @item @code{password} (default: @code{#f})
  7207. You would normally leave this field to @code{#f}, initialize user
  7208. passwords as @code{root} with the @command{passwd} command, and then let
  7209. users change it with @command{passwd}. Passwords set with
  7210. @command{passwd} are of course preserved across reboot and
  7211. reconfiguration.
  7212. If you @emph{do} want to have a preset password for an account, then
  7213. this field must contain the encrypted password, as a string.
  7214. @xref{crypt,,, libc, The GNU C Library Reference Manual}, for more information
  7215. on password encryption, and @ref{Encryption,,, guile, GNU Guile Reference
  7216. Manual}, for information on Guile's @code{crypt} procedure.
  7217. @end table
  7218. @end deftp
  7219. @cindex groups
  7220. User group declarations are even simpler:
  7221. @example
  7222. (user-group (name "students"))
  7223. @end example
  7224. @deftp {Data Type} user-group
  7225. This type is for, well, user groups. There are just a few fields:
  7226. @table @asis
  7227. @item @code{name}
  7228. The name of the group.
  7229. @item @code{id} (default: @code{#f})
  7230. The group identifier (a number). If @code{#f}, a new number is
  7231. automatically allocated when the group is created.
  7232. @item @code{system?} (default: @code{#f})
  7233. This Boolean value indicates whether the group is a ``system'' group.
  7234. System groups have low numerical IDs.
  7235. @item @code{password} (default: @code{#f})
  7236. What, user groups can have a password? Well, apparently yes. Unless
  7237. @code{#f}, this field specifies the password of the group.
  7238. @end table
  7239. @end deftp
  7240. For convenience, a variable lists all the basic user groups one may
  7241. expect:
  7242. @defvr {Scheme Variable} %base-groups
  7243. This is the list of basic user groups that users and/or packages expect
  7244. to be present on the system. This includes groups such as ``root'',
  7245. ``wheel'', and ``users'', as well as groups used to control access to
  7246. specific devices such as ``audio'', ``disk'', and ``cdrom''.
  7247. @end defvr
  7248. @defvr {Scheme Variable} %base-user-accounts
  7249. This is the list of basic system accounts that programs may expect to
  7250. find on a GNU/Linux system, such as the ``nobody'' account.
  7251. Note that the ``root'' account is not included here. It is a
  7252. special-case and is automatically added whether or not it is specified.
  7253. @end defvr
  7254. @node Locales
  7255. @subsection Locales
  7256. @cindex locale
  7257. A @dfn{locale} defines cultural conventions for a particular language
  7258. and region of the world (@pxref{Locales,,, libc, The GNU C Library
  7259. Reference Manual}). Each locale has a name that typically has the form
  7260. @code{@var{language}_@var{territory}.@var{codeset}}---e.g.,
  7261. @code{fr_LU.utf8} designates the locale for the French language, with
  7262. cultural conventions from Luxembourg, and using the UTF-8 encoding.
  7263. @cindex locale definition
  7264. Usually, you will want to specify the default locale for the machine
  7265. using the @code{locale} field of the @code{operating-system} declaration
  7266. (@pxref{operating-system Reference, @code{locale}}).
  7267. The selected locale is automatically added to the @dfn{locale
  7268. definitions} known to the system if needed, with its codeset inferred
  7269. from its name---e.g., @code{bo_CN.utf8} will be assumed to use the
  7270. @code{UTF-8} codeset. Additional locale definitions can be specified in
  7271. the @code{locale-definitions} slot of @code{operating-system}---this is
  7272. useful, for instance, if the codeset could not be inferred from the
  7273. locale name. The default set of locale definitions includes some widely
  7274. used locales, but not all the available locales, in order to save space.
  7275. For instance, to add the North Frisian locale for Germany, the value of
  7276. that field may be:
  7277. @example
  7278. (cons (locale-definition
  7279. (name "fy_DE.utf8") (source "fy_DE"))
  7280. %default-locale-definitions)
  7281. @end example
  7282. Likewise, to save space, one might want @code{locale-definitions} to
  7283. list only the locales that are actually used, as in:
  7284. @example
  7285. (list (locale-definition
  7286. (name "ja_JP.eucjp") (source "ja_JP")
  7287. (charset "EUC-JP")))
  7288. @end example
  7289. @vindex LOCPATH
  7290. The compiled locale definitions are available at
  7291. @file{/run/current-system/locale/X.Y}, where @code{X.Y} is the libc
  7292. version, which is the default location where the GNU@tie{}libc provided
  7293. by Guix looks for locale data. This can be overridden using the
  7294. @code{LOCPATH} environment variable (@pxref{locales-and-locpath,
  7295. @code{LOCPATH} and locale packages}).
  7296. The @code{locale-definition} form is provided by the @code{(gnu system
  7297. locale)} module. Details are given below.
  7298. @deftp {Data Type} locale-definition
  7299. This is the data type of a locale definition.
  7300. @table @asis
  7301. @item @code{name}
  7302. The name of the locale. @xref{Locale Names,,, libc, The GNU C Library
  7303. Reference Manual}, for more information on locale names.
  7304. @item @code{source}
  7305. The name of the source for that locale. This is typically the
  7306. @code{@var{language}_@var{territory}} part of the locale name.
  7307. @item @code{charset} (default: @code{"UTF-8"})
  7308. The ``character set'' or ``code set'' for that locale,
  7309. @uref{http://www.iana.org/assignments/character-sets, as defined by
  7310. IANA}.
  7311. @end table
  7312. @end deftp
  7313. @defvr {Scheme Variable} %default-locale-definitions
  7314. A list of commonly used UTF-8 locales, used as the default
  7315. value of the @code{locale-definitions} field of @code{operating-system}
  7316. declarations.
  7317. @cindex locale name
  7318. @cindex normalized codeset in locale names
  7319. These locale definitions use the @dfn{normalized codeset} for the part
  7320. that follows the dot in the name (@pxref{Using gettextized software,
  7321. normalized codeset,, libc, The GNU C Library Reference Manual}). So for
  7322. instance it has @code{uk_UA.utf8} but @emph{not}, say,
  7323. @code{uk_UA.UTF-8}.
  7324. @end defvr
  7325. @subsubsection Locale Data Compatibility Considerations
  7326. @cindex incompatibility, of locale data
  7327. @code{operating-system} declarations provide a @code{locale-libcs} field
  7328. to specify the GNU@tie{}libc packages that are used to compile locale
  7329. declarations (@pxref{operating-system Reference}). ``Why would I
  7330. care?'', you may ask. Well, it turns out that the binary format of
  7331. locale data is occasionally incompatible from one libc version to
  7332. another.
  7333. @c See <https://sourceware.org/ml/libc-alpha/2015-09/msg00575.html>
  7334. @c and <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
  7335. For instance, a program linked against libc version 2.21 is unable to
  7336. read locale data produced with libc 2.22; worse, that program
  7337. @emph{aborts} instead of simply ignoring the incompatible locale
  7338. data@footnote{Versions 2.23 and later of GNU@tie{}libc will simply skip
  7339. the incompatible locale data, which is already an improvement.}.
  7340. Similarly, a program linked against libc 2.22 can read most, but not
  7341. all, of the locale data from libc 2.21 (specifically, @code{LC_COLLATE}
  7342. data is incompatible); thus calls to @code{setlocale} may fail, but
  7343. programs will not abort.
  7344. The ``problem'' in GuixSD is that users have a lot of freedom: They can
  7345. choose whether and when to upgrade software in their profiles, and might
  7346. be using a libc version different from the one the system administrator
  7347. used to build the system-wide locale data.
  7348. Fortunately, unprivileged users can also install their own locale data
  7349. and define @var{GUIX_LOCPATH} accordingly (@pxref{locales-and-locpath,
  7350. @code{GUIX_LOCPATH} and locale packages}).
  7351. Still, it is best if the system-wide locale data at
  7352. @file{/run/current-system/locale} is built for all the libc versions
  7353. actually in use on the system, so that all the programs can access
  7354. it---this is especially crucial on a multi-user system. To do that, the
  7355. administrator can specify several libc packages in the
  7356. @code{locale-libcs} field of @code{operating-system}:
  7357. @example
  7358. (use-package-modules base)
  7359. (operating-system
  7360. ;; @dots{}
  7361. (locale-libcs (list glibc-2.21 (canonical-package glibc))))
  7362. @end example
  7363. This example would lead to a system containing locale definitions for
  7364. both libc 2.21 and the current version of libc in
  7365. @file{/run/current-system/locale}.
  7366. @node Services
  7367. @subsection Services
  7368. @cindex system services
  7369. An important part of preparing an @code{operating-system} declaration is
  7370. listing @dfn{system services} and their configuration (@pxref{Using the
  7371. Configuration System}). System services are typically daemons launched
  7372. when the system boots, or other actions needed at that time---e.g.,
  7373. configuring network access.
  7374. GuixSD has a broad definition of ``service'' (@pxref{Service
  7375. Composition}), but many services are managed by the GNU@tie{}Shepherd
  7376. (@pxref{Shepherd Services}). On a running system, the @command{herd}
  7377. command allows you to list the available services, show their status,
  7378. start and stop them, or do other specific operations (@pxref{Jump
  7379. Start,,, shepherd, The GNU Shepherd Manual}). For example:
  7380. @example
  7381. # herd status
  7382. @end example
  7383. The above command, run as @code{root}, lists the currently defined
  7384. services. The @command{herd doc} command shows a synopsis of the given
  7385. service:
  7386. @example
  7387. # herd doc nscd
  7388. Run libc's name service cache daemon (nscd).
  7389. @end example
  7390. The @command{start}, @command{stop}, and @command{restart} sub-commands
  7391. have the effect you would expect. For instance, the commands below stop
  7392. the nscd service and restart the Xorg display server:
  7393. @example
  7394. # herd stop nscd
  7395. Service nscd has been stopped.
  7396. # herd restart xorg-server
  7397. Service xorg-server has been stopped.
  7398. Service xorg-server has been started.
  7399. @end example
  7400. The following sections document the available services, starting with
  7401. the core services, that may be used in an @code{operating-system}
  7402. declaration.
  7403. @menu
  7404. * Base Services:: Essential system services.
  7405. * Scheduled Job Execution:: The mcron service.
  7406. * Log Rotation:: The rottlog service.
  7407. * Networking Services:: Network setup, SSH daemon, etc.
  7408. * X Window:: Graphical display.
  7409. * Printing Services:: Local and remote printer support.
  7410. * Desktop Services:: D-Bus and desktop services.
  7411. * Database Services:: SQL databases, key-value stores, etc.
  7412. * Mail Services:: IMAP, POP3, SMTP, and all that.
  7413. * Messaging Services:: Messaging services.
  7414. * Monitoring Services:: Monitoring services.
  7415. * Kerberos Services:: Kerberos services.
  7416. * Web Services:: Web servers.
  7417. * DNS Services:: DNS daemons.
  7418. * VPN Services:: VPN daemons.
  7419. * Network File System:: NFS related services.
  7420. * Continuous Integration:: The Cuirass service.
  7421. * Power management Services:: The TLP tool.
  7422. * Audio Services:: The MPD.
  7423. * Virtualization Services:: Virtualization services.
  7424. * Miscellaneous Services:: Other services.
  7425. @end menu
  7426. @node Base Services
  7427. @subsubsection Base Services
  7428. The @code{(gnu services base)} module provides definitions for the basic
  7429. services that one expects from the system. The services exported by
  7430. this module are listed below.
  7431. @defvr {Scheme Variable} %base-services
  7432. This variable contains a list of basic services (@pxref{Service Types
  7433. and Services}, for more information on service objects) one would
  7434. expect from the system: a login service (mingetty) on each tty, syslogd,
  7435. the libc name service cache daemon (nscd), the udev device manager, and
  7436. more.
  7437. This is the default value of the @code{services} field of
  7438. @code{operating-system} declarations. Usually, when customizing a
  7439. system, you will want to append services to @var{%base-services}, like
  7440. this:
  7441. @example
  7442. (cons* (avahi-service) (lsh-service) %base-services)
  7443. @end example
  7444. @end defvr
  7445. @defvr {Scheme Variable} special-files-service-type
  7446. This is the service that sets up ``special files'' such as
  7447. @file{/bin/sh}; an instance of it is part of @code{%base-services}.
  7448. The value associated with @code{special-files-service-type} services
  7449. must be a list of tuples where the first element is the ``special file''
  7450. and the second element is its target. By default it is:
  7451. @cindex @file{/bin/sh}
  7452. @cindex @file{sh}, in @file{/bin}
  7453. @example
  7454. `(("/bin/sh" ,(file-append @var{bash} "/bin/sh")))
  7455. @end example
  7456. @cindex @file{/usr/bin/env}
  7457. @cindex @file{env}, in @file{/usr/bin}
  7458. If you want to add, say, @code{/usr/bin/env} to your system, you can
  7459. change it to:
  7460. @example
  7461. `(("/bin/sh" ,(file-append @var{bash} "/bin/sh"))
  7462. ("/usr/bin/env" ,(file-append @var{coreutils} "/bin/env")))
  7463. @end example
  7464. Since this is part of @code{%base-services}, you can use
  7465. @code{modify-services} to customize the set of special files
  7466. (@pxref{Service Reference, @code{modify-services}}). But the simple way
  7467. to add a special file is @i{via} the @code{extra-special-file} procedure
  7468. (see below.)
  7469. @end defvr
  7470. @deffn {Scheme Procedure} extra-special-file @var{file} @var{target}
  7471. Use @var{target} as the ``special file'' @var{file}.
  7472. For example, adding the following lines to the @code{services} field of
  7473. your operating system declaration leads to a @file{/usr/bin/env}
  7474. symlink:
  7475. @example
  7476. (extra-special-file "/usr/bin/env"
  7477. (file-append coreutils "/bin/env"))
  7478. @end example
  7479. @end deffn
  7480. @deffn {Scheme Procedure} host-name-service @var{name}
  7481. Return a service that sets the host name to @var{name}.
  7482. @end deffn
  7483. @deffn {Scheme Procedure} login-service @var{config}
  7484. Return a service to run login according to @var{config}, a
  7485. @code{<login-configuration>} object, which specifies the message of the day,
  7486. among other things.
  7487. @end deffn
  7488. @deftp {Data Type} login-configuration
  7489. This is the data type representing the configuration of login.
  7490. @table @asis
  7491. @item @code{motd}
  7492. @cindex message of the day
  7493. A file-like object containing the ``message of the day''.
  7494. @item @code{allow-empty-passwords?} (default: @code{#t})
  7495. Allow empty passwords by default so that first-time users can log in when
  7496. the 'root' account has just been created.
  7497. @end table
  7498. @end deftp
  7499. @deffn {Scheme Procedure} mingetty-service @var{config}
  7500. Return a service to run mingetty according to @var{config}, a
  7501. @code{<mingetty-configuration>} object, which specifies the tty to run, among
  7502. other things.
  7503. @end deffn
  7504. @deftp {Data Type} mingetty-configuration
  7505. This is the data type representing the configuration of Mingetty, which
  7506. provides the default implementation of virtual console log-in.
  7507. @table @asis
  7508. @item @code{tty}
  7509. The name of the console this Mingetty runs on---e.g., @code{"tty1"}.
  7510. @item @code{auto-login} (default: @code{#f})
  7511. When true, this field must be a string denoting the user name under
  7512. which the system automatically logs in. When it is @code{#f}, a
  7513. user name and password must be entered to log in.
  7514. @item @code{login-program} (default: @code{#f})
  7515. This must be either @code{#f}, in which case the default log-in program
  7516. is used (@command{login} from the Shadow tool suite), or a gexp denoting
  7517. the name of the log-in program.
  7518. @item @code{login-pause?} (default: @code{#f})
  7519. When set to @code{#t} in conjunction with @var{auto-login}, the user
  7520. will have to press a key before the log-in shell is launched.
  7521. @item @code{mingetty} (default: @var{mingetty})
  7522. The Mingetty package to use.
  7523. @end table
  7524. @end deftp
  7525. @deffn {Scheme Procedure} agetty-service @var{config}
  7526. Return a service to run agetty according to @var{config}, an
  7527. @code{<agetty-configuration>} object, which specifies the tty to run,
  7528. among other things.
  7529. @end deffn
  7530. @deftp {Data Type} agetty-configuration
  7531. This is the data type representing the configuration of agetty, which
  7532. implements virtual and serial console log-in. See the @code{agetty(8)}
  7533. man page for more information.
  7534. @table @asis
  7535. @item @code{tty}
  7536. The name of the console this agetty runs on, as a string---e.g.,
  7537. @code{"ttyS0"}. This argument is mandatory.
  7538. @item @code{baud-rate} (default: @code{#f})
  7539. A string containing a comma-separated list of one or more baud rates, in
  7540. descending order.
  7541. @item @code{term} (default: @code{#f})
  7542. A string containing the value used for the @code{TERM} environment
  7543. variable.
  7544. @item @code{eight-bits?} (default: @code{#f})
  7545. When @code{#t}, the tty is assumed to be 8-bit clean, and parity detection is
  7546. disabled.
  7547. @item @code{auto-login} (default: @code{#f})
  7548. When passed a login name, as a string, the specified user will be logged
  7549. in automatically without prompting for their login name or password.
  7550. @item @code{no-reset?} (default: @code{#f})
  7551. When @code{#t}, don't reset terminal cflags (control modes).
  7552. @item @code{host} (default: @code{#f})
  7553. This accepts a string containing the "login_host", which will be written
  7554. into the @file{/var/run/utmpx} file.
  7555. @item @code{remote?} (default: @code{#f})
  7556. When set to @code{#t} in conjunction with @var{host}, this will add an
  7557. @code{-r} fakehost option to the command line of the login program
  7558. specified in @var{login-program}.
  7559. @item @code{flow-control?} (default: @code{#f})
  7560. When set to @code{#t}, enable hardware (RTS/CTS) flow control.
  7561. @item @code{no-issue?} (default: @code{#f})
  7562. When set to @code{#t}, the contents of the @file{/etc/issue} file will
  7563. not be displayed before presenting the login prompt.
  7564. @item @code{init-string} (default: @code{#f})
  7565. This accepts a string that will be sent to the tty or modem before
  7566. sending anything else. It can be used to initialize a modem.
  7567. @item @code{no-clear?} (default: @code{#f})
  7568. When set to @code{#t}, agetty will not clear the screen before showing
  7569. the login prompt.
  7570. @item @code{login-program} (default: (file-append shadow "/bin/login"))
  7571. This must be either a gexp denoting the name of a log-in program, or
  7572. unset, in which case the default value is the @command{login} from the
  7573. Shadow tool suite.
  7574. @item @code{local-line} (default: @code{#f})
  7575. Control the CLOCAL line flag. This accepts one of three symbols as
  7576. arguments, @code{'auto}, @code{'always}, or @code{'never}. If @code{#f},
  7577. the default value chosen by agetty is @code{'auto}.
  7578. @item @code{extract-baud?} (default: @code{#f})
  7579. When set to @code{#t}, instruct agetty to try to extract the baud rate
  7580. from the status messages produced by certain types of modems.
  7581. @item @code{skip-login?} (default: @code{#f})
  7582. When set to @code{#t}, do not prompt the user for a login name. This
  7583. can be used with @var{login-program} field to use non-standard login
  7584. systems.
  7585. @item @code{no-newline?} (default: @code{#f})
  7586. When set to @code{#t}, do not print a newline before printing the
  7587. @file{/etc/issue} file.
  7588. @c Is this dangerous only when used with login-program, or always?
  7589. @item @code{login-options} (default: @code{#f})
  7590. This option accepts a string containing options that are passed to the
  7591. login program. When used with the @var{login-program}, be aware that a
  7592. malicious user could try to enter a login name containing embedded
  7593. options that could be parsed by the login program.
  7594. @item @code{login-pause} (default: @code{#f})
  7595. When set to @code{#t}, wait for any key before showing the login prompt.
  7596. This can be used in conjunction with @var{auto-login} to save memory by
  7597. lazily spawning shells.
  7598. @item @code{chroot} (default: @code{#f})
  7599. Change root to the specified directory. This option accepts a directory
  7600. path as a string.
  7601. @item @code{hangup?} (default: @code{#f})
  7602. Use the Linux system call @code{vhangup} to do a virtual hangup of the
  7603. specified terminal.
  7604. @item @code{keep-baud?} (default: @code{#f})
  7605. When set to @code{#t}, try to keep the existing baud rate. The baud
  7606. rates from @var{baud-rate} are used when agetty receives a @key{BREAK}
  7607. character.
  7608. @item @code{timeout} (default: @code{#f})
  7609. When set to an integer value, terminate if no user name could be read
  7610. within @var{timeout} seconds.
  7611. @item @code{detect-case?} (default: @code{#f})
  7612. When set to @code{#t}, turn on support for detecting an uppercase-only
  7613. terminal. This setting will detect a login name containing only
  7614. uppercase letters as indicating an uppercase-only terminal and turn on
  7615. some upper-to-lower case conversions. Note that this will not support
  7616. Unicode characters.
  7617. @item @code{wait-cr?} (default: @code{#f})
  7618. When set to @code{#t}, wait for the user or modem to send a
  7619. carriage-return or linefeed character before displaying
  7620. @file{/etc/issue} or login prompt. This is typically used with the
  7621. @var{init-string} option.
  7622. @item @code{no-hints?} (default: @code{#f})
  7623. When set to @code{#t}, do not print hints about Num, Caps, and Scroll
  7624. locks.
  7625. @item @code{no-hostname?} (default: @code{#f})
  7626. By default, the hostname is printed. When this option is set to
  7627. @code{#t}, no hostname will be shown at all.
  7628. @item @code{long-hostname?} (default: @code{#f})
  7629. By default, the hostname is only printed until the first dot. When this
  7630. option is set to @code{#t}, the fully qualified hostname by
  7631. @code{gethostname} or @code{getaddrinfo} is shown.
  7632. @item @code{erase-characters} (default: @code{#f})
  7633. This option accepts a string of additional characters that should be
  7634. interpreted as backspace when the user types their login name.
  7635. @item @code{kill-characters} (default: @code{#f})
  7636. This option accepts a string that should be interpreted to mean "ignore
  7637. all previous characters" (also called a "kill" character) when the types
  7638. their login name.
  7639. @item @code{chdir} (default: @code{#f})
  7640. This option accepts, as a string, a directory path that will be changed
  7641. to before login.
  7642. @item @code{delay} (default: @code{#f})
  7643. This options accepts, as an integer, the number of seconds to sleep
  7644. before opening the tty and displaying the login prompt.
  7645. @item @code{nice} (default: @code{#f})
  7646. This option accepts, as an integer, the nice value with which to run the
  7647. @command{login} program.
  7648. @item @code{extra-options} (default: @code{'()})
  7649. This option provides an "escape hatch" for the user to provide arbitrary
  7650. command-line arguments to @command{agetty} as a list of strings.
  7651. @end table
  7652. @end deftp
  7653. @deffn {Scheme Procedure} kmscon-service-type @var{config}
  7654. Return a service to run @uref{https://www.freedesktop.org/wiki/Software/kmscon,kmscon}
  7655. according to @var{config}, a @code{<kmscon-configuration>} object, which
  7656. specifies the tty to run, among other things.
  7657. @end deffn
  7658. @deftp {Data Type} kmscon-configuration
  7659. This is the data type representing the configuration of Kmscon, which
  7660. implements virtual console log-in.
  7661. @table @asis
  7662. @item @code{virtual-terminal}
  7663. The name of the console this Kmscon runs on---e.g., @code{"tty1"}.
  7664. @item @code{login-program} (default: @code{#~(string-append #$shadow "/bin/login")})
  7665. A gexp denoting the name of the log-in program. The default log-in program is
  7666. @command{login} from the Shadow tool suite.
  7667. @item @code{login-arguments} (default: @code{'("-p")})
  7668. A list of arguments to pass to @command{login}.
  7669. @item @code{hardware-acceleration?} (default: #f)
  7670. Whether to use hardware acceleration.
  7671. @item @code{kmscon} (default: @var{kmscon})
  7672. The Kmscon package to use.
  7673. @end table
  7674. @end deftp
  7675. @cindex name service cache daemon
  7676. @cindex nscd
  7677. @deffn {Scheme Procedure} nscd-service [@var{config}] [#:glibc glibc] @
  7678. [#:name-services '()]
  7679. Return a service that runs the libc name service cache daemon (nscd) with the
  7680. given @var{config}---an @code{<nscd-configuration>} object. @xref{Name
  7681. Service Switch}, for an example.
  7682. @end deffn
  7683. @defvr {Scheme Variable} %nscd-default-configuration
  7684. This is the default @code{<nscd-configuration>} value (see below) used
  7685. by @code{nscd-service}. It uses the caches defined by
  7686. @var{%nscd-default-caches}; see below.
  7687. @end defvr
  7688. @deftp {Data Type} nscd-configuration
  7689. This is the data type representing the name service cache daemon (nscd)
  7690. configuration.
  7691. @table @asis
  7692. @item @code{name-services} (default: @code{'()})
  7693. List of packages denoting @dfn{name services} that must be visible to
  7694. the nscd---e.g., @code{(list @var{nss-mdns})}.
  7695. @item @code{glibc} (default: @var{glibc})
  7696. Package object denoting the GNU C Library providing the @command{nscd}
  7697. command.
  7698. @item @code{log-file} (default: @code{"/var/log/nscd.log"})
  7699. Name of the nscd log file. This is where debugging output goes when
  7700. @code{debug-level} is strictly positive.
  7701. @item @code{debug-level} (default: @code{0})
  7702. Integer denoting the debugging levels. Higher numbers mean that more
  7703. debugging output is logged.
  7704. @item @code{caches} (default: @var{%nscd-default-caches})
  7705. List of @code{<nscd-cache>} objects denoting things to be cached; see
  7706. below.
  7707. @end table
  7708. @end deftp
  7709. @deftp {Data Type} nscd-cache
  7710. Data type representing a cache database of nscd and its parameters.
  7711. @table @asis
  7712. @item @code{database}
  7713. This is a symbol representing the name of the database to be cached.
  7714. Valid values are @code{passwd}, @code{group}, @code{hosts}, and
  7715. @code{services}, which designate the corresponding NSS database
  7716. (@pxref{NSS Basics,,, libc, The GNU C Library Reference Manual}).
  7717. @item @code{positive-time-to-live}
  7718. @itemx @code{negative-time-to-live} (default: @code{20})
  7719. A number representing the number of seconds during which a positive or
  7720. negative lookup result remains in cache.
  7721. @item @code{check-files?} (default: @code{#t})
  7722. Whether to check for updates of the files corresponding to
  7723. @var{database}.
  7724. For instance, when @var{database} is @code{hosts}, setting this flag
  7725. instructs nscd to check for updates in @file{/etc/hosts} and to take
  7726. them into account.
  7727. @item @code{persistent?} (default: @code{#t})
  7728. Whether the cache should be stored persistently on disk.
  7729. @item @code{shared?} (default: @code{#t})
  7730. Whether the cache should be shared among users.
  7731. @item @code{max-database-size} (default: 32@tie{}MiB)
  7732. Maximum size in bytes of the database cache.
  7733. @c XXX: 'suggested-size' and 'auto-propagate?' seem to be expert
  7734. @c settings, so leave them out.
  7735. @end table
  7736. @end deftp
  7737. @defvr {Scheme Variable} %nscd-default-caches
  7738. List of @code{<nscd-cache>} objects used by default by
  7739. @code{nscd-configuration} (see above).
  7740. It enables persistent and aggressive caching of service and host name
  7741. lookups. The latter provides better host name lookup performance,
  7742. resilience in the face of unreliable name servers, and also better
  7743. privacy---often the result of host name lookups is in local cache, so
  7744. external name servers do not even need to be queried.
  7745. @end defvr
  7746. @anchor{syslog-configuration-type}
  7747. @cindex syslog
  7748. @cindex logging
  7749. @deftp {Data Type} syslog-configuration
  7750. This data type represents the configuration of the syslog daemon.
  7751. @table @asis
  7752. @item @code{syslogd} (default: @code{#~(string-append #$inetutils "/libexec/syslogd")})
  7753. The syslog daemon to use.
  7754. @item @code{config-file} (default: @code{%default-syslog.conf})
  7755. The syslog configuration file to use.
  7756. @end table
  7757. @end deftp
  7758. @anchor{syslog-service}
  7759. @cindex syslog
  7760. @deffn {Scheme Procedure} syslog-service @var{config}
  7761. Return a service that runs a syslog daemon according to @var{config}.
  7762. @xref{syslogd invocation,,, inetutils, GNU Inetutils}, for more
  7763. information on the configuration file syntax.
  7764. @end deffn
  7765. @anchor{guix-configuration-type}
  7766. @deftp {Data Type} guix-configuration
  7767. This data type represents the configuration of the Guix build daemon.
  7768. @xref{Invoking guix-daemon}, for more information.
  7769. @table @asis
  7770. @item @code{guix} (default: @var{guix})
  7771. The Guix package to use.
  7772. @item @code{build-group} (default: @code{"guixbuild"})
  7773. Name of the group for build user accounts.
  7774. @item @code{build-accounts} (default: @code{10})
  7775. Number of build user accounts to create.
  7776. @item @code{authorize-key?} (default: @code{#t})
  7777. @cindex substitutes, authorization thereof
  7778. Whether to authorize the substitute keys listed in
  7779. @code{authorized-keys}---by default that of @code{hydra.gnu.org}
  7780. (@pxref{Substitutes}).
  7781. @vindex %default-authorized-guix-keys
  7782. @item @code{authorized-keys} (default: @var{%default-authorized-guix-keys})
  7783. The list of authorized key files for archive imports, as a list of
  7784. string-valued gexps (@pxref{Invoking guix archive}). By default, it
  7785. contains that of @code{hydra.gnu.org} (@pxref{Substitutes}).
  7786. @item @code{use-substitutes?} (default: @code{#t})
  7787. Whether to use substitutes.
  7788. @item @code{substitute-urls} (default: @var{%default-substitute-urls})
  7789. The list of URLs where to look for substitutes by default.
  7790. @item @code{max-silent-time} (default: @code{0})
  7791. @itemx @code{timeout} (default: @code{0})
  7792. The number of seconds of silence and the number of seconds of activity,
  7793. respectively, after which a build process times out. A value of zero
  7794. disables the timeout.
  7795. @item @code{extra-options} (default: @code{'()})
  7796. List of extra command-line options for @command{guix-daemon}.
  7797. @item @code{log-file} (default: @code{"/var/log/guix-daemon.log"})
  7798. File where @command{guix-daemon}'s standard output and standard error
  7799. are written.
  7800. @item @code{lsof} (default: @var{lsof})
  7801. The lsof package to use.
  7802. @item @code{http-proxy} (default: @code{#f})
  7803. The HTTP proxy used for downloading fixed-output derivations and
  7804. substitutes.
  7805. @item @code{tmpdir} (default: @code{#f})
  7806. A directory path where the @command{guix-daemon} will perform builds.
  7807. @end table
  7808. @end deftp
  7809. @deffn {Scheme Procedure} guix-service @var{config}
  7810. Return a service that runs the Guix build daemon according to
  7811. @var{config}.
  7812. @end deffn
  7813. @deffn {Scheme Procedure} udev-service [#:udev udev]
  7814. Run @var{udev}, which populates the @file{/dev} directory dynamically.
  7815. @end deffn
  7816. @deffn {Scheme Procedure} urandom-seed-service @var{#f}
  7817. Save some entropy in @var{%random-seed-file} to seed @file{/dev/urandom}
  7818. when rebooting.
  7819. @end deffn
  7820. @defvr {Scheme Variable} %random-seed-file
  7821. This is the name of the file where some random bytes are saved by
  7822. @var{urandom-seed-service} to seed @file{/dev/urandom} when rebooting.
  7823. It defaults to @file{/var/lib/random-seed}.
  7824. @end defvr
  7825. @cindex keymap
  7826. @cindex keyboard
  7827. @deffn {Scheme Procedure} console-keymap-service @var{files} ...
  7828. @cindex keyboard layout
  7829. Return a service to load console keymaps from @var{files} using
  7830. @command{loadkeys} command. Most likely, you want to load some default
  7831. keymap, which can be done like this:
  7832. @example
  7833. (console-keymap-service "dvorak")
  7834. @end example
  7835. Or, for example, for a Swedish keyboard, you may need to combine
  7836. the following keymaps:
  7837. @example
  7838. (console-keymap-service "se-lat6" "se-fi-lat6")
  7839. @end example
  7840. Also you can specify a full file name (or file names) of your keymap(s).
  7841. See @code{man loadkeys} for details.
  7842. @end deffn
  7843. @cindex mouse
  7844. @cindex gpm
  7845. @deffn {Scheme Procedure} gpm-service [#:gpm @var{gpm}] @
  7846. [#:options]
  7847. Run @var{gpm}, the general-purpose mouse daemon, with the given
  7848. command-line @var{options}. GPM allows users to use the mouse in the console,
  7849. notably to select, copy, and paste text. The default value of @var{options}
  7850. uses the @code{ps2} protocol, which works for both USB and PS/2 mice.
  7851. This service is not part of @var{%base-services}.
  7852. @end deffn
  7853. @anchor{guix-publish-service-type}
  7854. @deffn {Scheme Variable} guix-publish-service-type
  7855. This is the service type for @command{guix publish} (@pxref{Invoking
  7856. guix publish}). Its value must be a @code{guix-configuration}
  7857. object, as described below.
  7858. This assumes that @file{/etc/guix} already contains a signing key pair as
  7859. created by @command{guix archive --generate-key} (@pxref{Invoking guix
  7860. archive}). If that is not the case, the service will fail to start.
  7861. @end deffn
  7862. @deftp {Data Type} guix-publish-configuration
  7863. Data type representing the configuration of the @code{guix publish}
  7864. service.
  7865. @table @asis
  7866. @item @code{guix} (default: @code{guix})
  7867. The Guix package to use.
  7868. @item @code{port} (default: @code{80})
  7869. The TCP port to listen for connections.
  7870. @item @code{host} (default: @code{"localhost"})
  7871. The host (and thus, network interface) to listen to. Use
  7872. @code{"0.0.0.0"} to listen on all the network interfaces.
  7873. @item @code{compression-level} (default: @code{3})
  7874. The gzip compression level at which substitutes are compressed. Use
  7875. @code{0} to disable compression altogether, and @code{9} to get the best
  7876. compression ratio at the expense of increased CPU usage.
  7877. @item @code{nar-path} (default: @code{"nar"})
  7878. The URL path at which ``nars'' can be fetched. @xref{Invoking guix
  7879. publish, @code{--nar-path}}, for details.
  7880. @item @code{cache} (default: @code{#f})
  7881. When it is @code{#f}, disable caching and instead generate archives on
  7882. demand. Otherwise, this should be the name of a directory---e.g.,
  7883. @code{"/var/cache/guix/publish"}---where @command{guix publish} caches
  7884. archives and meta-data ready to be sent. @xref{Invoking guix publish,
  7885. @option{--cache}}, for more information on the tradeoffs involved.
  7886. @item @code{workers} (default: @code{#f})
  7887. When it is an integer, this is the number of worker threads used for
  7888. caching; when @code{#f}, the number of processors is used.
  7889. @xref{Invoking guix publish, @option{--workers}}, for more information.
  7890. @item @code{ttl} (default: @code{#f})
  7891. When it is an integer, this denotes the @dfn{time-to-live} of the
  7892. published archives. @xref{Invoking guix publish, @option{--ttl}}, for
  7893. more information.
  7894. @end table
  7895. @end deftp
  7896. @anchor{rngd-service}
  7897. @deffn {Scheme Procedure} rngd-service [#:rng-tools @var{rng-tools}] @
  7898. [#:device "/dev/hwrng"]
  7899. Return a service that runs the @command{rngd} program from @var{rng-tools}
  7900. to add @var{device} to the kernel's entropy pool. The service will fail if
  7901. @var{device} does not exist.
  7902. @end deffn
  7903. @anchor{pam-limits-service}
  7904. @cindex session limits
  7905. @cindex ulimit
  7906. @cindex priority
  7907. @deffn {Scheme Procedure} pam-limits-service [#:limits @var{limits}]
  7908. Return a service that installs a configuration file for the
  7909. @uref{http://linux-pam.org/Linux-PAM-html/sag-pam_limits.html,
  7910. @code{pam_limits} module}. The procedure optionally takes a list of
  7911. @code{pam-limits-entry} values, which can be used to specify
  7912. @code{ulimit} limits and nice priority limits to user sessions.
  7913. The following limits definition sets two hard and soft limits for all
  7914. login sessions of users in the @code{realtime} group:
  7915. @example
  7916. (pam-limits-service
  7917. (list
  7918. (pam-limits-entry "@@realtime" 'both 'rtprio 99)
  7919. (pam-limits-entry "@@realtime" 'both 'memlock 'unlimited)))
  7920. @end example
  7921. The first entry increases the maximum realtime priority for
  7922. non-privileged processes; the second entry lifts any restriction of the
  7923. maximum address space that can be locked in memory. These settings are
  7924. commonly used for real-time audio systems.
  7925. @end deffn
  7926. @node Scheduled Job Execution
  7927. @subsubsection Scheduled Job Execution
  7928. @cindex cron
  7929. @cindex mcron
  7930. @cindex scheduling jobs
  7931. The @code{(gnu services mcron)} module provides an interface to
  7932. GNU@tie{}mcron, a daemon to run jobs at scheduled times (@pxref{Top,,,
  7933. mcron, GNU@tie{}mcron}). GNU@tie{}mcron is similar to the traditional
  7934. Unix @command{cron} daemon; the main difference is that it is
  7935. implemented in Guile Scheme, which provides a lot of flexibility when
  7936. specifying the scheduling of jobs and their actions.
  7937. The example below defines an operating system that runs the
  7938. @command{updatedb} (@pxref{Invoking updatedb,,, find, Finding Files})
  7939. and the @command{guix gc} commands (@pxref{Invoking guix gc}) daily, as
  7940. well as the @command{mkid} command on behalf of an unprivileged user
  7941. (@pxref{mkid invocation,,, idutils, ID Database Utilities}). It uses
  7942. gexps to introduce job definitions that are passed to mcron
  7943. (@pxref{G-Expressions}).
  7944. @lisp
  7945. (use-modules (guix) (gnu) (gnu services mcron))
  7946. (use-package-modules base idutils)
  7947. (define updatedb-job
  7948. ;; Run 'updatedb' at 3AM every day. Here we write the
  7949. ;; job's action as a Scheme procedure.
  7950. #~(job '(next-hour '(3))
  7951. (lambda ()
  7952. (execl (string-append #$findutils "/bin/updatedb")
  7953. "updatedb"
  7954. "--prunepaths=/tmp /var/tmp /gnu/store"))))
  7955. (define garbage-collector-job
  7956. ;; Collect garbage 5 minutes after midnight every day.
  7957. ;; The job's action is a shell command.
  7958. #~(job "5 0 * * *" ;Vixie cron syntax
  7959. "guix gc -F 1G"))
  7960. (define idutils-job
  7961. ;; Update the index database as user "charlie" at 12:15PM
  7962. ;; and 19:15PM. This runs from the user's home directory.
  7963. #~(job '(next-minute-from (next-hour '(12 19)) '(15))
  7964. (string-append #$idutils "/bin/mkid src")
  7965. #:user "charlie"))
  7966. (operating-system
  7967. ;; @dots{}
  7968. (services (cons (mcron-service (list garbage-collector-job
  7969. updatedb-job
  7970. idutils-job))
  7971. %base-services)))
  7972. @end lisp
  7973. @xref{Guile Syntax, mcron job specifications,, mcron, GNU@tie{}mcron},
  7974. for more information on mcron job specifications. Below is the
  7975. reference of the mcron service.
  7976. @deffn {Scheme Procedure} mcron-service @var{jobs} [#:mcron @var{mcron2}]
  7977. Return an mcron service running @var{mcron} that schedules @var{jobs}, a
  7978. list of gexps denoting mcron job specifications.
  7979. This is a shorthand for:
  7980. @example
  7981. (service mcron-service-type
  7982. (mcron-configuration (mcron mcron) (jobs jobs)))
  7983. @end example
  7984. @end deffn
  7985. @defvr {Scheme Variable} mcron-service-type
  7986. This is the type of the @code{mcron} service, whose value is an
  7987. @code{mcron-configuration} object.
  7988. This service type can be the target of a service extension that provides
  7989. it additional job specifications (@pxref{Service Composition}). In
  7990. other words, it is possible to define services that provide additional
  7991. mcron jobs to run.
  7992. @end defvr
  7993. @deftp {Data Type} mcron-configuration
  7994. Data type representing the configuration of mcron.
  7995. @table @asis
  7996. @item @code{mcron} (default: @var{mcron2})
  7997. The mcron package to use.
  7998. @item @code{jobs}
  7999. This is a list of gexps (@pxref{G-Expressions}), where each gexp
  8000. corresponds to an mcron job specification (@pxref{Syntax, mcron job
  8001. specifications,, mcron, GNU@tie{}mcron}).
  8002. @end table
  8003. @end deftp
  8004. @node Log Rotation
  8005. @subsubsection Log Rotation
  8006. @cindex rottlog
  8007. @cindex log rotation
  8008. @cindex logging
  8009. Log files such as those found in @file{/var/log} tend to grow endlessly,
  8010. so it's a good idea to @dfn{rotate} them once in a while---i.e., archive
  8011. their contents in separate files, possibly compressed. The @code{(gnu
  8012. services admin)} module provides an interface to GNU@tie{}Rot[t]log, a
  8013. log rotation tool (@pxref{Top,,, rottlog, GNU Rot[t]log Manual}).
  8014. The example below defines an operating system that provides log rotation
  8015. with the default settings, for commonly encountered log files.
  8016. @lisp
  8017. (use-modules (guix) (gnu))
  8018. (use-service-modules admin mcron)
  8019. (use-package-modules base idutils)
  8020. (operating-system
  8021. ;; @dots{}
  8022. (services (cons* (service mcron-service-type)
  8023. (service rottlog-service-type)
  8024. %base-services)))
  8025. @end lisp
  8026. @defvr {Scheme Variable} rottlog-service-type
  8027. This is the type of the Rottlog service, whose value is a
  8028. @code{rottlog-configuration} object.
  8029. Other services can extend this one with new @code{log-rotation} objects
  8030. (see below), thereby augmenting the set of files to be rotated.
  8031. This service type can define mcron jobs (@pxref{Scheduled Job
  8032. Execution}) to run the rottlog service.
  8033. @end defvr
  8034. @deftp {Data Type} rottlog-configuration
  8035. Data type representing the configuration of rottlog.
  8036. @table @asis
  8037. @item @code{rottlog} (default: @code{rottlog})
  8038. The Rottlog package to use.
  8039. @item @code{rc-file} (default: @code{(file-append rottlog "/etc/rc")})
  8040. The Rottlog configuration file to use (@pxref{Mandatory RC Variables,,,
  8041. rottlog, GNU Rot[t]log Manual}).
  8042. @item @code{rotations} (default: @code{%default-rotations})
  8043. A list of @code{log-rotation} objects as defined below.
  8044. @item @code{jobs}
  8045. This is a list of gexps where each gexp corresponds to an mcron job
  8046. specification (@pxref{Scheduled Job Execution}).
  8047. @end table
  8048. @end deftp
  8049. @deftp {Data Type} log-rotation
  8050. Data type representing the rotation of a group of log files.
  8051. Taking an example from the Rottlog manual (@pxref{Period Related File
  8052. Examples,,, rottlog, GNU Rot[t]log Manual}), a log rotation might be
  8053. defined like this:
  8054. @example
  8055. (log-rotation
  8056. (frequency 'daily)
  8057. (files '("/var/log/apache/*"))
  8058. (options '("storedir apache-archives"
  8059. "rotate 6"
  8060. "notifempty"
  8061. "nocompress")))
  8062. @end example
  8063. The list of fields is as follows:
  8064. @table @asis
  8065. @item @code{frequency} (default: @code{'weekly})
  8066. The log rotation frequency, a symbol.
  8067. @item @code{files}
  8068. The list of files or file glob patterns to rotate.
  8069. @item @code{options} (default: @code{'()})
  8070. The list of rottlog options for this rotation (@pxref{Configuration
  8071. parameters,,, rottlog, GNU Rot[t]lg Manual}).
  8072. @item @code{post-rotate} (default: @code{#f})
  8073. Either @code{#f} or a gexp to execute once the rotation has completed.
  8074. @end table
  8075. @end deftp
  8076. @defvr {Scheme Variable} %default-rotations
  8077. Specifies weekly rotation of @var{%rotated-files} and
  8078. a couple of other files.
  8079. @end defvr
  8080. @defvr {Scheme Variable} %rotated-files
  8081. The list of syslog-controlled files to be rotated. By default it is:
  8082. @code{'("/var/log/messages" "/var/log/secure")}.
  8083. @end defvr
  8084. @node Networking Services
  8085. @subsubsection Networking Services
  8086. The @code{(gnu services networking)} module provides services to configure
  8087. the network interface.
  8088. @cindex DHCP, networking service
  8089. @deffn {Scheme Procedure} dhcp-client-service [#:dhcp @var{isc-dhcp}]
  8090. Return a service that runs @var{dhcp}, a Dynamic Host Configuration
  8091. Protocol (DHCP) client, on all the non-loopback network interfaces.
  8092. @end deffn
  8093. @defvr {Scheme Variable} static-networking-service-type
  8094. This is the type for statically-configured network interfaces.
  8095. @c TODO Document <static-networking> data structures.
  8096. @end defvr
  8097. @deffn {Scheme Procedure} static-networking-service @var{interface} @var{ip} @
  8098. [#:netmask #f] [#:gateway #f] [#:name-servers @code{'()}]
  8099. Return a service that starts @var{interface} with address @var{ip}. If
  8100. @var{netmask} is true, use it as the network mask. If @var{gateway} is true,
  8101. it must be a string specifying the default network gateway.
  8102. This procedure can be called several times, one for each network
  8103. interface of interest. Behind the scenes what it does is extend
  8104. @code{static-networking-service-type} with additional network interfaces
  8105. to handle.
  8106. @end deffn
  8107. @cindex wicd
  8108. @cindex wireless
  8109. @cindex WiFi
  8110. @cindex network management
  8111. @deffn {Scheme Procedure} wicd-service [#:wicd @var{wicd}]
  8112. Return a service that runs @url{https://launchpad.net/wicd,Wicd}, a network
  8113. management daemon that aims to simplify wired and wireless networking.
  8114. This service adds the @var{wicd} package to the global profile, providing
  8115. several commands to interact with the daemon and configure networking:
  8116. @command{wicd-client}, a graphical user interface, and the @command{wicd-cli}
  8117. and @command{wicd-curses} user interfaces.
  8118. @end deffn
  8119. @cindex NetworkManager
  8120. @defvr {Scheme Variable} network-manager-service-type
  8121. This is the service type for the
  8122. @uref{https://wiki.gnome.org/Projects/NetworkManager, NetworkManager}
  8123. service. The value for this service type is a
  8124. @code{network-manager-configuration} record.
  8125. This service is part of @code{%desktop-services} (@pxref{Desktop
  8126. Services}).
  8127. @end defvr
  8128. @deftp {Data Type} network-manager-configuration
  8129. Data type representing the configuration of NetworkManager.
  8130. @table @asis
  8131. @item @code{network-manager} (default: @code{network-manager})
  8132. The NetworkManager package to use.
  8133. @item @code{dns} (default: @code{"default"})
  8134. Processing mode for DNS, which affects how NetworkManager uses the
  8135. @code{resolv.conf} configuration file.
  8136. @table @samp
  8137. @item default
  8138. NetworkManager will update @code{resolv.conf} to reflect the nameservers
  8139. provided by currently active connections.
  8140. @item dnsmasq
  8141. NetworkManager will run @code{dnsmasq} as a local caching nameserver,
  8142. using a "split DNS" configuration if you are connected to a VPN, and
  8143. then update @code{resolv.conf} to point to the local nameserver.
  8144. @item none
  8145. NetworkManager will not modify @code{resolv.conf}.
  8146. @end table
  8147. @item @code{vpn-plugins} (default: @code{'()})
  8148. This is the list of available plugins for virtual private networks
  8149. (VPNs). An example of this is the @code{network-manager-openvpn}
  8150. package, which allows NetworkManager to manage VPNs @i{via} OpenVPN.
  8151. @end table
  8152. @end deftp
  8153. @cindex Connman
  8154. @deffn {Scheme Variable} connman-service-type
  8155. This is the service type to run @url{https://01.org/connman,Connman},
  8156. a network connection manager.
  8157. Its value must be an
  8158. @code{connman-configuration} record as in this example:
  8159. @example
  8160. (service connman-service-type
  8161. (connman-configuration
  8162. (disable-vpn? #t)))
  8163. @end example
  8164. See below for details about @code{connman-configuration}.
  8165. @end deffn
  8166. @deftp {Data Type} connman-configuration
  8167. Data Type representing the configuration of connman.
  8168. @table @asis
  8169. @item @code{connman} (default: @var{connman})
  8170. The connman package to use.
  8171. @item @code{disable-vpn?} (default: @code{#f})
  8172. When true, enable connman's vpn plugin.
  8173. @end table
  8174. @end deftp
  8175. @cindex WPA Supplicant
  8176. @defvr {Scheme Variable} wpa-supplicant-service-type
  8177. This is the service type to run @url{https://w1.fi/wpa_supplicant/,WPA
  8178. supplicant}, an authentication daemon required to authenticate against
  8179. encrypted WiFi or ethernet networks. It is configured to listen for
  8180. requests on D-Bus.
  8181. The value of this service is the @code{wpa-supplicant} package to use.
  8182. Thus, it can be instantiated like this:
  8183. @lisp
  8184. (use-modules (gnu services networking))
  8185. (service wpa-supplicant-service-type)
  8186. @end lisp
  8187. @end defvr
  8188. @cindex NTP
  8189. @cindex real time clock
  8190. @deffn {Scheme Procedure} ntp-service [#:ntp @var{ntp}] @
  8191. [#:servers @var{%ntp-servers}] @
  8192. [#:allow-large-adjustment? #f]
  8193. Return a service that runs the daemon from @var{ntp}, the
  8194. @uref{http://www.ntp.org, Network Time Protocol package}. The daemon will
  8195. keep the system clock synchronized with that of @var{servers}.
  8196. @var{allow-large-adjustment?} determines whether @command{ntpd} is allowed to
  8197. make an initial adjustment of more than 1,000 seconds.
  8198. @end deffn
  8199. @defvr {Scheme Variable} %ntp-servers
  8200. List of host names used as the default NTP servers.
  8201. @end defvr
  8202. @cindex inetd
  8203. @deffn {Scheme variable} inetd-service-type
  8204. This service runs the @command{inetd} (@pxref{inetd invocation,,,
  8205. inetutils, GNU Inetutils}) daemon. @command{inetd} listens for
  8206. connections on internet sockets, and lazily starts the specified server
  8207. program when a connection is made on one of these sockets.
  8208. The value of this service is an @code{inetd-configuration} object. The
  8209. following example configures the @command{inetd} daemon to provide the
  8210. built-in @command{echo} service, as well as an smtp service which
  8211. forwards smtp traffic over ssh to a server @code{smtp-server} behind a
  8212. gateway @code{hostname}:
  8213. @example
  8214. (service
  8215. inetd-service-type
  8216. (inetd-configuration
  8217. (entries (list
  8218. (inetd-entry
  8219. (name "echo")
  8220. (socket-type 'stream)
  8221. (protocol "tcp")
  8222. (wait? #f)
  8223. (user "root"))
  8224. (inetd-entry
  8225. (node "127.0.0.1")
  8226. (name "smtp")
  8227. (socket-type 'stream)
  8228. (protocol "tcp")
  8229. (wait? #f)
  8230. (user "root")
  8231. (program (file-append openssh "/bin/ssh"))
  8232. (arguments
  8233. '("ssh" "-qT" "-i" "/path/to/ssh_key"
  8234. "-W" "smtp-server:25" "user@@hostname")))))
  8235. @end example
  8236. See below for more details about @code{inetd-configuration}.
  8237. @end deffn
  8238. @deftp {Data Type} inetd-configuration
  8239. Data type representing the configuration of @command{inetd}.
  8240. @table @asis
  8241. @item @code{program} (default: @code{(file-append inetutils "/libexec/inetd")})
  8242. The @command{inetd} executable to use.
  8243. @item @code{entries} (default: @code{'()})
  8244. A list of @command{inetd} service entries. Each entry should be created
  8245. by the @code{inetd-entry} constructor.
  8246. @end table
  8247. @end deftp
  8248. @deftp {Data Type} inetd-entry
  8249. Data type representing an entry in the @command{inetd} configuration.
  8250. Each entry corresponds to a socket where @command{inetd} will listen for
  8251. requests.
  8252. @table @asis
  8253. @item @code{node} (default: @code{#f})
  8254. Optional string, a comma-separated list of local addresses
  8255. @command{inetd} should use when listening for this service.
  8256. @xref{Configuration file,,, inetutils, GNU Inetutils} for a complete
  8257. description of all options.
  8258. @item @code{name}
  8259. A string, the name must correspond to an entry in @code{/etc/services}.
  8260. @item @code{socket-type}
  8261. One of @code{'stream}, @code{'dgram}, @code{'raw}, @code{'rdm} or
  8262. @code{'seqpacket}.
  8263. @item @code{protocol}
  8264. A string, must correspond to an entry in @code{/etc/protocols}.
  8265. @item @code{wait?} (default: @code{#t})
  8266. Whether @command{inetd} should wait for the server to exit before
  8267. listening to new service requests.
  8268. @item @code{user}
  8269. A string containing the user (and, optionally, group) name of the user
  8270. as whom the server should run. The group name can be specified in a
  8271. suffix, separated by a colon or period, i.e. @code{"user"},
  8272. @code{"user:group"} or @code{"user.group"}.
  8273. @item @code{program} (default: @code{"internal"})
  8274. The server program which will serve the requests, or @code{"internal"}
  8275. if @command{inetd} should use a built-in service.
  8276. @item @code{arguments} (default: @code{'()})
  8277. A list strings or file-like objects, which are the server program's
  8278. arguments, starting with the zeroth argument, i.e. the name of the
  8279. program itself. For @command{inetd}'s internal services, this entry
  8280. must be @code{'()} or @code{'("internal")}.
  8281. @end table
  8282. @xref{Configuration file,,, inetutils, GNU Inetutils} for a more
  8283. detailed discussion of each configuration field.
  8284. @end deftp
  8285. @cindex Tor
  8286. @deffn {Scheme Procedure} tor-service [@var{config-file}] [#:tor @var{tor}]
  8287. Return a service to run the @uref{https://torproject.org, Tor} anonymous
  8288. networking daemon.
  8289. The daemon runs as the @code{tor} unprivileged user. It is passed
  8290. @var{config-file}, a file-like object, with an additional @code{User tor} line
  8291. and lines for hidden services added via @code{tor-hidden-service}. Run
  8292. @command{man tor} for information about the configuration file.
  8293. @end deffn
  8294. @cindex hidden service
  8295. @deffn {Scheme Procedure} tor-hidden-service @var{name} @var{mapping}
  8296. Define a new Tor @dfn{hidden service} called @var{name} and implementing
  8297. @var{mapping}. @var{mapping} is a list of port/host tuples, such as:
  8298. @example
  8299. '((22 "127.0.0.1:22")
  8300. (80 "127.0.0.1:8080"))
  8301. @end example
  8302. In this example, port 22 of the hidden service is mapped to local port 22, and
  8303. port 80 is mapped to local port 8080.
  8304. This creates a @file{/var/lib/tor/hidden-services/@var{name}} directory, where
  8305. the @file{hostname} file contains the @code{.onion} host name for the hidden
  8306. service.
  8307. See @uref{https://www.torproject.org/docs/tor-hidden-service.html.en, the Tor
  8308. project's documentation} for more information.
  8309. @end deffn
  8310. @deffn {Scheme Procedure} bitlbee-service [#:bitlbee bitlbee] @
  8311. [#:interface "127.0.0.1"] [#:port 6667] @
  8312. [#:extra-settings ""]
  8313. Return a service that runs @url{http://bitlbee.org,BitlBee}, a daemon that
  8314. acts as a gateway between IRC and chat networks.
  8315. The daemon will listen to the interface corresponding to the IP address
  8316. specified in @var{interface}, on @var{port}. @code{127.0.0.1} means that only
  8317. local clients can connect, whereas @code{0.0.0.0} means that connections can
  8318. come from any networking interface.
  8319. In addition, @var{extra-settings} specifies a string to append to the
  8320. configuration file.
  8321. @end deffn
  8322. The @code{(gnu services rsync)} module provides the following services:
  8323. You might want an rsync daemon if you have files that you want available
  8324. so anyone (or just yourself) can download existing files or upload new
  8325. files.
  8326. @deffn {Scheme Variable} rsync-service-type
  8327. This is the type for the @uref{https://rsync.samba.org, rsync} rsync daemon,
  8328. @command{rsync-configuration} record as in this example:
  8329. @example
  8330. (service rsync-service-type)
  8331. @end example
  8332. See below for details about @code{rsync-configuration}.
  8333. @end deffn
  8334. @deftp {Data Type} rsync-configuration
  8335. Data type representing the configuration for @code{rsync-service}.
  8336. @table @asis
  8337. @item @code{package} (default: @var{rsync})
  8338. @code{rsync} package to use.
  8339. @item @code{port-number} (default: @code{873})
  8340. TCP port on which @command{rsync} listens for incoming connections. If port
  8341. is less than @code{1024} @command{rsync} needs to be started as the
  8342. @code{root} user and group.
  8343. @item @code{pid-file} (default: @code{"/var/run/rsyncd/rsyncd.pid"})
  8344. Name of the file where @command{rsync} writes its PID.
  8345. @item @code{lock-file} (default: @code{"/var/run/rsyncd/rsyncd.lock"})
  8346. Name of the file where @command{rsync} writes its lock file.
  8347. @item @code{log-file} (default: @code{"/var/log/rsyncd.log"})
  8348. Name of the file where @command{rsync} writes its log file.
  8349. @item @code{use-chroot?} (default: @var{#t})
  8350. Whether to use chroot for @command{rsync} shared directory.
  8351. @item @code{share-path} (default: @file{/srv/rsync})
  8352. Location of the @command{rsync} shared directory.
  8353. @item @code{share-comment} (default: @code{"Rsync share"})
  8354. Comment of the @command{rsync} shared directory.
  8355. @item @code{read-only?} (default: @var{#f})
  8356. Read-write permissions to shared directory.
  8357. @item @code{timeout} (default: @code{300})
  8358. I/O timeout in seconds.
  8359. @item @code{user} (default: @var{"root"})
  8360. Owner of the @code{rsync} process.
  8361. @item @code{group} (default: @var{"root"})
  8362. Group of the @code{rsync} process.
  8363. @item @code{uid} (default: @var{"rsyncd"})
  8364. User name or user ID that file transfers to and from that module should take
  8365. place as when the daemon was run as @code{root}.
  8366. @item @code{gid} (default: @var{"rsyncd"})
  8367. Group name or group ID that will be used when accessing the module.
  8368. @end table
  8369. @end deftp
  8370. Furthermore, @code{(gnu services ssh)} provides the following services.
  8371. @cindex SSH
  8372. @cindex SSH server
  8373. @deffn {Scheme Procedure} lsh-service [#:host-key "/etc/lsh/host-key"] @
  8374. [#:daemonic? #t] [#:interfaces '()] [#:port-number 22] @
  8375. [#:allow-empty-passwords? #f] [#:root-login? #f] @
  8376. [#:syslog-output? #t] [#:x11-forwarding? #t] @
  8377. [#:tcp/ip-forwarding? #t] [#:password-authentication? #t] @
  8378. [#:public-key-authentication? #t] [#:initialize? #t]
  8379. Run the @command{lshd} program from @var{lsh} to listen on port @var{port-number}.
  8380. @var{host-key} must designate a file containing the host key, and readable
  8381. only by root.
  8382. When @var{daemonic?} is true, @command{lshd} will detach from the
  8383. controlling terminal and log its output to syslogd, unless one sets
  8384. @var{syslog-output?} to false. Obviously, it also makes lsh-service
  8385. depend on existence of syslogd service. When @var{pid-file?} is true,
  8386. @command{lshd} writes its PID to the file called @var{pid-file}.
  8387. When @var{initialize?} is true, automatically create the seed and host key
  8388. upon service activation if they do not exist yet. This may take long and
  8389. require interaction.
  8390. When @var{initialize?} is false, it is up to the user to initialize the
  8391. randomness generator (@pxref{lsh-make-seed,,, lsh, LSH Manual}), and to create
  8392. a key pair with the private key stored in file @var{host-key} (@pxref{lshd
  8393. basics,,, lsh, LSH Manual}).
  8394. When @var{interfaces} is empty, lshd listens for connections on all the
  8395. network interfaces; otherwise, @var{interfaces} must be a list of host names
  8396. or addresses.
  8397. @var{allow-empty-passwords?} specifies whether to accept log-ins with empty
  8398. passwords, and @var{root-login?} specifies whether to accept log-ins as
  8399. root.
  8400. The other options should be self-descriptive.
  8401. @end deffn
  8402. @cindex SSH
  8403. @cindex SSH server
  8404. @deffn {Scheme Variable} openssh-service-type
  8405. This is the type for the @uref{http://www.openssh.org, OpenSSH} secure
  8406. shell daemon, @command{sshd}. Its value must be an
  8407. @code{openssh-configuration} record as in this example:
  8408. @example
  8409. (service openssh-service-type
  8410. (openssh-configuration
  8411. (x11-forwarding? #t)
  8412. (permit-root-login 'without-password)
  8413. (authorized-keys
  8414. `(("alice" ,(local-file "alice.pub"))
  8415. ("bob" ,(local-file "bob.pub"))))))
  8416. @end example
  8417. See below for details about @code{openssh-configuration}.
  8418. This service can be extended with extra authorized keys, as in this
  8419. example:
  8420. @example
  8421. (service-extension openssh-service-type
  8422. (const `(("charlie"
  8423. ,(local-file "charlie.pub")))))
  8424. @end example
  8425. @end deffn
  8426. @deftp {Data Type} openssh-configuration
  8427. This is the configuration record for OpenSSH's @command{sshd}.
  8428. @table @asis
  8429. @item @code{pid-file} (default: @code{"/var/run/sshd.pid"})
  8430. Name of the file where @command{sshd} writes its PID.
  8431. @item @code{port-number} (default: @code{22})
  8432. TCP port on which @command{sshd} listens for incoming connections.
  8433. @item @code{permit-root-login} (default: @code{#f})
  8434. This field determines whether and when to allow logins as root. If
  8435. @code{#f}, root logins are disallowed; if @code{#t}, they are allowed.
  8436. If it's the symbol @code{'without-password}, then root logins are
  8437. permitted but not with password-based authentication.
  8438. @item @code{allow-empty-passwords?} (default: @code{#f})
  8439. When true, users with empty passwords may log in. When false, they may
  8440. not.
  8441. @item @code{password-authentication?} (default: @code{#t})
  8442. When true, users may log in with their password. When false, they have
  8443. other authentication methods.
  8444. @item @code{public-key-authentication?} (default: @code{#t})
  8445. When true, users may log in using public key authentication. When
  8446. false, users have to use other authentication method.
  8447. Authorized public keys are stored in @file{~/.ssh/authorized_keys}.
  8448. This is used only by protocol version 2.
  8449. @item @code{x11-forwarding?} (default: @code{#f})
  8450. When true, forwarding of X11 graphical client connections is
  8451. enabled---in other words, @command{ssh} options @option{-X} and
  8452. @option{-Y} will work.
  8453. @item @code{challenge-response-authentication?} (default: @code{#f})
  8454. Specifies whether challenge response authentication is allowed (e.g. via
  8455. PAM).
  8456. @item @code{use-pam?} (default: @code{#t})
  8457. Enables the Pluggable Authentication Module interface. If set to
  8458. @code{#t}, this will enable PAM authentication using
  8459. @code{challenge-response-authentication?} and
  8460. @code{password-authentication?}, in addition to PAM account and session
  8461. module processing for all authentication types.
  8462. Because PAM challenge response authentication usually serves an
  8463. equivalent role to password authentication, you should disable either
  8464. @code{challenge-response-authentication?} or
  8465. @code{password-authentication?}.
  8466. @item @code{print-last-log?} (default: @code{#t})
  8467. Specifies whether @command{sshd} should print the date and time of the
  8468. last user login when a user logs in interactively.
  8469. @item @code{subsystems} (default: @code{'(("sftp" "internal-sftp"))})
  8470. Configures external subsystems (e.g. file transfer daemon).
  8471. This is a list of two-element lists, each of which containing the
  8472. subsystem name and a command (with optional arguments) to execute upon
  8473. subsystem request.
  8474. The command @command{internal-sftp} implements an in-process SFTP
  8475. server. Alternately, one can specify the @command{sftp-server} command:
  8476. @example
  8477. (service openssh-service-type
  8478. (openssh-configuration
  8479. (subsystems
  8480. `(("sftp" ,(file-append openssh "/libexec/sftp-server"))))))
  8481. @end example
  8482. @item @code{authorized-keys} (default: @code{'()})
  8483. @cindex authorized keys, SSH
  8484. @cindex SSH authorized keys
  8485. This is the list of authorized keys. Each element of the list is a user
  8486. name followed by one or more file-like objects that represent SSH public
  8487. keys. For example:
  8488. @example
  8489. (openssh-configuration
  8490. (authorized-keys
  8491. `(("rekado" ,(local-file "rekado.pub"))
  8492. ("chris" ,(local-file "chris.pub"))
  8493. ("root" ,(local-file "rekado.pub") ,(local-file "chris.pub")))))
  8494. @end example
  8495. @noindent
  8496. registers the specified public keys for user accounts @code{rekado},
  8497. @code{chris}, and @code{root}.
  8498. Additional authorized keys can be specified @i{via}
  8499. @code{service-extension}.
  8500. Note that this does @emph{not} interfere with the use of
  8501. @file{~/.ssh/authorized_keys}.
  8502. @end table
  8503. @end deftp
  8504. @deffn {Scheme Procedure} dropbear-service [@var{config}]
  8505. Run the @uref{https://matt.ucc.asn.au/dropbear/dropbear.html,Dropbear SSH
  8506. daemon} with the given @var{config}, a @code{<dropbear-configuration>}
  8507. object.
  8508. For example, to specify a Dropbear service listening on port 1234, add
  8509. this call to the operating system's @code{services} field:
  8510. @example
  8511. (dropbear-service (dropbear-configuration
  8512. (port-number 1234)))
  8513. @end example
  8514. @end deffn
  8515. @deftp {Data Type} dropbear-configuration
  8516. This data type represents the configuration of a Dropbear SSH daemon.
  8517. @table @asis
  8518. @item @code{dropbear} (default: @var{dropbear})
  8519. The Dropbear package to use.
  8520. @item @code{port-number} (default: 22)
  8521. The TCP port where the daemon waits for incoming connections.
  8522. @item @code{syslog-output?} (default: @code{#t})
  8523. Whether to enable syslog output.
  8524. @item @code{pid-file} (default: @code{"/var/run/dropbear.pid"})
  8525. File name of the daemon's PID file.
  8526. @item @code{root-login?} (default: @code{#f})
  8527. Whether to allow @code{root} logins.
  8528. @item @code{allow-empty-passwords?} (default: @code{#f})
  8529. Whether to allow empty passwords.
  8530. @item @code{password-authentication?} (default: @code{#t})
  8531. Whether to enable password-based authentication.
  8532. @end table
  8533. @end deftp
  8534. @defvr {Scheme Variable} %facebook-host-aliases
  8535. This variable contains a string for use in @file{/etc/hosts}
  8536. (@pxref{Host Names,,, libc, The GNU C Library Reference Manual}). Each
  8537. line contains a entry that maps a known server name of the Facebook
  8538. on-line service---e.g., @code{www.facebook.com}---to the local
  8539. host---@code{127.0.0.1} or its IPv6 equivalent, @code{::1}.
  8540. This variable is typically used in the @code{hosts-file} field of an
  8541. @code{operating-system} declaration (@pxref{operating-system Reference,
  8542. @file{/etc/hosts}}):
  8543. @example
  8544. (use-modules (gnu) (guix))
  8545. (operating-system
  8546. (host-name "mymachine")
  8547. ;; ...
  8548. (hosts-file
  8549. ;; Create a /etc/hosts file with aliases for "localhost"
  8550. ;; and "mymachine", as well as for Facebook servers.
  8551. (plain-file "hosts"
  8552. (string-append (local-host-aliases host-name)
  8553. %facebook-host-aliases))))
  8554. @end example
  8555. This mechanism can prevent programs running locally, such as Web
  8556. browsers, from accessing Facebook.
  8557. @end defvr
  8558. The @code{(gnu services avahi)} provides the following definition.
  8559. @deffn {Scheme Procedure} avahi-service [#:avahi @var{avahi}] @
  8560. [#:host-name #f] [#:publish? #t] [#:ipv4? #t] @
  8561. [#:ipv6? #t] [#:wide-area? #f] @
  8562. [#:domains-to-browse '()] [#:debug? #f]
  8563. Return a service that runs @command{avahi-daemon}, a system-wide
  8564. mDNS/DNS-SD responder that allows for service discovery and
  8565. "zero-configuration" host name lookups (see @uref{http://avahi.org/}), and
  8566. extends the name service cache daemon (nscd) so that it can resolve
  8567. @code{.local} host names using
  8568. @uref{http://0pointer.de/lennart/projects/nss-mdns/, nss-mdns}. Additionally,
  8569. add the @var{avahi} package to the system profile so that commands such as
  8570. @command{avahi-browse} are directly usable.
  8571. If @var{host-name} is different from @code{#f}, use that as the host name to
  8572. publish for this machine; otherwise, use the machine's actual host name.
  8573. When @var{publish?} is true, publishing of host names and services is allowed;
  8574. in particular, avahi-daemon will publish the machine's host name and IP
  8575. address via mDNS on the local network.
  8576. When @var{wide-area?} is true, DNS-SD over unicast DNS is enabled.
  8577. Boolean values @var{ipv4?} and @var{ipv6?} determine whether to use IPv4/IPv6
  8578. sockets.
  8579. @end deffn
  8580. @deffn {Scheme Variable} openvswitch-service-type
  8581. This is the type of the @uref{http://www.openvswitch.org, Open vSwitch}
  8582. service, whose value should be an @code{openvswitch-configuration}
  8583. object.
  8584. @end deffn
  8585. @deftp {Data Type} openvswitch-configuration
  8586. Data type representing the configuration of Open vSwitch, a multilayer
  8587. virtual switch which is designed to enable massive network automation
  8588. through programmatic extension.
  8589. @table @asis
  8590. @item @code{package} (default: @var{openvswitch})
  8591. Package object of the Open vSwitch.
  8592. @end table
  8593. @end deftp
  8594. @node X Window
  8595. @subsubsection X Window
  8596. @cindex X11
  8597. @cindex X Window System
  8598. Support for the X Window graphical display system---specifically
  8599. Xorg---is provided by the @code{(gnu services xorg)} module. Note that
  8600. there is no @code{xorg-service} procedure. Instead, the X server is
  8601. started by the @dfn{login manager}, currently SLiM.
  8602. @deftp {Data Type} sddm-configuration
  8603. This is the data type representing the sddm service configuration.
  8604. @table @asis
  8605. @item @code{display-server} (default: "x11")
  8606. Select display server to use for the greeter. Valid values are "x11"
  8607. or "wayland".
  8608. @item @code{numlock} (default: "on")
  8609. Valid values are "on", "off" or "none".
  8610. @item @code{halt-command} (default @code{#~(string-apppend #$shepherd "/sbin/halt")})
  8611. Command to run when halting.
  8612. @item @code{reboot-command} (default @code{#~(string-append #$shepherd "/sbin/reboot")})
  8613. Command to run when rebooting.
  8614. @item @code{theme} (default "maldives")
  8615. Theme to use. Default themes provided by SDDM are "elarun" or "maldives".
  8616. @item @code{themes-directory} (default "/run/current-system/profile/share/sddm/themes")
  8617. Directory to look for themes.
  8618. @item @code{faces-directory} (default "/run/current-system/profile/share/sddm/faces")
  8619. Directory to look for faces.
  8620. @item @code{default-path} (default "/run/current-system/profile/bin")
  8621. Default PATH to use.
  8622. @item @code{minimum-uid} (default 1000)
  8623. Minimum UID to display in SDDM.
  8624. @item @code{maximum-uid} (default 2000)
  8625. Maximum UID to display in SDDM
  8626. @item @code{remember-last-user?} (default #t)
  8627. Remember last user.
  8628. @item @code{remember-last-session?} (default #t)
  8629. Remember last session.
  8630. @item @code{hide-users} (default "")
  8631. Usernames to hide from SDDM greeter.
  8632. @item @code{hide-shells} (default @code{#~(string-append #$shadow "/sbin/nologin")})
  8633. Users with shells listed will be hidden from the SDDM greeter.
  8634. @item @code{session-command} (default @code{#~(string-append #$sddm "/share/sddm/scripts/wayland-session")})
  8635. Script to run before starting a wayland session.
  8636. @item @code{sessions-directory} (default "/run/current-system/profile/share/wayland-sessions")
  8637. Directory to look for desktop files starting wayland sessions.
  8638. @item @code{xorg-server-path} (default @code{xorg-start-command})
  8639. Path to xorg-server.
  8640. @item @code{xauth-path} (default @code{#~(string-append #$xauth "/bin/xauth")})
  8641. Path to xauth.
  8642. @item @code{xephyr-path} (default @code{#~(string-append #$xorg-server "/bin/Xephyr")})
  8643. Path to Xephyr.
  8644. @item @code{xdisplay-start} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xsetup")})
  8645. Script to run after starting xorg-server.
  8646. @item @code{xdisplay-stop} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xstop")})
  8647. Script to run before stopping xorg-server.
  8648. @item @code{xsession-command} (default: @code{xinitr })
  8649. Script to run before starting a X session.
  8650. @item @code{xsessions-directory} (default: "/run/current-system/profile/share/xsessions")
  8651. Directory to look for desktop files starting X sessions.
  8652. @item @code{minimum-vt} (default: 7)
  8653. Minimum VT to use.
  8654. @item @code{xserver-arguments} (default "-nolisten tcp")
  8655. Arguments to pass to xorg-server.
  8656. @item @code{auto-login-user} (default "")
  8657. User to use for auto-login.
  8658. @item @code{auto-login-session} (default "")
  8659. Desktop file to use for auto-login.
  8660. @item @code{relogin?} (default #f)
  8661. Relogin after logout.
  8662. @end table
  8663. @end deftp
  8664. @cindex login manager
  8665. @deffn {Scheme Procedure} sddm-service config
  8666. Return a service that spawns the SDDM graphical login manager for config of
  8667. type @code{<sddm-configuration>}.
  8668. @example
  8669. (sddm-service (sddm-configuration
  8670. (auto-login-user "Alice")
  8671. (auto-login-session "xfce.desktop")))
  8672. @end example
  8673. @end deffn
  8674. @deffn {Scheme Procedure} slim-service [#:allow-empty-passwords? #f] @
  8675. [#:auto-login? #f] [#:default-user ""] [#:startx] @
  8676. [#:theme @var{%default-slim-theme}] @
  8677. [#:theme-name @var{%default-slim-theme-name}]
  8678. Return a service that spawns the SLiM graphical login manager, which in
  8679. turn starts the X display server with @var{startx}, a command as returned by
  8680. @code{xorg-start-command}.
  8681. @cindex X session
  8682. SLiM automatically looks for session types described by the @file{.desktop}
  8683. files in @file{/run/current-system/profile/share/xsessions} and allows users
  8684. to choose a session from the log-in screen using @kbd{F1}. Packages such as
  8685. @var{xfce}, @var{sawfish}, and @var{ratpoison} provide @file{.desktop} files;
  8686. adding them to the system-wide set of packages automatically makes them
  8687. available at the log-in screen.
  8688. In addition, @file{~/.xsession} files are honored. When available,
  8689. @file{~/.xsession} must be an executable that starts a window manager
  8690. and/or other X clients.
  8691. When @var{allow-empty-passwords?} is true, allow logins with an empty
  8692. password. When @var{auto-login?} is true, log in automatically as
  8693. @var{default-user}.
  8694. If @var{theme} is @code{#f}, use the default log-in theme; otherwise
  8695. @var{theme} must be a gexp denoting the name of a directory containing the
  8696. theme to use. In that case, @var{theme-name} specifies the name of the
  8697. theme.
  8698. @end deffn
  8699. @defvr {Scheme Variable} %default-theme
  8700. @defvrx {Scheme Variable} %default-theme-name
  8701. The G-Expression denoting the default SLiM theme and its name.
  8702. @end defvr
  8703. @deffn {Scheme Procedure} xorg-start-command [#:guile] @
  8704. [#:configuration-file #f] [#:xorg-server @var{xorg-server}]
  8705. Return a derivation that builds a @var{guile} script to start the X server
  8706. from @var{xorg-server}. @var{configuration-file} is the server configuration
  8707. file or a derivation that builds it; when omitted, the result of
  8708. @code{xorg-configuration-file} is used.
  8709. Usually the X server is started by a login manager.
  8710. @end deffn
  8711. @deffn {Scheme Procedure} xorg-configuration-file @
  8712. [#:drivers '()] [#:resolutions '()] [#:extra-config '()]
  8713. Return a configuration file for the Xorg server containing search paths for
  8714. all the common drivers.
  8715. @var{drivers} must be either the empty list, in which case Xorg chooses a
  8716. graphics driver automatically, or a list of driver names that will be tried in
  8717. this order---e.g., @code{(\"modesetting\" \"vesa\")}.
  8718. Likewise, when @var{resolutions} is the empty list, Xorg chooses an
  8719. appropriate screen resolution; otherwise, it must be a list of
  8720. resolutions---e.g., @code{((1024 768) (640 480))}.
  8721. Last, @var{extra-config} is a list of strings or objects appended to the
  8722. @code{text-file*} argument list. It is used to pass extra text to be added
  8723. verbatim to the configuration file.
  8724. @end deffn
  8725. @deffn {Scheme Procedure} screen-locker-service @var{package} [@var{name}]
  8726. Add @var{package}, a package for a screen-locker or screen-saver whose
  8727. command is @var{program}, to the set of setuid programs and add a PAM entry
  8728. for it. For example:
  8729. @lisp
  8730. (screen-locker-service xlockmore "xlock")
  8731. @end lisp
  8732. makes the good ol' XlockMore usable.
  8733. @end deffn
  8734. @node Printing Services
  8735. @subsubsection Printing Services
  8736. @cindex printer support with CUPS
  8737. The @code{(gnu services cups)} module provides a Guix service definition
  8738. for the CUPS printing service. To add printer support to a GuixSD
  8739. system, add a @code{cups-service} to the operating system definition:
  8740. @deffn {Scheme Variable} cups-service-type
  8741. The service type for the CUPS print server. Its value should be a valid
  8742. CUPS configuration (see below). To use the default settings, simply
  8743. write:
  8744. @example
  8745. (service cups-service-type)
  8746. @end example
  8747. @end deffn
  8748. The CUPS configuration controls the basic things about your CUPS
  8749. installation: what interfaces it listens on, what to do if a print job
  8750. fails, how much logging to do, and so on. To actually add a printer,
  8751. you have to visit the @url{http://localhost:631} URL, or use a tool such
  8752. as GNOME's printer configuration services. By default, configuring a
  8753. CUPS service will generate a self-signed certificate if needed, for
  8754. secure connections to the print server.
  8755. Suppose you want to enable the Web interface of CUPS and also add
  8756. support for HP printers @i{via} the @code{hplip} package. You can do
  8757. that directly, like this (you need to use the @code{(gnu packages cups)}
  8758. module):
  8759. @example
  8760. (service cups-service-type
  8761. (cups-configuration
  8762. (web-interface? #t)
  8763. (extensions
  8764. (list cups-filters hplip))))
  8765. @end example
  8766. The available configuration parameters follow. Each parameter
  8767. definition is preceded by its type; for example, @samp{string-list foo}
  8768. indicates that the @code{foo} parameter should be specified as a list of
  8769. strings. There is also a way to specify the configuration as a string,
  8770. if you have an old @code{cupsd.conf} file that you want to port over
  8771. from some other system; see the end for more details.
  8772. @c The following documentation was initially generated by
  8773. @c (generate-documentation) in (gnu services cups). Manually maintained
  8774. @c documentation is better, so we shouldn't hesitate to edit below as
  8775. @c needed. However if the change you want to make to this documentation
  8776. @c can be done in an automated way, it's probably easier to change
  8777. @c (generate-documentation) than to make it below and have to deal with
  8778. @c the churn as CUPS updates.
  8779. Available @code{cups-configuration} fields are:
  8780. @deftypevr {@code{cups-configuration} parameter} package cups
  8781. The CUPS package.
  8782. @end deftypevr
  8783. @deftypevr {@code{cups-configuration} parameter} package-list extensions
  8784. Drivers and other extensions to the CUPS package.
  8785. @end deftypevr
  8786. @deftypevr {@code{cups-configuration} parameter} files-configuration files-configuration
  8787. Configuration of where to write logs, what directories to use for print
  8788. spools, and related privileged configuration parameters.
  8789. Available @code{files-configuration} fields are:
  8790. @deftypevr {@code{files-configuration} parameter} log-location access-log
  8791. Defines the access log filename. Specifying a blank filename disables
  8792. access log generation. The value @code{stderr} causes log entries to be
  8793. sent to the standard error file when the scheduler is running in the
  8794. foreground, or to the system log daemon when run in the background. The
  8795. value @code{syslog} causes log entries to be sent to the system log
  8796. daemon. The server name may be included in filenames using the string
  8797. @code{%s}, as in @code{/var/log/cups/%s-access_log}.
  8798. Defaults to @samp{"/var/log/cups/access_log"}.
  8799. @end deftypevr
  8800. @deftypevr {@code{files-configuration} parameter} file-name cache-dir
  8801. Where CUPS should cache data.
  8802. Defaults to @samp{"/var/cache/cups"}.
  8803. @end deftypevr
  8804. @deftypevr {@code{files-configuration} parameter} string config-file-perm
  8805. Specifies the permissions for all configuration files that the scheduler
  8806. writes.
  8807. Note that the permissions for the printers.conf file are currently
  8808. masked to only allow access from the scheduler user (typically root).
  8809. This is done because printer device URIs sometimes contain sensitive
  8810. authentication information that should not be generally known on the
  8811. system. There is no way to disable this security feature.
  8812. Defaults to @samp{"0640"}.
  8813. @end deftypevr
  8814. @deftypevr {@code{files-configuration} parameter} log-location error-log
  8815. Defines the error log filename. Specifying a blank filename disables
  8816. access log generation. The value @code{stderr} causes log entries to be
  8817. sent to the standard error file when the scheduler is running in the
  8818. foreground, or to the system log daemon when run in the background. The
  8819. value @code{syslog} causes log entries to be sent to the system log
  8820. daemon. The server name may be included in filenames using the string
  8821. @code{%s}, as in @code{/var/log/cups/%s-error_log}.
  8822. Defaults to @samp{"/var/log/cups/error_log"}.
  8823. @end deftypevr
  8824. @deftypevr {@code{files-configuration} parameter} string fatal-errors
  8825. Specifies which errors are fatal, causing the scheduler to exit. The
  8826. kind strings are:
  8827. @table @code
  8828. @item none
  8829. No errors are fatal.
  8830. @item all
  8831. All of the errors below are fatal.
  8832. @item browse
  8833. Browsing initialization errors are fatal, for example failed connections
  8834. to the DNS-SD daemon.
  8835. @item config
  8836. Configuration file syntax errors are fatal.
  8837. @item listen
  8838. Listen or Port errors are fatal, except for IPv6 failures on the
  8839. loopback or @code{any} addresses.
  8840. @item log
  8841. Log file creation or write errors are fatal.
  8842. @item permissions
  8843. Bad startup file permissions are fatal, for example shared TLS
  8844. certificate and key files with world-read permissions.
  8845. @end table
  8846. Defaults to @samp{"all -browse"}.
  8847. @end deftypevr
  8848. @deftypevr {@code{files-configuration} parameter} boolean file-device?
  8849. Specifies whether the file pseudo-device can be used for new printer
  8850. queues. The URI @uref{file:///dev/null} is always allowed.
  8851. Defaults to @samp{#f}.
  8852. @end deftypevr
  8853. @deftypevr {@code{files-configuration} parameter} string group
  8854. Specifies the group name or ID that will be used when executing external
  8855. programs.
  8856. Defaults to @samp{"lp"}.
  8857. @end deftypevr
  8858. @deftypevr {@code{files-configuration} parameter} string log-file-perm
  8859. Specifies the permissions for all log files that the scheduler writes.
  8860. Defaults to @samp{"0644"}.
  8861. @end deftypevr
  8862. @deftypevr {@code{files-configuration} parameter} log-location page-log
  8863. Defines the page log filename. Specifying a blank filename disables
  8864. access log generation. The value @code{stderr} causes log entries to be
  8865. sent to the standard error file when the scheduler is running in the
  8866. foreground, or to the system log daemon when run in the background. The
  8867. value @code{syslog} causes log entries to be sent to the system log
  8868. daemon. The server name may be included in filenames using the string
  8869. @code{%s}, as in @code{/var/log/cups/%s-page_log}.
  8870. Defaults to @samp{"/var/log/cups/page_log"}.
  8871. @end deftypevr
  8872. @deftypevr {@code{files-configuration} parameter} string remote-root
  8873. Specifies the username that is associated with unauthenticated accesses
  8874. by clients claiming to be the root user. The default is @code{remroot}.
  8875. Defaults to @samp{"remroot"}.
  8876. @end deftypevr
  8877. @deftypevr {@code{files-configuration} parameter} file-name request-root
  8878. Specifies the directory that contains print jobs and other HTTP request
  8879. data.
  8880. Defaults to @samp{"/var/spool/cups"}.
  8881. @end deftypevr
  8882. @deftypevr {@code{files-configuration} parameter} sandboxing sandboxing
  8883. Specifies the level of security sandboxing that is applied to print
  8884. filters, backends, and other child processes of the scheduler; either
  8885. @code{relaxed} or @code{strict}. This directive is currently only
  8886. used/supported on macOS.
  8887. Defaults to @samp{strict}.
  8888. @end deftypevr
  8889. @deftypevr {@code{files-configuration} parameter} file-name server-keychain
  8890. Specifies the location of TLS certificates and private keys. CUPS will
  8891. look for public and private keys in this directory: a @code{.crt} files
  8892. for PEM-encoded certificates and corresponding @code{.key} files for
  8893. PEM-encoded private keys.
  8894. Defaults to @samp{"/etc/cups/ssl"}.
  8895. @end deftypevr
  8896. @deftypevr {@code{files-configuration} parameter} file-name server-root
  8897. Specifies the directory containing the server configuration files.
  8898. Defaults to @samp{"/etc/cups"}.
  8899. @end deftypevr
  8900. @deftypevr {@code{files-configuration} parameter} boolean sync-on-close?
  8901. Specifies whether the scheduler calls fsync(2) after writing
  8902. configuration or state files.
  8903. Defaults to @samp{#f}.
  8904. @end deftypevr
  8905. @deftypevr {@code{files-configuration} parameter} space-separated-string-list system-group
  8906. Specifies the group(s) to use for @code{@@SYSTEM} group authentication.
  8907. @end deftypevr
  8908. @deftypevr {@code{files-configuration} parameter} file-name temp-dir
  8909. Specifies the directory where temporary files are stored.
  8910. Defaults to @samp{"/var/spool/cups/tmp"}.
  8911. @end deftypevr
  8912. @deftypevr {@code{files-configuration} parameter} string user
  8913. Specifies the user name or ID that is used when running external
  8914. programs.
  8915. Defaults to @samp{"lp"}.
  8916. @end deftypevr
  8917. @end deftypevr
  8918. @deftypevr {@code{cups-configuration} parameter} access-log-level access-log-level
  8919. Specifies the logging level for the AccessLog file. The @code{config}
  8920. level logs when printers and classes are added, deleted, or modified and
  8921. when configuration files are accessed or updated. The @code{actions}
  8922. level logs when print jobs are submitted, held, released, modified, or
  8923. canceled, and any of the conditions for @code{config}. The @code{all}
  8924. level logs all requests.
  8925. Defaults to @samp{actions}.
  8926. @end deftypevr
  8927. @deftypevr {@code{cups-configuration} parameter} boolean auto-purge-jobs?
  8928. Specifies whether to purge job history data automatically when it is no
  8929. longer required for quotas.
  8930. Defaults to @samp{#f}.
  8931. @end deftypevr
  8932. @deftypevr {@code{cups-configuration} parameter} browse-local-protocols browse-local-protocols
  8933. Specifies which protocols to use for local printer sharing.
  8934. Defaults to @samp{dnssd}.
  8935. @end deftypevr
  8936. @deftypevr {@code{cups-configuration} parameter} boolean browse-web-if?
  8937. Specifies whether the CUPS web interface is advertised.
  8938. Defaults to @samp{#f}.
  8939. @end deftypevr
  8940. @deftypevr {@code{cups-configuration} parameter} boolean browsing?
  8941. Specifies whether shared printers are advertised.
  8942. Defaults to @samp{#f}.
  8943. @end deftypevr
  8944. @deftypevr {@code{cups-configuration} parameter} string classification
  8945. Specifies the security classification of the server. Any valid banner
  8946. name can be used, including "classified", "confidential", "secret",
  8947. "topsecret", and "unclassified", or the banner can be omitted to disable
  8948. secure printing functions.
  8949. Defaults to @samp{""}.
  8950. @end deftypevr
  8951. @deftypevr {@code{cups-configuration} parameter} boolean classify-override?
  8952. Specifies whether users may override the classification (cover page) of
  8953. individual print jobs using the @code{job-sheets} option.
  8954. Defaults to @samp{#f}.
  8955. @end deftypevr
  8956. @deftypevr {@code{cups-configuration} parameter} default-auth-type default-auth-type
  8957. Specifies the default type of authentication to use.
  8958. Defaults to @samp{Basic}.
  8959. @end deftypevr
  8960. @deftypevr {@code{cups-configuration} parameter} default-encryption default-encryption
  8961. Specifies whether encryption will be used for authenticated requests.
  8962. Defaults to @samp{Required}.
  8963. @end deftypevr
  8964. @deftypevr {@code{cups-configuration} parameter} string default-language
  8965. Specifies the default language to use for text and web content.
  8966. Defaults to @samp{"en"}.
  8967. @end deftypevr
  8968. @deftypevr {@code{cups-configuration} parameter} string default-paper-size
  8969. Specifies the default paper size for new print queues. @samp{"Auto"}
  8970. uses a locale-specific default, while @samp{"None"} specifies there is
  8971. no default paper size. Specific size names are typically
  8972. @samp{"Letter"} or @samp{"A4"}.
  8973. Defaults to @samp{"Auto"}.
  8974. @end deftypevr
  8975. @deftypevr {@code{cups-configuration} parameter} string default-policy
  8976. Specifies the default access policy to use.
  8977. Defaults to @samp{"default"}.
  8978. @end deftypevr
  8979. @deftypevr {@code{cups-configuration} parameter} boolean default-shared?
  8980. Specifies whether local printers are shared by default.
  8981. Defaults to @samp{#t}.
  8982. @end deftypevr
  8983. @deftypevr {@code{cups-configuration} parameter} non-negative-integer dirty-clean-interval
  8984. Specifies the delay for updating of configuration and state files, in
  8985. seconds. A value of 0 causes the update to happen as soon as possible,
  8986. typically within a few milliseconds.
  8987. Defaults to @samp{30}.
  8988. @end deftypevr
  8989. @deftypevr {@code{cups-configuration} parameter} error-policy error-policy
  8990. Specifies what to do when an error occurs. Possible values are
  8991. @code{abort-job}, which will discard the failed print job;
  8992. @code{retry-job}, which will retry the job at a later time;
  8993. @code{retry-this-job}, which retries the failed job immediately; and
  8994. @code{stop-printer}, which stops the printer.
  8995. Defaults to @samp{stop-printer}.
  8996. @end deftypevr
  8997. @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-limit
  8998. Specifies the maximum cost of filters that are run concurrently, which
  8999. can be used to minimize disk, memory, and CPU resource problems. A
  9000. limit of 0 disables filter limiting. An average print to a
  9001. non-PostScript printer needs a filter limit of about 200. A PostScript
  9002. printer needs about half that (100). Setting the limit below these
  9003. thresholds will effectively limit the scheduler to printing a single job
  9004. at any time.
  9005. Defaults to @samp{0}.
  9006. @end deftypevr
  9007. @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-nice
  9008. Specifies the scheduling priority of filters that are run to print a
  9009. job. The nice value ranges from 0, the highest priority, to 19, the
  9010. lowest priority.
  9011. Defaults to @samp{0}.
  9012. @end deftypevr
  9013. @deftypevr {@code{cups-configuration} parameter} host-name-lookups host-name-lookups
  9014. Specifies whether to do reverse lookups on connecting clients. The
  9015. @code{double} setting causes @code{cupsd} to verify that the hostname
  9016. resolved from the address matches one of the addresses returned for that
  9017. hostname. Double lookups also prevent clients with unregistered
  9018. addresses from connecting to your server. Only set this option to
  9019. @code{#t} or @code{double} if absolutely required.
  9020. Defaults to @samp{#f}.
  9021. @end deftypevr
  9022. @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-kill-delay
  9023. Specifies the number of seconds to wait before killing the filters and
  9024. backend associated with a canceled or held job.
  9025. Defaults to @samp{30}.
  9026. @end deftypevr
  9027. @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-interval
  9028. Specifies the interval between retries of jobs in seconds. This is
  9029. typically used for fax queues but can also be used with normal print
  9030. queues whose error policy is @code{retry-job} or
  9031. @code{retry-current-job}.
  9032. Defaults to @samp{30}.
  9033. @end deftypevr
  9034. @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-limit
  9035. Specifies the number of retries that are done for jobs. This is
  9036. typically used for fax queues but can also be used with normal print
  9037. queues whose error policy is @code{retry-job} or
  9038. @code{retry-current-job}.
  9039. Defaults to @samp{5}.
  9040. @end deftypevr
  9041. @deftypevr {@code{cups-configuration} parameter} boolean keep-alive?
  9042. Specifies whether to support HTTP keep-alive connections.
  9043. Defaults to @samp{#t}.
  9044. @end deftypevr
  9045. @deftypevr {@code{cups-configuration} parameter} non-negative-integer keep-alive-timeout
  9046. Specifies how long an idle client connection remains open, in seconds.
  9047. Defaults to @samp{30}.
  9048. @end deftypevr
  9049. @deftypevr {@code{cups-configuration} parameter} non-negative-integer limit-request-body
  9050. Specifies the maximum size of print files, IPP requests, and HTML form
  9051. data. A limit of 0 disables the limit check.
  9052. Defaults to @samp{0}.
  9053. @end deftypevr
  9054. @deftypevr {@code{cups-configuration} parameter} multiline-string-list listen
  9055. Listens on the specified interfaces for connections. Valid values are
  9056. of the form @var{address}:@var{port}, where @var{address} is either an
  9057. IPv6 address enclosed in brackets, an IPv4 address, or @code{*} to
  9058. indicate all addresses. Values can also be file names of local UNIX
  9059. domain sockets. The Listen directive is similar to the Port directive
  9060. but allows you to restrict access to specific interfaces or networks.
  9061. @end deftypevr
  9062. @deftypevr {@code{cups-configuration} parameter} non-negative-integer listen-back-log
  9063. Specifies the number of pending connections that will be allowed. This
  9064. normally only affects very busy servers that have reached the MaxClients
  9065. limit, but can also be triggered by large numbers of simultaneous
  9066. connections. When the limit is reached, the operating system will
  9067. refuse additional connections until the scheduler can accept the pending
  9068. ones.
  9069. Defaults to @samp{128}.
  9070. @end deftypevr
  9071. @deftypevr {@code{cups-configuration} parameter} location-access-control-list location-access-controls
  9072. Specifies a set of additional access controls.
  9073. Available @code{location-access-controls} fields are:
  9074. @deftypevr {@code{location-access-controls} parameter} file-name path
  9075. Specifies the URI path to which the access control applies.
  9076. @end deftypevr
  9077. @deftypevr {@code{location-access-controls} parameter} access-control-list access-controls
  9078. Access controls for all access to this path, in the same format as the
  9079. @code{access-controls} of @code{operation-access-control}.
  9080. Defaults to @samp{()}.
  9081. @end deftypevr
  9082. @deftypevr {@code{location-access-controls} parameter} method-access-control-list method-access-controls
  9083. Access controls for method-specific access to this path.
  9084. Defaults to @samp{()}.
  9085. Available @code{method-access-controls} fields are:
  9086. @deftypevr {@code{method-access-controls} parameter} boolean reverse?
  9087. If @code{#t}, apply access controls to all methods except the listed
  9088. methods. Otherwise apply to only the listed methods.
  9089. Defaults to @samp{#f}.
  9090. @end deftypevr
  9091. @deftypevr {@code{method-access-controls} parameter} method-list methods
  9092. Methods to which this access control applies.
  9093. Defaults to @samp{()}.
  9094. @end deftypevr
  9095. @deftypevr {@code{method-access-controls} parameter} access-control-list access-controls
  9096. Access control directives, as a list of strings. Each string should be
  9097. one directive, such as "Order allow,deny".
  9098. Defaults to @samp{()}.
  9099. @end deftypevr
  9100. @end deftypevr
  9101. @end deftypevr
  9102. @deftypevr {@code{cups-configuration} parameter} non-negative-integer log-debug-history
  9103. Specifies the number of debugging messages that are retained for logging
  9104. if an error occurs in a print job. Debug messages are logged regardless
  9105. of the LogLevel setting.
  9106. Defaults to @samp{100}.
  9107. @end deftypevr
  9108. @deftypevr {@code{cups-configuration} parameter} log-level log-level
  9109. Specifies the level of logging for the ErrorLog file. The value
  9110. @code{none} stops all logging while @code{debug2} logs everything.
  9111. Defaults to @samp{info}.
  9112. @end deftypevr
  9113. @deftypevr {@code{cups-configuration} parameter} log-time-format log-time-format
  9114. Specifies the format of the date and time in the log files. The value
  9115. @code{standard} logs whole seconds while @code{usecs} logs microseconds.
  9116. Defaults to @samp{standard}.
  9117. @end deftypevr
  9118. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients
  9119. Specifies the maximum number of simultaneous clients that are allowed by
  9120. the scheduler.
  9121. Defaults to @samp{100}.
  9122. @end deftypevr
  9123. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients-per-host
  9124. Specifies the maximum number of simultaneous clients that are allowed
  9125. from a single address.
  9126. Defaults to @samp{100}.
  9127. @end deftypevr
  9128. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-copies
  9129. Specifies the maximum number of copies that a user can print of each
  9130. job.
  9131. Defaults to @samp{9999}.
  9132. @end deftypevr
  9133. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-hold-time
  9134. Specifies the maximum time a job may remain in the @code{indefinite}
  9135. hold state before it is canceled. A value of 0 disables cancellation of
  9136. held jobs.
  9137. Defaults to @samp{0}.
  9138. @end deftypevr
  9139. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs
  9140. Specifies the maximum number of simultaneous jobs that are allowed. Set
  9141. to 0 to allow an unlimited number of jobs.
  9142. Defaults to @samp{500}.
  9143. @end deftypevr
  9144. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-printer
  9145. Specifies the maximum number of simultaneous jobs that are allowed per
  9146. printer. A value of 0 allows up to MaxJobs jobs per printer.
  9147. Defaults to @samp{0}.
  9148. @end deftypevr
  9149. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-user
  9150. Specifies the maximum number of simultaneous jobs that are allowed per
  9151. user. A value of 0 allows up to MaxJobs jobs per user.
  9152. Defaults to @samp{0}.
  9153. @end deftypevr
  9154. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-job-time
  9155. Specifies the maximum time a job may take to print before it is
  9156. canceled, in seconds. Set to 0 to disable cancellation of "stuck" jobs.
  9157. Defaults to @samp{10800}.
  9158. @end deftypevr
  9159. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-log-size
  9160. Specifies the maximum size of the log files before they are rotated, in
  9161. bytes. The value 0 disables log rotation.
  9162. Defaults to @samp{1048576}.
  9163. @end deftypevr
  9164. @deftypevr {@code{cups-configuration} parameter} non-negative-integer multiple-operation-timeout
  9165. Specifies the maximum amount of time to allow between files in a
  9166. multiple file print job, in seconds.
  9167. Defaults to @samp{300}.
  9168. @end deftypevr
  9169. @deftypevr {@code{cups-configuration} parameter} string page-log-format
  9170. Specifies the format of PageLog lines. Sequences beginning with percent
  9171. (@samp{%}) characters are replaced with the corresponding information,
  9172. while all other characters are copied literally. The following percent
  9173. sequences are recognized:
  9174. @table @samp
  9175. @item %%
  9176. insert a single percent character
  9177. @item %@{name@}
  9178. insert the value of the specified IPP attribute
  9179. @item %C
  9180. insert the number of copies for the current page
  9181. @item %P
  9182. insert the current page number
  9183. @item %T
  9184. insert the current date and time in common log format
  9185. @item %j
  9186. insert the job ID
  9187. @item %p
  9188. insert the printer name
  9189. @item %u
  9190. insert the username
  9191. @end table
  9192. A value of the empty string disables page logging. The string @code{%p
  9193. %u %j %T %P %C %@{job-billing@} %@{job-originating-host-name@}
  9194. %@{job-name@} %@{media@} %@{sides@}} creates a page log with the
  9195. standard items.
  9196. Defaults to @samp{""}.
  9197. @end deftypevr
  9198. @deftypevr {@code{cups-configuration} parameter} environment-variables environment-variables
  9199. Passes the specified environment variable(s) to child processes; a list
  9200. of strings.
  9201. Defaults to @samp{()}.
  9202. @end deftypevr
  9203. @deftypevr {@code{cups-configuration} parameter} policy-configuration-list policies
  9204. Specifies named access control policies.
  9205. Available @code{policy-configuration} fields are:
  9206. @deftypevr {@code{policy-configuration} parameter} string name
  9207. Name of the policy.
  9208. @end deftypevr
  9209. @deftypevr {@code{policy-configuration} parameter} string job-private-access
  9210. Specifies an access list for a job's private values. @code{@@ACL} maps
  9211. to the printer's requesting-user-name-allowed or
  9212. requesting-user-name-denied values. @code{@@OWNER} maps to the job's
  9213. owner. @code{@@SYSTEM} maps to the groups listed for the
  9214. @code{system-group} field of the @code{files-config} configuration,
  9215. which is reified into the @code{cups-files.conf(5)} file. Other
  9216. possible elements of the access list include specific user names, and
  9217. @code{@@@var{group}} to indicate members of a specific group. The
  9218. access list may also be simply @code{all} or @code{default}.
  9219. Defaults to @samp{"@@OWNER @@SYSTEM"}.
  9220. @end deftypevr
  9221. @deftypevr {@code{policy-configuration} parameter} string job-private-values
  9222. Specifies the list of job values to make private, or @code{all},
  9223. @code{default}, or @code{none}.
  9224. Defaults to @samp{"job-name job-originating-host-name
  9225. job-originating-user-name phone"}.
  9226. @end deftypevr
  9227. @deftypevr {@code{policy-configuration} parameter} string subscription-private-access
  9228. Specifies an access list for a subscription's private values.
  9229. @code{@@ACL} maps to the printer's requesting-user-name-allowed or
  9230. requesting-user-name-denied values. @code{@@OWNER} maps to the job's
  9231. owner. @code{@@SYSTEM} maps to the groups listed for the
  9232. @code{system-group} field of the @code{files-config} configuration,
  9233. which is reified into the @code{cups-files.conf(5)} file. Other
  9234. possible elements of the access list include specific user names, and
  9235. @code{@@@var{group}} to indicate members of a specific group. The
  9236. access list may also be simply @code{all} or @code{default}.
  9237. Defaults to @samp{"@@OWNER @@SYSTEM"}.
  9238. @end deftypevr
  9239. @deftypevr {@code{policy-configuration} parameter} string subscription-private-values
  9240. Specifies the list of job values to make private, or @code{all},
  9241. @code{default}, or @code{none}.
  9242. Defaults to @samp{"notify-events notify-pull-method notify-recipient-uri
  9243. notify-subscriber-user-name notify-user-data"}.
  9244. @end deftypevr
  9245. @deftypevr {@code{policy-configuration} parameter} operation-access-control-list access-controls
  9246. Access control by IPP operation.
  9247. Defaults to @samp{()}.
  9248. @end deftypevr
  9249. @end deftypevr
  9250. @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-files
  9251. Specifies whether job files (documents) are preserved after a job is
  9252. printed. If a numeric value is specified, job files are preserved for
  9253. the indicated number of seconds after printing. Otherwise a boolean
  9254. value applies indefinitely.
  9255. Defaults to @samp{86400}.
  9256. @end deftypevr
  9257. @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-history
  9258. Specifies whether the job history is preserved after a job is printed.
  9259. If a numeric value is specified, the job history is preserved for the
  9260. indicated number of seconds after printing. If @code{#t}, the job
  9261. history is preserved until the MaxJobs limit is reached.
  9262. Defaults to @samp{#t}.
  9263. @end deftypevr
  9264. @deftypevr {@code{cups-configuration} parameter} non-negative-integer reload-timeout
  9265. Specifies the amount of time to wait for job completion before
  9266. restarting the scheduler.
  9267. Defaults to @samp{30}.
  9268. @end deftypevr
  9269. @deftypevr {@code{cups-configuration} parameter} string rip-cache
  9270. Specifies the maximum amount of memory to use when converting documents
  9271. into bitmaps for a printer.
  9272. Defaults to @samp{"128m"}.
  9273. @end deftypevr
  9274. @deftypevr {@code{cups-configuration} parameter} string server-admin
  9275. Specifies the email address of the server administrator.
  9276. Defaults to @samp{"root@@localhost.localdomain"}.
  9277. @end deftypevr
  9278. @deftypevr {@code{cups-configuration} parameter} host-name-list-or-* server-alias
  9279. The ServerAlias directive is used for HTTP Host header validation when
  9280. clients connect to the scheduler from external interfaces. Using the
  9281. special name @code{*} can expose your system to known browser-based DNS
  9282. rebinding attacks, even when accessing sites through a firewall. If the
  9283. auto-discovery of alternate names does not work, we recommend listing
  9284. each alternate name with a ServerAlias directive instead of using
  9285. @code{*}.
  9286. Defaults to @samp{*}.
  9287. @end deftypevr
  9288. @deftypevr {@code{cups-configuration} parameter} string server-name
  9289. Specifies the fully-qualified host name of the server.
  9290. Defaults to @samp{"localhost"}.
  9291. @end deftypevr
  9292. @deftypevr {@code{cups-configuration} parameter} server-tokens server-tokens
  9293. Specifies what information is included in the Server header of HTTP
  9294. responses. @code{None} disables the Server header. @code{ProductOnly}
  9295. reports @code{CUPS}. @code{Major} reports @code{CUPS 2}. @code{Minor}
  9296. reports @code{CUPS 2.0}. @code{Minimal} reports @code{CUPS 2.0.0}.
  9297. @code{OS} reports @code{CUPS 2.0.0 (@var{uname})} where @var{uname} is
  9298. the output of the @code{uname} command. @code{Full} reports @code{CUPS
  9299. 2.0.0 (@var{uname}) IPP/2.0}.
  9300. Defaults to @samp{Minimal}.
  9301. @end deftypevr
  9302. @deftypevr {@code{cups-configuration} parameter} string set-env
  9303. Set the specified environment variable to be passed to child processes.
  9304. Defaults to @samp{"variable value"}.
  9305. @end deftypevr
  9306. @deftypevr {@code{cups-configuration} parameter} multiline-string-list ssl-listen
  9307. Listens on the specified interfaces for encrypted connections. Valid
  9308. values are of the form @var{address}:@var{port}, where @var{address} is
  9309. either an IPv6 address enclosed in brackets, an IPv4 address, or
  9310. @code{*} to indicate all addresses.
  9311. Defaults to @samp{()}.
  9312. @end deftypevr
  9313. @deftypevr {@code{cups-configuration} parameter} ssl-options ssl-options
  9314. Sets encryption options. By default, CUPS only supports encryption
  9315. using TLS v1.0 or higher using known secure cipher suites. The
  9316. @code{AllowRC4} option enables the 128-bit RC4 cipher suites, which are
  9317. required for some older clients that do not implement newer ones. The
  9318. @code{AllowSSL3} option enables SSL v3.0, which is required for some
  9319. older clients that do not support TLS v1.0.
  9320. Defaults to @samp{()}.
  9321. @end deftypevr
  9322. @deftypevr {@code{cups-configuration} parameter} boolean strict-conformance?
  9323. Specifies whether the scheduler requires clients to strictly adhere to
  9324. the IPP specifications.
  9325. Defaults to @samp{#f}.
  9326. @end deftypevr
  9327. @deftypevr {@code{cups-configuration} parameter} non-negative-integer timeout
  9328. Specifies the HTTP request timeout, in seconds.
  9329. Defaults to @samp{300}.
  9330. @end deftypevr
  9331. @deftypevr {@code{cups-configuration} parameter} boolean web-interface?
  9332. Specifies whether the web interface is enabled.
  9333. Defaults to @samp{#f}.
  9334. @end deftypevr
  9335. At this point you're probably thinking ``oh dear, Guix manual, I like
  9336. you but you can stop already with the configuration options''. Indeed.
  9337. However, one more point: it could be that you have an existing
  9338. @code{cupsd.conf} that you want to use. In that case, you can pass an
  9339. @code{opaque-cups-configuration} as the configuration of a
  9340. @code{cups-service-type}.
  9341. Available @code{opaque-cups-configuration} fields are:
  9342. @deftypevr {@code{opaque-cups-configuration} parameter} package cups
  9343. The CUPS package.
  9344. @end deftypevr
  9345. @deftypevr {@code{opaque-cups-configuration} parameter} string cupsd.conf
  9346. The contents of the @code{cupsd.conf}, as a string.
  9347. @end deftypevr
  9348. @deftypevr {@code{opaque-cups-configuration} parameter} string cups-files.conf
  9349. The contents of the @code{cups-files.conf} file, as a string.
  9350. @end deftypevr
  9351. For example, if your @code{cupsd.conf} and @code{cups-files.conf} are in
  9352. strings of the same name, you could instantiate a CUPS service like
  9353. this:
  9354. @example
  9355. (service cups-service-type
  9356. (opaque-cups-configuration
  9357. (cupsd.conf cupsd.conf)
  9358. (cups-files.conf cups-files.conf)))
  9359. @end example
  9360. @node Desktop Services
  9361. @subsubsection Desktop Services
  9362. The @code{(gnu services desktop)} module provides services that are
  9363. usually useful in the context of a ``desktop'' setup---that is, on a
  9364. machine running a graphical display server, possibly with graphical user
  9365. interfaces, etc. It also defines services that provide specific desktop
  9366. environments like GNOME and XFCE.
  9367. To simplify things, the module defines a variable containing the set of
  9368. services that users typically expect on a machine with a graphical
  9369. environment and networking:
  9370. @defvr {Scheme Variable} %desktop-services
  9371. This is a list of services that builds upon @var{%base-services} and
  9372. adds or adjusts services for a typical ``desktop'' setup.
  9373. In particular, it adds a graphical login manager (@pxref{X Window,
  9374. @code{slim-service}}), screen lockers, a network management tool
  9375. (@pxref{Networking Services, @code{network-manager-service-type}}), energy and color
  9376. management services, the @code{elogind} login and seat manager, the
  9377. Polkit privilege service, the GeoClue location service, the
  9378. AccountsService daemon that allows authorized users change system
  9379. passwords, an NTP client (@pxref{Networking Services}), the Avahi
  9380. daemon, and has the name service switch service configured to be able to
  9381. use @code{nss-mdns} (@pxref{Name Service Switch, mDNS}).
  9382. @end defvr
  9383. The @var{%desktop-services} variable can be used as the @code{services}
  9384. field of an @code{operating-system} declaration (@pxref{operating-system
  9385. Reference, @code{services}}).
  9386. Additionally, the @code{gnome-desktop-service} and
  9387. @code{xfce-desktop-service} procedures can add GNOME and/or XFCE to a
  9388. system. To ``add GNOME'' means that system-level services like the
  9389. backlight adjustment helpers and the power management utilities are
  9390. added to the system, extending @code{polkit} and @code{dbus}
  9391. appropriately, allowing GNOME to operate with elevated privileges on a
  9392. limited number of special-purpose system interfaces. Additionally,
  9393. adding a service made by @code{gnome-desktop-service} adds the GNOME
  9394. metapackage to the system profile. Likewise, adding the XFCE service
  9395. not only adds the @code{xfce} metapackage to the system profile, but it
  9396. also gives the Thunar file manager the ability to open a ``root-mode''
  9397. file management window, if the user authenticates using the
  9398. administrator's password via the standard polkit graphical interface.
  9399. @deffn {Scheme Procedure} gnome-desktop-service
  9400. Return a service that adds the @code{gnome} package to the system
  9401. profile, and extends polkit with the actions from
  9402. @code{gnome-settings-daemon}.
  9403. @end deffn
  9404. @deffn {Scheme Procedure} xfce-desktop-service
  9405. Return a service that adds the @code{xfce} package to the system profile,
  9406. and extends polkit with the ability for @code{thunar} to manipulate the
  9407. file system as root from within a user session, after the user has
  9408. authenticated with the administrator's password.
  9409. @end deffn
  9410. Because the GNOME and XFCE desktop services pull in so many packages,
  9411. the default @code{%desktop-services} variable doesn't include either of
  9412. them by default. To add GNOME or XFCE, just @code{cons} them onto
  9413. @code{%desktop-services} in the @code{services} field of your
  9414. @code{operating-system}:
  9415. @example
  9416. (use-modules (gnu))
  9417. (use-service-modules desktop)
  9418. (operating-system
  9419. ...
  9420. ;; cons* adds items to the list given as its last argument.
  9421. (services (cons* (gnome-desktop-service)
  9422. (xfce-desktop-service)
  9423. %desktop-services))
  9424. ...)
  9425. @end example
  9426. These desktop environments will then be available as options in the
  9427. graphical login window.
  9428. The actual service definitions included in @code{%desktop-services} and
  9429. provided by @code{(gnu services dbus)} and @code{(gnu services desktop)}
  9430. are described below.
  9431. @deffn {Scheme Procedure} dbus-service [#:dbus @var{dbus}] [#:services '()]
  9432. Return a service that runs the ``system bus'', using @var{dbus}, with
  9433. support for @var{services}.
  9434. @uref{http://dbus.freedesktop.org/, D-Bus} is an inter-process communication
  9435. facility. Its system bus is used to allow system services to communicate
  9436. and to be notified of system-wide events.
  9437. @var{services} must be a list of packages that provide an
  9438. @file{etc/dbus-1/system.d} directory containing additional D-Bus configuration
  9439. and policy files. For example, to allow avahi-daemon to use the system bus,
  9440. @var{services} must be equal to @code{(list avahi)}.
  9441. @end deffn
  9442. @deffn {Scheme Procedure} elogind-service [#:config @var{config}]
  9443. Return a service that runs the @code{elogind} login and
  9444. seat management daemon. @uref{https://github.com/elogind/elogind,
  9445. Elogind} exposes a D-Bus interface that can be used to know which users
  9446. are logged in, know what kind of sessions they have open, suspend the
  9447. system, inhibit system suspend, reboot the system, and other tasks.
  9448. Elogind handles most system-level power events for a computer, for
  9449. example suspending the system when a lid is closed, or shutting it down
  9450. when the power button is pressed.
  9451. The @var{config} keyword argument specifies the configuration for
  9452. elogind, and should be the result of an @code{(elogind-configuration
  9453. (@var{parameter} @var{value})...)} invocation. Available parameters and
  9454. their default values are:
  9455. @table @code
  9456. @item kill-user-processes?
  9457. @code{#f}
  9458. @item kill-only-users
  9459. @code{()}
  9460. @item kill-exclude-users
  9461. @code{("root")}
  9462. @item inhibit-delay-max-seconds
  9463. @code{5}
  9464. @item handle-power-key
  9465. @code{poweroff}
  9466. @item handle-suspend-key
  9467. @code{suspend}
  9468. @item handle-hibernate-key
  9469. @code{hibernate}
  9470. @item handle-lid-switch
  9471. @code{suspend}
  9472. @item handle-lid-switch-docked
  9473. @code{ignore}
  9474. @item power-key-ignore-inhibited?
  9475. @code{#f}
  9476. @item suspend-key-ignore-inhibited?
  9477. @code{#f}
  9478. @item hibernate-key-ignore-inhibited?
  9479. @code{#f}
  9480. @item lid-switch-ignore-inhibited?
  9481. @code{#t}
  9482. @item holdoff-timeout-seconds
  9483. @code{30}
  9484. @item idle-action
  9485. @code{ignore}
  9486. @item idle-action-seconds
  9487. @code{(* 30 60)}
  9488. @item runtime-directory-size-percent
  9489. @code{10}
  9490. @item runtime-directory-size
  9491. @code{#f}
  9492. @item remove-ipc?
  9493. @code{#t}
  9494. @item suspend-state
  9495. @code{("mem" "standby" "freeze")}
  9496. @item suspend-mode
  9497. @code{()}
  9498. @item hibernate-state
  9499. @code{("disk")}
  9500. @item hibernate-mode
  9501. @code{("platform" "shutdown")}
  9502. @item hybrid-sleep-state
  9503. @code{("disk")}
  9504. @item hybrid-sleep-mode
  9505. @code{("suspend" "platform" "shutdown")}
  9506. @end table
  9507. @end deffn
  9508. @deffn {Scheme Procedure} accountsservice-service @
  9509. [#:accountsservice @var{accountsservice}]
  9510. Return a service that runs AccountsService, a system service that can
  9511. list available accounts, change their passwords, and so on.
  9512. AccountsService integrates with PolicyKit to enable unprivileged users
  9513. to acquire the capability to modify their system configuration.
  9514. @uref{https://www.freedesktop.org/wiki/Software/AccountsService/, the
  9515. accountsservice web site} for more information.
  9516. The @var{accountsservice} keyword argument is the @code{accountsservice}
  9517. package to expose as a service.
  9518. @end deffn
  9519. @deffn {Scheme Procedure} polkit-service @
  9520. [#:polkit @var{polkit}]
  9521. Return a service that runs the
  9522. @uref{http://www.freedesktop.org/wiki/Software/polkit/, Polkit privilege
  9523. management service}, which allows system administrators to grant access to
  9524. privileged operations in a structured way. By querying the Polkit service, a
  9525. privileged system component can know when it should grant additional
  9526. capabilities to ordinary users. For example, an ordinary user can be granted
  9527. the capability to suspend the system if the user is logged in locally.
  9528. @end deffn
  9529. @deffn {Scheme Procedure} upower-service [#:upower @var{upower}] @
  9530. [#:watts-up-pro? #f] @
  9531. [#:poll-batteries? #t] @
  9532. [#:ignore-lid? #f] @
  9533. [#:use-percentage-for-policy? #f] @
  9534. [#:percentage-low 10] @
  9535. [#:percentage-critical 3] @
  9536. [#:percentage-action 2] @
  9537. [#:time-low 1200] @
  9538. [#:time-critical 300] @
  9539. [#:time-action 120] @
  9540. [#:critical-power-action 'hybrid-sleep]
  9541. Return a service that runs @uref{http://upower.freedesktop.org/,
  9542. @command{upowerd}}, a system-wide monitor for power consumption and battery
  9543. levels, with the given configuration settings. It implements the
  9544. @code{org.freedesktop.UPower} D-Bus interface, and is notably used by
  9545. GNOME.
  9546. @end deffn
  9547. @deffn {Scheme Procedure} udisks-service [#:udisks @var{udisks}]
  9548. Return a service for @uref{http://udisks.freedesktop.org/docs/latest/,
  9549. UDisks}, a @dfn{disk management} daemon that provides user interfaces with
  9550. notifications and ways to mount/unmount disks. Programs that talk to UDisks
  9551. include the @command{udisksctl} command, part of UDisks, and GNOME Disks.
  9552. @end deffn
  9553. @deffn {Scheme Procedure} colord-service [#:colord @var{colord}]
  9554. Return a service that runs @command{colord}, a system service with a D-Bus
  9555. interface to manage the color profiles of input and output devices such as
  9556. screens and scanners. It is notably used by the GNOME Color Manager graphical
  9557. tool. See @uref{http://www.freedesktop.org/software/colord/, the colord web
  9558. site} for more information.
  9559. @end deffn
  9560. @deffn {Scheme Procedure} geoclue-application name [#:allowed? #t] [#:system? #f] [#:users '()]
  9561. Return a configuration allowing an application to access GeoClue
  9562. location data. @var{name} is the Desktop ID of the application, without
  9563. the @code{.desktop} part. If @var{allowed?} is true, the application
  9564. will have access to location information by default. The boolean
  9565. @var{system?} value indicates whether an application is a system component
  9566. or not. Finally @var{users} is a list of UIDs of all users for which
  9567. this application is allowed location info access. An empty users list
  9568. means that all users are allowed.
  9569. @end deffn
  9570. @defvr {Scheme Variable} %standard-geoclue-applications
  9571. The standard list of well-known GeoClue application configurations,
  9572. granting authority to the GNOME date-and-time utility to ask for the
  9573. current location in order to set the time zone, and allowing the
  9574. IceCat and Epiphany web browsers to request location information.
  9575. IceCat and Epiphany both query the user before allowing a web page to
  9576. know the user's location.
  9577. @end defvr
  9578. @deffn {Scheme Procedure} geoclue-service [#:colord @var{colord}] @
  9579. [#:whitelist '()] @
  9580. [#:wifi-geolocation-url "https://location.services.mozilla.com/v1/geolocate?key=geoclue"] @
  9581. [#:submit-data? #f]
  9582. [#:wifi-submission-url "https://location.services.mozilla.com/v1/submit?key=geoclue"] @
  9583. [#:submission-nick "geoclue"] @
  9584. [#:applications %standard-geoclue-applications]
  9585. Return a service that runs the GeoClue location service. This service
  9586. provides a D-Bus interface to allow applications to request access to a
  9587. user's physical location, and optionally to add information to online
  9588. location databases. See
  9589. @uref{https://wiki.freedesktop.org/www/Software/GeoClue/, the GeoClue
  9590. web site} for more information.
  9591. @end deffn
  9592. @deffn {Scheme Procedure} bluetooth-service [#:bluez @var{bluez}] @
  9593. [@w{#:auto-enable? #f}]
  9594. Return a service that runs the @command{bluetoothd} daemon, which
  9595. manages all the Bluetooth devices and provides a number of D-Bus
  9596. interfaces. When AUTO-ENABLE? is true, the bluetooth controller is
  9597. powered automatically at boot, which can be useful when using a
  9598. bluetooth keyboard or mouse.
  9599. Users need to be in the @code{lp} group to access the D-Bus service.
  9600. @end deffn
  9601. @node Database Services
  9602. @subsubsection Database Services
  9603. @cindex database
  9604. @cindex SQL
  9605. The @code{(gnu services databases)} module provides the following services.
  9606. @deffn {Scheme Procedure} postgresql-service [#:postgresql postgresql] @
  9607. [#:config-file] [#:data-directory ``/var/lib/postgresql/data''] @
  9608. [#:port 5432] [#:locale ``en_US.utf8'']
  9609. Return a service that runs @var{postgresql}, the PostgreSQL database
  9610. server.
  9611. The PostgreSQL daemon loads its runtime configuration from @var{config-file},
  9612. creates a database cluster with @var{locale} as the default
  9613. locale, stored in @var{data-directory}. It then listens on @var{port}.
  9614. @end deffn
  9615. @deffn {Scheme Procedure} mysql-service [#:config (mysql-configuration)]
  9616. Return a service that runs @command{mysqld}, the MySQL or MariaDB
  9617. database server.
  9618. The optional @var{config} argument specifies the configuration for
  9619. @command{mysqld}, which should be a @code{<mysql-configuration>} object.
  9620. @end deffn
  9621. @deftp {Data Type} mysql-configuration
  9622. Data type representing the configuration of @var{mysql-service}.
  9623. @table @asis
  9624. @item @code{mysql} (default: @var{mariadb})
  9625. Package object of the MySQL database server, can be either @var{mariadb}
  9626. or @var{mysql}.
  9627. For MySQL, a temporary root password will be displayed at activation time.
  9628. For MariaDB, the root password is empty.
  9629. @item @code{port} (default: @code{3306})
  9630. TCP port on which the database server listens for incoming connections.
  9631. @end table
  9632. @end deftp
  9633. @defvr {Scheme Variable} memcached-service-type
  9634. This is the service type for the @uref{https://memcached.org/,
  9635. Memcached} service, which provides a distributed in memory cache. The
  9636. value for the service type is a @code{memcached-configuration} object.
  9637. @end defvr
  9638. @example
  9639. (service memcached-service-type)
  9640. @end example
  9641. @deftp {Data Type} memcached-configuration
  9642. Data type representing the configuration of memcached.
  9643. @table @asis
  9644. @item @code{memcached} (default: @code{memcached})
  9645. The Memcached package to use.
  9646. @item @code{interfaces} (default: @code{'("0.0.0.0")})
  9647. Network interfaces on which to listen.
  9648. @item @code{tcp-port} (default: @code{11211})
  9649. Port on which to accept connections on,
  9650. @item @code{udp-port} (default: @code{11211})
  9651. Port on which to accept UDP connections on, a value of 0 will disable
  9652. listening on a UDP socket.
  9653. @item @code{additional-options} (default: @code{'()})
  9654. Additional command line options to pass to @code{memcached}.
  9655. @end table
  9656. @end deftp
  9657. @defvr {Scheme Variable} mongodb-service-type
  9658. This is the service type for @uref{https://www.mongodb.com/, MongoDB}.
  9659. The value for the service type is a @code{mongodb-configuration} object.
  9660. @end defvr
  9661. @example
  9662. (service mongodb-service-type)
  9663. @end example
  9664. @deftp {Data Type} mongodb-configuration
  9665. Data type representing the configuration of mongodb.
  9666. @table @asis
  9667. @item @code{mongodb} (default: @code{mongodb})
  9668. The MongoDB package to use.
  9669. @item @code{config-file} (default: @code{%default-mongodb-configuration-file})
  9670. The configuration file for MongoDB.
  9671. @item @code{data-directory} (default: @code{"/var/lib/mongodb"})
  9672. This value is used to create the directory, so that it exists and is
  9673. owned by the mongodb user. It should match the data-directory which
  9674. MongoDB is configured to use through the configuration file.
  9675. @end table
  9676. @end deftp
  9677. @defvr {Scheme Variable} redis-service-type
  9678. This is the service type for the @uref{https://redis.io/, Redis}
  9679. key/value store, whose value is a @code{redis-configuration} object.
  9680. @end defvr
  9681. @deftp {Data Type} redis-configuration
  9682. Data type representing the configuration of redis.
  9683. @table @asis
  9684. @item @code{redis} (default: @code{redis})
  9685. The Redis package to use.
  9686. @item @code{bind} (default: @code{"127.0.0.1"})
  9687. Network interface on which to listen.
  9688. @item @code{port} (default: @code{6379})
  9689. Port on which to accept connections on, a value of 0 will disable
  9690. listening on a TCP socket.
  9691. @item @code{working-directory} (default: @code{"/var/lib/redis"})
  9692. Directory in which to store the database and related files.
  9693. @end table
  9694. @end deftp
  9695. @node Mail Services
  9696. @subsubsection Mail Services
  9697. @cindex mail
  9698. @cindex email
  9699. The @code{(gnu services mail)} module provides Guix service definitions
  9700. for email services: IMAP, POP3, and LMTP servers, as well as mail
  9701. transport agents (MTAs). Lots of acronyms! These services are detailed
  9702. in the subsections below.
  9703. @subsubheading Dovecot Service
  9704. @deffn {Scheme Procedure} dovecot-service [#:config (dovecot-configuration)]
  9705. Return a service that runs the Dovecot IMAP/POP3/LMTP mail server.
  9706. @end deffn
  9707. By default, Dovecot does not need much configuration; the default
  9708. configuration object created by @code{(dovecot-configuration)} will
  9709. suffice if your mail is delivered to @code{~/Maildir}. A self-signed
  9710. certificate will be generated for TLS-protected connections, though
  9711. Dovecot will also listen on cleartext ports by default. There are a
  9712. number of options, though, which mail administrators might need to change,
  9713. and as is the case with other services, Guix allows the system
  9714. administrator to specify these parameters via a uniform Scheme interface.
  9715. For example, to specify that mail is located at @code{maildir~/.mail},
  9716. one would instantiate the Dovecot service like this:
  9717. @example
  9718. (dovecot-service #:config
  9719. (dovecot-configuration
  9720. (mail-location "maildir:~/.mail")))
  9721. @end example
  9722. The available configuration parameters follow. Each parameter
  9723. definition is preceded by its type; for example, @samp{string-list foo}
  9724. indicates that the @code{foo} parameter should be specified as a list of
  9725. strings. There is also a way to specify the configuration as a string,
  9726. if you have an old @code{dovecot.conf} file that you want to port over
  9727. from some other system; see the end for more details.
  9728. @c The following documentation was initially generated by
  9729. @c (generate-documentation) in (gnu services mail). Manually maintained
  9730. @c documentation is better, so we shouldn't hesitate to edit below as
  9731. @c needed. However if the change you want to make to this documentation
  9732. @c can be done in an automated way, it's probably easier to change
  9733. @c (generate-documentation) than to make it below and have to deal with
  9734. @c the churn as dovecot updates.
  9735. Available @code{dovecot-configuration} fields are:
  9736. @deftypevr {@code{dovecot-configuration} parameter} package dovecot
  9737. The dovecot package.
  9738. @end deftypevr
  9739. @deftypevr {@code{dovecot-configuration} parameter} comma-separated-string-list listen
  9740. A list of IPs or hosts where to listen for connections. @samp{*}
  9741. listens on all IPv4 interfaces, @samp{::} listens on all IPv6
  9742. interfaces. If you want to specify non-default ports or anything more
  9743. complex, customize the address and port fields of the
  9744. @samp{inet-listener} of the specific services you are interested in.
  9745. @end deftypevr
  9746. @deftypevr {@code{dovecot-configuration} parameter} protocol-configuration-list protocols
  9747. List of protocols we want to serve. Available protocols include
  9748. @samp{imap}, @samp{pop3}, and @samp{lmtp}.
  9749. Available @code{protocol-configuration} fields are:
  9750. @deftypevr {@code{protocol-configuration} parameter} string name
  9751. The name of the protocol.
  9752. @end deftypevr
  9753. @deftypevr {@code{protocol-configuration} parameter} string auth-socket-path
  9754. UNIX socket path to the master authentication server to find users.
  9755. This is used by imap (for shared users) and lda.
  9756. It defaults to @samp{"/var/run/dovecot/auth-userdb"}.
  9757. @end deftypevr
  9758. @deftypevr {@code{protocol-configuration} parameter} space-separated-string-list mail-plugins
  9759. Space separated list of plugins to load.
  9760. @end deftypevr
  9761. @deftypevr {@code{protocol-configuration} parameter} non-negative-integer mail-max-userip-connections
  9762. Maximum number of IMAP connections allowed for a user from each IP
  9763. address. NOTE: The username is compared case-sensitively.
  9764. Defaults to @samp{10}.
  9765. @end deftypevr
  9766. @end deftypevr
  9767. @deftypevr {@code{dovecot-configuration} parameter} service-configuration-list services
  9768. List of services to enable. Available services include @samp{imap},
  9769. @samp{imap-login}, @samp{pop3}, @samp{pop3-login}, @samp{auth}, and
  9770. @samp{lmtp}.
  9771. Available @code{service-configuration} fields are:
  9772. @deftypevr {@code{service-configuration} parameter} string kind
  9773. The service kind. Valid values include @code{director},
  9774. @code{imap-login}, @code{pop3-login}, @code{lmtp}, @code{imap},
  9775. @code{pop3}, @code{auth}, @code{auth-worker}, @code{dict},
  9776. @code{tcpwrap}, @code{quota-warning}, or anything else.
  9777. @end deftypevr
  9778. @deftypevr {@code{service-configuration} parameter} listener-configuration-list listeners
  9779. Listeners for the service. A listener is either a
  9780. @code{unix-listener-configuration}, a @code{fifo-listener-configuration}, or
  9781. an @code{inet-listener-configuration}.
  9782. Defaults to @samp{()}.
  9783. Available @code{unix-listener-configuration} fields are:
  9784. @deftypevr {@code{unix-listener-configuration} parameter} string path
  9785. Path to the file, relative to @code{base-dir} field. This is also used as
  9786. the section name.
  9787. @end deftypevr
  9788. @deftypevr {@code{unix-listener-configuration} parameter} string mode
  9789. The access mode for the socket.
  9790. Defaults to @samp{"0600"}.
  9791. @end deftypevr
  9792. @deftypevr {@code{unix-listener-configuration} parameter} string user
  9793. The user to own the socket.
  9794. Defaults to @samp{""}.
  9795. @end deftypevr
  9796. @deftypevr {@code{unix-listener-configuration} parameter} string group
  9797. The group to own the socket.
  9798. Defaults to @samp{""}.
  9799. @end deftypevr
  9800. Available @code{fifo-listener-configuration} fields are:
  9801. @deftypevr {@code{fifo-listener-configuration} parameter} string path
  9802. Path to the file, relative to @code{base-dir} field. This is also used as
  9803. the section name.
  9804. @end deftypevr
  9805. @deftypevr {@code{fifo-listener-configuration} parameter} string mode
  9806. The access mode for the socket.
  9807. Defaults to @samp{"0600"}.
  9808. @end deftypevr
  9809. @deftypevr {@code{fifo-listener-configuration} parameter} string user
  9810. The user to own the socket.
  9811. Defaults to @samp{""}.
  9812. @end deftypevr
  9813. @deftypevr {@code{fifo-listener-configuration} parameter} string group
  9814. The group to own the socket.
  9815. Defaults to @samp{""}.
  9816. @end deftypevr
  9817. Available @code{inet-listener-configuration} fields are:
  9818. @deftypevr {@code{inet-listener-configuration} parameter} string protocol
  9819. The protocol to listen for.
  9820. @end deftypevr
  9821. @deftypevr {@code{inet-listener-configuration} parameter} string address
  9822. The address on which to listen, or empty for all addresses.
  9823. Defaults to @samp{""}.
  9824. @end deftypevr
  9825. @deftypevr {@code{inet-listener-configuration} parameter} non-negative-integer port
  9826. The port on which to listen.
  9827. @end deftypevr
  9828. @deftypevr {@code{inet-listener-configuration} parameter} boolean ssl?
  9829. Whether to use SSL for this service; @samp{yes}, @samp{no}, or
  9830. @samp{required}.
  9831. Defaults to @samp{#t}.
  9832. @end deftypevr
  9833. @end deftypevr
  9834. @deftypevr {@code{service-configuration} parameter} non-negative-integer service-count
  9835. Number of connections to handle before starting a new process.
  9836. Typically the only useful values are 0 (unlimited) or 1. 1 is more
  9837. secure, but 0 is faster. <doc/wiki/LoginProcess.txt>.
  9838. Defaults to @samp{1}.
  9839. @end deftypevr
  9840. @deftypevr {@code{service-configuration} parameter} non-negative-integer process-min-avail
  9841. Number of processes to always keep waiting for more connections.
  9842. Defaults to @samp{0}.
  9843. @end deftypevr
  9844. @deftypevr {@code{service-configuration} parameter} non-negative-integer vsz-limit
  9845. If you set @samp{service-count 0}, you probably need to grow
  9846. this.
  9847. Defaults to @samp{256000000}.
  9848. @end deftypevr
  9849. @end deftypevr
  9850. @deftypevr {@code{dovecot-configuration} parameter} dict-configuration dict
  9851. Dict configuration, as created by the @code{dict-configuration}
  9852. constructor.
  9853. Available @code{dict-configuration} fields are:
  9854. @deftypevr {@code{dict-configuration} parameter} free-form-fields entries
  9855. A list of key-value pairs that this dict should hold.
  9856. Defaults to @samp{()}.
  9857. @end deftypevr
  9858. @end deftypevr
  9859. @deftypevr {@code{dovecot-configuration} parameter} passdb-configuration-list passdbs
  9860. A list of passdb configurations, each one created by the
  9861. @code{passdb-configuration} constructor.
  9862. Available @code{passdb-configuration} fields are:
  9863. @deftypevr {@code{passdb-configuration} parameter} string driver
  9864. The driver that the passdb should use. Valid values include
  9865. @samp{pam}, @samp{passwd}, @samp{shadow}, @samp{bsdauth}, and
  9866. @samp{static}.
  9867. Defaults to @samp{"pam"}.
  9868. @end deftypevr
  9869. @deftypevr {@code{passdb-configuration} parameter} space-separated-string-list args
  9870. Space separated list of arguments to the passdb driver.
  9871. Defaults to @samp{""}.
  9872. @end deftypevr
  9873. @end deftypevr
  9874. @deftypevr {@code{dovecot-configuration} parameter} userdb-configuration-list userdbs
  9875. List of userdb configurations, each one created by the
  9876. @code{userdb-configuration} constructor.
  9877. Available @code{userdb-configuration} fields are:
  9878. @deftypevr {@code{userdb-configuration} parameter} string driver
  9879. The driver that the userdb should use. Valid values include
  9880. @samp{passwd} and @samp{static}.
  9881. Defaults to @samp{"passwd"}.
  9882. @end deftypevr
  9883. @deftypevr {@code{userdb-configuration} parameter} space-separated-string-list args
  9884. Space separated list of arguments to the userdb driver.
  9885. Defaults to @samp{""}.
  9886. @end deftypevr
  9887. @deftypevr {@code{userdb-configuration} parameter} free-form-args override-fields
  9888. Override fields from passwd.
  9889. Defaults to @samp{()}.
  9890. @end deftypevr
  9891. @end deftypevr
  9892. @deftypevr {@code{dovecot-configuration} parameter} plugin-configuration plugin-configuration
  9893. Plug-in configuration, created by the @code{plugin-configuration}
  9894. constructor.
  9895. @end deftypevr
  9896. @deftypevr {@code{dovecot-configuration} parameter} list-of-namespace-configuration namespaces
  9897. List of namespaces. Each item in the list is created by the
  9898. @code{namespace-configuration} constructor.
  9899. Available @code{namespace-configuration} fields are:
  9900. @deftypevr {@code{namespace-configuration} parameter} string name
  9901. Name for this namespace.
  9902. @end deftypevr
  9903. @deftypevr {@code{namespace-configuration} parameter} string type
  9904. Namespace type: @samp{private}, @samp{shared} or @samp{public}.
  9905. Defaults to @samp{"private"}.
  9906. @end deftypevr
  9907. @deftypevr {@code{namespace-configuration} parameter} string separator
  9908. Hierarchy separator to use. You should use the same separator for
  9909. all namespaces or some clients get confused. @samp{/} is usually a good
  9910. one. The default however depends on the underlying mail storage
  9911. format.
  9912. Defaults to @samp{""}.
  9913. @end deftypevr
  9914. @deftypevr {@code{namespace-configuration} parameter} string prefix
  9915. Prefix required to access this namespace. This needs to be
  9916. different for all namespaces. For example @samp{Public/}.
  9917. Defaults to @samp{""}.
  9918. @end deftypevr
  9919. @deftypevr {@code{namespace-configuration} parameter} string location
  9920. Physical location of the mailbox. This is in the same format as
  9921. mail_location, which is also the default for it.
  9922. Defaults to @samp{""}.
  9923. @end deftypevr
  9924. @deftypevr {@code{namespace-configuration} parameter} boolean inbox?
  9925. There can be only one INBOX, and this setting defines which
  9926. namespace has it.
  9927. Defaults to @samp{#f}.
  9928. @end deftypevr
  9929. @deftypevr {@code{namespace-configuration} parameter} boolean hidden?
  9930. If namespace is hidden, it's not advertised to clients via NAMESPACE
  9931. extension. You'll most likely also want to set @samp{list? #f}. This is mostly
  9932. useful when converting from another server with different namespaces
  9933. which you want to deprecate but still keep working. For example you can
  9934. create hidden namespaces with prefixes @samp{~/mail/}, @samp{~%u/mail/}
  9935. and @samp{mail/}.
  9936. Defaults to @samp{#f}.
  9937. @end deftypevr
  9938. @deftypevr {@code{namespace-configuration} parameter} boolean list?
  9939. Show the mailboxes under this namespace with the LIST command. This
  9940. makes the namespace visible for clients that do not support the NAMESPACE
  9941. extension. The special @code{children} value lists child mailboxes, but
  9942. hides the namespace prefix.
  9943. Defaults to @samp{#t}.
  9944. @end deftypevr
  9945. @deftypevr {@code{namespace-configuration} parameter} boolean subscriptions?
  9946. Namespace handles its own subscriptions. If set to @code{#f}, the
  9947. parent namespace handles them. The empty prefix should always have this
  9948. as @code{#t}).
  9949. Defaults to @samp{#t}.
  9950. @end deftypevr
  9951. @deftypevr {@code{namespace-configuration} parameter} mailbox-configuration-list mailboxes
  9952. List of predefined mailboxes in this namespace.
  9953. Defaults to @samp{()}.
  9954. Available @code{mailbox-configuration} fields are:
  9955. @deftypevr {@code{mailbox-configuration} parameter} string name
  9956. Name for this mailbox.
  9957. @end deftypevr
  9958. @deftypevr {@code{mailbox-configuration} parameter} string auto
  9959. @samp{create} will automatically create this mailbox.
  9960. @samp{subscribe} will both create and subscribe to the mailbox.
  9961. Defaults to @samp{"no"}.
  9962. @end deftypevr
  9963. @deftypevr {@code{mailbox-configuration} parameter} space-separated-string-list special-use
  9964. List of IMAP @code{SPECIAL-USE} attributes as specified by RFC 6154.
  9965. Valid values are @code{\All}, @code{\Archive}, @code{\Drafts},
  9966. @code{\Flagged}, @code{\Junk}, @code{\Sent}, and @code{\Trash}.
  9967. Defaults to @samp{()}.
  9968. @end deftypevr
  9969. @end deftypevr
  9970. @end deftypevr
  9971. @deftypevr {@code{dovecot-configuration} parameter} file-name base-dir
  9972. Base directory where to store runtime data.
  9973. Defaults to @samp{"/var/run/dovecot/"}.
  9974. @end deftypevr
  9975. @deftypevr {@code{dovecot-configuration} parameter} string login-greeting
  9976. Greeting message for clients.
  9977. Defaults to @samp{"Dovecot ready."}.
  9978. @end deftypevr
  9979. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-trusted-networks
  9980. List of trusted network ranges. Connections from these IPs are
  9981. allowed to override their IP addresses and ports (for logging and for
  9982. authentication checks). @samp{disable-plaintext-auth} is also ignored
  9983. for these networks. Typically you would specify your IMAP proxy servers
  9984. here.
  9985. Defaults to @samp{()}.
  9986. @end deftypevr
  9987. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-access-sockets
  9988. List of login access check sockets (e.g. tcpwrap).
  9989. Defaults to @samp{()}.
  9990. @end deftypevr
  9991. @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-proctitle?
  9992. Show more verbose process titles (in ps). Currently shows user name
  9993. and IP address. Useful for seeing who is actually using the IMAP
  9994. processes (e.g. shared mailboxes or if the same uid is used for multiple
  9995. accounts).
  9996. Defaults to @samp{#f}.
  9997. @end deftypevr
  9998. @deftypevr {@code{dovecot-configuration} parameter} boolean shutdown-clients?
  9999. Should all processes be killed when Dovecot master process shuts down.
  10000. Setting this to @code{#f} means that Dovecot can be upgraded without
  10001. forcing existing client connections to close (although that could also
  10002. be a problem if the upgrade is e.g. due to a security fix).
  10003. Defaults to @samp{#t}.
  10004. @end deftypevr
  10005. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer doveadm-worker-count
  10006. If non-zero, run mail commands via this many connections to doveadm
  10007. server, instead of running them directly in the same process.
  10008. Defaults to @samp{0}.
  10009. @end deftypevr
  10010. @deftypevr {@code{dovecot-configuration} parameter} string doveadm-socket-path
  10011. UNIX socket or host:port used for connecting to doveadm server.
  10012. Defaults to @samp{"doveadm-server"}.
  10013. @end deftypevr
  10014. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list import-environment
  10015. List of environment variables that are preserved on Dovecot startup
  10016. and passed down to all of its child processes. You can also give
  10017. key=value pairs to always set specific settings.
  10018. @end deftypevr
  10019. @deftypevr {@code{dovecot-configuration} parameter} boolean disable-plaintext-auth?
  10020. Disable LOGIN command and all other plaintext authentications unless
  10021. SSL/TLS is used (LOGINDISABLED capability). Note that if the remote IP
  10022. matches the local IP (i.e. you're connecting from the same computer),
  10023. the connection is considered secure and plaintext authentication is
  10024. allowed. See also ssl=required setting.
  10025. Defaults to @samp{#t}.
  10026. @end deftypevr
  10027. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-cache-size
  10028. Authentication cache size (e.g. @samp{#e10e6}). 0 means it's disabled.
  10029. Note that bsdauth, PAM and vpopmail require @samp{cache-key} to be set
  10030. for caching to be used.
  10031. Defaults to @samp{0}.
  10032. @end deftypevr
  10033. @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-ttl
  10034. Time to live for cached data. After TTL expires the cached record
  10035. is no longer used, *except* if the main database lookup returns internal
  10036. failure. We also try to handle password changes automatically: If
  10037. user's previous authentication was successful, but this one wasn't, the
  10038. cache isn't used. For now this works only with plaintext
  10039. authentication.
  10040. Defaults to @samp{"1 hour"}.
  10041. @end deftypevr
  10042. @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-negative-ttl
  10043. TTL for negative hits (user not found, password mismatch).
  10044. 0 disables caching them completely.
  10045. Defaults to @samp{"1 hour"}.
  10046. @end deftypevr
  10047. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-realms
  10048. List of realms for SASL authentication mechanisms that need them.
  10049. You can leave it empty if you don't want to support multiple realms.
  10050. Many clients simply use the first one listed here, so keep the default
  10051. realm first.
  10052. Defaults to @samp{()}.
  10053. @end deftypevr
  10054. @deftypevr {@code{dovecot-configuration} parameter} string auth-default-realm
  10055. Default realm/domain to use if none was specified. This is used for
  10056. both SASL realms and appending @@domain to username in plaintext
  10057. logins.
  10058. Defaults to @samp{""}.
  10059. @end deftypevr
  10060. @deftypevr {@code{dovecot-configuration} parameter} string auth-username-chars
  10061. List of allowed characters in username. If the user-given username
  10062. contains a character not listed in here, the login automatically fails.
  10063. This is just an extra check to make sure user can't exploit any
  10064. potential quote escaping vulnerabilities with SQL/LDAP databases. If
  10065. you want to allow all characters, set this value to empty.
  10066. Defaults to @samp{"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@@"}.
  10067. @end deftypevr
  10068. @deftypevr {@code{dovecot-configuration} parameter} string auth-username-translation
  10069. Username character translations before it's looked up from
  10070. databases. The value contains series of from -> to characters. For
  10071. example @samp{#@@/@@} means that @samp{#} and @samp{/} characters are
  10072. translated to @samp{@@}.
  10073. Defaults to @samp{""}.
  10074. @end deftypevr
  10075. @deftypevr {@code{dovecot-configuration} parameter} string auth-username-format
  10076. Username formatting before it's looked up from databases. You can
  10077. use the standard variables here, e.g. %Lu would lowercase the username,
  10078. %n would drop away the domain if it was given, or @samp{%n-AT-%d} would
  10079. change the @samp{@@} into @samp{-AT-}. This translation is done after
  10080. @samp{auth-username-translation} changes.
  10081. Defaults to @samp{"%Lu"}.
  10082. @end deftypevr
  10083. @deftypevr {@code{dovecot-configuration} parameter} string auth-master-user-separator
  10084. If you want to allow master users to log in by specifying the master
  10085. username within the normal username string (i.e. not using SASL
  10086. mechanism's support for it), you can specify the separator character
  10087. here. The format is then <username><separator><master username>.
  10088. UW-IMAP uses @samp{*} as the separator, so that could be a good
  10089. choice.
  10090. Defaults to @samp{""}.
  10091. @end deftypevr
  10092. @deftypevr {@code{dovecot-configuration} parameter} string auth-anonymous-username
  10093. Username to use for users logging in with ANONYMOUS SASL
  10094. mechanism.
  10095. Defaults to @samp{"anonymous"}.
  10096. @end deftypevr
  10097. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-worker-max-count
  10098. Maximum number of dovecot-auth worker processes. They're used to
  10099. execute blocking passdb and userdb queries (e.g. MySQL and PAM).
  10100. They're automatically created and destroyed as needed.
  10101. Defaults to @samp{30}.
  10102. @end deftypevr
  10103. @deftypevr {@code{dovecot-configuration} parameter} string auth-gssapi-hostname
  10104. Host name to use in GSSAPI principal names. The default is to use
  10105. the name returned by gethostname(). Use @samp{$ALL} (with quotes) to
  10106. allow all keytab entries.
  10107. Defaults to @samp{""}.
  10108. @end deftypevr
  10109. @deftypevr {@code{dovecot-configuration} parameter} string auth-krb5-keytab
  10110. Kerberos keytab to use for the GSSAPI mechanism. Will use the
  10111. system default (usually @file{/etc/krb5.keytab}) if not specified. You may
  10112. need to change the auth service to run as root to be able to read this
  10113. file.
  10114. Defaults to @samp{""}.
  10115. @end deftypevr
  10116. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-use-winbind?
  10117. Do NTLM and GSS-SPNEGO authentication using Samba's winbind daemon
  10118. and @samp{ntlm-auth} helper.
  10119. <doc/wiki/Authentication/Mechanisms/Winbind.txt>.
  10120. Defaults to @samp{#f}.
  10121. @end deftypevr
  10122. @deftypevr {@code{dovecot-configuration} parameter} file-name auth-winbind-helper-path
  10123. Path for Samba's @samp{ntlm-auth} helper binary.
  10124. Defaults to @samp{"/usr/bin/ntlm_auth"}.
  10125. @end deftypevr
  10126. @deftypevr {@code{dovecot-configuration} parameter} string auth-failure-delay
  10127. Time to delay before replying to failed authentications.
  10128. Defaults to @samp{"2 secs"}.
  10129. @end deftypevr
  10130. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-require-client-cert?
  10131. Require a valid SSL client certificate or the authentication
  10132. fails.
  10133. Defaults to @samp{#f}.
  10134. @end deftypevr
  10135. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-username-from-cert?
  10136. Take the username from client's SSL certificate, using
  10137. @code{X509_NAME_get_text_by_NID()} which returns the subject's DN's
  10138. CommonName.
  10139. Defaults to @samp{#f}.
  10140. @end deftypevr
  10141. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-mechanisms
  10142. List of wanted authentication mechanisms. Supported mechanisms are:
  10143. @samp{plain}, @samp{login}, @samp{digest-md5}, @samp{cram-md5},
  10144. @samp{ntlm}, @samp{rpa}, @samp{apop}, @samp{anonymous}, @samp{gssapi},
  10145. @samp{otp}, @samp{skey}, and @samp{gss-spnego}. NOTE: See also
  10146. @samp{disable-plaintext-auth} setting.
  10147. @end deftypevr
  10148. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-servers
  10149. List of IPs or hostnames to all director servers, including ourself.
  10150. Ports can be specified as ip:port. The default port is the same as what
  10151. director service's @samp{inet-listener} is using.
  10152. Defaults to @samp{()}.
  10153. @end deftypevr
  10154. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-mail-servers
  10155. List of IPs or hostnames to all backend mail servers. Ranges are
  10156. allowed too, like 10.0.0.10-10.0.0.30.
  10157. Defaults to @samp{()}.
  10158. @end deftypevr
  10159. @deftypevr {@code{dovecot-configuration} parameter} string director-user-expire
  10160. How long to redirect users to a specific server after it no longer
  10161. has any connections.
  10162. Defaults to @samp{"15 min"}.
  10163. @end deftypevr
  10164. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer director-doveadm-port
  10165. TCP/IP port that accepts doveadm connections (instead of director
  10166. connections) If you enable this, you'll also need to add
  10167. @samp{inet-listener} for the port.
  10168. Defaults to @samp{0}.
  10169. @end deftypevr
  10170. @deftypevr {@code{dovecot-configuration} parameter} string director-username-hash
  10171. How the username is translated before being hashed. Useful values
  10172. include %Ln if user can log in with or without @@domain, %Ld if mailboxes
  10173. are shared within domain.
  10174. Defaults to @samp{"%Lu"}.
  10175. @end deftypevr
  10176. @deftypevr {@code{dovecot-configuration} parameter} string log-path
  10177. Log file to use for error messages. @samp{syslog} logs to syslog,
  10178. @samp{/dev/stderr} logs to stderr.
  10179. Defaults to @samp{"syslog"}.
  10180. @end deftypevr
  10181. @deftypevr {@code{dovecot-configuration} parameter} string info-log-path
  10182. Log file to use for informational messages. Defaults to
  10183. @samp{log-path}.
  10184. Defaults to @samp{""}.
  10185. @end deftypevr
  10186. @deftypevr {@code{dovecot-configuration} parameter} string debug-log-path
  10187. Log file to use for debug messages. Defaults to
  10188. @samp{info-log-path}.
  10189. Defaults to @samp{""}.
  10190. @end deftypevr
  10191. @deftypevr {@code{dovecot-configuration} parameter} string syslog-facility
  10192. Syslog facility to use if you're logging to syslog. Usually if you
  10193. don't want to use @samp{mail}, you'll use local0..local7. Also other
  10194. standard facilities are supported.
  10195. Defaults to @samp{"mail"}.
  10196. @end deftypevr
  10197. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-verbose?
  10198. Log unsuccessful authentication attempts and the reasons why they
  10199. failed.
  10200. Defaults to @samp{#f}.
  10201. @end deftypevr
  10202. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-verbose-passwords?
  10203. In case of password mismatches, log the attempted password. Valid
  10204. values are no, plain and sha1. sha1 can be useful for detecting brute
  10205. force password attempts vs. user simply trying the same password over
  10206. and over again. You can also truncate the value to n chars by appending
  10207. ":n" (e.g. sha1:6).
  10208. Defaults to @samp{#f}.
  10209. @end deftypevr
  10210. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug?
  10211. Even more verbose logging for debugging purposes. Shows for example
  10212. SQL queries.
  10213. Defaults to @samp{#f}.
  10214. @end deftypevr
  10215. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug-passwords?
  10216. In case of password mismatches, log the passwords and used scheme so
  10217. the problem can be debugged. Enabling this also enables
  10218. @samp{auth-debug}.
  10219. Defaults to @samp{#f}.
  10220. @end deftypevr
  10221. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-debug?
  10222. Enable mail process debugging. This can help you figure out why
  10223. Dovecot isn't finding your mails.
  10224. Defaults to @samp{#f}.
  10225. @end deftypevr
  10226. @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-ssl?
  10227. Show protocol level SSL errors.
  10228. Defaults to @samp{#f}.
  10229. @end deftypevr
  10230. @deftypevr {@code{dovecot-configuration} parameter} string log-timestamp
  10231. Prefix for each line written to log file. % codes are in
  10232. strftime(3) format.
  10233. Defaults to @samp{"\"%b %d %H:%M:%S \""}.
  10234. @end deftypevr
  10235. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-log-format-elements
  10236. List of elements we want to log. The elements which have a
  10237. non-empty variable value are joined together to form a comma-separated
  10238. string.
  10239. @end deftypevr
  10240. @deftypevr {@code{dovecot-configuration} parameter} string login-log-format
  10241. Login log format. %s contains @samp{login-log-format-elements}
  10242. string, %$ contains the data we want to log.
  10243. Defaults to @samp{"%$: %s"}.
  10244. @end deftypevr
  10245. @deftypevr {@code{dovecot-configuration} parameter} string mail-log-prefix
  10246. Log prefix for mail processes. See doc/wiki/Variables.txt for list
  10247. of possible variables you can use.
  10248. Defaults to @samp{"\"%s(%u): \""}.
  10249. @end deftypevr
  10250. @deftypevr {@code{dovecot-configuration} parameter} string deliver-log-format
  10251. Format to use for logging mail deliveries. You can use variables:
  10252. @table @code
  10253. @item %$
  10254. Delivery status message (e.g. @samp{saved to INBOX})
  10255. @item %m
  10256. Message-ID
  10257. @item %s
  10258. Subject
  10259. @item %f
  10260. From address
  10261. @item %p
  10262. Physical size
  10263. @item %w
  10264. Virtual size.
  10265. @end table
  10266. Defaults to @samp{"msgid=%m: %$"}.
  10267. @end deftypevr
  10268. @deftypevr {@code{dovecot-configuration} parameter} string mail-location
  10269. Location for users' mailboxes. The default is empty, which means
  10270. that Dovecot tries to find the mailboxes automatically. This won't work
  10271. if the user doesn't yet have any mail, so you should explicitly tell
  10272. Dovecot the full location.
  10273. If you're using mbox, giving a path to the INBOX
  10274. file (e.g. /var/mail/%u) isn't enough. You'll also need to tell Dovecot
  10275. where the other mailboxes are kept. This is called the "root mail
  10276. directory", and it must be the first path given in the
  10277. @samp{mail-location} setting.
  10278. There are a few special variables you can use, eg.:
  10279. @table @samp
  10280. @item %u
  10281. username
  10282. @item %n
  10283. user part in user@@domain, same as %u if there's no domain
  10284. @item %d
  10285. domain part in user@@domain, empty if there's no domain
  10286. @item %h
  10287. home director
  10288. @end table
  10289. See doc/wiki/Variables.txt for full list. Some examples:
  10290. @table @samp
  10291. @item maildir:~/Maildir
  10292. @item mbox:~/mail:INBOX=/var/mail/%u
  10293. @item mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/%
  10294. @end table
  10295. Defaults to @samp{""}.
  10296. @end deftypevr
  10297. @deftypevr {@code{dovecot-configuration} parameter} string mail-uid
  10298. System user and group used to access mails. If you use multiple,
  10299. userdb can override these by returning uid or gid fields. You can use
  10300. either numbers or names. <doc/wiki/UserIds.txt>.
  10301. Defaults to @samp{""}.
  10302. @end deftypevr
  10303. @deftypevr {@code{dovecot-configuration} parameter} string mail-gid
  10304. Defaults to @samp{""}.
  10305. @end deftypevr
  10306. @deftypevr {@code{dovecot-configuration} parameter} string mail-privileged-group
  10307. Group to enable temporarily for privileged operations. Currently
  10308. this is used only with INBOX when either its initial creation or
  10309. dotlocking fails. Typically this is set to "mail" to give access to
  10310. /var/mail.
  10311. Defaults to @samp{""}.
  10312. @end deftypevr
  10313. @deftypevr {@code{dovecot-configuration} parameter} string mail-access-groups
  10314. Grant access to these supplementary groups for mail processes.
  10315. Typically these are used to set up access to shared mailboxes. Note
  10316. that it may be dangerous to set these if users can create
  10317. symlinks (e.g. if "mail" group is set here, ln -s /var/mail ~/mail/var
  10318. could allow a user to delete others' mailboxes, or ln -s
  10319. /secret/shared/box ~/mail/mybox would allow reading it).
  10320. Defaults to @samp{""}.
  10321. @end deftypevr
  10322. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-full-filesystem-access?
  10323. Allow full file system access to clients. There's no access checks
  10324. other than what the operating system does for the active UID/GID. It
  10325. works with both maildir and mboxes, allowing you to prefix mailboxes
  10326. names with e.g. /path/ or ~user/.
  10327. Defaults to @samp{#f}.
  10328. @end deftypevr
  10329. @deftypevr {@code{dovecot-configuration} parameter} boolean mmap-disable?
  10330. Don't use mmap() at all. This is required if you store indexes to
  10331. shared file systems (NFS or clustered file system).
  10332. Defaults to @samp{#f}.
  10333. @end deftypevr
  10334. @deftypevr {@code{dovecot-configuration} parameter} boolean dotlock-use-excl?
  10335. Rely on @samp{O_EXCL} to work when creating dotlock files. NFS
  10336. supports @samp{O_EXCL} since version 3, so this should be safe to use
  10337. nowadays by default.
  10338. Defaults to @samp{#t}.
  10339. @end deftypevr
  10340. @deftypevr {@code{dovecot-configuration} parameter} string mail-fsync
  10341. When to use fsync() or fdatasync() calls:
  10342. @table @code
  10343. @item optimized
  10344. Whenever necessary to avoid losing important data
  10345. @item always
  10346. Useful with e.g. NFS when write()s are delayed
  10347. @item never
  10348. Never use it (best performance, but crashes can lose data).
  10349. @end table
  10350. Defaults to @samp{"optimized"}.
  10351. @end deftypevr
  10352. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-storage?
  10353. Mail storage exists in NFS. Set this to yes to make Dovecot flush
  10354. NFS caches whenever needed. If you're using only a single mail server
  10355. this isn't needed.
  10356. Defaults to @samp{#f}.
  10357. @end deftypevr
  10358. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-index?
  10359. Mail index files also exist in NFS. Setting this to yes requires
  10360. @samp{mmap-disable? #t} and @samp{fsync-disable? #f}.
  10361. Defaults to @samp{#f}.
  10362. @end deftypevr
  10363. @deftypevr {@code{dovecot-configuration} parameter} string lock-method
  10364. Locking method for index files. Alternatives are fcntl, flock and
  10365. dotlock. Dotlocking uses some tricks which may create more disk I/O
  10366. than other locking methods. NFS users: flock doesn't work, remember to
  10367. change @samp{mmap-disable}.
  10368. Defaults to @samp{"fcntl"}.
  10369. @end deftypevr
  10370. @deftypevr {@code{dovecot-configuration} parameter} file-name mail-temp-dir
  10371. Directory in which LDA/LMTP temporarily stores incoming mails >128
  10372. kB.
  10373. Defaults to @samp{"/tmp"}.
  10374. @end deftypevr
  10375. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-uid
  10376. Valid UID range for users. This is mostly to make sure that users can't
  10377. log in as daemons or other system users. Note that denying root logins is
  10378. hardcoded to dovecot binary and can't be done even if @samp{first-valid-uid}
  10379. is set to 0.
  10380. Defaults to @samp{500}.
  10381. @end deftypevr
  10382. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-uid
  10383. Defaults to @samp{0}.
  10384. @end deftypevr
  10385. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-gid
  10386. Valid GID range for users. Users having non-valid GID as primary group ID
  10387. aren't allowed to log in. If user belongs to supplementary groups with
  10388. non-valid GIDs, those groups are not set.
  10389. Defaults to @samp{1}.
  10390. @end deftypevr
  10391. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-gid
  10392. Defaults to @samp{0}.
  10393. @end deftypevr
  10394. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-max-keyword-length
  10395. Maximum allowed length for mail keyword name. It's only forced when
  10396. trying to create new keywords.
  10397. Defaults to @samp{50}.
  10398. @end deftypevr
  10399. @deftypevr {@code{dovecot-configuration} parameter} colon-separated-file-name-list valid-chroot-dirs
  10400. List of directories under which chrooting is allowed for mail
  10401. processes (i.e. /var/mail will allow chrooting to /var/mail/foo/bar
  10402. too). This setting doesn't affect @samp{login-chroot}
  10403. @samp{mail-chroot} or auth chroot settings. If this setting is empty,
  10404. "/./" in home dirs are ignored. WARNING: Never add directories here
  10405. which local users can modify, that may lead to root exploit. Usually
  10406. this should be done only if you don't allow shell access for users.
  10407. <doc/wiki/Chrooting.txt>.
  10408. Defaults to @samp{()}.
  10409. @end deftypevr
  10410. @deftypevr {@code{dovecot-configuration} parameter} string mail-chroot
  10411. Default chroot directory for mail processes. This can be overridden
  10412. for specific users in user database by giving /./ in user's home
  10413. directory (e.g. /home/./user chroots into /home). Note that usually
  10414. there is no real need to do chrooting, Dovecot doesn't allow users to
  10415. access files outside their mail directory anyway. If your home
  10416. directories are prefixed with the chroot directory, append "/." to
  10417. @samp{mail-chroot}. <doc/wiki/Chrooting.txt>.
  10418. Defaults to @samp{""}.
  10419. @end deftypevr
  10420. @deftypevr {@code{dovecot-configuration} parameter} file-name auth-socket-path
  10421. UNIX socket path to master authentication server to find users.
  10422. This is used by imap (for shared users) and lda.
  10423. Defaults to @samp{"/var/run/dovecot/auth-userdb"}.
  10424. @end deftypevr
  10425. @deftypevr {@code{dovecot-configuration} parameter} file-name mail-plugin-dir
  10426. Directory where to look up mail plugins.
  10427. Defaults to @samp{"/usr/lib/dovecot"}.
  10428. @end deftypevr
  10429. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mail-plugins
  10430. List of plugins to load for all services. Plugins specific to IMAP,
  10431. LDA, etc. are added to this list in their own .conf files.
  10432. Defaults to @samp{()}.
  10433. @end deftypevr
  10434. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-cache-min-mail-count
  10435. The minimum number of mails in a mailbox before updates are done to
  10436. cache file. This allows optimizing Dovecot's behavior to do less disk
  10437. writes at the cost of more disk reads.
  10438. Defaults to @samp{0}.
  10439. @end deftypevr
  10440. @deftypevr {@code{dovecot-configuration} parameter} string mailbox-idle-check-interval
  10441. When IDLE command is running, mailbox is checked once in a while to
  10442. see if there are any new mails or other changes. This setting defines
  10443. the minimum time to wait between those checks. Dovecot can also use
  10444. dnotify, inotify and kqueue to find out immediately when changes
  10445. occur.
  10446. Defaults to @samp{"30 secs"}.
  10447. @end deftypevr
  10448. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-save-crlf?
  10449. Save mails with CR+LF instead of plain LF. This makes sending those
  10450. mails take less CPU, especially with sendfile() syscall with Linux and
  10451. FreeBSD. But it also creates a bit more disk I/O which may just make it
  10452. slower. Also note that if other software reads the mboxes/maildirs,
  10453. they may handle the extra CRs wrong and cause problems.
  10454. Defaults to @samp{#f}.
  10455. @end deftypevr
  10456. @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-stat-dirs?
  10457. By default LIST command returns all entries in maildir beginning
  10458. with a dot. Enabling this option makes Dovecot return only entries
  10459. which are directories. This is done by stat()ing each entry, so it
  10460. causes more disk I/O.
  10461. (For systems setting struct @samp{dirent->d_type} this check is free
  10462. and it's done always regardless of this setting).
  10463. Defaults to @samp{#f}.
  10464. @end deftypevr
  10465. @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-copy-with-hardlinks?
  10466. When copying a message, do it with hard links whenever possible.
  10467. This makes the performance much better, and it's unlikely to have any
  10468. side effects.
  10469. Defaults to @samp{#t}.
  10470. @end deftypevr
  10471. @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-very-dirty-syncs?
  10472. Assume Dovecot is the only MUA accessing Maildir: Scan cur/
  10473. directory only when its mtime changes unexpectedly or when we can't find
  10474. the mail otherwise.
  10475. Defaults to @samp{#f}.
  10476. @end deftypevr
  10477. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-read-locks
  10478. Which locking methods to use for locking mbox. There are four
  10479. available:
  10480. @table @code
  10481. @item dotlock
  10482. Create <mailbox>.lock file. This is the oldest and most NFS-safe
  10483. solution. If you want to use /var/mail/ like directory, the users will
  10484. need write access to that directory.
  10485. @item dotlock-try
  10486. Same as dotlock, but if it fails because of permissions or because there
  10487. isn't enough disk space, just skip it.
  10488. @item fcntl
  10489. Use this if possible. Works with NFS too if lockd is used.
  10490. @item flock
  10491. May not exist in all systems. Doesn't work with NFS.
  10492. @item lockf
  10493. May not exist in all systems. Doesn't work with NFS.
  10494. @end table
  10495. You can use multiple locking methods; if you do the order they're declared
  10496. in is important to avoid deadlocks if other MTAs/MUAs are using multiple
  10497. locking methods as well. Some operating systems don't allow using some of
  10498. them simultaneously.
  10499. @end deftypevr
  10500. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-write-locks
  10501. @end deftypevr
  10502. @deftypevr {@code{dovecot-configuration} parameter} string mbox-lock-timeout
  10503. Maximum time to wait for lock (all of them) before aborting.
  10504. Defaults to @samp{"5 mins"}.
  10505. @end deftypevr
  10506. @deftypevr {@code{dovecot-configuration} parameter} string mbox-dotlock-change-timeout
  10507. If dotlock exists but the mailbox isn't modified in any way,
  10508. override the lock file after this much time.
  10509. Defaults to @samp{"2 mins"}.
  10510. @end deftypevr
  10511. @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-dirty-syncs?
  10512. When mbox changes unexpectedly we have to fully read it to find out
  10513. what changed. If the mbox is large this can take a long time. Since
  10514. the change is usually just a newly appended mail, it'd be faster to
  10515. simply read the new mails. If this setting is enabled, Dovecot does
  10516. this but still safely fallbacks to re-reading the whole mbox file
  10517. whenever something in mbox isn't how it's expected to be. The only real
  10518. downside to this setting is that if some other MUA changes message
  10519. flags, Dovecot doesn't notice it immediately. Note that a full sync is
  10520. done with SELECT, EXAMINE, EXPUNGE and CHECK commands.
  10521. Defaults to @samp{#t}.
  10522. @end deftypevr
  10523. @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-very-dirty-syncs?
  10524. Like @samp{mbox-dirty-syncs}, but don't do full syncs even with SELECT,
  10525. EXAMINE, EXPUNGE or CHECK commands. If this is set,
  10526. @samp{mbox-dirty-syncs} is ignored.
  10527. Defaults to @samp{#f}.
  10528. @end deftypevr
  10529. @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-lazy-writes?
  10530. Delay writing mbox headers until doing a full write sync (EXPUNGE
  10531. and CHECK commands and when closing the mailbox). This is especially
  10532. useful for POP3 where clients often delete all mails. The downside is
  10533. that our changes aren't immediately visible to other MUAs.
  10534. Defaults to @samp{#t}.
  10535. @end deftypevr
  10536. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mbox-min-index-size
  10537. If mbox size is smaller than this (e.g. 100k), don't write index
  10538. files. If an index file already exists it's still read, just not
  10539. updated.
  10540. Defaults to @samp{0}.
  10541. @end deftypevr
  10542. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mdbox-rotate-size
  10543. Maximum dbox file size until it's rotated.
  10544. Defaults to @samp{2000000}.
  10545. @end deftypevr
  10546. @deftypevr {@code{dovecot-configuration} parameter} string mdbox-rotate-interval
  10547. Maximum dbox file age until it's rotated. Typically in days. Day
  10548. begins from midnight, so 1d = today, 2d = yesterday, etc. 0 = check
  10549. disabled.
  10550. Defaults to @samp{"1d"}.
  10551. @end deftypevr
  10552. @deftypevr {@code{dovecot-configuration} parameter} boolean mdbox-preallocate-space?
  10553. When creating new mdbox files, immediately preallocate their size to
  10554. @samp{mdbox-rotate-size}. This setting currently works only in Linux
  10555. with some file systems (ext4, xfs).
  10556. Defaults to @samp{#f}.
  10557. @end deftypevr
  10558. @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-dir
  10559. sdbox and mdbox support saving mail attachments to external files,
  10560. which also allows single instance storage for them. Other backends
  10561. don't support this for now.
  10562. WARNING: This feature hasn't been tested much yet. Use at your own risk.
  10563. Directory root where to store mail attachments. Disabled, if empty.
  10564. Defaults to @samp{""}.
  10565. @end deftypevr
  10566. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-attachment-min-size
  10567. Attachments smaller than this aren't saved externally. It's also
  10568. possible to write a plugin to disable saving specific attachments
  10569. externally.
  10570. Defaults to @samp{128000}.
  10571. @end deftypevr
  10572. @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-fs
  10573. File system backend to use for saving attachments:
  10574. @table @code
  10575. @item posix
  10576. No SiS done by Dovecot (but this might help FS's own deduplication)
  10577. @item sis posix
  10578. SiS with immediate byte-by-byte comparison during saving
  10579. @item sis-queue posix
  10580. SiS with delayed comparison and deduplication.
  10581. @end table
  10582. Defaults to @samp{"sis posix"}.
  10583. @end deftypevr
  10584. @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-hash
  10585. Hash format to use in attachment filenames. You can add any text and
  10586. variables: @code{%@{md4@}}, @code{%@{md5@}}, @code{%@{sha1@}},
  10587. @code{%@{sha256@}}, @code{%@{sha512@}}, @code{%@{size@}}. Variables can be
  10588. truncated, e.g. @code{%@{sha256:80@}} returns only first 80 bits.
  10589. Defaults to @samp{"%@{sha1@}"}.
  10590. @end deftypevr
  10591. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-process-limit
  10592. Defaults to @samp{100}.
  10593. @end deftypevr
  10594. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-client-limit
  10595. Defaults to @samp{1000}.
  10596. @end deftypevr
  10597. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-vsz-limit
  10598. Default VSZ (virtual memory size) limit for service processes.
  10599. This is mainly intended to catch and kill processes that leak memory
  10600. before they eat up everything.
  10601. Defaults to @samp{256000000}.
  10602. @end deftypevr
  10603. @deftypevr {@code{dovecot-configuration} parameter} string default-login-user
  10604. Login user is internally used by login processes. This is the most
  10605. untrusted user in Dovecot system. It shouldn't have access to anything
  10606. at all.
  10607. Defaults to @samp{"dovenull"}.
  10608. @end deftypevr
  10609. @deftypevr {@code{dovecot-configuration} parameter} string default-internal-user
  10610. Internal user is used by unprivileged processes. It should be
  10611. separate from login user, so that login processes can't disturb other
  10612. processes.
  10613. Defaults to @samp{"dovecot"}.
  10614. @end deftypevr
  10615. @deftypevr {@code{dovecot-configuration} parameter} string ssl?
  10616. SSL/TLS support: yes, no, required. <doc/wiki/SSL.txt>.
  10617. Defaults to @samp{"required"}.
  10618. @end deftypevr
  10619. @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert
  10620. PEM encoded X.509 SSL/TLS certificate (public key).
  10621. Defaults to @samp{"</etc/dovecot/default.pem"}.
  10622. @end deftypevr
  10623. @deftypevr {@code{dovecot-configuration} parameter} string ssl-key
  10624. PEM encoded SSL/TLS private key. The key is opened before
  10625. dropping root privileges, so keep the key file unreadable by anyone but
  10626. root.
  10627. Defaults to @samp{"</etc/dovecot/private/default.pem"}.
  10628. @end deftypevr
  10629. @deftypevr {@code{dovecot-configuration} parameter} string ssl-key-password
  10630. If key file is password protected, give the password here.
  10631. Alternatively give it when starting dovecot with -p parameter. Since
  10632. this file is often world-readable, you may want to place this setting
  10633. instead to a different.
  10634. Defaults to @samp{""}.
  10635. @end deftypevr
  10636. @deftypevr {@code{dovecot-configuration} parameter} string ssl-ca
  10637. PEM encoded trusted certificate authority. Set this only if you
  10638. intend to use @samp{ssl-verify-client-cert? #t}. The file should
  10639. contain the CA certificate(s) followed by the matching
  10640. CRL(s). (e.g. @samp{ssl-ca </etc/ssl/certs/ca.pem}).
  10641. Defaults to @samp{""}.
  10642. @end deftypevr
  10643. @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-require-crl?
  10644. Require that CRL check succeeds for client certificates.
  10645. Defaults to @samp{#t}.
  10646. @end deftypevr
  10647. @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-verify-client-cert?
  10648. Request client to send a certificate. If you also want to require
  10649. it, set @samp{auth-ssl-require-client-cert? #t} in auth section.
  10650. Defaults to @samp{#f}.
  10651. @end deftypevr
  10652. @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert-username-field
  10653. Which field from certificate to use for username. commonName and
  10654. x500UniqueIdentifier are the usual choices. You'll also need to set
  10655. @samp{auth-ssl-username-from-cert? #t}.
  10656. Defaults to @samp{"commonName"}.
  10657. @end deftypevr
  10658. @deftypevr {@code{dovecot-configuration} parameter} hours ssl-parameters-regenerate
  10659. How often to regenerate the SSL parameters file. Generation is
  10660. quite CPU intensive operation. The value is in hours, 0 disables
  10661. regeneration entirely.
  10662. Defaults to @samp{168}.
  10663. @end deftypevr
  10664. @deftypevr {@code{dovecot-configuration} parameter} string ssl-protocols
  10665. SSL protocols to use.
  10666. Defaults to @samp{"!SSLv2"}.
  10667. @end deftypevr
  10668. @deftypevr {@code{dovecot-configuration} parameter} string ssl-cipher-list
  10669. SSL ciphers to use.
  10670. Defaults to @samp{"ALL:!LOW:!SSLv2:!EXP:!aNULL"}.
  10671. @end deftypevr
  10672. @deftypevr {@code{dovecot-configuration} parameter} string ssl-crypto-device
  10673. SSL crypto device to use, for valid values run "openssl engine".
  10674. Defaults to @samp{""}.
  10675. @end deftypevr
  10676. @deftypevr {@code{dovecot-configuration} parameter} string postmaster-address
  10677. Address to use when sending rejection mails.
  10678. %d expands to recipient domain.
  10679. Defaults to @samp{"postmaster@@%d"}.
  10680. @end deftypevr
  10681. @deftypevr {@code{dovecot-configuration} parameter} string hostname
  10682. Hostname to use in various parts of sent mails (e.g. in Message-Id)
  10683. and in LMTP replies. Default is the system's real hostname@@domain.
  10684. Defaults to @samp{""}.
  10685. @end deftypevr
  10686. @deftypevr {@code{dovecot-configuration} parameter} boolean quota-full-tempfail?
  10687. If user is over quota, return with temporary failure instead of
  10688. bouncing the mail.
  10689. Defaults to @samp{#f}.
  10690. @end deftypevr
  10691. @deftypevr {@code{dovecot-configuration} parameter} file-name sendmail-path
  10692. Binary to use for sending mails.
  10693. Defaults to @samp{"/usr/sbin/sendmail"}.
  10694. @end deftypevr
  10695. @deftypevr {@code{dovecot-configuration} parameter} string submission-host
  10696. If non-empty, send mails via this SMTP host[:port] instead of
  10697. sendmail.
  10698. Defaults to @samp{""}.
  10699. @end deftypevr
  10700. @deftypevr {@code{dovecot-configuration} parameter} string rejection-subject
  10701. Subject: header to use for rejection mails. You can use the same
  10702. variables as for @samp{rejection-reason} below.
  10703. Defaults to @samp{"Rejected: %s"}.
  10704. @end deftypevr
  10705. @deftypevr {@code{dovecot-configuration} parameter} string rejection-reason
  10706. Human readable error message for rejection mails. You can use
  10707. variables:
  10708. @table @code
  10709. @item %n
  10710. CRLF
  10711. @item %r
  10712. reason
  10713. @item %s
  10714. original subject
  10715. @item %t
  10716. recipient
  10717. @end table
  10718. Defaults to @samp{"Your message to <%t> was automatically rejected:%n%r"}.
  10719. @end deftypevr
  10720. @deftypevr {@code{dovecot-configuration} parameter} string recipient-delimiter
  10721. Delimiter character between local-part and detail in email
  10722. address.
  10723. Defaults to @samp{"+"}.
  10724. @end deftypevr
  10725. @deftypevr {@code{dovecot-configuration} parameter} string lda-original-recipient-header
  10726. Header where the original recipient address (SMTP's RCPT TO:
  10727. address) is taken from if not available elsewhere. With dovecot-lda -a
  10728. parameter overrides this. A commonly used header for this is
  10729. X-Original-To.
  10730. Defaults to @samp{""}.
  10731. @end deftypevr
  10732. @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autocreate?
  10733. Should saving a mail to a nonexistent mailbox automatically create
  10734. it?.
  10735. Defaults to @samp{#f}.
  10736. @end deftypevr
  10737. @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autosubscribe?
  10738. Should automatically created mailboxes be also automatically
  10739. subscribed?.
  10740. Defaults to @samp{#f}.
  10741. @end deftypevr
  10742. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer imap-max-line-length
  10743. Maximum IMAP command line length. Some clients generate very long
  10744. command lines with huge mailboxes, so you may need to raise this if you
  10745. get "Too long argument" or "IMAP command line too large" errors
  10746. often.
  10747. Defaults to @samp{64000}.
  10748. @end deftypevr
  10749. @deftypevr {@code{dovecot-configuration} parameter} string imap-logout-format
  10750. IMAP logout format string:
  10751. @table @code
  10752. @item %i
  10753. total number of bytes read from client
  10754. @item %o
  10755. total number of bytes sent to client.
  10756. @end table
  10757. Defaults to @samp{"in=%i out=%o"}.
  10758. @end deftypevr
  10759. @deftypevr {@code{dovecot-configuration} parameter} string imap-capability
  10760. Override the IMAP CAPABILITY response. If the value begins with '+',
  10761. add the given capabilities on top of the defaults (e.g. +XFOO XBAR).
  10762. Defaults to @samp{""}.
  10763. @end deftypevr
  10764. @deftypevr {@code{dovecot-configuration} parameter} string imap-idle-notify-interval
  10765. How long to wait between "OK Still here" notifications when client
  10766. is IDLEing.
  10767. Defaults to @samp{"2 mins"}.
  10768. @end deftypevr
  10769. @deftypevr {@code{dovecot-configuration} parameter} string imap-id-send
  10770. ID field names and values to send to clients. Using * as the value
  10771. makes Dovecot use the default value. The following fields have default
  10772. values currently: name, version, os, os-version, support-url,
  10773. support-email.
  10774. Defaults to @samp{""}.
  10775. @end deftypevr
  10776. @deftypevr {@code{dovecot-configuration} parameter} string imap-id-log
  10777. ID fields sent by client to log. * means everything.
  10778. Defaults to @samp{""}.
  10779. @end deftypevr
  10780. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list imap-client-workarounds
  10781. Workarounds for various client bugs:
  10782. @table @code
  10783. @item delay-newmail
  10784. Send EXISTS/RECENT new mail notifications only when replying to NOOP and
  10785. CHECK commands. Some clients ignore them otherwise, for example OSX
  10786. Mail (<v2.1). Outlook Express breaks more badly though, without this it
  10787. may show user "Message no longer in server" errors. Note that OE6
  10788. still breaks even with this workaround if synchronization is set to
  10789. "Headers Only".
  10790. @item tb-extra-mailbox-sep
  10791. Thunderbird gets somehow confused with LAYOUT=fs (mbox and dbox) and
  10792. adds extra @samp{/} suffixes to mailbox names. This option causes Dovecot to
  10793. ignore the extra @samp{/} instead of treating it as invalid mailbox name.
  10794. @item tb-lsub-flags
  10795. Show \Noselect flags for LSUB replies with LAYOUT=fs (e.g. mbox).
  10796. This makes Thunderbird realize they aren't selectable and show them
  10797. greyed out, instead of only later giving "not selectable" popup error.
  10798. @end table
  10799. Defaults to @samp{()}.
  10800. @end deftypevr
  10801. @deftypevr {@code{dovecot-configuration} parameter} string imap-urlauth-host
  10802. Host allowed in URLAUTH URLs sent by client. "*" allows all.
  10803. Defaults to @samp{""}.
  10804. @end deftypevr
  10805. Whew! Lots of configuration options. The nice thing about it though is
  10806. that GuixSD has a complete interface to Dovecot's configuration
  10807. language. This allows not only a nice way to declare configurations,
  10808. but also offers reflective capabilities as well: users can write code to
  10809. inspect and transform configurations from within Scheme.
  10810. However, it could be that you just want to get a @code{dovecot.conf} up
  10811. and running. In that case, you can pass an
  10812. @code{opaque-dovecot-configuration} as the @code{#:config} parameter to
  10813. @code{dovecot-service}. As its name indicates, an opaque configuration
  10814. does not have easy reflective capabilities.
  10815. Available @code{opaque-dovecot-configuration} fields are:
  10816. @deftypevr {@code{opaque-dovecot-configuration} parameter} package dovecot
  10817. The dovecot package.
  10818. @end deftypevr
  10819. @deftypevr {@code{opaque-dovecot-configuration} parameter} string string
  10820. The contents of the @code{dovecot.conf}, as a string.
  10821. @end deftypevr
  10822. For example, if your @code{dovecot.conf} is just the empty string, you
  10823. could instantiate a dovecot service like this:
  10824. @example
  10825. (dovecot-service #:config
  10826. (opaque-dovecot-configuration
  10827. (string "")))
  10828. @end example
  10829. @subsubheading OpenSMTPD Service
  10830. @deffn {Scheme Variable} opensmtpd-service-type
  10831. This is the type of the @uref{https://www.opensmtpd.org, OpenSMTPD}
  10832. service, whose value should be an @code{opensmtpd-configuration} object
  10833. as in this example:
  10834. @example
  10835. (service opensmtpd-service-type
  10836. (opensmtpd-configuration
  10837. (config-file (local-file "./my-smtpd.conf"))))
  10838. @end example
  10839. @end deffn
  10840. @deftp {Data Type} opensmtpd-configuration
  10841. Data type representing the configuration of opensmtpd.
  10842. @table @asis
  10843. @item @code{package} (default: @var{opensmtpd})
  10844. Package object of the OpenSMTPD SMTP server.
  10845. @item @code{config-file} (default: @var{%default-opensmtpd-file})
  10846. File-like object of the OpenSMTPD configuration file to use. By default
  10847. it listens on the loopback network interface, and allows for mail from
  10848. users and daemons on the local machine, as well as permitting email to
  10849. remote servers. Run @command{man smtpd.conf} for more information.
  10850. @end table
  10851. @end deftp
  10852. @subsubheading Exim Service
  10853. @cindex mail transfer agent (MTA)
  10854. @cindex MTA (mail transfer agent)
  10855. @cindex SMTP
  10856. @deffn {Scheme Variable} exim-service-type
  10857. This is the type of the @uref{https://exim.org, Exim} mail transfer
  10858. agent (MTA), whose value should be an @code{exim-configuration} object
  10859. as in this example:
  10860. @example
  10861. (service exim-service-type
  10862. (exim-configuration
  10863. (config-file (local-file "./my-exim.conf"))))
  10864. @end example
  10865. @end deffn
  10866. In order to use an @code{exim-service-type} service you must also have a
  10867. @code{mail-aliases-service-type} service present in your
  10868. @code{operating-system} (even if it has no aliases).
  10869. @deftp {Data Type} exim-configuration
  10870. Data type representing the configuration of exim.
  10871. @table @asis
  10872. @item @code{package} (default: @var{exim})
  10873. Package object of the Exim server.
  10874. @item @code{config-file} (default: @code{#f})
  10875. File-like object of the Exim configuration file to use. If its value is
  10876. @code{#f} then use the default configuration file from the package
  10877. provided in @code{package}. The resulting configuration file is loaded
  10878. after setting the @code{exim_user} and @code{exim_group} configuration
  10879. variables.
  10880. @end table
  10881. @end deftp
  10882. @subsubheading Mail Aliases Service
  10883. @cindex email aliases
  10884. @cindex aliases, for email addresses
  10885. @deffn {Scheme Variable} mail-aliases-service-type
  10886. This is the type of the service which provides @code{/etc/aliases},
  10887. specifying how to deliver mail to users on this system.
  10888. @example
  10889. (service mail-aliases-service-type
  10890. '(("postmaster" "bob")
  10891. ("bob" "bob@@example.com" "bob@@example2.com")))
  10892. @end example
  10893. @end deffn
  10894. The configuration for a @code{mail-aliases-service-type} service is an
  10895. association list denoting how to deliver mail that comes to this
  10896. system. Each entry is of the form @code{(alias addresses ...)}, with
  10897. @code{alias} specifying the local alias and @code{addresses} specifying
  10898. where to deliver this user's mail.
  10899. The aliases aren't required to exist as users on the local system. In
  10900. the above example, there doesn't need to be a @code{postmaster} entry in
  10901. the @code{operating-system}'s @code{user-accounts} in order to deliver
  10902. the @code{postmaster} mail to @code{bob} (which subsequently would
  10903. deliver mail to @code{bob@@example.com} and @code{bob@@example2.com}).
  10904. @node Messaging Services
  10905. @subsubsection Messaging Services
  10906. @cindex messaging
  10907. @cindex jabber
  10908. @cindex XMPP
  10909. The @code{(gnu services messaging)} module provides Guix service
  10910. definitions for messaging services: currently only Prosody is supported.
  10911. @subsubheading Prosody Service
  10912. @deffn {Scheme Variable} prosody-service-type
  10913. This is the type for the @uref{http://prosody.im, Prosody XMPP
  10914. communication server}. Its value must be a @code{prosody-configuration}
  10915. record as in this example:
  10916. @example
  10917. (service prosody-service-type
  10918. (prosody-configuration
  10919. (modules-enabled (cons "groups" %default-modules-enabled))
  10920. (int-components
  10921. (list
  10922. (int-component-configuration
  10923. (hostname "conference.example.net")
  10924. (plugin "muc")
  10925. (mod-muc (mod-muc-configuration)))))
  10926. (virtualhosts
  10927. (list
  10928. (virtualhost-configuration
  10929. (domain "example.net"))))))
  10930. @end example
  10931. See below for details about @code{prosody-configuration}.
  10932. @end deffn
  10933. By default, Prosody does not need much configuration. Only one
  10934. @code{virtualhosts} field is needed: it specifies the domain you wish
  10935. Prosody to serve.
  10936. Prosodyctl will help you generate X.509 certificates and keys:
  10937. @example
  10938. prosodyctl cert request example.net
  10939. @end example
  10940. The available configuration parameters follow. Each parameter
  10941. definition is preceded by its type; for example, @samp{string-list foo}
  10942. indicates that the @code{foo} parameter should be specified as a list of
  10943. strings. Types starting with @code{maybe-} denote parameters that won't
  10944. show up in @code{prosody.cfg.lua} when their value is @code{'disabled}.
  10945. There is also a way to specify the configuration as a string, if you
  10946. have an old @code{prosody.cfg.lua} file that you want to port over from
  10947. some other system; see the end for more details.
  10948. @c The following documentation was initially generated by
  10949. @c (generate-documentation) in (gnu services messaging). Manually maintained
  10950. @c documentation is better, so we shouldn't hesitate to edit below as
  10951. @c needed. However if the change you want to make to this documentation
  10952. @c can be done in an automated way, it's probably easier to change
  10953. @c (generate-documentation) than to make it below and have to deal with
  10954. @c the churn as Prosody updates.
  10955. Available @code{prosody-configuration} fields are:
  10956. @deftypevr {@code{prosody-configuration} parameter} package prosody
  10957. The Prosody package.
  10958. @end deftypevr
  10959. @deftypevr {@code{prosody-configuration} parameter} file-name data-path
  10960. Location of the Prosody data storage directory. See
  10961. @url{http://prosody.im/doc/configure}.
  10962. Defaults to @samp{"/var/lib/prosody"}.
  10963. @end deftypevr
  10964. @deftypevr {@code{prosody-configuration} parameter} file-name-list plugin-paths
  10965. Additional plugin directories. They are searched in all the specified
  10966. paths in order. See @url{http://prosody.im/doc/plugins_directory}.
  10967. Defaults to @samp{()}.
  10968. @end deftypevr
  10969. @deftypevr {@code{prosody-configuration} parameter} string-list admins
  10970. This is a list of accounts that are admins for the server. Note that you
  10971. must create the accounts separately. See @url{http://prosody.im/doc/admins} and
  10972. @url{http://prosody.im/doc/creating_accounts}.
  10973. Example: @code{(admins '("user1@@example.com" "user2@@example.net"))}
  10974. Defaults to @samp{()}.
  10975. @end deftypevr
  10976. @deftypevr {@code{prosody-configuration} parameter} boolean use-libevent?
  10977. Enable use of libevent for better performance under high load. See
  10978. @url{http://prosody.im/doc/libevent}.
  10979. Defaults to @samp{#f}.
  10980. @end deftypevr
  10981. @deftypevr {@code{prosody-configuration} parameter} module-list modules-enabled
  10982. This is the list of modules Prosody will load on startup. It looks for
  10983. @code{mod_modulename.lua} in the plugins folder, so make sure that exists too.
  10984. Documentation on modules can be found at: @url{http://prosody.im/doc/modules}.
  10985. Defaults to @samp{%default-modules-enabled}.
  10986. @end deftypevr
  10987. @deftypevr {@code{prosody-configuration} parameter} string-list modules-disabled
  10988. @samp{"offline"}, @samp{"c2s"} and @samp{"s2s"} are auto-loaded, but
  10989. should you want to disable them then add them to this list.
  10990. Defaults to @samp{()}.
  10991. @end deftypevr
  10992. @deftypevr {@code{prosody-configuration} parameter} file-name groups-file
  10993. Path to a text file where the shared groups are defined. If this path is
  10994. empty then @samp{mod_groups} does nothing. See
  10995. @url{http://prosody.im/doc/modules/mod_groups}.
  10996. Defaults to @samp{"/var/lib/prosody/sharedgroups.txt"}.
  10997. @end deftypevr
  10998. @deftypevr {@code{prosody-configuration} parameter} boolean allow-registration?
  10999. Disable account creation by default, for security. See
  11000. @url{http://prosody.im/doc/creating_accounts}.
  11001. Defaults to @samp{#f}.
  11002. @end deftypevr
  11003. @deftypevr {@code{prosody-configuration} parameter} maybe-ssl-configuration ssl
  11004. These are the SSL/TLS-related settings. Most of them are disabled so to
  11005. use Prosody's defaults. If you do not completely understand these options, do
  11006. not add them to your config, it is easy to lower the security of your server
  11007. using them. See @url{http://prosody.im/doc/advanced_ssl_config}.
  11008. Available @code{ssl-configuration} fields are:
  11009. @deftypevr {@code{ssl-configuration} parameter} maybe-string protocol
  11010. This determines what handshake to use.
  11011. @end deftypevr
  11012. @deftypevr {@code{ssl-configuration} parameter} file-name key
  11013. Path to your private key file, relative to @code{/etc/prosody}.
  11014. Defaults to @samp{"/etc/prosody/certs/key.pem"}.
  11015. @end deftypevr
  11016. @deftypevr {@code{ssl-configuration} parameter} file-name certificate
  11017. Path to your certificate file, relative to @code{/etc/prosody}.
  11018. Defaults to @samp{"/etc/prosody/certs/cert.pem"}.
  11019. @end deftypevr
  11020. @deftypevr {@code{ssl-configuration} parameter} file-name capath
  11021. Path to directory containing root certificates that you wish Prosody to
  11022. trust when verifying the certificates of remote servers.
  11023. Defaults to @samp{"/etc/ssl/certs"}.
  11024. @end deftypevr
  11025. @deftypevr {@code{ssl-configuration} parameter} maybe-file-name cafile
  11026. Path to a file containing root certificates that you wish Prosody to trust.
  11027. Similar to @code{capath} but with all certificates concatenated together.
  11028. @end deftypevr
  11029. @deftypevr {@code{ssl-configuration} parameter} maybe-string-list verify
  11030. A list of verification options (these mostly map to OpenSSL's
  11031. @code{set_verify()} flags).
  11032. @end deftypevr
  11033. @deftypevr {@code{ssl-configuration} parameter} maybe-string-list options
  11034. A list of general options relating to SSL/TLS. These map to OpenSSL's
  11035. @code{set_options()}. For a full list of options available in LuaSec, see the
  11036. LuaSec source.
  11037. @end deftypevr
  11038. @deftypevr {@code{ssl-configuration} parameter} maybe-non-negative-integer depth
  11039. How long a chain of certificate authorities to check when looking for a
  11040. trusted root certificate.
  11041. @end deftypevr
  11042. @deftypevr {@code{ssl-configuration} parameter} maybe-string ciphers
  11043. An OpenSSL cipher string. This selects what ciphers Prosody will offer to
  11044. clients, and in what order.
  11045. @end deftypevr
  11046. @deftypevr {@code{ssl-configuration} parameter} maybe-file-name dhparam
  11047. A path to a file containing parameters for Diffie-Hellman key exchange. You
  11048. can create such a file with:
  11049. @code{openssl dhparam -out /etc/prosody/certs/dh-2048.pem 2048}
  11050. @end deftypevr
  11051. @deftypevr {@code{ssl-configuration} parameter} maybe-string curve
  11052. Curve for Elliptic curve Diffie-Hellman. Prosody's default is
  11053. @samp{"secp384r1"}.
  11054. @end deftypevr
  11055. @deftypevr {@code{ssl-configuration} parameter} maybe-string-list verifyext
  11056. A list of "extra" verification options.
  11057. @end deftypevr
  11058. @deftypevr {@code{ssl-configuration} parameter} maybe-string password
  11059. Password for encrypted private keys.
  11060. @end deftypevr
  11061. @end deftypevr
  11062. @deftypevr {@code{prosody-configuration} parameter} boolean c2s-require-encryption?
  11063. Whether to force all client-to-server connections to be encrypted or not.
  11064. See @url{http://prosody.im/doc/modules/mod_tls}.
  11065. Defaults to @samp{#f}.
  11066. @end deftypevr
  11067. @deftypevr {@code{prosody-configuration} parameter} boolean s2s-require-encryption?
  11068. Whether to force all server-to-server connections to be encrypted or not.
  11069. See @url{http://prosody.im/doc/modules/mod_tls}.
  11070. Defaults to @samp{#f}.
  11071. @end deftypevr
  11072. @deftypevr {@code{prosody-configuration} parameter} boolean s2s-secure-auth?
  11073. Whether to require encryption and certificate authentication. This
  11074. provides ideal security, but requires servers you communicate with to support
  11075. encryption AND present valid, trusted certificates. See
  11076. @url{http://prosody.im/doc/s2s#security}.
  11077. Defaults to @samp{#f}.
  11078. @end deftypevr
  11079. @deftypevr {@code{prosody-configuration} parameter} string-list s2s-insecure-domains
  11080. Many servers don't support encryption or have invalid or self-signed
  11081. certificates. You can list domains here that will not be required to
  11082. authenticate using certificates. They will be authenticated using DNS. See
  11083. @url{http://prosody.im/doc/s2s#security}.
  11084. Defaults to @samp{()}.
  11085. @end deftypevr
  11086. @deftypevr {@code{prosody-configuration} parameter} string-list s2s-secure-domains
  11087. Even if you leave @code{s2s-secure-auth?} disabled, you can still require
  11088. valid certificates for some domains by specifying a list here. See
  11089. @url{http://prosody.im/doc/s2s#security}.
  11090. Defaults to @samp{()}.
  11091. @end deftypevr
  11092. @deftypevr {@code{prosody-configuration} parameter} string authentication
  11093. Select the authentication backend to use. The default provider stores
  11094. passwords in plaintext and uses Prosody's configured data storage to store the
  11095. authentication data. If you do not trust your server please see
  11096. @url{http://prosody.im/doc/modules/mod_auth_internal_hashed} for information
  11097. about using the hashed backend. See also
  11098. @url{http://prosody.im/doc/authentication}
  11099. Defaults to @samp{"internal_plain"}.
  11100. @end deftypevr
  11101. @deftypevr {@code{prosody-configuration} parameter} maybe-string log
  11102. Set logging options. Advanced logging configuration is not yet supported
  11103. by the GuixSD Prosody Service. See @url{http://prosody.im/doc/logging}.
  11104. Defaults to @samp{"*syslog"}.
  11105. @end deftypevr
  11106. @deftypevr {@code{prosody-configuration} parameter} file-name pidfile
  11107. File to write pid in. See @url{http://prosody.im/doc/modules/mod_posix}.
  11108. Defaults to @samp{"/var/run/prosody/prosody.pid"}.
  11109. @end deftypevr
  11110. @deftypevr {@code{prosody-configuration} parameter} virtualhost-configuration-list virtualhosts
  11111. A host in Prosody is a domain on which user accounts can be created. For
  11112. example if you want your users to have addresses like
  11113. @samp{"john.smith@@example.com"} then you need to add a host
  11114. @samp{"example.com"}. All options in this list will apply only to this host.
  11115. Note: the name "virtual" host is used in configuration to avoid confusion with
  11116. the actual physical host that Prosody is installed on. A single Prosody
  11117. instance can serve many domains, each one defined as a VirtualHost entry in
  11118. Prosody's configuration. Conversely a server that hosts a single domain would
  11119. have just one VirtualHost entry.
  11120. See @url{http://prosody.im/doc/configure#virtual_host_settings}.
  11121. Available @code{virtualhost-configuration} fields are:
  11122. 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{s2s-require-encryption?}, @code{s2s-secure-auth?}, @code{s2s-insecure-domains}, @code{s2s-secure-domains}, @code{authentication}, @code{log}, plus:
  11123. @deftypevr {@code{virtualhost-configuration} parameter} string domain
  11124. Domain you wish Prosody to serve.
  11125. @end deftypevr
  11126. @end deftypevr
  11127. @deftypevr {@code{prosody-configuration} parameter} int-component-configuration-list int-components
  11128. Components are extra services on a server which are available to clients,
  11129. usually on a subdomain of the main server (such as
  11130. @samp{"mycomponent.example.com"}). Example components might be chatroom
  11131. servers, user directories, or gateways to other protocols.
  11132. Internal components are implemented with Prosody-specific plugins. To add an
  11133. internal component, you simply fill the hostname field, and the plugin you wish
  11134. to use for the component.
  11135. See @url{http://prosody.im/doc/components}.
  11136. Defaults to @samp{()}.
  11137. Available @code{int-component-configuration} fields are:
  11138. 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{s2s-require-encryption?}, @code{s2s-secure-auth?}, @code{s2s-insecure-domains}, @code{s2s-secure-domains}, @code{authentication}, @code{log}, plus:
  11139. @deftypevr {@code{int-component-configuration} parameter} string hostname
  11140. Hostname of the component.
  11141. @end deftypevr
  11142. @deftypevr {@code{int-component-configuration} parameter} string plugin
  11143. Plugin you wish to use for the component.
  11144. @end deftypevr
  11145. @deftypevr {@code{int-component-configuration} parameter} maybe-mod-muc-configuration mod-muc
  11146. Multi-user chat (MUC) is Prosody's module for allowing you to create
  11147. hosted chatrooms/conferences for XMPP users.
  11148. General information on setting up and using multi-user chatrooms can be found
  11149. in the "Chatrooms" documentation (@url{http://prosody.im/doc/chatrooms}),
  11150. which you should read if you are new to XMPP chatrooms.
  11151. See also @url{http://prosody.im/doc/modules/mod_muc}.
  11152. Available @code{mod-muc-configuration} fields are:
  11153. @deftypevr {@code{mod-muc-configuration} parameter} string name
  11154. The name to return in service discovery responses.
  11155. Defaults to @samp{"Prosody Chatrooms"}.
  11156. @end deftypevr
  11157. @deftypevr {@code{mod-muc-configuration} parameter} string-or-boolean restrict-room-creation
  11158. If @samp{#t}, this will only allow admins to create new chatrooms.
  11159. Otherwise anyone can create a room. The value @samp{"local"} restricts room
  11160. creation to users on the service's parent domain. E.g. @samp{user@@example.com}
  11161. can create rooms on @samp{rooms.example.com}. The value @samp{"admin"}
  11162. restricts to service administrators only.
  11163. Defaults to @samp{#f}.
  11164. @end deftypevr
  11165. @deftypevr {@code{mod-muc-configuration} parameter} non-negative-integer max-history-messages
  11166. Maximum number of history messages that will be sent to the member that has
  11167. just joined the room.
  11168. Defaults to @samp{20}.
  11169. @end deftypevr
  11170. @end deftypevr
  11171. @end deftypevr
  11172. @deftypevr {@code{prosody-configuration} parameter} ext-component-configuration-list ext-components
  11173. External components use XEP-0114, which most standalone components
  11174. support. To add an external component, you simply fill the hostname field. See
  11175. @url{http://prosody.im/doc/components}.
  11176. Defaults to @samp{()}.
  11177. Available @code{ext-component-configuration} fields are:
  11178. 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{s2s-require-encryption?}, @code{s2s-secure-auth?}, @code{s2s-insecure-domains}, @code{s2s-secure-domains}, @code{authentication}, @code{log}, plus:
  11179. @deftypevr {@code{ext-component-configuration} parameter} string component-secret
  11180. Password which the component will use to log in.
  11181. @end deftypevr
  11182. @deftypevr {@code{ext-component-configuration} parameter} string hostname
  11183. Hostname of the component.
  11184. @end deftypevr
  11185. @end deftypevr
  11186. @deftypevr {@code{prosody-configuration} parameter} non-negative-integer-list component-ports
  11187. Port(s) Prosody listens on for component connections.
  11188. @end deftypevr
  11189. @deftypevr {@code{prosody-configuration} parameter} string component-interface
  11190. Interface Prosody listens on for component connections.
  11191. Defaults to @samp{"127.0.0.1"}.
  11192. @end deftypevr
  11193. It could be that you just want to get a @code{prosody.cfg.lua}
  11194. up and running. In that case, you can pass an
  11195. @code{opaque-prosody-configuration} record as the value of
  11196. @code{prosody-service-type}. As its name indicates, an opaque configuration
  11197. does not have easy reflective capabilities.
  11198. Available @code{opaque-prosody-configuration} fields are:
  11199. @deftypevr {@code{opaque-prosody-configuration} parameter} package prosody
  11200. The prosody package.
  11201. @end deftypevr
  11202. @deftypevr {@code{opaque-prosody-configuration} parameter} string prosody.cfg.lua
  11203. The contents of the @code{prosody.cfg.lua} to use.
  11204. @end deftypevr
  11205. For example, if your @code{prosody.cfg.lua} is just the empty
  11206. string, you could instantiate a prosody service like this:
  11207. @example
  11208. (service prosody-service-type
  11209. (opaque-prosody-configuration
  11210. (prosody.cfg.lua "")))
  11211. @end example
  11212. @node Monitoring Services
  11213. @subsubsection Monitoring Services
  11214. @subsubheading Tailon Service
  11215. @uref{https://tailon.readthedocs.io/, Tailon} is a web application for
  11216. viewing and searching log files.
  11217. The following example will configure the service with default values.
  11218. By default, Tailon can be accessed on port 8080 (@code{http://localhost:8080}).
  11219. @example
  11220. (service tailon-service-type)
  11221. @end example
  11222. The following example customises more of the Tailon configuration,
  11223. adding @command{sed} to the list of allowed commands.
  11224. @example
  11225. (service tailon-service-type
  11226. (tailon-configuration
  11227. (config-file
  11228. (tailon-configuration-file
  11229. (allowed-commands '("tail" "grep" "awk" "sed"))))))
  11230. @end example
  11231. @deftp {Data Type} tailon-configuration
  11232. Data type representing the configuration of Tailon.
  11233. This type has the following parameters:
  11234. @table @asis
  11235. @item @code{config-file} (default: @code{(tailon-configuration-file)})
  11236. The configuration file to use for Tailon. This can be set to a
  11237. @dfn{tailon-configuration-file} record value, or any gexp
  11238. (@pxref{G-Expressions}).
  11239. For example, to instead use a local file, the @code{local-file} function
  11240. can be used:
  11241. @example
  11242. (service tailon-service-type
  11243. (tailon-configuration
  11244. (config-file (local-file "./my-tailon.conf"))))
  11245. @end example
  11246. @item @code{package} (default: @code{tailon})
  11247. The tailon package to use.
  11248. @end table
  11249. @end deftp
  11250. @deftp {Data Type} tailon-configuration-file
  11251. Data type representing the configuration options for Tailon.
  11252. This type has the following parameters:
  11253. @table @asis
  11254. @item @code{files} (default: @code{(list "/var/log")})
  11255. List of files to display. The list can include strings for a single file
  11256. or directory, or a list, where the first item is the name of a
  11257. subsection, and the remaining items are the files or directories in that
  11258. subsection.
  11259. @item @code{bind} (default: @code{"localhost:8080"})
  11260. Address and port to which Tailon should bind on.
  11261. @item @code{relative-root} (default: @code{#f})
  11262. URL path to use for Tailon, set to @code{#f} to not use a path.
  11263. @item @code{allow-transfers?} (default: @code{#t})
  11264. Allow downloading the log files in the web interface.
  11265. @item @code{follow-names?} (default: @code{#t})
  11266. Allow tailing of not-yet existent files.
  11267. @item @code{tail-lines} (default: @code{200})
  11268. Number of lines to read initially from each file.
  11269. @item @code{allowed-commands} (default: @code{(list "tail" "grep" "awk")})
  11270. Commands to allow running. By default, @code{sed} is disabled.
  11271. @item @code{debug?} (default: @code{#f})
  11272. Set @code{debug?} to @code{#t} to show debug messages.
  11273. @item @code{wrap-lines} (default: @code{#t})
  11274. Initial line wrapping state in the web interface. Set to @code{#t} to
  11275. initially wrap lines (the default), or to @code{#f} to initially not
  11276. wrap lines.
  11277. @item @code{http-auth} (default: @code{#f})
  11278. HTTP authentication type to use. Set to @code{#f} to disable
  11279. authentication (the default). Supported values are @code{"digest"} or
  11280. @code{"basic"}.
  11281. @item @code{users} (default: @code{#f})
  11282. If HTTP authentication is enabled (see @code{http-auth}), access will be
  11283. restricted to the credentials provided here. To configure users, use a
  11284. list of pairs, where the first element of the pair is the username, and
  11285. the 2nd element of the pair is the password.
  11286. @example
  11287. (tailon-configuration-file
  11288. (http-auth "basic")
  11289. (users '(("user1" . "password1")
  11290. ("user2" . "password2"))))
  11291. @end example
  11292. @end table
  11293. @end deftp
  11294. @node Kerberos Services
  11295. @subsubsection Kerberos Services
  11296. @cindex Kerberos
  11297. The @code{(gnu services kerberos)} module provides services relating to
  11298. the authentication protocol @dfn{Kerberos}.
  11299. @subsubheading Krb5 Service
  11300. Programs using a Kerberos client library normally
  11301. expect a configuration file in @file{/etc/krb5.conf}.
  11302. This service generates such a file from a definition provided in the
  11303. operating system declaration.
  11304. It does not cause any daemon to be started.
  11305. No ``keytab'' files are provided by this service---you must explicitly create them.
  11306. This service is known to work with the MIT client library, @code{mit-krb5}.
  11307. Other implementations have not been tested.
  11308. @defvr {Scheme Variable} krb5-service-type
  11309. A service type for Kerberos 5 clients.
  11310. @end defvr
  11311. @noindent
  11312. Here is an example of its use:
  11313. @lisp
  11314. (service krb5-service-type
  11315. (krb5-configuration
  11316. (default-realm "EXAMPLE.COM")
  11317. (allow-weak-crypto? #t)
  11318. (realms (list
  11319. (krb5-realm
  11320. (name "EXAMPLE.COM")
  11321. (admin-server "groucho.example.com")
  11322. (kdc "karl.example.com"))
  11323. (krb5-realm
  11324. (name "ARGRX.EDU")
  11325. (admin-server "kerb-admin.argrx.edu")
  11326. (kdc "keys.argrx.edu"))))))
  11327. @end lisp
  11328. @noindent
  11329. This example provides a Kerberos@tie{}5 client configuration which:
  11330. @itemize
  11331. @item Recognizes two realms, @i{viz:} ``EXAMPLE.COM'' and ``ARGRX.EDU'', both
  11332. of which have distinct administration servers and key distribution centers;
  11333. @item Will default to the realm ``EXAMPLE.COM'' if the realm is not explicitly
  11334. specified by clients;
  11335. @item Accepts services which only support encryption types known to be weak.
  11336. @end itemize
  11337. The @code{krb5-realm} and @code{krb5-configuration} types have many fields.
  11338. Only the most commonly used ones are described here.
  11339. For a full list, and more detailed explanation of each, see the MIT
  11340. @uref{http://web.mit.edu/kerberos/krb5-devel/doc/admin/conf_files/krb5_conf.html,,krb5.conf}
  11341. documentation.
  11342. @deftp {Data Type} krb5-realm
  11343. @cindex realm, kerberos
  11344. @table @asis
  11345. @item @code{name}
  11346. This field is a string identifying the name of the realm.
  11347. A common convention is to use the fully qualified DNS name of your organization,
  11348. converted to upper case.
  11349. @item @code{admin-server}
  11350. This field is a string identifying the host where the administration server is
  11351. running.
  11352. @item @code{kdc}
  11353. This field is a string identifying the key distribution center
  11354. for the realm.
  11355. @end table
  11356. @end deftp
  11357. @deftp {Data Type} krb5-configuration
  11358. @table @asis
  11359. @item @code{allow-weak-crypto?} (default: @code{#f})
  11360. If this flag is @code{#t} then services which only offer encryption algorithms
  11361. known to be weak will be accepted.
  11362. @item @code{default-realm} (default: @code{#f})
  11363. This field should be a string identifying the default Kerberos
  11364. realm for the client.
  11365. You should set this field to the name of your Kerberos realm.
  11366. If this value is @code{#f}
  11367. then a realm must be specified with every Kerberos principal when invoking programs
  11368. such as @command{kinit}.
  11369. @item @code{realms}
  11370. This should be a non-empty list of @code{krb5-realm} objects, which clients may
  11371. access.
  11372. Normally, one of them will have a @code{name} field matching the @code{default-realm}
  11373. field.
  11374. @end table
  11375. @end deftp
  11376. @subsubheading PAM krb5 Service
  11377. @cindex pam-krb5
  11378. The @code{pam-krb5} service allows for login authentication and password
  11379. management via Kerberos.
  11380. You will need this service if you want PAM enabled applications to authenticate
  11381. users using Kerberos.
  11382. @defvr {Scheme Variable} pam-krb5-service-type
  11383. A service type for the Kerberos 5 PAM module.
  11384. @end defvr
  11385. @deftp {Data Type} pam-krb5-configuration
  11386. Data type representing the configuration of the Kerberos 5 PAM module
  11387. This type has the following parameters:
  11388. @table @asis
  11389. @item @code{pam-krb5} (default: @code{pam-krb5})
  11390. The pam-krb5 package to use.
  11391. @item @code{minimum-uid} (default: @code{1000})
  11392. The smallest user ID for which Kerberos authentications should be attempted.
  11393. Local accounts with lower values will silently fail to authenticate.
  11394. @end table
  11395. @end deftp
  11396. @node Web Services
  11397. @subsubsection Web Services
  11398. @cindex web
  11399. @cindex www
  11400. @cindex HTTP
  11401. The @code{(gnu services web)} module provides the nginx web server and
  11402. also a fastcgi wrapper daemon.
  11403. @deffn {Scheme Variable} nginx-service-type
  11404. Service type for the @uref{https://nginx.org/,NGinx} web server. The
  11405. value for this service type is a @code{<nginx-configuration>} record.
  11406. A simple example configuration is given below.
  11407. @example
  11408. (service nginx-service-type
  11409. (nginx-configuration
  11410. (server-blocks
  11411. (list (nginx-server-configuration
  11412. (server-name '("www.example.com"))
  11413. (root "/srv/http/www.example.com")
  11414. (https-port #f)
  11415. (ssl-certificate #f)
  11416. (ssl-certificate-key #f))))))
  11417. @end example
  11418. In addition to adding server blocks to the service configuration
  11419. directly, this service can be extended by other services to add server
  11420. blocks, as in this example:
  11421. @example
  11422. (simple-service 'my-extra-server nginx-service-type
  11423. (list (nginx-server-configuration
  11424. (https-port #f)
  11425. (ssl-certificate #f)
  11426. (ssl-certificate-key #f)
  11427. (root "/srv/http/extra-website")
  11428. (try-files (list "$uri" "$uri/index.html")))))
  11429. @end example
  11430. @end deffn
  11431. At startup, @command{nginx} has not yet read its configuration file, so
  11432. it uses a default file to log error messages. If it fails to load its
  11433. configuration file, that is where error messages are logged. After the
  11434. configuration file is loaded, the default error log file changes as per
  11435. configuration. In our case, startup error messages can be found in
  11436. @file{/var/run/nginx/logs/error.log}, and after configuration in
  11437. @file{/var/log/nginx/error.log}. The second location can be changed
  11438. with the @var{log-directory} configuration option.
  11439. @deffn {Data Type} nginx-configuration
  11440. This data type represents the configuration for NGinx. Some
  11441. configuration can be done through this and the other provided record
  11442. types, or alternatively, a config file can be provided.
  11443. @table @asis
  11444. @item @code{nginx} (default: @code{nginx})
  11445. The nginx package to use.
  11446. @item @code{log-directory} (default: @code{"/var/log/nginx"})
  11447. The directory to which NGinx will write log files.
  11448. @item @code{run-directory} (default: @code{"/var/run/nginx"})
  11449. The directory in which NGinx will create a pid file, and write temporary
  11450. files.
  11451. @item @code{server-blocks} (default: @code{'()})
  11452. A list of @dfn{server blocks} to create in the generated configuration
  11453. file, the elements should be of type
  11454. @code{<nginx-server-configuration>}.
  11455. The following example would setup NGinx to serve @code{www.example.com}
  11456. from the @code{/srv/http/www.example.com} directory, without using
  11457. HTTPS.
  11458. @example
  11459. (service nginx-service-type
  11460. (nginx-configuration
  11461. (server-blocks
  11462. (list (nginx-server-configuration
  11463. (server-name '("www.example.com"))
  11464. (root "/srv/http/www.example.com")
  11465. (https-port #f)
  11466. (ssl-certificate #f)
  11467. (ssl-certificate-key #f))))))
  11468. @end example
  11469. @item @code{upstream-blocks} (default: @code{'()})
  11470. A list of @dfn{upstream blocks} to create in the generated configuration
  11471. file, the elements should be of type
  11472. @code{<nginx-upstream-configuration>}.
  11473. Configuring upstreams through the @code{upstream-blocks} can be useful
  11474. when combined with @code{locations} in the
  11475. @code{<nginx-server-configuration>} records. The following example
  11476. creates a server configuration with one location configuration, that
  11477. will proxy requests to a upstream configuration, which will handle
  11478. requests with two servers.
  11479. @example
  11480. (service
  11481. nginx-service-type
  11482. (nginx-configuration
  11483. (server-blocks
  11484. (list (nginx-server-configuration
  11485. (server-name '("www.example.com"))
  11486. (root "/srv/http/www.example.com")
  11487. (https-port #f)
  11488. (ssl-certificate #f)
  11489. (ssl-certificate-key #f)
  11490. (locations
  11491. (list
  11492. (nginx-location-configuration
  11493. (uri "/path1")
  11494. (body '("proxy_pass http://server-proxy;"))))))))
  11495. (upstream-blocks
  11496. (list (nginx-upstream-configuration
  11497. (name "server-proxy")
  11498. (servers (list "server1.example.com"
  11499. "server2.example.com")))))))
  11500. @end example
  11501. @item @code{file} (default: @code{#f})
  11502. If a configuration @var{file} is provided, this will be used, rather than
  11503. generating a configuration file from the provided @code{log-directory},
  11504. @code{run-directory}, @code{server-blocks} and @code{upstream-blocks}. For
  11505. proper operation, these arguments should match what is in @var{file} to ensure
  11506. that the directories are created when the service is activated.
  11507. This can be useful if you have an existing configuration file, or it's
  11508. not possible to do what is required through the other parts of the
  11509. nginx-configuration record.
  11510. @end table
  11511. @end deffn
  11512. @deftp {Data Type} nginx-server-configuration
  11513. Data type representing the configuration of an nginx server block.
  11514. This type has the following parameters:
  11515. @table @asis
  11516. @item @code{http-port} (default: @code{80})
  11517. Nginx will listen for HTTP connection on this port. Set it at @code{#f} if
  11518. nginx should not listen for HTTP (non secure) connection for this
  11519. @dfn{server block}.
  11520. @item @code{https-port} (default: @code{443})
  11521. Nginx will listen for HTTPS connection on this port. Set it at @code{#f} if
  11522. nginx should not listen for HTTPS (secure) connection for this @dfn{server block}.
  11523. Note that nginx can listen for HTTP and HTTPS connections in the same
  11524. @dfn{server block}.
  11525. @item @code{server-name} (default: @code{(list 'default)})
  11526. A list of server names this server represents. @code{'default} represents the
  11527. default server for connections matching no other server.
  11528. @item @code{root} (default: @code{"/srv/http"})
  11529. Root of the website nginx will serve.
  11530. @item @code{locations} (default: @code{'()})
  11531. A list of @dfn{nginx-location-configuration} or
  11532. @dfn{nginx-named-location-configuration} records to use within this
  11533. server block.
  11534. @item @code{index} (default: @code{(list "index.html")})
  11535. Index files to look for when clients ask for a directory. If it cannot be found,
  11536. Nginx will send the list of files in the directory.
  11537. @item @code{try-files} (default: @code{'()})
  11538. A list of files whose existence is checked in the specified order.
  11539. @code{nginx} will use the first file it finds to process the request.
  11540. @item @code{ssl-certificate} (default: @code{"/etc/nginx/cert.pem"})
  11541. Where to find the certificate for secure connections. Set it to @code{#f} if
  11542. you don't have a certificate or you don't want to use HTTPS.
  11543. @item @code{ssl-certificate-key} (default: @code{"/etc/nginx/key.pem"})
  11544. Where to find the private key for secure connections. Set it to @code{#f} if
  11545. you don't have a key or you don't want to use HTTPS.
  11546. @item @code{server-tokens?} (default: @code{#f})
  11547. Whether the server should add its configuration to response.
  11548. @end table
  11549. @end deftp
  11550. @deftp {Data Type} nginx-upstream-configuration
  11551. Data type representing the configuration of an nginx @code{upstream}
  11552. block. This type has the following parameters:
  11553. @table @asis
  11554. @item @code{name}
  11555. Name for this group of servers.
  11556. @item @code{servers}
  11557. Specify the addresses of the servers in the group. The address can be
  11558. specified as a IP address (e.g. @samp{127.0.0.1}), domain name
  11559. (e.g. @samp{backend1.example.com}) or a path to a UNIX socket using the
  11560. prefix @samp{unix:}. For addresses using an IP address or domain name,
  11561. the default port is 80, and a different port can be specified
  11562. explicitly.
  11563. @end table
  11564. @end deftp
  11565. @deftp {Data Type} nginx-location-configuration
  11566. Data type representing the configuration of an nginx @code{location}
  11567. block. This type has the following parameters:
  11568. @table @asis
  11569. @item @code{uri}
  11570. URI which this location block matches.
  11571. @anchor{nginx-location-configuration body}
  11572. @item @code{body}
  11573. Body of the location block, specified as a string. This can contain many
  11574. configuration directives. For example, to pass requests to a upstream
  11575. server group defined using an @code{nginx-upstream-configuration} block,
  11576. the following directive would be specified in the body @samp{proxy_pass
  11577. http://upstream-name;}.
  11578. @end table
  11579. @end deftp
  11580. @deftp {Data Type} nginx-named-location-configuration
  11581. Data type representing the configuration of an nginx named location
  11582. block. Named location blocks are used for request redirection, and not
  11583. used for regular request processing. This type has the following
  11584. parameters:
  11585. @table @asis
  11586. @item @code{name}
  11587. Name to identify this location block.
  11588. @item @code{body}
  11589. @xref{nginx-location-configuration body}, as the body for named location
  11590. blocks can be used in a similar way to the
  11591. @code{nginx-location-configuration body}. One restriction is that the
  11592. body of a named location block cannot contain location blocks.
  11593. @end table
  11594. @end deftp
  11595. @cindex fastcgi
  11596. @cindex fcgiwrap
  11597. FastCGI is an interface between the front-end and the back-end of a web
  11598. service. It is a somewhat legacy facility; new web services should
  11599. generally just talk HTTP between the front-end and the back-end.
  11600. However there are a number of back-end services such as PHP or the
  11601. optimized HTTP Git repository access that use FastCGI, so we have
  11602. support for it in Guix.
  11603. To use FastCGI, you configure the front-end web server (e.g., nginx) to
  11604. dispatch some subset of its requests to the fastcgi backend, which
  11605. listens on a local TCP or UNIX socket. There is an intermediary
  11606. @code{fcgiwrap} program that sits between the actual backend process and
  11607. the web server. The front-end indicates which backend program to run,
  11608. passing that information to the @code{fcgiwrap} process.
  11609. @defvr {Scheme Variable} fcgiwrap-service-type
  11610. A service type for the @code{fcgiwrap} FastCGI proxy.
  11611. @end defvr
  11612. @deftp {Data Type} fcgiwrap-configuration
  11613. Data type representing the configuration of the @code{fcgiwrap} serice.
  11614. This type has the following parameters:
  11615. @table @asis
  11616. @item @code{package} (default: @code{fcgiwrap})
  11617. The fcgiwrap package to use.
  11618. @item @code{socket} (default: @code{tcp:127.0.0.1:9000})
  11619. The socket on which the @code{fcgiwrap} process should listen, as a
  11620. string. Valid @var{socket} values include
  11621. @code{unix:@var{/path/to/unix/socket}},
  11622. @code{tcp:@var{dot.ted.qu.ad}:@var{port}} and
  11623. @code{tcp6:[@var{ipv6_addr}]:port}.
  11624. @item @code{user} (default: @code{fcgiwrap})
  11625. @itemx @code{group} (default: @code{fcgiwrap})
  11626. The user and group names, as strings, under which to run the
  11627. @code{fcgiwrap} process. The @code{fastcgi} service will ensure that if
  11628. the user asks for the specific user or group names @code{fcgiwrap} that
  11629. the corresponding user and/or group is present on the system.
  11630. It is possible to configure a FastCGI-backed web service to pass HTTP
  11631. authentication information from the front-end to the back-end, and to
  11632. allow @code{fcgiwrap} to run the back-end process as a corresponding
  11633. local user. To enable this capability on the back-end., run
  11634. @code{fcgiwrap} as the @code{root} user and group. Note that this
  11635. capability also has to be configured on the front-end as well.
  11636. @end table
  11637. @end deftp
  11638. @node DNS Services
  11639. @subsubsection DNS Services
  11640. @cindex DNS (domain name system)
  11641. @cindex domain name system (DNS)
  11642. The @code{(gnu services dns)} module provides services related to the
  11643. @dfn{domain name system} (DNS). It provides a server service for hosting
  11644. an @emph{authoritative} DNS server for multiple zones, slave or master.
  11645. This service uses @uref{https://www.knot-dns.cz/, Knot DNS}.
  11646. An example configuration of an authoritative server for two zones, one master
  11647. and one slave, is:
  11648. @lisp
  11649. (define-zone-entries example.org.zone
  11650. ;; Name TTL Class Type Data
  11651. ("@@" "" "IN" "A" "127.0.0.1")
  11652. ("@@" "" "IN" "NS" "ns")
  11653. ("ns" "" "IN" "A" "127.0.0.1"))
  11654. (define master-zone
  11655. (knot-zone-configuration
  11656. (domain "example.org")
  11657. (zone (zone-file
  11658. (origin "example.org")
  11659. (entries example.org.zone)))))
  11660. (define slave-zone
  11661. (knot-zone-configuration
  11662. (domain "plop.org")
  11663. (dnssec-policy "default")
  11664. (master (list "plop-master"))))
  11665. (define plop-master
  11666. (knot-remote-configuration
  11667. (id "plop-master")
  11668. (address (list "208.76.58.171"))))
  11669. (operating-system
  11670. ;; ...
  11671. (services (cons* (service knot-service-type
  11672. (knot-confifguration
  11673. (remotes (list plop-master))
  11674. (zones (list master-zone slave-zone))))
  11675. ;; ...
  11676. %base-services)))
  11677. @end lisp
  11678. @deffn {Scheme Variable} knot-service-type
  11679. This is the type for the Knot DNS server.
  11680. Knot DNS is an authoritative DNS server, meaning that it can serve multiple
  11681. zones, that is to say domain names you would buy from a registrar. This server
  11682. is not a resolver, meaning that it can only resolve names for which it is
  11683. authoritative. This server can be configured to serve zones as a master server
  11684. or a slave server as a per-zone basis. Slave zones will get their data from
  11685. masters, and will serve it as an authoritative server. From the point of view
  11686. of a resolver, there is no difference between master and slave.
  11687. The following data types are used to configure the Knot DNS server:
  11688. @end deffn
  11689. @deftp {Data Type} knot-key-configuration
  11690. Data type representing a key.
  11691. This type has the following parameters:
  11692. @table @asis
  11693. @item @code{id} (default: @code{""})
  11694. An identifier for other configuration fields to refer to this key. IDs must
  11695. be unique and must not be empty.
  11696. @item @code{algorithm} (default: @code{#f})
  11697. The algorithm to use. Choose between @code{#f}, @code{'hmac-md5},
  11698. @code{'hmac-sha1}, @code{'hmac-sha224}, @code{'hmac-sha256}, @code{'hmac-sha384}
  11699. and @code{'hmac-sha512}.
  11700. @item @code{secret} (default: @code{""})
  11701. The secret key itself.
  11702. @end table
  11703. @end deftp
  11704. @deftp {Data Type} knot-acl-configuration
  11705. Data type representing an Access Control List (ACL) configuration.
  11706. This type has the following parameters:
  11707. @table @asis
  11708. @item @code{id} (default: @code{""})
  11709. An identifier for ether configuration fields to refer to this key. IDs must be
  11710. unique and must not be empty.
  11711. @item @code{address} (default: @code{'()})
  11712. An ordered list of IP addresses, network subnets, or network ranges represented
  11713. with strings. The query must match one of them. Empty value means that
  11714. address match is not required.
  11715. @item @code{key} (default: @code{'()})
  11716. An ordered list of references to keys represented with strings. The string
  11717. must match a key ID defined in a @code{knot-key-configuration}. No key means
  11718. that a key is not require to match that ACL.
  11719. @item @code{action} (default: @code{'()})
  11720. An ordered list of actions that are permitted or forbidden by this ACL. Possible
  11721. values are lists of zero or more elements from @code{'transfer}, @code{'notify}
  11722. and @code{'update}.
  11723. @item @code{deny?} (default: @code{#f})
  11724. When true, the ACL defines restrictions. Listed actions are forbidden. When
  11725. false, listed actions are allowed.
  11726. @end table
  11727. @end deftp
  11728. @deftp {Data Type} zone-entry
  11729. Data type represnting a record entry in a zone file.
  11730. This type has the following parameters:
  11731. @table @asis
  11732. @item @code{name} (default: @code{"@@"})
  11733. The name of the record. @code{"@@"} refers to the origin of the zone. Names
  11734. are relative to the origin of the zone. For example, in the @code{example.org}
  11735. zone, @code{"ns.example.org"} actually refers to @code{ns.example.org.example.org}.
  11736. Names ending with a dot are absolute, which means that @code{"ns.example.org."}
  11737. refers to @code{ns.example.org}.
  11738. @item @code{ttl} (default: @code{""})
  11739. The Time-To-Live (TTL) of this record. If not set, the default TTL is used.
  11740. @item @code{class} (default: @code{"IN"})
  11741. The class of the record. Knot currently supports only @code{"IN"} and
  11742. partially @code{"CH"}.
  11743. @item @code{type} (default: @code{"A"})
  11744. The type of the record. Common types include A (IPv4 address), AAAA (IPv6
  11745. address), NS (Name Server) and MX (Mail eXchange). Many other types are
  11746. defined.
  11747. @item @code{data} (default: @code{""})
  11748. The data contained in the record. For instance an IP address associated with
  11749. an A record, or a domain name associated with an NS record. Remember that
  11750. domain names are relative to the origin unless they end with a dot.
  11751. @end table
  11752. @end deftp
  11753. @deftp {Data Type} zone-file
  11754. Data type representing the content of a zone file.
  11755. This type has the following parameters:
  11756. @table @asis
  11757. @item @code{entries} (default: @code{'()})
  11758. The list of entries. The SOA record is taken care of, so you don't need to
  11759. put it in the list of entries. This list should probably contain an entry
  11760. for your primary authoritative DNS server. Other than using a list of entries
  11761. directly, you can use @code{define-zone-entries} to define a object containing
  11762. the list of entries more easily, that you can later pass to the @code{entries}
  11763. field of the @code{zone-file}.
  11764. @item @code{origin} (default: @code{""})
  11765. The name of your zone. This parameter cannot be empty.
  11766. @item @code{ns} (default: @code{"ns"})
  11767. The domain of your primary authoritative DNS server. The name is relative to
  11768. the origin, unless it ends with a dot. It is mandatory that this primary
  11769. DNS server corresponds to an NS record in the zone and that it is associated
  11770. to an IP address in the list of entries.
  11771. @item @code{mail} (default: @code{"hostmaster"})
  11772. An email address people can contact you at, as the owner of the zone. This
  11773. is translated as @code{<mail>@@<origin>}.
  11774. @item @code{serial} (default: @code{1})
  11775. The serial number of the zone. As this is used to keep track of changes by
  11776. both slaves and resolvers, it is mandatory that it @emph{never} decreases.
  11777. Always increment it when you make a change in your zone.
  11778. @item @code{refresh} (default: @code{(* 2 24 3600)})
  11779. The frequency at which slaves will do a zone transfer. This value is a number
  11780. of seconds. It can be computed by multiplications or with
  11781. @code{(string->duration)}.
  11782. @item @code{retry} (default: @code{(* 15 60)})
  11783. The period after which a slave will retry to contact its master when it fails
  11784. to do so a first time.
  11785. @item @code{expiry} (default: @code{(* 14 24 3600)})
  11786. Default TTL of records. Existing records are considered correct for at most
  11787. this amount of time. After this period, resolvers will invalidate their cache
  11788. and check again that it still exists.
  11789. @item @code{nx} (default: @code{3600})
  11790. Default TTL of inexistant records. This delay is usually short because you want
  11791. your new domains to reach everyone quickly.
  11792. @end table
  11793. @end deftp
  11794. @deftp {Data Type} knot-remote-configuration
  11795. Data type representing a remote configuration.
  11796. This type has the following parameters:
  11797. @table @asis
  11798. @item @code{id} (default: @code{""})
  11799. An identifier for other configuration fields to refer to this remote. IDs must
  11800. be unique and must not be empty.
  11801. @item @code{address} (default: @code{'()})
  11802. An ordered list of destination IP addresses. Addresses are tried in sequence.
  11803. An optional port can be given with the @@ separator. For instance:
  11804. @code{(list "1.2.3.4" "2.3.4.5@@53")}. Default port is 53.
  11805. @item @code{via} (default: @code{'()})
  11806. An ordered list of source IP addresses. An empty list will have Knot choose
  11807. an appropriate source IP. An optional port can be given with the @@ separator.
  11808. The default is to choose at random.
  11809. @item @code{key} (default: @code{#f})
  11810. A reference to a key, that is a string containing the identifier of a key
  11811. defined in a @code{knot-key-configuration} field.
  11812. @end table
  11813. @end deftp
  11814. @deftp {Data Type} knot-keystore-configuration
  11815. Data type representing a keystore to hold dnssec keys.
  11816. This type has the following parameters:
  11817. @table @asis
  11818. @item @code{id} (default: @code{""})
  11819. The id of the keystore. It must not be empty.
  11820. @item @code{backend} (default: @code{'pem})
  11821. The backend to store the keys in. Can be @code{'pem} or @code{'pkcs11}.
  11822. @item @code{config} (default: @code{"/var/lib/knot/keys/keys"})
  11823. The configuration string of the backend. An example for the PKCS#11 is:
  11824. @code{"pkcs11:token=knot;pin-value=1234 /gnu/store/.../lib/pkcs11/libsofthsm2.so"}.
  11825. For the pem backend, the string reprensents a path in the filesystem.
  11826. @end table
  11827. @end deftp
  11828. @deftp {Data Type} knot-policy-configuration
  11829. Data type representing a dnssec policy. Knot DNS is able to automatically
  11830. sign your zones. It can either generate and manage your keys automatically or
  11831. use keys that you generate.
  11832. Dnssec is usually implemented using two keys: a Key Signing Key (KSK) that is
  11833. used to sign the second, and a Zone Signing Key (ZSK) that is used to sign the
  11834. zone. In order to be trusted, the KSK needs to be present in the parent zone
  11835. (usually a top-level domain). If your registrar supports dnssec, you will
  11836. have to send them your KSK's hash so they can add a DS record in their zone.
  11837. This is not automated and need to be done each time you change your KSK.
  11838. The policy also defines the lifetime of keys. Usually, ZSK can be changed
  11839. easily and use weaker cryptographic functions (they use lower parameters) in
  11840. order to sign records quickly, so they are changed often. The KSK however
  11841. requires manual interaction with the registrar, so they are changed less often
  11842. and use stronger parameters because they sign only one record.
  11843. This type has the following parameters:
  11844. @table @asis
  11845. @item @code{id} (default: @code{""})
  11846. The id of the policy. It must not be empty.
  11847. @item @code{keystore} (default: @code{"default"})
  11848. A reference to a keystore, that is a string containing the identifier of a
  11849. keystore defined in a @code{knot-keystore-configuration} field. The
  11850. @code{"default"} identifier means the default keystore (a kasp database that
  11851. was setup by this service).
  11852. @item @code{manual?} (default: @code{#f})
  11853. Whether the key management is manual or automatic.
  11854. @item @code{single-type-signing?} (default: @code{#f})
  11855. When @code{#t}, use the Single-Type Signing Scheme.
  11856. @item @code{algorithm} (default: @code{"ecdsap256sha256"})
  11857. An algorithm of signing keys and issued signatures.
  11858. @item @code{ksk-size} (default: @code{256})
  11859. The length of the KSK. Note that this value is correct for the default
  11860. algorithm, but would be unsecure for other algorithms.
  11861. @item @code{zsk-size} (default: @code{256})
  11862. The length of the ZSK. Note that this value is correct for the default
  11863. algorithm, but would be unsecure for other algorithms.
  11864. @item @code{dnskey-ttl} (default: @code{'default})
  11865. The TTL value for DNSKEY records added into zone apex. The special
  11866. @code{'default} value means same as the zone SOA TTL.
  11867. @item @code{zsk-lifetime} (default: @code{(* 30 24 3600)})
  11868. The period between ZSK publication and the next rollover initiation.
  11869. @item @code{propagation-delay} (default: @code{(* 24 3600)})
  11870. An extra delay added for each key rollover step. This value should be high
  11871. enough to cover propagation of data from the master server to all slaves.
  11872. @item @code{rrsig-lifetime} (default: @code{(* 14 24 3600)})
  11873. A validity period of newly issued signatures.
  11874. @item @code{rrsig-refresh} (default: @code{(* 7 24 3600)})
  11875. A period how long before a signature expiration the signature will be refreshed.
  11876. @item @code{nsec3?} (default: @code{#f})
  11877. When @code{#t}, NSEC3 will be used instead of NSEC.
  11878. @item @code{nsec3-iterations} (default: @code{5})
  11879. The number of additional times the hashing is performed.
  11880. @item @code{nsec3-salt-length} (default: @code{8})
  11881. The length of a salt field in octets, which is appended to the original owner
  11882. name before hashing.
  11883. @item @code{nsec3-salt-lifetime} (default: @code{(* 30 24 3600)})
  11884. The validity period of newly issued salt field.
  11885. @end table
  11886. @end deftp
  11887. @deftp {Data Type} knot-zone-configuration
  11888. Data type representing a zone served by Knot.
  11889. This type has the following parameters:
  11890. @table @asis
  11891. @item @code{domain} (default: @code{""})
  11892. The domain served by this configuration. It must not be empty.
  11893. @item @code{file} (default: @code{""})
  11894. The file where this zone is saved. This parameter is ignored by master zones.
  11895. Empty means default location that depends on the domain name.
  11896. @item @code{zone} (default: @code{(zone-file)})
  11897. The content of the zone file. This parameter is ignored by slave zones. It
  11898. must contain a zone-file record.
  11899. @item @code{master} (default: @code{'()})
  11900. A list of master remotes. When empty, this zone is a master. When set, this
  11901. zone is a slave. This is a list of remotes identifiers.
  11902. @item @code{ddns-master} (default: @code{#f})
  11903. The main master. When empty, it defaults to the first master in the list of
  11904. masters.
  11905. @item @code{notify} (default: @code{'()})
  11906. A list of slave remote identifiers.
  11907. @item @code{acl} (default: @code{'()})
  11908. A list of acl identifiers.
  11909. @item @code{semantic-checks?} (default: @code{#f})
  11910. When set, this adds more semantic checks to the zone.
  11911. @item @code{disable-any?} (default: @code{#f})
  11912. When set, this forbids queries of the ANY type.
  11913. @item @code{zonefile-sync} (default: @code{0})
  11914. The delay between a modification in memory and on disk. 0 means immediate
  11915. synchronization.
  11916. @item @code{serial-policy} (default: @code{'increment})
  11917. A policy between @code{'increment} and @code{'unixtime}.
  11918. @end table
  11919. @end deftp
  11920. @deftp {Data Type} knot-configuration
  11921. Data type representing the Knot configuration.
  11922. This type has the following parameters:
  11923. @table @asis
  11924. @item @code{knot} (default: @code{knot})
  11925. The Knot package.
  11926. @item @code{run-directory} (default: @code{"/var/run/knot"})
  11927. The run directory. This directory will be used for pid file and sockets.
  11928. @item @code{listen-v4} (default: @code{"0.0.0.0"})
  11929. An ip address on which to listen.
  11930. @item @code{listen-v6} (default: @code{"::"})
  11931. An ip address on which to listen.
  11932. @item @code{listen-port} (default: @code{53})
  11933. A port on which to listen.
  11934. @item @code{keys} (default: @code{'()})
  11935. The list of knot-key-configuration used by this configuration.
  11936. @item @code{acls} (default: @code{'()})
  11937. The list of knot-acl-configuration used by this configuration.
  11938. @item @code{remotes} (default: @code{'()})
  11939. The list of knot-remote-configuration used by this configuration.
  11940. @item @code{zones} (default: @code{'()})
  11941. The list of knot-zone-configuration used by this configuration.
  11942. @end table
  11943. @end deftp
  11944. @node VPN Services
  11945. @subsubsection VPN Services
  11946. @cindex VPN (virtual private network)
  11947. @cindex virtual private network (VPN)
  11948. The @code{(gnu services vpn)} module provides services related to
  11949. @dfn{virtual private networks} (VPNs). It provides a @emph{client} service for
  11950. your machine to connect to a VPN, and a @emph{servire} service for your machine
  11951. to host a VPN. Both services use @uref{https://openvpn.net/, OpenVPN}.
  11952. @deffn {Scheme Procedure} openvpn-client-service @
  11953. [#:config (openvpn-client-configuration)]
  11954. Return a service that runs @command{openvpn}, a VPN daemon, as a client.
  11955. @end deffn
  11956. @deffn {Scheme Procedure} openvpn-server-service @
  11957. [#:config (openvpn-server-configuration)]
  11958. Return a service that runs @command{openvpn}, a VPN daemon, as a server.
  11959. Both can be run simultaneously.
  11960. @end deffn
  11961. @c %automatically generated documentation
  11962. Available @code{openvpn-client-configuration} fields are:
  11963. @deftypevr {@code{openvpn-client-configuration} parameter} package openvpn
  11964. The OpenVPN package.
  11965. @end deftypevr
  11966. @deftypevr {@code{openvpn-client-configuration} parameter} string pid-file
  11967. The OpenVPN pid file.
  11968. Defaults to @samp{"/var/run/openvpn/openvpn.pid"}.
  11969. @end deftypevr
  11970. @deftypevr {@code{openvpn-client-configuration} parameter} proto proto
  11971. The protocol (UDP or TCP) used to open a channel between clients and
  11972. servers.
  11973. Defaults to @samp{udp}.
  11974. @end deftypevr
  11975. @deftypevr {@code{openvpn-client-configuration} parameter} dev dev
  11976. The device type used to represent the VPN connection.
  11977. Defaults to @samp{tun}.
  11978. @end deftypevr
  11979. @deftypevr {@code{openvpn-client-configuration} parameter} string ca
  11980. The certificate authority to check connections against.
  11981. Defaults to @samp{"/etc/openvpn/ca.crt"}.
  11982. @end deftypevr
  11983. @deftypevr {@code{openvpn-client-configuration} parameter} string cert
  11984. The certificate of the machine the daemon is running on. It should be
  11985. signed by the authority given in @code{ca}.
  11986. Defaults to @samp{"/etc/openvpn/client.crt"}.
  11987. @end deftypevr
  11988. @deftypevr {@code{openvpn-client-configuration} parameter} string key
  11989. The key of the machine the daemon is running on. It must be the key whose
  11990. certificate is @code{cert}.
  11991. Defaults to @samp{"/etc/openvpn/client.key"}.
  11992. @end deftypevr
  11993. @deftypevr {@code{openvpn-client-configuration} parameter} boolean comp-lzo?
  11994. Whether to use the lzo compression algorithm.
  11995. Defaults to @samp{#t}.
  11996. @end deftypevr
  11997. @deftypevr {@code{openvpn-client-configuration} parameter} boolean persist-key?
  11998. Don't re-read key files across SIGUSR1 or --ping-restart.
  11999. Defaults to @samp{#t}.
  12000. @end deftypevr
  12001. @deftypevr {@code{openvpn-client-configuration} parameter} boolean persist-tun?
  12002. Don't close and reopen TUN/TAP device or run up/down scripts across
  12003. SIGUSR1 or --ping-restart restarts.
  12004. Defaults to @samp{#t}.
  12005. @end deftypevr
  12006. @deftypevr {@code{openvpn-client-configuration} parameter} number verbosity
  12007. Verbosity level.
  12008. Defaults to @samp{3}.
  12009. @end deftypevr
  12010. @deftypevr {@code{openvpn-client-configuration} parameter} tls-auth-client tls-auth
  12011. Add an additional layer of HMAC authentication on top of the TLS control
  12012. channel to protect against DoS attacks.
  12013. Defaults to @samp{#f}.
  12014. @end deftypevr
  12015. @deftypevr {@code{openvpn-client-configuration} parameter} key-usage verify-key-usage?
  12016. Whether to check the server certificate has server usage extension.
  12017. Defaults to @samp{#t}.
  12018. @end deftypevr
  12019. @deftypevr {@code{openvpn-client-configuration} parameter} bind bind?
  12020. Bind to a specific local port number.
  12021. Defaults to @samp{#f}.
  12022. @end deftypevr
  12023. @deftypevr {@code{openvpn-client-configuration} parameter} resolv-retry resolv-retry?
  12024. Retry resolving server address.
  12025. Defaults to @samp{#t}.
  12026. @end deftypevr
  12027. @deftypevr {@code{openvpn-client-configuration} parameter} openvpn-remote-list remote
  12028. A list of remote servers to connect to.
  12029. Defaults to @samp{()}.
  12030. Available @code{openvpn-remote-configuration} fields are:
  12031. @deftypevr {@code{openvpn-remote-configuration} parameter} string name
  12032. Server name.
  12033. Defaults to @samp{"my-server"}.
  12034. @end deftypevr
  12035. @deftypevr {@code{openvpn-remote-configuration} parameter} number port
  12036. Port number the server listens to.
  12037. Defaults to @samp{1194}.
  12038. @end deftypevr
  12039. @end deftypevr
  12040. @c %end of automatic openvpn-client documentation
  12041. @c %automatically generated documentation
  12042. Available @code{openvpn-server-configuration} fields are:
  12043. @deftypevr {@code{openvpn-server-configuration} parameter} package openvpn
  12044. The OpenVPN package.
  12045. @end deftypevr
  12046. @deftypevr {@code{openvpn-server-configuration} parameter} string pid-file
  12047. The OpenVPN pid file.
  12048. Defaults to @samp{"/var/run/openvpn/openvpn.pid"}.
  12049. @end deftypevr
  12050. @deftypevr {@code{openvpn-server-configuration} parameter} proto proto
  12051. The protocol (UDP or TCP) used to open a channel between clients and
  12052. servers.
  12053. Defaults to @samp{udp}.
  12054. @end deftypevr
  12055. @deftypevr {@code{openvpn-server-configuration} parameter} dev dev
  12056. The device type used to represent the VPN connection.
  12057. Defaults to @samp{tun}.
  12058. @end deftypevr
  12059. @deftypevr {@code{openvpn-server-configuration} parameter} string ca
  12060. The certificate authority to check connections against.
  12061. Defaults to @samp{"/etc/openvpn/ca.crt"}.
  12062. @end deftypevr
  12063. @deftypevr {@code{openvpn-server-configuration} parameter} string cert
  12064. The certificate of the machine the daemon is running on. It should be
  12065. signed by the authority given in @code{ca}.
  12066. Defaults to @samp{"/etc/openvpn/client.crt"}.
  12067. @end deftypevr
  12068. @deftypevr {@code{openvpn-server-configuration} parameter} string key
  12069. The key of the machine the daemon is running on. It must be the key whose
  12070. certificate is @code{cert}.
  12071. Defaults to @samp{"/etc/openvpn/client.key"}.
  12072. @end deftypevr
  12073. @deftypevr {@code{openvpn-server-configuration} parameter} boolean comp-lzo?
  12074. Whether to use the lzo compression algorithm.
  12075. Defaults to @samp{#t}.
  12076. @end deftypevr
  12077. @deftypevr {@code{openvpn-server-configuration} parameter} boolean persist-key?
  12078. Don't re-read key files across SIGUSR1 or --ping-restart.
  12079. Defaults to @samp{#t}.
  12080. @end deftypevr
  12081. @deftypevr {@code{openvpn-server-configuration} parameter} boolean persist-tun?
  12082. Don't close and reopen TUN/TAP device or run up/down scripts across
  12083. SIGUSR1 or --ping-restart restarts.
  12084. Defaults to @samp{#t}.
  12085. @end deftypevr
  12086. @deftypevr {@code{openvpn-server-configuration} parameter} number verbosity
  12087. Verbosity level.
  12088. Defaults to @samp{3}.
  12089. @end deftypevr
  12090. @deftypevr {@code{openvpn-server-configuration} parameter} tls-auth-server tls-auth
  12091. Add an additional layer of HMAC authentication on top of the TLS control
  12092. channel to protect against DoS attacks.
  12093. Defaults to @samp{#f}.
  12094. @end deftypevr
  12095. @deftypevr {@code{openvpn-server-configuration} parameter} number port
  12096. Specifies the port number on which the server listens.
  12097. Defaults to @samp{1194}.
  12098. @end deftypevr
  12099. @deftypevr {@code{openvpn-server-configuration} parameter} ip-mask server
  12100. An ip and mask specifying the subnet inside the virtual network.
  12101. Defaults to @samp{"10.8.0.0 255.255.255.0"}.
  12102. @end deftypevr
  12103. @deftypevr {@code{openvpn-server-configuration} parameter} cidr6 server-ipv6
  12104. A CIDR notation specifying the IPv6 subnet inside the virtual network.
  12105. Defaults to @samp{#f}.
  12106. @end deftypevr
  12107. @deftypevr {@code{openvpn-server-configuration} parameter} string dh
  12108. The Diffie-Hellman parameters file.
  12109. Defaults to @samp{"/etc/openvpn/dh2048.pem"}.
  12110. @end deftypevr
  12111. @deftypevr {@code{openvpn-server-configuration} parameter} string ifconfig-pool-persist
  12112. The file that records client IPs.
  12113. Defaults to @samp{"/etc/openvpn/ipp.txt"}.
  12114. @end deftypevr
  12115. @deftypevr {@code{openvpn-server-configuration} parameter} gateway redirect-gateway?
  12116. When true, the server will act as a gateway for its clients.
  12117. Defaults to @samp{#f}.
  12118. @end deftypevr
  12119. @deftypevr {@code{openvpn-server-configuration} parameter} boolean client-to-client?
  12120. When true, clients are allowed to talk to each other inside the VPN.
  12121. Defaults to @samp{#f}.
  12122. @end deftypevr
  12123. @deftypevr {@code{openvpn-server-configuration} parameter} keepalive keepalive
  12124. Causes ping-like messages to be sent back and forth over the link so
  12125. that each side knows when the other side has gone down. @code{keepalive}
  12126. requires a pair. The first element is the period of the ping sending,
  12127. and the second element is the timeout before considering the other side
  12128. down.
  12129. @end deftypevr
  12130. @deftypevr {@code{openvpn-server-configuration} parameter} number max-clients
  12131. The maximum number of clients.
  12132. Defaults to @samp{100}.
  12133. @end deftypevr
  12134. @deftypevr {@code{openvpn-server-configuration} parameter} string status
  12135. The status file. This file shows a small report on current connection.
  12136. It is truncated and rewritten every minute.
  12137. Defaults to @samp{"/var/run/openvpn/status"}.
  12138. @end deftypevr
  12139. @deftypevr {@code{openvpn-server-configuration} parameter} openvpn-ccd-list client-config-dir
  12140. The list of configuration for some clients.
  12141. Defaults to @samp{()}.
  12142. Available @code{openvpn-ccd-configuration} fields are:
  12143. @deftypevr {@code{openvpn-ccd-configuration} parameter} string name
  12144. Client name.
  12145. Defaults to @samp{"client"}.
  12146. @end deftypevr
  12147. @deftypevr {@code{openvpn-ccd-configuration} parameter} ip-mask iroute
  12148. Client own network
  12149. Defaults to @samp{#f}.
  12150. @end deftypevr
  12151. @deftypevr {@code{openvpn-ccd-configuration} parameter} ip-mask ifconfig-push
  12152. Client VPN IP.
  12153. Defaults to @samp{#f}.
  12154. @end deftypevr
  12155. @end deftypevr
  12156. @c %end of automatic openvpn-server documentation
  12157. @node Network File System
  12158. @subsubsection Network File System
  12159. @cindex NFS
  12160. The @code{(gnu services nfs)} module provides the following services,
  12161. which are most commonly used in relation to mounting or exporting
  12162. directory trees as @dfn{network file systems} (NFS).
  12163. @subsubheading RPC Bind Service
  12164. @cindex rpcbind
  12165. The RPC Bind service provides a facility to map program numbers into
  12166. universal addresses.
  12167. Many NFS related services use this facility. Hence it is automatically
  12168. started when a dependent service starts.
  12169. @defvr {Scheme Variable} rpcbind-service-type
  12170. A service type for the RPC portmapper daemon.
  12171. @end defvr
  12172. @deftp {Data Type} rpcbind-configuration
  12173. Data type representing the configuration of the RPC Bind Service.
  12174. This type has the following parameters:
  12175. @table @asis
  12176. @item @code{rpcbind} (default: @code{rpcbind})
  12177. The rpcbind package to use.
  12178. @item @code{warm-start?} (default: @code{#t})
  12179. If this parameter is @code{#t}, then the daemon will read a
  12180. state file on startup thus reloading state information saved by a previous
  12181. instance.
  12182. @end table
  12183. @end deftp
  12184. @subsubheading Pipefs Pseudo File System
  12185. @cindex pipefs
  12186. @cindex rpc_pipefs
  12187. The pipefs file system is used to transfer NFS related data
  12188. between the kernel and user space programs.
  12189. @defvr {Scheme Variable} pipefs-service-type
  12190. A service type for the pipefs pseudo file system.
  12191. @end defvr
  12192. @deftp {Data Type} pipefs-configuration
  12193. Data type representing the configuration of the pipefs pseudo file system service.
  12194. This type has the following parameters:
  12195. @table @asis
  12196. @item @code{mount-point} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  12197. The directory to which the file system is to be attached.
  12198. @end table
  12199. @end deftp
  12200. @subsubheading GSS Daemon Service
  12201. @cindex GSSD
  12202. @cindex GSS
  12203. @cindex global security system
  12204. The @dfn{global security system} (GSS) daemon provides strong security for RPC
  12205. based protocols.
  12206. Before exchanging RPC requests an RPC client must establish a security
  12207. context. Typically this is done using the Kerberos command @command{kinit}
  12208. or automatically at login time using PAM services (@pxref{Kerberos Services}).
  12209. @defvr {Scheme Variable} gss-service-type
  12210. A service type for the Global Security System (GSS) daemon.
  12211. @end defvr
  12212. @deftp {Data Type} gss-configuration
  12213. Data type representing the configuration of the GSS daemon service.
  12214. This type has the following parameters:
  12215. @table @asis
  12216. @item @code{nfs-utils} (default: @code{nfs-utils})
  12217. The package in which the @command{rpc.gssd} command is to be found.
  12218. @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  12219. The directory where the pipefs file system is mounted.
  12220. @end table
  12221. @end deftp
  12222. @subsubheading IDMAP Daemon Service
  12223. @cindex idmapd
  12224. @cindex name mapper
  12225. The idmap daemon service provides mapping between user IDs and user names.
  12226. Typically it is required in order to access file systems mounted via NFSv4.
  12227. @defvr {Scheme Variable} idmap-service-type
  12228. A service type for the Identity Mapper (IDMAP) daemon.
  12229. @end defvr
  12230. @deftp {Data Type} idmap-configuration
  12231. Data type representing the configuration of the IDMAP daemon service.
  12232. This type has the following parameters:
  12233. @table @asis
  12234. @item @code{nfs-utils} (default: @code{nfs-utils})
  12235. The package in which the @command{rpc.idmapd} command is to be found.
  12236. @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  12237. The directory where the pipefs file system is mounted.
  12238. @item @code{domain} (default: @code{#f})
  12239. The local NFSv4 domain name.
  12240. This must be a string or @code{#f}.
  12241. If it is @code{#f} then the daemon will use the host's fully qualified domain name.
  12242. @end table
  12243. @end deftp
  12244. @node Continuous Integration
  12245. @subsubsection Continuous Integration
  12246. @cindex continuous integration
  12247. @uref{https://notabug.org/mthl/cuirass, Cuirass} is a continuous
  12248. integration tool for Guix. It can be used both for development and for
  12249. providing substitutes to others (@pxref{Substitutes}).
  12250. The @code{(gnu services cuirass)} module provides the following service.
  12251. @defvr {Scheme Procedure} cuirass-service-type
  12252. The type of the Cuirass service. Its value must be a
  12253. @code{cuirass-configuration} object, as described below.
  12254. @end defvr
  12255. To add build jobs, you have to set the @code{specifications} field of
  12256. the configuration. Here is an example of a service defining a build job
  12257. based on a specification that can be found in Cuirass source tree. This
  12258. service polls the Guix repository and builds a subset of the Guix
  12259. packages, as prescribed in the @file{gnu-system.scm} example spec:
  12260. @example
  12261. (let ((spec #~((#:name . "guix")
  12262. (#:url . "git://git.savannah.gnu.org/guix.git")
  12263. (#:load-path . ".")
  12264. (#:file . "build-aux/cuirass/gnu-system.scm")
  12265. (#:proc . cuirass-jobs)
  12266. (#:arguments (subset . "hello"))
  12267. (#:branch . "master"))))
  12268. (service cuirass-service-type
  12269. (cuirass-configuration
  12270. (specifications #~(list '#$spec)))))
  12271. @end example
  12272. While information related to build jobs is located directly in the
  12273. specifications, global settings for the @command{cuirass} process are
  12274. accessible in other @code{cuirass-configuration} fields.
  12275. @deftp {Data Type} cuirass-configuration
  12276. Data type representing the configuration of Cuirass.
  12277. @table @asis
  12278. @item @code{log-file} (default: @code{"/var/log/cuirass.log"})
  12279. Location of the log file.
  12280. @item @code{cache-directory} (default: @code{"/var/cache/cuirass"})
  12281. Location of the repository cache.
  12282. @item @code{user} (default: @code{"cuirass"})
  12283. Owner of the @code{cuirass} process.
  12284. @item @code{group} (default: @code{"cuirass"})
  12285. Owner's group of the @code{cuirass} process.
  12286. @item @code{interval} (default: @code{60})
  12287. Number of seconds between the poll of the repositories followed by the
  12288. Cuirass jobs.
  12289. @item @code{database} (default: @code{"/var/run/cuirass/cuirass.db"})
  12290. Location of sqlite database which contains the build results and previously
  12291. added specifications.
  12292. @item @code{port} (default: @code{8081})
  12293. Port number used by the HTTP server.
  12294. @item --listen=@var{host}
  12295. Listen on the network interface for @var{host}. The default is to
  12296. accept connections from localhost.
  12297. @item @code{specifications} (default: @code{#~'()})
  12298. A gexp (@pxref{G-Expressions}) that evaluates to a list of specifications,
  12299. where a specification is an association list
  12300. (@pxref{Associations Lists,,, guile, GNU Guile Reference Manual}) whose
  12301. keys are keywords (@code{#:keyword-example}) as shown in the example
  12302. above.
  12303. @item @code{use-substitutes?} (default: @code{#f})
  12304. This allows using substitutes to avoid building every dependencies of a job
  12305. from source.
  12306. @item @code{one-shot?} (default: @code{#f})
  12307. Only evaluate specifications and build derivations once.
  12308. @item @code{fallback?} (default: @code{#f})
  12309. When substituting a pre-built binary fails, fall back to building
  12310. packages locally.
  12311. @item @code{load-path} (default: @code{'()})
  12312. This allows users to define their own packages and make them visible to
  12313. cuirass as in @command{guix build} command.
  12314. @item @code{cuirass} (default: @code{cuirass})
  12315. The Cuirass package to use.
  12316. @end table
  12317. @end deftp
  12318. @node Power management Services
  12319. @subsubsection Power management Services
  12320. @cindex power management with TLP
  12321. The @code{(gnu services pm)} module provides a Guix service definition
  12322. for the Linux power management tool TLP.
  12323. TLP enables various powersaving modes in userspace and kernel.
  12324. Contrary to @code{upower-service}, it is not a passive,
  12325. monitoring tool, as it will apply custom settings each time a new power
  12326. source is detected. More information can be found at
  12327. @uref{http://linrunner.de/en/tlp/tlp.html, TLP home page}.
  12328. @deffn {Scheme Variable} tlp-service-type
  12329. The service type for the TLP tool. Its value should be a valid
  12330. TLP configuration (see below). To use the default settings, simply
  12331. write:
  12332. @example
  12333. (service tlp-service-type)
  12334. @end example
  12335. @end deffn
  12336. By default TLP does not need much configuration but most TLP parameters
  12337. can be tweaked using @code{tlp-configuration}.
  12338. Each parameter definition is preceded by its type; for example,
  12339. @samp{boolean foo} indicates that the @code{foo} parameter
  12340. should be specified as a boolean. Types starting with
  12341. @code{maybe-} denote parameters that won't show up in TLP config file
  12342. when their value is @code{'disabled}.
  12343. @c The following documentation was initially generated by
  12344. @c (generate-tlp-documentation) in (gnu services pm). Manually maintained
  12345. @c documentation is better, so we shouldn't hesitate to edit below as
  12346. @c needed. However if the change you want to make to this documentation
  12347. @c can be done in an automated way, it's probably easier to change
  12348. @c (generate-documentation) than to make it below and have to deal with
  12349. @c the churn as TLP updates.
  12350. Available @code{tlp-configuration} fields are:
  12351. @deftypevr {@code{tlp-configuration} parameter} package tlp
  12352. The TLP package.
  12353. @end deftypevr
  12354. @deftypevr {@code{tlp-configuration} parameter} boolean tlp-enable?
  12355. Set to true if you wish to enable TLP.
  12356. Defaults to @samp{#t}.
  12357. @end deftypevr
  12358. @deftypevr {@code{tlp-configuration} parameter} string tlp-default-mode
  12359. Default mode when no power supply can be detected. Alternatives are AC
  12360. and BAT.
  12361. Defaults to @samp{"AC"}.
  12362. @end deftypevr
  12363. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer disk-idle-secs-on-ac
  12364. Number of seconds Linux kernel has to wait after the disk goes idle,
  12365. before syncing on AC.
  12366. Defaults to @samp{0}.
  12367. @end deftypevr
  12368. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer disk-idle-secs-on-bat
  12369. Same as @code{disk-idle-ac} but on BAT mode.
  12370. Defaults to @samp{2}.
  12371. @end deftypevr
  12372. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer max-lost-work-secs-on-ac
  12373. Dirty pages flushing periodicity, expressed in seconds.
  12374. Defaults to @samp{15}.
  12375. @end deftypevr
  12376. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer max-lost-work-secs-on-bat
  12377. Same as @code{max-lost-work-secs-on-ac} but on BAT mode.
  12378. Defaults to @samp{60}.
  12379. @end deftypevr
  12380. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list cpu-scaling-governor-on-ac
  12381. CPU frequency scaling governor on AC mode. With intel_pstate driver,
  12382. alternatives are powersave and performance. With acpi-cpufreq driver,
  12383. alternatives are ondemand, powersave, performance and conservative.
  12384. Defaults to @samp{disabled}.
  12385. @end deftypevr
  12386. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list cpu-scaling-governor-on-bat
  12387. Same as @code{cpu-scaling-governor-on-ac} but on BAT mode.
  12388. Defaults to @samp{disabled}.
  12389. @end deftypevr
  12390. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-min-freq-on-ac
  12391. Set the min available frequency for the scaling governor on AC.
  12392. Defaults to @samp{disabled}.
  12393. @end deftypevr
  12394. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-max-freq-on-ac
  12395. Set the max available frequency for the scaling governor on AC.
  12396. Defaults to @samp{disabled}.
  12397. @end deftypevr
  12398. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-min-freq-on-bat
  12399. Set the min available frequency for the scaling governor on BAT.
  12400. Defaults to @samp{disabled}.
  12401. @end deftypevr
  12402. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-max-freq-on-bat
  12403. Set the max available frequency for the scaling governor on BAT.
  12404. Defaults to @samp{disabled}.
  12405. @end deftypevr
  12406. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-min-perf-on-ac
  12407. Limit the min P-state to control the power dissipation of the CPU, in AC
  12408. mode. Values are stated as a percentage of the available performance.
  12409. Defaults to @samp{disabled}.
  12410. @end deftypevr
  12411. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-max-perf-on-ac
  12412. Limit the max P-state to control the power dissipation of the CPU, in AC
  12413. mode. Values are stated as a percentage of the available performance.
  12414. Defaults to @samp{disabled}.
  12415. @end deftypevr
  12416. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-min-perf-on-bat
  12417. Same as @code{cpu-min-perf-on-ac} on BAT mode.
  12418. Defaults to @samp{disabled}.
  12419. @end deftypevr
  12420. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-max-perf-on-bat
  12421. Same as @code{cpu-max-perf-on-ac} on BAT mode.
  12422. Defaults to @samp{disabled}.
  12423. @end deftypevr
  12424. @deftypevr {@code{tlp-configuration} parameter} maybe-boolean cpu-boost-on-ac?
  12425. Enable CPU turbo boost feature on AC mode.
  12426. Defaults to @samp{disabled}.
  12427. @end deftypevr
  12428. @deftypevr {@code{tlp-configuration} parameter} maybe-boolean cpu-boost-on-bat?
  12429. Same as @code{cpu-boost-on-ac?} on BAT mode.
  12430. Defaults to @samp{disabled}.
  12431. @end deftypevr
  12432. @deftypevr {@code{tlp-configuration} parameter} boolean sched-powersave-on-ac?
  12433. Allow Linux kernel to minimize the number of CPU cores/hyper-threads
  12434. used under light load conditions.
  12435. Defaults to @samp{#f}.
  12436. @end deftypevr
  12437. @deftypevr {@code{tlp-configuration} parameter} boolean sched-powersave-on-bat?
  12438. Same as @code{sched-powersave-on-ac?} but on BAT mode.
  12439. Defaults to @samp{#t}.
  12440. @end deftypevr
  12441. @deftypevr {@code{tlp-configuration} parameter} boolean nmi-watchdog?
  12442. Enable Linux kernel NMI watchdog.
  12443. Defaults to @samp{#f}.
  12444. @end deftypevr
  12445. @deftypevr {@code{tlp-configuration} parameter} maybe-string phc-controls
  12446. For Linux kernels with PHC patch applied, change CPU voltages. An
  12447. example value would be @samp{"F:V F:V F:V F:V"}.
  12448. Defaults to @samp{disabled}.
  12449. @end deftypevr
  12450. @deftypevr {@code{tlp-configuration} parameter} string energy-perf-policy-on-ac
  12451. Set CPU performance versus energy saving policy on AC. Alternatives are
  12452. performance, normal, powersave.
  12453. Defaults to @samp{"performance"}.
  12454. @end deftypevr
  12455. @deftypevr {@code{tlp-configuration} parameter} string energy-perf-policy-on-bat
  12456. Same as @code{energy-perf-policy-ac} but on BAT mode.
  12457. Defaults to @samp{"powersave"}.
  12458. @end deftypevr
  12459. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disks-devices
  12460. Hard disk devices.
  12461. @end deftypevr
  12462. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disk-apm-level-on-ac
  12463. Hard disk advanced power management level.
  12464. @end deftypevr
  12465. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disk-apm-level-on-bat
  12466. Same as @code{disk-apm-bat} but on BAT mode.
  12467. @end deftypevr
  12468. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-spindown-timeout-on-ac
  12469. Hard disk spin down timeout. One value has to be specified for each
  12470. declared hard disk.
  12471. Defaults to @samp{disabled}.
  12472. @end deftypevr
  12473. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-spindown-timeout-on-bat
  12474. Same as @code{disk-spindown-timeout-on-ac} but on BAT mode.
  12475. Defaults to @samp{disabled}.
  12476. @end deftypevr
  12477. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-iosched
  12478. Select IO scheduler for disk devices. One value has to be specified for
  12479. each declared hard disk. Example alternatives are cfq, deadline and
  12480. noop.
  12481. Defaults to @samp{disabled}.
  12482. @end deftypevr
  12483. @deftypevr {@code{tlp-configuration} parameter} string sata-linkpwr-on-ac
  12484. SATA aggressive link power management (ALPM) level. Alternatives are
  12485. min_power, medium_power, max_performance.
  12486. Defaults to @samp{"max_performance"}.
  12487. @end deftypevr
  12488. @deftypevr {@code{tlp-configuration} parameter} string sata-linkpwr-on-bat
  12489. Same as @code{sata-linkpwr-ac} but on BAT mode.
  12490. Defaults to @samp{"min_power"}.
  12491. @end deftypevr
  12492. @deftypevr {@code{tlp-configuration} parameter} maybe-string sata-linkpwr-blacklist
  12493. Exclude specified SATA host devices for link power management.
  12494. Defaults to @samp{disabled}.
  12495. @end deftypevr
  12496. @deftypevr {@code{tlp-configuration} parameter} maybe-on-off-boolean ahci-runtime-pm-on-ac?
  12497. Enable Runtime Power Management for AHCI controller and disks on AC
  12498. mode.
  12499. Defaults to @samp{disabled}.
  12500. @end deftypevr
  12501. @deftypevr {@code{tlp-configuration} parameter} maybe-on-off-boolean ahci-runtime-pm-on-bat?
  12502. Same as @code{ahci-runtime-pm-on-ac} on BAT mode.
  12503. Defaults to @samp{disabled}.
  12504. @end deftypevr
  12505. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer ahci-runtime-pm-timeout
  12506. Seconds of inactivity before disk is suspended.
  12507. Defaults to @samp{15}.
  12508. @end deftypevr
  12509. @deftypevr {@code{tlp-configuration} parameter} string pcie-aspm-on-ac
  12510. PCI Express Active State Power Management level. Alternatives are
  12511. default, performance, powersave.
  12512. Defaults to @samp{"performance"}.
  12513. @end deftypevr
  12514. @deftypevr {@code{tlp-configuration} parameter} string pcie-aspm-on-bat
  12515. Same as @code{pcie-aspm-ac} but on BAT mode.
  12516. Defaults to @samp{"powersave"}.
  12517. @end deftypevr
  12518. @deftypevr {@code{tlp-configuration} parameter} string radeon-power-profile-on-ac
  12519. Radeon graphics clock speed level. Alternatives are low, mid, high,
  12520. auto, default.
  12521. Defaults to @samp{"high"}.
  12522. @end deftypevr
  12523. @deftypevr {@code{tlp-configuration} parameter} string radeon-power-profile-on-bat
  12524. Same as @code{radeon-power-ac} but on BAT mode.
  12525. Defaults to @samp{"low"}.
  12526. @end deftypevr
  12527. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-state-on-ac
  12528. Radeon dynamic power management method (DPM). Alternatives are battery,
  12529. performance.
  12530. Defaults to @samp{"performance"}.
  12531. @end deftypevr
  12532. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-state-on-bat
  12533. Same as @code{radeon-dpm-state-ac} but on BAT mode.
  12534. Defaults to @samp{"battery"}.
  12535. @end deftypevr
  12536. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-perf-level-on-ac
  12537. Radeon DPM performance level. Alternatives are auto, low, high.
  12538. Defaults to @samp{"auto"}.
  12539. @end deftypevr
  12540. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-perf-level-on-bat
  12541. Same as @code{radeon-dpm-perf-ac} but on BAT mode.
  12542. Defaults to @samp{"auto"}.
  12543. @end deftypevr
  12544. @deftypevr {@code{tlp-configuration} parameter} on-off-boolean wifi-pwr-on-ac?
  12545. Wifi power saving mode.
  12546. Defaults to @samp{#f}.
  12547. @end deftypevr
  12548. @deftypevr {@code{tlp-configuration} parameter} on-off-boolean wifi-pwr-on-bat?
  12549. Same as @code{wifi-power-ac?} but on BAT mode.
  12550. Defaults to @samp{#t}.
  12551. @end deftypevr
  12552. @deftypevr {@code{tlp-configuration} parameter} y-n-boolean wol-disable?
  12553. Disable wake on LAN.
  12554. Defaults to @samp{#t}.
  12555. @end deftypevr
  12556. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer sound-power-save-on-ac
  12557. Timeout duration in seconds before activating audio power saving on
  12558. Intel HDA and AC97 devices. A value of 0 disables power saving.
  12559. Defaults to @samp{0}.
  12560. @end deftypevr
  12561. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer sound-power-save-on-bat
  12562. Same as @code{sound-powersave-ac} but on BAT mode.
  12563. Defaults to @samp{1}.
  12564. @end deftypevr
  12565. @deftypevr {@code{tlp-configuration} parameter} y-n-boolean sound-power-save-controller?
  12566. Disable controller in powersaving mode on Intel HDA devices.
  12567. Defaults to @samp{#t}.
  12568. @end deftypevr
  12569. @deftypevr {@code{tlp-configuration} parameter} boolean bay-poweroff-on-bat?
  12570. Enable optical drive in UltraBay/MediaBay on BAT mode. Drive can be
  12571. powered on again by releasing (and reinserting) the eject lever or by
  12572. pressing the disc eject button on newer models.
  12573. Defaults to @samp{#f}.
  12574. @end deftypevr
  12575. @deftypevr {@code{tlp-configuration} parameter} string bay-device
  12576. Name of the optical drive device to power off.
  12577. Defaults to @samp{"sr0"}.
  12578. @end deftypevr
  12579. @deftypevr {@code{tlp-configuration} parameter} string runtime-pm-on-ac
  12580. Runtime Power Management for PCI(e) bus devices. Alternatives are on
  12581. and auto.
  12582. Defaults to @samp{"on"}.
  12583. @end deftypevr
  12584. @deftypevr {@code{tlp-configuration} parameter} string runtime-pm-on-bat
  12585. Same as @code{runtime-pm-ac} but on BAT mode.
  12586. Defaults to @samp{"auto"}.
  12587. @end deftypevr
  12588. @deftypevr {@code{tlp-configuration} parameter} boolean runtime-pm-all?
  12589. Runtime Power Management for all PCI(e) bus devices, except blacklisted
  12590. ones.
  12591. Defaults to @samp{#t}.
  12592. @end deftypevr
  12593. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list runtime-pm-blacklist
  12594. Exclude specified PCI(e) device addresses from Runtime Power Management.
  12595. Defaults to @samp{disabled}.
  12596. @end deftypevr
  12597. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list runtime-pm-driver-blacklist
  12598. Exclude PCI(e) devices assigned to the specified drivers from Runtime
  12599. Power Management.
  12600. @end deftypevr
  12601. @deftypevr {@code{tlp-configuration} parameter} boolean usb-autosuspend?
  12602. Enable USB autosuspend feature.
  12603. Defaults to @samp{#t}.
  12604. @end deftypevr
  12605. @deftypevr {@code{tlp-configuration} parameter} maybe-string usb-blacklist
  12606. Exclude specified devices from USB autosuspend.
  12607. Defaults to @samp{disabled}.
  12608. @end deftypevr
  12609. @deftypevr {@code{tlp-configuration} parameter} boolean usb-blacklist-wwan?
  12610. Exclude WWAN devices from USB autosuspend.
  12611. Defaults to @samp{#t}.
  12612. @end deftypevr
  12613. @deftypevr {@code{tlp-configuration} parameter} maybe-string usb-whitelist
  12614. Include specified devices into USB autosuspend, even if they are already
  12615. excluded by the driver or via @code{usb-blacklist-wwan?}.
  12616. Defaults to @samp{disabled}.
  12617. @end deftypevr
  12618. @deftypevr {@code{tlp-configuration} parameter} maybe-boolean usb-autosuspend-disable-on-shutdown?
  12619. Enable USB autosuspend before shutdown.
  12620. Defaults to @samp{disabled}.
  12621. @end deftypevr
  12622. @deftypevr {@code{tlp-configuration} parameter} boolean restore-device-state-on-startup?
  12623. Restore radio device state (bluetooth, wifi, wwan) from previous
  12624. shutdown on system startup.
  12625. Defaults to @samp{#f}.
  12626. @end deftypevr
  12627. The @code{(gnu services pm)} module provides an interface to
  12628. thermald, a CPU frequency scaling service which helps prevent overheating.
  12629. @defvr {Scheme Variable} thermald-service-type
  12630. This is the service type for
  12631. @uref{https://01.org/linux-thermal-daemon/, thermald}, the Linux
  12632. Thermal Daemon, which is responsible for controlling the thermal state
  12633. of processors and preventing overheating.
  12634. @end defvr
  12635. @deftp {Data Type} thermald-configuration
  12636. Data type representing the configuration of @code{thermald-service-type}.
  12637. @table @asis
  12638. @item @code{ignore-cpuid-check?} (default: @code{#f})
  12639. Ignore cpuid check for supported CPU models.
  12640. @item @code{thermald} (default: @var{thermald})
  12641. Package object of thermald.
  12642. @end table
  12643. @end deftp
  12644. @node Audio Services
  12645. @subsubsection Audio Services
  12646. The @code{(gnu services audio)} module provides a service to start MPD
  12647. (the Music Player Daemon).
  12648. @cindex mpd
  12649. @subsubheading Music Player Daemon
  12650. The Music Player Daemon (MPD) is a service that can play music while
  12651. being controlled from the local machine or over the network by a variety
  12652. of clients.
  12653. The following example shows how one might run @code{mpd} as user
  12654. @code{"bob"} on port @code{6666}. It uses pulseaudio for output.
  12655. @example
  12656. (service mpd-service-type
  12657. (mpd-configuration
  12658. (user "bob")
  12659. (port "6666")))
  12660. @end example
  12661. @defvr {Scheme Variable} mpd-service-type
  12662. The service type for @command{mpd}
  12663. @end defvr
  12664. @deftp {Data Type} mpd-configuration
  12665. Data type representing the configuration of @command{mpd}.
  12666. @table @asis
  12667. @item @code{user} (default: @code{"mpd"})
  12668. The user to run mpd as.
  12669. @item @code{music-dir} (default: @code{"~/Music"})
  12670. The directory to scan for music files.
  12671. @item @code{playlist-dir} (default: @code{"~/.mpd/playlists"})
  12672. The directory to store playlists.
  12673. @item @code{port} (default: @code{"6600"})
  12674. The port to run mpd on.
  12675. @item @code{address} (default: @code{"any"})
  12676. The address that mpd will bind to. To use a Unix domain socket,
  12677. an absolute path can be specified here.
  12678. @end table
  12679. @end deftp
  12680. @node Virtualization Services
  12681. @subsubsection Virtualization services
  12682. The @code{(gnu services virtualization)} module provides services for
  12683. the libvirt and virtlog daemons.
  12684. @subsubheading Libvirt daemon
  12685. @code{libvirtd} is the server side daemon component of the libvirt
  12686. virtualization management system. This daemon runs on host servers
  12687. and performs required management tasks for virtualized guests.
  12688. @deffn {Scheme Variable} libvirt-service-type
  12689. This is the type of the @uref{https://libvirt.org, libvirt daemon}.
  12690. Its value must be a @code{libvirt-configuration}.
  12691. @example
  12692. (service libvirt-service-type
  12693. (libvirt-configuration
  12694. (unix-sock-group "libvirt")
  12695. (tls-port "16555")))
  12696. @end example
  12697. @end deffn
  12698. @c Auto-generated with (generate-libvirt-documentation)
  12699. Available @code{libvirt-configuration} fields are:
  12700. @deftypevr {@code{libvirt-configuration} parameter} package libvirt
  12701. Libvirt package.
  12702. @end deftypevr
  12703. @deftypevr {@code{libvirt-configuration} parameter} boolean listen-tls?
  12704. Flag listening for secure TLS connections on the public TCP/IP port.
  12705. must set @code{listen} for this to have any effect.
  12706. It is necessary to setup a CA and issue server certificates before using
  12707. this capability.
  12708. Defaults to @samp{#t}.
  12709. @end deftypevr
  12710. @deftypevr {@code{libvirt-configuration} parameter} boolean listen-tcp?
  12711. Listen for unencrypted TCP connections on the public TCP/IP port. must
  12712. set @code{listen} for this to have any effect.
  12713. Using the TCP socket requires SASL authentication by default. Only SASL
  12714. mechanisms which support data encryption are allowed. This is
  12715. DIGEST_MD5 and GSSAPI (Kerberos5)
  12716. Defaults to @samp{#f}.
  12717. @end deftypevr
  12718. @deftypevr {@code{libvirt-configuration} parameter} string tls-port
  12719. Port for accepting secure TLS connections This can be a port number, or
  12720. service name
  12721. Defaults to @samp{"16514"}.
  12722. @end deftypevr
  12723. @deftypevr {@code{libvirt-configuration} parameter} string tcp-port
  12724. Port for accepting insecure TCP connections This can be a port number,
  12725. or service name
  12726. Defaults to @samp{"16509"}.
  12727. @end deftypevr
  12728. @deftypevr {@code{libvirt-configuration} parameter} string listen-addr
  12729. IP address or hostname used for client connections.
  12730. Defaults to @samp{"0.0.0.0"}.
  12731. @end deftypevr
  12732. @deftypevr {@code{libvirt-configuration} parameter} boolean mdns-adv?
  12733. Flag toggling mDNS advertisement of the libvirt service.
  12734. Alternatively can disable for all services on a host by stopping the
  12735. Avahi daemon.
  12736. Defaults to @samp{#f}.
  12737. @end deftypevr
  12738. @deftypevr {@code{libvirt-configuration} parameter} string mdns-name
  12739. Default mDNS advertisement name. This must be unique on the immediate
  12740. broadcast network.
  12741. Defaults to @samp{"Virtualization Host <hostname>"}.
  12742. @end deftypevr
  12743. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-group
  12744. UNIX domain socket group ownership. This can be used to allow a
  12745. 'trusted' set of users access to management capabilities without
  12746. becoming root.
  12747. Defaults to @samp{"root"}.
  12748. @end deftypevr
  12749. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-ro-perms
  12750. UNIX socket permissions for the R/O socket. This is used for monitoring
  12751. VM status only.
  12752. Defaults to @samp{"0777"}.
  12753. @end deftypevr
  12754. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-rw-perms
  12755. UNIX socket permissions for the R/W socket. Default allows only root.
  12756. If PolicyKit is enabled on the socket, the default will change to allow
  12757. everyone (eg, 0777)
  12758. Defaults to @samp{"0770"}.
  12759. @end deftypevr
  12760. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-admin-perms
  12761. UNIX socket permissions for the admin socket. Default allows only owner
  12762. (root), do not change it unless you are sure to whom you are exposing
  12763. the access to.
  12764. Defaults to @samp{"0777"}.
  12765. @end deftypevr
  12766. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-dir
  12767. The directory in which sockets will be found/created.
  12768. Defaults to @samp{"/var/run/libvirt"}.
  12769. @end deftypevr
  12770. @deftypevr {@code{libvirt-configuration} parameter} string auth-unix-ro
  12771. Authentication scheme for UNIX read-only sockets. By default socket
  12772. permissions allow anyone to connect
  12773. Defaults to @samp{"polkit"}.
  12774. @end deftypevr
  12775. @deftypevr {@code{libvirt-configuration} parameter} string auth-unix-rw
  12776. Authentication scheme for UNIX read-write sockets. By default socket
  12777. permissions only allow root. If PolicyKit support was compiled into
  12778. libvirt, the default will be to use 'polkit' auth.
  12779. Defaults to @samp{"polkit"}.
  12780. @end deftypevr
  12781. @deftypevr {@code{libvirt-configuration} parameter} string auth-tcp
  12782. Authentication scheme for TCP sockets. If you don't enable SASL, then
  12783. all TCP traffic is cleartext. Don't do this outside of a dev/test
  12784. scenario.
  12785. Defaults to @samp{"sasl"}.
  12786. @end deftypevr
  12787. @deftypevr {@code{libvirt-configuration} parameter} string auth-tls
  12788. Authentication scheme for TLS sockets. TLS sockets already have
  12789. encryption provided by the TLS layer, and limited authentication is done
  12790. by certificates.
  12791. It is possible to make use of any SASL authentication mechanism as well,
  12792. by using 'sasl' for this option
  12793. Defaults to @samp{"none"}.
  12794. @end deftypevr
  12795. @deftypevr {@code{libvirt-configuration} parameter} optional-list access-drivers
  12796. API access control scheme.
  12797. By default an authenticated user is allowed access to all APIs. Access
  12798. drivers can place restrictions on this.
  12799. Defaults to @samp{()}.
  12800. @end deftypevr
  12801. @deftypevr {@code{libvirt-configuration} parameter} string key-file
  12802. Server key file path. If set to an empty string, then no private key is
  12803. loaded.
  12804. Defaults to @samp{""}.
  12805. @end deftypevr
  12806. @deftypevr {@code{libvirt-configuration} parameter} string cert-file
  12807. Server key file path. If set to an empty string, then no certificate is
  12808. loaded.
  12809. Defaults to @samp{""}.
  12810. @end deftypevr
  12811. @deftypevr {@code{libvirt-configuration} parameter} string ca-file
  12812. Server key file path. If set to an empty string, then no CA certificate
  12813. is loaded.
  12814. Defaults to @samp{""}.
  12815. @end deftypevr
  12816. @deftypevr {@code{libvirt-configuration} parameter} string crl-file
  12817. Certificate revocation list path. If set to an empty string, then no
  12818. CRL is loaded.
  12819. Defaults to @samp{""}.
  12820. @end deftypevr
  12821. @deftypevr {@code{libvirt-configuration} parameter} boolean tls-no-sanity-cert
  12822. Disable verification of our own server certificates.
  12823. When libvirtd starts it performs some sanity checks against its own
  12824. certificates.
  12825. Defaults to @samp{#f}.
  12826. @end deftypevr
  12827. @deftypevr {@code{libvirt-configuration} parameter} boolean tls-no-verify-cert
  12828. Disable verification of client certificates.
  12829. Client certificate verification is the primary authentication mechanism.
  12830. Any client which does not present a certificate signed by the CA will be
  12831. rejected.
  12832. Defaults to @samp{#f}.
  12833. @end deftypevr
  12834. @deftypevr {@code{libvirt-configuration} parameter} optional-list tls-allowed-dn-list
  12835. Whitelist of allowed x509 Distinguished Name.
  12836. Defaults to @samp{()}.
  12837. @end deftypevr
  12838. @deftypevr {@code{libvirt-configuration} parameter} optional-list sasl-allowed-usernames
  12839. Whitelist of allowed SASL usernames. The format for username depends on
  12840. the SASL authentication mechanism.
  12841. Defaults to @samp{()}.
  12842. @end deftypevr
  12843. @deftypevr {@code{libvirt-configuration} parameter} string tls-priority
  12844. Override the compile time default TLS priority string. The default is
  12845. usually "NORMAL" unless overridden at build time. Only set this is it
  12846. is desired for libvirt to deviate from the global default settings.
  12847. Defaults to @samp{"NORMAL"}.
  12848. @end deftypevr
  12849. @deftypevr {@code{libvirt-configuration} parameter} integer max-clients
  12850. Maximum number of concurrent client connections to allow over all
  12851. sockets combined.
  12852. Defaults to @samp{5000}.
  12853. @end deftypevr
  12854. @deftypevr {@code{libvirt-configuration} parameter} integer max-queued-clients
  12855. Maximum length of queue of connections waiting to be accepted by the
  12856. daemon. Note, that some protocols supporting retransmission may obey
  12857. this so that a later reattempt at connection succeeds.
  12858. Defaults to @samp{1000}.
  12859. @end deftypevr
  12860. @deftypevr {@code{libvirt-configuration} parameter} integer max-anonymous-clients
  12861. Maximum length of queue of accepted but not yet authenticated clients.
  12862. Set this to zero to turn this feature off
  12863. Defaults to @samp{20}.
  12864. @end deftypevr
  12865. @deftypevr {@code{libvirt-configuration} parameter} integer min-workers
  12866. Number of workers to start up initially.
  12867. Defaults to @samp{5}.
  12868. @end deftypevr
  12869. @deftypevr {@code{libvirt-configuration} parameter} integer max-workers
  12870. Maximum number of worker threads.
  12871. If the number of active clients exceeds @code{min-workers}, then more
  12872. threads are spawned, up to max_workers limit. Typically you'd want
  12873. max_workers to equal maximum number of clients allowed.
  12874. Defaults to @samp{20}.
  12875. @end deftypevr
  12876. @deftypevr {@code{libvirt-configuration} parameter} integer prio-workers
  12877. Number of priority workers. If all workers from above pool are stuck,
  12878. some calls marked as high priority (notably domainDestroy) can be
  12879. executed in this pool.
  12880. Defaults to @samp{5}.
  12881. @end deftypevr
  12882. @deftypevr {@code{libvirt-configuration} parameter} integer max-requests
  12883. Total global limit on concurrent RPC calls.
  12884. Defaults to @samp{20}.
  12885. @end deftypevr
  12886. @deftypevr {@code{libvirt-configuration} parameter} integer max-client-requests
  12887. Limit on concurrent requests from a single client connection. To avoid
  12888. one client monopolizing the server this should be a small fraction of
  12889. the global max_requests and max_workers parameter.
  12890. Defaults to @samp{5}.
  12891. @end deftypevr
  12892. @deftypevr {@code{libvirt-configuration} parameter} integer admin-min-workers
  12893. Same as @code{min-workers} but for the admin interface.
  12894. Defaults to @samp{1}.
  12895. @end deftypevr
  12896. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-workers
  12897. Same as @code{max-workers} but for the admin interface.
  12898. Defaults to @samp{5}.
  12899. @end deftypevr
  12900. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-clients
  12901. Same as @code{max-clients} but for the admin interface.
  12902. Defaults to @samp{5}.
  12903. @end deftypevr
  12904. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-queued-clients
  12905. Same as @code{max-queued-clients} but for the admin interface.
  12906. Defaults to @samp{5}.
  12907. @end deftypevr
  12908. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-client-requests
  12909. Same as @code{max-client-requests} but for the admin interface.
  12910. Defaults to @samp{5}.
  12911. @end deftypevr
  12912. @deftypevr {@code{libvirt-configuration} parameter} integer log-level
  12913. Logging level. 4 errors, 3 warnings, 2 information, 1 debug.
  12914. Defaults to @samp{3}.
  12915. @end deftypevr
  12916. @deftypevr {@code{libvirt-configuration} parameter} string log-filters
  12917. Logging filters.
  12918. A filter allows to select a different logging level for a given category
  12919. of logs The format for a filter is one of:
  12920. @itemize @bullet
  12921. @item
  12922. x:name
  12923. @item
  12924. x:+name
  12925. @end itemize
  12926. where @code{name} is a string which is matched against the category
  12927. given in the @code{VIR_LOG_INIT()} at the top of each libvirt source
  12928. file, e.g., "remote", "qemu", or "util.json" (the name in the filter can
  12929. be a substring of the full category name, in order to match multiple
  12930. similar categories), the optional "+" prefix tells libvirt to log stack
  12931. trace for each message matching name, and @code{x} is the minimal level
  12932. where matching messages should be logged:
  12933. @itemize @bullet
  12934. @item
  12935. 1: DEBUG
  12936. @item
  12937. 2: INFO
  12938. @item
  12939. 3: WARNING
  12940. @item
  12941. 4: ERROR
  12942. @end itemize
  12943. Multiple filters can be defined in a single filters statement, they just
  12944. need to be separated by spaces.
  12945. Defaults to @samp{"3:remote 4:event"}.
  12946. @end deftypevr
  12947. @deftypevr {@code{libvirt-configuration} parameter} string log-outputs
  12948. Logging outputs.
  12949. An output is one of the places to save logging information The format
  12950. for an output can be:
  12951. @table @code
  12952. @item x:stderr
  12953. output goes to stderr
  12954. @item x:syslog:name
  12955. use syslog for the output and use the given name as the ident
  12956. @item x:file:file_path
  12957. output to a file, with the given filepath
  12958. @item x:journald
  12959. output to journald logging system
  12960. @end table
  12961. In all case the x prefix is the minimal level, acting as a filter
  12962. @itemize @bullet
  12963. @item
  12964. 1: DEBUG
  12965. @item
  12966. 2: INFO
  12967. @item
  12968. 3: WARNING
  12969. @item
  12970. 4: ERROR
  12971. @end itemize
  12972. Multiple outputs can be defined, they just need to be separated by
  12973. spaces.
  12974. Defaults to @samp{"3:stderr"}.
  12975. @end deftypevr
  12976. @deftypevr {@code{libvirt-configuration} parameter} integer audit-level
  12977. Allows usage of the auditing subsystem to be altered
  12978. @itemize @bullet
  12979. @item
  12980. 0: disable all auditing
  12981. @item
  12982. 1: enable auditing, only if enabled on host
  12983. @item
  12984. 2: enable auditing, and exit if disabled on host.
  12985. @end itemize
  12986. Defaults to @samp{1}.
  12987. @end deftypevr
  12988. @deftypevr {@code{libvirt-configuration} parameter} boolean audit-logging
  12989. Send audit messages via libvirt logging infrastructure.
  12990. Defaults to @samp{#f}.
  12991. @end deftypevr
  12992. @deftypevr {@code{libvirt-configuration} parameter} optional-string host-uuid
  12993. Host UUID. UUID must not have all digits be the same.
  12994. Defaults to @samp{""}.
  12995. @end deftypevr
  12996. @deftypevr {@code{libvirt-configuration} parameter} string host-uuid-source
  12997. Source to read host UUID.
  12998. @itemize @bullet
  12999. @item
  13000. @code{smbios}: fetch the UUID from @code{dmidecode -s system-uuid}
  13001. @item
  13002. @code{machine-id}: fetch the UUID from @code{/etc/machine-id}
  13003. @end itemize
  13004. If @code{dmidecode} does not provide a valid UUID a temporary UUID will
  13005. be generated.
  13006. Defaults to @samp{"smbios"}.
  13007. @end deftypevr
  13008. @deftypevr {@code{libvirt-configuration} parameter} integer keepalive-interval
  13009. A keepalive message is sent to a client after @code{keepalive_interval}
  13010. seconds of inactivity to check if the client is still responding. If
  13011. set to -1, libvirtd will never send keepalive requests; however clients
  13012. can still send them and the daemon will send responses.
  13013. Defaults to @samp{5}.
  13014. @end deftypevr
  13015. @deftypevr {@code{libvirt-configuration} parameter} integer keepalive-count
  13016. Maximum number of keepalive messages that are allowed to be sent to the
  13017. client without getting any response before the connection is considered
  13018. broken.
  13019. In other words, the connection is automatically closed approximately
  13020. after @code{keepalive_interval * (keepalive_count + 1)} seconds since
  13021. the last message received from the client. When @code{keepalive-count}
  13022. is set to 0, connections will be automatically closed after
  13023. @code{keepalive-interval} seconds of inactivity without sending any
  13024. keepalive messages.
  13025. Defaults to @samp{5}.
  13026. @end deftypevr
  13027. @deftypevr {@code{libvirt-configuration} parameter} integer admin-keepalive-interval
  13028. Same as above but for admin interface.
  13029. Defaults to @samp{5}.
  13030. @end deftypevr
  13031. @deftypevr {@code{libvirt-configuration} parameter} integer admin-keepalive-count
  13032. Same as above but for admin interface.
  13033. Defaults to @samp{5}.
  13034. @end deftypevr
  13035. @deftypevr {@code{libvirt-configuration} parameter} integer ovs-timeout
  13036. Timeout for Open vSwitch calls.
  13037. The @code{ovs-vsctl} utility is used for the configuration and its
  13038. timeout option is set by default to 5 seconds to avoid potential
  13039. infinite waits blocking libvirt.
  13040. Defaults to @samp{5}.
  13041. @end deftypevr
  13042. @c %end of autogenerated docs
  13043. @subsubheading Virtlog daemon
  13044. The virtlogd service is a server side daemon component of libvirt that is
  13045. used to manage logs from virtual machine consoles.
  13046. This daemon is not used directly by libvirt client applications, rather it
  13047. is called on their behalf by @code{libvirtd}. By maintaining the logs in a
  13048. standalone daemon, the main @code{libvirtd} daemon can be restarted without
  13049. risk of losing logs. The @code{virtlogd} daemon has the ability to re-exec()
  13050. itself upon receiving @code{SIGUSR1}, to allow live upgrades without downtime.
  13051. @deffn {Scheme Variable} virtlog-service-type
  13052. This is the type of the virtlog daemon.
  13053. Its value must be a @code{virtlog-configuration}.
  13054. @example
  13055. (service virtlog-service-type
  13056. (virtlog-configuration
  13057. (max-clients 1000)))
  13058. @end example
  13059. @end deffn
  13060. @deftypevr {@code{virtlog-configuration} parameter} integer log-level
  13061. Logging level. 4 errors, 3 warnings, 2 information, 1 debug.
  13062. Defaults to @samp{3}.
  13063. @end deftypevr
  13064. @deftypevr {@code{virtlog-configuration} parameter} string log-filters
  13065. Logging filters.
  13066. A filter allows to select a different logging level for a given category
  13067. of logs The format for a filter is one of:
  13068. @itemize @bullet
  13069. @item
  13070. x:name
  13071. @item
  13072. x:+name
  13073. @end itemize
  13074. where @code{name} is a string which is matched against the category
  13075. given in the @code{VIR_LOG_INIT()} at the top of each libvirt source
  13076. file, e.g., "remote", "qemu", or "util.json" (the name in the filter can
  13077. be a substring of the full category name, in order to match multiple
  13078. similar categories), the optional "+" prefix tells libvirt to log stack
  13079. trace for each message matching name, and @code{x} is the minimal level
  13080. where matching messages should be logged:
  13081. @itemize @bullet
  13082. @item
  13083. 1: DEBUG
  13084. @item
  13085. 2: INFO
  13086. @item
  13087. 3: WARNING
  13088. @item
  13089. 4: ERROR
  13090. @end itemize
  13091. Multiple filters can be defined in a single filters statement, they just
  13092. need to be separated by spaces.
  13093. Defaults to @samp{"3:remote 4:event"}.
  13094. @end deftypevr
  13095. @deftypevr {@code{virtlog-configuration} parameter} string log-outputs
  13096. Logging outputs.
  13097. An output is one of the places to save logging information The format
  13098. for an output can be:
  13099. @table @code
  13100. @item x:stderr
  13101. output goes to stderr
  13102. @item x:syslog:name
  13103. use syslog for the output and use the given name as the ident
  13104. @item x:file:file_path
  13105. output to a file, with the given filepath
  13106. @item x:journald
  13107. output to journald logging system
  13108. @end table
  13109. In all case the x prefix is the minimal level, acting as a filter
  13110. @itemize @bullet
  13111. @item
  13112. 1: DEBUG
  13113. @item
  13114. 2: INFO
  13115. @item
  13116. 3: WARNING
  13117. @item
  13118. 4: ERROR
  13119. @end itemize
  13120. Multiple outputs can be defined, they just need to be separated by
  13121. spaces.
  13122. Defaults to @samp{"3:stderr"}.
  13123. @end deftypevr
  13124. @deftypevr {@code{virtlog-configuration} parameter} integer max-clients
  13125. Maximum number of concurrent client connections to allow over all
  13126. sockets combined.
  13127. Defaults to @samp{1024}.
  13128. @end deftypevr
  13129. @deftypevr {@code{virtlog-configuration} parameter} integer max-size
  13130. Maximum file size before rolling over.
  13131. Defaults to @samp{2MB}
  13132. @end deftypevr
  13133. @deftypevr {@code{virtlog-configuration} parameter} integer max-backups
  13134. Maximum number of backup files to keep.
  13135. Defaults to @samp{3}
  13136. @end deftypevr
  13137. @node Miscellaneous Services
  13138. @subsubsection Miscellaneous Services
  13139. @cindex sysctl
  13140. @subsubheading System Control Service
  13141. The @code{(gnu services sysctl)} provides a service to configure kernel
  13142. parameters at boot.
  13143. @defvr {Scheme Variable} sysctl-service-type
  13144. The service type for @command{sysctl}, which modifies kernel parameters
  13145. under @file{/proc/sys/}. To enable IPv4 forwarding, it can be
  13146. instantiated as:
  13147. @example
  13148. (service sysctl-service-type
  13149. (sysctl-configuration
  13150. (settings '(("net.ipv4.ip_forward" . "1")))))
  13151. @end example
  13152. @end defvr
  13153. @deftp {Data Type} sysctl-configuration
  13154. The data type representing the configuration of @command{sysctl}.
  13155. @table @asis
  13156. @item @code{sysctl} (default: @code{(file-append procps "/sbin/sysctl"})
  13157. The @command{sysctl} executable to use.
  13158. @item @code{settings} (default: @code{'()})
  13159. An association list specifies kernel parameters and their values.
  13160. @end table
  13161. @end deftp
  13162. @cindex lirc
  13163. @subsubheading Lirc Service
  13164. The @code{(gnu services lirc)} module provides the following service.
  13165. @deffn {Scheme Procedure} lirc-service [#:lirc lirc] @
  13166. [#:device #f] [#:driver #f] [#:config-file #f] @
  13167. [#:extra-options '()]
  13168. Return a service that runs @url{http://www.lirc.org,LIRC}, a daemon that
  13169. decodes infrared signals from remote controls.
  13170. Optionally, @var{device}, @var{driver} and @var{config-file}
  13171. (configuration file name) may be specified. See @command{lircd} manual
  13172. for details.
  13173. Finally, @var{extra-options} is a list of additional command-line options
  13174. passed to @command{lircd}.
  13175. @end deffn
  13176. @cindex spice
  13177. @subsubheading Spice Service
  13178. The @code{(gnu services spice)} module provides the following service.
  13179. @deffn {Scheme Procedure} spice-vdagent-service [#:spice-vdagent]
  13180. Returns a service that runs @url{http://www.spice-space.org,VDAGENT}, a daemon
  13181. that enables sharing the clipboard with a vm and setting the guest display
  13182. resolution when the graphical console window resizes.
  13183. @end deffn
  13184. @subsubsection Dictionary Services
  13185. @cindex dictionary
  13186. The @code{(gnu services dict)} module provides the following service:
  13187. @deffn {Scheme Procedure} dicod-service [#:config (dicod-configuration)]
  13188. Return a service that runs the @command{dicod} daemon, an implementation
  13189. of DICT server (@pxref{Dicod,,, dico, GNU Dico Manual}).
  13190. The optional @var{config} argument specifies the configuration for
  13191. @command{dicod}, which should be a @code{<dicod-configuration>} object, by
  13192. default it serves the GNU Collaborative International Dictonary of English.
  13193. You can add @command{open localhost} to your @file{~/.dico} file to make
  13194. @code{localhost} the default server for @command{dico} client
  13195. (@pxref{Initialization File,,, dico, GNU Dico Manual}).
  13196. @end deffn
  13197. @deftp {Data Type} dicod-configuration
  13198. Data type representing the configuration of dicod.
  13199. @table @asis
  13200. @item @code{dico} (default: @var{dico})
  13201. Package object of the GNU Dico dictionary server.
  13202. @item @code{interfaces} (default: @var{'("localhost")})
  13203. This is the list of IP addresses and ports and possibly socket file
  13204. names to listen to (@pxref{Server Settings, @code{listen} directive,,
  13205. dico, GNU Dico Manual}).
  13206. @item @code{handlers} (default: @var{'()})
  13207. List of @code{<dicod-handler>} objects denoting handlers (module instances).
  13208. @item @code{databases} (default: @var{(list %dicod-database:gcide)})
  13209. List of @code{<dicod-database>} objects denoting dictionaries to be served.
  13210. @end table
  13211. @end deftp
  13212. @deftp {Data Type} dicod-handler
  13213. Data type representing a dictionary handler (module instance).
  13214. @table @asis
  13215. @item @code{name}
  13216. Name of the handler (module instance).
  13217. @item @code{module} (default: @var{#f})
  13218. Name of the dicod module of the handler (instance). If it is @code{#f},
  13219. the module has the same name as the handler.
  13220. (@pxref{Modules,,, dico, GNU Dico Manual}).
  13221. @item @code{options}
  13222. List of strings or gexps representing the arguments for the module handler
  13223. @end table
  13224. @end deftp
  13225. @deftp {Data Type} dicod-database
  13226. Data type representing a dictionary database.
  13227. @table @asis
  13228. @item @code{name}
  13229. Name of the database, will be used in DICT commands.
  13230. @item @code{handler}
  13231. Name of the dicod handler (module instance) used by this database
  13232. (@pxref{Handlers,,, dico, GNU Dico Manual}).
  13233. @item @code{complex?} (default: @var{#f})
  13234. Whether the database configuration complex. The complex configuration
  13235. will need a corresponding @code{<dicod-handler>} object, otherwise not.
  13236. @item @code{options}
  13237. List of strings or gexps representing the arguments for the database
  13238. (@pxref{Databases,,, dico, GNU Dico Manual}).
  13239. @end table
  13240. @end deftp
  13241. @defvr {Scheme Variable} %dicod-database:gcide
  13242. A @code{<dicod-database>} object serving the GNU Collaborative International
  13243. Dictionary of English using the @code{gcide} package.
  13244. @end defvr
  13245. The following is an example @code{dicod-service} configuration.
  13246. @example
  13247. (dicod-service #:config
  13248. (dicod-configuration
  13249. (handlers (list (dicod-handler
  13250. (name "wordnet")
  13251. (module "dictorg")
  13252. (options
  13253. (list #~(string-append "dbdir=" #$wordnet))))))
  13254. (databases (list (dicod-database
  13255. (name "wordnet")
  13256. (complex? #t)
  13257. (handler "wordnet")
  13258. (options '("database=wn")))
  13259. %dicod-database:gcide))))
  13260. @end example
  13261. @subsubsection Version Control
  13262. The @code{(gnu services version-control)} module provides the following services:
  13263. @subsubheading Git daemon service
  13264. @deffn {Scheme Procedure} git-daemon-service [#:config (git-daemon-configuration)]
  13265. Return a service that runs @command{git daemon}, a simple TCP server to
  13266. expose repositories over the Git protocol for anonymous access.
  13267. The optional @var{config} argument should be a
  13268. @code{<git-daemon-configuration>} object, by default it allows read-only
  13269. access to exported@footnote{By creating the magic file
  13270. "git-daemon-export-ok" in the repository directory.} repositories under
  13271. @file{/srv/git}.
  13272. @end deffn
  13273. @deftp {Data Type} git-daemon-configuration
  13274. Data type representing the configuration for @code{git-daemon-service}.
  13275. @table @asis
  13276. @item @code{package} (default: @var{git})
  13277. Package object of the Git distributed version control system.
  13278. @item @code{export-all?} (default: @var{#f})
  13279. Whether to allow access for all Git repositories, even if they do not
  13280. have the @file{git-daemon-export-ok} file.
  13281. @item @code{base-path} (default: @file{/srv/git})
  13282. Whether to remap all the path requests as relative to the given path.
  13283. If you run git daemon with @var{(base-path "/srv/git")} on example.com,
  13284. then if you later try to pull @code{git://example.com/hello.git}, git
  13285. daemon will interpret the path as @code{/srv/git/hello.git}.
  13286. @item @code{user-path} (default: @var{#f})
  13287. Whether to allow @code{~user} notation to be used in requests. When
  13288. specified with empty string, requests to @code{git://host/~alice/foo} is
  13289. taken as a request to access @code{foo} repository in the home directory
  13290. of user @code{alice}. If @var{(user-path "path")} is specified, the
  13291. same request is taken as a request to access @code{path/foo} repository
  13292. in the home directory of user @code{alice}.
  13293. @item @code{listen} (default: @var{'()})
  13294. Whether to listen on specific IP addresses or hostnames, defaults to
  13295. all.
  13296. @item @code{port} (default: @var{#f})
  13297. Whether to listen on an alternative port, which defaults to 9418.
  13298. @item @code{whitelist} (default: @var{'()})
  13299. If not empty, only allow access to this list of directories.
  13300. @item @code{extra-options} (default: @var{'()})
  13301. Extra options will be passed to @code{git daemon}, please run
  13302. @command{man git-daemon} for more information.
  13303. @end table
  13304. @end deftp
  13305. @subsubheading Cgit Service
  13306. @cindex Cgit service
  13307. @cindex Git, web interface
  13308. @uref{https://git.zx2c4.com/cgit/, Cgit} is a web frontend for Git
  13309. repositories written in C.
  13310. The following example will configure the service with default values.
  13311. By default, Cgit can be accessed on port 80 (@code{http://localhost:80}).
  13312. @example
  13313. (service nginx-service-type)
  13314. (service fcgiwrap-service-type)
  13315. (service cgit-service-type)
  13316. @end example
  13317. @deftp {Data Type} cgit-configuration
  13318. Data type representing the configuration of Cgit.
  13319. This type has the following parameters:
  13320. @table @asis
  13321. @item @code{config-file} (default: @code{(cgit-configuration-file)})
  13322. The configuration file to use for Cgit. This can be set to a
  13323. @dfn{cgit-configuration-file} record value, or any gexp
  13324. (@pxref{G-Expressions}).
  13325. For example, to instead use a local file, the @code{local-file} function
  13326. can be used:
  13327. @example
  13328. (service cgit-service-type
  13329. (cgit-configuration
  13330. (config-file (local-file "./my-cgitrc.conf"))))
  13331. @end example
  13332. @item @code{package} (default: @code{cgit})
  13333. The Cgit package to use.
  13334. @end table
  13335. @end deftp
  13336. @deftp {Data Type} cgit-configuration-file
  13337. Data type representing the configuration options for Cgit.
  13338. This type has the following parameters:
  13339. @table @asis
  13340. @item @code{css} (default: @code{"/share/cgit/cgit.css"})
  13341. URL which specifies the css document to include in all Cgit pages.
  13342. @item @code{logo} (default: @code{"/share/cgit/cgit.png"})
  13343. URL which specifies the source of an image which will be used as a logo
  13344. on all Cgit pages.
  13345. @item @code{virtual-root} (default: @code{"/"})
  13346. URL which, if specified, will be used as root for all Cgit links.
  13347. @item @code{repository-directory} (default: @code{"/srv/git"})
  13348. Name of the directory to scan for repositories.
  13349. @item @code{robots} (default: @code{(list "noindex" "nofollow")})
  13350. Text used as content for the ``robots'' meta-tag.
  13351. @end table
  13352. @end deftp
  13353. @node Setuid Programs
  13354. @subsection Setuid Programs
  13355. @cindex setuid programs
  13356. Some programs need to run with ``root'' privileges, even when they are
  13357. launched by unprivileged users. A notorious example is the
  13358. @command{passwd} program, which users can run to change their
  13359. password, and which needs to access the @file{/etc/passwd} and
  13360. @file{/etc/shadow} files---something normally restricted to root, for
  13361. obvious security reasons. To address that, these executables are
  13362. @dfn{setuid-root}, meaning that they always run with root privileges
  13363. (@pxref{How Change Persona,,, libc, The GNU C Library Reference Manual},
  13364. for more info about the setuid mechanism.)
  13365. The store itself @emph{cannot} contain setuid programs: that would be a
  13366. security issue since any user on the system can write derivations that
  13367. populate the store (@pxref{The Store}). Thus, a different mechanism is
  13368. used: instead of changing the setuid bit directly on files that are in
  13369. the store, we let the system administrator @emph{declare} which programs
  13370. should be setuid root.
  13371. The @code{setuid-programs} field of an @code{operating-system}
  13372. declaration contains a list of G-expressions denoting the names of
  13373. programs to be setuid-root (@pxref{Using the Configuration System}).
  13374. For instance, the @command{passwd} program, which is part of the Shadow
  13375. package, can be designated by this G-expression (@pxref{G-Expressions}):
  13376. @example
  13377. #~(string-append #$shadow "/bin/passwd")
  13378. @end example
  13379. A default set of setuid programs is defined by the
  13380. @code{%setuid-programs} variable of the @code{(gnu system)} module.
  13381. @defvr {Scheme Variable} %setuid-programs
  13382. A list of G-expressions denoting common programs that are setuid-root.
  13383. The list includes commands such as @command{passwd}, @command{ping},
  13384. @command{su}, and @command{sudo}.
  13385. @end defvr
  13386. Under the hood, the actual setuid programs are created in the
  13387. @file{/run/setuid-programs} directory at system activation time. The
  13388. files in this directory refer to the ``real'' binaries, which are in the
  13389. store.
  13390. @node X.509 Certificates
  13391. @subsection X.509 Certificates
  13392. @cindex HTTPS, certificates
  13393. @cindex X.509 certificates
  13394. @cindex TLS
  13395. Web servers available over HTTPS (that is, HTTP over the transport-layer
  13396. security mechanism, TLS) send client programs an @dfn{X.509 certificate}
  13397. that the client can then use to @emph{authenticate} the server. To do
  13398. that, clients verify that the server's certificate is signed by a
  13399. so-called @dfn{certificate authority} (CA). But to verify the CA's
  13400. signature, clients must have first acquired the CA's certificate.
  13401. Web browsers such as GNU@tie{}IceCat include their own set of CA
  13402. certificates, such that they are able to verify CA signatures
  13403. out-of-the-box.
  13404. However, most other programs that can talk HTTPS---@command{wget},
  13405. @command{git}, @command{w3m}, etc.---need to be told where CA
  13406. certificates can be found.
  13407. @cindex @code{nss-certs}
  13408. In GuixSD, this is done by adding a package that provides certificates
  13409. to the @code{packages} field of the @code{operating-system} declaration
  13410. (@pxref{operating-system Reference}). GuixSD includes one such package,
  13411. @code{nss-certs}, which is a set of CA certificates provided as part of
  13412. Mozilla's Network Security Services.
  13413. Note that it is @emph{not} part of @var{%base-packages}, so you need to
  13414. explicitly add it. The @file{/etc/ssl/certs} directory, which is where
  13415. most applications and libraries look for certificates by default, points
  13416. to the certificates installed globally.
  13417. Unprivileged users, including users of Guix on a foreign distro,
  13418. can also install their own certificate package in
  13419. their profile. A number of environment variables need to be defined so
  13420. that applications and libraries know where to find them. Namely, the
  13421. OpenSSL library honors the @code{SSL_CERT_DIR} and @code{SSL_CERT_FILE}
  13422. variables. Some applications add their own environment variables; for
  13423. instance, the Git version control system honors the certificate bundle
  13424. pointed to by the @code{GIT_SSL_CAINFO} environment variable. Thus, you
  13425. would typically run something like:
  13426. @example
  13427. $ guix package -i nss-certs
  13428. $ export SSL_CERT_DIR="$HOME/.guix-profile/etc/ssl/certs"
  13429. $ export SSL_CERT_FILE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt"
  13430. $ export GIT_SSL_CAINFO="$SSL_CERT_FILE"
  13431. @end example
  13432. As another example, R requires the @code{CURL_CA_BUNDLE} environment
  13433. variable to point to a certificate bundle, so you would have to run
  13434. something like this:
  13435. @example
  13436. $ guix package -i nss-certs
  13437. $ export CURL_CA_BUNDLE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt"
  13438. @end example
  13439. For other applications you may want to look up the required environment
  13440. variable in the relevant documentation.
  13441. @node Name Service Switch
  13442. @subsection Name Service Switch
  13443. @cindex name service switch
  13444. @cindex NSS
  13445. The @code{(gnu system nss)} module provides bindings to the
  13446. configuration file of the libc @dfn{name service switch} or @dfn{NSS}
  13447. (@pxref{NSS Configuration File,,, libc, The GNU C Library Reference
  13448. Manual}). In a nutshell, the NSS is a mechanism that allows libc to be
  13449. extended with new ``name'' lookup methods for system databases, which
  13450. includes host names, service names, user accounts, and more (@pxref{Name
  13451. Service Switch, System Databases and Name Service Switch,, libc, The GNU
  13452. C Library Reference Manual}).
  13453. The NSS configuration specifies, for each system database, which lookup
  13454. method is to be used, and how the various methods are chained
  13455. together---for instance, under which circumstances NSS should try the
  13456. next method in the list. The NSS configuration is given in the
  13457. @code{name-service-switch} field of @code{operating-system} declarations
  13458. (@pxref{operating-system Reference, @code{name-service-switch}}).
  13459. @cindex nss-mdns
  13460. @cindex .local, host name lookup
  13461. As an example, the declaration below configures the NSS to use the
  13462. @uref{http://0pointer.de/lennart/projects/nss-mdns/, @code{nss-mdns}
  13463. back-end}, which supports host name lookups over multicast DNS (mDNS)
  13464. for host names ending in @code{.local}:
  13465. @example
  13466. (name-service-switch
  13467. (hosts (list %files ;first, check /etc/hosts
  13468. ;; If the above did not succeed, try
  13469. ;; with 'mdns_minimal'.
  13470. (name-service
  13471. (name "mdns_minimal")
  13472. ;; 'mdns_minimal' is authoritative for
  13473. ;; '.local'. When it returns "not found",
  13474. ;; no need to try the next methods.
  13475. (reaction (lookup-specification
  13476. (not-found => return))))
  13477. ;; Then fall back to DNS.
  13478. (name-service
  13479. (name "dns"))
  13480. ;; Finally, try with the "full" 'mdns'.
  13481. (name-service
  13482. (name "mdns")))))
  13483. @end example
  13484. Do not worry: the @code{%mdns-host-lookup-nss} variable (see below)
  13485. contains this configuration, so you will not have to type it if all you
  13486. want is to have @code{.local} host lookup working.
  13487. Note that, in this case, in addition to setting the
  13488. @code{name-service-switch} of the @code{operating-system} declaration,
  13489. you also need to use @code{avahi-service} (@pxref{Networking Services,
  13490. @code{avahi-service}}), or @var{%desktop-services}, which includes it
  13491. (@pxref{Desktop Services}). Doing this makes @code{nss-mdns} accessible
  13492. to the name service cache daemon (@pxref{Base Services,
  13493. @code{nscd-service}}).
  13494. For convenience, the following variables provide typical NSS
  13495. configurations.
  13496. @defvr {Scheme Variable} %default-nss
  13497. This is the default name service switch configuration, a
  13498. @code{name-service-switch} object.
  13499. @end defvr
  13500. @defvr {Scheme Variable} %mdns-host-lookup-nss
  13501. This is the name service switch configuration with support for host name
  13502. lookup over multicast DNS (mDNS) for host names ending in @code{.local}.
  13503. @end defvr
  13504. The reference for name service switch configuration is given below. It
  13505. is a direct mapping of the configuration file format of the C library , so
  13506. please refer to the C library manual for more information (@pxref{NSS
  13507. Configuration File,,, libc, The GNU C Library Reference Manual}).
  13508. Compared to the configuration file format of libc NSS, it has the advantage
  13509. not only of adding this warm parenthetic feel that we like, but also
  13510. static checks: you will know about syntax errors and typos as soon as you
  13511. run @command{guix system}.
  13512. @deftp {Data Type} name-service-switch
  13513. This is the data type representation the configuration of libc's name
  13514. service switch (NSS). Each field below represents one of the supported
  13515. system databases.
  13516. @table @code
  13517. @item aliases
  13518. @itemx ethers
  13519. @itemx group
  13520. @itemx gshadow
  13521. @itemx hosts
  13522. @itemx initgroups
  13523. @itemx netgroup
  13524. @itemx networks
  13525. @itemx password
  13526. @itemx public-key
  13527. @itemx rpc
  13528. @itemx services
  13529. @itemx shadow
  13530. The system databases handled by the NSS. Each of these fields must be a
  13531. list of @code{<name-service>} objects (see below).
  13532. @end table
  13533. @end deftp
  13534. @deftp {Data Type} name-service
  13535. This is the data type representing an actual name service and the
  13536. associated lookup action.
  13537. @table @code
  13538. @item name
  13539. A string denoting the name service (@pxref{Services in the NSS
  13540. configuration,,, libc, The GNU C Library Reference Manual}).
  13541. Note that name services listed here must be visible to nscd. This is
  13542. achieved by passing the @code{#:name-services} argument to
  13543. @code{nscd-service} the list of packages providing the needed name
  13544. services (@pxref{Base Services, @code{nscd-service}}).
  13545. @item reaction
  13546. An action specified using the @code{lookup-specification} macro
  13547. (@pxref{Actions in the NSS configuration,,, libc, The GNU C Library
  13548. Reference Manual}). For example:
  13549. @example
  13550. (lookup-specification (unavailable => continue)
  13551. (success => return))
  13552. @end example
  13553. @end table
  13554. @end deftp
  13555. @node Initial RAM Disk
  13556. @subsection Initial RAM Disk
  13557. @cindex initrd
  13558. @cindex initial RAM disk
  13559. For bootstrapping purposes, the Linux-Libre kernel is passed an
  13560. @dfn{initial RAM disk}, or @dfn{initrd}. An initrd contains a temporary
  13561. root file system as well as an initialization script. The latter is
  13562. responsible for mounting the real root file system, and for loading any
  13563. kernel modules that may be needed to achieve that.
  13564. The @code{initrd} field of an @code{operating-system} declaration allows
  13565. you to specify which initrd you would like to use. The @code{(gnu
  13566. system linux-initrd)} module provides three ways to build an initrd: the
  13567. high-level @code{base-initrd} procedure and the low-level
  13568. @code{raw-initrd} and @code{expression->initrd} procedures.
  13569. The @code{base-initrd} procedure is intended to cover most common uses.
  13570. For example, if you want to add a bunch of kernel modules to be loaded
  13571. at boot time, you can define the @code{initrd} field of the operating
  13572. system declaration like this:
  13573. @example
  13574. (initrd (lambda (file-systems . rest)
  13575. ;; Create a standard initrd that has modules "foo.ko"
  13576. ;; and "bar.ko", as well as their dependencies, in
  13577. ;; addition to the modules available by default.
  13578. (apply base-initrd file-systems
  13579. #:extra-modules '("foo" "bar")
  13580. rest)))
  13581. @end example
  13582. The @code{base-initrd} procedure also handles common use cases that
  13583. involves using the system as a QEMU guest, or as a ``live'' system with
  13584. volatile root file system.
  13585. The @code{base-initrd} procedure is built from @code{raw-initrd} procedure.
  13586. Unlike @code{base-initrd}, @code{raw-initrd} doesn't do anything high-level,
  13587. such as trying to guess which kernel modules and packages should be included
  13588. to the initrd. An example use of @code{raw-initrd} is when a user has
  13589. a custom Linux kernel configuration and default kernel modules included by
  13590. @code{base-initrd} are not available.
  13591. The initial RAM disk produced by @code{base-initrd} or @code{raw-initrd}
  13592. honors several options passed on the Linux kernel command line
  13593. (that is, arguments passed @i{via} the @code{linux} command of GRUB, or the
  13594. @code{-append} option of QEMU), notably:
  13595. @table @code
  13596. @item --load=@var{boot}
  13597. Tell the initial RAM disk to load @var{boot}, a file containing a Scheme
  13598. program, once it has mounted the root file system.
  13599. GuixSD uses this option to yield control to a boot program that runs the
  13600. service activation programs and then spawns the GNU@tie{}Shepherd, the
  13601. initialization system.
  13602. @item --root=@var{root}
  13603. Mount @var{root} as the root file system. @var{root} can be a
  13604. device name like @code{/dev/sda1}, a partition label, or a partition
  13605. UUID.
  13606. @item --system=@var{system}
  13607. Have @file{/run/booted-system} and @file{/run/current-system} point to
  13608. @var{system}.
  13609. @item modprobe.blacklist=@var{modules}@dots{}
  13610. @cindex module, black-listing
  13611. @cindex black list, of kernel modules
  13612. Instruct the initial RAM disk as well as the @command{modprobe} command
  13613. (from the kmod package) to refuse to load @var{modules}. @var{modules}
  13614. must be a comma-separated list of module names---e.g.,
  13615. @code{usbkbd,9pnet}.
  13616. @item --repl
  13617. Start a read-eval-print loop (REPL) from the initial RAM disk before it
  13618. tries to load kernel modules and to mount the root file system. Our
  13619. marketing team calls it @dfn{boot-to-Guile}. The Schemer in you will
  13620. love it. @xref{Using Guile Interactively,,, guile, GNU Guile Reference
  13621. Manual}, for more information on Guile's REPL.
  13622. @end table
  13623. Now that you know all the features that initial RAM disks produced by
  13624. @code{base-initrd} and @code{raw-initrd} provide,
  13625. here is how to use it and customize it further.
  13626. @cindex initrd
  13627. @cindex initial RAM disk
  13628. @deffn {Monadic Procedure} raw-initrd @var{file-systems} @
  13629. [#:linux-modules '()] [#:mapped-devices '()] @
  13630. [#:helper-packages '()] [#:qemu-networking? #f] [#:volatile-root? #f]
  13631. Return a monadic derivation that builds a raw initrd. @var{file-systems} is
  13632. a list of file systems to be mounted by the initrd, possibly in addition to
  13633. the root file system specified on the kernel command line via @code{--root}.
  13634. @var{linux-modules} is a list of kernel modules to be loaded at boot time.
  13635. @var{mapped-devices} is a list of device mappings to realize before
  13636. @var{file-systems} are mounted (@pxref{Mapped Devices}).
  13637. @var{helper-packages} is a list of packages to be copied in the initrd. It may
  13638. include @code{e2fsck/static} or other packages needed by the initrd to check
  13639. root partition.
  13640. When @var{qemu-networking?} is true, set up networking with the standard QEMU
  13641. parameters. When @var{virtio?} is true, load additional modules so that the
  13642. initrd can be used as a QEMU guest with para-virtualized I/O drivers.
  13643. When @var{volatile-root?} is true, the root file system is writable but any changes
  13644. to it are lost.
  13645. @end deffn
  13646. @deffn {Monadic Procedure} base-initrd @var{file-systems} @
  13647. [#:mapped-devices '()] [#:qemu-networking? #f] [#:volatile-root? #f]@
  13648. [#:virtio? #t] [#:extra-modules '()]
  13649. Return a monadic derivation that builds a generic initrd. @var{file-systems} is
  13650. a list of file systems to be mounted by the initrd like for @code{raw-initrd}.
  13651. @var{mapped-devices}, @var{qemu-networking?} and @var{volatile-root?}
  13652. also behaves as in @code{raw-initrd}.
  13653. When @var{virtio?} is true, load additional modules so that the
  13654. initrd can be used as a QEMU guest with para-virtualized I/O drivers.
  13655. The initrd is automatically populated with all the kernel modules necessary
  13656. for @var{file-systems} and for the given options. However, additional kernel
  13657. modules can be listed in @var{extra-modules}. They will be added to the initrd, and
  13658. loaded at boot time in the order in which they appear.
  13659. @end deffn
  13660. Needless to say, the initrds we produce and use embed a
  13661. statically-linked Guile, and the initialization program is a Guile
  13662. program. That gives a lot of flexibility. The
  13663. @code{expression->initrd} procedure builds such an initrd, given the
  13664. program to run in that initrd.
  13665. @deffn {Monadic Procedure} expression->initrd @var{exp} @
  13666. [#:guile %guile-static-stripped] [#:name "guile-initrd"]
  13667. Return a derivation that builds a Linux initrd (a gzipped cpio archive)
  13668. containing @var{guile} and that evaluates @var{exp}, a G-expression,
  13669. upon booting. All the derivations referenced by @var{exp} are
  13670. automatically copied to the initrd.
  13671. @end deffn
  13672. @node Bootloader Configuration
  13673. @subsection Bootloader Configuration
  13674. @cindex bootloader
  13675. @cindex boot loader
  13676. The operating system supports multiple bootloaders. The bootloader is
  13677. configured using @code{bootloader-configuration} declaration. All the
  13678. fields of this structure are bootloader agnostic except for one field,
  13679. @code{bootloader} that indicates the bootloader to be configured and
  13680. installed.
  13681. Some of the bootloaders do not honor every field of
  13682. @code{bootloader-configuration}. For instance, the extlinux
  13683. bootloader does not support themes and thus ignores the @code{theme}
  13684. field.
  13685. @deftp {Data Type} bootloader-configuration
  13686. The type of a bootloader configuration declaration.
  13687. @table @asis
  13688. @item @code{bootloader}
  13689. @cindex EFI, bootloader
  13690. @cindex UEFI, bootloader
  13691. @cindex BIOS, bootloader
  13692. The bootloader to use, as a @code{bootloader} object. For now
  13693. @code{grub-bootloader}, @code{grub-efi-bootloader},
  13694. @code{extlinux-bootloader} and @code{u-boot-bootloader} are supported.
  13695. @code{grub-efi-bootloader} allows to boot on modern systems using the
  13696. @dfn{Unified Extensible Firmware Interface} (UEFI).
  13697. Available bootloaders are described in @code{(gnu bootloader @dots{})}
  13698. modules.
  13699. @item @code{target}
  13700. This is a string denoting the target onto which to install the
  13701. bootloader. The exact interpretation depends on the bootloader in
  13702. question; for @code{grub-bootloader}, for example, it should be a device
  13703. name understood by the bootloader @command{installer} command, such as
  13704. @code{/dev/sda} or @code{(hd0)} (for GRUB, @pxref{Invoking
  13705. grub-install,,, grub, GNU GRUB Manual}). For
  13706. @code{grub-efi-bootloader}, it should be the path to a mounted EFI file
  13707. system.
  13708. @item @code{menu-entries} (default: @code{()})
  13709. A possibly empty list of @code{menu-entry} objects (see below), denoting
  13710. entries to appear in the bootloader menu, in addition to the current
  13711. system entry and the entry pointing to previous system generations.
  13712. generations.
  13713. @item @code{default-entry} (default: @code{0})
  13714. The index of the default boot menu entry. Index 0 is for the entry of the
  13715. current system.
  13716. @item @code{timeout} (default: @code{5})
  13717. The number of seconds to wait for keyboard input before booting. Set to
  13718. 0 to boot immediately, and to -1 to wait indefinitely.
  13719. @item @code{theme} (default: @var{#f})
  13720. The bootloader theme object describing the theme to use. If no theme
  13721. is provided, some bootloaders might use a default theme, that's true
  13722. for GRUB.
  13723. @item @code{terminal-outputs} (default: @code{'gfxterm})
  13724. The output terminals used for the bootloader boot menu, as a list of
  13725. symbols. GRUB accepts the values: @code{console}, @code{serial},
  13726. @code{serial_@{0-3@}}, @code{gfxterm}, @code{vga_text},
  13727. @code{mda_text}, @code{morse}, and @code{pkmodem}. This field
  13728. corresponds to the GRUB variable GRUB_TERMINAL_OUTPUT (@pxref{Simple
  13729. configuration,,, grub,GNU GRUB manual}).
  13730. @item @code{terminal-inputs} (default: @code{'()})
  13731. The input terminals used for the bootloader boot menu, as a list of
  13732. symbols. For GRUB, the default is the native platform terminal as
  13733. determined at run-time. GRUB accepts the values: @code{console},
  13734. @code{serial}, @code{serial_@{0-3@}}, @code{at_keyboard}, and
  13735. @code{usb_keyboard}. This field corresponds to the GRUB variable
  13736. GRUB_TERMINAL_INPUT (@pxref{Simple configuration,,, grub,GNU GRUB
  13737. manual}).
  13738. @item @code{serial-unit} (default: @code{#f})
  13739. The serial unit used by the bootloader, as an integer from 0 to 3.
  13740. For GRUB it is choosen at run-time; currently GRUB chooses 0, which
  13741. corresponds to COM1 (@pxref{Serial terminal,,, grub,GNU GRUB manual}).
  13742. @item @code{serial-speed} (default: @code{#f})
  13743. The speed of the serial interface, as an integer. For GRUB, the
  13744. default value is chosen at run-time; currently GRUB chooses
  13745. 9600@tie{}bps (@pxref{Serial terminal,,, grub,GNU GRUB manual}).
  13746. @end table
  13747. @end deftp
  13748. @cindex dual boot
  13749. @cindex boot menu
  13750. Should you want to list additional boot menu entries @i{via} the
  13751. @code{menu-entries} field above, you will need to create them with the
  13752. @code{menu-entry} form. For example, imagine you want to be able to
  13753. boot another distro (hard to imagine!), you can define a menu entry
  13754. along these lines:
  13755. @example
  13756. (menu-entry
  13757. (label "The Other Distro")
  13758. (linux "/boot/old/vmlinux-2.6.32")
  13759. (linux-arguments '("root=/dev/sda2"))
  13760. (initrd "/boot/old/initrd"))
  13761. @end example
  13762. Details below.
  13763. @deftp {Data Type} menu-entry
  13764. The type of an entry in the bootloader menu.
  13765. @table @asis
  13766. @item @code{label}
  13767. The label to show in the menu---e.g., @code{"GNU"}.
  13768. @item @code{linux}
  13769. The Linux kernel image to boot, for example:
  13770. @example
  13771. (file-append linux-libre "/bzImage")
  13772. @end example
  13773. For GRUB, it is also possible to specify a device explicitly in the
  13774. file path using GRUB's device naming convention (@pxref{Naming
  13775. convention,,, grub, GNU GRUB manual}), for example:
  13776. @example
  13777. "(hd0,msdos1)/boot/vmlinuz"
  13778. @end example
  13779. If the device is specified explicitly as above, then the @code{device}
  13780. field is ignored entirely.
  13781. @item @code{linux-arguments} (default: @code{()})
  13782. The list of extra Linux kernel command-line arguments---e.g.,
  13783. @code{("console=ttyS0")}.
  13784. @item @code{initrd}
  13785. A G-Expression or string denoting the file name of the initial RAM disk
  13786. to use (@pxref{G-Expressions}).
  13787. @item @code{device} (default: @code{#f})
  13788. The device where the kernel and initrd are to be found---i.e., for GRUB,
  13789. @dfn{root} for this menu entry (@pxref{root,,, grub, GNU GRUB manual}).
  13790. This may be a file system label (a string), a file system UUID (a
  13791. bytevector, @pxref{File Systems}), or @code{#f}, in which case
  13792. the bootloader will search the device containing the file specified by
  13793. the @code{linux} field (@pxref{search,,, grub, GNU GRUB manual}). It
  13794. must @emph{not} be an OS device name such as @file{/dev/sda1}.
  13795. @end table
  13796. @end deftp
  13797. @c FIXME: Write documentation once it's stable.
  13798. Fow now only GRUB has theme support. GRUB themes are created using
  13799. the @code{grub-theme} form, which is not documented yet.
  13800. @defvr {Scheme Variable} %default-theme
  13801. This is the default GRUB theme used by the operating system if no
  13802. @code{theme} field is specified in @code{bootloader-configuration}
  13803. record.
  13804. It comes with a fancy background image displaying the GNU and Guix
  13805. logos.
  13806. @end defvr
  13807. @node Invoking guix system
  13808. @subsection Invoking @code{guix system}
  13809. Once you have written an operating system declaration as seen in the
  13810. previous section, it can be @dfn{instantiated} using the @command{guix
  13811. system} command. The synopsis is:
  13812. @example
  13813. guix system @var{options}@dots{} @var{action} @var{file}
  13814. @end example
  13815. @var{file} must be the name of a file containing an
  13816. @code{operating-system} declaration. @var{action} specifies how the
  13817. operating system is instantiated. Currently the following values are
  13818. supported:
  13819. @table @code
  13820. @item search
  13821. Display available service type definitions that match the given regular
  13822. expressions, sorted by relevance:
  13823. @example
  13824. $ guix system search console font
  13825. name: console-fonts
  13826. location: gnu/services/base.scm:729:2
  13827. extends: shepherd-root
  13828. description: Install the given fonts on the specified ttys (fonts are
  13829. + per virtual console on GNU/Linux). The value of this service is a list
  13830. + of tty/font pairs like:
  13831. +
  13832. + '(("tty1" . "LatGrkCyr-8x16"))
  13833. relevance: 20
  13834. name: mingetty
  13835. location: gnu/services/base.scm:1048:2
  13836. extends: shepherd-root
  13837. description: Provide console login using the `mingetty' program.
  13838. relevance: 2
  13839. name: login
  13840. location: gnu/services/base.scm:775:2
  13841. extends: pam
  13842. description: Provide a console log-in service as specified by its
  13843. + configuration value, a `login-configuration' object.
  13844. relevance: 2
  13845. @dots{}
  13846. @end example
  13847. As for @command{guix package --search}, the result is written in
  13848. @code{recutils} format, which makes it easy to filter the output
  13849. (@pxref{Top, GNU recutils databases,, recutils, GNU recutils manual}).
  13850. @item reconfigure
  13851. Build the operating system described in @var{file}, activate it, and
  13852. switch to it@footnote{This action (and the related actions
  13853. @code{switch-generation} and @code{roll-back}) are usable only on
  13854. systems already running GuixSD.}.
  13855. This effects all the configuration specified in @var{file}: user
  13856. accounts, system services, global package list, setuid programs, etc.
  13857. The command starts system services specified in @var{file} that are not
  13858. currently running; if a service is currently running, it does not
  13859. attempt to upgrade it since this would not be possible without stopping it
  13860. first.
  13861. This command creates a new generation whose number is one greater than
  13862. the current generation (as reported by @command{guix system
  13863. list-generations}). If that generation already exists, it will be
  13864. overwritten. This behavior mirrors that of @command{guix package}
  13865. (@pxref{Invoking guix package}).
  13866. It also adds a bootloader menu entry for the new OS configuration,
  13867. ---unless @option{--no-bootloader} is passed. For GRUB, it moves
  13868. entries for older configurations to a submenu, allowing you to choose
  13869. an older system generation at boot time should you need it.
  13870. @quotation Note
  13871. @c The paragraph below refers to the problem discussed at
  13872. @c <http://lists.gnu.org/archive/html/guix-devel/2014-08/msg00057.html>.
  13873. It is highly recommended to run @command{guix pull} once before you run
  13874. @command{guix system reconfigure} for the first time (@pxref{Invoking
  13875. guix pull}). Failing to do that you would see an older version of Guix
  13876. once @command{reconfigure} has completed.
  13877. @end quotation
  13878. @item switch-generation
  13879. @cindex generations
  13880. Switch to an existing system generation. This action atomically
  13881. switches the system profile to the specified system generation. It
  13882. also rearranges the system's existing bootloader menu entries. It
  13883. makes the menu entry for the specified system generation the default,
  13884. and it moves the entries for the other generatiors to a submenu, if
  13885. supported by the bootloader being used. The next time the system
  13886. boots, it will use the specified system generation.
  13887. The bootloader itself is not being reinstalled when using this
  13888. command. Thus, the installed bootloader is used with an updated
  13889. configuration file.
  13890. The target generation can be specified explicitly by its generation
  13891. number. For example, the following invocation would switch to system
  13892. generation 7:
  13893. @example
  13894. guix system switch-generation 7
  13895. @end example
  13896. The target generation can also be specified relative to the current
  13897. generation with the form @code{+N} or @code{-N}, where @code{+3} means
  13898. ``3 generations ahead of the current generation,'' and @code{-1} means
  13899. ``1 generation prior to the current generation.'' When specifying a
  13900. negative value such as @code{-1}, you must precede it with @code{--} to
  13901. prevent it from being parsed as an option. For example:
  13902. @example
  13903. guix system switch-generation -- -1
  13904. @end example
  13905. Currently, the effect of invoking this action is @emph{only} to switch
  13906. the system profile to an existing generation and rearrange the
  13907. bootloader menu entries. To actually start using the target system
  13908. generation, you must reboot after running this action. In the future,
  13909. it will be updated to do the same things as @command{reconfigure},
  13910. like activating and deactivating services.
  13911. This action will fail if the specified generation does not exist.
  13912. @item roll-back
  13913. @cindex rolling back
  13914. Switch to the preceding system generation. The next time the system
  13915. boots, it will use the preceding system generation. This is the inverse
  13916. of @command{reconfigure}, and it is exactly the same as invoking
  13917. @command{switch-generation} with an argument of @code{-1}.
  13918. Currently, as with @command{switch-generation}, you must reboot after
  13919. running this action to actually start using the preceding system
  13920. generation.
  13921. @item build
  13922. Build the derivation of the operating system, which includes all the
  13923. configuration files and programs needed to boot and run the system.
  13924. This action does not actually install anything.
  13925. @item init
  13926. Populate the given directory with all the files necessary to run the
  13927. operating system specified in @var{file}. This is useful for first-time
  13928. installations of GuixSD. For instance:
  13929. @example
  13930. guix system init my-os-config.scm /mnt
  13931. @end example
  13932. copies to @file{/mnt} all the store items required by the configuration
  13933. specified in @file{my-os-config.scm}. This includes configuration
  13934. files, packages, and so on. It also creates other essential files
  13935. needed for the system to operate correctly---e.g., the @file{/etc},
  13936. @file{/var}, and @file{/run} directories, and the @file{/bin/sh} file.
  13937. This command also installs bootloader on the target specified in
  13938. @file{my-os-config}, unless the @option{--no-bootloader} option was
  13939. passed.
  13940. @item vm
  13941. @cindex virtual machine
  13942. @cindex VM
  13943. @anchor{guix system vm}
  13944. Build a virtual machine that contains the operating system declared in
  13945. @var{file}, and return a script to run that virtual machine (VM).
  13946. Arguments given to the script are passed to QEMU as in the example
  13947. below, which enables networking and requests 1@tie{}GiB of RAM for the
  13948. emulated machine:
  13949. @example
  13950. $ /gnu/store/@dots{}-run-vm.sh -m 1024 -net user
  13951. @end example
  13952. The VM shares its store with the host system.
  13953. Additional file systems can be shared between the host and the VM using
  13954. the @code{--share} and @code{--expose} command-line options: the former
  13955. specifies a directory to be shared with write access, while the latter
  13956. provides read-only access to the shared directory.
  13957. The example below creates a VM in which the user's home directory is
  13958. accessible read-only, and where the @file{/exchange} directory is a
  13959. read-write mapping of @file{$HOME/tmp} on the host:
  13960. @example
  13961. guix system vm my-config.scm \
  13962. --expose=$HOME --share=$HOME/tmp=/exchange
  13963. @end example
  13964. On GNU/Linux, the default is to boot directly to the kernel; this has
  13965. the advantage of requiring only a very tiny root disk image since the
  13966. store of the host can then be mounted.
  13967. The @code{--full-boot} option forces a complete boot sequence, starting
  13968. with the bootloader. This requires more disk space since a root image
  13969. containing at least the kernel, initrd, and bootloader data files must
  13970. be created. The @code{--image-size} option can be used to specify the
  13971. size of the image.
  13972. @item vm-image
  13973. @itemx disk-image
  13974. Return a virtual machine or disk image of the operating system declared
  13975. in @var{file} that stands alone. By default, @command{guix system}
  13976. estimates the size of the image needed to store the system, but you can
  13977. use the @option{--image-size} option to specify a value.
  13978. You can specify the root file system type by using the
  13979. @option{--file-system-type} option. It defaults to @code{ext4}.
  13980. When using @code{vm-image}, the returned image is in qcow2 format, which
  13981. the QEMU emulator can efficiently use. @xref{Running GuixSD in a VM},
  13982. for more information on how to run the image in a virtual machine.
  13983. When using @code{disk-image}, a raw disk image is produced; it can be
  13984. copied as is to a USB stick, for instance. Assuming @code{/dev/sdc} is
  13985. the device corresponding to a USB stick, one can copy the image to it
  13986. using the following command:
  13987. @example
  13988. # dd if=$(guix system disk-image my-os.scm) of=/dev/sdc
  13989. @end example
  13990. @item container
  13991. Return a script to run the operating system declared in @var{file}
  13992. within a container. Containers are a set of lightweight isolation
  13993. mechanisms provided by the kernel Linux-libre. Containers are
  13994. substantially less resource-demanding than full virtual machines since
  13995. the kernel, shared objects, and other resources can be shared with the
  13996. host system; this also means they provide thinner isolation.
  13997. Currently, the script must be run as root in order to support more than
  13998. a single user and group. The container shares its store with the host
  13999. system.
  14000. As with the @code{vm} action (@pxref{guix system vm}), additional file
  14001. systems to be shared between the host and container can be specified
  14002. using the @option{--share} and @option{--expose} options:
  14003. @example
  14004. guix system container my-config.scm \
  14005. --expose=$HOME --share=$HOME/tmp=/exchange
  14006. @end example
  14007. @quotation Note
  14008. This option requires Linux-libre 3.19 or newer.
  14009. @end quotation
  14010. @end table
  14011. @var{options} can contain any of the common build options (@pxref{Common
  14012. Build Options}). In addition, @var{options} can contain one of the
  14013. following:
  14014. @table @option
  14015. @item --system=@var{system}
  14016. @itemx -s @var{system}
  14017. Attempt to build for @var{system} instead of the host system type.
  14018. This works as per @command{guix build} (@pxref{Invoking guix build}).
  14019. @item --derivation
  14020. @itemx -d
  14021. Return the derivation file name of the given operating system without
  14022. building anything.
  14023. @item --file-system-type=@var{type}
  14024. @itemx -t @var{type}
  14025. For the @code{disk-image} action, create a file system of the given
  14026. @var{type} on the image.
  14027. When this option is omitted, @command{guix system} uses @code{ext4}.
  14028. @cindex ISO-9660 format
  14029. @cindex CD image format
  14030. @cindex DVD image format
  14031. @code{--file-system-type=iso9660} produces an ISO-9660 image, suitable
  14032. for burning on CDs and DVDs.
  14033. @item --image-size=@var{size}
  14034. For the @code{vm-image} and @code{disk-image} actions, create an image
  14035. of the given @var{size}. @var{size} may be a number of bytes, or it may
  14036. include a unit as a suffix (@pxref{Block size, size specifications,,
  14037. coreutils, GNU Coreutils}).
  14038. When this option is omitted, @command{guix system} computes an estimate
  14039. of the image size as a function of the size of the system declared in
  14040. @var{file}.
  14041. @item --root=@var{file}
  14042. @itemx -r @var{file}
  14043. Make @var{file} a symlink to the result, and register it as a garbage
  14044. collector root.
  14045. @item --on-error=@var{strategy}
  14046. Apply @var{strategy} when an error occurs when reading @var{file}.
  14047. @var{strategy} may be one of the following:
  14048. @table @code
  14049. @item nothing-special
  14050. Report the error concisely and exit. This is the default strategy.
  14051. @item backtrace
  14052. Likewise, but also display a backtrace.
  14053. @item debug
  14054. Report the error and enter Guile's debugger. From there, you can run
  14055. commands such as @code{,bt} to get a backtrace, @code{,locals} to
  14056. display local variable values, and more generally inspect the state of the
  14057. program. @xref{Debug Commands,,, guile, GNU Guile Reference Manual}, for
  14058. a list of available debugging commands.
  14059. @end table
  14060. @end table
  14061. @quotation Note
  14062. All the actions above, except @code{build} and @code{init},
  14063. can use KVM support in the Linux-libre kernel. Specifically, if the
  14064. machine has hardware virtualization support, the corresponding
  14065. KVM kernel module should be loaded, and the @file{/dev/kvm} device node
  14066. must exist and be readable and writable by the user and by the
  14067. build users of the daemon (@pxref{Build Environment Setup}).
  14068. @end quotation
  14069. Once you have built, configured, re-configured, and re-re-configured
  14070. your GuixSD installation, you may find it useful to list the operating
  14071. system generations available on disk---and that you can choose from the
  14072. bootloader boot menu:
  14073. @table @code
  14074. @item list-generations
  14075. List a summary of each generation of the operating system available on
  14076. disk, in a human-readable way. This is similar to the
  14077. @option{--list-generations} option of @command{guix package}
  14078. (@pxref{Invoking guix package}).
  14079. Optionally, one can specify a pattern, with the same syntax that is used
  14080. in @command{guix package --list-generations}, to restrict the list of
  14081. generations displayed. For instance, the following command displays
  14082. generations that are up to 10 days old:
  14083. @example
  14084. $ guix system list-generations 10d
  14085. @end example
  14086. @end table
  14087. The @command{guix system} command has even more to offer! The following
  14088. sub-commands allow you to visualize how your system services relate to
  14089. each other:
  14090. @anchor{system-extension-graph}
  14091. @table @code
  14092. @item extension-graph
  14093. Emit in Dot/Graphviz format to standard output the @dfn{service
  14094. extension graph} of the operating system defined in @var{file}
  14095. (@pxref{Service Composition}, for more information on service
  14096. extensions.)
  14097. The command:
  14098. @example
  14099. $ guix system extension-graph @var{file} | dot -Tpdf > services.pdf
  14100. @end example
  14101. produces a PDF file showing the extension relations among services.
  14102. @anchor{system-shepherd-graph}
  14103. @item shepherd-graph
  14104. Emit in Dot/Graphviz format to standard output the @dfn{dependency
  14105. graph} of shepherd services of the operating system defined in
  14106. @var{file}. @xref{Shepherd Services}, for more information and for an
  14107. example graph.
  14108. @end table
  14109. @node Running GuixSD in a VM
  14110. @subsection Running GuixSD in a Virtual Machine
  14111. @cindex virtual machine
  14112. To run GuixSD in a virtual machine (VM), one can either use the
  14113. pre-built GuixSD VM image distributed at
  14114. @indicateurl{ftp://alpha.gnu.org/guix/guixsd-vm-image-@value{VERSION}.@var{system}.tar.xz}
  14115. , or build their own virtual machine image using @command{guix system
  14116. vm-image} (@pxref{Invoking guix system}). The returned image is in
  14117. qcow2 format, which the @uref{http://qemu.org/, QEMU emulator} can
  14118. efficiently use.
  14119. @cindex QEMU
  14120. If you built your own image, you must copy it out of the store
  14121. (@pxref{The Store}) and give yourself permission to write to the copy
  14122. before you can use it. When invoking QEMU, you must choose a system
  14123. emulator that is suitable for your hardware platform. Here is a minimal
  14124. QEMU invocation that will boot the result of @command{guix system
  14125. vm-image} on x86_64 hardware:
  14126. @example
  14127. $ qemu-system-x86_64 \
  14128. -net user -net nic,model=virtio \
  14129. -enable-kvm -m 256 /tmp/qemu-image
  14130. @end example
  14131. Here is what each of these options means:
  14132. @table @code
  14133. @item qemu-system-x86_64
  14134. This specifies the hardware platform to emulate. This should match the
  14135. host.
  14136. @item -net user
  14137. Enable the unprivileged user-mode network stack. The guest OS can
  14138. access the host but not vice versa. This is the simplest way to get the
  14139. guest OS online.
  14140. @item -net nic,model=virtio
  14141. You must create a network interface of a given model. If you do not
  14142. create a NIC, the boot will fail. Assuming your hardware platform is
  14143. x86_64, you can get a list of available NIC models by running
  14144. @command{qemu-system-x86_64 -net nic,model=help}.
  14145. @item -enable-kvm
  14146. If your system has hardware virtualization extensions, enabling the
  14147. virtual machine support (KVM) of the Linux kernel will make things run
  14148. faster.
  14149. @item -m 256
  14150. RAM available to the guest OS, in mebibytes. Defaults to 128@tie{}MiB,
  14151. which may be insufficient for some operations.
  14152. @item /tmp/qemu-image
  14153. The file name of the qcow2 image.
  14154. @end table
  14155. The default @command{run-vm.sh} script that is returned by an invocation of
  14156. @command{guix system vm} does not add a @command{-net user} flag by default.
  14157. To get network access from within the vm add the @code{(dhcp-client-service)}
  14158. to your system definition and start the VM using
  14159. @command{`guix system vm config.scm` -net user}. An important caveat of using
  14160. @command{-net user} for networking is that @command{ping} will not work, because
  14161. it uses the ICMP protocol. You'll have to use a different command to check for
  14162. network connectivity, for example @command{guix download}.
  14163. @subsubsection Connecting Through SSH
  14164. @cindex SSH
  14165. @cindex SSH server
  14166. To enable SSH inside a VM you need to add a SSH server like @code{(dropbear-service)}
  14167. or @code{(lsh-service)} to your VM. The @code{(lsh-service}) doesn't currently
  14168. boot unsupervised. It requires you to type some characters to initialize the
  14169. randomness generator. In addition you need to forward the SSH port, 22 by
  14170. default, to the host. You can do this with
  14171. @example
  14172. `guix system vm config.scm` -net user,hostfwd=tcp::10022-:22
  14173. @end example
  14174. To connect to the VM you can run
  14175. @example
  14176. ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 10022
  14177. @end example
  14178. The @command{-p} tells @command{ssh} the port you want to connect to.
  14179. @command{-o UserKnownHostsFile=/dev/null} prevents @command{ssh} from complaining
  14180. every time you modify your @command{config.scm} file and the
  14181. @command{-o StrictHostKeyChecking=no} prevents you from having to allow a
  14182. connection to an unknown host every time you connect.
  14183. @subsubsection Using @command{virt-viewer} with Spice
  14184. As an alternative to the default @command{qemu} graphical client you can
  14185. use the @command{remote-viewer} from the @command{virt-viewer} package. To
  14186. connect pass the @command{-spice port=5930,disable-ticketing} flag to
  14187. @command{qemu}. See previous section for further information on how to do this.
  14188. Spice also allows you to do some nice stuff like share your clipboard with your
  14189. VM. To enable that you'll also have to pass the following flags to @command{qemu}:
  14190. @example
  14191. -device virtio-serial-pci,id=virtio-serial0,max_ports=16,bus=pci.0,addr=0x5
  14192. -chardev spicevmc,name=vdagent,id=vdagent
  14193. -device virtserialport,nr=1,bus=virtio-serial0.0,chardev=vdagent,
  14194. name=com.redhat.spice.0
  14195. @end example
  14196. You'll also need to add the @pxref{Miscellaneous Services, Spice service}.
  14197. @node Defining Services
  14198. @subsection Defining Services
  14199. The previous sections show the available services and how one can combine
  14200. them in an @code{operating-system} declaration. But how do we define
  14201. them in the first place? And what is a service anyway?
  14202. @menu
  14203. * Service Composition:: The model for composing services.
  14204. * Service Types and Services:: Types and services.
  14205. * Service Reference:: API reference.
  14206. * Shepherd Services:: A particular type of service.
  14207. @end menu
  14208. @node Service Composition
  14209. @subsubsection Service Composition
  14210. @cindex services
  14211. @cindex daemons
  14212. Here we define a @dfn{service} as, broadly, something that extends the
  14213. functionality of the operating system. Often a service is a process---a
  14214. @dfn{daemon}---started when the system boots: a secure shell server, a
  14215. Web server, the Guix build daemon, etc. Sometimes a service is a daemon
  14216. whose execution can be triggered by another daemon---e.g., an FTP server
  14217. started by @command{inetd} or a D-Bus service activated by
  14218. @command{dbus-daemon}. Occasionally, a service does not map to a
  14219. daemon. For instance, the ``account'' service collects user accounts
  14220. and makes sure they exist when the system runs; the ``udev'' service
  14221. collects device management rules and makes them available to the eudev
  14222. daemon; the @file{/etc} service populates the @file{/etc} directory
  14223. of the system.
  14224. @cindex service extensions
  14225. GuixSD services are connected by @dfn{extensions}. For instance, the
  14226. secure shell service @emph{extends} the Shepherd---the GuixSD
  14227. initialization system, running as PID@tie{}1---by giving it the command
  14228. lines to start and stop the secure shell daemon (@pxref{Networking
  14229. Services, @code{lsh-service}}); the UPower service extends the D-Bus
  14230. service by passing it its @file{.service} specification, and extends the
  14231. udev service by passing it device management rules (@pxref{Desktop
  14232. Services, @code{upower-service}}); the Guix daemon service extends the
  14233. Shepherd by passing it the command lines to start and stop the daemon,
  14234. and extends the account service by passing it a list of required build
  14235. user accounts (@pxref{Base Services}).
  14236. All in all, services and their ``extends'' relations form a directed
  14237. acyclic graph (DAG). If we represent services as boxes and extensions
  14238. as arrows, a typical system might provide something like this:
  14239. @image{images/service-graph,,5in,Typical service extension graph.}
  14240. @cindex system service
  14241. At the bottom, we see the @dfn{system service}, which produces the
  14242. directory containing everything to run and boot the system, as returned
  14243. by the @command{guix system build} command. @xref{Service Reference},
  14244. to learn about the other service types shown here.
  14245. @xref{system-extension-graph, the @command{guix system extension-graph}
  14246. command}, for information on how to generate this representation for a
  14247. particular operating system definition.
  14248. @cindex service types
  14249. Technically, developers can define @dfn{service types} to express these
  14250. relations. There can be any number of services of a given type on the
  14251. system---for instance, a system running two instances of the GNU secure
  14252. shell server (lsh) has two instances of @var{lsh-service-type}, with
  14253. different parameters.
  14254. The following section describes the programming interface for service
  14255. types and services.
  14256. @node Service Types and Services
  14257. @subsubsection Service Types and Services
  14258. A @dfn{service type} is a node in the DAG described above. Let us start
  14259. with a simple example, the service type for the Guix build daemon
  14260. (@pxref{Invoking guix-daemon}):
  14261. @example
  14262. (define guix-service-type
  14263. (service-type
  14264. (name 'guix)
  14265. (extensions
  14266. (list (service-extension shepherd-root-service-type guix-shepherd-service)
  14267. (service-extension account-service-type guix-accounts)
  14268. (service-extension activation-service-type guix-activation)))
  14269. (default-value (guix-configuration))))
  14270. @end example
  14271. @noindent
  14272. It defines three things:
  14273. @enumerate
  14274. @item
  14275. A name, whose sole purpose is to make inspection and debugging easier.
  14276. @item
  14277. A list of @dfn{service extensions}, where each extension designates the
  14278. target service type and a procedure that, given the parameters of the
  14279. service, returns a list of objects to extend the service of that type.
  14280. Every service type has at least one service extension. The only
  14281. exception is the @dfn{boot service type}, which is the ultimate service.
  14282. @item
  14283. Optionally, a default value for instances of this type.
  14284. @end enumerate
  14285. In this example, @var{guix-service-type} extends three services:
  14286. @table @var
  14287. @item shepherd-root-service-type
  14288. The @var{guix-shepherd-service} procedure defines how the Shepherd
  14289. service is extended. Namely, it returns a @code{<shepherd-service>}
  14290. object that defines how @command{guix-daemon} is started and stopped
  14291. (@pxref{Shepherd Services}).
  14292. @item account-service-type
  14293. This extension for this service is computed by @var{guix-accounts},
  14294. which returns a list of @code{user-group} and @code{user-account}
  14295. objects representing the build user accounts (@pxref{Invoking
  14296. guix-daemon}).
  14297. @item activation-service-type
  14298. Here @var{guix-activation} is a procedure that returns a gexp, which is
  14299. a code snippet to run at ``activation time''---e.g., when the service is
  14300. booted.
  14301. @end table
  14302. A service of this type is instantiated like this:
  14303. @example
  14304. (service guix-service-type
  14305. (guix-configuration
  14306. (build-accounts 5)
  14307. (use-substitutes? #f)))
  14308. @end example
  14309. The second argument to the @code{service} form is a value representing
  14310. the parameters of this specific service instance.
  14311. @xref{guix-configuration-type, @code{guix-configuration}}, for
  14312. information about the @code{guix-configuration} data type. When the
  14313. value is omitted, the default value specified by
  14314. @code{guix-service-type} is used:
  14315. @example
  14316. (service guix-service-type)
  14317. @end example
  14318. @var{guix-service-type} is quite simple because it extends other
  14319. services but is not extensible itself.
  14320. @c @subsubsubsection Extensible Service Types
  14321. The service type for an @emph{extensible} service looks like this:
  14322. @example
  14323. (define udev-service-type
  14324. (service-type (name 'udev)
  14325. (extensions
  14326. (list (service-extension shepherd-root-service-type
  14327. udev-shepherd-service)))
  14328. (compose concatenate) ;concatenate the list of rules
  14329. (extend (lambda (config rules)
  14330. (match config
  14331. (($ <udev-configuration> udev initial-rules)
  14332. (udev-configuration
  14333. (udev udev) ;the udev package to use
  14334. (rules (append initial-rules rules)))))))))
  14335. @end example
  14336. This is the service type for the
  14337. @uref{https://wiki.gentoo.org/wiki/Project:Eudev, eudev device
  14338. management daemon}. Compared to the previous example, in addition to an
  14339. extension of @var{shepherd-root-service-type}, we see two new fields:
  14340. @table @code
  14341. @item compose
  14342. This is the procedure to @dfn{compose} the list of extensions to
  14343. services of this type.
  14344. Services can extend the udev service by passing it lists of rules; we
  14345. compose those extensions simply by concatenating them.
  14346. @item extend
  14347. This procedure defines how the value of the service is @dfn{extended} with
  14348. the composition of the extensions.
  14349. Udev extensions are composed into a list of rules, but the udev service
  14350. value is itself a @code{<udev-configuration>} record. So here, we
  14351. extend that record by appending the list of rules it contains to the
  14352. list of contributed rules.
  14353. @item description
  14354. This is a string giving an overview of the service type. The string can
  14355. contain Texinfo markup (@pxref{Overview,,, texinfo, GNU Texinfo}). The
  14356. @command{guix system search} command searches these strings and displays
  14357. them (@pxref{Invoking guix system}).
  14358. @end table
  14359. There can be only one instance of an extensible service type such as
  14360. @var{udev-service-type}. If there were more, the
  14361. @code{service-extension} specifications would be ambiguous.
  14362. Still here? The next section provides a reference of the programming
  14363. interface for services.
  14364. @node Service Reference
  14365. @subsubsection Service Reference
  14366. We have seen an overview of service types (@pxref{Service Types and
  14367. Services}). This section provides a reference on how to manipulate
  14368. services and service types. This interface is provided by the
  14369. @code{(gnu services)} module.
  14370. @deffn {Scheme Procedure} service @var{type} [@var{value}]
  14371. Return a new service of @var{type}, a @code{<service-type>} object (see
  14372. below.) @var{value} can be any object; it represents the parameters of
  14373. this particular service instance.
  14374. When @var{value} is omitted, the default value specified by @var{type}
  14375. is used; if @var{type} does not specify a default value, an error is
  14376. raised.
  14377. For instance, this:
  14378. @example
  14379. (service openssh-service-type)
  14380. @end example
  14381. @noindent
  14382. is equivalent to this:
  14383. @example
  14384. (service openssh-service-type
  14385. (openssh-configuration))
  14386. @end example
  14387. In both cases the result is an instance of @code{openssh-service-type}
  14388. with the default configuration.
  14389. @end deffn
  14390. @deffn {Scheme Procedure} service? @var{obj}
  14391. Return true if @var{obj} is a service.
  14392. @end deffn
  14393. @deffn {Scheme Procedure} service-kind @var{service}
  14394. Return the type of @var{service}---i.e., a @code{<service-type>} object.
  14395. @end deffn
  14396. @deffn {Scheme Procedure} service-value @var{service}
  14397. Return the value associated with @var{service}. It represents its
  14398. parameters.
  14399. @end deffn
  14400. Here is an example of how a service is created and manipulated:
  14401. @example
  14402. (define s
  14403. (service nginx-service-type
  14404. (nginx-configuration
  14405. (nginx nginx)
  14406. (log-directory log-directory)
  14407. (run-directory run-directory)
  14408. (file config-file))))
  14409. (service? s)
  14410. @result{} #t
  14411. (eq? (service-kind s) nginx-service-type)
  14412. @result{} #t
  14413. @end example
  14414. The @code{modify-services} form provides a handy way to change the
  14415. parameters of some of the services of a list such as
  14416. @var{%base-services} (@pxref{Base Services, @code{%base-services}}). It
  14417. evaluates to a list of services. Of course, you could always use
  14418. standard list combinators such as @code{map} and @code{fold} to do that
  14419. (@pxref{SRFI-1, List Library,, guile, GNU Guile Reference Manual});
  14420. @code{modify-services} simply provides a more concise form for this
  14421. common pattern.
  14422. @deffn {Scheme Syntax} modify-services @var{services} @
  14423. (@var{type} @var{variable} => @var{body}) @dots{}
  14424. Modify the services listed in @var{services} according to the given
  14425. clauses. Each clause has the form:
  14426. @example
  14427. (@var{type} @var{variable} => @var{body})
  14428. @end example
  14429. where @var{type} is a service type---e.g.,
  14430. @code{guix-service-type}---and @var{variable} is an identifier that is
  14431. bound within the @var{body} to the service parameters---e.g., a
  14432. @code{guix-configuration} instance---of the original service of that
  14433. @var{type}.
  14434. The @var{body} should evaluate to the new service parameters, which will
  14435. be used to configure the new service. This new service will replace the
  14436. original in the resulting list. Because a service's service parameters
  14437. are created using @code{define-record-type*}, you can write a succinct
  14438. @var{body} that evaluates to the new service parameters by using the
  14439. @code{inherit} feature that @code{define-record-type*} provides.
  14440. @xref{Using the Configuration System}, for example usage.
  14441. @end deffn
  14442. Next comes the programming interface for service types. This is
  14443. something you want to know when writing new service definitions, but not
  14444. necessarily when simply looking for ways to customize your
  14445. @code{operating-system} declaration.
  14446. @deftp {Data Type} service-type
  14447. @cindex service type
  14448. This is the representation of a @dfn{service type} (@pxref{Service Types
  14449. and Services}).
  14450. @table @asis
  14451. @item @code{name}
  14452. This is a symbol, used only to simplify inspection and debugging.
  14453. @item @code{extensions}
  14454. A non-empty list of @code{<service-extension>} objects (see below).
  14455. @item @code{compose} (default: @code{#f})
  14456. If this is @code{#f}, then the service type denotes services that cannot
  14457. be extended---i.e., services that do not receive ``values'' from other
  14458. services.
  14459. Otherwise, it must be a one-argument procedure. The procedure is called
  14460. by @code{fold-services} and is passed a list of values collected from
  14461. extensions. It must return a value that is a valid parameter value for
  14462. the service instance.
  14463. @item @code{extend} (default: @code{#f})
  14464. If this is @code{#f}, services of this type cannot be extended.
  14465. Otherwise, it must be a two-argument procedure: @code{fold-services}
  14466. calls it, passing it the initial value of the service as the first argument
  14467. and the result of applying @code{compose} to the extension values as the
  14468. second argument.
  14469. @end table
  14470. @xref{Service Types and Services}, for examples.
  14471. @end deftp
  14472. @deffn {Scheme Procedure} service-extension @var{target-type} @
  14473. @var{compute}
  14474. Return a new extension for services of type @var{target-type}.
  14475. @var{compute} must be a one-argument procedure: @code{fold-services}
  14476. calls it, passing it the value associated with the service that provides
  14477. the extension; it must return a valid value for the target service.
  14478. @end deffn
  14479. @deffn {Scheme Procedure} service-extension? @var{obj}
  14480. Return true if @var{obj} is a service extension.
  14481. @end deffn
  14482. Occasionally, you might want to simply extend an existing service. This
  14483. involves creating a new service type and specifying the extension of
  14484. interest, which can be verbose; the @code{simple-service} procedure
  14485. provides a shorthand for this.
  14486. @deffn {Scheme Procedure} simple-service @var{name} @var{target} @var{value}
  14487. Return a service that extends @var{target} with @var{value}. This works
  14488. by creating a singleton service type @var{name}, of which the returned
  14489. service is an instance.
  14490. For example, this extends mcron (@pxref{Scheduled Job Execution}) with
  14491. an additional job:
  14492. @example
  14493. (simple-service 'my-mcron-job mcron-service-type
  14494. #~(job '(next-hour (3)) "guix gc -F 2G"))
  14495. @end example
  14496. @end deffn
  14497. At the core of the service abstraction lies the @code{fold-services}
  14498. procedure, which is responsible for ``compiling'' a list of services
  14499. down to a single directory that contains everything needed to boot and
  14500. run the system---the directory shown by the @command{guix system build}
  14501. command (@pxref{Invoking guix system}). In essence, it propagates
  14502. service extensions down the service graph, updating each node parameters
  14503. on the way, until it reaches the root node.
  14504. @deffn {Scheme Procedure} fold-services @var{services} @
  14505. [#:target-type @var{system-service-type}]
  14506. Fold @var{services} by propagating their extensions down to the root of
  14507. type @var{target-type}; return the root service adjusted accordingly.
  14508. @end deffn
  14509. Lastly, the @code{(gnu services)} module also defines several essential
  14510. service types, some of which are listed below.
  14511. @defvr {Scheme Variable} system-service-type
  14512. This is the root of the service graph. It produces the system directory
  14513. as returned by the @command{guix system build} command.
  14514. @end defvr
  14515. @defvr {Scheme Variable} boot-service-type
  14516. The type of the ``boot service'', which produces the @dfn{boot script}.
  14517. The boot script is what the initial RAM disk runs when booting.
  14518. @end defvr
  14519. @defvr {Scheme Variable} etc-service-type
  14520. The type of the @file{/etc} service. This service can be extended by
  14521. passing it name/file tuples such as:
  14522. @example
  14523. (list `("issue" ,(plain-file "issue" "Welcome!\n")))
  14524. @end example
  14525. In this example, the effect would be to add an @file{/etc/issue} file
  14526. pointing to the given file.
  14527. @end defvr
  14528. @defvr {Scheme Variable} setuid-program-service-type
  14529. Type for the ``setuid-program service''. This service collects lists of
  14530. executable file names, passed as gexps, and adds them to the set of
  14531. setuid-root programs on the system (@pxref{Setuid Programs}).
  14532. @end defvr
  14533. @defvr {Scheme Variable} profile-service-type
  14534. Type of the service that populates the @dfn{system profile}---i.e., the
  14535. programs under @file{/run/current-system/profile}. Other services can
  14536. extend it by passing it lists of packages to add to the system profile.
  14537. @end defvr
  14538. @node Shepherd Services
  14539. @subsubsection Shepherd Services
  14540. @cindex shepherd services
  14541. @cindex PID 1
  14542. @cindex init system
  14543. The @code{(gnu services shepherd)} module provides a way to define
  14544. services managed by the GNU@tie{}Shepherd, which is the GuixSD
  14545. initialization system---the first process that is started when the
  14546. system boots, also known as PID@tie{}1
  14547. (@pxref{Introduction,,, shepherd, The GNU Shepherd Manual}).
  14548. Services in the Shepherd can depend on each other. For instance, the
  14549. SSH daemon may need to be started after the syslog daemon has been
  14550. started, which in turn can only happen once all the file systems have
  14551. been mounted. The simple operating system defined earlier (@pxref{Using
  14552. the Configuration System}) results in a service graph like this:
  14553. @image{images/shepherd-graph,,5in,Typical shepherd service graph.}
  14554. You can actually generate such a graph for any operating system
  14555. definition using the @command{guix system shepherd-graph} command
  14556. (@pxref{system-shepherd-graph, @command{guix system shepherd-graph}}).
  14557. The @var{%shepherd-root-service} is a service object representing
  14558. PID@tie{}1, of type @var{shepherd-root-service-type}; it can be extended
  14559. by passing it lists of @code{<shepherd-service>} objects.
  14560. @deftp {Data Type} shepherd-service
  14561. The data type representing a service managed by the Shepherd.
  14562. @table @asis
  14563. @item @code{provision}
  14564. This is a list of symbols denoting what the service provides.
  14565. These are the names that may be passed to @command{herd start},
  14566. @command{herd status}, and similar commands (@pxref{Invoking herd,,,
  14567. shepherd, The GNU Shepherd Manual}). @xref{Slots of services, the
  14568. @code{provides} slot,, shepherd, The GNU Shepherd Manual}, for details.
  14569. @item @code{requirements} (default: @code{'()})
  14570. List of symbols denoting the Shepherd services this one depends on.
  14571. @item @code{respawn?} (default: @code{#t})
  14572. Whether to restart the service when it stops, for instance when the
  14573. underlying process dies.
  14574. @item @code{start}
  14575. @itemx @code{stop} (default: @code{#~(const #f)})
  14576. The @code{start} and @code{stop} fields refer to the Shepherd's
  14577. facilities to start and stop processes (@pxref{Service De- and
  14578. Constructors,,, shepherd, The GNU Shepherd Manual}). They are given as
  14579. G-expressions that get expanded in the Shepherd configuration file
  14580. (@pxref{G-Expressions}).
  14581. @item @code{documentation}
  14582. A documentation string, as shown when running:
  14583. @example
  14584. herd doc @var{service-name}
  14585. @end example
  14586. where @var{service-name} is one of the symbols in @var{provision}
  14587. (@pxref{Invoking herd,,, shepherd, The GNU Shepherd Manual}).
  14588. @item @code{modules} (default: @var{%default-modules})
  14589. This is the list of modules that must be in scope when @code{start} and
  14590. @code{stop} are evaluated.
  14591. @end table
  14592. @end deftp
  14593. @defvr {Scheme Variable} shepherd-root-service-type
  14594. The service type for the Shepherd ``root service''---i.e., PID@tie{}1.
  14595. This is the service type that extensions target when they want to create
  14596. shepherd services (@pxref{Service Types and Services}, for an example).
  14597. Each extension must pass a list of @code{<shepherd-service>}.
  14598. @end defvr
  14599. @defvr {Scheme Variable} %shepherd-root-service
  14600. This service represents PID@tie{}1.
  14601. @end defvr
  14602. @node Documentation
  14603. @section Documentation
  14604. @cindex documentation, searching for
  14605. @cindex searching for documentation
  14606. @cindex Info, documentation format
  14607. @cindex man pages
  14608. @cindex manual pages
  14609. In most cases packages installed with Guix come with documentation.
  14610. There are two main documentation formats: ``Info'', a browseable
  14611. hypertext format used for GNU software, and ``manual pages'' (or ``man
  14612. pages''), the linear documentation format traditionally found on Unix.
  14613. Info manuals are accessed with the @command{info} command or with Emacs,
  14614. and man pages are accessed using @command{man}.
  14615. You can look for documentation of software installed on your system by
  14616. keyword. For example, the following command searches for information
  14617. about ``TLS'' in Info manuals:
  14618. @example
  14619. $ info -k TLS
  14620. "(emacs)Network Security" -- STARTTLS
  14621. "(emacs)Network Security" -- TLS
  14622. "(gnutls)Core TLS API" -- gnutls_certificate_set_verify_flags
  14623. "(gnutls)Core TLS API" -- gnutls_certificate_set_verify_function
  14624. @dots{}
  14625. @end example
  14626. @noindent
  14627. The command below searches for the same keyword in man pages:
  14628. @example
  14629. $ man -k TLS
  14630. SSL (7) - OpenSSL SSL/TLS library
  14631. certtool (1) - GnuTLS certificate tool
  14632. @dots {}
  14633. @end example
  14634. These searches are purely local to your computer so you have the
  14635. guarantee that documentation you find corresponds to what you have
  14636. actually installed, you can access it off-line, and your privacy is
  14637. respected.
  14638. Once you have these results, you can view the relevant documentation by
  14639. running, say:
  14640. @example
  14641. $ info "(gnutls)Core TLS API"
  14642. @end example
  14643. @noindent
  14644. or:
  14645. @example
  14646. $ man certtool
  14647. @end example
  14648. Info manuals contain sections and indices as well as hyperlinks like
  14649. those found in Web pages. The @command{info} reader (@pxref{Top, Info
  14650. reader,, info-stnd, Stand-alone GNU Info}) and its Emacs counterpart
  14651. (@pxref{Misc Help,,, emacs, The GNU Emacs Manual}) provide intuitive key
  14652. bindings to navigate manuals. @xref{Getting Started,,, info, Info: An
  14653. Introduction}, for an introduction to Info navigation.
  14654. @node Installing Debugging Files
  14655. @section Installing Debugging Files
  14656. @cindex debugging files
  14657. Program binaries, as produced by the GCC compilers for instance, are
  14658. typically written in the ELF format, with a section containing
  14659. @dfn{debugging information}. Debugging information is what allows the
  14660. debugger, GDB, to map binary code to source code; it is required to
  14661. debug a compiled program in good conditions.
  14662. The problem with debugging information is that is takes up a fair amount
  14663. of disk space. For example, debugging information for the GNU C Library
  14664. weighs in at more than 60 MiB. Thus, as a user, keeping all the
  14665. debugging info of all the installed programs is usually not an option.
  14666. Yet, space savings should not come at the cost of an impediment to
  14667. debugging---especially in the GNU system, which should make it easier
  14668. for users to exert their computing freedom (@pxref{GNU Distribution}).
  14669. Thankfully, the GNU Binary Utilities (Binutils) and GDB provide a
  14670. mechanism that allows users to get the best of both worlds: debugging
  14671. information can be stripped from the binaries and stored in separate
  14672. files. GDB is then able to load debugging information from those files,
  14673. when they are available (@pxref{Separate Debug Files,,, gdb, Debugging
  14674. with GDB}).
  14675. The GNU distribution takes advantage of this by storing debugging
  14676. information in the @code{lib/debug} sub-directory of a separate package
  14677. output unimaginatively called @code{debug} (@pxref{Packages with
  14678. Multiple Outputs}). Users can choose to install the @code{debug} output
  14679. of a package when they need it. For instance, the following command
  14680. installs the debugging information for the GNU C Library and for GNU
  14681. Guile:
  14682. @example
  14683. guix package -i glibc:debug guile:debug
  14684. @end example
  14685. GDB must then be told to look for debug files in the user's profile, by
  14686. setting the @code{debug-file-directory} variable (consider setting it
  14687. from the @file{~/.gdbinit} file, @pxref{Startup,,, gdb, Debugging with
  14688. GDB}):
  14689. @example
  14690. (gdb) set debug-file-directory ~/.guix-profile/lib/debug
  14691. @end example
  14692. From there on, GDB will pick up debugging information from the
  14693. @code{.debug} files under @file{~/.guix-profile/lib/debug}.
  14694. In addition, you will most likely want GDB to be able to show the source
  14695. code being debugged. To do that, you will have to unpack the source
  14696. code of the package of interest (obtained with @code{guix build
  14697. --source}, @pxref{Invoking guix build}), and to point GDB to that source
  14698. directory using the @code{directory} command (@pxref{Source Path,
  14699. @code{directory},, gdb, Debugging with GDB}).
  14700. @c XXX: keep me up-to-date
  14701. The @code{debug} output mechanism in Guix is implemented by the
  14702. @code{gnu-build-system} (@pxref{Build Systems}). Currently, it is
  14703. opt-in---debugging information is available only for the packages
  14704. with definitions explicitly declaring a @code{debug} output. This may be
  14705. changed to opt-out in the future if our build farm servers can handle
  14706. the load. To check whether a package has a @code{debug} output, use
  14707. @command{guix package --list-available} (@pxref{Invoking guix package}).
  14708. @node Security Updates
  14709. @section Security Updates
  14710. @cindex security updates
  14711. @cindex security vulnerabilities
  14712. Occasionally, important security vulnerabilities are discovered in software
  14713. packages and must be patched. Guix developers try hard to keep track of
  14714. known vulnerabilities and to apply fixes as soon as possible in the
  14715. @code{master} branch of Guix (we do not yet provide a ``stable'' branch
  14716. containing only security updates.) The @command{guix lint} tool helps
  14717. developers find out about vulnerable versions of software packages in the
  14718. distribution:
  14719. @smallexample
  14720. $ guix lint -c cve
  14721. gnu/packages/base.scm:652:2: glibc@@2.21: probably vulnerable to CVE-2015-1781, CVE-2015-7547
  14722. gnu/packages/gcc.scm:334:2: gcc@@4.9.3: probably vulnerable to CVE-2015-5276
  14723. gnu/packages/image.scm:312:2: openjpeg@@2.1.0: probably vulnerable to CVE-2016-1923, CVE-2016-1924
  14724. @dots{}
  14725. @end smallexample
  14726. @xref{Invoking guix lint}, for more information.
  14727. @quotation Note
  14728. As of version @value{VERSION}, the feature described below is considered
  14729. ``beta''.
  14730. @end quotation
  14731. Guix follows a functional
  14732. package management discipline (@pxref{Introduction}), which implies
  14733. that, when a package is changed, @emph{every package that depends on it}
  14734. must be rebuilt. This can significantly slow down the deployment of
  14735. fixes in core packages such as libc or Bash, since basically the whole
  14736. distribution would need to be rebuilt. Using pre-built binaries helps
  14737. (@pxref{Substitutes}), but deployment may still take more time than
  14738. desired.
  14739. @cindex grafts
  14740. To address this, Guix implements @dfn{grafts}, a mechanism that allows
  14741. for fast deployment of critical updates without the costs associated
  14742. with a whole-distribution rebuild. The idea is to rebuild only the
  14743. package that needs to be patched, and then to ``graft'' it onto packages
  14744. explicitly installed by the user and that were previously referring to
  14745. the original package. The cost of grafting is typically very low, and
  14746. order of magnitudes lower than a full rebuild of the dependency chain.
  14747. @cindex replacements of packages, for grafts
  14748. For instance, suppose a security update needs to be applied to Bash.
  14749. Guix developers will provide a package definition for the ``fixed''
  14750. Bash, say @var{bash-fixed}, in the usual way (@pxref{Defining
  14751. Packages}). Then, the original package definition is augmented with a
  14752. @code{replacement} field pointing to the package containing the bug fix:
  14753. @example
  14754. (define bash
  14755. (package
  14756. (name "bash")
  14757. ;; @dots{}
  14758. (replacement bash-fixed)))
  14759. @end example
  14760. From there on, any package depending directly or indirectly on Bash---as
  14761. reported by @command{guix gc --requisites} (@pxref{Invoking guix
  14762. gc})---that is installed is automatically ``rewritten'' to refer to
  14763. @var{bash-fixed} instead of @var{bash}. This grafting process takes
  14764. time proportional to the size of the package, usually less than a
  14765. minute for an ``average'' package on a recent machine. Grafting is
  14766. recursive: when an indirect dependency requires grafting, then grafting
  14767. ``propagates'' up to the package that the user is installing.
  14768. Currently, the length of the name and version of the graft and that of
  14769. the package it replaces (@var{bash-fixed} and @var{bash} in the example
  14770. above) must be equal. This restriction mostly comes from the fact that
  14771. grafting works by patching files, including binary files, directly.
  14772. Other restrictions may apply: for instance, when adding a graft to a
  14773. package providing a shared library, the original shared library and its
  14774. replacement must have the same @code{SONAME} and be binary-compatible.
  14775. The @option{--no-grafts} command-line option allows you to forcefully
  14776. avoid grafting (@pxref{Common Build Options, @option{--no-grafts}}).
  14777. Thus, the command:
  14778. @example
  14779. guix build bash --no-grafts
  14780. @end example
  14781. @noindent
  14782. returns the store file name of the original Bash, whereas:
  14783. @example
  14784. guix build bash
  14785. @end example
  14786. @noindent
  14787. returns the store file name of the ``fixed'', replacement Bash. This
  14788. allows you to distinguish between the two variants of Bash.
  14789. To verify which Bash your whole profile refers to, you can run
  14790. (@pxref{Invoking guix gc}):
  14791. @example
  14792. guix gc -R `readlink -f ~/.guix-profile` | grep bash
  14793. @end example
  14794. @noindent
  14795. @dots{} and compare the store file names that you get with those above.
  14796. Likewise for a complete GuixSD system generation:
  14797. @example
  14798. guix gc -R `guix system build my-config.scm` | grep bash
  14799. @end example
  14800. Lastly, to check which Bash running processes are using, you can use the
  14801. @command{lsof} command:
  14802. @example
  14803. lsof | grep /gnu/store/.*bash
  14804. @end example
  14805. @node Package Modules
  14806. @section Package Modules
  14807. From a programming viewpoint, the package definitions of the
  14808. GNU distribution are provided by Guile modules in the @code{(gnu packages
  14809. @dots{})} name space@footnote{Note that packages under the @code{(gnu
  14810. packages @dots{})} module name space are not necessarily ``GNU
  14811. packages''. This module naming scheme follows the usual Guile module
  14812. naming convention: @code{gnu} means that these modules are distributed
  14813. as part of the GNU system, and @code{packages} identifies modules that
  14814. define packages.} (@pxref{Modules, Guile modules,, guile, GNU Guile
  14815. Reference Manual}). For instance, the @code{(gnu packages emacs)}
  14816. module exports a variable named @code{emacs}, which is bound to a
  14817. @code{<package>} object (@pxref{Defining Packages}).
  14818. The @code{(gnu packages @dots{})} module name space is
  14819. automatically scanned for packages by the command-line tools. For
  14820. instance, when running @code{guix package -i emacs}, all the @code{(gnu
  14821. packages @dots{})} modules are scanned until one that exports a package
  14822. object whose name is @code{emacs} is found. This package search
  14823. facility is implemented in the @code{(gnu packages)} module.
  14824. @cindex customization, of packages
  14825. @cindex package module search path
  14826. Users can store package definitions in modules with different
  14827. names---e.g., @code{(my-packages emacs)}@footnote{Note that the file
  14828. name and module name must match. For instance, the @code{(my-packages
  14829. emacs)} module must be stored in a @file{my-packages/emacs.scm} file
  14830. relative to the load path specified with @option{--load-path} or
  14831. @code{GUIX_PACKAGE_PATH}. @xref{Modules and the File System,,,
  14832. guile, GNU Guile Reference Manual}, for details.}. These package definitions
  14833. will not be visible by default. Users can invoke commands such as
  14834. @command{guix package} and @command{guix build} with the
  14835. @code{-e} option so that they know where to find the package. Better
  14836. yet, they can use the
  14837. @code{-L} option of these commands to make those modules visible
  14838. (@pxref{Invoking guix build, @code{--load-path}}), or define the
  14839. @code{GUIX_PACKAGE_PATH} environment variable. This environment
  14840. variable makes it easy to extend or customize the distribution and is
  14841. honored by all the user interfaces.
  14842. @defvr {Environment Variable} GUIX_PACKAGE_PATH
  14843. This is a colon-separated list of directories to search for additional
  14844. package modules. Directories listed in this variable take precedence
  14845. over the own modules of the distribution.
  14846. @end defvr
  14847. The distribution is fully @dfn{bootstrapped} and @dfn{self-contained}:
  14848. each package is built based solely on other packages in the
  14849. distribution. The root of this dependency graph is a small set of
  14850. @dfn{bootstrap binaries}, provided by the @code{(gnu packages
  14851. bootstrap)} module. For more information on bootstrapping,
  14852. @pxref{Bootstrapping}.
  14853. @node Packaging Guidelines
  14854. @section Packaging Guidelines
  14855. @cindex packages, creating
  14856. The GNU distribution is nascent and may well lack some of your favorite
  14857. packages. This section describes how you can help make the distribution
  14858. grow. @xref{Contributing}, for additional information on how you can
  14859. help.
  14860. Free software packages are usually distributed in the form of
  14861. @dfn{source code tarballs}---typically @file{tar.gz} files that contain
  14862. all the source files. Adding a package to the distribution means
  14863. essentially two things: adding a @dfn{recipe} that describes how to
  14864. build the package, including a list of other packages required to build
  14865. it, and adding @dfn{package metadata} along with that recipe, such as a
  14866. description and licensing information.
  14867. In Guix all this information is embodied in @dfn{package definitions}.
  14868. Package definitions provide a high-level view of the package. They are
  14869. written using the syntax of the Scheme programming language; in fact,
  14870. for each package we define a variable bound to the package definition,
  14871. and export that variable from a module (@pxref{Package Modules}).
  14872. However, in-depth Scheme knowledge is @emph{not} a prerequisite for
  14873. creating packages. For more information on package definitions,
  14874. @pxref{Defining Packages}.
  14875. Once a package definition is in place, stored in a file in the Guix
  14876. source tree, it can be tested using the @command{guix build} command
  14877. (@pxref{Invoking guix build}). For example, assuming the new package is
  14878. called @code{gnew}, you may run this command from the Guix build tree
  14879. (@pxref{Running Guix Before It Is Installed}):
  14880. @example
  14881. ./pre-inst-env guix build gnew --keep-failed
  14882. @end example
  14883. Using @code{--keep-failed} makes it easier to debug build failures since
  14884. it provides access to the failed build tree. Another useful
  14885. command-line option when debugging is @code{--log-file}, to access the
  14886. build log.
  14887. If the package is unknown to the @command{guix} command, it may be that
  14888. the source file contains a syntax error, or lacks a @code{define-public}
  14889. clause to export the package variable. To figure it out, you may load
  14890. the module from Guile to get more information about the actual error:
  14891. @example
  14892. ./pre-inst-env guile -c '(use-modules (gnu packages gnew))'
  14893. @end example
  14894. Once your package builds correctly, please send us a patch
  14895. (@pxref{Contributing}). Well, if you need help, we will be happy to
  14896. help you too. Once the patch is committed in the Guix repository, the
  14897. new package automatically gets built on the supported platforms by
  14898. @url{http://hydra.gnu.org/jobset/gnu/master, our continuous integration
  14899. system}.
  14900. @cindex substituter
  14901. Users can obtain the new package definition simply by running
  14902. @command{guix pull} (@pxref{Invoking guix pull}). When
  14903. @code{hydra.gnu.org} is done building the package, installing the
  14904. package automatically downloads binaries from there
  14905. (@pxref{Substitutes}). The only place where human intervention is
  14906. needed is to review and apply the patch.
  14907. @menu
  14908. * Software Freedom:: What may go into the distribution.
  14909. * Package Naming:: What's in a name?
  14910. * Version Numbers:: When the name is not enough.
  14911. * Synopses and Descriptions:: Helping users find the right package.
  14912. * Python Modules:: A touch of British comedy.
  14913. * Perl Modules:: Little pearls.
  14914. * Java Packages:: Coffee break.
  14915. * Fonts:: Fond of fonts.
  14916. @end menu
  14917. @node Software Freedom
  14918. @subsection Software Freedom
  14919. @c Adapted from http://www.gnu.org/philosophy/philosophy.html.
  14920. @cindex free software
  14921. The GNU operating system has been developed so that users can have
  14922. freedom in their computing. GNU is @dfn{free software}, meaning that
  14923. users have the @url{http://www.gnu.org/philosophy/free-sw.html,four
  14924. essential freedoms}: to run the program, to study and change the program
  14925. in source code form, to redistribute exact copies, and to distribute
  14926. modified versions. Packages found in the GNU distribution provide only
  14927. software that conveys these four freedoms.
  14928. In addition, the GNU distribution follow the
  14929. @url{http://www.gnu.org/distros/free-system-distribution-guidelines.html,free
  14930. software distribution guidelines}. Among other things, these guidelines
  14931. reject non-free firmware, recommendations of non-free software, and
  14932. discuss ways to deal with trademarks and patents.
  14933. Some otherwise free upstream package sources contain a small and optional
  14934. subset that violates the above guidelines, for instance because this subset
  14935. is itself non-free code. When that happens, the offending items are removed
  14936. with appropriate patches or code snippets in the @code{origin} form of the
  14937. package (@pxref{Defining Packages}). This way, @code{guix
  14938. build --source} returns the ``freed'' source rather than the unmodified
  14939. upstream source.
  14940. @node Package Naming
  14941. @subsection Package Naming
  14942. @cindex package name
  14943. A package has actually two names associated with it:
  14944. First, there is the name of the @emph{Scheme variable}, the one following
  14945. @code{define-public}. By this name, the package can be made known in the
  14946. Scheme code, for instance as input to another package. Second, there is
  14947. the string in the @code{name} field of a package definition. This name
  14948. is used by package management commands such as
  14949. @command{guix package} and @command{guix build}.
  14950. Both are usually the same and correspond to the lowercase conversion of
  14951. the project name chosen upstream, with underscores replaced with
  14952. hyphens. For instance, GNUnet is available as @code{gnunet}, and
  14953. SDL_net as @code{sdl-net}.
  14954. We do not add @code{lib} prefixes for library packages, unless these are
  14955. already part of the official project name. But @pxref{Python
  14956. Modules} and @ref{Perl Modules} for special rules concerning modules for
  14957. the Python and Perl languages.
  14958. Font package names are handled differently, @pxref{Fonts}.
  14959. @node Version Numbers
  14960. @subsection Version Numbers
  14961. @cindex package version
  14962. We usually package only the latest version of a given free software
  14963. project. But sometimes, for instance for incompatible library versions,
  14964. two (or more) versions of the same package are needed. These require
  14965. different Scheme variable names. We use the name as defined
  14966. in @ref{Package Naming}
  14967. for the most recent version; previous versions use the same name, suffixed
  14968. by @code{-} and the smallest prefix of the version number that may
  14969. distinguish the two versions.
  14970. The name inside the package definition is the same for all versions of a
  14971. package and does not contain any version number.
  14972. For instance, the versions 2.24.20 and 3.9.12 of GTK+ may be packaged as follows:
  14973. @example
  14974. (define-public gtk+
  14975. (package
  14976. (name "gtk+")
  14977. (version "3.9.12")
  14978. ...))
  14979. (define-public gtk+-2
  14980. (package
  14981. (name "gtk+")
  14982. (version "2.24.20")
  14983. ...))
  14984. @end example
  14985. If we also wanted GTK+ 3.8.2, this would be packaged as
  14986. @example
  14987. (define-public gtk+-3.8
  14988. (package
  14989. (name "gtk+")
  14990. (version "3.8.2")
  14991. ...))
  14992. @end example
  14993. @c See <https://lists.gnu.org/archive/html/guix-devel/2016-01/msg00425.html>,
  14994. @c for a discussion of what follows.
  14995. @cindex version number, for VCS snapshots
  14996. Occasionally, we package snapshots of upstream's version control system
  14997. (VCS) instead of formal releases. This should remain exceptional,
  14998. because it is up to upstream developers to clarify what the stable
  14999. release is. Yet, it is sometimes necessary. So, what should we put in
  15000. the @code{version} field?
  15001. Clearly, we need to make the commit identifier of the VCS snapshot
  15002. visible in the version string, but we also need to make sure that the
  15003. version string is monotonically increasing so that @command{guix package
  15004. --upgrade} can determine which version is newer. Since commit
  15005. identifiers, notably with Git, are not monotonically increasing, we add
  15006. a revision number that we increase each time we upgrade to a newer
  15007. snapshot. The resulting version string looks like this:
  15008. @example
  15009. 2.0.11-3.cabba9e
  15010. ^ ^ ^
  15011. | | `-- upstream commit ID
  15012. | |
  15013. | `--- Guix package revision
  15014. |
  15015. latest upstream version
  15016. @end example
  15017. It is a good idea to strip commit identifiers in the @code{version}
  15018. field to, say, 7 digits. It avoids an aesthetic annoyance (assuming
  15019. aesthetics have a role to play here) as well as problems related to OS
  15020. limits such as the maximum shebang length (127 bytes for the Linux
  15021. kernel.) It is best to use the full commit identifiers in
  15022. @code{origin}s, though, to avoid ambiguities. A typical package
  15023. definition may look like this:
  15024. @example
  15025. (define my-package
  15026. (let ((commit "c3f29bc928d5900971f65965feaae59e1272a3f7")
  15027. (revision "1")) ;Guix package revision
  15028. (package
  15029. (version (string-append "0.9-" revision "."
  15030. (string-take commit 7)))
  15031. (source (origin
  15032. (method git-fetch)
  15033. (uri (git-reference
  15034. (url "git://example.org/my-package.git")
  15035. (commit commit)))
  15036. (sha256 (base32 "1mbikn@dots{}"))
  15037. (file-name (string-append "my-package-" version
  15038. "-checkout"))))
  15039. ;; @dots{}
  15040. )))
  15041. @end example
  15042. @node Synopses and Descriptions
  15043. @subsection Synopses and Descriptions
  15044. @cindex package description
  15045. @cindex package synopsis
  15046. As we have seen before, each package in GNU@tie{}Guix includes a
  15047. synopsis and a description (@pxref{Defining Packages}). Synopses and
  15048. descriptions are important: They are what @command{guix package
  15049. --search} searches, and a crucial piece of information to help users
  15050. determine whether a given package suits their needs. Consequently,
  15051. packagers should pay attention to what goes into them.
  15052. Synopses must start with a capital letter and must not end with a
  15053. period. They must not start with ``a'' or ``the'', which usually does
  15054. not bring anything; for instance, prefer ``File-frobbing tool'' over ``A
  15055. tool that frobs files''. The synopsis should say what the package
  15056. is---e.g., ``Core GNU utilities (file, text, shell)''---or what it is
  15057. used for---e.g., the synopsis for GNU@tie{}grep is ``Print lines
  15058. matching a pattern''.
  15059. Keep in mind that the synopsis must be meaningful for a very wide
  15060. audience. For example, ``Manipulate alignments in the SAM format''
  15061. might make sense for a seasoned bioinformatics researcher, but might be
  15062. fairly unhelpful or even misleading to a non-specialized audience. It
  15063. is a good idea to come up with a synopsis that gives an idea of the
  15064. application domain of the package. In this example, this might give
  15065. something like ``Manipulate nucleotide sequence alignments'', which
  15066. hopefully gives the user a better idea of whether this is what they are
  15067. looking for.
  15068. Descriptions should take between five and ten lines. Use full
  15069. sentences, and avoid using acronyms without first introducing them.
  15070. Please avoid marketing phrases such as ``world-leading'',
  15071. ``industrial-strength'', and ``next-generation'', and avoid superlatives
  15072. like ``the most advanced''---they are not helpful to users looking for a
  15073. package and may even sound suspicious. Instead, try to be factual,
  15074. mentioning use cases and features.
  15075. @cindex Texinfo markup, in package descriptions
  15076. Descriptions can include Texinfo markup, which is useful to introduce
  15077. ornaments such as @code{@@code} or @code{@@dfn}, bullet lists, or
  15078. hyperlinks (@pxref{Overview,,, texinfo, GNU Texinfo}). However you
  15079. should be careful when using some characters for example @samp{@@} and
  15080. curly braces which are the basic special characters in Texinfo
  15081. (@pxref{Special Characters,,, texinfo, GNU Texinfo}). User interfaces
  15082. such as @command{guix package --show} take care of rendering it
  15083. appropriately.
  15084. Synopses and descriptions are translated by volunteers
  15085. @uref{http://translationproject.org/domain/guix-packages.html, at the
  15086. Translation Project} so that as many users as possible can read them in
  15087. their native language. User interfaces search them and display them in
  15088. the language specified by the current locale.
  15089. To allow @command{xgettext} to extract them as translatable strings,
  15090. synopses and descriptions @emph{must be literal strings}. This means
  15091. that you cannot use @code{string-append} or @code{format} to construct
  15092. these strings:
  15093. @lisp
  15094. (package
  15095. ;; @dots{}
  15096. (synopsis "This is translatable")
  15097. (description (string-append "This is " "*not*" " translatable.")))
  15098. @end lisp
  15099. Translation is a lot of work so, as a packager, please pay even more
  15100. attention to your synopses and descriptions as every change may entail
  15101. additional work for translators. In order to help them, it is possible
  15102. to make recommendations or instructions visible to them by inserting
  15103. special comments like this (@pxref{xgettext Invocation,,, gettext, GNU
  15104. Gettext}):
  15105. @example
  15106. ;; TRANSLATORS: "X11 resize-and-rotate" should not be translated.
  15107. (description "ARandR is designed to provide a simple visual front end
  15108. for the X11 resize-and-rotate (RandR) extension. @dots{}")
  15109. @end example
  15110. @node Python Modules
  15111. @subsection Python Modules
  15112. @cindex python
  15113. We currently package Python 2 and Python 3, under the Scheme variable names
  15114. @code{python-2} and @code{python} as explained in @ref{Version Numbers}.
  15115. To avoid confusion and naming clashes with other programming languages, it
  15116. seems desirable that the name of a package for a Python module contains
  15117. the word @code{python}.
  15118. Some modules are compatible with only one version of Python, others with both.
  15119. If the package Foo compiles only with Python 3, we name it
  15120. @code{python-foo}; if it compiles only with Python 2, we name it
  15121. @code{python2-foo}. If it is compatible with both versions, we create two
  15122. packages with the corresponding names.
  15123. If a project already contains the word @code{python}, we drop this;
  15124. for instance, the module python-dateutil is packaged under the names
  15125. @code{python-dateutil} and @code{python2-dateutil}. If the project name
  15126. starts with @code{py} (e.g. @code{pytz}), we keep it and prefix it as
  15127. described above.
  15128. @subsubsection Specifying Dependencies
  15129. @cindex inputs, for Python packages
  15130. Dependency information for Python packages is usually available in the
  15131. package source tree, with varying degrees of accuracy: in the
  15132. @file{setup.py} file, in @file{requirements.txt}, or in @file{tox.ini}.
  15133. Your mission, when writing a recipe for a Python package, is to map
  15134. these dependencies to the appropriate type of ``input'' (@pxref{package
  15135. Reference, inputs}). Although the @code{pypi} importer normally does a
  15136. good job (@pxref{Invoking guix import}), you may want to check the
  15137. following check list to determine which dependency goes where.
  15138. @itemize
  15139. @item
  15140. We currently package Python 2 with @code{setuptools} and @code{pip}
  15141. installed like Python 3.4 has per default. Thus you don't need to
  15142. specify either of these as an input. @command{guix lint} will warn you
  15143. if you do.
  15144. @item
  15145. Python dependencies required at run time go into
  15146. @code{propagated-inputs}. They are typically defined with the
  15147. @code{install_requires} keyword in @file{setup.py}, or in the
  15148. @file{requirements.txt} file.
  15149. @item
  15150. Python packages required only at build time---e.g., those listed with
  15151. the @code{setup_requires} keyword in @file{setup.py}---or only for
  15152. testing---e.g., those in @code{tests_require}---go into
  15153. @code{native-inputs}. The rationale is that (1) they do not need to be
  15154. propagated because they are not needed at run time, and (2) in a
  15155. cross-compilation context, it's the ``native'' input that we'd want.
  15156. Examples are the @code{pytest}, @code{mock}, and @code{nose} test
  15157. frameworks. Of course if any of these packages is also required at
  15158. run-time, it needs to go to @code{propagated-inputs}.
  15159. @item
  15160. Anything that does not fall in the previous categories goes to
  15161. @code{inputs}, for example programs or C libraries required for building
  15162. Python packages containing C extensions.
  15163. @item
  15164. If a Python package has optional dependencies (@code{extras_require}),
  15165. it is up to you to decide whether to add them or not, based on their
  15166. usefulness/overhead ratio (@pxref{Submitting Patches, @command{guix
  15167. size}}).
  15168. @end itemize
  15169. @node Perl Modules
  15170. @subsection Perl Modules
  15171. @cindex perl
  15172. Perl programs standing for themselves are named as any other package,
  15173. using the lowercase upstream name.
  15174. For Perl packages containing a single class, we use the lowercase class name,
  15175. replace all occurrences of @code{::} by dashes and prepend the prefix
  15176. @code{perl-}.
  15177. So the class @code{XML::Parser} becomes @code{perl-xml-parser}.
  15178. Modules containing several classes keep their lowercase upstream name and
  15179. are also prepended by @code{perl-}. Such modules tend to have the word
  15180. @code{perl} somewhere in their name, which gets dropped in favor of the
  15181. prefix. For instance, @code{libwww-perl} becomes @code{perl-libwww}.
  15182. @node Java Packages
  15183. @subsection Java Packages
  15184. @cindex java
  15185. Java programs standing for themselves are named as any other package,
  15186. using the lowercase upstream name.
  15187. To avoid confusion and naming clashes with other programming languages,
  15188. it is desirable that the name of a package for a Java package is
  15189. prefixed with @code{java-}. If a project already contains the word
  15190. @code{java}, we drop this; for instance, the package @code{ngsjava} is
  15191. packaged under the name @code{java-ngs}.
  15192. For Java packages containing a single class or a small class hierarchy,
  15193. we use the lowercase class name, replace all occurrences of @code{.} by
  15194. dashes and prepend the prefix @code{java-}. So the class
  15195. @code{apache.commons.cli} becomes package
  15196. @code{java-apache-commons-cli}.
  15197. @node Fonts
  15198. @subsection Fonts
  15199. @cindex fonts
  15200. For fonts that are in general not installed by a user for typesetting
  15201. purposes, or that are distributed as part of a larger software package,
  15202. we rely on the general packaging rules for software; for instance, this
  15203. applies to the fonts delivered as part of the X.Org system or fonts that
  15204. are part of TeX Live.
  15205. To make it easier for a user to search for fonts, names for other packages
  15206. containing only fonts are constructed as follows, independently of the
  15207. upstream package name.
  15208. The name of a package containing only one font family starts with
  15209. @code{font-}; it is followed by the foundry name and a dash @code{-}
  15210. if the foundry is known, and the font family name, in which spaces are
  15211. replaced by dashes (and as usual, all upper case letters are transformed
  15212. to lower case).
  15213. For example, the Gentium font family by SIL is packaged under the name
  15214. @code{font-sil-gentium}.
  15215. For a package containing several font families, the name of the collection
  15216. is used in the place of the font family name.
  15217. For instance, the Liberation fonts consist of three families,
  15218. Liberation Sans, Liberation Serif and Liberation Mono.
  15219. These could be packaged separately under the names
  15220. @code{font-liberation-sans} and so on; but as they are distributed together
  15221. under a common name, we prefer to package them together as
  15222. @code{font-liberation}.
  15223. In the case where several formats of the same font family or font collection
  15224. are packaged separately, a short form of the format, prepended by a dash,
  15225. is added to the package name. We use @code{-ttf} for TrueType fonts,
  15226. @code{-otf} for OpenType fonts and @code{-type1} for PostScript Type 1
  15227. fonts.
  15228. @node Bootstrapping
  15229. @section Bootstrapping
  15230. @c Adapted from the ELS 2013 paper.
  15231. @cindex bootstrapping
  15232. Bootstrapping in our context refers to how the distribution gets built
  15233. ``from nothing''. Remember that the build environment of a derivation
  15234. contains nothing but its declared inputs (@pxref{Introduction}). So
  15235. there's an obvious chicken-and-egg problem: how does the first package
  15236. get built? How does the first compiler get compiled? Note that this is
  15237. a question of interest only to the curious hacker, not to the regular
  15238. user, so you can shamelessly skip this section if you consider yourself
  15239. a ``regular user''.
  15240. @cindex bootstrap binaries
  15241. The GNU system is primarily made of C code, with libc at its core. The
  15242. GNU build system itself assumes the availability of a Bourne shell and
  15243. command-line tools provided by GNU Coreutils, Awk, Findutils, `sed', and
  15244. `grep'. Furthermore, build programs---programs that run
  15245. @code{./configure}, @code{make}, etc.---are written in Guile Scheme
  15246. (@pxref{Derivations}). Consequently, to be able to build anything at
  15247. all, from scratch, Guix relies on pre-built binaries of Guile, GCC,
  15248. Binutils, libc, and the other packages mentioned above---the
  15249. @dfn{bootstrap binaries}.
  15250. These bootstrap binaries are ``taken for granted'', though we can also
  15251. re-create them if needed (more on that later).
  15252. @unnumberedsubsec Preparing to Use the Bootstrap Binaries
  15253. @c As of Emacs 24.3, Info-mode displays the image, but since it's a
  15254. @c large image, it's hard to scroll. Oh well.
  15255. @image{images/bootstrap-graph,6in,,Dependency graph of the early bootstrap derivations}
  15256. The figure above shows the very beginning of the dependency graph of the
  15257. distribution, corresponding to the package definitions of the @code{(gnu
  15258. packages bootstrap)} module. A similar figure can be generated with
  15259. @command{guix graph} (@pxref{Invoking guix graph}), along the lines of:
  15260. @example
  15261. guix graph -t derivation \
  15262. -e '(@@@@ (gnu packages bootstrap) %bootstrap-gcc)' \
  15263. | dot -Tps > t.ps
  15264. @end example
  15265. At this level of detail, things are
  15266. slightly complex. First, Guile itself consists of an ELF executable,
  15267. along with many source and compiled Scheme files that are dynamically
  15268. loaded when it runs. This gets stored in the @file{guile-2.0.7.tar.xz}
  15269. tarball shown in this graph. This tarball is part of Guix's ``source''
  15270. distribution, and gets inserted into the store with @code{add-to-store}
  15271. (@pxref{The Store}).
  15272. But how do we write a derivation that unpacks this tarball and adds it
  15273. to the store? To solve this problem, the @code{guile-bootstrap-2.0.drv}
  15274. derivation---the first one that gets built---uses @code{bash} as its
  15275. builder, which runs @code{build-bootstrap-guile.sh}, which in turn calls
  15276. @code{tar} to unpack the tarball. Thus, @file{bash}, @file{tar},
  15277. @file{xz}, and @file{mkdir} are statically-linked binaries, also part of
  15278. the Guix source distribution, whose sole purpose is to allow the Guile
  15279. tarball to be unpacked.
  15280. Once @code{guile-bootstrap-2.0.drv} is built, we have a functioning
  15281. Guile that can be used to run subsequent build programs. Its first task
  15282. is to download tarballs containing the other pre-built binaries---this
  15283. is what the @code{.tar.xz.drv} derivations do. Guix modules such as
  15284. @code{ftp-client.scm} are used for this purpose. The
  15285. @code{module-import.drv} derivations import those modules in a directory
  15286. in the store, using the original layout. The
  15287. @code{module-import-compiled.drv} derivations compile those modules, and
  15288. write them in an output directory with the right layout. This
  15289. corresponds to the @code{#:modules} argument of
  15290. @code{build-expression->derivation} (@pxref{Derivations}).
  15291. Finally, the various tarballs are unpacked by the
  15292. derivations @code{gcc-bootstrap-0.drv}, @code{glibc-bootstrap-0.drv},
  15293. etc., at which point we have a working C tool chain.
  15294. @unnumberedsubsec Building the Build Tools
  15295. Bootstrapping is complete when we have a full tool chain that does not
  15296. depend on the pre-built bootstrap tools discussed above. This
  15297. no-dependency requirement is verified by checking whether the files of
  15298. the final tool chain contain references to the @file{/gnu/store}
  15299. directories of the bootstrap inputs. The process that leads to this
  15300. ``final'' tool chain is described by the package definitions found in
  15301. the @code{(gnu packages commencement)} module.
  15302. The @command{guix graph} command allows us to ``zoom out'' compared to
  15303. the graph above, by looking at the level of package objects instead of
  15304. individual derivations---remember that a package may translate to
  15305. several derivations, typically one derivation to download its source,
  15306. one to build the Guile modules it needs, and one to actually build the
  15307. package from source. The command:
  15308. @example
  15309. guix graph -t bag \
  15310. -e '(@@@@ (gnu packages commencement)
  15311. glibc-final-with-bootstrap-bash)' | dot -Tps > t.ps
  15312. @end example
  15313. @noindent
  15314. produces the dependency graph leading to the ``final'' C
  15315. library@footnote{You may notice the @code{glibc-intermediate} label,
  15316. suggesting that it is not @emph{quite} final, but as a good
  15317. approximation, we will consider it final.}, depicted below.
  15318. @image{images/bootstrap-packages,6in,,Dependency graph of the early packages}
  15319. @c See <http://lists.gnu.org/archive/html/gnu-system-discuss/2012-10/msg00000.html>.
  15320. The first tool that gets built with the bootstrap binaries is
  15321. GNU@tie{}Make---noted @code{make-boot0} above---which is a prerequisite
  15322. for all the following packages. From there Findutils and Diffutils get
  15323. built.
  15324. Then come the first-stage Binutils and GCC, built as pseudo cross
  15325. tools---i.e., with @code{--target} equal to @code{--host}. They are
  15326. used to build libc. Thanks to this cross-build trick, this libc is
  15327. guaranteed not to hold any reference to the initial tool chain.
  15328. From there the final Binutils and GCC (not shown above) are built.
  15329. GCC uses @code{ld}
  15330. from the final Binutils, and links programs against the just-built libc.
  15331. This tool chain is used to build the other packages used by Guix and by
  15332. the GNU Build System: Guile, Bash, Coreutils, etc.
  15333. And voilà! At this point we have the complete set of build tools that
  15334. the GNU Build System expects. These are in the @code{%final-inputs}
  15335. variable of the @code{(gnu packages commencement)} module, and are
  15336. implicitly used by any package that uses @code{gnu-build-system}
  15337. (@pxref{Build Systems, @code{gnu-build-system}}).
  15338. @unnumberedsubsec Building the Bootstrap Binaries
  15339. @cindex bootstrap binaries
  15340. Because the final tool chain does not depend on the bootstrap binaries,
  15341. those rarely need to be updated. Nevertheless, it is useful to have an
  15342. automated way to produce them, should an update occur, and this is what
  15343. the @code{(gnu packages make-bootstrap)} module provides.
  15344. The following command builds the tarballs containing the bootstrap
  15345. binaries (Guile, Binutils, GCC, libc, and a tarball containing a mixture
  15346. of Coreutils and other basic command-line tools):
  15347. @example
  15348. guix build bootstrap-tarballs
  15349. @end example
  15350. The generated tarballs are those that should be referred to in the
  15351. @code{(gnu packages bootstrap)} module mentioned at the beginning of
  15352. this section.
  15353. Still here? Then perhaps by now you've started to wonder: when do we
  15354. reach a fixed point? That is an interesting question! The answer is
  15355. unknown, but if you would like to investigate further (and have
  15356. significant computational and storage resources to do so), then let us
  15357. know.
  15358. @node Porting
  15359. @section Porting to a New Platform
  15360. As discussed above, the GNU distribution is self-contained, and
  15361. self-containment is achieved by relying on pre-built ``bootstrap
  15362. binaries'' (@pxref{Bootstrapping}). These binaries are specific to an
  15363. operating system kernel, CPU architecture, and application binary
  15364. interface (ABI). Thus, to port the distribution to a platform that is
  15365. not yet supported, one must build those bootstrap binaries, and update
  15366. the @code{(gnu packages bootstrap)} module to use them on that platform.
  15367. Fortunately, Guix can @emph{cross compile} those bootstrap binaries.
  15368. When everything goes well, and assuming the GNU tool chain supports the
  15369. target platform, this can be as simple as running a command like this
  15370. one:
  15371. @example
  15372. guix build --target=armv5tel-linux-gnueabi bootstrap-tarballs
  15373. @end example
  15374. For this to work, the @code{glibc-dynamic-linker} procedure in
  15375. @code{(gnu packages bootstrap)} must be augmented to return the right
  15376. file name for libc's dynamic linker on that platform; likewise,
  15377. @code{system->linux-architecture} in @code{(gnu packages linux)} must be
  15378. taught about the new platform.
  15379. Once these are built, the @code{(gnu packages bootstrap)} module needs
  15380. to be updated to refer to these binaries on the target platform. That
  15381. is, the hashes and URLs of the bootstrap tarballs for the new platform
  15382. must be added alongside those of the currently supported platforms. The
  15383. bootstrap Guile tarball is treated specially: it is expected to be
  15384. available locally, and @file{gnu/local.mk} has rules do download it for
  15385. the supported architectures; a rule for the new platform must be added
  15386. as well.
  15387. In practice, there may be some complications. First, it may be that the
  15388. extended GNU triplet that specifies an ABI (like the @code{eabi} suffix
  15389. above) is not recognized by all the GNU tools. Typically, glibc
  15390. recognizes some of these, whereas GCC uses an extra @code{--with-abi}
  15391. configure flag (see @code{gcc.scm} for examples of how to handle this).
  15392. Second, some of the required packages could fail to build for that
  15393. platform. Lastly, the generated binaries could be broken for some
  15394. reason.
  15395. @c *********************************************************************
  15396. @include contributing.texi
  15397. @c *********************************************************************
  15398. @node Acknowledgments
  15399. @chapter Acknowledgments
  15400. Guix is based on the @uref{http://nixos.org/nix/, Nix package manager},
  15401. which was designed and
  15402. implemented by Eelco Dolstra, with contributions from other people (see
  15403. the @file{nix/AUTHORS} file in Guix.) Nix pioneered functional package
  15404. management, and promoted unprecedented features, such as transactional
  15405. package upgrades and rollbacks, per-user profiles, and referentially
  15406. transparent build processes. Without this work, Guix would not exist.
  15407. The Nix-based software distributions, Nixpkgs and NixOS, have also been
  15408. an inspiration for Guix.
  15409. GNU@tie{}Guix itself is a collective work with contributions from a
  15410. number of people. See the @file{AUTHORS} file in Guix for more
  15411. information on these fine people. The @file{THANKS} file lists people
  15412. who have helped by reporting bugs, taking care of the infrastructure,
  15413. providing artwork and themes, making suggestions, and more---thank you!
  15414. @c *********************************************************************
  15415. @node GNU Free Documentation License
  15416. @appendix GNU Free Documentation License
  15417. @cindex license, GNU Free Documentation License
  15418. @include fdl-1.3.texi
  15419. @c *********************************************************************
  15420. @node Concept Index
  15421. @unnumbered Concept Index
  15422. @printindex cp
  15423. @node Programming Index
  15424. @unnumbered Programming Index
  15425. @syncodeindex tp fn
  15426. @syncodeindex vr fn
  15427. @printindex fn
  15428. @bye
  15429. @c Local Variables:
  15430. @c ispell-local-dictionary: "american";
  15431. @c End: