guix.texi 759 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776
  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, 2018 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, 2017 Chris Marusich@*
  23. Copyright @copyright{} 2016, 2017 Efraim Flashner@*
  24. Copyright @copyright{} 2016 John Darrington@*
  25. Copyright @copyright{} 2016, 2017 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. Copyright @copyright{} 2017 George Clemmer@*
  41. Copyright @copyright{} 2017 Andy Wingo@*
  42. Copyright @copyright{} 2017 Arun Isaac@*
  43. Copyright @copyright{} 2017 nee@*
  44. Copyright @copyright{} 2018 Rutger Helling
  45. Permission is granted to copy, distribute and/or modify this document
  46. under the terms of the GNU Free Documentation License, Version 1.3 or
  47. any later version published by the Free Software Foundation; with no
  48. Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
  49. copy of the license is included in the section entitled ``GNU Free
  50. Documentation License''.
  51. @end copying
  52. @dircategory System administration
  53. @direntry
  54. * Guix: (guix). Manage installed software and system configuration.
  55. * guix package: (guix)Invoking guix package. Installing, removing, and upgrading packages.
  56. * guix gc: (guix)Invoking guix gc. Reclaiming unused disk space.
  57. * guix pull: (guix)Invoking guix pull. Update the list of available packages.
  58. * guix system: (guix)Invoking guix system. Manage the operating system configuration.
  59. @end direntry
  60. @dircategory Software development
  61. @direntry
  62. * guix environment: (guix)Invoking guix environment. Building development environments with Guix.
  63. * guix build: (guix)Invoking guix build. Building packages.
  64. * guix pack: (guix)Invoking guix pack. Creating binary bundles.
  65. @end direntry
  66. @titlepage
  67. @title GNU Guix Reference Manual
  68. @subtitle Using the GNU Guix Functional Package Manager
  69. @author The GNU Guix Developers
  70. @page
  71. @vskip 0pt plus 1filll
  72. Edition @value{EDITION} @*
  73. @value{UPDATED} @*
  74. @insertcopying
  75. @end titlepage
  76. @contents
  77. @c *********************************************************************
  78. @node Top
  79. @top GNU Guix
  80. This document describes GNU Guix version @value{VERSION}, a functional
  81. package management tool written for the GNU system.
  82. @menu
  83. * Introduction:: What is Guix about?
  84. * Installation:: Installing Guix.
  85. * Package Management:: Package installation, upgrade, etc.
  86. * Programming Interface:: Using Guix in Scheme.
  87. * Utilities:: Package management commands.
  88. * GNU Distribution:: Software for your friendly GNU system.
  89. * Contributing:: Your help needed!
  90. * Acknowledgments:: Thanks!
  91. * GNU Free Documentation License:: The license of this manual.
  92. * Concept Index:: Concepts.
  93. * Programming Index:: Data types, functions, and variables.
  94. @detailmenu
  95. --- The Detailed Node Listing ---
  96. Installation
  97. * Binary Installation:: Getting Guix running in no time!
  98. * Requirements:: Software needed to build and run Guix.
  99. * Running the Test Suite:: Testing Guix.
  100. * Setting Up the Daemon:: Preparing the build daemon's environment.
  101. * Invoking guix-daemon:: Running the build daemon.
  102. * Application Setup:: Application-specific setup.
  103. Setting Up the Daemon
  104. * Build Environment Setup:: Preparing the isolated build environment.
  105. * Daemon Offload Setup:: Offloading builds to remote machines.
  106. Package Management
  107. * Features:: How Guix will make your life brighter.
  108. * Invoking guix package:: Package installation, removal, etc.
  109. * Substitutes:: Downloading pre-built binaries.
  110. * Packages with Multiple Outputs:: Single source package, multiple outputs.
  111. * Invoking guix gc:: Running the garbage collector.
  112. * Invoking guix pull:: Fetching the latest Guix and distribution.
  113. * Invoking guix pack:: Creating software bundles.
  114. * Invoking guix archive:: Exporting and importing store files.
  115. Substitutes
  116. * Official Substitute Server:: One particular source of substitutes.
  117. * Substitute Server Authorization:: How to enable or disable substitutes.
  118. * Substitute Authentication:: How Guix verifies substitutes.
  119. * Proxy Settings:: How to get substitutes via proxy.
  120. * Substitution Failure:: What happens when substitution fails.
  121. * On Trusting Binaries:: How can you trust that binary blob?
  122. Programming Interface
  123. * Defining Packages:: Defining new packages.
  124. * Build Systems:: Specifying how packages are built.
  125. * The Store:: Manipulating the package store.
  126. * Derivations:: Low-level interface to package derivations.
  127. * The Store Monad:: Purely functional interface to the store.
  128. * G-Expressions:: Manipulating build expressions.
  129. Defining Packages
  130. * package Reference :: The package data type.
  131. * origin Reference:: The origin data type.
  132. Utilities
  133. * Invoking guix build:: Building packages from the command line.
  134. * Invoking guix edit:: Editing package definitions.
  135. * Invoking guix download:: Downloading a file and printing its hash.
  136. * Invoking guix hash:: Computing the cryptographic hash of a file.
  137. * Invoking guix import:: Importing package definitions.
  138. * Invoking guix refresh:: Updating package definitions.
  139. * Invoking guix lint:: Finding errors in package definitions.
  140. * Invoking guix size:: Profiling disk usage.
  141. * Invoking guix graph:: Visualizing the graph of packages.
  142. * Invoking guix environment:: Setting up development environments.
  143. * Invoking guix publish:: Sharing substitutes.
  144. * Invoking guix challenge:: Challenging substitute servers.
  145. * Invoking guix copy:: Copying to and from a remote store.
  146. * Invoking guix container:: Process isolation.
  147. * Invoking guix weather:: Assessing substitute availability.
  148. Invoking @command{guix build}
  149. * Common Build Options:: Build options for most commands.
  150. * Package Transformation Options:: Creating variants of packages.
  151. * Additional Build Options:: Options specific to 'guix build'.
  152. * Debugging Build Failures:: Real life packaging experience.
  153. GNU Distribution
  154. * System Installation:: Installing the whole operating system.
  155. * System Configuration:: Configuring the operating system.
  156. * Documentation:: Browsing software user manuals.
  157. * Installing Debugging Files:: Feeding the debugger.
  158. * Security Updates:: Deploying security fixes quickly.
  159. * Package Modules:: Packages from the programmer's viewpoint.
  160. * Packaging Guidelines:: Growing the distribution.
  161. * Bootstrapping:: GNU/Linux built from scratch.
  162. * Porting:: Targeting another platform or kernel.
  163. System Installation
  164. * Limitations:: What you can expect.
  165. * Hardware Considerations:: Supported hardware.
  166. * USB Stick and DVD Installation:: Preparing the installation medium.
  167. * Preparing for Installation:: Networking, partitioning, etc.
  168. * Proceeding with the Installation:: The real thing.
  169. * Installing GuixSD in a VM:: GuixSD playground.
  170. * Building the Installation Image:: How this comes to be.
  171. System Configuration
  172. * Using the Configuration System:: Customizing your GNU system.
  173. * operating-system Reference:: Detail of operating-system declarations.
  174. * File Systems:: Configuring file system mounts.
  175. * Mapped Devices:: Block device extra processing.
  176. * User Accounts:: Specifying user accounts.
  177. * Locales:: Language and cultural convention settings.
  178. * Services:: Specifying system services.
  179. * Setuid Programs:: Programs running with root privileges.
  180. * X.509 Certificates:: Authenticating HTTPS servers.
  181. * Name Service Switch:: Configuring libc's name service switch.
  182. * Initial RAM Disk:: Linux-Libre bootstrapping.
  183. * Bootloader Configuration:: Configuring the boot loader.
  184. * Invoking guix system:: Instantiating a system configuration.
  185. * Running GuixSD in a VM:: How to run GuixSD in a virtual machine.
  186. * Defining Services:: Adding new service definitions.
  187. Services
  188. * Base Services:: Essential system services.
  189. * Scheduled Job Execution:: The mcron service.
  190. * Log Rotation:: The rottlog service.
  191. * Networking Services:: Network setup, SSH daemon, etc.
  192. * X Window:: Graphical display.
  193. * Printing Services:: Local and remote printer support.
  194. * Desktop Services:: D-Bus and desktop services.
  195. * Database Services:: SQL databases, key-value stores, etc.
  196. * Mail Services:: IMAP, POP3, SMTP, and all that.
  197. * Messaging Services:: Messaging services.
  198. * Telephony Services:: Telephony services.
  199. * Monitoring Services:: Monitoring services.
  200. * Kerberos Services:: Kerberos services.
  201. * Web Services:: Web servers.
  202. * Certificate Services:: TLS certificates via Let's Encrypt.
  203. * DNS Services:: DNS daemons.
  204. * VPN Services:: VPN daemons.
  205. * Network File System:: NFS related services.
  206. * Continuous Integration:: The Cuirass service.
  207. * Power management Services:: The TLP tool.
  208. * Audio Services:: The MPD.
  209. * Virtualization Services:: Virtualization services.
  210. * Version Control Services:: Providing remote access to Git repositories.
  211. * Miscellaneous Services:: Other services.
  212. Defining Services
  213. * Service Composition:: The model for composing services.
  214. * Service Types and Services:: Types and services.
  215. * Service Reference:: API reference.
  216. * Shepherd Services:: A particular type of service.
  217. Packaging Guidelines
  218. * Software Freedom:: What may go into the distribution.
  219. * Package Naming:: What's in a name?
  220. * Version Numbers:: When the name is not enough.
  221. * Synopses and Descriptions:: Helping users find the right package.
  222. * Python Modules:: A touch of British comedy.
  223. * Perl Modules:: Little pearls.
  224. * Java Packages:: Coffee break.
  225. * Fonts:: Fond of fonts.
  226. Contributing
  227. * Building from Git:: The latest and greatest.
  228. * Running Guix Before It Is Installed:: Hacker tricks.
  229. * The Perfect Setup:: The right tools.
  230. * Coding Style:: Hygiene of the contributor.
  231. * Submitting Patches:: Share your work.
  232. Coding Style
  233. * Programming Paradigm:: How to compose your elements.
  234. * Modules:: Where to store your code?
  235. * Data Types and Pattern Matching:: Implementing data structures.
  236. * Formatting Code:: Writing conventions.
  237. @end detailmenu
  238. @end menu
  239. @c *********************************************************************
  240. @node Introduction
  241. @chapter Introduction
  242. @cindex purpose
  243. GNU Guix@footnote{``Guix'' is pronounced like ``geeks'', or ``ɡiːks''
  244. using the international phonetic alphabet (IPA).} is a package
  245. management tool for the GNU system. Guix makes it easy for unprivileged
  246. users to install, upgrade, or remove packages, to roll back to a
  247. previous package set, to build packages from source, and generally
  248. assists with the creation and maintenance of software environments.
  249. @cindex user interfaces
  250. Guix provides a command-line package management interface
  251. (@pxref{Invoking guix package}), a set of command-line utilities
  252. (@pxref{Utilities}), as well as Scheme programming interfaces
  253. (@pxref{Programming Interface}).
  254. @cindex build daemon
  255. Its @dfn{build daemon} is responsible for building packages on behalf of
  256. users (@pxref{Setting Up the Daemon}) and for downloading pre-built
  257. binaries from authorized sources (@pxref{Substitutes}).
  258. @cindex extensibility of the distribution
  259. @cindex customization, of packages
  260. Guix includes package definitions for many GNU and non-GNU packages, all
  261. of which @uref{https://www.gnu.org/philosophy/free-sw.html, respect the
  262. user's computing freedom}. It is @emph{extensible}: users can write
  263. their own package definitions (@pxref{Defining Packages}) and make them
  264. available as independent package modules (@pxref{Package Modules}). It
  265. is also @emph{customizable}: users can @emph{derive} specialized package
  266. definitions from existing ones, including from the command line
  267. (@pxref{Package Transformation Options}).
  268. @cindex Guix System Distribution
  269. @cindex GuixSD
  270. You can install GNU@tie{}Guix on top of an existing GNU/Linux system
  271. where it complements the available tools without interference
  272. (@pxref{Installation}), or you can use it as part of the standalone
  273. @dfn{Guix System Distribution} or GuixSD (@pxref{GNU Distribution}).
  274. With GNU@tie{}GuixSD, you @emph{declare} all aspects of the operating
  275. system configuration and Guix takes care of instantiating the
  276. configuration in a transactional, reproducible, and stateless fashion
  277. (@pxref{System Configuration}).
  278. @cindex functional package management
  279. Under the hood, Guix implements the @dfn{functional package management}
  280. discipline pioneered by Nix (@pxref{Acknowledgments}).
  281. In Guix, the package build and installation process is seen
  282. as a @emph{function}, in the mathematical sense. That function takes inputs,
  283. such as build scripts, a compiler, and libraries, and
  284. returns an installed package. As a pure function, its result depends
  285. solely on its inputs---for instance, it cannot refer to software or
  286. scripts that were not explicitly passed as inputs. A build function
  287. always produces the same result when passed a given set of inputs. It
  288. cannot alter the environment of the running system in
  289. any way; for instance, it cannot create, modify, or delete files outside
  290. of its build and installation directories. This is achieved by running
  291. build processes in isolated environments (or @dfn{containers}), where only their
  292. explicit inputs are visible.
  293. @cindex store
  294. The result of package build functions is @dfn{cached} in the file
  295. system, in a special directory called @dfn{the store} (@pxref{The
  296. Store}). Each package is installed in a directory of its own in the
  297. store---by default under @file{/gnu/store}. The directory name contains
  298. a hash of all the inputs used to build that package; thus, changing an
  299. input yields a different directory name.
  300. This approach is the foundation for the salient features of Guix: support
  301. for transactional package upgrade and rollback, per-user installation, and
  302. garbage collection of packages (@pxref{Features}).
  303. @c *********************************************************************
  304. @node Installation
  305. @chapter Installation
  306. @cindex installing Guix
  307. GNU Guix is available for download from its website at
  308. @url{http://www.gnu.org/software/guix/}. This section describes the
  309. software requirements of Guix, as well as how to install it and get
  310. ready to use it.
  311. Note that this section is concerned with the installation of the package
  312. manager, which can be done on top of a running GNU/Linux system. If,
  313. instead, you want to install the complete GNU operating system,
  314. @pxref{System Installation}.
  315. @cindex foreign distro
  316. When installed on a running GNU/Linux system---thereafter called a
  317. @dfn{foreign distro}---GNU@tie{}Guix complements the available tools
  318. without interference. Its data lives exclusively in two directories,
  319. usually @file{/gnu/store} and @file{/var/guix}; other files on your
  320. system, such as @file{/etc}, are left untouched.
  321. Once installed, Guix can be updated by running @command{guix pull}
  322. (@pxref{Invoking guix pull}).
  323. @menu
  324. * Binary Installation:: Getting Guix running in no time!
  325. * Requirements:: Software needed to build and run Guix.
  326. * Running the Test Suite:: Testing Guix.
  327. * Setting Up the Daemon:: Preparing the build daemon's environment.
  328. * Invoking guix-daemon:: Running the build daemon.
  329. * Application Setup:: Application-specific setup.
  330. @end menu
  331. @node Binary Installation
  332. @section Binary Installation
  333. @cindex installing Guix from binaries
  334. This section describes how to install Guix on an arbitrary system from a
  335. self-contained tarball providing binaries for Guix and for all its
  336. dependencies. This is often quicker than installing from source, which
  337. is described in the next sections. The only requirement is to have
  338. GNU@tie{}tar and Xz.
  339. Installing goes along these lines:
  340. @enumerate
  341. @item
  342. @cindex downloading Guix binary
  343. Download the binary tarball from
  344. @indicateurl{ftp://alpha.gnu.org/gnu/guix/guix-binary-@value{VERSION}.@var{system}.tar.xz},
  345. where @var{system} is @code{x86_64-linux} for an @code{x86_64} machine
  346. already running the kernel Linux, and so on.
  347. @c The following is somewhat duplicated in ``System Installation''.
  348. Make sure to download the associated @file{.sig} file and to verify the
  349. authenticity of the tarball against it, along these lines:
  350. @example
  351. $ wget ftp://alpha.gnu.org/gnu/guix/guix-binary-@value{VERSION}.@var{system}.tar.xz.sig
  352. $ gpg --verify guix-binary-@value{VERSION}.@var{system}.tar.xz.sig
  353. @end example
  354. If that command fails because you do not have the required public key,
  355. then run this command to import it:
  356. @example
  357. $ gpg --keyserver pgp.mit.edu --recv-keys @value{OPENPGP-SIGNING-KEY-ID}
  358. @end example
  359. @noindent
  360. and rerun the @code{gpg --verify} command.
  361. @c end authentication part
  362. @item
  363. As @code{root}, run:
  364. @example
  365. # cd /tmp
  366. # tar --warning=no-timestamp -xf \
  367. guix-binary-@value{VERSION}.@var{system}.tar.xz
  368. # mv var/guix /var/ && mv gnu /
  369. @end example
  370. This creates @file{/gnu/store} (@pxref{The Store}) and @file{/var/guix}.
  371. The latter contains a ready-to-use profile for @code{root} (see next
  372. step.)
  373. Do @emph{not} unpack the tarball on a working Guix system since that
  374. would overwrite its own essential files.
  375. The @code{--warning=no-timestamp} option makes sure GNU@tie{}tar does
  376. not emit warnings about ``implausibly old time stamps'' (such
  377. warnings were triggered by GNU@tie{}tar 1.26 and older; recent
  378. versions are fine.)
  379. They stem from the fact that all the
  380. files in the archive have their modification time set to zero (which
  381. means January 1st, 1970.) This is done on purpose to make sure the
  382. archive content is independent of its creation time, thus making it
  383. reproducible.
  384. @item
  385. Make @code{root}'s profile available under @file{~/.guix-profile}:
  386. @example
  387. # ln -sf /var/guix/profiles/per-user/root/guix-profile \
  388. ~root/.guix-profile
  389. @end example
  390. Source @file{etc/profile} to augment @code{PATH} and other relevant
  391. environment variables:
  392. @example
  393. # GUIX_PROFILE=$HOME/.guix-profile ; \
  394. source $GUIX_PROFILE/etc/profile
  395. @end example
  396. @item
  397. Create the group and user accounts for build users as explained below
  398. (@pxref{Build Environment Setup}).
  399. @item
  400. Run the daemon, and set it to automatically start on boot.
  401. If your host distro uses the systemd init system, this can be achieved
  402. with these commands:
  403. @c Versions of systemd that supported symlinked service files are not
  404. @c yet widely deployed, so we should suggest that users copy the service
  405. @c files into place.
  406. @c
  407. @c See this thread for more information:
  408. @c http://lists.gnu.org/archive/html/guix-devel/2017-01/msg01199.html
  409. @example
  410. # cp ~root/.guix-profile/lib/systemd/system/guix-daemon.service \
  411. /etc/systemd/system/
  412. # systemctl start guix-daemon && systemctl enable guix-daemon
  413. @end example
  414. If your host distro uses the Upstart init system:
  415. @example
  416. # initctl reload-configuration
  417. # cp ~root/.guix-profile/lib/upstart/system/guix-daemon.conf /etc/init/
  418. # start guix-daemon
  419. @end example
  420. Otherwise, you can still start the daemon manually with:
  421. @example
  422. # ~root/.guix-profile/bin/guix-daemon --build-users-group=guixbuild
  423. @end example
  424. @item
  425. Make the @command{guix} command available to other users on the machine,
  426. for instance with:
  427. @example
  428. # mkdir -p /usr/local/bin
  429. # cd /usr/local/bin
  430. # ln -s /var/guix/profiles/per-user/root/guix-profile/bin/guix
  431. @end example
  432. It is also a good idea to make the Info version of this manual available
  433. there:
  434. @example
  435. # mkdir -p /usr/local/share/info
  436. # cd /usr/local/share/info
  437. # for i in /var/guix/profiles/per-user/root/guix-profile/share/info/* ;
  438. do ln -s $i ; done
  439. @end example
  440. That way, assuming @file{/usr/local/share/info} is in the search path,
  441. running @command{info guix} will open this manual (@pxref{Other Info
  442. Directories,,, texinfo, GNU Texinfo}, for more details on changing the
  443. Info search path.)
  444. @item
  445. @cindex substitutes, authorization thereof
  446. To use substitutes from @code{hydra.gnu.org} or one of its mirrors
  447. (@pxref{Substitutes}), authorize them:
  448. @example
  449. # guix archive --authorize < ~root/.guix-profile/share/guix/hydra.gnu.org.pub
  450. @end example
  451. @item
  452. Each user may need to perform a few additional steps to make their Guix
  453. environment ready for use, @pxref{Application Setup}.
  454. @end enumerate
  455. Voilà, the installation is complete!
  456. You can confirm that Guix is working by installing a sample package into
  457. the root profile:
  458. @example
  459. # guix package -i hello
  460. @end example
  461. The @code{guix} package must remain available in @code{root}'s profile,
  462. or it would become subject to garbage collection---in which case you
  463. would find yourself badly handicapped by the lack of the @command{guix}
  464. command. In other words, do not remove @code{guix} by running
  465. @code{guix package -r guix}.
  466. The binary installation tarball can be (re)produced and verified simply
  467. by running the following command in the Guix source tree:
  468. @example
  469. make guix-binary.@var{system}.tar.xz
  470. @end example
  471. @noindent
  472. ... which, in turn, runs:
  473. @example
  474. guix pack -s @var{system} --localstatedir guix
  475. @end example
  476. @xref{Invoking guix pack}, for more info on this handy tool.
  477. @node Requirements
  478. @section Requirements
  479. This section lists requirements when building Guix from source. The
  480. build procedure for Guix is the same as for other GNU software, and is
  481. not covered here. Please see the files @file{README} and @file{INSTALL}
  482. in the Guix source tree for additional details.
  483. GNU Guix depends on the following packages:
  484. @itemize
  485. @item @url{http://gnu.org/software/guile/, GNU Guile}, version 2.0.9 or
  486. later, including 2.2.x;
  487. @item @url{http://gnupg.org/, GNU libgcrypt};
  488. @item
  489. @uref{http://gnutls.org/, GnuTLS}, specifically its Guile bindings
  490. (@pxref{Guile Preparations, how to install the GnuTLS bindings for
  491. Guile,, gnutls-guile, GnuTLS-Guile});
  492. @item
  493. @c FIXME: Specify a version number once a release has been made.
  494. @uref{https://gitlab.com/guile-git/guile-git, Guile-Git}, from August
  495. 2017 or later;
  496. @item @url{http://zlib.net, zlib};
  497. @item @url{http://www.gnu.org/software/make/, GNU Make}.
  498. @end itemize
  499. The following dependencies are optional:
  500. @itemize
  501. @item
  502. Installing
  503. @url{http://savannah.nongnu.org/projects/guile-json/, Guile-JSON} will
  504. allow you to use the @command{guix import pypi} command (@pxref{Invoking
  505. guix import}). It is of
  506. interest primarily for developers and not for casual users.
  507. @item
  508. @c Note: We need at least 0.10.2 for 'channel-send-eof'.
  509. Support for build offloading (@pxref{Daemon Offload Setup}) and
  510. @command{guix copy} (@pxref{Invoking guix copy}) depends on
  511. @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH},
  512. version 0.10.2 or later.
  513. @item
  514. When @url{http://www.bzip.org, libbz2} is available,
  515. @command{guix-daemon} can use it to compress build logs.
  516. @end itemize
  517. Unless @code{--disable-daemon} was passed to @command{configure}, the
  518. following packages are also needed:
  519. @itemize
  520. @item @url{http://sqlite.org, SQLite 3};
  521. @item @url{http://gcc.gnu.org, GCC's g++}, with support for the
  522. C++11 standard.
  523. @end itemize
  524. @cindex state directory
  525. When configuring Guix on a system that already has a Guix installation,
  526. be sure to specify the same state directory as the existing installation
  527. using the @code{--localstatedir} option of the @command{configure}
  528. script (@pxref{Directory Variables, @code{localstatedir},, standards,
  529. GNU Coding Standards}). The @command{configure} script protects against
  530. unintended misconfiguration of @var{localstatedir} so you do not
  531. inadvertently corrupt your store (@pxref{The Store}).
  532. @cindex Nix, compatibility
  533. When a working installation of @url{http://nixos.org/nix/, the Nix package
  534. manager} is available, you
  535. can instead configure Guix with @code{--disable-daemon}. In that case,
  536. Nix replaces the three dependencies above.
  537. Guix is compatible with Nix, so it is possible to share the same store
  538. between both. To do so, you must pass @command{configure} not only the
  539. same @code{--with-store-dir} value, but also the same
  540. @code{--localstatedir} value. The latter is essential because it
  541. specifies where the database that stores metadata about the store is
  542. located, among other things. The default values for Nix are
  543. @code{--with-store-dir=/nix/store} and @code{--localstatedir=/nix/var}.
  544. Note that @code{--disable-daemon} is not required if
  545. your goal is to share the store with Nix.
  546. @node Running the Test Suite
  547. @section Running the Test Suite
  548. @cindex test suite
  549. After a successful @command{configure} and @code{make} run, it is a good
  550. idea to run the test suite. It can help catch issues with the setup or
  551. environment, or bugs in Guix itself---and really, reporting test
  552. failures is a good way to help improve the software. To run the test
  553. suite, type:
  554. @example
  555. make check
  556. @end example
  557. Test cases can run in parallel: you can use the @code{-j} option of
  558. GNU@tie{}make to speed things up. The first run may take a few minutes
  559. on a recent machine; subsequent runs will be faster because the store
  560. that is created for test purposes will already have various things in
  561. cache.
  562. It is also possible to run a subset of the tests by defining the
  563. @code{TESTS} makefile variable as in this example:
  564. @example
  565. make check TESTS="tests/store.scm tests/cpio.scm"
  566. @end example
  567. By default, tests results are displayed at a file level. In order to
  568. see the details of every individual test cases, it is possible to define
  569. the @code{SCM_LOG_DRIVER_FLAGS} makefile variable as in this example:
  570. @example
  571. make check TESTS="tests/base64.scm" SCM_LOG_DRIVER_FLAGS="--brief=no"
  572. @end example
  573. Upon failure, please email @email{bug-guix@@gnu.org} and attach the
  574. @file{test-suite.log} file. Please specify the Guix version being used
  575. as well as version numbers of the dependencies (@pxref{Requirements}) in
  576. your message.
  577. Guix also comes with a whole-system test suite that tests complete
  578. GuixSD operating system instances. It can only run on systems where
  579. Guix is already installed, using:
  580. @example
  581. make check-system
  582. @end example
  583. @noindent
  584. or, again, by defining @code{TESTS} to select a subset of tests to run:
  585. @example
  586. make check-system TESTS="basic mcron"
  587. @end example
  588. These system tests are defined in the @code{(gnu tests @dots{})}
  589. modules. They work by running the operating systems under test with
  590. lightweight instrumentation in a virtual machine (VM). They can be
  591. computationally intensive or rather cheap, depending on whether
  592. substitutes are available for their dependencies (@pxref{Substitutes}).
  593. Some of them require a lot of storage space to hold VM images.
  594. Again in case of test failures, please send @email{bug-guix@@gnu.org}
  595. all the details.
  596. @node Setting Up the Daemon
  597. @section Setting Up the Daemon
  598. @cindex daemon
  599. Operations such as building a package or running the garbage collector
  600. are all performed by a specialized process, the @dfn{build daemon}, on
  601. behalf of clients. Only the daemon may access the store and its
  602. associated database. Thus, any operation that manipulates the store
  603. goes through the daemon. For instance, command-line tools such as
  604. @command{guix package} and @command{guix build} communicate with the
  605. daemon (@i{via} remote procedure calls) to instruct it what to do.
  606. The following sections explain how to prepare the build daemon's
  607. environment. See also @ref{Substitutes}, for information on how to allow
  608. the daemon to download pre-built binaries.
  609. @menu
  610. * Build Environment Setup:: Preparing the isolated build environment.
  611. * Daemon Offload Setup:: Offloading builds to remote machines.
  612. @end menu
  613. @node Build Environment Setup
  614. @subsection Build Environment Setup
  615. @cindex build environment
  616. In a standard multi-user setup, Guix and its daemon---the
  617. @command{guix-daemon} program---are installed by the system
  618. administrator; @file{/gnu/store} is owned by @code{root} and
  619. @command{guix-daemon} runs as @code{root}. Unprivileged users may use
  620. Guix tools to build packages or otherwise access the store, and the
  621. daemon will do it on their behalf, ensuring that the store is kept in a
  622. consistent state, and allowing built packages to be shared among users.
  623. @cindex build users
  624. When @command{guix-daemon} runs as @code{root}, you may not want package
  625. build processes themselves to run as @code{root} too, for obvious
  626. security reasons. To avoid that, a special pool of @dfn{build users}
  627. should be created for use by build processes started by the daemon.
  628. These build users need not have a shell and a home directory: they will
  629. just be used when the daemon drops @code{root} privileges in build
  630. processes. Having several such users allows the daemon to launch
  631. distinct build processes under separate UIDs, which guarantees that they
  632. do not interfere with each other---an essential feature since builds are
  633. regarded as pure functions (@pxref{Introduction}).
  634. On a GNU/Linux system, a build user pool may be created like this (using
  635. Bash syntax and the @code{shadow} commands):
  636. @c See http://lists.gnu.org/archive/html/bug-guix/2013-01/msg00239.html
  637. @c for why `-G' is needed.
  638. @example
  639. # groupadd --system guixbuild
  640. # for i in `seq -w 1 10`;
  641. do
  642. useradd -g guixbuild -G guixbuild \
  643. -d /var/empty -s `which nologin` \
  644. -c "Guix build user $i" --system \
  645. guixbuilder$i;
  646. done
  647. @end example
  648. @noindent
  649. The number of build users determines how many build jobs may run in
  650. parallel, as specified by the @option{--max-jobs} option
  651. (@pxref{Invoking guix-daemon, @option{--max-jobs}}). To use
  652. @command{guix system vm} and related commands, you may need to add the
  653. build users to the @code{kvm} group so they can access @file{/dev/kvm},
  654. using @code{-G guixbuild,kvm} instead of @code{-G guixbuild}
  655. (@pxref{Invoking guix system}).
  656. The @code{guix-daemon} program may then be run as @code{root} with the
  657. following command@footnote{If your machine uses the systemd init system,
  658. dropping the @file{@var{prefix}/lib/systemd/system/guix-daemon.service}
  659. file in @file{/etc/systemd/system} will ensure that
  660. @command{guix-daemon} is automatically started. Similarly, if your
  661. machine uses the Upstart init system, drop the
  662. @file{@var{prefix}/lib/upstart/system/guix-daemon.conf}
  663. file in @file{/etc/init}.}:
  664. @example
  665. # guix-daemon --build-users-group=guixbuild
  666. @end example
  667. @cindex chroot
  668. @noindent
  669. This way, the daemon starts build processes in a chroot, under one of
  670. the @code{guixbuilder} users. On GNU/Linux, by default, the chroot
  671. environment contains nothing but:
  672. @c Keep this list in sync with libstore/build.cc! -----------------------
  673. @itemize
  674. @item
  675. a minimal @code{/dev} directory, created mostly independently from the
  676. host @code{/dev}@footnote{``Mostly'', because while the set of files
  677. that appear in the chroot's @code{/dev} is fixed, most of these files
  678. can only be created if the host has them.};
  679. @item
  680. the @code{/proc} directory; it only shows the processes of the container
  681. since a separate PID name space is used;
  682. @item
  683. @file{/etc/passwd} with an entry for the current user and an entry for
  684. user @file{nobody};
  685. @item
  686. @file{/etc/group} with an entry for the user's group;
  687. @item
  688. @file{/etc/hosts} with an entry that maps @code{localhost} to
  689. @code{127.0.0.1};
  690. @item
  691. a writable @file{/tmp} directory.
  692. @end itemize
  693. You can influence the directory where the daemon stores build trees
  694. @i{via} the @code{TMPDIR} environment variable. However, the build tree
  695. within the chroot is always called @file{/tmp/guix-build-@var{name}.drv-0},
  696. where @var{name} is the derivation name---e.g., @code{coreutils-8.24}.
  697. This way, the value of @code{TMPDIR} does not leak inside build
  698. environments, which avoids discrepancies in cases where build processes
  699. capture the name of their build tree.
  700. @vindex http_proxy
  701. The daemon also honors the @code{http_proxy} environment variable for
  702. HTTP downloads it performs, be it for fixed-output derivations
  703. (@pxref{Derivations}) or for substitutes (@pxref{Substitutes}).
  704. If you are installing Guix as an unprivileged user, it is still possible
  705. to run @command{guix-daemon} provided you pass @code{--disable-chroot}.
  706. However, build processes will not be isolated from one another, and not
  707. from the rest of the system. Thus, build processes may interfere with
  708. each other, and may access programs, libraries, and other files
  709. available on the system---making it much harder to view them as
  710. @emph{pure} functions.
  711. @node Daemon Offload Setup
  712. @subsection Using the Offload Facility
  713. @cindex offloading
  714. @cindex build hook
  715. When desired, the build daemon can @dfn{offload} derivation builds to
  716. other machines running Guix, using the @code{offload} @dfn{build
  717. hook}@footnote{This feature is available only when
  718. @uref{https://github.com/artyom-poptsov/guile-ssh, Guile-SSH} is
  719. present.}. When that
  720. feature is enabled, a list of user-specified build machines is read from
  721. @file{/etc/guix/machines.scm}; every time a build is requested, for
  722. instance via @code{guix build}, the daemon attempts to offload it to one
  723. of the machines that satisfy the constraints of the derivation, in
  724. particular its system type---e.g., @file{x86_64-linux}. Missing
  725. prerequisites for the build are copied over SSH to the target machine,
  726. which then proceeds with the build; upon success the output(s) of the
  727. build are copied back to the initial machine.
  728. The @file{/etc/guix/machines.scm} file typically looks like this:
  729. @example
  730. (list (build-machine
  731. (name "eightysix.example.org")
  732. (system "x86_64-linux")
  733. (host-key "ssh-ed25519 AAAAC3Nza@dots{}")
  734. (user "bob")
  735. (speed 2.)) ;incredibly fast!
  736. (build-machine
  737. (name "meeps.example.org")
  738. (system "mips64el-linux")
  739. (host-key "ssh-rsa AAAAB3Nza@dots{}")
  740. (user "alice")
  741. (private-key
  742. (string-append (getenv "HOME")
  743. "/.ssh/identity-for-guix"))))
  744. @end example
  745. @noindent
  746. In the example above we specify a list of two build machines, one for
  747. the @code{x86_64} architecture and one for the @code{mips64el}
  748. architecture.
  749. In fact, this file is---not surprisingly!---a Scheme file that is
  750. evaluated when the @code{offload} hook is started. Its return value
  751. must be a list of @code{build-machine} objects. While this example
  752. shows a fixed list of build machines, one could imagine, say, using
  753. DNS-SD to return a list of potential build machines discovered in the
  754. local network (@pxref{Introduction, Guile-Avahi,, guile-avahi, Using
  755. Avahi in Guile Scheme Programs}). The @code{build-machine} data type is
  756. detailed below.
  757. @deftp {Data Type} build-machine
  758. This data type represents build machines to which the daemon may offload
  759. builds. The important fields are:
  760. @table @code
  761. @item name
  762. The host name of the remote machine.
  763. @item system
  764. The system type of the remote machine---e.g., @code{"x86_64-linux"}.
  765. @item user
  766. The user account to use when connecting to the remote machine over SSH.
  767. Note that the SSH key pair must @emph{not} be passphrase-protected, to
  768. allow non-interactive logins.
  769. @item host-key
  770. This must be the machine's SSH @dfn{public host key} in OpenSSH format.
  771. This is used to authenticate the machine when we connect to it. It is a
  772. long string that looks like this:
  773. @example
  774. ssh-ed25519 AAAAC3NzaC@dots{}mde+UhL hint@@example.org
  775. @end example
  776. If the machine is running the OpenSSH daemon, @command{sshd}, the host
  777. key can be found in a file such as
  778. @file{/etc/ssh/ssh_host_ed25519_key.pub}.
  779. If the machine is running the SSH daemon of GNU@tie{}lsh,
  780. @command{lshd}, the host key is in @file{/etc/lsh/host-key.pub} or a
  781. similar file. It can be converted to the OpenSSH format using
  782. @command{lsh-export-key} (@pxref{Converting keys,,, lsh, LSH Manual}):
  783. @example
  784. $ lsh-export-key --openssh < /etc/lsh/host-key.pub
  785. ssh-rsa AAAAB3NzaC1yc2EAAAAEOp8FoQAAAQEAs1eB46LV@dots{}
  786. @end example
  787. @end table
  788. A number of optional fields may be specified:
  789. @table @asis
  790. @item @code{port} (default: @code{22})
  791. Port number of SSH server on the machine.
  792. @item @code{private-key} (default: @file{~root/.ssh/id_rsa})
  793. The SSH private key file to use when connecting to the machine, in
  794. OpenSSH format.
  795. Note that the default value is the private key @emph{of the root
  796. account}. Make sure it exists if you use the default.
  797. @item @code{compression} (default: @code{"zlib@@openssh.com,zlib"})
  798. @itemx @code{compression-level} (default: @code{3})
  799. The SSH-level compression methods and compression level requested.
  800. Note that offloading relies on SSH compression to reduce bandwidth usage
  801. when transferring files to and from build machines.
  802. @item @code{daemon-socket} (default: @code{"/var/guix/daemon-socket/socket"})
  803. File name of the Unix-domain socket @command{guix-daemon} is listening
  804. to on that machine.
  805. @item @code{parallel-builds} (default: @code{1})
  806. The number of builds that may run in parallel on the machine.
  807. @item @code{speed} (default: @code{1.0})
  808. A ``relative speed factor''. The offload scheduler will tend to prefer
  809. machines with a higher speed factor.
  810. @item @code{features} (default: @code{'()})
  811. A list of strings denoting specific features supported by the machine.
  812. An example is @code{"kvm"} for machines that have the KVM Linux modules
  813. and corresponding hardware support. Derivations can request features by
  814. name, and they will be scheduled on matching build machines.
  815. @end table
  816. @end deftp
  817. The @code{guile} command must be in the search path on the build
  818. machines. In addition, the Guix modules must be in
  819. @code{$GUILE_LOAD_PATH} on the build machine---you can check whether
  820. this is the case by running:
  821. @example
  822. ssh build-machine guile -c "'(use-modules (guix config))'"
  823. @end example
  824. There is one last thing to do once @file{machines.scm} is in place. As
  825. explained above, when offloading, files are transferred back and forth
  826. between the machine stores. For this to work, you first need to
  827. generate a key pair on each machine to allow the daemon to export signed
  828. archives of files from the store (@pxref{Invoking guix archive}):
  829. @example
  830. # guix archive --generate-key
  831. @end example
  832. @noindent
  833. Each build machine must authorize the key of the master machine so that
  834. it accepts store items it receives from the master:
  835. @example
  836. # guix archive --authorize < master-public-key.txt
  837. @end example
  838. @noindent
  839. Likewise, the master machine must authorize the key of each build machine.
  840. All the fuss with keys is here to express pairwise mutual trust
  841. relations between the master and the build machines. Concretely, when
  842. the master receives files from a build machine (and @i{vice versa}), its
  843. build daemon can make sure they are genuine, have not been tampered
  844. with, and that they are signed by an authorized key.
  845. @cindex offload test
  846. To test whether your setup is operational, run this command on the
  847. master node:
  848. @example
  849. # guix offload test
  850. @end example
  851. This will attempt to connect to each of the build machines specified in
  852. @file{/etc/guix/machines.scm}, make sure Guile and the Guix modules are
  853. available on each machine, attempt to export to the machine and import
  854. from it, and report any error in the process.
  855. If you want to test a different machine file, just specify it on the
  856. command line:
  857. @example
  858. # guix offload test machines-qualif.scm
  859. @end example
  860. Last, you can test the subset of the machines whose name matches a
  861. regular expression like this:
  862. @example
  863. # guix offload test machines.scm '\.gnu\.org$'
  864. @end example
  865. @cindex offload status
  866. To display the current load of all build hosts, run this command on the
  867. main node:
  868. @example
  869. # guix offload status
  870. @end example
  871. @node Invoking guix-daemon
  872. @section Invoking @command{guix-daemon}
  873. The @command{guix-daemon} program implements all the functionality to
  874. access the store. This includes launching build processes, running the
  875. garbage collector, querying the availability of a build result, etc. It
  876. is normally run as @code{root} like this:
  877. @example
  878. # guix-daemon --build-users-group=guixbuild
  879. @end example
  880. @noindent
  881. For details on how to set it up, @pxref{Setting Up the Daemon}.
  882. @cindex chroot
  883. @cindex container, build environment
  884. @cindex build environment
  885. @cindex reproducible builds
  886. By default, @command{guix-daemon} launches build processes under
  887. different UIDs, taken from the build group specified with
  888. @code{--build-users-group}. In addition, each build process is run in a
  889. chroot environment that only contains the subset of the store that the
  890. build process depends on, as specified by its derivation
  891. (@pxref{Programming Interface, derivation}), plus a set of specific
  892. system directories. By default, the latter contains @file{/dev} and
  893. @file{/dev/pts}. Furthermore, on GNU/Linux, the build environment is a
  894. @dfn{container}: in addition to having its own file system tree, it has
  895. a separate mount name space, its own PID name space, network name space,
  896. etc. This helps achieve reproducible builds (@pxref{Features}).
  897. When the daemon performs a build on behalf of the user, it creates a
  898. build directory under @file{/tmp} or under the directory specified by
  899. its @code{TMPDIR} environment variable; this directory is shared with
  900. the container for the duration of the build. Be aware that using a
  901. directory other than @file{/tmp} can affect build results---for example,
  902. with a longer directory name, a build process that uses Unix-domain
  903. sockets might hit the name length limitation for @code{sun_path}, which
  904. it would otherwise not hit.
  905. The build directory is automatically deleted upon completion, unless the
  906. build failed and the client specified @option{--keep-failed}
  907. (@pxref{Invoking guix build, @option{--keep-failed}}).
  908. The following command-line options are supported:
  909. @table @code
  910. @item --build-users-group=@var{group}
  911. Take users from @var{group} to run build processes (@pxref{Setting Up
  912. the Daemon, build users}).
  913. @item --no-substitutes
  914. @cindex substitutes
  915. Do not use substitutes for build products. That is, always build things
  916. locally instead of allowing downloads of pre-built binaries
  917. (@pxref{Substitutes}).
  918. When the daemon runs with @code{--no-substitutes}, clients can still
  919. explicitly enable substitution @i{via} the @code{set-build-options}
  920. remote procedure call (@pxref{The Store}).
  921. @item --substitute-urls=@var{urls}
  922. @anchor{daemon-substitute-urls}
  923. Consider @var{urls} the default whitespace-separated list of substitute
  924. source URLs. When this option is omitted,
  925. @indicateurl{https://mirror.hydra.gnu.org https://hydra.gnu.org} is used
  926. (@code{mirror.hydra.gnu.org} is a mirror of @code{hydra.gnu.org}).
  927. This means that substitutes may be downloaded from @var{urls}, as long
  928. as they are signed by a trusted signature (@pxref{Substitutes}).
  929. @cindex build hook
  930. @item --no-build-hook
  931. Do not use the @dfn{build hook}.
  932. The build hook is a helper program that the daemon can start and to
  933. which it submits build requests. This mechanism is used to offload
  934. builds to other machines (@pxref{Daemon Offload Setup}).
  935. @item --cache-failures
  936. Cache build failures. By default, only successful builds are cached.
  937. When this option is used, @command{guix gc --list-failures} can be used
  938. to query the set of store items marked as failed; @command{guix gc
  939. --clear-failures} removes store items from the set of cached failures.
  940. @xref{Invoking guix gc}.
  941. @item --cores=@var{n}
  942. @itemx -c @var{n}
  943. Use @var{n} CPU cores to build each derivation; @code{0} means as many
  944. as available.
  945. The default value is @code{0}, but it may be overridden by clients, such
  946. as the @code{--cores} option of @command{guix build} (@pxref{Invoking
  947. guix build}).
  948. The effect is to define the @code{NIX_BUILD_CORES} environment variable
  949. in the build process, which can then use it to exploit internal
  950. parallelism---for instance, by running @code{make -j$NIX_BUILD_CORES}.
  951. @item --max-jobs=@var{n}
  952. @itemx -M @var{n}
  953. Allow at most @var{n} build jobs in parallel. The default value is
  954. @code{1}. Setting it to @code{0} means that no builds will be performed
  955. locally; instead, the daemon will offload builds (@pxref{Daemon Offload
  956. Setup}), or simply fail.
  957. @item --max-silent-time=@var{seconds}
  958. When the build or substitution process remains silent for more than
  959. @var{seconds}, terminate it and report a build failure.
  960. The default value is @code{0}, which disables the timeout.
  961. The value specified here can be overridden by clients (@pxref{Common
  962. Build Options, @code{--max-silent-time}}).
  963. @item --timeout=@var{seconds}
  964. Likewise, when the build or substitution process lasts for more than
  965. @var{seconds}, terminate it and report a build failure.
  966. The default value is @code{0}, which disables the timeout.
  967. The value specified here can be overridden by clients (@pxref{Common
  968. Build Options, @code{--timeout}}).
  969. @item --rounds=@var{N}
  970. Build each derivation @var{n} times in a row, and raise an error if
  971. consecutive build results are not bit-for-bit identical. Note that this
  972. setting can be overridden by clients such as @command{guix build}
  973. (@pxref{Invoking guix build}).
  974. When used in conjunction with @option{--keep-failed}, the differing
  975. output is kept in the store, under @file{/gnu/store/@dots{}-check}.
  976. This makes it easy to look for differences between the two results.
  977. @item --debug
  978. Produce debugging output.
  979. This is useful to debug daemon start-up issues, but then it may be
  980. overridden by clients, for example the @code{--verbosity} option of
  981. @command{guix build} (@pxref{Invoking guix build}).
  982. @item --chroot-directory=@var{dir}
  983. Add @var{dir} to the build chroot.
  984. Doing this may change the result of build processes---for instance if
  985. they use optional dependencies found in @var{dir} when it is available,
  986. and not otherwise. For that reason, it is not recommended to do so.
  987. Instead, make sure that each derivation declares all the inputs that it
  988. needs.
  989. @item --disable-chroot
  990. Disable chroot builds.
  991. Using this option is not recommended since, again, it would allow build
  992. processes to gain access to undeclared dependencies. It is necessary,
  993. though, when @command{guix-daemon} is running under an unprivileged user
  994. account.
  995. @item --log-compression=@var{type}
  996. Compress build logs according to @var{type}, one of @code{gzip},
  997. @code{bzip2}, or @code{none}.
  998. Unless @code{--lose-logs} is used, all the build logs are kept in the
  999. @var{localstatedir}. To save space, the daemon automatically compresses
  1000. them with bzip2 by default.
  1001. @item --disable-deduplication
  1002. @cindex deduplication
  1003. Disable automatic file ``deduplication'' in the store.
  1004. By default, files added to the store are automatically ``deduplicated'':
  1005. if a newly added file is identical to another one found in the store,
  1006. the daemon makes the new file a hard link to the other file. This can
  1007. noticeably reduce disk usage, at the expense of slightly increased
  1008. input/output load at the end of a build process. This option disables
  1009. this optimization.
  1010. @item --gc-keep-outputs[=yes|no]
  1011. Tell whether the garbage collector (GC) must keep outputs of live
  1012. derivations.
  1013. @cindex GC roots
  1014. @cindex garbage collector roots
  1015. When set to ``yes'', the GC will keep the outputs of any live derivation
  1016. available in the store---the @code{.drv} files. The default is ``no'',
  1017. meaning that derivation outputs are kept only if they are GC roots.
  1018. @xref{Invoking guix gc}, for more on GC roots.
  1019. @item --gc-keep-derivations[=yes|no]
  1020. Tell whether the garbage collector (GC) must keep derivations
  1021. corresponding to live outputs.
  1022. When set to ``yes'', as is the case by default, the GC keeps
  1023. derivations---i.e., @code{.drv} files---as long as at least one of their
  1024. outputs is live. This allows users to keep track of the origins of
  1025. items in their store. Setting it to ``no'' saves a bit of disk space.
  1026. Note that when both @code{--gc-keep-derivations} and
  1027. @code{--gc-keep-outputs} are used, the effect is to keep all the build
  1028. prerequisites (the sources, compiler, libraries, and other build-time
  1029. tools) of live objects in the store, regardless of whether these
  1030. prerequisites are live. This is convenient for developers since it
  1031. saves rebuilds or downloads.
  1032. @item --impersonate-linux-2.6
  1033. On Linux-based systems, impersonate Linux 2.6. This means that the
  1034. kernel's @code{uname} system call will report 2.6 as the release number.
  1035. This might be helpful to build programs that (usually wrongfully) depend
  1036. on the kernel version number.
  1037. @item --lose-logs
  1038. Do not keep build logs. By default they are kept under
  1039. @code{@var{localstatedir}/guix/log}.
  1040. @item --system=@var{system}
  1041. Assume @var{system} as the current system type. By default it is the
  1042. architecture/kernel pair found at configure time, such as
  1043. @code{x86_64-linux}.
  1044. @item --listen=@var{endpoint}
  1045. Listen for connections on @var{endpoint}. @var{endpoint} is interpreted
  1046. as the file name of a Unix-domain socket if it starts with
  1047. @code{/} (slash sign). Otherwise, @var{endpoint} is interpreted as a
  1048. host name or host name and port to listen to. Here are a few examples:
  1049. @table @code
  1050. @item --listen=/gnu/var/daemon
  1051. Listen for connections on the @file{/gnu/var/daemon} Unix-domain socket,
  1052. creating it if needed.
  1053. @item --listen=localhost
  1054. @cindex daemon, remote access
  1055. @cindex remote access to the daemon
  1056. @cindex daemon, cluster setup
  1057. @cindex clusters, daemon setup
  1058. Listen for TCP connections on the network interface corresponding to
  1059. @code{localhost}, on port 44146.
  1060. @item --listen=128.0.0.42:1234
  1061. Listen for TCP connections on the network interface corresponding to
  1062. @code{128.0.0.42}, on port 1234.
  1063. @end table
  1064. This option can be repeated multiple times, in which case
  1065. @command{guix-daemon} accepts connections on all the specified
  1066. endpoints. Users can tell client commands what endpoint to connect to
  1067. by setting the @code{GUIX_DAEMON_SOCKET} environment variable
  1068. (@pxref{The Store, @code{GUIX_DAEMON_SOCKET}}).
  1069. @quotation Note
  1070. The daemon protocol is @emph{unauthenticated and unencrypted}. Using
  1071. @code{--listen=@var{host}} is suitable on local networks, such as
  1072. clusters, where only trusted nodes may connect to the build daemon. In
  1073. other cases where remote access to the daemon is needed, we recommend
  1074. using Unix-domain sockets along with SSH.
  1075. @end quotation
  1076. When @code{--listen} is omitted, @command{guix-daemon} listens for
  1077. connections on the Unix-domain socket located at
  1078. @file{@var{localstatedir}/guix/daemon-socket/socket}.
  1079. @end table
  1080. @node Application Setup
  1081. @section Application Setup
  1082. @cindex foreign distro
  1083. When using Guix on top of GNU/Linux distribution other than GuixSD---a
  1084. so-called @dfn{foreign distro}---a few additional steps are needed to
  1085. get everything in place. Here are some of them.
  1086. @subsection Locales
  1087. @anchor{locales-and-locpath}
  1088. @cindex locales, when not on GuixSD
  1089. @vindex LOCPATH
  1090. @vindex GUIX_LOCPATH
  1091. Packages installed @i{via} Guix will not use the locale data of the
  1092. host system. Instead, you must first install one of the locale packages
  1093. available with Guix and then define the @code{GUIX_LOCPATH} environment
  1094. variable:
  1095. @example
  1096. $ guix package -i glibc-locales
  1097. $ export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale
  1098. @end example
  1099. Note that the @code{glibc-locales} package contains data for all the
  1100. locales supported by the GNU@tie{}libc and weighs in at around
  1101. 110@tie{}MiB. Alternatively, the @code{glibc-utf8-locales} is smaller but
  1102. limited to a few UTF-8 locales.
  1103. The @code{GUIX_LOCPATH} variable plays a role similar to @code{LOCPATH}
  1104. (@pxref{Locale Names, @code{LOCPATH},, libc, The GNU C Library Reference
  1105. Manual}). There are two important differences though:
  1106. @enumerate
  1107. @item
  1108. @code{GUIX_LOCPATH} is honored only by the libc in Guix, and not by the libc
  1109. provided by foreign distros. Thus, using @code{GUIX_LOCPATH} allows you
  1110. to make sure the programs of the foreign distro will not end up loading
  1111. incompatible locale data.
  1112. @item
  1113. libc suffixes each entry of @code{GUIX_LOCPATH} with @code{/X.Y}, where
  1114. @code{X.Y} is the libc version---e.g., @code{2.22}. This means that,
  1115. should your Guix profile contain a mixture of programs linked against
  1116. different libc version, each libc version will only try to load locale
  1117. data in the right format.
  1118. @end enumerate
  1119. This is important because the locale data format used by different libc
  1120. versions may be incompatible.
  1121. @subsection Name Service Switch
  1122. @cindex name service switch, glibc
  1123. @cindex NSS (name service switch), glibc
  1124. @cindex nscd (name service caching daemon)
  1125. @cindex name service caching daemon (nscd)
  1126. When using Guix on a foreign distro, we @emph{strongly recommend} that
  1127. the system run the GNU C library's @dfn{name service cache daemon},
  1128. @command{nscd}, which should be listening on the
  1129. @file{/var/run/nscd/socket} socket. Failing to do that, applications
  1130. installed with Guix may fail to look up host names or user accounts, or
  1131. may even crash. The next paragraphs explain why.
  1132. @cindex @file{nsswitch.conf}
  1133. The GNU C library implements a @dfn{name service switch} (NSS), which is
  1134. an extensible mechanism for ``name lookups'' in general: host name
  1135. resolution, user accounts, and more (@pxref{Name Service Switch,,, libc,
  1136. The GNU C Library Reference Manual}).
  1137. @cindex Network information service (NIS)
  1138. @cindex NIS (Network information service)
  1139. Being extensible, the NSS supports @dfn{plugins}, which provide new name
  1140. lookup implementations: for example, the @code{nss-mdns} plugin allow
  1141. resolution of @code{.local} host names, the @code{nis} plugin allows
  1142. user account lookup using the Network information service (NIS), and so
  1143. on. These extra ``lookup services'' are configured system-wide in
  1144. @file{/etc/nsswitch.conf}, and all the programs running on the system
  1145. honor those settings (@pxref{NSS Configuration File,,, libc, The GNU C
  1146. Reference Manual}).
  1147. When they perform a name lookup---for instance by calling the
  1148. @code{getaddrinfo} function in C---applications first try to connect to
  1149. the nscd; on success, nscd performs name lookups on their behalf. If
  1150. the nscd is not running, then they perform the name lookup by
  1151. themselves, by loading the name lookup services into their own address
  1152. space and running it. These name lookup services---the
  1153. @file{libnss_*.so} files---are @code{dlopen}'d, but they may come from
  1154. the host system's C library, rather than from the C library the
  1155. application is linked against (the C library coming from Guix).
  1156. And this is where the problem is: if your application is linked against
  1157. Guix's C library (say, glibc 2.24) and tries to load NSS plugins from
  1158. another C library (say, @code{libnss_mdns.so} for glibc 2.22), it will
  1159. likely crash or have its name lookups fail unexpectedly.
  1160. Running @command{nscd} on the system, among other advantages, eliminates
  1161. this binary incompatibility problem because those @code{libnss_*.so}
  1162. files are loaded in the @command{nscd} process, not in applications
  1163. themselves.
  1164. @subsection X11 Fonts
  1165. @cindex fonts
  1166. The majority of graphical applications use Fontconfig to locate and
  1167. load fonts and perform X11-client-side rendering. The @code{fontconfig}
  1168. package in Guix looks for fonts in @file{$HOME/.guix-profile}
  1169. by default. Thus, to allow graphical applications installed with Guix
  1170. to display fonts, you have to install fonts with Guix as well.
  1171. Essential font packages include @code{gs-fonts}, @code{font-dejavu}, and
  1172. @code{font-gnu-freefont-ttf}.
  1173. To display text written in Chinese languages, Japanese, or Korean in
  1174. graphical applications, consider installing
  1175. @code{font-adobe-source-han-sans} or @code{font-wqy-zenhei}. The former
  1176. has multiple outputs, one per language family (@pxref{Packages with
  1177. Multiple Outputs}). For instance, the following command installs fonts
  1178. for Chinese languages:
  1179. @example
  1180. guix package -i font-adobe-source-han-sans:cn
  1181. @end example
  1182. @cindex @code{xterm}
  1183. Older programs such as @command{xterm} do not use Fontconfig and instead
  1184. rely on server-side font rendering. Such programs require to specify a
  1185. full name of a font using XLFD (X Logical Font Description), like this:
  1186. @example
  1187. -*-dejavu sans-medium-r-normal-*-*-100-*-*-*-*-*-1
  1188. @end example
  1189. To be able to use such full names for the TrueType fonts installed in
  1190. your Guix profile, you need to extend the font path of the X server:
  1191. @example
  1192. xset +fp ~/.guix-profile/share/fonts/truetype
  1193. @end example
  1194. @cindex @code{xlsfonts}
  1195. After that, you can run @code{xlsfonts} (from @code{xlsfonts} package)
  1196. to make sure your TrueType fonts are listed there.
  1197. @cindex @code{fc-cache}
  1198. @cindex font cache
  1199. After installing fonts you may have to refresh the font cache to use
  1200. them in applications. The same applies when applications installed via
  1201. Guix do not seem to find fonts. To force rebuilding of the font cache
  1202. run @code{fc-cache -f}. The @code{fc-cache} command is provided by the
  1203. @code{fontconfig} package.
  1204. @subsection X.509 Certificates
  1205. @cindex @code{nss-certs}
  1206. The @code{nss-certs} package provides X.509 certificates, which allow
  1207. programs to authenticate Web servers accessed over HTTPS.
  1208. When using Guix on a foreign distro, you can install this package and
  1209. define the relevant environment variables so that packages know where to
  1210. look for certificates. @xref{X.509 Certificates}, for detailed
  1211. information.
  1212. @subsection Emacs Packages
  1213. @cindex @code{emacs}
  1214. When you install Emacs packages with Guix, the elisp files may be placed
  1215. either in @file{$HOME/.guix-profile/share/emacs/site-lisp/} or in
  1216. sub-directories of
  1217. @file{$HOME/.guix-profile/share/emacs/site-lisp/guix.d/}. The latter
  1218. directory exists because potentially there may exist thousands of Emacs
  1219. packages and storing all their files in a single directory may not be
  1220. reliable (because of name conflicts). So we think using a separate
  1221. directory for each package is a good idea. It is very similar to how
  1222. the Emacs package system organizes the file structure (@pxref{Package
  1223. Files,,, emacs, The GNU Emacs Manual}).
  1224. By default, Emacs (installed with Guix) ``knows'' where these packages
  1225. are placed, so you do not need to perform any configuration. If, for
  1226. some reason, you want to avoid auto-loading Emacs packages installed
  1227. with Guix, you can do so by running Emacs with @code{--no-site-file}
  1228. option (@pxref{Init File,,, emacs, The GNU Emacs Manual}).
  1229. @subsection The GCC toolchain
  1230. @cindex GCC
  1231. @cindex ld-wrapper
  1232. Guix offers individual compiler packages such as @code{gcc} but if you
  1233. are in need of a complete toolchain for compiling and linking source
  1234. code what you really want is the @code{gcc-toolchain} package. This
  1235. package provides a complete GCC toolchain for C/C++ development,
  1236. including GCC itself, the GNU C Library (headers and binaries, plus
  1237. debugging symbols in the @code{debug} output), Binutils, and a linker
  1238. wrapper.
  1239. @cindex attempt to use impure library, error message
  1240. The wrapper's purpose is to inspect the @code{-L} and @code{-l} switches
  1241. passed to the linker, add corresponding @code{-rpath} arguments, and
  1242. invoke the actual linker with this new set of arguments. By default,
  1243. the linker wrapper refuses to link to libraries outside the store to
  1244. ensure ``purity''. This can be annoying when using the toolchain to
  1245. link with local libraries. To allow references to libraries outside the
  1246. store you need to define the environment variable
  1247. @code{GUIX_LD_WRAPPER_ALLOW_IMPURITIES}.
  1248. @c TODO What else?
  1249. @c *********************************************************************
  1250. @node Package Management
  1251. @chapter Package Management
  1252. @cindex packages
  1253. The purpose of GNU Guix is to allow users to easily install, upgrade, and
  1254. remove software packages, without having to know about their build
  1255. procedures or dependencies. Guix also goes beyond this obvious set of
  1256. features.
  1257. This chapter describes the main features of Guix, as well as the
  1258. package management tools it provides. Along with the command-line
  1259. interface described below (@pxref{Invoking guix package, @code{guix
  1260. package}}), you may also use the Emacs-Guix interface (@pxref{Top,,,
  1261. emacs-guix, The Emacs-Guix Reference Manual}), after installing
  1262. @code{emacs-guix} package (run @kbd{M-x guix-help} command to start
  1263. with it):
  1264. @example
  1265. guix package -i emacs-guix
  1266. @end example
  1267. @menu
  1268. * Features:: How Guix will make your life brighter.
  1269. * Invoking guix package:: Package installation, removal, etc.
  1270. * Substitutes:: Downloading pre-built binaries.
  1271. * Packages with Multiple Outputs:: Single source package, multiple outputs.
  1272. * Invoking guix gc:: Running the garbage collector.
  1273. * Invoking guix pull:: Fetching the latest Guix and distribution.
  1274. * Invoking guix pack:: Creating software bundles.
  1275. * Invoking guix archive:: Exporting and importing store files.
  1276. @end menu
  1277. @node Features
  1278. @section Features
  1279. When using Guix, each package ends up in the @dfn{package store}, in its
  1280. own directory---something that resembles
  1281. @file{/gnu/store/xxx-package-1.2}, where @code{xxx} is a base32 string.
  1282. Instead of referring to these directories, users have their own
  1283. @dfn{profile}, which points to the packages that they actually want to
  1284. use. These profiles are stored within each user's home directory, at
  1285. @code{$HOME/.guix-profile}.
  1286. For example, @code{alice} installs GCC 4.7.2. As a result,
  1287. @file{/home/alice/.guix-profile/bin/gcc} points to
  1288. @file{/gnu/store/@dots{}-gcc-4.7.2/bin/gcc}. Now, on the same machine,
  1289. @code{bob} had already installed GCC 4.8.0. The profile of @code{bob}
  1290. simply continues to point to
  1291. @file{/gnu/store/@dots{}-gcc-4.8.0/bin/gcc}---i.e., both versions of GCC
  1292. coexist on the same system without any interference.
  1293. The @command{guix package} command is the central tool to manage
  1294. packages (@pxref{Invoking guix package}). It operates on the per-user
  1295. profiles, and can be used @emph{with normal user privileges}.
  1296. @cindex transactions
  1297. The command provides the obvious install, remove, and upgrade
  1298. operations. Each invocation is actually a @emph{transaction}: either
  1299. the specified operation succeeds, or nothing happens. Thus, if the
  1300. @command{guix package} process is terminated during the transaction,
  1301. or if a power outage occurs during the transaction, then the user's
  1302. profile remains in its previous state, and remains usable.
  1303. In addition, any package transaction may be @emph{rolled back}. So, if,
  1304. for example, an upgrade installs a new version of a package that turns
  1305. out to have a serious bug, users may roll back to the previous instance
  1306. of their profile, which was known to work well. Similarly, the global
  1307. system configuration on GuixSD is subject to
  1308. transactional upgrades and roll-back
  1309. (@pxref{Using the Configuration System}).
  1310. All packages in the package store may be @emph{garbage-collected}.
  1311. Guix can determine which packages are still referenced by user
  1312. profiles, and remove those that are provably no longer referenced
  1313. (@pxref{Invoking guix gc}). Users may also explicitly remove old
  1314. generations of their profile so that the packages they refer to can be
  1315. collected.
  1316. @cindex reproducibility
  1317. @cindex reproducible builds
  1318. Finally, Guix takes a @dfn{purely functional} approach to package
  1319. management, as described in the introduction (@pxref{Introduction}).
  1320. Each @file{/gnu/store} package directory name contains a hash of all the
  1321. inputs that were used to build that package---compiler, libraries, build
  1322. scripts, etc. This direct correspondence allows users to make sure a
  1323. given package installation matches the current state of their
  1324. distribution. It also helps maximize @dfn{build reproducibility}:
  1325. thanks to the isolated build environments that are used, a given build
  1326. is likely to yield bit-identical files when performed on different
  1327. machines (@pxref{Invoking guix-daemon, container}).
  1328. @cindex substitutes
  1329. This foundation allows Guix to support @dfn{transparent binary/source
  1330. deployment}. When a pre-built binary for a @file{/gnu/store} item is
  1331. available from an external source---a @dfn{substitute}, Guix just
  1332. downloads it and unpacks it;
  1333. otherwise, it builds the package from source, locally
  1334. (@pxref{Substitutes}). Because build results are usually bit-for-bit
  1335. reproducible, users do not have to trust servers that provide
  1336. substitutes: they can force a local build and @emph{challenge} providers
  1337. (@pxref{Invoking guix challenge}).
  1338. Control over the build environment is a feature that is also useful for
  1339. developers. The @command{guix environment} command allows developers of
  1340. a package to quickly set up the right development environment for their
  1341. package, without having to manually install the dependencies of the
  1342. package into their profile (@pxref{Invoking guix environment}).
  1343. @node Invoking guix package
  1344. @section Invoking @command{guix package}
  1345. @cindex installing packages
  1346. @cindex removing packages
  1347. @cindex package installation
  1348. @cindex package removal
  1349. The @command{guix package} command is the tool that allows users to
  1350. install, upgrade, and remove packages, as well as rolling back to
  1351. previous configurations. It operates only on the user's own profile,
  1352. and works with normal user privileges (@pxref{Features}). Its syntax
  1353. is:
  1354. @example
  1355. guix package @var{options}
  1356. @end example
  1357. @cindex transactions
  1358. Primarily, @var{options} specifies the operations to be performed during
  1359. the transaction. Upon completion, a new profile is created, but
  1360. previous @dfn{generations} of the profile remain available, should the user
  1361. want to roll back.
  1362. For example, to remove @code{lua} and install @code{guile} and
  1363. @code{guile-cairo} in a single transaction:
  1364. @example
  1365. guix package -r lua -i guile guile-cairo
  1366. @end example
  1367. @command{guix package} also supports a @dfn{declarative approach}
  1368. whereby the user specifies the exact set of packages to be available and
  1369. passes it @i{via} the @option{--manifest} option
  1370. (@pxref{profile-manifest, @option{--manifest}}).
  1371. @cindex profile
  1372. For each user, a symlink to the user's default profile is automatically
  1373. created in @file{$HOME/.guix-profile}. This symlink always points to the
  1374. current generation of the user's default profile. Thus, users can add
  1375. @file{$HOME/.guix-profile/bin} to their @code{PATH} environment
  1376. variable, and so on.
  1377. @cindex search paths
  1378. If you are not using the Guix System Distribution, consider adding the
  1379. following lines to your @file{~/.bash_profile} (@pxref{Bash Startup
  1380. Files,,, bash, The GNU Bash Reference Manual}) so that newly-spawned
  1381. shells get all the right environment variable definitions:
  1382. @example
  1383. GUIX_PROFILE="$HOME/.guix-profile" ; \
  1384. source "$HOME/.guix-profile/etc/profile"
  1385. @end example
  1386. In a multi-user setup, user profiles are stored in a place registered as
  1387. a @dfn{garbage-collector root}, which @file{$HOME/.guix-profile} points
  1388. to (@pxref{Invoking guix gc}). That directory is normally
  1389. @code{@var{localstatedir}/guix/profiles/per-user/@var{user}}, where
  1390. @var{localstatedir} is the value passed to @code{configure} as
  1391. @code{--localstatedir}, and @var{user} is the user name. The
  1392. @file{per-user} directory is created when @command{guix-daemon} is
  1393. started, and the @var{user} sub-directory is created by @command{guix
  1394. package}.
  1395. The @var{options} can be among the following:
  1396. @table @code
  1397. @item --install=@var{package} @dots{}
  1398. @itemx -i @var{package} @dots{}
  1399. Install the specified @var{package}s.
  1400. Each @var{package} may specify either a simple package name, such as
  1401. @code{guile}, or a package name followed by an at-sign and version number,
  1402. such as @code{guile@@1.8.8} or simply @code{guile@@1.8} (in the latter
  1403. case, the newest version prefixed by @code{1.8} is selected.)
  1404. If no version number is specified, the
  1405. newest available version will be selected. In addition, @var{package}
  1406. may contain a colon, followed by the name of one of the outputs of the
  1407. package, as in @code{gcc:doc} or @code{binutils@@2.22:lib}
  1408. (@pxref{Packages with Multiple Outputs}). Packages with a corresponding
  1409. name (and optionally version) are searched for among the GNU
  1410. distribution modules (@pxref{Package Modules}).
  1411. @cindex propagated inputs
  1412. Sometimes packages have @dfn{propagated inputs}: these are dependencies
  1413. that automatically get installed along with the required package
  1414. (@pxref{package-propagated-inputs, @code{propagated-inputs} in
  1415. @code{package} objects}, for information about propagated inputs in
  1416. package definitions).
  1417. @anchor{package-cmd-propagated-inputs}
  1418. An example is the GNU MPC library: its C header files refer to those of
  1419. the GNU MPFR library, which in turn refer to those of the GMP library.
  1420. Thus, when installing MPC, the MPFR and GMP libraries also get installed
  1421. in the profile; removing MPC also removes MPFR and GMP---unless they had
  1422. also been explicitly installed by the user.
  1423. Besides, packages sometimes rely on the definition of environment
  1424. variables for their search paths (see explanation of
  1425. @code{--search-paths} below). Any missing or possibly incorrect
  1426. environment variable definitions are reported here.
  1427. @item --install-from-expression=@var{exp}
  1428. @itemx -e @var{exp}
  1429. Install the package @var{exp} evaluates to.
  1430. @var{exp} must be a Scheme expression that evaluates to a
  1431. @code{<package>} object. This option is notably useful to disambiguate
  1432. between same-named variants of a package, with expressions such as
  1433. @code{(@@ (gnu packages base) guile-final)}.
  1434. Note that this option installs the first output of the specified
  1435. package, which may be insufficient when needing a specific output of a
  1436. multiple-output package.
  1437. @item --install-from-file=@var{file}
  1438. @itemx -f @var{file}
  1439. Install the package that the code within @var{file} evaluates to.
  1440. As an example, @var{file} might contain a definition like this
  1441. (@pxref{Defining Packages}):
  1442. @example
  1443. @verbatiminclude package-hello.scm
  1444. @end example
  1445. Developers may find it useful to include such a @file{guix.scm} file
  1446. in the root of their project source tree that can be used to test
  1447. development snapshots and create reproducible development environments
  1448. (@pxref{Invoking guix environment}).
  1449. @item --remove=@var{package} @dots{}
  1450. @itemx -r @var{package} @dots{}
  1451. Remove the specified @var{package}s.
  1452. As for @code{--install}, each @var{package} may specify a version number
  1453. and/or output name in addition to the package name. For instance,
  1454. @code{-r glibc:debug} would remove the @code{debug} output of
  1455. @code{glibc}.
  1456. @item --upgrade[=@var{regexp} @dots{}]
  1457. @itemx -u [@var{regexp} @dots{}]
  1458. @cindex upgrading packages
  1459. Upgrade all the installed packages. If one or more @var{regexp}s are
  1460. specified, upgrade only installed packages whose name matches a
  1461. @var{regexp}. Also see the @code{--do-not-upgrade} option below.
  1462. Note that this upgrades package to the latest version of packages found
  1463. in the distribution currently installed. To update your distribution,
  1464. you should regularly run @command{guix pull} (@pxref{Invoking guix
  1465. pull}).
  1466. @item --do-not-upgrade[=@var{regexp} @dots{}]
  1467. When used together with the @code{--upgrade} option, do @emph{not}
  1468. upgrade any packages whose name matches a @var{regexp}. For example, to
  1469. upgrade all packages in the current profile except those containing the
  1470. substring ``emacs'':
  1471. @example
  1472. $ guix package --upgrade . --do-not-upgrade emacs
  1473. @end example
  1474. @item @anchor{profile-manifest}--manifest=@var{file}
  1475. @itemx -m @var{file}
  1476. @cindex profile declaration
  1477. @cindex profile manifest
  1478. Create a new generation of the profile from the manifest object
  1479. returned by the Scheme code in @var{file}.
  1480. This allows you to @emph{declare} the profile's contents rather than
  1481. constructing it through a sequence of @code{--install} and similar
  1482. commands. The advantage is that @var{file} can be put under version
  1483. control, copied to different machines to reproduce the same profile, and
  1484. so on.
  1485. @c FIXME: Add reference to (guix profile) documentation when available.
  1486. @var{file} must return a @dfn{manifest} object, which is roughly a list
  1487. of packages:
  1488. @findex packages->manifest
  1489. @example
  1490. (use-package-modules guile emacs)
  1491. (packages->manifest
  1492. (list emacs
  1493. guile-2.0
  1494. ;; Use a specific package output.
  1495. (list guile-2.0 "debug")))
  1496. @end example
  1497. @findex specifications->manifest
  1498. In this example we have to know which modules define the @code{emacs}
  1499. and @code{guile-2.0} variables to provide the right
  1500. @code{use-package-modules} line, which can be cumbersome. We can
  1501. instead provide regular package specifications and let
  1502. @code{specifications->manifest} look up the corresponding package
  1503. objects, like this:
  1504. @example
  1505. (specifications->manifest
  1506. '("emacs" "guile@@2.2" "guile@@2.2:debug"))
  1507. @end example
  1508. @item --roll-back
  1509. @cindex rolling back
  1510. @cindex undoing transactions
  1511. @cindex transactions, undoing
  1512. Roll back to the previous @dfn{generation} of the profile---i.e., undo
  1513. the last transaction.
  1514. When combined with options such as @code{--install}, roll back occurs
  1515. before any other actions.
  1516. When rolling back from the first generation that actually contains
  1517. installed packages, the profile is made to point to the @dfn{zeroth
  1518. generation}, which contains no files apart from its own metadata.
  1519. After having rolled back, installing, removing, or upgrading packages
  1520. overwrites previous future generations. Thus, the history of the
  1521. generations in a profile is always linear.
  1522. @item --switch-generation=@var{pattern}
  1523. @itemx -S @var{pattern}
  1524. @cindex generations
  1525. Switch to a particular generation defined by @var{pattern}.
  1526. @var{pattern} may be either a generation number or a number prefixed
  1527. with ``+'' or ``-''. The latter means: move forward/backward by a
  1528. specified number of generations. For example, if you want to return to
  1529. the latest generation after @code{--roll-back}, use
  1530. @code{--switch-generation=+1}.
  1531. The difference between @code{--roll-back} and
  1532. @code{--switch-generation=-1} is that @code{--switch-generation} will
  1533. not make a zeroth generation, so if a specified generation does not
  1534. exist, the current generation will not be changed.
  1535. @item --search-paths[=@var{kind}]
  1536. @cindex search paths
  1537. Report environment variable definitions, in Bash syntax, that may be
  1538. needed in order to use the set of installed packages. These environment
  1539. variables are used to specify @dfn{search paths} for files used by some
  1540. of the installed packages.
  1541. For example, GCC needs the @code{CPATH} and @code{LIBRARY_PATH}
  1542. environment variables to be defined so it can look for headers and
  1543. libraries in the user's profile (@pxref{Environment Variables,,, gcc,
  1544. Using the GNU Compiler Collection (GCC)}). If GCC and, say, the C
  1545. library are installed in the profile, then @code{--search-paths} will
  1546. suggest setting these variables to @code{@var{profile}/include} and
  1547. @code{@var{profile}/lib}, respectively.
  1548. The typical use case is to define these environment variables in the
  1549. shell:
  1550. @example
  1551. $ eval `guix package --search-paths`
  1552. @end example
  1553. @var{kind} may be one of @code{exact}, @code{prefix}, or @code{suffix},
  1554. meaning that the returned environment variable definitions will either
  1555. be exact settings, or prefixes or suffixes of the current value of these
  1556. variables. When omitted, @var{kind} defaults to @code{exact}.
  1557. This option can also be used to compute the @emph{combined} search paths
  1558. of several profiles. Consider this example:
  1559. @example
  1560. $ guix package -p foo -i guile
  1561. $ guix package -p bar -i guile-json
  1562. $ guix package -p foo -p bar --search-paths
  1563. @end example
  1564. The last command above reports about the @code{GUILE_LOAD_PATH}
  1565. variable, even though, taken individually, neither @file{foo} nor
  1566. @file{bar} would lead to that recommendation.
  1567. @item --profile=@var{profile}
  1568. @itemx -p @var{profile}
  1569. Use @var{profile} instead of the user's default profile.
  1570. @item --verbose
  1571. Produce verbose output. In particular, emit the build log of the
  1572. environment on the standard error port.
  1573. @item --bootstrap
  1574. Use the bootstrap Guile to build the profile. This option is only
  1575. useful to distribution developers.
  1576. @end table
  1577. In addition to these actions, @command{guix package} supports the
  1578. following options to query the current state of a profile, or the
  1579. availability of packages:
  1580. @table @option
  1581. @item --search=@var{regexp}
  1582. @itemx -s @var{regexp}
  1583. @cindex searching for packages
  1584. List the available packages whose name, synopsis, or description matches
  1585. @var{regexp}, sorted by relevance. Print all the metadata of matching packages in
  1586. @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils,
  1587. GNU recutils manual}).
  1588. This allows specific fields to be extracted using the @command{recsel}
  1589. command, for instance:
  1590. @example
  1591. $ guix package -s malloc | recsel -p name,version,relevance
  1592. name: jemalloc
  1593. version: 4.5.0
  1594. relevance: 6
  1595. name: glibc
  1596. version: 2.25
  1597. relevance: 1
  1598. name: libgc
  1599. version: 7.6.0
  1600. relevance: 1
  1601. @end example
  1602. Similarly, to show the name of all the packages available under the
  1603. terms of the GNU@tie{}LGPL version 3:
  1604. @example
  1605. $ guix package -s "" | recsel -p name -e 'license ~ "LGPL 3"'
  1606. name: elfutils
  1607. name: gmp
  1608. @dots{}
  1609. @end example
  1610. It is also possible to refine search results using several @code{-s}
  1611. flags. For example, the following command returns a list of board
  1612. games:
  1613. @example
  1614. $ guix package -s '\<board\>' -s game | recsel -p name
  1615. name: gnubg
  1616. @dots{}
  1617. @end example
  1618. If we were to omit @code{-s game}, we would also get software packages
  1619. that deal with printed circuit boards; removing the angle brackets
  1620. around @code{board} would further add packages that have to do with
  1621. keyboards.
  1622. And now for a more elaborate example. The following command searches
  1623. for cryptographic libraries, filters out Haskell, Perl, Python, and Ruby
  1624. libraries, and prints the name and synopsis of the matching packages:
  1625. @example
  1626. $ guix package -s crypto -s library | \
  1627. recsel -e '! (name ~ "^(ghc|perl|python|ruby)")' -p name,synopsis
  1628. @end example
  1629. @noindent
  1630. @xref{Selection Expressions,,, recutils, GNU recutils manual}, for more
  1631. information on @dfn{selection expressions} for @code{recsel -e}.
  1632. @item --show=@var{package}
  1633. Show details about @var{package}, taken from the list of available packages, in
  1634. @code{recutils} format (@pxref{Top, GNU recutils databases,, recutils, GNU
  1635. recutils manual}).
  1636. @example
  1637. $ guix package --show=python | recsel -p name,version
  1638. name: python
  1639. version: 2.7.6
  1640. name: python
  1641. version: 3.3.5
  1642. @end example
  1643. You may also specify the full name of a package to only get details about a
  1644. specific version of it:
  1645. @example
  1646. $ guix package --show=python@@3.4 | recsel -p name,version
  1647. name: python
  1648. version: 3.4.3
  1649. @end example
  1650. @item --list-installed[=@var{regexp}]
  1651. @itemx -I [@var{regexp}]
  1652. List the currently installed packages in the specified profile, with the
  1653. most recently installed packages shown last. When @var{regexp} is
  1654. specified, list only installed packages whose name matches @var{regexp}.
  1655. For each installed package, print the following items, separated by
  1656. tabs: the package name, its version string, the part of the package that
  1657. is installed (for instance, @code{out} for the default output,
  1658. @code{include} for its headers, etc.), and the path of this package in
  1659. the store.
  1660. @item --list-available[=@var{regexp}]
  1661. @itemx -A [@var{regexp}]
  1662. List packages currently available in the distribution for this system
  1663. (@pxref{GNU Distribution}). When @var{regexp} is specified, list only
  1664. installed packages whose name matches @var{regexp}.
  1665. For each package, print the following items separated by tabs: its name,
  1666. its version string, the parts of the package (@pxref{Packages with
  1667. Multiple Outputs}), and the source location of its definition.
  1668. @item --list-generations[=@var{pattern}]
  1669. @itemx -l [@var{pattern}]
  1670. @cindex generations
  1671. Return a list of generations along with their creation dates; for each
  1672. generation, show the installed packages, with the most recently
  1673. installed packages shown last. Note that the zeroth generation is never
  1674. shown.
  1675. For each installed package, print the following items, separated by
  1676. tabs: the name of a package, its version string, the part of the package
  1677. that is installed (@pxref{Packages with Multiple Outputs}), and the
  1678. location of this package in the store.
  1679. When @var{pattern} is used, the command returns only matching
  1680. generations. Valid patterns include:
  1681. @itemize
  1682. @item @emph{Integers and comma-separated integers}. Both patterns denote
  1683. generation numbers. For instance, @code{--list-generations=1} returns
  1684. the first one.
  1685. And @code{--list-generations=1,8,2} outputs three generations in the
  1686. specified order. Neither spaces nor trailing commas are allowed.
  1687. @item @emph{Ranges}. @code{--list-generations=2..9} prints the
  1688. specified generations and everything in between. Note that the start of
  1689. a range must be smaller than its end.
  1690. It is also possible to omit the endpoint. For example,
  1691. @code{--list-generations=2..}, returns all generations starting from the
  1692. second one.
  1693. @item @emph{Durations}. You can also get the last @emph{N}@tie{}days, weeks,
  1694. or months by passing an integer along with the first letter of the
  1695. duration. For example, @code{--list-generations=20d} lists generations
  1696. that are up to 20 days old.
  1697. @end itemize
  1698. @item --delete-generations[=@var{pattern}]
  1699. @itemx -d [@var{pattern}]
  1700. When @var{pattern} is omitted, delete all generations except the current
  1701. one.
  1702. This command accepts the same patterns as @option{--list-generations}.
  1703. When @var{pattern} is specified, delete the matching generations. When
  1704. @var{pattern} specifies a duration, generations @emph{older} than the
  1705. specified duration match. For instance, @code{--delete-generations=1m}
  1706. deletes generations that are more than one month old.
  1707. If the current generation matches, it is @emph{not} deleted. Also, the
  1708. zeroth generation is never deleted.
  1709. Note that deleting generations prevents rolling back to them.
  1710. Consequently, this command must be used with care.
  1711. @end table
  1712. Finally, since @command{guix package} may actually start build
  1713. processes, it supports all the common build options (@pxref{Common Build
  1714. Options}). It also supports package transformation options, such as
  1715. @option{--with-source} (@pxref{Package Transformation Options}).
  1716. However, note that package transformations are lost when upgrading; to
  1717. preserve transformations across upgrades, you should define your own
  1718. package variant in a Guile module and add it to @code{GUIX_PACKAGE_PATH}
  1719. (@pxref{Defining Packages}).
  1720. @node Substitutes
  1721. @section Substitutes
  1722. @cindex substitutes
  1723. @cindex pre-built binaries
  1724. Guix supports transparent source/binary deployment, which means that it
  1725. can either build things locally, or download pre-built items from a
  1726. server, or both. We call these pre-built items @dfn{substitutes}---they
  1727. are substitutes for local build results. In many cases, downloading a
  1728. substitute is much faster than building things locally.
  1729. Substitutes can be anything resulting from a derivation build
  1730. (@pxref{Derivations}). Of course, in the common case, they are
  1731. pre-built package binaries, but source tarballs, for instance, which
  1732. also result from derivation builds, can be available as substitutes.
  1733. @menu
  1734. * Official Substitute Server:: One particular source of substitutes.
  1735. * Substitute Server Authorization:: How to enable or disable substitutes.
  1736. * Substitute Authentication:: How Guix verifies substitutes.
  1737. * Proxy Settings:: How to get substitutes via proxy.
  1738. * Substitution Failure:: What happens when substitution fails.
  1739. * On Trusting Binaries:: How can you trust that binary blob?
  1740. @end menu
  1741. @node Official Substitute Server
  1742. @subsection Official Substitute Server
  1743. @cindex hydra
  1744. @cindex build farm
  1745. The @code{mirror.hydra.gnu.org} server is a front-end to an official build farm
  1746. that builds packages from Guix continuously for some
  1747. architectures, and makes them available as substitutes. This is the
  1748. default source of substitutes; it can be overridden by passing the
  1749. @option{--substitute-urls} option either to @command{guix-daemon}
  1750. (@pxref{daemon-substitute-urls,, @code{guix-daemon --substitute-urls}})
  1751. or to client tools such as @command{guix package}
  1752. (@pxref{client-substitute-urls,, client @option{--substitute-urls}
  1753. option}).
  1754. Substitute URLs can be either HTTP or HTTPS.
  1755. HTTPS is recommended because communications are encrypted; conversely,
  1756. using HTTP makes all communications visible to an eavesdropper, who
  1757. could use the information gathered to determine, for instance, whether
  1758. your system has unpatched security vulnerabilities.
  1759. Substitutes from the official build farm are enabled by default when
  1760. using the Guix System Distribution (@pxref{GNU Distribution}). However,
  1761. they are disabled by default when using Guix on a foreign distribution,
  1762. unless you have explicitly enabled them via one of the recommended
  1763. installation steps (@pxref{Installation}). The following paragraphs
  1764. describe how to enable or disable substitutes for the official build
  1765. farm; the same procedure can also be used to enable substitutes for any
  1766. other substitute server.
  1767. @node Substitute Server Authorization
  1768. @subsection Substitute Server Authorization
  1769. @cindex security
  1770. @cindex substitutes, authorization thereof
  1771. @cindex access control list (ACL), for substitutes
  1772. @cindex ACL (access control list), for substitutes
  1773. To allow Guix to download substitutes from @code{hydra.gnu.org} or a
  1774. mirror thereof, you
  1775. must add its public key to the access control list (ACL) of archive
  1776. imports, using the @command{guix archive} command (@pxref{Invoking guix
  1777. archive}). Doing so implies that you trust @code{hydra.gnu.org} to not
  1778. be compromised and to serve genuine substitutes.
  1779. The public key for @code{hydra.gnu.org} is installed along with Guix, in
  1780. @code{@var{prefix}/share/guix/hydra.gnu.org.pub}, where @var{prefix} is
  1781. the installation prefix of Guix. If you installed Guix from source,
  1782. make sure you checked the GPG signature of
  1783. @file{guix-@value{VERSION}.tar.gz}, which contains this public key file.
  1784. Then, you can run something like this:
  1785. @example
  1786. # guix archive --authorize < @var{prefix}/share/guix/hydra.gnu.org.pub
  1787. @end example
  1788. @quotation Note
  1789. Similarly, the @file{berlin.guixsd.org.pub} file contains the public key
  1790. for the project's new build farm, reachable at
  1791. @indicateurl{https://berlin.guixsd.org}.
  1792. As of this writing @code{berlin.guixsd.org} is being upgraded so it can
  1793. better scale up, but you might want to give it a try. It is backed by
  1794. 20 x86_64/i686 build nodes and may be able to provide substitutes more
  1795. quickly than @code{mirror.hydra.gnu.org}.
  1796. @end quotation
  1797. Once this is in place, the output of a command like @code{guix build}
  1798. should change from something like:
  1799. @example
  1800. $ guix build emacs --dry-run
  1801. The following derivations would be built:
  1802. /gnu/store/yr7bnx8xwcayd6j95r2clmkdl1qh688w-emacs-24.3.drv
  1803. /gnu/store/x8qsh1hlhgjx6cwsjyvybnfv2i37z23w-dbus-1.6.4.tar.gz.drv
  1804. /gnu/store/1ixwp12fl950d15h2cj11c73733jay0z-alsa-lib-1.0.27.1.tar.bz2.drv
  1805. /gnu/store/nlma1pw0p603fpfiqy7kn4zm105r5dmw-util-linux-2.21.drv
  1806. @dots{}
  1807. @end example
  1808. @noindent
  1809. to something like:
  1810. @example
  1811. $ guix build emacs --dry-run
  1812. 112.3 MB would be downloaded:
  1813. /gnu/store/pk3n22lbq6ydamyymqkkz7i69wiwjiwi-emacs-24.3
  1814. /gnu/store/2ygn4ncnhrpr61rssa6z0d9x22si0va3-libjpeg-8d
  1815. /gnu/store/71yz6lgx4dazma9dwn2mcjxaah9w77jq-cairo-1.12.16
  1816. /gnu/store/7zdhgp0n1518lvfn8mb96sxqfmvqrl7v-libxrender-0.9.7
  1817. @dots{}
  1818. @end example
  1819. @noindent
  1820. This indicates that substitutes from @code{hydra.gnu.org} are usable and
  1821. will be downloaded, when possible, for future builds.
  1822. @cindex substitutes, how to disable
  1823. The substitute mechanism can be disabled globally by running
  1824. @code{guix-daemon} with @code{--no-substitutes} (@pxref{Invoking
  1825. guix-daemon}). It can also be disabled temporarily by passing the
  1826. @code{--no-substitutes} option to @command{guix package}, @command{guix
  1827. build}, and other command-line tools.
  1828. @node Substitute Authentication
  1829. @subsection Substitute Authentication
  1830. @cindex digital signatures
  1831. Guix detects and raises an error when attempting to use a substitute
  1832. that has been tampered with. Likewise, it ignores substitutes that are
  1833. not signed, or that are not signed by one of the keys listed in the ACL.
  1834. There is one exception though: if an unauthorized server provides
  1835. substitutes that are @emph{bit-for-bit identical} to those provided by
  1836. an authorized server, then the unauthorized server becomes eligible for
  1837. downloads. For example, assume we have chosen two substitute servers
  1838. with this option:
  1839. @example
  1840. --substitute-urls="https://a.example.org https://b.example.org"
  1841. @end example
  1842. @noindent
  1843. @cindex reproducible builds
  1844. If the ACL contains only the key for @code{b.example.org}, and if
  1845. @code{a.example.org} happens to serve the @emph{exact same} substitutes,
  1846. then Guix will download substitutes from @code{a.example.org} because it
  1847. comes first in the list and can be considered a mirror of
  1848. @code{b.example.org}. In practice, independent build machines usually
  1849. produce the same binaries, thanks to bit-reproducible builds (see
  1850. below).
  1851. When using HTTPS, the server's X.509 certificate is @emph{not} validated
  1852. (in other words, the server is not authenticated), contrary to what
  1853. HTTPS clients such as Web browsers usually do. This is because Guix
  1854. authenticates substitute information itself, as explained above, which
  1855. is what we care about (whereas X.509 certificates are about
  1856. authenticating bindings between domain names and public keys.)
  1857. @node Proxy Settings
  1858. @subsection Proxy Settings
  1859. @vindex http_proxy
  1860. Substitutes are downloaded over HTTP or HTTPS.
  1861. The @code{http_proxy} environment
  1862. variable can be set in the environment of @command{guix-daemon} and is
  1863. honored for downloads of substitutes. Note that the value of
  1864. @code{http_proxy} in the environment where @command{guix build},
  1865. @command{guix package}, and other client commands are run has
  1866. @emph{absolutely no effect}.
  1867. @node Substitution Failure
  1868. @subsection Substitution Failure
  1869. Even when a substitute for a derivation is available, sometimes the
  1870. substitution attempt will fail. This can happen for a variety of
  1871. reasons: the substitute server might be offline, the substitute may
  1872. recently have been deleted, the connection might have been interrupted,
  1873. etc.
  1874. When substitutes are enabled and a substitute for a derivation is
  1875. available, but the substitution attempt fails, Guix will attempt to
  1876. build the derivation locally depending on whether or not
  1877. @code{--fallback} was given (@pxref{fallback-option,, common build
  1878. option @code{--fallback}}). Specifically, if @code{--fallback} was
  1879. omitted, then no local build will be performed, and the derivation is
  1880. considered to have failed. However, if @code{--fallback} was given,
  1881. then Guix will attempt to build the derivation locally, and the success
  1882. or failure of the derivation depends on the success or failure of the
  1883. local build. Note that when substitutes are disabled or no substitute
  1884. is available for the derivation in question, a local build will
  1885. @emph{always} be performed, regardless of whether or not
  1886. @code{--fallback} was given.
  1887. To get an idea of how many substitutes are available right now, you can
  1888. try running the @command{guix weather} command (@pxref{Invoking guix
  1889. weather}). This command provides statistics on the substitutes provided
  1890. by a server.
  1891. @node On Trusting Binaries
  1892. @subsection On Trusting Binaries
  1893. @cindex trust, of pre-built binaries
  1894. Today, each individual's control over their own computing is at the
  1895. mercy of institutions, corporations, and groups with enough power and
  1896. determination to subvert the computing infrastructure and exploit its
  1897. weaknesses. While using @code{hydra.gnu.org} substitutes can be
  1898. convenient, we encourage users to also build on their own, or even run
  1899. their own build farm, such that @code{hydra.gnu.org} is less of an
  1900. interesting target. One way to help is by publishing the software you
  1901. build using @command{guix publish} so that others have one more choice
  1902. of server to download substitutes from (@pxref{Invoking guix publish}).
  1903. Guix has the foundations to maximize build reproducibility
  1904. (@pxref{Features}). In most cases, independent builds of a given
  1905. package or derivation should yield bit-identical results. Thus, through
  1906. a diverse set of independent package builds, we can strengthen the
  1907. integrity of our systems. The @command{guix challenge} command aims to
  1908. help users assess substitute servers, and to assist developers in
  1909. finding out about non-deterministic package builds (@pxref{Invoking guix
  1910. challenge}). Similarly, the @option{--check} option of @command{guix
  1911. build} allows users to check whether previously-installed substitutes
  1912. are genuine by rebuilding them locally (@pxref{build-check,
  1913. @command{guix build --check}}).
  1914. In the future, we want Guix to have support to publish and retrieve
  1915. binaries to/from other users, in a peer-to-peer fashion. If you would
  1916. like to discuss this project, join us on @email{guix-devel@@gnu.org}.
  1917. @node Packages with Multiple Outputs
  1918. @section Packages with Multiple Outputs
  1919. @cindex multiple-output packages
  1920. @cindex package outputs
  1921. @cindex outputs
  1922. Often, packages defined in Guix have a single @dfn{output}---i.e., the
  1923. source package leads to exactly one directory in the store. When running
  1924. @command{guix package -i glibc}, one installs the default output of the
  1925. GNU libc package; the default output is called @code{out}, but its name
  1926. can be omitted as shown in this command. In this particular case, the
  1927. default output of @code{glibc} contains all the C header files, shared
  1928. libraries, static libraries, Info documentation, and other supporting
  1929. files.
  1930. Sometimes it is more appropriate to separate the various types of files
  1931. produced from a single source package into separate outputs. For
  1932. instance, the GLib C library (used by GTK+ and related packages)
  1933. installs more than 20 MiB of reference documentation as HTML pages.
  1934. To save space for users who do not need it, the documentation goes to a
  1935. separate output, called @code{doc}. To install the main GLib output,
  1936. which contains everything but the documentation, one would run:
  1937. @example
  1938. guix package -i glib
  1939. @end example
  1940. @cindex documentation
  1941. The command to install its documentation is:
  1942. @example
  1943. guix package -i glib:doc
  1944. @end example
  1945. Some packages install programs with different ``dependency footprints''.
  1946. For instance, the WordNet package installs both command-line tools and
  1947. graphical user interfaces (GUIs). The former depend solely on the C
  1948. library, whereas the latter depend on Tcl/Tk and the underlying X
  1949. libraries. In this case, we leave the command-line tools in the default
  1950. output, whereas the GUIs are in a separate output. This allows users
  1951. who do not need the GUIs to save space. The @command{guix size} command
  1952. can help find out about such situations (@pxref{Invoking guix size}).
  1953. @command{guix graph} can also be helpful (@pxref{Invoking guix graph}).
  1954. There are several such multiple-output packages in the GNU distribution.
  1955. Other conventional output names include @code{lib} for libraries and
  1956. possibly header files, @code{bin} for stand-alone programs, and
  1957. @code{debug} for debugging information (@pxref{Installing Debugging
  1958. Files}). The outputs of a packages are listed in the third column of
  1959. the output of @command{guix package --list-available} (@pxref{Invoking
  1960. guix package}).
  1961. @node Invoking guix gc
  1962. @section Invoking @command{guix gc}
  1963. @cindex garbage collector
  1964. @cindex disk space
  1965. Packages that are installed, but not used, may be @dfn{garbage-collected}.
  1966. The @command{guix gc} command allows users to explicitly run the garbage
  1967. collector to reclaim space from the @file{/gnu/store} directory. It is
  1968. the @emph{only} way to remove files from @file{/gnu/store}---removing
  1969. files or directories manually may break it beyond repair!
  1970. @cindex GC roots
  1971. @cindex garbage collector roots
  1972. The garbage collector has a set of known @dfn{roots}: any file under
  1973. @file{/gnu/store} reachable from a root is considered @dfn{live} and
  1974. cannot be deleted; any other file is considered @dfn{dead} and may be
  1975. deleted. The set of garbage collector roots (``GC roots'' for short)
  1976. includes default user profiles; by default, the symlinks under
  1977. @file{/var/guix/gcroots} represent these GC roots. New GC roots can be
  1978. added with @command{guix build --root}, for example (@pxref{Invoking
  1979. guix build}).
  1980. Prior to running @code{guix gc --collect-garbage} to make space, it is
  1981. often useful to remove old generations from user profiles; that way, old
  1982. package builds referenced by those generations can be reclaimed. This
  1983. is achieved by running @code{guix package --delete-generations}
  1984. (@pxref{Invoking guix package}).
  1985. Our recommendation is to run a garbage collection periodically, or when
  1986. you are short on disk space. For instance, to guarantee that at least
  1987. 5@tie{}GB are available on your disk, simply run:
  1988. @example
  1989. guix gc -F 5G
  1990. @end example
  1991. It is perfectly safe to run as a non-interactive periodic job
  1992. (@pxref{Scheduled Job Execution}, for how to set up such a job on
  1993. GuixSD). Running @command{guix gc} with no arguments will collect as
  1994. much garbage as it can, but that is often inconvenient: you may find
  1995. yourself having to rebuild or re-download software that is ``dead'' from
  1996. the GC viewpoint but that is necessary to build other pieces of
  1997. software---e.g., the compiler tool chain.
  1998. The @command{guix gc} command has three modes of operation: it can be
  1999. used to garbage-collect any dead files (the default), to delete specific
  2000. files (the @code{--delete} option), to print garbage-collector
  2001. information, or for more advanced queries. The garbage collection
  2002. options are as follows:
  2003. @table @code
  2004. @item --collect-garbage[=@var{min}]
  2005. @itemx -C [@var{min}]
  2006. Collect garbage---i.e., unreachable @file{/gnu/store} files and
  2007. sub-directories. This is the default operation when no option is
  2008. specified.
  2009. When @var{min} is given, stop once @var{min} bytes have been collected.
  2010. @var{min} may be a number of bytes, or it may include a unit as a
  2011. suffix, such as @code{MiB} for mebibytes and @code{GB} for gigabytes
  2012. (@pxref{Block size, size specifications,, coreutils, GNU Coreutils}).
  2013. When @var{min} is omitted, collect all the garbage.
  2014. @item --free-space=@var{free}
  2015. @itemx -F @var{free}
  2016. Collect garbage until @var{free} space is available under
  2017. @file{/gnu/store}, if possible; @var{free} denotes storage space, such
  2018. as @code{500MiB}, as described above.
  2019. When @var{free} or more is already available in @file{/gnu/store}, do
  2020. nothing and exit immediately.
  2021. @item --delete
  2022. @itemx -d
  2023. Attempt to delete all the store files and directories specified as
  2024. arguments. This fails if some of the files are not in the store, or if
  2025. they are still live.
  2026. @item --list-failures
  2027. List store items corresponding to cached build failures.
  2028. This prints nothing unless the daemon was started with
  2029. @option{--cache-failures} (@pxref{Invoking guix-daemon,
  2030. @option{--cache-failures}}).
  2031. @item --clear-failures
  2032. Remove the specified store items from the failed-build cache.
  2033. Again, this option only makes sense when the daemon is started with
  2034. @option{--cache-failures}. Otherwise, it does nothing.
  2035. @item --list-dead
  2036. Show the list of dead files and directories still present in the
  2037. store---i.e., files and directories no longer reachable from any root.
  2038. @item --list-live
  2039. Show the list of live store files and directories.
  2040. @end table
  2041. In addition, the references among existing store files can be queried:
  2042. @table @code
  2043. @item --references
  2044. @itemx --referrers
  2045. @cindex package dependencies
  2046. List the references (respectively, the referrers) of store files given
  2047. as arguments.
  2048. @item --requisites
  2049. @itemx -R
  2050. @cindex closure
  2051. List the requisites of the store files passed as arguments. Requisites
  2052. include the store files themselves, their references, and the references
  2053. of these, recursively. In other words, the returned list is the
  2054. @dfn{transitive closure} of the store files.
  2055. @xref{Invoking guix size}, for a tool to profile the size of the closure
  2056. of an element. @xref{Invoking guix graph}, for a tool to visualize
  2057. the graph of references.
  2058. @end table
  2059. Lastly, the following options allow you to check the integrity of the
  2060. store and to control disk usage.
  2061. @table @option
  2062. @item --verify[=@var{options}]
  2063. @cindex integrity, of the store
  2064. @cindex integrity checking
  2065. Verify the integrity of the store.
  2066. By default, make sure that all the store items marked as valid in the
  2067. database of the daemon actually exist in @file{/gnu/store}.
  2068. When provided, @var{options} must be a comma-separated list containing one
  2069. or more of @code{contents} and @code{repair}.
  2070. When passing @option{--verify=contents}, the daemon computes the
  2071. content hash of each store item and compares it against its hash in the
  2072. database. Hash mismatches are reported as data corruptions. Because it
  2073. traverses @emph{all the files in the store}, this command can take a
  2074. long time, especially on systems with a slow disk drive.
  2075. @cindex repairing the store
  2076. @cindex corruption, recovering from
  2077. Using @option{--verify=repair} or @option{--verify=contents,repair}
  2078. causes the daemon to try to repair corrupt store items by fetching
  2079. substitutes for them (@pxref{Substitutes}). Because repairing is not
  2080. atomic, and thus potentially dangerous, it is available only to the
  2081. system administrator. A lightweight alternative, when you know exactly
  2082. which items in the store are corrupt, is @command{guix build --repair}
  2083. (@pxref{Invoking guix build}).
  2084. @item --optimize
  2085. @cindex deduplication
  2086. Optimize the store by hard-linking identical files---this is
  2087. @dfn{deduplication}.
  2088. The daemon performs deduplication after each successful build or archive
  2089. import, unless it was started with @code{--disable-deduplication}
  2090. (@pxref{Invoking guix-daemon, @code{--disable-deduplication}}). Thus,
  2091. this option is primarily useful when the daemon was running with
  2092. @code{--disable-deduplication}.
  2093. @end table
  2094. @node Invoking guix pull
  2095. @section Invoking @command{guix pull}
  2096. @cindex upgrading Guix
  2097. @cindex updating Guix
  2098. @cindex @command{guix pull}
  2099. @cindex pull
  2100. Packages are installed or upgraded to the latest version available in
  2101. the distribution currently available on your local machine. To update
  2102. that distribution, along with the Guix tools, you must run @command{guix
  2103. pull}: the command downloads the latest Guix source code and package
  2104. descriptions, and deploys it. Source code is downloaded from a
  2105. @uref{https://git-scm.com, Git} repository.
  2106. On completion, @command{guix package} will use packages and package
  2107. versions from this just-retrieved copy of Guix. Not only that, but all
  2108. the Guix commands and Scheme modules will also be taken from that latest
  2109. version. New @command{guix} sub-commands added by the update also
  2110. become available.
  2111. Any user can update their Guix copy using @command{guix pull}, and the
  2112. effect is limited to the user who run @command{guix pull}. For
  2113. instance, when user @code{root} runs @command{guix pull}, this has no
  2114. effect on the version of Guix that user @code{alice} sees, and vice
  2115. versa@footnote{Under the hood, @command{guix pull} updates the
  2116. @file{~/.config/guix/latest} symbolic link to point to the latest Guix,
  2117. and the @command{guix} command loads code from there. Currently, the
  2118. only way to roll back an invocation of @command{guix pull} is to
  2119. manually update this symlink to point to the previous Guix.}.
  2120. The @command{guix pull} command is usually invoked with no arguments,
  2121. but it supports the following options:
  2122. @table @code
  2123. @item --verbose
  2124. Produce verbose output, writing build logs to the standard error output.
  2125. @item --url=@var{url}
  2126. Download Guix from the Git repository at @var{url}.
  2127. @vindex GUIX_PULL_URL
  2128. By default, the source is taken from its canonical Git repository at
  2129. @code{gnu.org}, for the stable branch of Guix. To use a different source,
  2130. set the @code{GUIX_PULL_URL} environment variable.
  2131. @item --commit=@var{commit}
  2132. Deploy @var{commit}, a valid Git commit ID represented as a hexadecimal
  2133. string.
  2134. @item --branch=@var{branch}
  2135. Deploy the tip of @var{branch}, the name of a Git branch available on
  2136. the repository at @var{url}.
  2137. @item --bootstrap
  2138. Use the bootstrap Guile to build the latest Guix. This option is only
  2139. useful to Guix developers.
  2140. @end table
  2141. In addition, @command{guix pull} supports all the common build options
  2142. (@pxref{Common Build Options}).
  2143. @node Invoking guix pack
  2144. @section Invoking @command{guix pack}
  2145. Occasionally you want to pass software to people who are not (yet!)
  2146. lucky enough to be using Guix. You'd tell them to run @command{guix
  2147. package -i @var{something}}, but that's not possible in this case. This
  2148. is where @command{guix pack} comes in.
  2149. @quotation Note
  2150. If you are looking for ways to exchange binaries among machines that
  2151. already run Guix, @pxref{Invoking guix copy}, @ref{Invoking guix
  2152. publish}, and @ref{Invoking guix archive}.
  2153. @end quotation
  2154. @cindex pack
  2155. @cindex bundle
  2156. @cindex application bundle
  2157. @cindex software bundle
  2158. The @command{guix pack} command creates a shrink-wrapped @dfn{pack} or
  2159. @dfn{software bundle}: it creates a tarball or some other archive
  2160. containing the binaries of the software you're interested in, and all
  2161. its dependencies. The resulting archive can be used on any machine that
  2162. does not have Guix, and people can run the exact same binaries as those
  2163. you have with Guix. The pack itself is created in a bit-reproducible
  2164. fashion, so anyone can verify that it really contains the build results
  2165. that you pretend to be shipping.
  2166. For example, to create a bundle containing Guile, Emacs, Geiser, and all
  2167. their dependencies, you can run:
  2168. @example
  2169. $ guix pack guile emacs geiser
  2170. @dots{}
  2171. /gnu/store/@dots{}-pack.tar.gz
  2172. @end example
  2173. The result here is a tarball containing a @file{/gnu/store} directory
  2174. with all the relevant packages. The resulting tarball contains a
  2175. @dfn{profile} with the three packages of interest; the profile is the
  2176. same as would be created by @command{guix package -i}. It is this
  2177. mechanism that is used to create Guix's own standalone binary tarball
  2178. (@pxref{Binary Installation}).
  2179. Users of this pack would have to run
  2180. @file{/gnu/store/@dots{}-profile/bin/guile} to run Guile, which you may
  2181. find inconvenient. To work around it, you can create, say, a
  2182. @file{/opt/gnu/bin} symlink to the profile:
  2183. @example
  2184. guix pack -S /opt/gnu/bin=bin guile emacs geiser
  2185. @end example
  2186. @noindent
  2187. That way, users can happily type @file{/opt/gnu/bin/guile} and enjoy.
  2188. Alternatively, you can produce a pack in the Docker image format using
  2189. the following command:
  2190. @example
  2191. guix pack -f docker guile emacs geiser
  2192. @end example
  2193. @noindent
  2194. The result is a tarball that can be passed to the @command{docker load}
  2195. command. See the
  2196. @uref{https://docs.docker.com/engine/reference/commandline/load/, Docker
  2197. documentation} for more information.
  2198. Several command-line options allow you to customize your pack:
  2199. @table @code
  2200. @item --format=@var{format}
  2201. @itemx -f @var{format}
  2202. Produce a pack in the given @var{format}.
  2203. The available formats are:
  2204. @table @code
  2205. @item tarball
  2206. This is the default format. It produces a tarball containing all the
  2207. specified binaries and symlinks.
  2208. @item docker
  2209. This produces a tarball that follows the
  2210. @uref{https://github.com/docker/docker/blob/master/image/spec/v1.2.md,
  2211. Docker Image Specification}.
  2212. @end table
  2213. @item --expression=@var{expr}
  2214. @itemx -e @var{expr}
  2215. Consider the package @var{expr} evaluates to.
  2216. This has the same purpose as the same-named option in @command{guix
  2217. build} (@pxref{Additional Build Options, @code{--expression} in
  2218. @command{guix build}}).
  2219. @item --system=@var{system}
  2220. @itemx -s @var{system}
  2221. Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
  2222. the system type of the build host.
  2223. @item --target=@var{triplet}
  2224. @cindex cross-compilation
  2225. Cross-build for @var{triplet}, which must be a valid GNU triplet, such
  2226. as @code{"mips64el-linux-gnu"} (@pxref{Specifying target triplets, GNU
  2227. configuration triplets,, autoconf, Autoconf}).
  2228. @item --compression=@var{tool}
  2229. @itemx -C @var{tool}
  2230. Compress the resulting tarball using @var{tool}---one of @code{gzip},
  2231. @code{bzip2}, @code{xz}, @code{lzip}, or @code{none} for no compression.
  2232. @item --symlink=@var{spec}
  2233. @itemx -S @var{spec}
  2234. Add the symlinks specified by @var{spec} to the pack. This option can
  2235. appear several times.
  2236. @var{spec} has the form @code{@var{source}=@var{target}}, where
  2237. @var{source} is the symlink that will be created and @var{target} is the
  2238. symlink target.
  2239. For instance, @code{-S /opt/gnu/bin=bin} creates a @file{/opt/gnu/bin}
  2240. symlink pointing to the @file{bin} sub-directory of the profile.
  2241. @item --localstatedir
  2242. Include the ``local state directory'', @file{/var/guix}, in the
  2243. resulting pack.
  2244. @file{/var/guix} contains the store database (@pxref{The Store}) as well
  2245. as garbage-collector roots (@pxref{Invoking guix gc}). Providing it in
  2246. the pack means that the store is ``complete'' and manageable by Guix;
  2247. not providing it pack means that the store is ``dead'': items cannot be
  2248. added to it or removed from it after extraction of the pack.
  2249. One use case for this is the Guix self-contained binary tarball
  2250. (@pxref{Binary Installation}).
  2251. @end table
  2252. In addition, @command{guix pack} supports all the common build options
  2253. (@pxref{Common Build Options}) and all the package transformation
  2254. options (@pxref{Package Transformation Options}).
  2255. @node Invoking guix archive
  2256. @section Invoking @command{guix archive}
  2257. @cindex @command{guix archive}
  2258. @cindex archive
  2259. The @command{guix archive} command allows users to @dfn{export} files
  2260. from the store into a single archive, and to later @dfn{import} them on
  2261. a machine that runs Guix.
  2262. In particular, it allows store files to be transferred from one machine
  2263. to the store on another machine.
  2264. @quotation Note
  2265. If you're looking for a way to produce archives in a format suitable for
  2266. tools other than Guix, @pxref{Invoking guix pack}.
  2267. @end quotation
  2268. @cindex exporting store items
  2269. To export store files as an archive to standard output, run:
  2270. @example
  2271. guix archive --export @var{options} @var{specifications}...
  2272. @end example
  2273. @var{specifications} may be either store file names or package
  2274. specifications, as for @command{guix package} (@pxref{Invoking guix
  2275. package}). For instance, the following command creates an archive
  2276. containing the @code{gui} output of the @code{git} package and the main
  2277. output of @code{emacs}:
  2278. @example
  2279. guix archive --export git:gui /gnu/store/...-emacs-24.3 > great.nar
  2280. @end example
  2281. If the specified packages are not built yet, @command{guix archive}
  2282. automatically builds them. The build process may be controlled with the
  2283. common build options (@pxref{Common Build Options}).
  2284. To transfer the @code{emacs} package to a machine connected over SSH,
  2285. one would run:
  2286. @example
  2287. guix archive --export -r emacs | ssh the-machine guix archive --import
  2288. @end example
  2289. @noindent
  2290. Similarly, a complete user profile may be transferred from one machine
  2291. to another like this:
  2292. @example
  2293. guix archive --export -r $(readlink -f ~/.guix-profile) | \
  2294. ssh the-machine guix-archive --import
  2295. @end example
  2296. @noindent
  2297. However, note that, in both examples, all of @code{emacs} and the
  2298. profile as well as all of their dependencies are transferred (due to
  2299. @code{-r}), regardless of what is already available in the store on the
  2300. target machine. The @code{--missing} option can help figure out which
  2301. items are missing from the target store. The @command{guix copy}
  2302. command simplifies and optimizes this whole process, so this is probably
  2303. what you should use in this case (@pxref{Invoking guix copy}).
  2304. @cindex nar, archive format
  2305. @cindex normalized archive (nar)
  2306. Archives are stored in the ``normalized archive'' or ``nar'' format, which is
  2307. comparable in spirit to `tar', but with differences
  2308. that make it more appropriate for our purposes. First, rather than
  2309. recording all Unix metadata for each file, the nar format only mentions
  2310. the file type (regular, directory, or symbolic link); Unix permissions
  2311. and owner/group are dismissed. Second, the order in which directory
  2312. entries are stored always follows the order of file names according to
  2313. the C locale collation order. This makes archive production fully
  2314. deterministic.
  2315. When exporting, the daemon digitally signs the contents of the archive,
  2316. and that digital signature is appended. When importing, the daemon
  2317. verifies the signature and rejects the import in case of an invalid
  2318. signature or if the signing key is not authorized.
  2319. @c FIXME: Add xref to daemon doc about signatures.
  2320. The main options are:
  2321. @table @code
  2322. @item --export
  2323. Export the specified store files or packages (see below.) Write the
  2324. resulting archive to the standard output.
  2325. Dependencies are @emph{not} included in the output, unless
  2326. @code{--recursive} is passed.
  2327. @item -r
  2328. @itemx --recursive
  2329. When combined with @code{--export}, this instructs @command{guix
  2330. archive} to include dependencies of the given items in the archive.
  2331. Thus, the resulting archive is self-contained: it contains the closure
  2332. of the exported store items.
  2333. @item --import
  2334. Read an archive from the standard input, and import the files listed
  2335. therein into the store. Abort if the archive has an invalid digital
  2336. signature, or if it is signed by a public key not among the authorized
  2337. keys (see @code{--authorize} below.)
  2338. @item --missing
  2339. Read a list of store file names from the standard input, one per line,
  2340. and write on the standard output the subset of these files missing from
  2341. the store.
  2342. @item --generate-key[=@var{parameters}]
  2343. @cindex signing, archives
  2344. Generate a new key pair for the daemon. This is a prerequisite before
  2345. archives can be exported with @code{--export}. Note that this operation
  2346. usually takes time, because it needs to gather enough entropy to
  2347. generate the key pair.
  2348. The generated key pair is typically stored under @file{/etc/guix}, in
  2349. @file{signing-key.pub} (public key) and @file{signing-key.sec} (private
  2350. key, which must be kept secret.) When @var{parameters} is omitted,
  2351. an ECDSA key using the Ed25519 curve is generated, or, for Libgcrypt
  2352. versions before 1.6.0, it is a 4096-bit RSA key.
  2353. Alternatively, @var{parameters} can specify
  2354. @code{genkey} parameters suitable for Libgcrypt (@pxref{General
  2355. public-key related Functions, @code{gcry_pk_genkey},, gcrypt, The
  2356. Libgcrypt Reference Manual}).
  2357. @item --authorize
  2358. @cindex authorizing, archives
  2359. Authorize imports signed by the public key passed on standard input.
  2360. The public key must be in ``s-expression advanced format''---i.e., the
  2361. same format as the @file{signing-key.pub} file.
  2362. The list of authorized keys is kept in the human-editable file
  2363. @file{/etc/guix/acl}. The file contains
  2364. @url{http://people.csail.mit.edu/rivest/Sexp.txt, ``advanced-format
  2365. s-expressions''} and is structured as an access-control list in the
  2366. @url{http://theworld.com/~cme/spki.txt, Simple Public-Key Infrastructure
  2367. (SPKI)}.
  2368. @item --extract=@var{directory}
  2369. @itemx -x @var{directory}
  2370. Read a single-item archive as served by substitute servers
  2371. (@pxref{Substitutes}) and extract it to @var{directory}. This is a
  2372. low-level operation needed in only very narrow use cases; see below.
  2373. For example, the following command extracts the substitute for Emacs
  2374. served by @code{hydra.gnu.org} to @file{/tmp/emacs}:
  2375. @example
  2376. $ wget -O - \
  2377. https://hydra.gnu.org/nar/@dots{}-emacs-24.5 \
  2378. | bunzip2 | guix archive -x /tmp/emacs
  2379. @end example
  2380. Single-item archives are different from multiple-item archives produced
  2381. by @command{guix archive --export}; they contain a single store item,
  2382. and they do @emph{not} embed a signature. Thus this operation does
  2383. @emph{no} signature verification and its output should be considered
  2384. unsafe.
  2385. The primary purpose of this operation is to facilitate inspection of
  2386. archive contents coming from possibly untrusted substitute servers.
  2387. @end table
  2388. @c *********************************************************************
  2389. @node Programming Interface
  2390. @chapter Programming Interface
  2391. GNU Guix provides several Scheme programming interfaces (APIs) to
  2392. define, build, and query packages. The first interface allows users to
  2393. write high-level package definitions. These definitions refer to
  2394. familiar packaging concepts, such as the name and version of a package,
  2395. its build system, and its dependencies. These definitions can then be
  2396. turned into concrete build actions.
  2397. Build actions are performed by the Guix daemon, on behalf of users. In a
  2398. standard setup, the daemon has write access to the store---the
  2399. @file{/gnu/store} directory---whereas users do not. The recommended
  2400. setup also has the daemon perform builds in chroots, under a specific
  2401. build users, to minimize interference with the rest of the system.
  2402. @cindex derivation
  2403. Lower-level APIs are available to interact with the daemon and the
  2404. store. To instruct the daemon to perform a build action, users actually
  2405. provide it with a @dfn{derivation}. A derivation is a low-level
  2406. representation of the build actions to be taken, and the environment in
  2407. which they should occur---derivations are to package definitions what
  2408. assembly is to C programs. The term ``derivation'' comes from the fact
  2409. that build results @emph{derive} from them.
  2410. This chapter describes all these APIs in turn, starting from high-level
  2411. package definitions.
  2412. @menu
  2413. * Defining Packages:: Defining new packages.
  2414. * Build Systems:: Specifying how packages are built.
  2415. * The Store:: Manipulating the package store.
  2416. * Derivations:: Low-level interface to package derivations.
  2417. * The Store Monad:: Purely functional interface to the store.
  2418. * G-Expressions:: Manipulating build expressions.
  2419. @end menu
  2420. @node Defining Packages
  2421. @section Defining Packages
  2422. The high-level interface to package definitions is implemented in the
  2423. @code{(guix packages)} and @code{(guix build-system)} modules. As an
  2424. example, the package definition, or @dfn{recipe}, for the GNU Hello
  2425. package looks like this:
  2426. @example
  2427. (define-module (gnu packages hello)
  2428. #:use-module (guix packages)
  2429. #:use-module (guix download)
  2430. #:use-module (guix build-system gnu)
  2431. #:use-module (guix licenses)
  2432. #:use-module (gnu packages gawk))
  2433. (define-public hello
  2434. (package
  2435. (name "hello")
  2436. (version "2.10")
  2437. (source (origin
  2438. (method url-fetch)
  2439. (uri (string-append "mirror://gnu/hello/hello-" version
  2440. ".tar.gz"))
  2441. (sha256
  2442. (base32
  2443. "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
  2444. (build-system gnu-build-system)
  2445. (arguments '(#:configure-flags '("--enable-silent-rules")))
  2446. (inputs `(("gawk" ,gawk)))
  2447. (synopsis "Hello, GNU world: An example GNU package")
  2448. (description "Guess what GNU Hello prints!")
  2449. (home-page "http://www.gnu.org/software/hello/")
  2450. (license gpl3+)))
  2451. @end example
  2452. @noindent
  2453. Without being a Scheme expert, the reader may have guessed the meaning
  2454. of the various fields here. This expression binds the variable
  2455. @code{hello} to a @code{<package>} object, which is essentially a record
  2456. (@pxref{SRFI-9, Scheme records,, guile, GNU Guile Reference Manual}).
  2457. This package object can be inspected using procedures found in the
  2458. @code{(guix packages)} module; for instance, @code{(package-name hello)}
  2459. returns---surprise!---@code{"hello"}.
  2460. With luck, you may be able to import part or all of the definition of
  2461. the package you are interested in from another repository, using the
  2462. @code{guix import} command (@pxref{Invoking guix import}).
  2463. In the example above, @var{hello} is defined in a module of its own,
  2464. @code{(gnu packages hello)}. Technically, this is not strictly
  2465. necessary, but it is convenient to do so: all the packages defined in
  2466. modules under @code{(gnu packages @dots{})} are automatically known to
  2467. the command-line tools (@pxref{Package Modules}).
  2468. There are a few points worth noting in the above package definition:
  2469. @itemize
  2470. @item
  2471. The @code{source} field of the package is an @code{<origin>} object
  2472. (@pxref{origin Reference}, for the complete reference).
  2473. Here, the @code{url-fetch} method from @code{(guix download)} is used,
  2474. meaning that the source is a file to be downloaded over FTP or HTTP.
  2475. The @code{mirror://gnu} prefix instructs @code{url-fetch} to use one of
  2476. the GNU mirrors defined in @code{(guix download)}.
  2477. The @code{sha256} field specifies the expected SHA256 hash of the file
  2478. being downloaded. It is mandatory, and allows Guix to check the
  2479. integrity of the file. The @code{(base32 @dots{})} form introduces the
  2480. base32 representation of the hash. You can obtain this information with
  2481. @code{guix download} (@pxref{Invoking guix download}) and @code{guix
  2482. hash} (@pxref{Invoking guix hash}).
  2483. @cindex patches
  2484. When needed, the @code{origin} form can also have a @code{patches} field
  2485. listing patches to be applied, and a @code{snippet} field giving a
  2486. Scheme expression to modify the source code.
  2487. @item
  2488. @cindex GNU Build System
  2489. The @code{build-system} field specifies the procedure to build the
  2490. package (@pxref{Build Systems}). Here, @var{gnu-build-system}
  2491. represents the familiar GNU Build System, where packages may be
  2492. configured, built, and installed with the usual @code{./configure &&
  2493. make && make check && make install} command sequence.
  2494. @item
  2495. The @code{arguments} field specifies options for the build system
  2496. (@pxref{Build Systems}). Here it is interpreted by
  2497. @var{gnu-build-system} as a request run @file{configure} with the
  2498. @code{--enable-silent-rules} flag.
  2499. @cindex quote
  2500. @cindex quoting
  2501. @findex '
  2502. @findex quote
  2503. What about these quote (@code{'}) characters? They are Scheme syntax to
  2504. introduce a literal list; @code{'} is synonymous with @code{quote}.
  2505. @xref{Expression Syntax, quoting,, guile, GNU Guile Reference Manual},
  2506. for details. Here the value of the @code{arguments} field is a list of
  2507. arguments passed to the build system down the road, as with @code{apply}
  2508. (@pxref{Fly Evaluation, @code{apply},, guile, GNU Guile Reference
  2509. Manual}).
  2510. The hash-colon (@code{#:}) sequence defines a Scheme @dfn{keyword}
  2511. (@pxref{Keywords,,, guile, GNU Guile Reference Manual}), and
  2512. @code{#:configure-flags} is a keyword used to pass a keyword argument
  2513. to the build system (@pxref{Coding With Keywords,,, guile, GNU Guile
  2514. Reference Manual}).
  2515. @item
  2516. The @code{inputs} field specifies inputs to the build process---i.e.,
  2517. build-time or run-time dependencies of the package. Here, we define an
  2518. input called @code{"gawk"} whose value is that of the @var{gawk}
  2519. variable; @var{gawk} is itself bound to a @code{<package>} object.
  2520. @cindex backquote (quasiquote)
  2521. @findex `
  2522. @findex quasiquote
  2523. @cindex comma (unquote)
  2524. @findex ,
  2525. @findex unquote
  2526. @findex ,@@
  2527. @findex unquote-splicing
  2528. Again, @code{`} (a backquote, synonymous with @code{quasiquote}) allows
  2529. us to introduce a literal list in the @code{inputs} field, while
  2530. @code{,} (a comma, synonymous with @code{unquote}) allows us to insert a
  2531. value in that list (@pxref{Expression Syntax, unquote,, guile, GNU Guile
  2532. Reference Manual}).
  2533. Note that GCC, Coreutils, Bash, and other essential tools do not need to
  2534. be specified as inputs here. Instead, @var{gnu-build-system} takes care
  2535. of ensuring that they are present (@pxref{Build Systems}).
  2536. However, any other dependencies need to be specified in the
  2537. @code{inputs} field. Any dependency not specified here will simply be
  2538. unavailable to the build process, possibly leading to a build failure.
  2539. @end itemize
  2540. @xref{package Reference}, for a full description of possible fields.
  2541. Once a package definition is in place, the
  2542. package may actually be built using the @code{guix build} command-line
  2543. tool (@pxref{Invoking guix build}), troubleshooting any build failures
  2544. you encounter (@pxref{Debugging Build Failures}). You can easily jump back to the
  2545. package definition using the @command{guix edit} command
  2546. (@pxref{Invoking guix edit}).
  2547. @xref{Packaging Guidelines}, for
  2548. more information on how to test package definitions, and
  2549. @ref{Invoking guix lint}, for information on how to check a definition
  2550. for style conformance.
  2551. @vindex GUIX_PACKAGE_PATH
  2552. Lastly, @pxref{Package Modules}, for information
  2553. on how to extend the distribution by adding your own package definitions
  2554. to @code{GUIX_PACKAGE_PATH}.
  2555. Finally, updating the package definition to a new upstream version
  2556. can be partly automated by the @command{guix refresh} command
  2557. (@pxref{Invoking guix refresh}).
  2558. Behind the scenes, a derivation corresponding to the @code{<package>}
  2559. object is first computed by the @code{package-derivation} procedure.
  2560. That derivation is stored in a @code{.drv} file under @file{/gnu/store}.
  2561. The build actions it prescribes may then be realized by using the
  2562. @code{build-derivations} procedure (@pxref{The Store}).
  2563. @deffn {Scheme Procedure} package-derivation @var{store} @var{package} [@var{system}]
  2564. Return the @code{<derivation>} object of @var{package} for @var{system}
  2565. (@pxref{Derivations}).
  2566. @var{package} must be a valid @code{<package>} object, and @var{system}
  2567. must be a string denoting the target system type---e.g.,
  2568. @code{"x86_64-linux"} for an x86_64 Linux-based GNU system. @var{store}
  2569. must be a connection to the daemon, which operates on the store
  2570. (@pxref{The Store}).
  2571. @end deffn
  2572. @noindent
  2573. @cindex cross-compilation
  2574. Similarly, it is possible to compute a derivation that cross-builds a
  2575. package for some other system:
  2576. @deffn {Scheme Procedure} package-cross-derivation @var{store} @
  2577. @var{package} @var{target} [@var{system}]
  2578. Return the @code{<derivation>} object of @var{package} cross-built from
  2579. @var{system} to @var{target}.
  2580. @var{target} must be a valid GNU triplet denoting the target hardware
  2581. and operating system, such as @code{"mips64el-linux-gnu"}
  2582. (@pxref{Configuration Names, GNU configuration triplets,, configure, GNU
  2583. Configure and Build System}).
  2584. @end deffn
  2585. @cindex package transformations
  2586. @cindex input rewriting
  2587. @cindex dependency tree rewriting
  2588. Packages can be manipulated in arbitrary ways. An example of a useful
  2589. transformation is @dfn{input rewriting}, whereby the dependency tree of
  2590. a package is rewritten by replacing specific inputs by others:
  2591. @deffn {Scheme Procedure} package-input-rewriting @var{replacements} @
  2592. [@var{rewrite-name}]
  2593. Return a procedure that, when passed a package, replaces its direct and
  2594. indirect dependencies (but not its implicit inputs) according to
  2595. @var{replacements}. @var{replacements} is a list of package pairs; the
  2596. first element of each pair is the package to replace, and the second one
  2597. is the replacement.
  2598. Optionally, @var{rewrite-name} is a one-argument procedure that takes
  2599. the name of a package and returns its new name after rewrite.
  2600. @end deffn
  2601. @noindent
  2602. Consider this example:
  2603. @example
  2604. (define libressl-instead-of-openssl
  2605. ;; This is a procedure to replace OPENSSL by LIBRESSL,
  2606. ;; recursively.
  2607. (package-input-rewriting `((,openssl . ,libressl))))
  2608. (define git-with-libressl
  2609. (libressl-instead-of-openssl git))
  2610. @end example
  2611. @noindent
  2612. Here we first define a rewriting procedure that replaces @var{openssl}
  2613. with @var{libressl}. Then we use it to define a @dfn{variant} of the
  2614. @var{git} package that uses @var{libressl} instead of @var{openssl}.
  2615. This is exactly what the @option{--with-input} command-line option does
  2616. (@pxref{Package Transformation Options, @option{--with-input}}).
  2617. A more generic procedure to rewrite a package dependency graph is
  2618. @code{package-mapping}: it supports arbitrary changes to nodes in the
  2619. graph.
  2620. @deffn {Scheme Procedure} package-mapping @var{proc} [@var{cut?}]
  2621. Return a procedure that, given a package, applies @var{proc} to all the packages
  2622. depended on and returns the resulting package. The procedure stops recursion
  2623. when @var{cut?} returns true for a given package.
  2624. @end deffn
  2625. @menu
  2626. * package Reference :: The package data type.
  2627. * origin Reference:: The origin data type.
  2628. @end menu
  2629. @node package Reference
  2630. @subsection @code{package} Reference
  2631. This section summarizes all the options available in @code{package}
  2632. declarations (@pxref{Defining Packages}).
  2633. @deftp {Data Type} package
  2634. This is the data type representing a package recipe.
  2635. @table @asis
  2636. @item @code{name}
  2637. The name of the package, as a string.
  2638. @item @code{version}
  2639. The version of the package, as a string.
  2640. @item @code{source}
  2641. An object telling how the source code for the package should be
  2642. acquired. Most of the time, this is an @code{origin} object, which
  2643. denotes a file fetched from the Internet (@pxref{origin Reference}). It
  2644. can also be any other ``file-like'' object such as a @code{local-file},
  2645. which denotes a file from the local file system (@pxref{G-Expressions,
  2646. @code{local-file}}).
  2647. @item @code{build-system}
  2648. The build system that should be used to build the package (@pxref{Build
  2649. Systems}).
  2650. @item @code{arguments} (default: @code{'()})
  2651. The arguments that should be passed to the build system. This is a
  2652. list, typically containing sequential keyword-value pairs.
  2653. @item @code{inputs} (default: @code{'()})
  2654. @itemx @code{native-inputs} (default: @code{'()})
  2655. @itemx @code{propagated-inputs} (default: @code{'()})
  2656. @cindex inputs, of packages
  2657. These fields list dependencies of the package. Each one is a list of
  2658. tuples, where each tuple has a label for the input (a string) as its
  2659. first element, a package, origin, or derivation as its second element,
  2660. and optionally the name of the output thereof that should be used, which
  2661. defaults to @code{"out"} (@pxref{Packages with Multiple Outputs}, for
  2662. more on package outputs). For example, the list below specifies three
  2663. inputs:
  2664. @example
  2665. `(("libffi" ,libffi)
  2666. ("libunistring" ,libunistring)
  2667. ("glib:bin" ,glib "bin")) ;the "bin" output of Glib
  2668. @end example
  2669. @cindex cross compilation, package dependencies
  2670. The distinction between @code{native-inputs} and @code{inputs} is
  2671. necessary when considering cross-compilation. When cross-compiling,
  2672. dependencies listed in @code{inputs} are built for the @emph{target}
  2673. architecture; conversely, dependencies listed in @code{native-inputs}
  2674. are built for the architecture of the @emph{build} machine.
  2675. @code{native-inputs} is typically used to list tools needed at
  2676. build time, but not at run time, such as Autoconf, Automake, pkg-config,
  2677. Gettext, or Bison. @command{guix lint} can report likely mistakes in
  2678. this area (@pxref{Invoking guix lint}).
  2679. @anchor{package-propagated-inputs}
  2680. Lastly, @code{propagated-inputs} is similar to @code{inputs}, but the
  2681. specified packages will be automatically installed alongside the package
  2682. they belong to (@pxref{package-cmd-propagated-inputs, @command{guix
  2683. package}}, for information on how @command{guix package} deals with
  2684. propagated inputs.)
  2685. For example this is necessary when a C/C++ library needs headers of
  2686. another library to compile, or when a pkg-config file refers to another
  2687. one @i{via} its @code{Requires} field.
  2688. Another example where @code{propagated-inputs} is useful is for languages
  2689. that lack a facility to record the run-time search path akin to the
  2690. @code{RUNPATH} of ELF files; this includes Guile, Python, Perl, and
  2691. more. To ensure that libraries written in those languages can find
  2692. library code they depend on at run time, run-time dependencies must be
  2693. listed in @code{propagated-inputs} rather than @code{inputs}.
  2694. @item @code{self-native-input?} (default: @code{#f})
  2695. This is a Boolean field telling whether the package should use itself as
  2696. a native input when cross-compiling.
  2697. @item @code{outputs} (default: @code{'("out")})
  2698. The list of output names of the package. @xref{Packages with Multiple
  2699. Outputs}, for typical uses of additional outputs.
  2700. @item @code{native-search-paths} (default: @code{'()})
  2701. @itemx @code{search-paths} (default: @code{'()})
  2702. A list of @code{search-path-specification} objects describing
  2703. search-path environment variables honored by the package.
  2704. @item @code{replacement} (default: @code{#f})
  2705. This must be either @code{#f} or a package object that will be used as a
  2706. @dfn{replacement} for this package. @xref{Security Updates, grafts},
  2707. for details.
  2708. @item @code{synopsis}
  2709. A one-line description of the package.
  2710. @item @code{description}
  2711. A more elaborate description of the package.
  2712. @item @code{license}
  2713. @cindex license, of packages
  2714. The license of the package; a value from @code{(guix licenses)},
  2715. or a list of such values.
  2716. @item @code{home-page}
  2717. The URL to the home-page of the package, as a string.
  2718. @item @code{supported-systems} (default: @var{%supported-systems})
  2719. The list of systems supported by the package, as strings of the form
  2720. @code{architecture-kernel}, for example @code{"x86_64-linux"}.
  2721. @item @code{maintainers} (default: @code{'()})
  2722. The list of maintainers of the package, as @code{maintainer} objects.
  2723. @item @code{location} (default: source location of the @code{package} form)
  2724. The source location of the package. It is useful to override this when
  2725. inheriting from another package, in which case this field is not
  2726. automatically corrected.
  2727. @end table
  2728. @end deftp
  2729. @node origin Reference
  2730. @subsection @code{origin} Reference
  2731. This section summarizes all the options available in @code{origin}
  2732. declarations (@pxref{Defining Packages}).
  2733. @deftp {Data Type} origin
  2734. This is the data type representing a source code origin.
  2735. @table @asis
  2736. @item @code{uri}
  2737. An object containing the URI of the source. The object type depends on
  2738. the @code{method} (see below). For example, when using the
  2739. @var{url-fetch} method of @code{(guix download)}, the valid @code{uri}
  2740. values are: a URL represented as a string, or a list thereof.
  2741. @item @code{method}
  2742. A procedure that handles the URI.
  2743. Examples include:
  2744. @table @asis
  2745. @item @var{url-fetch} from @code{(guix download)}
  2746. download a file from the HTTP, HTTPS, or FTP URL specified in the
  2747. @code{uri} field;
  2748. @vindex git-fetch
  2749. @item @var{git-fetch} from @code{(guix git-download)}
  2750. clone the Git version control repository, and check out the revision
  2751. specified in the @code{uri} field as a @code{git-reference} object; a
  2752. @code{git-reference} looks like this:
  2753. @example
  2754. (git-reference
  2755. (url "git://git.debian.org/git/pkg-shadow/shadow")
  2756. (commit "v4.1.5.1"))
  2757. @end example
  2758. @end table
  2759. @item @code{sha256}
  2760. A bytevector containing the SHA-256 hash of the source. Typically the
  2761. @code{base32} form is used here to generate the bytevector from a
  2762. base-32 string.
  2763. You can obtain this information using @code{guix download}
  2764. (@pxref{Invoking guix download}) or @code{guix hash} (@pxref{Invoking
  2765. guix hash}).
  2766. @item @code{file-name} (default: @code{#f})
  2767. The file name under which the source code should be saved. When this is
  2768. @code{#f}, a sensible default value will be used in most cases. In case
  2769. the source is fetched from a URL, the file name from the URL will be
  2770. used. For version control checkouts, it is recommended to provide the
  2771. file name explicitly because the default is not very descriptive.
  2772. @item @code{patches} (default: @code{'()})
  2773. A list of file names, origins, or file-like objects (@pxref{G-Expressions,
  2774. file-like objects}) pointing to patches to be applied to the source.
  2775. This list of patches must be unconditional. In particular, it cannot
  2776. depend on the value of @code{%current-system} or
  2777. @code{%current-target-system}.
  2778. @item @code{snippet} (default: @code{#f})
  2779. A G-expression (@pxref{G-Expressions}) or S-expression that will be run
  2780. in the source directory. This is a convenient way to modify the source,
  2781. sometimes more convenient than a patch.
  2782. @item @code{patch-flags} (default: @code{'("-p1")})
  2783. A list of command-line flags that should be passed to the @code{patch}
  2784. command.
  2785. @item @code{patch-inputs} (default: @code{#f})
  2786. Input packages or derivations to the patching process. When this is
  2787. @code{#f}, the usual set of inputs necessary for patching are provided,
  2788. such as GNU@tie{}Patch.
  2789. @item @code{modules} (default: @code{'()})
  2790. A list of Guile modules that should be loaded during the patching
  2791. process and while running the code in the @code{snippet} field.
  2792. @item @code{patch-guile} (default: @code{#f})
  2793. The Guile package that should be used in the patching process. When
  2794. this is @code{#f}, a sensible default is used.
  2795. @end table
  2796. @end deftp
  2797. @node Build Systems
  2798. @section Build Systems
  2799. @cindex build system
  2800. Each package definition specifies a @dfn{build system} and arguments for
  2801. that build system (@pxref{Defining Packages}). This @code{build-system}
  2802. field represents the build procedure of the package, as well as implicit
  2803. dependencies of that build procedure.
  2804. Build systems are @code{<build-system>} objects. The interface to
  2805. create and manipulate them is provided by the @code{(guix build-system)}
  2806. module, and actual build systems are exported by specific modules.
  2807. @cindex bag (low-level package representation)
  2808. Under the hood, build systems first compile package objects to
  2809. @dfn{bags}. A @dfn{bag} is like a package, but with less
  2810. ornamentation---in other words, a bag is a lower-level representation of
  2811. a package, which includes all the inputs of that package, including some
  2812. that were implicitly added by the build system. This intermediate
  2813. representation is then compiled to a derivation (@pxref{Derivations}).
  2814. Build systems accept an optional list of @dfn{arguments}. In package
  2815. definitions, these are passed @i{via} the @code{arguments} field
  2816. (@pxref{Defining Packages}). They are typically keyword arguments
  2817. (@pxref{Optional Arguments, keyword arguments in Guile,, guile, GNU
  2818. Guile Reference Manual}). The value of these arguments is usually
  2819. evaluated in the @dfn{build stratum}---i.e., by a Guile process launched
  2820. by the daemon (@pxref{Derivations}).
  2821. The main build system is @var{gnu-build-system}, which implements the
  2822. standard build procedure for GNU and many other packages. It
  2823. is provided by the @code{(guix build-system gnu)} module.
  2824. @defvr {Scheme Variable} gnu-build-system
  2825. @var{gnu-build-system} represents the GNU Build System, and variants
  2826. thereof (@pxref{Configuration, configuration and makefile conventions,,
  2827. standards, GNU Coding Standards}).
  2828. @cindex build phases
  2829. In a nutshell, packages using it are configured, built, and installed with
  2830. the usual @code{./configure && make && make check && make install}
  2831. command sequence. In practice, a few additional steps are often needed.
  2832. All these steps are split up in separate @dfn{phases},
  2833. notably@footnote{Please see the @code{(guix build gnu-build-system)}
  2834. modules for more details about the build phases.}:
  2835. @table @code
  2836. @item unpack
  2837. Unpack the source tarball, and change the current directory to the
  2838. extracted source tree. If the source is actually a directory, copy it
  2839. to the build tree, and enter that directory.
  2840. @item patch-source-shebangs
  2841. Patch shebangs encountered in source files so they refer to the right
  2842. store file names. For instance, this changes @code{#!/bin/sh} to
  2843. @code{#!/gnu/store/@dots{}-bash-4.3/bin/sh}.
  2844. @item configure
  2845. Run the @file{configure} script with a number of default options, such
  2846. as @code{--prefix=/gnu/store/@dots{}}, as well as the options specified
  2847. by the @code{#:configure-flags} argument.
  2848. @item build
  2849. Run @code{make} with the list of flags specified with
  2850. @code{#:make-flags}. If the @code{#:parallel-build?} argument is true
  2851. (the default), build with @code{make -j}.
  2852. @item check
  2853. Run @code{make check}, or some other target specified with
  2854. @code{#:test-target}, unless @code{#:tests? #f} is passed. If the
  2855. @code{#:parallel-tests?} argument is true (the default), run @code{make
  2856. check -j}.
  2857. @item install
  2858. Run @code{make install} with the flags listed in @code{#:make-flags}.
  2859. @item patch-shebangs
  2860. Patch shebangs on the installed executable files.
  2861. @item strip
  2862. Strip debugging symbols from ELF files (unless @code{#:strip-binaries?}
  2863. is false), copying them to the @code{debug} output when available
  2864. (@pxref{Installing Debugging Files}).
  2865. @end table
  2866. @vindex %standard-phases
  2867. The build-side module @code{(guix build gnu-build-system)} defines
  2868. @var{%standard-phases} as the default list of build phases.
  2869. @var{%standard-phases} is a list of symbol/procedure pairs, where the
  2870. procedure implements the actual phase.
  2871. The list of phases used for a particular package can be changed with the
  2872. @code{#:phases} parameter. For instance, passing:
  2873. @example
  2874. #:phases (modify-phases %standard-phases (delete 'configure))
  2875. @end example
  2876. means that all the phases described above will be used, except the
  2877. @code{configure} phase.
  2878. In addition, this build system ensures that the ``standard'' environment
  2879. for GNU packages is available. This includes tools such as GCC, libc,
  2880. Coreutils, Bash, Make, Diffutils, grep, and sed (see the @code{(guix
  2881. build-system gnu)} module for a complete list). We call these the
  2882. @dfn{implicit inputs} of a package, because package definitions do not
  2883. have to mention them.
  2884. @end defvr
  2885. Other @code{<build-system>} objects are defined to support other
  2886. conventions and tools used by free software packages. They inherit most
  2887. of @var{gnu-build-system}, and differ mainly in the set of inputs
  2888. implicitly added to the build process, and in the list of phases
  2889. executed. Some of these build systems are listed below.
  2890. @defvr {Scheme Variable} ant-build-system
  2891. This variable is exported by @code{(guix build-system ant)}. It
  2892. implements the build procedure for Java packages that can be built with
  2893. @url{http://ant.apache.org/, Ant build tool}.
  2894. It adds both @code{ant} and the @dfn{Java Development Kit} (JDK) as
  2895. provided by the @code{icedtea} package to the set of inputs. Different
  2896. packages can be specified with the @code{#:ant} and @code{#:jdk}
  2897. parameters, respectively.
  2898. When the original package does not provide a suitable Ant build file,
  2899. the parameter @code{#:jar-name} can be used to generate a minimal Ant
  2900. build file @file{build.xml} with tasks to build the specified jar
  2901. archive. In this case the parameter @code{#:source-dir} can be used to
  2902. specify the source sub-directory, defaulting to ``src''.
  2903. The @code{#:main-class} parameter can be used with the minimal ant
  2904. buildfile to specify the main class of the resulting jar. This makes the
  2905. jar file executable. The @code{#:test-include} parameter can be used to
  2906. specify the list of junit tests to run. It defaults to
  2907. @code{(list "**/*Test.java")}. The @code{#:test-exclude} can be used to
  2908. disable some tests. It defaults to @code{(list "**/Abstract*.java")},
  2909. because abstract classes cannot be run as tests.
  2910. The parameter @code{#:build-target} can be used to specify the Ant task
  2911. that should be run during the @code{build} phase. By default the
  2912. ``jar'' task will be run.
  2913. @end defvr
  2914. @defvr {Scheme Variable} asdf-build-system/source
  2915. @defvrx {Scheme Variable} asdf-build-system/sbcl
  2916. @defvrx {Scheme Variable} asdf-build-system/ecl
  2917. These variables, exported by @code{(guix build-system asdf)}, implement
  2918. build procedures for Common Lisp packages using
  2919. @url{https://common-lisp.net/project/asdf/, ``ASDF''}. ASDF is a system
  2920. definition facility for Common Lisp programs and libraries.
  2921. The @code{asdf-build-system/source} system installs the packages in
  2922. source form, and can be loaded using any common lisp implementation, via
  2923. ASDF. The others, such as @code{asdf-build-system/sbcl}, install binary
  2924. systems in the format which a particular implementation understands.
  2925. These build systems can also be used to produce executable programs, or
  2926. lisp images which contain a set of packages pre-loaded.
  2927. The build system uses naming conventions. For binary packages, the
  2928. package name should be prefixed with the lisp implementation, such as
  2929. @code{sbcl-} for @code{asdf-build-system/sbcl}.
  2930. Additionally, the corresponding source package should be labeled using
  2931. the same convention as python packages (see @ref{Python Modules}), using
  2932. the @code{cl-} prefix.
  2933. For binary packages, each system should be defined as a Guix package.
  2934. If one package @code{origin} contains several systems, package variants
  2935. can be created in order to build all the systems. Source packages,
  2936. which use @code{asdf-build-system/source}, may contain several systems.
  2937. In order to create executable programs and images, the build-side
  2938. procedures @code{build-program} and @code{build-image} can be used.
  2939. They should be called in a build phase after the @code{create-symlinks}
  2940. phase, so that the system which was just built can be used within the
  2941. resulting image. @code{build-program} requires a list of Common Lisp
  2942. expressions to be passed as the @code{#:entry-program} argument.
  2943. If the system is not defined within its own @code{.asd} file of the same
  2944. name, then the @code{#:asd-file} parameter should be used to specify
  2945. which file the system is defined in. Furthermore, if the package
  2946. defines a system for its tests in a separate file, it will be loaded
  2947. before the tests are run if it is specified by the
  2948. @code{#:test-asd-file} parameter. If it is not set, the files
  2949. @code{<system>-tests.asd}, @code{<system>-test.asd}, @code{tests.asd},
  2950. and @code{test.asd} will be tried if they exist.
  2951. If for some reason the package must be named in a different way than the
  2952. naming conventions suggest, the @code{#:asd-system-name} parameter can
  2953. be used to specify the name of the system.
  2954. @end defvr
  2955. @defvr {Scheme Variable} cargo-build-system
  2956. @cindex Rust programming language
  2957. @cindex Cargo (Rust build system)
  2958. This variable is exported by @code{(guix build-system cargo)}. It
  2959. supports builds of packages using Cargo, the build tool of the
  2960. @uref{https://www.rust-lang.org, Rust programming language}.
  2961. In its @code{configure} phase, this build system replaces dependencies
  2962. specified in the @file{Carto.toml} file with inputs to the Guix package.
  2963. The @code{install} phase installs the binaries, and it also installs the
  2964. source code and @file{Cargo.toml} file.
  2965. @end defvr
  2966. @defvr {Scheme Variable} cmake-build-system
  2967. This variable is exported by @code{(guix build-system cmake)}. It
  2968. implements the build procedure for packages using the
  2969. @url{http://www.cmake.org, CMake build tool}.
  2970. It automatically adds the @code{cmake} package to the set of inputs.
  2971. Which package is used can be specified with the @code{#:cmake}
  2972. parameter.
  2973. The @code{#:configure-flags} parameter is taken as a list of flags
  2974. passed to the @command{cmake} command. The @code{#:build-type}
  2975. parameter specifies in abstract terms the flags passed to the compiler;
  2976. it defaults to @code{"RelWithDebInfo"} (short for ``release mode with
  2977. debugging information''), which roughly means that code is compiled with
  2978. @code{-O2 -g}, as is the case for Autoconf-based packages by default.
  2979. @end defvr
  2980. @defvr {Scheme Variable} go-build-system
  2981. This variable is exported by @code{(guix build-system go)}. It
  2982. implements a build procedure for Go packages using the standard
  2983. @url{https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies,
  2984. Go build mechanisms}.
  2985. The user is expected to provide a value for the key @code{#:import-path}
  2986. and, in some cases, @code{#:unpack-path}. The
  2987. @url{https://golang.org/doc/code.html#ImportPaths, import path}
  2988. corresponds to the filesystem path expected by the package's build
  2989. scripts and any referring packages, and provides a unique way to
  2990. refer to a Go package. It is typically based on a combination of the
  2991. package source code's remote URI and filesystem hierarchy structure. In
  2992. some cases, you will need to unpack the package's source code to a
  2993. different directory structure than the one indicated by the import path,
  2994. and @code{#:unpack-path} should be used in such cases.
  2995. Packages that provide Go libraries should be installed along with their
  2996. source code. The key @code{#:install-source?}, which defaults to
  2997. @code{#t}, controls whether or not the source code is installed. It can
  2998. be set to @code{#f} for packages that only provide executable files.
  2999. @end defvr
  3000. @defvr {Scheme Variable} glib-or-gtk-build-system
  3001. This variable is exported by @code{(guix build-system glib-or-gtk)}. It
  3002. is intended for use with packages making use of GLib or GTK+.
  3003. This build system adds the following two phases to the ones defined by
  3004. @var{gnu-build-system}:
  3005. @table @code
  3006. @item glib-or-gtk-wrap
  3007. The phase @code{glib-or-gtk-wrap} ensures that programs in
  3008. @file{bin/} are able to find GLib ``schemas'' and
  3009. @uref{https://developer.gnome.org/gtk3/stable/gtk-running.html, GTK+
  3010. modules}. This is achieved by wrapping the programs in launch scripts
  3011. that appropriately set the @code{XDG_DATA_DIRS} and @code{GTK_PATH}
  3012. environment variables.
  3013. It is possible to exclude specific package outputs from that wrapping
  3014. process by listing their names in the
  3015. @code{#:glib-or-gtk-wrap-excluded-outputs} parameter. This is useful
  3016. when an output is known not to contain any GLib or GTK+ binaries, and
  3017. where wrapping would gratuitously add a dependency of that output on
  3018. GLib and GTK+.
  3019. @item glib-or-gtk-compile-schemas
  3020. The phase @code{glib-or-gtk-compile-schemas} makes sure that all
  3021. @uref{https://developer.gnome.org/gio/stable/glib-compile-schemas.html,
  3022. GSettings schemas} of GLib are compiled. Compilation is performed by the
  3023. @command{glib-compile-schemas} program. It is provided by the package
  3024. @code{glib:bin} which is automatically imported by the build system.
  3025. The @code{glib} package providing @command{glib-compile-schemas} can be
  3026. specified with the @code{#:glib} parameter.
  3027. @end table
  3028. Both phases are executed after the @code{install} phase.
  3029. @end defvr
  3030. @defvr {Scheme Variable} minify-build-system
  3031. This variable is exported by @code{(guix build-system minify)}. It
  3032. implements a minification procedure for simple JavaScript packages.
  3033. It adds @code{uglify-js} to the set of inputs and uses it to compress
  3034. all JavaScript files in the @file{src} directory. A different minifier
  3035. package can be specified with the @code{#:uglify-js} parameter, but it
  3036. is expected that the package writes the minified code to the standard
  3037. output.
  3038. When the input JavaScript files are not all located in the @file{src}
  3039. directory, the parameter @code{#:javascript-files} can be used to
  3040. specify a list of file names to feed to the minifier.
  3041. @end defvr
  3042. @defvr {Scheme Variable} ocaml-build-system
  3043. This variable is exported by @code{(guix build-system ocaml)}. It implements
  3044. a build procedure for @uref{https://ocaml.org, OCaml} packages, which consists
  3045. of choosing the correct set of commands to run for each package. OCaml
  3046. packages can expect many different commands to be run. This build system will
  3047. try some of them.
  3048. When the package has a @file{setup.ml} file present at the top-level, it will
  3049. run @code{ocaml setup.ml -configure}, @code{ocaml setup.ml -build} and
  3050. @code{ocaml setup.ml -install}. The build system will assume that this file
  3051. was generated by @uref{http://oasis.forge.ocamlcore.org/, OASIS} and will take
  3052. care of setting the prefix and enabling tests if they are not disabled. You
  3053. can pass configure and build flags with the @code{#:configure-flags} and
  3054. @code{#:build-flags}. The @code{#:test-flags} key can be passed to change the
  3055. set of flags used to enable tests. The @code{#:use-make?} key can be used to
  3056. bypass this system in the build and install phases.
  3057. When the package has a @file{configure} file, it is assumed that it is a
  3058. hand-made configure script that requires a different argument format than
  3059. in the @code{gnu-build-system}. You can add more flags with the
  3060. @code{#:configure-flags} key.
  3061. When the package has a @file{Makefile} file (or @code{#:use-make?} is
  3062. @code{#t}), it will be used and more flags can be passed to the build and
  3063. install phases with the @code{#:make-flags} key.
  3064. Finally, some packages do not have these files and use a somewhat standard
  3065. location for its build system. In that case, the build system will run
  3066. @code{ocaml pkg/pkg.ml} or @code{ocaml pkg/build.ml} and take care of
  3067. providing the path to the required findlib module. Additional flags can
  3068. be passed via the @code{#:build-flags} key. Install is taken care of by
  3069. @command{opam-installer}. In this case, the @code{opam} package must
  3070. be added to the @code{native-inputs} field of the package definition.
  3071. Note that most OCaml packages assume they will be installed in the same
  3072. directory as OCaml, which is not what we want in guix. In particular, they
  3073. will install @file{.so} files in their module's directory, which is usually
  3074. fine because it is in the OCaml compiler directory. In guix though, these
  3075. libraries cannot be found and we use @code{CAML_LD_LIBRARY_PATH}. This
  3076. variable points to @file{lib/ocaml/site-lib/stubslibs} and this is where
  3077. @file{.so} libraries should be installed.
  3078. @end defvr
  3079. @defvr {Scheme Variable} python-build-system
  3080. This variable is exported by @code{(guix build-system python)}. It
  3081. implements the more or less standard build procedure used by Python
  3082. packages, which consists in running @code{python setup.py build} and
  3083. then @code{python setup.py install --prefix=/gnu/store/@dots{}}.
  3084. For packages that install stand-alone Python programs under @code{bin/},
  3085. it takes care of wrapping these programs so that their @code{PYTHONPATH}
  3086. environment variable points to all the Python libraries they depend on.
  3087. Which Python package is used to perform the build can be specified with
  3088. the @code{#:python} parameter. This is a useful way to force a package
  3089. to be built for a specific version of the Python interpreter, which
  3090. might be necessary if the package is only compatible with a single
  3091. interpreter version.
  3092. By default guix calls @code{setup.py} under control of
  3093. @code{setuptools}, much like @command{pip} does. Some packages are not
  3094. compatible with setuptools (and pip), thus you can disable this by
  3095. setting the @code{#:use-setuptools} parameter to @code{#f}.
  3096. @end defvr
  3097. @defvr {Scheme Variable} perl-build-system
  3098. This variable is exported by @code{(guix build-system perl)}. It
  3099. implements the standard build procedure for Perl packages, which either
  3100. consists in running @code{perl Build.PL --prefix=/gnu/store/@dots{}},
  3101. followed by @code{Build} and @code{Build install}; or in running
  3102. @code{perl Makefile.PL PREFIX=/gnu/store/@dots{}}, followed by
  3103. @code{make} and @code{make install}, depending on which of
  3104. @code{Build.PL} or @code{Makefile.PL} is present in the package
  3105. distribution. Preference is given to the former if both @code{Build.PL}
  3106. and @code{Makefile.PL} exist in the package distribution. This
  3107. preference can be reversed by specifying @code{#t} for the
  3108. @code{#:make-maker?} parameter.
  3109. The initial @code{perl Makefile.PL} or @code{perl Build.PL} invocation
  3110. passes flags specified by the @code{#:make-maker-flags} or
  3111. @code{#:module-build-flags} parameter, respectively.
  3112. Which Perl package is used can be specified with @code{#:perl}.
  3113. @end defvr
  3114. @defvr {Scheme Variable} r-build-system
  3115. This variable is exported by @code{(guix build-system r)}. It
  3116. implements the build procedure used by @uref{http://r-project.org, R}
  3117. packages, which essentially is little more than running @code{R CMD
  3118. INSTALL --library=/gnu/store/@dots{}} in an environment where
  3119. @code{R_LIBS_SITE} contains the paths to all R package inputs. Tests
  3120. are run after installation using the R function
  3121. @code{tools::testInstalledPackage}.
  3122. @end defvr
  3123. @defvr {Scheme Variable} texlive-build-system
  3124. This variable is exported by @code{(guix build-system texlive)}. It is
  3125. used to build TeX packages in batch mode with a specified engine. The
  3126. build system sets the @code{TEXINPUTS} variable to find all TeX source
  3127. files in the inputs.
  3128. By default it runs @code{luatex} on all files ending on @code{ins}. A
  3129. different engine and format can be specified with the
  3130. @code{#:tex-format} argument. Different build targets can be specified
  3131. with the @code{#:build-targets} argument, which expects a list of file
  3132. names. The build system adds only @code{texlive-bin} and
  3133. @code{texlive-latex-base} (both from @code{(gnu packages tex}) to the
  3134. inputs. Both can be overridden with the arguments @code{#:texlive-bin}
  3135. and @code{#:texlive-latex-base}, respectively.
  3136. The @code{#:tex-directory} parameter tells the build system where to
  3137. install the built files under the texmf tree.
  3138. @end defvr
  3139. @defvr {Scheme Variable} ruby-build-system
  3140. This variable is exported by @code{(guix build-system ruby)}. It
  3141. implements the RubyGems build procedure used by Ruby packages, which
  3142. involves running @code{gem build} followed by @code{gem install}.
  3143. The @code{source} field of a package that uses this build system
  3144. typically references a gem archive, since this is the format that Ruby
  3145. developers use when releasing their software. The build system unpacks
  3146. the gem archive, potentially patches the source, runs the test suite,
  3147. repackages the gem, and installs it. Additionally, directories and
  3148. tarballs may be referenced to allow building unreleased gems from Git or
  3149. a traditional source release tarball.
  3150. Which Ruby package is used can be specified with the @code{#:ruby}
  3151. parameter. A list of additional flags to be passed to the @command{gem}
  3152. command can be specified with the @code{#:gem-flags} parameter.
  3153. @end defvr
  3154. @defvr {Scheme Variable} waf-build-system
  3155. This variable is exported by @code{(guix build-system waf)}. It
  3156. implements a build procedure around the @code{waf} script. The common
  3157. phases---@code{configure}, @code{build}, and @code{install}---are
  3158. implemented by passing their names as arguments to the @code{waf}
  3159. script.
  3160. The @code{waf} script is executed by the Python interpreter. Which
  3161. Python package is used to run the script can be specified with the
  3162. @code{#:python} parameter.
  3163. @end defvr
  3164. @defvr {Scheme Variable} scons-build-system
  3165. This variable is exported by @code{(guix build-system scons)}. It
  3166. implements the build procedure used by the SCons software construction
  3167. tool. This build system runs @code{scons} to build the package,
  3168. @code{scons test} to run tests, and then @code{scons install} to install
  3169. the package.
  3170. Additional flags to be passed to @code{scons} can be specified with the
  3171. @code{#:scons-flags} parameter. The version of Python used to run SCons
  3172. can be specified by selecting the appropriate SCons package with the
  3173. @code{#:scons} parameter.
  3174. @end defvr
  3175. @defvr {Scheme Variable} haskell-build-system
  3176. This variable is exported by @code{(guix build-system haskell)}. It
  3177. implements the Cabal build procedure used by Haskell packages, which
  3178. involves running @code{runhaskell Setup.hs configure
  3179. --prefix=/gnu/store/@dots{}} and @code{runhaskell Setup.hs build}.
  3180. Instead of installing the package by running @code{runhaskell Setup.hs
  3181. install}, to avoid trying to register libraries in the read-only
  3182. compiler store directory, the build system uses @code{runhaskell
  3183. Setup.hs copy}, followed by @code{runhaskell Setup.hs register}. In
  3184. addition, the build system generates the package documentation by
  3185. running @code{runhaskell Setup.hs haddock}, unless @code{#:haddock? #f}
  3186. is passed. Optional Haddock parameters can be passed with the help of
  3187. the @code{#:haddock-flags} parameter. If the file @code{Setup.hs} is
  3188. not found, the build system looks for @code{Setup.lhs} instead.
  3189. Which Haskell compiler is used can be specified with the @code{#:haskell}
  3190. parameter which defaults to @code{ghc}.
  3191. @end defvr
  3192. @defvr {Scheme Variable} dub-build-system
  3193. This variable is exported by @code{(guix build-system dub)}. It
  3194. implements the Dub build procedure used by D packages, which
  3195. involves running @code{dub build} and @code{dub run}.
  3196. Installation is done by copying the files manually.
  3197. Which D compiler is used can be specified with the @code{#:ldc}
  3198. parameter which defaults to @code{ldc}.
  3199. @end defvr
  3200. @defvr {Scheme Variable} emacs-build-system
  3201. This variable is exported by @code{(guix build-system emacs)}. It
  3202. implements an installation procedure similar to the packaging system
  3203. of Emacs itself (@pxref{Packages,,, emacs, The GNU Emacs Manual}).
  3204. It first creates the @code{@var{package}-autoloads.el} file, then it
  3205. byte compiles all Emacs Lisp files. Differently from the Emacs
  3206. packaging system, the Info documentation files are moved to the standard
  3207. documentation directory and the @file{dir} file is deleted. Each
  3208. package is installed in its own directory under
  3209. @file{share/emacs/site-lisp/guix.d}.
  3210. @end defvr
  3211. @defvr {Scheme Variable} font-build-system
  3212. This variable is exported by @code{(guix build-system font)}. It
  3213. implements an installation procedure for font packages where upstream
  3214. provides pre-compiled TrueType, OpenType, etc. font files that merely
  3215. need to be copied into place. It copies font files to standard
  3216. locations in the output directory.
  3217. @end defvr
  3218. @defvr {Scheme Variable} meson-build-system
  3219. This variable is exported by @code{(guix build-system meson)}. It
  3220. implements the build procedure for packages that use
  3221. @url{http://mesonbuild.com, Meson} as their build system.
  3222. It adds both Meson and @uref{https://ninja-build.org/, Ninja} to the set
  3223. of inputs, and they can be changed with the parameters @code{#:meson}
  3224. and @code{#:ninja} if needed. The default Meson is
  3225. @code{meson-for-build}, which is special because it doesn't clear the
  3226. @code{RUNPATH} of binaries and libraries when they are installed.
  3227. This build system is an extension of @var{gnu-build-system}, but with the
  3228. following phases changed to some specific for Meson:
  3229. @table @code
  3230. @item configure
  3231. The phase runs @code{meson} with the flags specified in
  3232. @code{#:configure-flags}. The flag @code{--build-type} is always set to
  3233. @code{plain} unless something else is specified in @code{#:build-type}.
  3234. @item build
  3235. The phase runs @code{ninja} to build the package in parallel by default, but
  3236. this can be changed with @code{#:parallel-build?}.
  3237. @item check
  3238. The phase runs @code{ninja} with the target specified in @code{#:test-target},
  3239. which is @code{"test"} by default.
  3240. @item install
  3241. The phase runs @code{ninja install} and can not be changed.
  3242. @end table
  3243. Apart from that, the build system also adds the following phases:
  3244. @table @code
  3245. @item fix-runpath
  3246. This phase tries to locate the local directories in the package being build,
  3247. which has libraries that some of the binaries need. If any are found, they will
  3248. be added to the programs @code{RUNPATH}. It is needed because
  3249. @code{meson-for-build} keeps the @code{RUNPATH} of binaries and libraries from
  3250. when they are build, but often that is not the @code{RUNPATH} we want.
  3251. Therefor it is also shrinked to the minimum needed by the program.
  3252. @item glib-or-gtk-wrap
  3253. This phase is the phase provided by @code{glib-or-gtk-build-system}, and it
  3254. is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
  3255. @item glib-or-gtk-compile-schemas
  3256. This phase is the phase provided by @code{glib-or-gtk-build-system}, and it
  3257. is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
  3258. @end table
  3259. @end defvr
  3260. Lastly, for packages that do not need anything as sophisticated, a
  3261. ``trivial'' build system is provided. It is trivial in the sense that
  3262. it provides basically no support: it does not pull any implicit inputs,
  3263. and does not have a notion of build phases.
  3264. @defvr {Scheme Variable} trivial-build-system
  3265. This variable is exported by @code{(guix build-system trivial)}.
  3266. This build system requires a @code{#:builder} argument. This argument
  3267. must be a Scheme expression that builds the package output(s)---as
  3268. with @code{build-expression->derivation} (@pxref{Derivations,
  3269. @code{build-expression->derivation}}).
  3270. @end defvr
  3271. @node The Store
  3272. @section The Store
  3273. @cindex store
  3274. @cindex store items
  3275. @cindex store paths
  3276. Conceptually, the @dfn{store} is the place where derivations that have
  3277. been built successfully are stored---by default, @file{/gnu/store}.
  3278. Sub-directories in the store are referred to as @dfn{store items} or
  3279. sometimes @dfn{store paths}. The store has an associated database that
  3280. contains information such as the store paths referred to by each store
  3281. path, and the list of @emph{valid} store items---results of successful
  3282. builds. This database resides in @file{@var{localstatedir}/guix/db},
  3283. where @var{localstatedir} is the state directory specified @i{via}
  3284. @option{--localstatedir} at configure time, usually @file{/var}.
  3285. The store is @emph{always} accessed by the daemon on behalf of its clients
  3286. (@pxref{Invoking guix-daemon}). To manipulate the store, clients
  3287. connect to the daemon over a Unix-domain socket, send requests to it,
  3288. and read the result---these are remote procedure calls, or RPCs.
  3289. @quotation Note
  3290. Users must @emph{never} modify files under @file{/gnu/store} directly.
  3291. This would lead to inconsistencies and break the immutability
  3292. assumptions of Guix's functional model (@pxref{Introduction}).
  3293. @xref{Invoking guix gc, @command{guix gc --verify}}, for information on
  3294. how to check the integrity of the store and attempt recovery from
  3295. accidental modifications.
  3296. @end quotation
  3297. The @code{(guix store)} module provides procedures to connect to the
  3298. daemon, and to perform RPCs. These are described below. By default,
  3299. @code{open-connection}, and thus all the @command{guix} commands,
  3300. connect to the local daemon or to the URI specified by the
  3301. @code{GUIX_DAEMON_SOCKET} environment variable.
  3302. @defvr {Environment Variable} GUIX_DAEMON_SOCKET
  3303. When set, the value of this variable should be a file name or a URI
  3304. designating the daemon endpoint. When it is a file name, it denotes a
  3305. Unix-domain socket to connect to. In addition to file names, the
  3306. supported URI schemes are:
  3307. @table @code
  3308. @item file
  3309. @itemx unix
  3310. These are for Unix-domain sockets.
  3311. @code{file:///var/guix/daemon-socket/socket} is equivalent to
  3312. @file{/var/guix/daemon-socket/socket}.
  3313. @item guix
  3314. @cindex daemon, remote access
  3315. @cindex remote access to the daemon
  3316. @cindex daemon, cluster setup
  3317. @cindex clusters, daemon setup
  3318. These URIs denote connections over TCP/IP, without encryption nor
  3319. authentication of the remote host. The URI must specify the host name
  3320. and optionally a port number (by default port 44146 is used):
  3321. @example
  3322. guix://master.guix.example.org:1234
  3323. @end example
  3324. This setup is suitable on local networks, such as clusters, where only
  3325. trusted nodes may connect to the build daemon at
  3326. @code{master.guix.example.org}.
  3327. The @code{--listen} option of @command{guix-daemon} can be used to
  3328. instruct it to listen for TCP connections (@pxref{Invoking guix-daemon,
  3329. @code{--listen}}).
  3330. @item ssh
  3331. @cindex SSH access to build daemons
  3332. These URIs allow you to connect to a remote daemon over
  3333. SSH@footnote{This feature requires Guile-SSH (@pxref{Requirements}).}.
  3334. A typical URL might look like this:
  3335. @example
  3336. ssh://charlie@@guix.example.org:22
  3337. @end example
  3338. As for @command{guix copy}, the usual OpenSSH client configuration files
  3339. are honored (@pxref{Invoking guix copy}).
  3340. @end table
  3341. Additional URI schemes may be supported in the future.
  3342. @c XXX: Remove this note when the protocol incurs fewer round trips
  3343. @c and when (guix derivations) no longer relies on file system access.
  3344. @quotation Note
  3345. The ability to connect to remote build daemons is considered
  3346. experimental as of @value{VERSION}. Please get in touch with us to
  3347. share any problems or suggestions you may have (@pxref{Contributing}).
  3348. @end quotation
  3349. @end defvr
  3350. @deffn {Scheme Procedure} open-connection [@var{uri}] [#:reserve-space? #t]
  3351. Connect to the daemon over the Unix-domain socket at @var{uri} (a string). When
  3352. @var{reserve-space?} is true, instruct it to reserve a little bit of
  3353. extra space on the file system so that the garbage collector can still
  3354. operate should the disk become full. Return a server object.
  3355. @var{file} defaults to @var{%default-socket-path}, which is the normal
  3356. location given the options that were passed to @command{configure}.
  3357. @end deffn
  3358. @deffn {Scheme Procedure} close-connection @var{server}
  3359. Close the connection to @var{server}.
  3360. @end deffn
  3361. @defvr {Scheme Variable} current-build-output-port
  3362. This variable is bound to a SRFI-39 parameter, which refers to the port
  3363. where build and error logs sent by the daemon should be written.
  3364. @end defvr
  3365. Procedures that make RPCs all take a server object as their first
  3366. argument.
  3367. @deffn {Scheme Procedure} valid-path? @var{server} @var{path}
  3368. @cindex invalid store items
  3369. Return @code{#t} when @var{path} designates a valid store item and
  3370. @code{#f} otherwise (an invalid item may exist on disk but still be
  3371. invalid, for instance because it is the result of an aborted or failed
  3372. build.)
  3373. A @code{&nix-protocol-error} condition is raised if @var{path} is not
  3374. prefixed by the store directory (@file{/gnu/store}).
  3375. @end deffn
  3376. @deffn {Scheme Procedure} add-text-to-store @var{server} @var{name} @var{text} [@var{references}]
  3377. Add @var{text} under file @var{name} in the store, and return its store
  3378. path. @var{references} is the list of store paths referred to by the
  3379. resulting store path.
  3380. @end deffn
  3381. @deffn {Scheme Procedure} build-derivations @var{server} @var{derivations}
  3382. Build @var{derivations} (a list of @code{<derivation>} objects or
  3383. derivation paths), and return when the worker is done building them.
  3384. Return @code{#t} on success.
  3385. @end deffn
  3386. Note that the @code{(guix monads)} module provides a monad as well as
  3387. monadic versions of the above procedures, with the goal of making it
  3388. more convenient to work with code that accesses the store (@pxref{The
  3389. Store Monad}).
  3390. @c FIXME
  3391. @i{This section is currently incomplete.}
  3392. @node Derivations
  3393. @section Derivations
  3394. @cindex derivations
  3395. Low-level build actions and the environment in which they are performed
  3396. are represented by @dfn{derivations}. A derivation contains the
  3397. following pieces of information:
  3398. @itemize
  3399. @item
  3400. The outputs of the derivation---derivations produce at least one file or
  3401. directory in the store, but may produce more.
  3402. @item
  3403. The inputs of the derivations, which may be other derivations or plain
  3404. files in the store (patches, build scripts, etc.)
  3405. @item
  3406. The system type targeted by the derivation---e.g., @code{x86_64-linux}.
  3407. @item
  3408. The file name of a build script in the store, along with the arguments
  3409. to be passed.
  3410. @item
  3411. A list of environment variables to be defined.
  3412. @end itemize
  3413. @cindex derivation path
  3414. Derivations allow clients of the daemon to communicate build actions to
  3415. the store. They exist in two forms: as an in-memory representation,
  3416. both on the client- and daemon-side, and as files in the store whose
  3417. name end in @code{.drv}---these files are referred to as @dfn{derivation
  3418. paths}. Derivations paths can be passed to the @code{build-derivations}
  3419. procedure to perform the build actions they prescribe (@pxref{The
  3420. Store}).
  3421. @cindex fixed-output derivations
  3422. Operations such as file downloads and version-control checkouts for
  3423. which the expected content hash is known in advance are modeled as
  3424. @dfn{fixed-output derivations}. Unlike regular derivations, the outputs
  3425. of a fixed-output derivation are independent of its inputs---e.g., a
  3426. source code download produces the same result regardless of the download
  3427. method and tools being used.
  3428. The @code{(guix derivations)} module provides a representation of
  3429. derivations as Scheme objects, along with procedures to create and
  3430. otherwise manipulate derivations. The lowest-level primitive to create
  3431. a derivation is the @code{derivation} procedure:
  3432. @deffn {Scheme Procedure} derivation @var{store} @var{name} @var{builder} @
  3433. @var{args} [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
  3434. [#:recursive? #f] [#:inputs '()] [#:env-vars '()] @
  3435. [#:system (%current-system)] [#:references-graphs #f] @
  3436. [#:allowed-references #f] [#:disallowed-references #f] @
  3437. [#:leaked-env-vars #f] [#:local-build? #f] @
  3438. [#:substitutable? #t]
  3439. Build a derivation with the given arguments, and return the resulting
  3440. @code{<derivation>} object.
  3441. When @var{hash} and @var{hash-algo} are given, a
  3442. @dfn{fixed-output derivation} is created---i.e., one whose result is
  3443. known in advance, such as a file download. If, in addition,
  3444. @var{recursive?} is true, then that fixed output may be an executable
  3445. file or a directory and @var{hash} must be the hash of an archive
  3446. containing this output.
  3447. When @var{references-graphs} is true, it must be a list of file
  3448. name/store path pairs. In that case, the reference graph of each store
  3449. path is exported in the build environment in the corresponding file, in
  3450. a simple text format.
  3451. When @var{allowed-references} is true, it must be a list of store items
  3452. or outputs that the derivation's output may refer to. Likewise,
  3453. @var{disallowed-references}, if true, must be a list of things the
  3454. outputs may @emph{not} refer to.
  3455. When @var{leaked-env-vars} is true, it must be a list of strings
  3456. denoting environment variables that are allowed to ``leak'' from the
  3457. daemon's environment to the build environment. This is only applicable
  3458. to fixed-output derivations---i.e., when @var{hash} is true. The main
  3459. use is to allow variables such as @code{http_proxy} to be passed to
  3460. derivations that download files.
  3461. When @var{local-build?} is true, declare that the derivation is not a
  3462. good candidate for offloading and should rather be built locally
  3463. (@pxref{Daemon Offload Setup}). This is the case for small derivations
  3464. where the costs of data transfers would outweigh the benefits.
  3465. When @var{substitutable?} is false, declare that substitutes of the
  3466. derivation's output should not be used (@pxref{Substitutes}). This is
  3467. useful, for instance, when building packages that capture details of the
  3468. host CPU instruction set.
  3469. @end deffn
  3470. @noindent
  3471. Here's an example with a shell script as its builder, assuming
  3472. @var{store} is an open connection to the daemon, and @var{bash} points
  3473. to a Bash executable in the store:
  3474. @lisp
  3475. (use-modules (guix utils)
  3476. (guix store)
  3477. (guix derivations))
  3478. (let ((builder ; add the Bash script to the store
  3479. (add-text-to-store store "my-builder.sh"
  3480. "echo hello world > $out\n" '())))
  3481. (derivation store "foo"
  3482. bash `("-e" ,builder)
  3483. #:inputs `((,bash) (,builder))
  3484. #:env-vars '(("HOME" . "/homeless"))))
  3485. @result{} #<derivation /gnu/store/@dots{}-foo.drv => /gnu/store/@dots{}-foo>
  3486. @end lisp
  3487. As can be guessed, this primitive is cumbersome to use directly. A
  3488. better approach is to write build scripts in Scheme, of course! The
  3489. best course of action for that is to write the build code as a
  3490. ``G-expression'', and to pass it to @code{gexp->derivation}. For more
  3491. information, @pxref{G-Expressions}.
  3492. Once upon a time, @code{gexp->derivation} did not exist and constructing
  3493. derivations with build code written in Scheme was achieved with
  3494. @code{build-expression->derivation}, documented below. This procedure
  3495. is now deprecated in favor of the much nicer @code{gexp->derivation}.
  3496. @deffn {Scheme Procedure} build-expression->derivation @var{store} @
  3497. @var{name} @var{exp} @
  3498. [#:system (%current-system)] [#:inputs '()] @
  3499. [#:outputs '("out")] [#:hash #f] [#:hash-algo #f] @
  3500. [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
  3501. [#:references-graphs #f] [#:allowed-references #f] @
  3502. [#:disallowed-references #f] @
  3503. [#:local-build? #f] [#:substitutable? #t] [#:guile-for-build #f]
  3504. Return a derivation that executes Scheme expression @var{exp} as a
  3505. builder for derivation @var{name}. @var{inputs} must be a list of
  3506. @code{(name drv-path sub-drv)} tuples; when @var{sub-drv} is omitted,
  3507. @code{"out"} is assumed. @var{modules} is a list of names of Guile
  3508. modules from the current search path to be copied in the store,
  3509. compiled, and made available in the load path during the execution of
  3510. @var{exp}---e.g., @code{((guix build utils) (guix build
  3511. gnu-build-system))}.
  3512. @var{exp} is evaluated in an environment where @code{%outputs} is bound
  3513. to a list of output/path pairs, and where @code{%build-inputs} is bound
  3514. to a list of string/output-path pairs made from @var{inputs}.
  3515. Optionally, @var{env-vars} is a list of string pairs specifying the name
  3516. and value of environment variables visible to the builder. The builder
  3517. terminates by passing the result of @var{exp} to @code{exit}; thus, when
  3518. @var{exp} returns @code{#f}, the build is considered to have failed.
  3519. @var{exp} is built using @var{guile-for-build} (a derivation). When
  3520. @var{guile-for-build} is omitted or is @code{#f}, the value of the
  3521. @code{%guile-for-build} fluid is used instead.
  3522. See the @code{derivation} procedure for the meaning of
  3523. @var{references-graphs}, @var{allowed-references},
  3524. @var{disallowed-references}, @var{local-build?}, and
  3525. @var{substitutable?}.
  3526. @end deffn
  3527. @noindent
  3528. Here's an example of a single-output derivation that creates a directory
  3529. containing one file:
  3530. @lisp
  3531. (let ((builder '(let ((out (assoc-ref %outputs "out")))
  3532. (mkdir out) ; create /gnu/store/@dots{}-goo
  3533. (call-with-output-file (string-append out "/test")
  3534. (lambda (p)
  3535. (display '(hello guix) p))))))
  3536. (build-expression->derivation store "goo" builder))
  3537. @result{} #<derivation /gnu/store/@dots{}-goo.drv => @dots{}>
  3538. @end lisp
  3539. @node The Store Monad
  3540. @section The Store Monad
  3541. @cindex monad
  3542. The procedures that operate on the store described in the previous
  3543. sections all take an open connection to the build daemon as their first
  3544. argument. Although the underlying model is functional, they either have
  3545. side effects or depend on the current state of the store.
  3546. The former is inconvenient: the connection to the build daemon has to be
  3547. carried around in all those functions, making it impossible to compose
  3548. functions that do not take that parameter with functions that do. The
  3549. latter can be problematic: since store operations have side effects
  3550. and/or depend on external state, they have to be properly sequenced.
  3551. @cindex monadic values
  3552. @cindex monadic functions
  3553. This is where the @code{(guix monads)} module comes in. This module
  3554. provides a framework for working with @dfn{monads}, and a particularly
  3555. useful monad for our uses, the @dfn{store monad}. Monads are a
  3556. construct that allows two things: associating ``context'' with values
  3557. (in our case, the context is the store), and building sequences of
  3558. computations (here computations include accesses to the store). Values
  3559. in a monad---values that carry this additional context---are called
  3560. @dfn{monadic values}; procedures that return such values are called
  3561. @dfn{monadic procedures}.
  3562. Consider this ``normal'' procedure:
  3563. @example
  3564. (define (sh-symlink store)
  3565. ;; Return a derivation that symlinks the 'bash' executable.
  3566. (let* ((drv (package-derivation store bash))
  3567. (out (derivation->output-path drv))
  3568. (sh (string-append out "/bin/bash")))
  3569. (build-expression->derivation store "sh"
  3570. `(symlink ,sh %output))))
  3571. @end example
  3572. Using @code{(guix monads)} and @code{(guix gexp)}, it may be rewritten
  3573. as a monadic function:
  3574. @example
  3575. (define (sh-symlink)
  3576. ;; Same, but return a monadic value.
  3577. (mlet %store-monad ((drv (package->derivation bash)))
  3578. (gexp->derivation "sh"
  3579. #~(symlink (string-append #$drv "/bin/bash")
  3580. #$output))))
  3581. @end example
  3582. There are several things to note in the second version: the @code{store}
  3583. parameter is now implicit and is ``threaded'' in the calls to the
  3584. @code{package->derivation} and @code{gexp->derivation} monadic
  3585. procedures, and the monadic value returned by @code{package->derivation}
  3586. is @dfn{bound} using @code{mlet} instead of plain @code{let}.
  3587. As it turns out, the call to @code{package->derivation} can even be
  3588. omitted since it will take place implicitly, as we will see later
  3589. (@pxref{G-Expressions}):
  3590. @example
  3591. (define (sh-symlink)
  3592. (gexp->derivation "sh"
  3593. #~(symlink (string-append #$bash "/bin/bash")
  3594. #$output)))
  3595. @end example
  3596. @c See
  3597. @c <https://syntaxexclamation.wordpress.com/2014/06/26/escaping-continuations/>
  3598. @c for the funny quote.
  3599. Calling the monadic @code{sh-symlink} has no effect. As someone once
  3600. said, ``you exit a monad like you exit a building on fire: by running''.
  3601. So, to exit the monad and get the desired effect, one must use
  3602. @code{run-with-store}:
  3603. @example
  3604. (run-with-store (open-connection) (sh-symlink))
  3605. @result{} /gnu/store/...-sh-symlink
  3606. @end example
  3607. Note that the @code{(guix monad-repl)} module extends the Guile REPL with
  3608. new ``meta-commands'' to make it easier to deal with monadic procedures:
  3609. @code{run-in-store}, and @code{enter-store-monad}. The former is used
  3610. to ``run'' a single monadic value through the store:
  3611. @example
  3612. scheme@@(guile-user)> ,run-in-store (package->derivation hello)
  3613. $1 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
  3614. @end example
  3615. The latter enters a recursive REPL, where all the return values are
  3616. automatically run through the store:
  3617. @example
  3618. scheme@@(guile-user)> ,enter-store-monad
  3619. store-monad@@(guile-user) [1]> (package->derivation hello)
  3620. $2 = #<derivation /gnu/store/@dots{}-hello-2.9.drv => @dots{}>
  3621. store-monad@@(guile-user) [1]> (text-file "foo" "Hello!")
  3622. $3 = "/gnu/store/@dots{}-foo"
  3623. store-monad@@(guile-user) [1]> ,q
  3624. scheme@@(guile-user)>
  3625. @end example
  3626. @noindent
  3627. Note that non-monadic values cannot be returned in the
  3628. @code{store-monad} REPL.
  3629. The main syntactic forms to deal with monads in general are provided by
  3630. the @code{(guix monads)} module and are described below.
  3631. @deffn {Scheme Syntax} with-monad @var{monad} @var{body} ...
  3632. Evaluate any @code{>>=} or @code{return} forms in @var{body} as being
  3633. in @var{monad}.
  3634. @end deffn
  3635. @deffn {Scheme Syntax} return @var{val}
  3636. Return a monadic value that encapsulates @var{val}.
  3637. @end deffn
  3638. @deffn {Scheme Syntax} >>= @var{mval} @var{mproc} ...
  3639. @dfn{Bind} monadic value @var{mval}, passing its ``contents'' to monadic
  3640. procedures @var{mproc}@dots{}@footnote{This operation is commonly
  3641. referred to as ``bind'', but that name denotes an unrelated procedure in
  3642. Guile. Thus we use this somewhat cryptic symbol inherited from the
  3643. Haskell language.}. There can be one @var{mproc} or several of them, as
  3644. in this example:
  3645. @example
  3646. (run-with-state
  3647. (with-monad %state-monad
  3648. (>>= (return 1)
  3649. (lambda (x) (return (+ 1 x)))
  3650. (lambda (x) (return (* 2 x)))))
  3651. 'some-state)
  3652. @result{} 4
  3653. @result{} some-state
  3654. @end example
  3655. @end deffn
  3656. @deffn {Scheme Syntax} mlet @var{monad} ((@var{var} @var{mval}) ...) @
  3657. @var{body} ...
  3658. @deffnx {Scheme Syntax} mlet* @var{monad} ((@var{var} @var{mval}) ...) @
  3659. @var{body} ...
  3660. Bind the variables @var{var} to the monadic values @var{mval} in
  3661. @var{body}, which is a sequence of expressions. As with the bind
  3662. operator, this can be thought of as ``unpacking'' the raw, non-monadic
  3663. value ``contained'' in @var{mval} and making @var{var} refer to that
  3664. raw, non-monadic value within the scope of the @var{body}. The form
  3665. (@var{var} -> @var{val}) binds @var{var} to the ``normal'' value
  3666. @var{val}, as per @code{let}. The binding operations occur in sequence
  3667. from left to right. The last expression of @var{body} must be a monadic
  3668. expression, and its result will become the result of the @code{mlet} or
  3669. @code{mlet*} when run in the @var{monad}.
  3670. @code{mlet*} is to @code{mlet} what @code{let*} is to @code{let}
  3671. (@pxref{Local Bindings,,, guile, GNU Guile Reference Manual}).
  3672. @end deffn
  3673. @deffn {Scheme System} mbegin @var{monad} @var{mexp} ...
  3674. Bind @var{mexp} and the following monadic expressions in sequence,
  3675. returning the result of the last expression. Every expression in the
  3676. sequence must be a monadic expression.
  3677. This is akin to @code{mlet}, except that the return values of the
  3678. monadic expressions are ignored. In that sense, it is analogous to
  3679. @code{begin}, but applied to monadic expressions.
  3680. @end deffn
  3681. @deffn {Scheme System} mwhen @var{condition} @var{mexp0} @var{mexp*} ...
  3682. When @var{condition} is true, evaluate the sequence of monadic
  3683. expressions @var{mexp0}..@var{mexp*} as in an @code{mbegin}. When
  3684. @var{condition} is false, return @code{*unspecified*} in the current
  3685. monad. Every expression in the sequence must be a monadic expression.
  3686. @end deffn
  3687. @deffn {Scheme System} munless @var{condition} @var{mexp0} @var{mexp*} ...
  3688. When @var{condition} is false, evaluate the sequence of monadic
  3689. expressions @var{mexp0}..@var{mexp*} as in an @code{mbegin}. When
  3690. @var{condition} is true, return @code{*unspecified*} in the current
  3691. monad. Every expression in the sequence must be a monadic expression.
  3692. @end deffn
  3693. @cindex state monad
  3694. The @code{(guix monads)} module provides the @dfn{state monad}, which
  3695. allows an additional value---the state---to be @emph{threaded} through
  3696. monadic procedure calls.
  3697. @defvr {Scheme Variable} %state-monad
  3698. The state monad. Procedures in the state monad can access and change
  3699. the state that is threaded.
  3700. Consider the example below. The @code{square} procedure returns a value
  3701. in the state monad. It returns the square of its argument, but also
  3702. increments the current state value:
  3703. @example
  3704. (define (square x)
  3705. (mlet %state-monad ((count (current-state)))
  3706. (mbegin %state-monad
  3707. (set-current-state (+ 1 count))
  3708. (return (* x x)))))
  3709. (run-with-state (sequence %state-monad (map square (iota 3))) 0)
  3710. @result{} (0 1 4)
  3711. @result{} 3
  3712. @end example
  3713. When ``run'' through @var{%state-monad}, we obtain that additional state
  3714. value, which is the number of @code{square} calls.
  3715. @end defvr
  3716. @deffn {Monadic Procedure} current-state
  3717. Return the current state as a monadic value.
  3718. @end deffn
  3719. @deffn {Monadic Procedure} set-current-state @var{value}
  3720. Set the current state to @var{value} and return the previous state as a
  3721. monadic value.
  3722. @end deffn
  3723. @deffn {Monadic Procedure} state-push @var{value}
  3724. Push @var{value} to the current state, which is assumed to be a list,
  3725. and return the previous state as a monadic value.
  3726. @end deffn
  3727. @deffn {Monadic Procedure} state-pop
  3728. Pop a value from the current state and return it as a monadic value.
  3729. The state is assumed to be a list.
  3730. @end deffn
  3731. @deffn {Scheme Procedure} run-with-state @var{mval} [@var{state}]
  3732. Run monadic value @var{mval} starting with @var{state} as the initial
  3733. state. Return two values: the resulting value, and the resulting state.
  3734. @end deffn
  3735. The main interface to the store monad, provided by the @code{(guix
  3736. store)} module, is as follows.
  3737. @defvr {Scheme Variable} %store-monad
  3738. The store monad---an alias for @var{%state-monad}.
  3739. Values in the store monad encapsulate accesses to the store. When its
  3740. effect is needed, a value of the store monad must be ``evaluated'' by
  3741. passing it to the @code{run-with-store} procedure (see below.)
  3742. @end defvr
  3743. @deffn {Scheme Procedure} run-with-store @var{store} @var{mval} [#:guile-for-build] [#:system (%current-system)]
  3744. Run @var{mval}, a monadic value in the store monad, in @var{store}, an
  3745. open store connection.
  3746. @end deffn
  3747. @deffn {Monadic Procedure} text-file @var{name} @var{text} [@var{references}]
  3748. Return as a monadic value the absolute file name in the store of the file
  3749. containing @var{text}, a string. @var{references} is a list of store items that the
  3750. resulting text file refers to; it defaults to the empty list.
  3751. @end deffn
  3752. @deffn {Monadic Procedure} interned-file @var{file} [@var{name}] @
  3753. [#:recursive? #t] [#:select? (const #t)]
  3754. Return the name of @var{file} once interned in the store. Use
  3755. @var{name} as its store name, or the basename of @var{file} if
  3756. @var{name} is omitted.
  3757. When @var{recursive?} is true, the contents of @var{file} are added
  3758. recursively; if @var{file} designates a flat file and @var{recursive?}
  3759. is true, its contents are added, and its permission bits are kept.
  3760. When @var{recursive?} is true, call @code{(@var{select?} @var{file}
  3761. @var{stat})} for each directory entry, where @var{file} is the entry's
  3762. absolute file name and @var{stat} is the result of @code{lstat}; exclude
  3763. entries for which @var{select?} does not return true.
  3764. The example below adds a file to the store, under two different names:
  3765. @example
  3766. (run-with-store (open-connection)
  3767. (mlet %store-monad ((a (interned-file "README"))
  3768. (b (interned-file "README" "LEGU-MIN")))
  3769. (return (list a b))))
  3770. @result{} ("/gnu/store/rwm@dots{}-README" "/gnu/store/44i@dots{}-LEGU-MIN")
  3771. @end example
  3772. @end deffn
  3773. The @code{(guix packages)} module exports the following package-related
  3774. monadic procedures:
  3775. @deffn {Monadic Procedure} package-file @var{package} [@var{file}] @
  3776. [#:system (%current-system)] [#:target #f] @
  3777. [#:output "out"]
  3778. Return as a monadic
  3779. value in the absolute file name of @var{file} within the @var{output}
  3780. directory of @var{package}. When @var{file} is omitted, return the name
  3781. of the @var{output} directory of @var{package}. When @var{target} is
  3782. true, use it as a cross-compilation target triplet.
  3783. @end deffn
  3784. @deffn {Monadic Procedure} package->derivation @var{package} [@var{system}]
  3785. @deffnx {Monadic Procedure} package->cross-derivation @var{package} @
  3786. @var{target} [@var{system}]
  3787. Monadic version of @code{package-derivation} and
  3788. @code{package-cross-derivation} (@pxref{Defining Packages}).
  3789. @end deffn
  3790. @node G-Expressions
  3791. @section G-Expressions
  3792. @cindex G-expression
  3793. @cindex build code quoting
  3794. So we have ``derivations'', which represent a sequence of build actions
  3795. to be performed to produce an item in the store (@pxref{Derivations}).
  3796. These build actions are performed when asking the daemon to actually
  3797. build the derivations; they are run by the daemon in a container
  3798. (@pxref{Invoking guix-daemon}).
  3799. @cindex strata of code
  3800. It should come as no surprise that we like to write these build actions
  3801. in Scheme. When we do that, we end up with two @dfn{strata} of Scheme
  3802. code@footnote{The term @dfn{stratum} in this context was coined by
  3803. Manuel Serrano et al.@: in the context of their work on Hop. Oleg
  3804. Kiselyov, who has written insightful
  3805. @url{http://okmij.org/ftp/meta-programming/#meta-scheme, essays and code
  3806. on this topic}, refers to this kind of code generation as
  3807. @dfn{staging}.}: the ``host code''---code that defines packages, talks
  3808. to the daemon, etc.---and the ``build code''---code that actually
  3809. performs build actions, such as making directories, invoking
  3810. @command{make}, etc.
  3811. To describe a derivation and its build actions, one typically needs to
  3812. embed build code inside host code. It boils down to manipulating build
  3813. code as data, and the homoiconicity of Scheme---code has a direct
  3814. representation as data---comes in handy for that. But we need more than
  3815. the normal @code{quasiquote} mechanism in Scheme to construct build
  3816. expressions.
  3817. The @code{(guix gexp)} module implements @dfn{G-expressions}, a form of
  3818. S-expressions adapted to build expressions. G-expressions, or
  3819. @dfn{gexps}, consist essentially of three syntactic forms: @code{gexp},
  3820. @code{ungexp}, and @code{ungexp-splicing} (or simply: @code{#~},
  3821. @code{#$}, and @code{#$@@}), which are comparable to
  3822. @code{quasiquote}, @code{unquote}, and @code{unquote-splicing},
  3823. respectively (@pxref{Expression Syntax, @code{quasiquote},, guile,
  3824. GNU Guile Reference Manual}). However, there are major differences:
  3825. @itemize
  3826. @item
  3827. Gexps are meant to be written to a file and run or manipulated by other
  3828. processes.
  3829. @item
  3830. When a high-level object such as a package or derivation is unquoted
  3831. inside a gexp, the result is as if its output file name had been
  3832. introduced.
  3833. @item
  3834. Gexps carry information about the packages or derivations they refer to,
  3835. and these dependencies are automatically added as inputs to the build
  3836. processes that use them.
  3837. @end itemize
  3838. @cindex lowering, of high-level objects in gexps
  3839. This mechanism is not limited to package and derivation
  3840. objects: @dfn{compilers} able to ``lower'' other high-level objects to
  3841. derivations or files in the store can be defined,
  3842. such that these objects can also be inserted
  3843. into gexps. For example, a useful type of high-level objects that can be
  3844. inserted in a gexp is ``file-like objects'', which make it easy to
  3845. add files to the store and to refer to them in
  3846. derivations and such (see @code{local-file} and @code{plain-file}
  3847. below.)
  3848. To illustrate the idea, here is an example of a gexp:
  3849. @example
  3850. (define build-exp
  3851. #~(begin
  3852. (mkdir #$output)
  3853. (chdir #$output)
  3854. (symlink (string-append #$coreutils "/bin/ls")
  3855. "list-files")))
  3856. @end example
  3857. This gexp can be passed to @code{gexp->derivation}; we obtain a
  3858. derivation that builds a directory containing exactly one symlink to
  3859. @file{/gnu/store/@dots{}-coreutils-8.22/bin/ls}:
  3860. @example
  3861. (gexp->derivation "the-thing" build-exp)
  3862. @end example
  3863. As one would expect, the @code{"/gnu/store/@dots{}-coreutils-8.22"} string is
  3864. substituted to the reference to the @var{coreutils} package in the
  3865. actual build code, and @var{coreutils} is automatically made an input to
  3866. the derivation. Likewise, @code{#$output} (equivalent to @code{(ungexp
  3867. output)}) is replaced by a string containing the directory name of the
  3868. output of the derivation.
  3869. @cindex cross compilation
  3870. In a cross-compilation context, it is useful to distinguish between
  3871. references to the @emph{native} build of a package---that can run on the
  3872. host---versus references to cross builds of a package. To that end, the
  3873. @code{#+} plays the same role as @code{#$}, but is a reference to a
  3874. native package build:
  3875. @example
  3876. (gexp->derivation "vi"
  3877. #~(begin
  3878. (mkdir #$output)
  3879. (system* (string-append #+coreutils "/bin/ln")
  3880. "-s"
  3881. (string-append #$emacs "/bin/emacs")
  3882. (string-append #$output "/bin/vi")))
  3883. #:target "mips64el-linux-gnu")
  3884. @end example
  3885. @noindent
  3886. In the example above, the native build of @var{coreutils} is used, so
  3887. that @command{ln} can actually run on the host; but then the
  3888. cross-compiled build of @var{emacs} is referenced.
  3889. @cindex imported modules, for gexps
  3890. @findex with-imported-modules
  3891. Another gexp feature is @dfn{imported modules}: sometimes you want to be
  3892. able to use certain Guile modules from the ``host environment'' in the
  3893. gexp, so those modules should be imported in the ``build environment''.
  3894. The @code{with-imported-modules} form allows you to express that:
  3895. @example
  3896. (let ((build (with-imported-modules '((guix build utils))
  3897. #~(begin
  3898. (use-modules (guix build utils))
  3899. (mkdir-p (string-append #$output "/bin"))))))
  3900. (gexp->derivation "empty-dir"
  3901. #~(begin
  3902. #$build
  3903. (display "success!\n")
  3904. #t)))
  3905. @end example
  3906. @noindent
  3907. In this example, the @code{(guix build utils)} module is automatically
  3908. pulled into the isolated build environment of our gexp, such that
  3909. @code{(use-modules (guix build utils))} works as expected.
  3910. @cindex module closure
  3911. @findex source-module-closure
  3912. Usually you want the @emph{closure} of the module to be imported---i.e.,
  3913. the module itself and all the modules it depends on---rather than just
  3914. the module; failing to do that, attempts to use the module will fail
  3915. because of missing dependent modules. The @code{source-module-closure}
  3916. procedure computes the closure of a module by looking at its source file
  3917. headers, which comes in handy in this case:
  3918. @example
  3919. (use-modules (guix modules)) ;for 'source-module-closure'
  3920. (with-imported-modules (source-module-closure
  3921. '((guix build utils)
  3922. (gnu build vm)))
  3923. (gexp->derivation "something-with-vms"
  3924. #~(begin
  3925. (use-modules (guix build utils)
  3926. (gnu build vm))
  3927. @dots{})))
  3928. @end example
  3929. The syntactic form to construct gexps is summarized below.
  3930. @deffn {Scheme Syntax} #~@var{exp}
  3931. @deffnx {Scheme Syntax} (gexp @var{exp})
  3932. Return a G-expression containing @var{exp}. @var{exp} may contain one
  3933. or more of the following forms:
  3934. @table @code
  3935. @item #$@var{obj}
  3936. @itemx (ungexp @var{obj})
  3937. Introduce a reference to @var{obj}. @var{obj} may have one of the
  3938. supported types, for example a package or a
  3939. derivation, in which case the @code{ungexp} form is replaced by its
  3940. output file name---e.g., @code{"/gnu/store/@dots{}-coreutils-8.22}.
  3941. If @var{obj} is a list, it is traversed and references to supported
  3942. objects are substituted similarly.
  3943. If @var{obj} is another gexp, its contents are inserted and its
  3944. dependencies are added to those of the containing gexp.
  3945. If @var{obj} is another kind of object, it is inserted as is.
  3946. @item #$@var{obj}:@var{output}
  3947. @itemx (ungexp @var{obj} @var{output})
  3948. This is like the form above, but referring explicitly to the
  3949. @var{output} of @var{obj}---this is useful when @var{obj} produces
  3950. multiple outputs (@pxref{Packages with Multiple Outputs}).
  3951. @item #+@var{obj}
  3952. @itemx #+@var{obj}:output
  3953. @itemx (ungexp-native @var{obj})
  3954. @itemx (ungexp-native @var{obj} @var{output})
  3955. Same as @code{ungexp}, but produces a reference to the @emph{native}
  3956. build of @var{obj} when used in a cross compilation context.
  3957. @item #$output[:@var{output}]
  3958. @itemx (ungexp output [@var{output}])
  3959. Insert a reference to derivation output @var{output}, or to the main
  3960. output when @var{output} is omitted.
  3961. This only makes sense for gexps passed to @code{gexp->derivation}.
  3962. @item #$@@@var{lst}
  3963. @itemx (ungexp-splicing @var{lst})
  3964. Like the above, but splices the contents of @var{lst} inside the
  3965. containing list.
  3966. @item #+@@@var{lst}
  3967. @itemx (ungexp-native-splicing @var{lst})
  3968. Like the above, but refers to native builds of the objects listed in
  3969. @var{lst}.
  3970. @end table
  3971. G-expressions created by @code{gexp} or @code{#~} are run-time objects
  3972. of the @code{gexp?} type (see below.)
  3973. @end deffn
  3974. @deffn {Scheme Syntax} with-imported-modules @var{modules} @var{body}@dots{}
  3975. Mark the gexps defined in @var{body}@dots{} as requiring @var{modules}
  3976. in their execution environment.
  3977. Each item in @var{modules} can be the name of a module, such as
  3978. @code{(guix build utils)}, or it can be a module name, followed by an
  3979. arrow, followed by a file-like object:
  3980. @example
  3981. `((guix build utils)
  3982. (guix gcrypt)
  3983. ((guix config) => ,(scheme-file "config.scm"
  3984. #~(define-module @dots{}))))
  3985. @end example
  3986. @noindent
  3987. In the example above, the first two modules are taken from the search
  3988. path, and the last one is created from the given file-like object.
  3989. This form has @emph{lexical} scope: it has an effect on the gexps
  3990. directly defined in @var{body}@dots{}, but not on those defined, say, in
  3991. procedures called from @var{body}@dots{}.
  3992. @end deffn
  3993. @deffn {Scheme Procedure} gexp? @var{obj}
  3994. Return @code{#t} if @var{obj} is a G-expression.
  3995. @end deffn
  3996. G-expressions are meant to be written to disk, either as code building
  3997. some derivation, or as plain files in the store. The monadic procedures
  3998. below allow you to do that (@pxref{The Store Monad}, for more
  3999. information about monads.)
  4000. @deffn {Monadic Procedure} gexp->derivation @var{name} @var{exp} @
  4001. [#:system (%current-system)] [#:target #f] [#:graft? #t] @
  4002. [#:hash #f] [#:hash-algo #f] @
  4003. [#:recursive? #f] [#:env-vars '()] [#:modules '()] @
  4004. [#:module-path @var{%load-path}] @
  4005. [#:references-graphs #f] [#:allowed-references #f] @
  4006. [#:disallowed-references #f] @
  4007. [#:leaked-env-vars #f] @
  4008. [#:script-name (string-append @var{name} "-builder")] @
  4009. [#:deprecation-warnings #f] @
  4010. [#:local-build? #f] [#:substitutable? #t] [#:guile-for-build #f]
  4011. Return a derivation @var{name} that runs @var{exp} (a gexp) with
  4012. @var{guile-for-build} (a derivation) on @var{system}; @var{exp} is
  4013. stored in a file called @var{script-name}. When @var{target} is true,
  4014. it is used as the cross-compilation target triplet for packages referred
  4015. to by @var{exp}.
  4016. @var{modules} is deprecated in favor of @code{with-imported-modules}.
  4017. Its meaning is to
  4018. make @var{modules} available in the evaluation context of @var{exp};
  4019. @var{modules} is a list of names of Guile modules searched in
  4020. @var{module-path} to be copied in the store, compiled, and made available in
  4021. the load path during the execution of @var{exp}---e.g., @code{((guix
  4022. build utils) (guix build gnu-build-system))}.
  4023. @var{graft?} determines whether packages referred to by @var{exp} should be grafted when
  4024. applicable.
  4025. When @var{references-graphs} is true, it must be a list of tuples of one of the
  4026. following forms:
  4027. @example
  4028. (@var{file-name} @var{package})
  4029. (@var{file-name} @var{package} @var{output})
  4030. (@var{file-name} @var{derivation})
  4031. (@var{file-name} @var{derivation} @var{output})
  4032. (@var{file-name} @var{store-item})
  4033. @end example
  4034. The right-hand-side of each element of @var{references-graphs} is automatically made
  4035. an input of the build process of @var{exp}. In the build environment, each
  4036. @var{file-name} contains the reference graph of the corresponding item, in a simple
  4037. text format.
  4038. @var{allowed-references} must be either @code{#f} or a list of output names and packages.
  4039. In the latter case, the list denotes store items that the result is allowed to
  4040. refer to. Any reference to another store item will lead to a build error.
  4041. Similarly for @var{disallowed-references}, which can list items that must not be
  4042. referenced by the outputs.
  4043. @var{deprecation-warnings} determines whether to show deprecation warnings while
  4044. compiling modules. It can be @code{#f}, @code{#t}, or @code{'detailed}.
  4045. The other arguments are as for @code{derivation} (@pxref{Derivations}).
  4046. @end deffn
  4047. @cindex file-like objects
  4048. The @code{local-file}, @code{plain-file}, @code{computed-file},
  4049. @code{program-file}, and @code{scheme-file} procedures below return
  4050. @dfn{file-like objects}. That is, when unquoted in a G-expression,
  4051. these objects lead to a file in the store. Consider this G-expression:
  4052. @example
  4053. #~(system* #$(file-append glibc "/sbin/nscd") "-f"
  4054. #$(local-file "/tmp/my-nscd.conf"))
  4055. @end example
  4056. The effect here is to ``intern'' @file{/tmp/my-nscd.conf} by copying it
  4057. to the store. Once expanded, for instance @i{via}
  4058. @code{gexp->derivation}, the G-expression refers to that copy under
  4059. @file{/gnu/store}; thus, modifying or removing the file in @file{/tmp}
  4060. does not have any effect on what the G-expression does.
  4061. @code{plain-file} can be used similarly; it differs in that the file
  4062. content is directly passed as a string.
  4063. @deffn {Scheme Procedure} local-file @var{file} [@var{name}] @
  4064. [#:recursive? #f] [#:select? (const #t)]
  4065. Return an object representing local file @var{file} to add to the store; this
  4066. object can be used in a gexp. If @var{file} is a relative file name, it is looked
  4067. up relative to the source file where this form appears. @var{file} will be added to
  4068. the store under @var{name}--by default the base name of @var{file}.
  4069. When @var{recursive?} is true, the contents of @var{file} are added recursively; if @var{file}
  4070. designates a flat file and @var{recursive?} is true, its contents are added, and its
  4071. permission bits are kept.
  4072. When @var{recursive?} is true, call @code{(@var{select?} @var{file}
  4073. @var{stat})} for each directory entry, where @var{file} is the entry's
  4074. absolute file name and @var{stat} is the result of @code{lstat}; exclude
  4075. entries for which @var{select?} does not return true.
  4076. This is the declarative counterpart of the @code{interned-file} monadic
  4077. procedure (@pxref{The Store Monad, @code{interned-file}}).
  4078. @end deffn
  4079. @deffn {Scheme Procedure} plain-file @var{name} @var{content}
  4080. Return an object representing a text file called @var{name} with the given
  4081. @var{content} (a string) to be added to the store.
  4082. This is the declarative counterpart of @code{text-file}.
  4083. @end deffn
  4084. @deffn {Scheme Procedure} computed-file @var{name} @var{gexp} @
  4085. [#:options '(#:local-build? #t)]
  4086. Return an object representing the store item @var{name}, a file or
  4087. directory computed by @var{gexp}. @var{options}
  4088. is a list of additional arguments to pass to @code{gexp->derivation}.
  4089. This is the declarative counterpart of @code{gexp->derivation}.
  4090. @end deffn
  4091. @deffn {Monadic Procedure} gexp->script @var{name} @var{exp}
  4092. Return an executable script @var{name} that runs @var{exp} using
  4093. @var{guile}, with @var{exp}'s imported modules in its search path.
  4094. The example below builds a script that simply invokes the @command{ls}
  4095. command:
  4096. @example
  4097. (use-modules (guix gexp) (gnu packages base))
  4098. (gexp->script "list-files"
  4099. #~(execl #$(file-append coreutils "/bin/ls")
  4100. "ls"))
  4101. @end example
  4102. When ``running'' it through the store (@pxref{The Store Monad,
  4103. @code{run-with-store}}), we obtain a derivation that produces an
  4104. executable file @file{/gnu/store/@dots{}-list-files} along these lines:
  4105. @example
  4106. #!/gnu/store/@dots{}-guile-2.0.11/bin/guile -ds
  4107. !#
  4108. (execl "/gnu/store/@dots{}-coreutils-8.22"/bin/ls" "ls")
  4109. @end example
  4110. @end deffn
  4111. @deffn {Scheme Procedure} program-file @var{name} @var{exp} @
  4112. [#:guile #f]
  4113. Return an object representing the executable store item @var{name} that
  4114. runs @var{gexp}. @var{guile} is the Guile package used to execute that
  4115. script.
  4116. This is the declarative counterpart of @code{gexp->script}.
  4117. @end deffn
  4118. @deffn {Monadic Procedure} gexp->file @var{name} @var{exp} @
  4119. [#:set-load-path? #t]
  4120. Return a derivation that builds a file @var{name} containing @var{exp}.
  4121. When @var{set-load-path?} is true, emit code in the resulting file to
  4122. set @code{%load-path} and @code{%load-compiled-path} to honor
  4123. @var{exp}'s imported modules.
  4124. The resulting file holds references to all the dependencies of @var{exp}
  4125. or a subset thereof.
  4126. @end deffn
  4127. @deffn {Scheme Procedure} scheme-file @var{name} @var{exp}
  4128. Return an object representing the Scheme file @var{name} that contains
  4129. @var{exp}.
  4130. This is the declarative counterpart of @code{gexp->file}.
  4131. @end deffn
  4132. @deffn {Monadic Procedure} text-file* @var{name} @var{text} @dots{}
  4133. Return as a monadic value a derivation that builds a text file
  4134. containing all of @var{text}. @var{text} may list, in addition to
  4135. strings, objects of any type that can be used in a gexp: packages,
  4136. derivations, local file objects, etc. The resulting store file holds
  4137. references to all these.
  4138. This variant should be preferred over @code{text-file} anytime the file
  4139. to create will reference items from the store. This is typically the
  4140. case when building a configuration file that embeds store file names,
  4141. like this:
  4142. @example
  4143. (define (profile.sh)
  4144. ;; Return the name of a shell script in the store that
  4145. ;; initializes the 'PATH' environment variable.
  4146. (text-file* "profile.sh"
  4147. "export PATH=" coreutils "/bin:"
  4148. grep "/bin:" sed "/bin\n"))
  4149. @end example
  4150. In this example, the resulting @file{/gnu/store/@dots{}-profile.sh} file
  4151. will reference @var{coreutils}, @var{grep}, and @var{sed}, thereby
  4152. preventing them from being garbage-collected during its lifetime.
  4153. @end deffn
  4154. @deffn {Scheme Procedure} mixed-text-file @var{name} @var{text} @dots{}
  4155. Return an object representing store file @var{name} containing
  4156. @var{text}. @var{text} is a sequence of strings and file-like objects,
  4157. as in:
  4158. @example
  4159. (mixed-text-file "profile"
  4160. "export PATH=" coreutils "/bin:" grep "/bin")
  4161. @end example
  4162. This is the declarative counterpart of @code{text-file*}.
  4163. @end deffn
  4164. @deffn {Scheme Procedure} file-union @var{name} @var{files}
  4165. Return a @code{<computed-file>} that builds a directory containing all of @var{files}.
  4166. Each item in @var{files} must be a two-element list where the first element is the
  4167. file name to use in the new directory, and the second element is a gexp
  4168. denoting the target file. Here's an example:
  4169. @example
  4170. (file-union "etc"
  4171. `(("hosts" ,(plain-file "hosts"
  4172. "127.0.0.1 localhost"))
  4173. ("bashrc" ,(plain-file "bashrc"
  4174. "alias ls='ls --color'"))))
  4175. @end example
  4176. This yields an @code{etc} directory containing these two files.
  4177. @end deffn
  4178. @deffn {Scheme Procedure} directory-union @var{name} @var{things}
  4179. Return a directory that is the union of @var{things}, where @var{things} is a list of
  4180. file-like objects denoting directories. For example:
  4181. @example
  4182. (directory-union "guile+emacs" (list guile emacs))
  4183. @end example
  4184. yields a directory that is the union of the @code{guile} and @code{emacs} packages.
  4185. @end deffn
  4186. @deffn {Scheme Procedure} file-append @var{obj} @var{suffix} @dots{}
  4187. Return a file-like object that expands to the concatenation of @var{obj}
  4188. and @var{suffix}, where @var{obj} is a lowerable object and each
  4189. @var{suffix} is a string.
  4190. As an example, consider this gexp:
  4191. @example
  4192. (gexp->script "run-uname"
  4193. #~(system* #$(file-append coreutils
  4194. "/bin/uname")))
  4195. @end example
  4196. The same effect could be achieved with:
  4197. @example
  4198. (gexp->script "run-uname"
  4199. #~(system* (string-append #$coreutils
  4200. "/bin/uname")))
  4201. @end example
  4202. There is one difference though: in the @code{file-append} case, the
  4203. resulting script contains the absolute file name as a string, whereas in
  4204. the second case, the resulting script contains a @code{(string-append
  4205. @dots{})} expression to construct the file name @emph{at run time}.
  4206. @end deffn
  4207. Of course, in addition to gexps embedded in ``host'' code, there are
  4208. also modules containing build tools. To make it clear that they are
  4209. meant to be used in the build stratum, these modules are kept in the
  4210. @code{(guix build @dots{})} name space.
  4211. @cindex lowering, of high-level objects in gexps
  4212. Internally, high-level objects are @dfn{lowered}, using their compiler,
  4213. to either derivations or store items. For instance, lowering a package
  4214. yields a derivation, and lowering a @code{plain-file} yields a store
  4215. item. This is achieved using the @code{lower-object} monadic procedure.
  4216. @deffn {Monadic Procedure} lower-object @var{obj} [@var{system}] @
  4217. [#:target #f]
  4218. Return as a value in @var{%store-monad} the derivation or store item
  4219. corresponding to @var{obj} for @var{system}, cross-compiling for
  4220. @var{target} if @var{target} is true. @var{obj} must be an object that
  4221. has an associated gexp compiler, such as a @code{<package>}.
  4222. @end deffn
  4223. @c *********************************************************************
  4224. @node Utilities
  4225. @chapter Utilities
  4226. This section describes Guix command-line utilities. Some of them are
  4227. primarily targeted at developers and users who write new package
  4228. definitions, while others are more generally useful. They complement
  4229. the Scheme programming interface of Guix in a convenient way.
  4230. @menu
  4231. * Invoking guix build:: Building packages from the command line.
  4232. * Invoking guix edit:: Editing package definitions.
  4233. * Invoking guix download:: Downloading a file and printing its hash.
  4234. * Invoking guix hash:: Computing the cryptographic hash of a file.
  4235. * Invoking guix import:: Importing package definitions.
  4236. * Invoking guix refresh:: Updating package definitions.
  4237. * Invoking guix lint:: Finding errors in package definitions.
  4238. * Invoking guix size:: Profiling disk usage.
  4239. * Invoking guix graph:: Visualizing the graph of packages.
  4240. * Invoking guix environment:: Setting up development environments.
  4241. * Invoking guix publish:: Sharing substitutes.
  4242. * Invoking guix challenge:: Challenging substitute servers.
  4243. * Invoking guix copy:: Copying to and from a remote store.
  4244. * Invoking guix container:: Process isolation.
  4245. * Invoking guix weather:: Assessing substitute availability.
  4246. @end menu
  4247. @node Invoking guix build
  4248. @section Invoking @command{guix build}
  4249. @cindex package building
  4250. @cindex @command{guix build}
  4251. The @command{guix build} command builds packages or derivations and
  4252. their dependencies, and prints the resulting store paths. Note that it
  4253. does not modify the user's profile---this is the job of the
  4254. @command{guix package} command (@pxref{Invoking guix package}). Thus,
  4255. it is mainly useful for distribution developers.
  4256. The general syntax is:
  4257. @example
  4258. guix build @var{options} @var{package-or-derivation}@dots{}
  4259. @end example
  4260. As an example, the following command builds the latest versions of Emacs
  4261. and of Guile, displays their build logs, and finally displays the
  4262. resulting directories:
  4263. @example
  4264. guix build emacs guile
  4265. @end example
  4266. Similarly, the following command builds all the available packages:
  4267. @example
  4268. guix build --quiet --keep-going \
  4269. `guix package -A | cut -f1,2 --output-delimiter=@@`
  4270. @end example
  4271. @var{package-or-derivation} may be either the name of a package found in
  4272. the software distribution such as @code{coreutils} or
  4273. @code{coreutils@@8.20}, or a derivation such as
  4274. @file{/gnu/store/@dots{}-coreutils-8.19.drv}. In the former case, a
  4275. package with the corresponding name (and optionally version) is searched
  4276. for among the GNU distribution modules (@pxref{Package Modules}).
  4277. Alternatively, the @code{--expression} option may be used to specify a
  4278. Scheme expression that evaluates to a package; this is useful when
  4279. disambiguating among several same-named packages or package variants is
  4280. needed.
  4281. There may be zero or more @var{options}. The available options are
  4282. described in the subsections below.
  4283. @menu
  4284. * Common Build Options:: Build options for most commands.
  4285. * Package Transformation Options:: Creating variants of packages.
  4286. * Additional Build Options:: Options specific to 'guix build'.
  4287. * Debugging Build Failures:: Real life packaging experience.
  4288. @end menu
  4289. @node Common Build Options
  4290. @subsection Common Build Options
  4291. A number of options that control the build process are common to
  4292. @command{guix build} and other commands that can spawn builds, such as
  4293. @command{guix package} or @command{guix archive}. These are the
  4294. following:
  4295. @table @code
  4296. @item --load-path=@var{directory}
  4297. @itemx -L @var{directory}
  4298. Add @var{directory} to the front of the package module search path
  4299. (@pxref{Package Modules}).
  4300. This allows users to define their own packages and make them visible to
  4301. the command-line tools.
  4302. @item --keep-failed
  4303. @itemx -K
  4304. Keep the build tree of failed builds. Thus, if a build fails, its build
  4305. tree is kept under @file{/tmp}, in a directory whose name is shown at
  4306. the end of the build log. This is useful when debugging build issues.
  4307. @xref{Debugging Build Failures}, for tips and tricks on how to debug
  4308. build issues.
  4309. @item --keep-going
  4310. @itemx -k
  4311. Keep going when some of the derivations fail to build; return only once
  4312. all the builds have either completed or failed.
  4313. The default behavior is to stop as soon as one of the specified
  4314. derivations has failed.
  4315. @item --dry-run
  4316. @itemx -n
  4317. Do not build the derivations.
  4318. @anchor{fallback-option}
  4319. @item --fallback
  4320. When substituting a pre-built binary fails, fall back to building
  4321. packages locally (@pxref{Substitution Failure}).
  4322. @item --substitute-urls=@var{urls}
  4323. @anchor{client-substitute-urls}
  4324. Consider @var{urls} the whitespace-separated list of substitute source
  4325. URLs, overriding the default list of URLs of @command{guix-daemon}
  4326. (@pxref{daemon-substitute-urls,, @command{guix-daemon} URLs}).
  4327. This means that substitutes may be downloaded from @var{urls}, provided
  4328. they are signed by a key authorized by the system administrator
  4329. (@pxref{Substitutes}).
  4330. When @var{urls} is the empty string, substitutes are effectively
  4331. disabled.
  4332. @item --no-substitutes
  4333. Do not use substitutes for build products. That is, always build things
  4334. locally instead of allowing downloads of pre-built binaries
  4335. (@pxref{Substitutes}).
  4336. @item --no-grafts
  4337. Do not ``graft'' packages. In practice, this means that package updates
  4338. available as grafts are not applied. @xref{Security Updates}, for more
  4339. information on grafts.
  4340. @item --rounds=@var{n}
  4341. Build each derivation @var{n} times in a row, and raise an error if
  4342. consecutive build results are not bit-for-bit identical.
  4343. This is a useful way to detect non-deterministic builds processes.
  4344. Non-deterministic build processes are a problem because they make it
  4345. practically impossible for users to @emph{verify} whether third-party
  4346. binaries are genuine. @xref{Invoking guix challenge}, for more.
  4347. Note that, currently, the differing build results are not kept around,
  4348. so you will have to manually investigate in case of an error---e.g., by
  4349. stashing one of the build results with @code{guix archive --export}
  4350. (@pxref{Invoking guix archive}), then rebuilding, and finally comparing
  4351. the two results.
  4352. @item --no-build-hook
  4353. Do not attempt to offload builds @i{via} the ``build hook'' of the daemon
  4354. (@pxref{Daemon Offload Setup}). That is, always build things locally
  4355. instead of offloading builds to remote machines.
  4356. @item --max-silent-time=@var{seconds}
  4357. When the build or substitution process remains silent for more than
  4358. @var{seconds}, terminate it and report a build failure.
  4359. By default, the daemon's setting is honored (@pxref{Invoking
  4360. guix-daemon, @code{--max-silent-time}}).
  4361. @item --timeout=@var{seconds}
  4362. Likewise, when the build or substitution process lasts for more than
  4363. @var{seconds}, terminate it and report a build failure.
  4364. By default, the daemon's setting is honored (@pxref{Invoking
  4365. guix-daemon, @code{--timeout}}).
  4366. @item --verbosity=@var{level}
  4367. Use the given verbosity level. @var{level} must be an integer between 0
  4368. and 5; higher means more verbose output. Setting a level of 4 or more
  4369. may be helpful when debugging setup issues with the build daemon.
  4370. @item --cores=@var{n}
  4371. @itemx -c @var{n}
  4372. Allow the use of up to @var{n} CPU cores for the build. The special
  4373. value @code{0} means to use as many CPU cores as available.
  4374. @item --max-jobs=@var{n}
  4375. @itemx -M @var{n}
  4376. Allow at most @var{n} build jobs in parallel. @xref{Invoking
  4377. guix-daemon, @code{--max-jobs}}, for details about this option and the
  4378. equivalent @command{guix-daemon} option.
  4379. @end table
  4380. Behind the scenes, @command{guix build} is essentially an interface to
  4381. the @code{package-derivation} procedure of the @code{(guix packages)}
  4382. module, and to the @code{build-derivations} procedure of the @code{(guix
  4383. derivations)} module.
  4384. In addition to options explicitly passed on the command line,
  4385. @command{guix build} and other @command{guix} commands that support
  4386. building honor the @code{GUIX_BUILD_OPTIONS} environment variable.
  4387. @defvr {Environment Variable} GUIX_BUILD_OPTIONS
  4388. Users can define this variable to a list of command line options that
  4389. will automatically be used by @command{guix build} and other
  4390. @command{guix} commands that can perform builds, as in the example
  4391. below:
  4392. @example
  4393. $ export GUIX_BUILD_OPTIONS="--no-substitutes -c 2 -L /foo/bar"
  4394. @end example
  4395. These options are parsed independently, and the result is appended to
  4396. the parsed command-line options.
  4397. @end defvr
  4398. @node Package Transformation Options
  4399. @subsection Package Transformation Options
  4400. @cindex package variants
  4401. Another set of command-line options supported by @command{guix build}
  4402. and also @command{guix package} are @dfn{package transformation
  4403. options}. These are options that make it possible to define @dfn{package
  4404. variants}---for instance, packages built from different source code.
  4405. This is a convenient way to create customized packages on the fly
  4406. without having to type in the definitions of package variants
  4407. (@pxref{Defining Packages}).
  4408. @table @code
  4409. @item --with-source=@var{source}
  4410. @itemx --with-source=@var{package}=@var{source}
  4411. @itemx --with-source=@var{package}@@@var{version}=@var{source}
  4412. Use @var{source} as the source of @var{package}, and @var{version} as
  4413. its version number.
  4414. @var{source} must be a file name or a URL, as for @command{guix
  4415. download} (@pxref{Invoking guix download}).
  4416. When @var{package} is omitted,
  4417. it is taken to be the package name specified on the
  4418. command line that matches the base of @var{source}---e.g.,
  4419. if @var{source} is @code{/src/guile-2.0.10.tar.gz}, the corresponding
  4420. package is @code{guile}.
  4421. Likewise, when @var{version} is omitted, the version string is inferred from
  4422. @var{source}; in the previous example, it is @code{2.0.10}.
  4423. This option allows users to try out versions of packages other than the
  4424. one provided by the distribution. The example below downloads
  4425. @file{ed-1.7.tar.gz} from a GNU mirror and uses that as the source for
  4426. the @code{ed} package:
  4427. @example
  4428. guix build ed --with-source=mirror://gnu/ed/ed-1.7.tar.gz
  4429. @end example
  4430. As a developer, @code{--with-source} makes it easy to test release
  4431. candidates:
  4432. @example
  4433. guix build guile --with-source=../guile-2.0.9.219-e1bb7.tar.xz
  4434. @end example
  4435. @dots{} or to build from a checkout in a pristine environment:
  4436. @example
  4437. $ git clone git://git.sv.gnu.org/guix.git
  4438. $ guix build guix --with-source=guix@@1.0=./guix
  4439. @end example
  4440. @item --with-input=@var{package}=@var{replacement}
  4441. Replace dependency on @var{package} by a dependency on
  4442. @var{replacement}. @var{package} must be a package name, and
  4443. @var{replacement} must be a package specification such as @code{guile}
  4444. or @code{guile@@1.8}.
  4445. For instance, the following command builds Guix, but replaces its
  4446. dependency on the current stable version of Guile with a dependency on
  4447. the legacy version of Guile, @code{guile@@2.0}:
  4448. @example
  4449. guix build --with-input=guile=guile@@2.0 guix
  4450. @end example
  4451. This is a recursive, deep replacement. So in this example, both
  4452. @code{guix} and its dependency @code{guile-json} (which also depends on
  4453. @code{guile}) get rebuilt against @code{guile@@2.0}.
  4454. This is implemented using the @code{package-input-rewriting} Scheme
  4455. procedure (@pxref{Defining Packages, @code{package-input-rewriting}}).
  4456. @item --with-graft=@var{package}=@var{replacement}
  4457. This is similar to @code{--with-input} but with an important difference:
  4458. instead of rebuilding the whole dependency chain, @var{replacement} is
  4459. built and then @dfn{grafted} onto the binaries that were initially
  4460. referring to @var{package}. @xref{Security Updates}, for more
  4461. information on grafts.
  4462. For example, the command below grafts version 3.5.4 of GnuTLS onto Wget
  4463. and all its dependencies, replacing references to the version of GnuTLS
  4464. they currently refer to:
  4465. @example
  4466. guix build --with-graft=gnutls=gnutls@@3.5.4 wget
  4467. @end example
  4468. This has the advantage of being much faster than rebuilding everything.
  4469. But there is a caveat: it works if and only if @var{package} and
  4470. @var{replacement} are strictly compatible---for example, if they provide
  4471. a library, the application binary interface (ABI) of those libraries
  4472. must be compatible. If @var{replacement} is somehow incompatible with
  4473. @var{package}, then the resulting package may be unusable. Use with
  4474. care!
  4475. @end table
  4476. @node Additional Build Options
  4477. @subsection Additional Build Options
  4478. The command-line options presented below are specific to @command{guix
  4479. build}.
  4480. @table @code
  4481. @item --quiet
  4482. @itemx -q
  4483. Build quietly, without displaying the build log. Upon completion, the
  4484. build log is kept in @file{/var} (or similar) and can always be
  4485. retrieved using the @option{--log-file} option.
  4486. @item --file=@var{file}
  4487. @itemx -f @var{file}
  4488. Build the package or derivation that the code within @var{file}
  4489. evaluates to.
  4490. As an example, @var{file} might contain a package definition like this
  4491. (@pxref{Defining Packages}):
  4492. @example
  4493. @verbatiminclude package-hello.scm
  4494. @end example
  4495. @item --expression=@var{expr}
  4496. @itemx -e @var{expr}
  4497. Build the package or derivation @var{expr} evaluates to.
  4498. For example, @var{expr} may be @code{(@@ (gnu packages guile)
  4499. guile-1.8)}, which unambiguously designates this specific variant of
  4500. version 1.8 of Guile.
  4501. Alternatively, @var{expr} may be a G-expression, in which case it is used
  4502. as a build program passed to @code{gexp->derivation}
  4503. (@pxref{G-Expressions}).
  4504. Lastly, @var{expr} may refer to a zero-argument monadic procedure
  4505. (@pxref{The Store Monad}). The procedure must return a derivation as a
  4506. monadic value, which is then passed through @code{run-with-store}.
  4507. @item --source
  4508. @itemx -S
  4509. Build the source derivations of the packages, rather than the packages
  4510. themselves.
  4511. For instance, @code{guix build -S gcc} returns something like
  4512. @file{/gnu/store/@dots{}-gcc-4.7.2.tar.bz2}, which is the GCC
  4513. source tarball.
  4514. The returned source tarball is the result of applying any patches and
  4515. code snippets specified in the package @code{origin} (@pxref{Defining
  4516. Packages}).
  4517. @item --sources
  4518. Fetch and return the source of @var{package-or-derivation} and all their
  4519. dependencies, recursively. This is a handy way to obtain a local copy
  4520. of all the source code needed to build @var{packages}, allowing you to
  4521. eventually build them even without network access. It is an extension
  4522. of the @code{--source} option and can accept one of the following
  4523. optional argument values:
  4524. @table @code
  4525. @item package
  4526. This value causes the @code{--sources} option to behave in the same way
  4527. as the @code{--source} option.
  4528. @item all
  4529. Build the source derivations of all packages, including any source that
  4530. might be listed as @code{inputs}. This is the default value.
  4531. @example
  4532. $ guix build --sources tzdata
  4533. The following derivations will be built:
  4534. /gnu/store/@dots{}-tzdata2015b.tar.gz.drv
  4535. /gnu/store/@dots{}-tzcode2015b.tar.gz.drv
  4536. @end example
  4537. @item transitive
  4538. Build the source derivations of all packages, as well of all transitive
  4539. inputs to the packages. This can be used e.g. to
  4540. prefetch package source for later offline building.
  4541. @example
  4542. $ guix build --sources=transitive tzdata
  4543. The following derivations will be built:
  4544. /gnu/store/@dots{}-tzcode2015b.tar.gz.drv
  4545. /gnu/store/@dots{}-findutils-4.4.2.tar.xz.drv
  4546. /gnu/store/@dots{}-grep-2.21.tar.xz.drv
  4547. /gnu/store/@dots{}-coreutils-8.23.tar.xz.drv
  4548. /gnu/store/@dots{}-make-4.1.tar.xz.drv
  4549. /gnu/store/@dots{}-bash-4.3.tar.xz.drv
  4550. @dots{}
  4551. @end example
  4552. @end table
  4553. @item --system=@var{system}
  4554. @itemx -s @var{system}
  4555. Attempt to build for @var{system}---e.g., @code{i686-linux}---instead of
  4556. the system type of the build host.
  4557. @quotation Note
  4558. The @code{--system} flag is for @emph{native} compilation and must not
  4559. be confused with cross-compilation. See @code{--target} below for
  4560. information on cross-compilation.
  4561. @end quotation
  4562. An example use of this is on Linux-based systems, which can emulate
  4563. different personalities. For instance, passing
  4564. @code{--system=i686-linux} on an @code{x86_64-linux} system allows you
  4565. to build packages in a complete 32-bit environment.
  4566. Similarly, when transparent emulation with QEMU and @code{binfmt_misc}
  4567. is enabled (@pxref{Virtualization Services,
  4568. @code{qemu-binfmt-service-type}}), you can build for any system for
  4569. which a QEMU @code{binfmt_misc} handler is installed.
  4570. Builds for a system other than that of the machine you are using can
  4571. also be offloaded to a remote machine of the right architecture.
  4572. @xref{Daemon Offload Setup}, for more information on offloading.
  4573. @item --target=@var{triplet}
  4574. @cindex cross-compilation
  4575. Cross-build for @var{triplet}, which must be a valid GNU triplet, such
  4576. as @code{"mips64el-linux-gnu"} (@pxref{Specifying target triplets, GNU
  4577. configuration triplets,, autoconf, Autoconf}).
  4578. @anchor{build-check}
  4579. @item --check
  4580. @cindex determinism, checking
  4581. @cindex reproducibility, checking
  4582. Rebuild @var{package-or-derivation}, which are already available in the
  4583. store, and raise an error if the build results are not bit-for-bit
  4584. identical.
  4585. This mechanism allows you to check whether previously installed
  4586. substitutes are genuine (@pxref{Substitutes}), or whether the build result
  4587. of a package is deterministic. @xref{Invoking guix challenge}, for more
  4588. background information and tools.
  4589. When used in conjunction with @option{--keep-failed}, the differing
  4590. output is kept in the store, under @file{/gnu/store/@dots{}-check}.
  4591. This makes it easy to look for differences between the two results.
  4592. @item --repair
  4593. @cindex repairing store items
  4594. @cindex corruption, recovering from
  4595. Attempt to repair the specified store items, if they are corrupt, by
  4596. re-downloading or rebuilding them.
  4597. This operation is not atomic and thus restricted to @code{root}.
  4598. @item --derivations
  4599. @itemx -d
  4600. Return the derivation paths, not the output paths, of the given
  4601. packages.
  4602. @item --root=@var{file}
  4603. @itemx -r @var{file}
  4604. @cindex GC roots, adding
  4605. @cindex garbage collector roots, adding
  4606. Make @var{file} a symlink to the result, and register it as a garbage
  4607. collector root.
  4608. Consequently, the results of this @command{guix build} invocation are
  4609. protected from garbage collection until @var{file} is removed. When
  4610. that option is omitted, build results are eligible for garbage
  4611. collection as soon as the build completes. @xref{Invoking guix gc}, for
  4612. more on GC roots.
  4613. @item --log-file
  4614. @cindex build logs, access
  4615. Return the build log file names or URLs for the given
  4616. @var{package-or-derivation}, or raise an error if build logs are
  4617. missing.
  4618. This works regardless of how packages or derivations are specified. For
  4619. instance, the following invocations are equivalent:
  4620. @example
  4621. guix build --log-file `guix build -d guile`
  4622. guix build --log-file `guix build guile`
  4623. guix build --log-file guile
  4624. guix build --log-file -e '(@@ (gnu packages guile) guile-2.0)'
  4625. @end example
  4626. If a log is unavailable locally, and unless @code{--no-substitutes} is
  4627. passed, the command looks for a corresponding log on one of the
  4628. substitute servers (as specified with @code{--substitute-urls}.)
  4629. So for instance, imagine you want to see the build log of GDB on MIPS,
  4630. but you are actually on an @code{x86_64} machine:
  4631. @example
  4632. $ guix build --log-file gdb -s mips64el-linux
  4633. https://hydra.gnu.org/log/@dots{}-gdb-7.10
  4634. @end example
  4635. You can freely access a huge library of build logs!
  4636. @end table
  4637. @node Debugging Build Failures
  4638. @subsection Debugging Build Failures
  4639. @cindex build failures, debugging
  4640. When defining a new package (@pxref{Defining Packages}), you will
  4641. probably find yourself spending some time debugging and tweaking the
  4642. build until it succeeds. To do that, you need to operate the build
  4643. commands yourself in an environment as close as possible to the one the
  4644. build daemon uses.
  4645. To that end, the first thing to do is to use the @option{--keep-failed}
  4646. or @option{-K} option of @command{guix build}, which will keep the
  4647. failed build tree in @file{/tmp} or whatever directory you specified as
  4648. @code{TMPDIR} (@pxref{Invoking guix build, @code{--keep-failed}}).
  4649. From there on, you can @command{cd} to the failed build tree and source
  4650. the @file{environment-variables} file, which contains all the
  4651. environment variable definitions that were in place when the build
  4652. failed. So let's say you're debugging a build failure in package
  4653. @code{foo}; a typical session would look like this:
  4654. @example
  4655. $ guix build foo -K
  4656. @dots{} @i{build fails}
  4657. $ cd /tmp/guix-build-foo.drv-0
  4658. $ source ./environment-variables
  4659. $ cd foo-1.2
  4660. @end example
  4661. Now, you can invoke commands as if you were the daemon (almost) and
  4662. troubleshoot your build process.
  4663. Sometimes it happens that, for example, a package's tests pass when you
  4664. run them manually but they fail when the daemon runs them. This can
  4665. happen because the daemon runs builds in containers where, unlike in our
  4666. environment above, network access is missing, @file{/bin/sh} does not
  4667. exist, etc. (@pxref{Build Environment Setup}).
  4668. In such cases, you may need to run inspect the build process from within
  4669. a container similar to the one the build daemon creates:
  4670. @example
  4671. $ guix build -K foo
  4672. @dots{}
  4673. $ cd /tmp/guix-build-foo.drv-0
  4674. $ guix environment --no-grafts -C foo --ad-hoc strace gdb
  4675. [env]# source ./environment-variables
  4676. [env]# cd foo-1.2
  4677. @end example
  4678. Here, @command{guix environment -C} creates a container and spawns a new
  4679. shell in it (@pxref{Invoking guix environment}). The @command{--ad-hoc
  4680. strace gdb} part adds the @command{strace} and @command{gdb} commands to
  4681. the container, which would may find handy while debugging. The
  4682. @option{--no-grafts} option makes sure we get the exact same
  4683. environment, with ungrafted packages (@pxref{Security Updates}, for more
  4684. info on grafts).
  4685. To get closer to a container like that used by the build daemon, we can
  4686. remove @file{/bin/sh}:
  4687. @example
  4688. [env]# rm /bin/sh
  4689. @end example
  4690. (Don't worry, this is harmless: this is all happening in the throw-away
  4691. container created by @command{guix environment}.)
  4692. The @command{strace} command is probably not in the search path, but we
  4693. can run:
  4694. @example
  4695. [env]# $GUIX_ENVIRONMENT/bin/strace -f -o log make check
  4696. @end example
  4697. In this way, not only you will have reproduced the environment variables
  4698. the daemon uses, you will also be running the build process in a container
  4699. similar to the one the daemon uses.
  4700. @node Invoking guix edit
  4701. @section Invoking @command{guix edit}
  4702. @cindex @command{guix edit}
  4703. @cindex package definition, editing
  4704. So many packages, so many source files! The @command{guix edit} command
  4705. facilitates the life of users and packagers by pointing their editor at
  4706. the source file containing the definition of the specified packages.
  4707. For instance:
  4708. @example
  4709. guix edit gcc@@4.9 vim
  4710. @end example
  4711. @noindent
  4712. launches the program specified in the @code{VISUAL} or in the
  4713. @code{EDITOR} environment variable to view the recipe of GCC@tie{}4.9.3
  4714. and that of Vim.
  4715. If you are using a Guix Git checkout (@pxref{Building from Git}), or
  4716. have created your own packages on @code{GUIX_PACKAGE_PATH}
  4717. (@pxref{Defining Packages}), you will be able to edit the package
  4718. recipes. Otherwise, you will be able to examine the read-only recipes
  4719. for packages currently in the store.
  4720. @node Invoking guix download
  4721. @section Invoking @command{guix download}
  4722. @cindex @command{guix download}
  4723. @cindex downloading package sources
  4724. When writing a package definition, developers typically need to download
  4725. a source tarball, compute its SHA256 hash, and write that
  4726. hash in the package definition (@pxref{Defining Packages}). The
  4727. @command{guix download} tool helps with this task: it downloads a file
  4728. from the given URI, adds it to the store, and prints both its file name
  4729. in the store and its SHA256 hash.
  4730. The fact that the downloaded file is added to the store saves bandwidth:
  4731. when the developer eventually tries to build the newly defined package
  4732. with @command{guix build}, the source tarball will not have to be
  4733. downloaded again because it is already in the store. It is also a
  4734. convenient way to temporarily stash files, which may be deleted
  4735. eventually (@pxref{Invoking guix gc}).
  4736. The @command{guix download} command supports the same URIs as used in
  4737. package definitions. In particular, it supports @code{mirror://} URIs.
  4738. @code{https} URIs (HTTP over TLS) are supported @emph{provided} the
  4739. Guile bindings for GnuTLS are available in the user's environment; when
  4740. they are not available, an error is raised. @xref{Guile Preparations,
  4741. how to install the GnuTLS bindings for Guile,, gnutls-guile,
  4742. GnuTLS-Guile}, for more information.
  4743. @command{guix download} verifies HTTPS server certificates by loading
  4744. the certificates of X.509 authorities from the directory pointed to by
  4745. the @code{SSL_CERT_DIR} environment variable (@pxref{X.509
  4746. Certificates}), unless @option{--no-check-certificate} is used.
  4747. The following options are available:
  4748. @table @code
  4749. @item --format=@var{fmt}
  4750. @itemx -f @var{fmt}
  4751. Write the hash in the format specified by @var{fmt}. For more
  4752. information on the valid values for @var{fmt}, @pxref{Invoking guix hash}.
  4753. @item --no-check-certificate
  4754. Do not validate the X.509 certificates of HTTPS servers.
  4755. When using this option, you have @emph{absolutely no guarantee} that you
  4756. are communicating with the authentic server responsible for the given
  4757. URL, which makes you vulnerable to ``man-in-the-middle'' attacks.
  4758. @item --output=@var{file}
  4759. @itemx -o @var{file}
  4760. Save the downloaded file to @var{file} instead of adding it to the
  4761. store.
  4762. @end table
  4763. @node Invoking guix hash
  4764. @section Invoking @command{guix hash}
  4765. @cindex @command{guix hash}
  4766. The @command{guix hash} command computes the SHA256 hash of a file.
  4767. It is primarily a convenience tool for anyone contributing to the
  4768. distribution: it computes the cryptographic hash of a file, which can be
  4769. used in the definition of a package (@pxref{Defining Packages}).
  4770. The general syntax is:
  4771. @example
  4772. guix hash @var{option} @var{file}
  4773. @end example
  4774. When @var{file} is @code{-} (a hyphen), @command{guix hash} computes the
  4775. hash of data read from standard input. @command{guix hash} has the
  4776. following options:
  4777. @table @code
  4778. @item --format=@var{fmt}
  4779. @itemx -f @var{fmt}
  4780. Write the hash in the format specified by @var{fmt}.
  4781. Supported formats: @code{nix-base32}, @code{base32}, @code{base16}
  4782. (@code{hex} and @code{hexadecimal} can be used as well).
  4783. If the @option{--format} option is not specified, @command{guix hash}
  4784. will output the hash in @code{nix-base32}. This representation is used
  4785. in the definitions of packages.
  4786. @item --recursive
  4787. @itemx -r
  4788. Compute the hash on @var{file} recursively.
  4789. In this case, the hash is computed on an archive containing @var{file},
  4790. including its children if it is a directory. Some of the metadata of
  4791. @var{file} is part of the archive; for instance, when @var{file} is a
  4792. regular file, the hash is different depending on whether @var{file} is
  4793. executable or not. Metadata such as time stamps has no impact on the
  4794. hash (@pxref{Invoking guix archive}).
  4795. @c FIXME: Replace xref above with xref to an ``Archive'' section when
  4796. @c it exists.
  4797. @item --exclude-vcs
  4798. @itemx -x
  4799. When combined with @option{--recursive}, exclude version control system
  4800. directories (@file{.bzr}, @file{.git}, @file{.hg}, etc.)
  4801. @vindex git-fetch
  4802. As an example, here is how you would compute the hash of a Git checkout,
  4803. which is useful when using the @code{git-fetch} method (@pxref{origin
  4804. Reference}):
  4805. @example
  4806. $ git clone http://example.org/foo.git
  4807. $ cd foo
  4808. $ guix hash -rx .
  4809. @end example
  4810. @end table
  4811. @node Invoking guix import
  4812. @section Invoking @command{guix import}
  4813. @cindex importing packages
  4814. @cindex package import
  4815. @cindex package conversion
  4816. @cindex Invoking @command{guix import}
  4817. The @command{guix import} command is useful for people who would like to
  4818. add a package to the distribution with as little work as
  4819. possible---a legitimate demand. The command knows of a few
  4820. repositories from which it can ``import'' package metadata. The result
  4821. is a package definition, or a template thereof, in the format we know
  4822. (@pxref{Defining Packages}).
  4823. The general syntax is:
  4824. @example
  4825. guix import @var{importer} @var{options}@dots{}
  4826. @end example
  4827. @var{importer} specifies the source from which to import package
  4828. metadata, and @var{options} specifies a package identifier and other
  4829. options specific to @var{importer}. Currently, the available
  4830. ``importers'' are:
  4831. @table @code
  4832. @item gnu
  4833. Import metadata for the given GNU package. This provides a template
  4834. for the latest version of that GNU package, including the hash of its
  4835. source tarball, and its canonical synopsis and description.
  4836. Additional information such as the package dependencies and its
  4837. license needs to be figured out manually.
  4838. For example, the following command returns a package definition for
  4839. GNU@tie{}Hello:
  4840. @example
  4841. guix import gnu hello
  4842. @end example
  4843. Specific command-line options are:
  4844. @table @code
  4845. @item --key-download=@var{policy}
  4846. As for @code{guix refresh}, specify the policy to handle missing OpenPGP
  4847. keys when verifying the package signature. @xref{Invoking guix
  4848. refresh, @code{--key-download}}.
  4849. @end table
  4850. @item pypi
  4851. @cindex pypi
  4852. Import metadata from the @uref{https://pypi.python.org/, Python Package
  4853. Index}@footnote{This functionality requires Guile-JSON to be installed.
  4854. @xref{Requirements}.}. Information is taken from the JSON-formatted
  4855. description available at @code{pypi.python.org} and usually includes all
  4856. the relevant information, including package dependencies. For maximum
  4857. efficiency, it is recommended to install the @command{unzip} utility, so
  4858. that the importer can unzip Python wheels and gather data from them.
  4859. The command below imports metadata for the @code{itsdangerous} Python
  4860. package:
  4861. @example
  4862. guix import pypi itsdangerous
  4863. @end example
  4864. @item gem
  4865. @cindex gem
  4866. Import metadata from @uref{https://rubygems.org/,
  4867. RubyGems}@footnote{This functionality requires Guile-JSON to be
  4868. installed. @xref{Requirements}.}. Information is taken from the
  4869. JSON-formatted description available at @code{rubygems.org} and includes
  4870. most relevant information, including runtime dependencies. There are
  4871. some caveats, however. The metadata doesn't distinguish between
  4872. synopses and descriptions, so the same string is used for both fields.
  4873. Additionally, the details of non-Ruby dependencies required to build
  4874. native extensions is unavailable and left as an exercise to the
  4875. packager.
  4876. The command below imports metadata for the @code{rails} Ruby package:
  4877. @example
  4878. guix import gem rails
  4879. @end example
  4880. @item cpan
  4881. @cindex CPAN
  4882. Import metadata from @uref{https://www.metacpan.org/, MetaCPAN}@footnote{This
  4883. functionality requires Guile-JSON to be installed.
  4884. @xref{Requirements}.}.
  4885. Information is taken from the JSON-formatted metadata provided through
  4886. @uref{https://fastapi.metacpan.org/, MetaCPAN's API} and includes most
  4887. relevant information, such as module dependencies. License information
  4888. should be checked closely. If Perl is available in the store, then the
  4889. @code{corelist} utility will be used to filter core modules out of the
  4890. list of dependencies.
  4891. The command command below imports metadata for the @code{Acme::Boolean}
  4892. Perl module:
  4893. @example
  4894. guix import cpan Acme::Boolean
  4895. @end example
  4896. @item cran
  4897. @cindex CRAN
  4898. @cindex Bioconductor
  4899. Import metadata from @uref{https://cran.r-project.org/, CRAN}, the
  4900. central repository for the @uref{http://r-project.org, GNU@tie{}R
  4901. statistical and graphical environment}.
  4902. Information is extracted from the @code{DESCRIPTION} file of the package.
  4903. The command command below imports metadata for the @code{Cairo}
  4904. R package:
  4905. @example
  4906. guix import cran Cairo
  4907. @end example
  4908. When @code{--recursive} is added, the importer will traverse the
  4909. dependency graph of the given upstream package recursively and generate
  4910. package expressions for all those packages that are not yet in Guix.
  4911. When @code{--archive=bioconductor} is added, metadata is imported from
  4912. @uref{https://www.bioconductor.org/, Bioconductor}, a repository of R
  4913. packages for for the analysis and comprehension of high-throughput
  4914. genomic data in bioinformatics.
  4915. Information is extracted from the @code{DESCRIPTION} file of a package
  4916. published on the web interface of the Bioconductor SVN repository.
  4917. The command below imports metadata for the @code{GenomicRanges}
  4918. R package:
  4919. @example
  4920. guix import cran --archive=bioconductor GenomicRanges
  4921. @end example
  4922. @item texlive
  4923. @cindex TeX Live
  4924. @cindex CTAN
  4925. Import metadata from @uref{http://www.ctan.org/, CTAN}, the
  4926. comprehensive TeX archive network for TeX packages that are part of the
  4927. @uref{https://www.tug.org/texlive/, TeX Live distribution}.
  4928. Information about the package is obtained through the XML API provided
  4929. by CTAN, while the source code is downloaded from the SVN repository of
  4930. the Tex Live project. This is done because the CTAN does not keep
  4931. versioned archives.
  4932. The command command below imports metadata for the @code{fontspec}
  4933. TeX package:
  4934. @example
  4935. guix import texlive fontspec
  4936. @end example
  4937. When @code{--archive=DIRECTORY} is added, the source code is downloaded
  4938. not from the @file{latex} sub-directory of the @file{texmf-dist/source}
  4939. tree in the TeX Live SVN repository, but from the specified sibling
  4940. directory under the same root.
  4941. The command below imports metadata for the @code{ifxetex} package from
  4942. CTAN while fetching the sources from the directory
  4943. @file{texmf/source/generic}:
  4944. @example
  4945. guix import texlive --archive=generic ifxetex
  4946. @end example
  4947. @item json
  4948. @cindex JSON, import
  4949. Import package metadata from a local JSON file@footnote{This
  4950. functionality requires Guile-JSON to be installed.
  4951. @xref{Requirements}.}. Consider the following example package
  4952. definition in JSON format:
  4953. @example
  4954. @{
  4955. "name": "hello",
  4956. "version": "2.10",
  4957. "source": "mirror://gnu/hello/hello-2.10.tar.gz",
  4958. "build-system": "gnu",
  4959. "home-page": "https://www.gnu.org/software/hello/",
  4960. "synopsis": "Hello, GNU world: An example GNU package",
  4961. "description": "GNU Hello prints a greeting.",
  4962. "license": "GPL-3.0+",
  4963. "native-inputs": ["gcc@@6"]
  4964. @}
  4965. @end example
  4966. The field names are the same as for the @code{<package>} record
  4967. (@xref{Defining Packages}). References to other packages are provided
  4968. as JSON lists of quoted package specification strings such as
  4969. @code{guile} or @code{guile@@2.0}.
  4970. The importer also supports a more explicit source definition using the
  4971. common fields for @code{<origin>} records:
  4972. @example
  4973. @{
  4974. @dots{}
  4975. "source": @{
  4976. "method": "url-fetch",
  4977. "uri": "mirror://gnu/hello/hello-2.10.tar.gz",
  4978. "sha256": @{
  4979. "base32": "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"
  4980. @}
  4981. @}
  4982. @dots{}
  4983. @}
  4984. @end example
  4985. The command below reads metadata from the JSON file @code{hello.json}
  4986. and outputs a package expression:
  4987. @example
  4988. guix import json hello.json
  4989. @end example
  4990. @item nix
  4991. Import metadata from a local copy of the source of the
  4992. @uref{http://nixos.org/nixpkgs/, Nixpkgs distribution}@footnote{This
  4993. relies on the @command{nix-instantiate} command of
  4994. @uref{http://nixos.org/nix/, Nix}.}. Package definitions in Nixpkgs are
  4995. typically written in a mixture of Nix-language and Bash code. This
  4996. command only imports the high-level package structure that is written in
  4997. the Nix language. It normally includes all the basic fields of a
  4998. package definition.
  4999. When importing a GNU package, the synopsis and descriptions are replaced
  5000. by their canonical upstream variant.
  5001. Usually, you will first need to do:
  5002. @example
  5003. export NIX_REMOTE=daemon
  5004. @end example
  5005. @noindent
  5006. so that @command{nix-instantiate} does not try to open the Nix database.
  5007. As an example, the command below imports the package definition of
  5008. LibreOffice (more precisely, it imports the definition of the package
  5009. bound to the @code{libreoffice} top-level attribute):
  5010. @example
  5011. guix import nix ~/path/to/nixpkgs libreoffice
  5012. @end example
  5013. @item hackage
  5014. @cindex hackage
  5015. Import metadata from the Haskell community's central package archive
  5016. @uref{https://hackage.haskell.org/, Hackage}. Information is taken from
  5017. Cabal files and includes all the relevant information, including package
  5018. dependencies.
  5019. Specific command-line options are:
  5020. @table @code
  5021. @item --stdin
  5022. @itemx -s
  5023. Read a Cabal file from standard input.
  5024. @item --no-test-dependencies
  5025. @itemx -t
  5026. Do not include dependencies required only by the test suites.
  5027. @item --cabal-environment=@var{alist}
  5028. @itemx -e @var{alist}
  5029. @var{alist} is a Scheme alist defining the environment in which the
  5030. Cabal conditionals are evaluated. The accepted keys are: @code{os},
  5031. @code{arch}, @code{impl} and a string representing the name of a flag.
  5032. The value associated with a flag has to be either the symbol
  5033. @code{true} or @code{false}. The value associated with other keys
  5034. has to conform to the Cabal file format definition. The default value
  5035. associated with the keys @code{os}, @code{arch} and @code{impl} is
  5036. @samp{linux}, @samp{x86_64} and @samp{ghc}, respectively.
  5037. @end table
  5038. The command below imports metadata for the latest version of the
  5039. @code{HTTP} Haskell package without including test dependencies and
  5040. specifying the value of the flag @samp{network-uri} as @code{false}:
  5041. @example
  5042. guix import hackage -t -e "'((\"network-uri\" . false))" HTTP
  5043. @end example
  5044. A specific package version may optionally be specified by following the
  5045. package name by an at-sign and a version number as in the following example:
  5046. @example
  5047. guix import hackage mtl@@2.1.3.1
  5048. @end example
  5049. @item stackage
  5050. @cindex stackage
  5051. The @code{stackage} importer is a wrapper around the @code{hackage} one.
  5052. It takes a package name, looks up the package version included in a
  5053. long-term support (LTS) @uref{https://www.stackage.org, Stackage}
  5054. release and uses the @code{hackage} importer to retrieve its metadata.
  5055. Note that it is up to you to select an LTS release compatible with the
  5056. GHC compiler used by Guix.
  5057. Specific command-line options are:
  5058. @table @code
  5059. @item --no-test-dependencies
  5060. @itemx -t
  5061. Do not include dependencies required only by the test suites.
  5062. @item --lts-version=@var{version}
  5063. @itemx -r @var{version}
  5064. @var{version} is the desired LTS release version. If omitted the latest
  5065. release is used.
  5066. @end table
  5067. The command below imports metadata for the @code{HTTP} Haskell package
  5068. included in the LTS Stackage release version 7.18:
  5069. @example
  5070. guix import stackage --lts-version=7.18 HTTP
  5071. @end example
  5072. @item elpa
  5073. @cindex elpa
  5074. Import metadata from an Emacs Lisp Package Archive (ELPA) package
  5075. repository (@pxref{Packages,,, emacs, The GNU Emacs Manual}).
  5076. Specific command-line options are:
  5077. @table @code
  5078. @item --archive=@var{repo}
  5079. @itemx -a @var{repo}
  5080. @var{repo} identifies the archive repository from which to retrieve the
  5081. information. Currently the supported repositories and their identifiers
  5082. are:
  5083. @itemize -
  5084. @item
  5085. @uref{http://elpa.gnu.org/packages, GNU}, selected by the @code{gnu}
  5086. identifier. This is the default.
  5087. Packages from @code{elpa.gnu.org} are signed with one of the keys
  5088. contained in the GnuPG keyring at
  5089. @file{share/emacs/25.1/etc/package-keyring.gpg} (or similar) in the
  5090. @code{emacs} package (@pxref{Package Installation, ELPA package
  5091. signatures,, emacs, The GNU Emacs Manual}).
  5092. @item
  5093. @uref{http://stable.melpa.org/packages, MELPA-Stable}, selected by the
  5094. @code{melpa-stable} identifier.
  5095. @item
  5096. @uref{http://melpa.org/packages, MELPA}, selected by the @code{melpa}
  5097. identifier.
  5098. @end itemize
  5099. @end table
  5100. @item crate
  5101. @cindex crate
  5102. Import metadata from the crates.io Rust package repository
  5103. @uref{https://crates.io, crates.io}.
  5104. @end table
  5105. The structure of the @command{guix import} code is modular. It would be
  5106. useful to have more importers for other package formats, and your help
  5107. is welcome here (@pxref{Contributing}).
  5108. @node Invoking guix refresh
  5109. @section Invoking @command{guix refresh}
  5110. @cindex @command {guix refresh}
  5111. The primary audience of the @command{guix refresh} command is developers
  5112. of the GNU software distribution. By default, it reports any packages
  5113. provided by the distribution that are outdated compared to the latest
  5114. upstream version, like this:
  5115. @example
  5116. $ guix refresh
  5117. gnu/packages/gettext.scm:29:13: gettext would be upgraded from 0.18.1.1 to 0.18.2.1
  5118. gnu/packages/glib.scm:77:12: glib would be upgraded from 2.34.3 to 2.37.0
  5119. @end example
  5120. Alternately, one can specify packages to consider, in which case a
  5121. warning is emitted for packages that lack an updater:
  5122. @example
  5123. $ guix refresh coreutils guile guile-ssh
  5124. gnu/packages/ssh.scm:205:2: warning: no updater for guile-ssh
  5125. gnu/packages/guile.scm:136:12: guile would be upgraded from 2.0.12 to 2.0.13
  5126. @end example
  5127. @command{guix refresh} browses the upstream repository of each package and determines
  5128. the highest version number of the releases therein. The command
  5129. knows how to update specific types of packages: GNU packages, ELPA
  5130. packages, etc.---see the documentation for @option{--type} below. There
  5131. are many packages, though, for which it lacks a method to determine
  5132. whether a new upstream release is available. However, the mechanism is
  5133. extensible, so feel free to get in touch with us to add a new method!
  5134. When passed @code{--update}, it modifies distribution source files to
  5135. update the version numbers and source tarball hashes of those package
  5136. recipes (@pxref{Defining Packages}). This is achieved by downloading
  5137. each package's latest source tarball and its associated OpenPGP
  5138. signature, authenticating the downloaded tarball against its signature
  5139. using @command{gpg}, and finally computing its hash. When the public
  5140. key used to sign the tarball is missing from the user's keyring, an
  5141. attempt is made to automatically retrieve it from a public key server;
  5142. when this is successful, the key is added to the user's keyring; otherwise,
  5143. @command{guix refresh} reports an error.
  5144. The following options are supported:
  5145. @table @code
  5146. @item --expression=@var{expr}
  5147. @itemx -e @var{expr}
  5148. Consider the package @var{expr} evaluates to.
  5149. This is useful to precisely refer to a package, as in this example:
  5150. @example
  5151. guix refresh -l -e '(@@@@ (gnu packages commencement) glibc-final)'
  5152. @end example
  5153. This command lists the dependents of the ``final'' libc (essentially all
  5154. the packages.)
  5155. @item --update
  5156. @itemx -u
  5157. Update distribution source files (package recipes) in place. This is
  5158. usually run from a checkout of the Guix source tree (@pxref{Running
  5159. Guix Before It Is Installed}):
  5160. @example
  5161. $ ./pre-inst-env guix refresh -s non-core -u
  5162. @end example
  5163. @xref{Defining Packages}, for more information on package definitions.
  5164. @item --select=[@var{subset}]
  5165. @itemx -s @var{subset}
  5166. Select all the packages in @var{subset}, one of @code{core} or
  5167. @code{non-core}.
  5168. The @code{core} subset refers to all the packages at the core of the
  5169. distribution---i.e., packages that are used to build ``everything
  5170. else''. This includes GCC, libc, Binutils, Bash, etc. Usually,
  5171. changing one of these packages in the distribution entails a rebuild of
  5172. all the others. Thus, such updates are an inconvenience to users in
  5173. terms of build time or bandwidth used to achieve the upgrade.
  5174. The @code{non-core} subset refers to the remaining packages. It is
  5175. typically useful in cases where an update of the core packages would be
  5176. inconvenient.
  5177. @item --manifest=@var{file}
  5178. @itemx -m @var{file}
  5179. Select all the packages from the manifest in @var{file}. This is useful to
  5180. check if any packages of the user manifest can be updated.
  5181. @item --type=@var{updater}
  5182. @itemx -t @var{updater}
  5183. Select only packages handled by @var{updater} (may be a comma-separated
  5184. list of updaters). Currently, @var{updater} may be one of:
  5185. @table @code
  5186. @item gnu
  5187. the updater for GNU packages;
  5188. @item gnome
  5189. the updater for GNOME packages;
  5190. @item kde
  5191. the updater for KDE packages;
  5192. @item xorg
  5193. the updater for X.org packages;
  5194. @item kernel.org
  5195. the updater for packages hosted on kernel.org;
  5196. @item elpa
  5197. the updater for @uref{http://elpa.gnu.org/, ELPA} packages;
  5198. @item cran
  5199. the updater for @uref{https://cran.r-project.org/, CRAN} packages;
  5200. @item bioconductor
  5201. the updater for @uref{https://www.bioconductor.org/, Bioconductor} R packages;
  5202. @item cpan
  5203. the updater for @uref{http://www.cpan.org/, CPAN} packages;
  5204. @item pypi
  5205. the updater for @uref{https://pypi.python.org, PyPI} packages.
  5206. @item gem
  5207. the updater for @uref{https://rubygems.org, RubyGems} packages.
  5208. @item github
  5209. the updater for @uref{https://github.com, GitHub} packages.
  5210. @item hackage
  5211. the updater for @uref{https://hackage.haskell.org, Hackage} packages.
  5212. @item stackage
  5213. the updater for @uref{https://www.stackage.org, Stackage} packages.
  5214. @item crate
  5215. the updater for @uref{https://crates.io, Crates} packages.
  5216. @end table
  5217. For instance, the following command only checks for updates of Emacs
  5218. packages hosted at @code{elpa.gnu.org} and for updates of CRAN packages:
  5219. @example
  5220. $ guix refresh --type=elpa,cran
  5221. gnu/packages/statistics.scm:819:13: r-testthat would be upgraded from 0.10.0 to 0.11.0
  5222. gnu/packages/emacs.scm:856:13: emacs-auctex would be upgraded from 11.88.6 to 11.88.9
  5223. @end example
  5224. @end table
  5225. In addition, @command{guix refresh} can be passed one or more package
  5226. names, as in this example:
  5227. @example
  5228. $ ./pre-inst-env guix refresh -u emacs idutils gcc@@4.8
  5229. @end example
  5230. @noindent
  5231. The command above specifically updates the @code{emacs} and
  5232. @code{idutils} packages. The @code{--select} option would have no
  5233. effect in this case.
  5234. When considering whether to upgrade a package, it is sometimes
  5235. convenient to know which packages would be affected by the upgrade and
  5236. should be checked for compatibility. For this the following option may
  5237. be used when passing @command{guix refresh} one or more package names:
  5238. @table @code
  5239. @item --list-updaters
  5240. @itemx -L
  5241. List available updaters and exit (see @option{--type} above.)
  5242. For each updater, display the fraction of packages it covers; at the
  5243. end, display the fraction of packages covered by all these updaters.
  5244. @item --list-dependent
  5245. @itemx -l
  5246. List top-level dependent packages that would need to be rebuilt as a
  5247. result of upgrading one or more packages.
  5248. @xref{Invoking guix graph, the @code{reverse-package} type of
  5249. @command{guix graph}}, for information on how to visualize the list of
  5250. dependents of a package.
  5251. @end table
  5252. Be aware that the @code{--list-dependent} option only
  5253. @emph{approximates} the rebuilds that would be required as a result of
  5254. an upgrade. More rebuilds might be required under some circumstances.
  5255. @example
  5256. $ guix refresh --list-dependent flex
  5257. Building the following 120 packages would ensure 213 dependent packages are rebuilt:
  5258. hop@@2.4.0 geiser@@0.4 notmuch@@0.18 mu@@0.9.9.5 cflow@@1.4 idutils@@4.6 @dots{}
  5259. @end example
  5260. The command above lists a set of packages that could be built to check
  5261. for compatibility with an upgraded @code{flex} package.
  5262. The following options can be used to customize GnuPG operation:
  5263. @table @code
  5264. @item --gpg=@var{command}
  5265. Use @var{command} as the GnuPG 2.x command. @var{command} is searched
  5266. for in @code{$PATH}.
  5267. @item --key-download=@var{policy}
  5268. Handle missing OpenPGP keys according to @var{policy}, which may be one
  5269. of:
  5270. @table @code
  5271. @item always
  5272. Always download missing OpenPGP keys from the key server, and add them
  5273. to the user's GnuPG keyring.
  5274. @item never
  5275. Never try to download missing OpenPGP keys. Instead just bail out.
  5276. @item interactive
  5277. When a package signed with an unknown OpenPGP key is encountered, ask
  5278. the user whether to download it or not. This is the default behavior.
  5279. @end table
  5280. @item --key-server=@var{host}
  5281. Use @var{host} as the OpenPGP key server when importing a public key.
  5282. @end table
  5283. The @code{github} updater uses the
  5284. @uref{https://developer.github.com/v3/, GitHub API} to query for new
  5285. releases. When used repeatedly e.g. when refreshing all packages,
  5286. GitHub will eventually refuse to answer any further API requests. By
  5287. default 60 API requests per hour are allowed, and a full refresh on all
  5288. GitHub packages in Guix requires more than this. Authentication with
  5289. GitHub through the use of an API token alleviates these limits. To use
  5290. an API token, set the environment variable @code{GUIX_GITHUB_TOKEN} to a
  5291. token procured from @uref{https://github.com/settings/tokens} or
  5292. otherwise.
  5293. @node Invoking guix lint
  5294. @section Invoking @command{guix lint}
  5295. @cindex @command{guix lint}
  5296. @cindex package, checking for errors
  5297. The @command{guix lint} command is meant to help package developers avoid
  5298. common errors and use a consistent style. It runs a number of checks on
  5299. a given set of packages in order to find common mistakes in their
  5300. definitions. Available @dfn{checkers} include (see
  5301. @code{--list-checkers} for a complete list):
  5302. @table @code
  5303. @item synopsis
  5304. @itemx description
  5305. Validate certain typographical and stylistic rules about package
  5306. descriptions and synopses.
  5307. @item inputs-should-be-native
  5308. Identify inputs that should most likely be native inputs.
  5309. @item source
  5310. @itemx home-page
  5311. @itemx mirror-url
  5312. @itemx source-file-name
  5313. Probe @code{home-page} and @code{source} URLs and report those that are
  5314. invalid. Suggest a @code{mirror://} URL when applicable. Check that
  5315. the source file name is meaningful, e.g. is not
  5316. just a version number or ``git-checkout'', without a declared
  5317. @code{file-name} (@pxref{origin Reference}).
  5318. @item cve
  5319. @cindex security vulnerabilities
  5320. @cindex CVE, Common Vulnerabilities and Exposures
  5321. Report known vulnerabilities found in the Common Vulnerabilities and
  5322. Exposures (CVE) databases of the current and past year
  5323. @uref{https://nvd.nist.gov/download.cfm#CVE_FEED, published by the US
  5324. NIST}.
  5325. To view information about a particular vulnerability, visit pages such as:
  5326. @itemize
  5327. @item
  5328. @indicateurl{https://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-YYYY-ABCD}
  5329. @item
  5330. @indicateurl{https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-YYYY-ABCD}
  5331. @end itemize
  5332. @noindent
  5333. where @code{CVE-YYYY-ABCD} is the CVE identifier---e.g.,
  5334. @code{CVE-2015-7554}.
  5335. Package developers can specify in package recipes the
  5336. @uref{https://nvd.nist.gov/cpe.cfm,Common Platform Enumeration (CPE)}
  5337. name and version of the package when they differ from the name that Guix
  5338. uses, as in this example:
  5339. @example
  5340. (package
  5341. (name "grub")
  5342. ;; @dots{}
  5343. ;; CPE calls this package "grub2".
  5344. (properties '((cpe-name . "grub2"))))
  5345. @end example
  5346. @item formatting
  5347. Warn about obvious source code formatting issues: trailing white space,
  5348. use of tabulations, etc.
  5349. @end table
  5350. The general syntax is:
  5351. @example
  5352. guix lint @var{options} @var{package}@dots{}
  5353. @end example
  5354. If no package is given on the command line, then all packages are checked.
  5355. The @var{options} may be zero or more of the following:
  5356. @table @code
  5357. @item --list-checkers
  5358. @itemx -l
  5359. List and describe all the available checkers that will be run on packages
  5360. and exit.
  5361. @item --checkers
  5362. @itemx -c
  5363. Only enable the checkers specified in a comma-separated list using the
  5364. names returned by @code{--list-checkers}.
  5365. @end table
  5366. @node Invoking guix size
  5367. @section Invoking @command{guix size}
  5368. @cindex size
  5369. @cindex package size
  5370. @cindex closure
  5371. @cindex @command{guix size}
  5372. The @command{guix size} command helps package developers profile the
  5373. disk usage of packages. It is easy to overlook the impact of an
  5374. additional dependency added to a package, or the impact of using a
  5375. single output for a package that could easily be split (@pxref{Packages
  5376. with Multiple Outputs}). Such are the typical issues that
  5377. @command{guix size} can highlight.
  5378. The command can be passed a package specification such as @code{gcc@@4.8}
  5379. or @code{guile:debug}, or a file name in the store. Consider this
  5380. example:
  5381. @example
  5382. $ guix size coreutils
  5383. store item total self
  5384. /gnu/store/@dots{}-coreutils-8.23 70.0 13.9 19.8%
  5385. /gnu/store/@dots{}-gmp-6.0.0a 55.3 2.5 3.6%
  5386. /gnu/store/@dots{}-acl-2.2.52 53.7 0.5 0.7%
  5387. /gnu/store/@dots{}-attr-2.4.46 53.2 0.3 0.5%
  5388. /gnu/store/@dots{}-gcc-4.8.4-lib 52.9 15.7 22.4%
  5389. /gnu/store/@dots{}-glibc-2.21 37.2 37.2 53.1%
  5390. @end example
  5391. @cindex closure
  5392. The store items listed here constitute the @dfn{transitive closure} of
  5393. Coreutils---i.e., Coreutils and all its dependencies, recursively---as
  5394. would be returned by:
  5395. @example
  5396. $ guix gc -R /gnu/store/@dots{}-coreutils-8.23
  5397. @end example
  5398. Here the output shows three columns next to store items. The first column,
  5399. labeled ``total'', shows the size in mebibytes (MiB) of the closure of
  5400. the store item---that is, its own size plus the size of all its
  5401. dependencies. The next column, labeled ``self'', shows the size of the
  5402. item itself. The last column shows the ratio of the size of the item
  5403. itself to the space occupied by all the items listed here.
  5404. In this example, we see that the closure of Coreutils weighs in at
  5405. 70@tie{}MiB, half of which is taken by libc. (That libc represents a
  5406. large fraction of the closure is not a problem @i{per se} because it is
  5407. always available on the system anyway.)
  5408. When the package passed to @command{guix size} is available in the
  5409. store, @command{guix size} queries the daemon to determine its
  5410. dependencies, and measures its size in the store, similar to @command{du
  5411. -ms --apparent-size} (@pxref{du invocation,,, coreutils, GNU
  5412. Coreutils}).
  5413. When the given package is @emph{not} in the store, @command{guix size}
  5414. reports information based on the available substitutes
  5415. (@pxref{Substitutes}). This makes it possible it to profile disk usage of
  5416. store items that are not even on disk, only available remotely.
  5417. You can also specify several package names:
  5418. @example
  5419. $ guix size coreutils grep sed bash
  5420. store item total self
  5421. /gnu/store/@dots{}-coreutils-8.24 77.8 13.8 13.4%
  5422. /gnu/store/@dots{}-grep-2.22 73.1 0.8 0.8%
  5423. /gnu/store/@dots{}-bash-4.3.42 72.3 4.7 4.6%
  5424. /gnu/store/@dots{}-readline-6.3 67.6 1.2 1.2%
  5425. @dots{}
  5426. total: 102.3 MiB
  5427. @end example
  5428. @noindent
  5429. In this example we see that the combination of the four packages takes
  5430. 102.3@tie{}MiB in total, which is much less than the sum of each closure
  5431. since they have a lot of dependencies in common.
  5432. The available options are:
  5433. @table @option
  5434. @item --substitute-urls=@var{urls}
  5435. Use substitute information from @var{urls}.
  5436. @xref{client-substitute-urls, the same option for @code{guix build}}.
  5437. @item --sort=@var{key}
  5438. Sort lines according to @var{key}, one of the following options:
  5439. @table @code
  5440. @item self
  5441. the size of each item (the default);
  5442. @item closure
  5443. the total size of the item's closure.
  5444. @end table
  5445. @item --map-file=@var{file}
  5446. Write a graphical map of disk usage in PNG format to @var{file}.
  5447. For the example above, the map looks like this:
  5448. @image{images/coreutils-size-map,5in,, map of Coreutils disk usage
  5449. produced by @command{guix size}}
  5450. This option requires that
  5451. @uref{http://wingolog.org/software/guile-charting/, Guile-Charting} be
  5452. installed and visible in Guile's module search path. When that is not
  5453. the case, @command{guix size} fails as it tries to load it.
  5454. @item --system=@var{system}
  5455. @itemx -s @var{system}
  5456. Consider packages for @var{system}---e.g., @code{x86_64-linux}.
  5457. @end table
  5458. @node Invoking guix graph
  5459. @section Invoking @command{guix graph}
  5460. @cindex DAG
  5461. @cindex @command{guix graph}
  5462. @cindex package dependencies
  5463. Packages and their dependencies form a @dfn{graph}, specifically a
  5464. directed acyclic graph (DAG). It can quickly become difficult to have a
  5465. mental model of the package DAG, so the @command{guix graph} command
  5466. provides a visual representation of the DAG. By default,
  5467. @command{guix graph} emits a DAG representation in the input format of
  5468. @uref{http://www.graphviz.org/, Graphviz}, so its output can be passed
  5469. directly to the @command{dot} command of Graphviz. It can also emit an
  5470. HTML page with embedded JavaScript code to display a ``chord diagram''
  5471. in a Web browser, using the @uref{https://d3js.org/, d3.js} library, or
  5472. emit Cypher queries to construct a graph in a graph database supporting
  5473. the @uref{http://www.opencypher.org/, openCypher} query language.
  5474. The general syntax is:
  5475. @example
  5476. guix graph @var{options} @var{package}@dots{}
  5477. @end example
  5478. For example, the following command generates a PDF file representing the
  5479. package DAG for the GNU@tie{}Core Utilities, showing its build-time
  5480. dependencies:
  5481. @example
  5482. guix graph coreutils | dot -Tpdf > dag.pdf
  5483. @end example
  5484. The output looks like this:
  5485. @image{images/coreutils-graph,2in,,Dependency graph of the GNU Coreutils}
  5486. Nice little graph, no?
  5487. But there is more than one graph! The one above is concise: it is the
  5488. graph of package objects, omitting implicit inputs such as GCC, libc,
  5489. grep, etc. It is often useful to have such a concise graph, but
  5490. sometimes one may want to see more details. @command{guix graph} supports
  5491. several types of graphs, allowing you to choose the level of detail:
  5492. @table @code
  5493. @item package
  5494. This is the default type used in the example above. It shows the DAG of
  5495. package objects, excluding implicit dependencies. It is concise, but
  5496. filters out many details.
  5497. @item reverse-package
  5498. This shows the @emph{reverse} DAG of packages. For example:
  5499. @example
  5500. guix graph --type=reverse-package ocaml
  5501. @end example
  5502. ... yields the graph of packages that depend on OCaml.
  5503. Note that for core packages this can yield huge graphs. If all you want
  5504. is to know the number of packages that depend on a given package, use
  5505. @command{guix refresh --list-dependent} (@pxref{Invoking guix refresh,
  5506. @option{--list-dependent}}).
  5507. @item bag-emerged
  5508. This is the package DAG, @emph{including} implicit inputs.
  5509. For instance, the following command:
  5510. @example
  5511. guix graph --type=bag-emerged coreutils | dot -Tpdf > dag.pdf
  5512. @end example
  5513. ... yields this bigger graph:
  5514. @image{images/coreutils-bag-graph,,5in,Detailed dependency graph of the GNU Coreutils}
  5515. At the bottom of the graph, we see all the implicit inputs of
  5516. @var{gnu-build-system} (@pxref{Build Systems, @code{gnu-build-system}}).
  5517. Now, note that the dependencies of these implicit inputs---that is, the
  5518. @dfn{bootstrap dependencies} (@pxref{Bootstrapping})---are not shown
  5519. here, for conciseness.
  5520. @item bag
  5521. Similar to @code{bag-emerged}, but this time including all the bootstrap
  5522. dependencies.
  5523. @item bag-with-origins
  5524. Similar to @code{bag}, but also showing origins and their dependencies.
  5525. @item derivation
  5526. This is the most detailed representation: It shows the DAG of
  5527. derivations (@pxref{Derivations}) and plain store items. Compared to
  5528. the above representation, many additional nodes are visible, including
  5529. build scripts, patches, Guile modules, etc.
  5530. For this type of graph, it is also possible to pass a @file{.drv} file
  5531. name instead of a package name, as in:
  5532. @example
  5533. guix graph -t derivation `guix system build -d my-config.scm`
  5534. @end example
  5535. @end table
  5536. All the types above correspond to @emph{build-time dependencies}. The
  5537. following graph type represents the @emph{run-time dependencies}:
  5538. @table @code
  5539. @item references
  5540. This is the graph of @dfn{references} of a package output, as returned
  5541. by @command{guix gc --references} (@pxref{Invoking guix gc}).
  5542. If the given package output is not available in the store, @command{guix
  5543. graph} attempts to obtain dependency information from substitutes.
  5544. Here you can also pass a store file name instead of a package name. For
  5545. example, the command below produces the reference graph of your profile
  5546. (which can be big!):
  5547. @example
  5548. guix graph -t references `readlink -f ~/.guix-profile`
  5549. @end example
  5550. @item referrers
  5551. This is the graph of the @dfn{referrers} of a store item, as returned by
  5552. @command{guix gc --referrers} (@pxref{Invoking guix gc}).
  5553. This relies exclusively on local information from your store. For
  5554. instance, let us suppose that the current Inkscape is available in 10
  5555. profiles on your machine; @command{guix graph -t referrers inkscape}
  5556. will show a graph rooted at Inkscape and with those 10 profiles linked
  5557. to it.
  5558. It can help determine what is preventing a store item from being garbage
  5559. collected.
  5560. @end table
  5561. The available options are the following:
  5562. @table @option
  5563. @item --type=@var{type}
  5564. @itemx -t @var{type}
  5565. Produce a graph output of @var{type}, where @var{type} must be one of
  5566. the values listed above.
  5567. @item --list-types
  5568. List the supported graph types.
  5569. @item --backend=@var{backend}
  5570. @itemx -b @var{backend}
  5571. Produce a graph using the selected @var{backend}.
  5572. @item --list-backends
  5573. List the supported graph backends.
  5574. Currently, the available backends are Graphviz and d3.js.
  5575. @item --expression=@var{expr}
  5576. @itemx -e @var{expr}
  5577. Consider the package @var{expr} evaluates to.
  5578. This is useful to precisely refer to a package, as in this example:
  5579. @example
  5580. guix graph -e '(@@@@ (gnu packages commencement) gnu-make-final)'
  5581. @end example
  5582. @end table
  5583. @node Invoking guix environment
  5584. @section Invoking @command{guix environment}
  5585. @cindex reproducible build environments
  5586. @cindex development environments
  5587. @cindex @command{guix environment}
  5588. @cindex environment, package build environment
  5589. The purpose of @command{guix environment} is to assist hackers in
  5590. creating reproducible development environments without polluting their
  5591. package profile. The @command{guix environment} tool takes one or more
  5592. packages, builds all of their inputs, and creates a shell
  5593. environment to use them.
  5594. The general syntax is:
  5595. @example
  5596. guix environment @var{options} @var{package}@dots{}
  5597. @end example
  5598. The following example spawns a new shell set up for the development of
  5599. GNU@tie{}Guile:
  5600. @example
  5601. guix environment guile
  5602. @end example
  5603. If the needed dependencies are not built yet, @command{guix environment}
  5604. automatically builds them. The environment of the new shell is an augmented
  5605. version of the environment that @command{guix environment} was run in.
  5606. It contains the necessary search paths for building the given package
  5607. added to the existing environment variables. To create a ``pure''
  5608. environment, in which the original environment variables have been unset,
  5609. use the @code{--pure} option@footnote{Users sometimes wrongfully augment
  5610. environment variables such as @code{PATH} in their @file{~/.bashrc}
  5611. file. As a consequence, when @code{guix environment} launches it, Bash
  5612. may read @file{~/.bashrc}, thereby introducing ``impurities'' in these
  5613. environment variables. It is an error to define such environment
  5614. variables in @file{.bashrc}; instead, they should be defined in
  5615. @file{.bash_profile}, which is sourced only by log-in shells.
  5616. @xref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}, for
  5617. details on Bash start-up files.}.
  5618. @vindex GUIX_ENVIRONMENT
  5619. @command{guix environment} defines the @code{GUIX_ENVIRONMENT}
  5620. variable in the shell it spawns; its value is the file name of the
  5621. profile of this environment. This allows users to, say, define a
  5622. specific prompt for development environments in their @file{.bashrc}
  5623. (@pxref{Bash Startup Files,,, bash, The GNU Bash Reference Manual}):
  5624. @example
  5625. if [ -n "$GUIX_ENVIRONMENT" ]
  5626. then
  5627. export PS1="\u@@\h \w [dev]\$ "
  5628. fi
  5629. @end example
  5630. @noindent
  5631. ... or to browse the profile:
  5632. @example
  5633. $ ls "$GUIX_ENVIRONMENT/bin"
  5634. @end example
  5635. Additionally, more than one package may be specified, in which case the
  5636. union of the inputs for the given packages are used. For example, the
  5637. command below spawns a shell where all of the dependencies of both Guile
  5638. and Emacs are available:
  5639. @example
  5640. guix environment guile emacs
  5641. @end example
  5642. Sometimes an interactive shell session is not desired. An arbitrary
  5643. command may be invoked by placing the @code{--} token to separate the
  5644. command from the rest of the arguments:
  5645. @example
  5646. guix environment guile -- make -j4
  5647. @end example
  5648. In other situations, it is more convenient to specify the list of
  5649. packages needed in the environment. For example, the following command
  5650. runs @command{python} from an environment containing Python@tie{}2.7 and
  5651. NumPy:
  5652. @example
  5653. guix environment --ad-hoc python2-numpy python-2.7 -- python
  5654. @end example
  5655. Furthermore, one might want the dependencies of a package and also some
  5656. additional packages that are not build-time or runtime dependencies, but
  5657. are useful when developing nonetheless. Because of this, the
  5658. @code{--ad-hoc} flag is positional. Packages appearing before
  5659. @code{--ad-hoc} are interpreted as packages whose dependencies will be
  5660. added to the environment. Packages appearing after are interpreted as
  5661. packages that will be added to the environment directly. For example,
  5662. the following command creates a Guix development environment that
  5663. additionally includes Git and strace:
  5664. @example
  5665. guix environment guix --ad-hoc git strace
  5666. @end example
  5667. Sometimes it is desirable to isolate the environment as much as
  5668. possible, for maximal purity and reproducibility. In particular, when
  5669. using Guix on a host distro that is not GuixSD, it is desirable to
  5670. prevent access to @file{/usr/bin} and other system-wide resources from
  5671. the development environment. For example, the following command spawns
  5672. a Guile REPL in a ``container'' where only the store and the current
  5673. working directory are mounted:
  5674. @example
  5675. guix environment --ad-hoc --container guile -- guile
  5676. @end example
  5677. @quotation Note
  5678. The @code{--container} option requires Linux-libre 3.19 or newer.
  5679. @end quotation
  5680. The available options are summarized below.
  5681. @table @code
  5682. @item --root=@var{file}
  5683. @itemx -r @var{file}
  5684. @cindex persistent environment
  5685. @cindex garbage collector root, for environments
  5686. Make @var{file} a symlink to the profile for this environment, and
  5687. register it as a garbage collector root.
  5688. This is useful if you want to protect your environment from garbage
  5689. collection, to make it ``persistent''.
  5690. When this option is omitted, the environment is protected from garbage
  5691. collection only for the duration of the @command{guix environment}
  5692. session. This means that next time you recreate the same environment,
  5693. you could have to rebuild or re-download packages. @xref{Invoking guix
  5694. gc}, for more on GC roots.
  5695. @item --expression=@var{expr}
  5696. @itemx -e @var{expr}
  5697. Create an environment for the package or list of packages that
  5698. @var{expr} evaluates to.
  5699. For example, running:
  5700. @example
  5701. guix environment -e '(@@ (gnu packages maths) petsc-openmpi)'
  5702. @end example
  5703. starts a shell with the environment for this specific variant of the
  5704. PETSc package.
  5705. Running:
  5706. @example
  5707. guix environment --ad-hoc -e '(@@ (gnu) %base-packages)'
  5708. @end example
  5709. starts a shell with all the GuixSD base packages available.
  5710. The above commands only use the default output of the given packages.
  5711. To select other outputs, two element tuples can be specified:
  5712. @example
  5713. guix environment --ad-hoc -e '(list (@@ (gnu packages bash) bash) "include")'
  5714. @end example
  5715. @item --load=@var{file}
  5716. @itemx -l @var{file}
  5717. Create an environment for the package or list of packages that the code
  5718. within @var{file} evaluates to.
  5719. As an example, @var{file} might contain a definition like this
  5720. (@pxref{Defining Packages}):
  5721. @example
  5722. @verbatiminclude environment-gdb.scm
  5723. @end example
  5724. @item --ad-hoc
  5725. Include all specified packages in the resulting environment, as if an
  5726. @i{ad hoc} package were defined with them as inputs. This option is
  5727. useful for quickly creating an environment without having to write a
  5728. package expression to contain the desired inputs.
  5729. For instance, the command:
  5730. @example
  5731. guix environment --ad-hoc guile guile-sdl -- guile
  5732. @end example
  5733. runs @command{guile} in an environment where Guile and Guile-SDL are
  5734. available.
  5735. Note that this example implicitly asks for the default output of
  5736. @code{guile} and @code{guile-sdl}, but it is possible to ask for a
  5737. specific output---e.g., @code{glib:bin} asks for the @code{bin} output
  5738. of @code{glib} (@pxref{Packages with Multiple Outputs}).
  5739. This option may be composed with the default behavior of @command{guix
  5740. environment}. Packages appearing before @code{--ad-hoc} are interpreted
  5741. as packages whose dependencies will be added to the environment, the
  5742. default behavior. Packages appearing after are interpreted as packages
  5743. that will be added to the environment directly.
  5744. @item --pure
  5745. Unset existing environment variables when building the new environment.
  5746. This has the effect of creating an environment in which search paths
  5747. only contain package inputs.
  5748. @item --search-paths
  5749. Display the environment variable definitions that make up the
  5750. environment.
  5751. @item --system=@var{system}
  5752. @itemx -s @var{system}
  5753. Attempt to build for @var{system}---e.g., @code{i686-linux}.
  5754. @item --container
  5755. @itemx -C
  5756. @cindex container
  5757. Run @var{command} within an isolated container. The current working
  5758. directory outside the container is mapped inside the container.
  5759. Additionally, a dummy home directory is created that matches the current
  5760. user's home directory, and @file{/etc/passwd} is configured accordingly.
  5761. The spawned process runs as the current user outside the container, but
  5762. has root privileges in the context of the container.
  5763. @item --network
  5764. @itemx -N
  5765. For containers, share the network namespace with the host system.
  5766. Containers created without this flag only have access to the loopback
  5767. device.
  5768. @item --expose=@var{source}[=@var{target}]
  5769. For containers, expose the file system @var{source} from the host system
  5770. as the read-only file system @var{target} within the container. If
  5771. @var{target} is not specified, @var{source} is used as the target mount
  5772. point in the container.
  5773. The example below spawns a Guile REPL in a container in which the user's
  5774. home directory is accessible read-only via the @file{/exchange}
  5775. directory:
  5776. @example
  5777. guix environment --container --expose=$HOME=/exchange --ad-hoc guile -- guile
  5778. @end example
  5779. @item --share=@var{source}[=@var{target}]
  5780. For containers, share the file system @var{source} from the host system
  5781. as the writable file system @var{target} within the container. If
  5782. @var{target} is not specified, @var{source} is used as the target mount
  5783. point in the container.
  5784. The example below spawns a Guile REPL in a container in which the user's
  5785. home directory is accessible for both reading and writing via the
  5786. @file{/exchange} directory:
  5787. @example
  5788. guix environment --container --share=$HOME=/exchange --ad-hoc guile -- guile
  5789. @end example
  5790. @end table
  5791. @command{guix environment}
  5792. also supports all of the common build options that @command{guix
  5793. build} supports (@pxref{Common Build Options}).
  5794. @node Invoking guix publish
  5795. @section Invoking @command{guix publish}
  5796. @cindex @command{guix publish}
  5797. The purpose of @command{guix publish} is to enable users to easily share
  5798. their store with others, who can then use it as a substitute server
  5799. (@pxref{Substitutes}).
  5800. When @command{guix publish} runs, it spawns an HTTP server which allows
  5801. anyone with network access to obtain substitutes from it. This means
  5802. that any machine running Guix can also act as if it were a build farm,
  5803. since the HTTP interface is compatible with Hydra, the software behind
  5804. the @code{hydra.gnu.org} build farm.
  5805. For security, each substitute is signed, allowing recipients to check
  5806. their authenticity and integrity (@pxref{Substitutes}). Because
  5807. @command{guix publish} uses the signing key of the system, which is only
  5808. readable by the system administrator, it must be started as root; the
  5809. @code{--user} option makes it drop root privileges early on.
  5810. The signing key pair must be generated before @command{guix publish} is
  5811. launched, using @command{guix archive --generate-key} (@pxref{Invoking
  5812. guix archive}).
  5813. The general syntax is:
  5814. @example
  5815. guix publish @var{options}@dots{}
  5816. @end example
  5817. Running @command{guix publish} without any additional arguments will
  5818. spawn an HTTP server on port 8080:
  5819. @example
  5820. guix publish
  5821. @end example
  5822. Once a publishing server has been authorized (@pxref{Invoking guix
  5823. archive}), the daemon may download substitutes from it:
  5824. @example
  5825. guix-daemon --substitute-urls=http://example.org:8080
  5826. @end example
  5827. By default, @command{guix publish} compresses archives on the fly as it
  5828. serves them. This ``on-the-fly'' mode is convenient in that it requires
  5829. no setup and is immediately available. However, when serving lots of
  5830. clients, we recommend using the @option{--cache} option, which enables
  5831. caching of the archives before they are sent to clients---see below for
  5832. details. The @command{guix weather} command provides a handy way to
  5833. check what a server provides (@pxref{Invoking guix weather}).
  5834. As a bonus, @command{guix publish} also serves as a content-addressed
  5835. mirror for source files referenced in @code{origin} records
  5836. (@pxref{origin Reference}). For instance, assuming @command{guix
  5837. publish} is running on @code{example.org}, the following URL returns the
  5838. raw @file{hello-2.10.tar.gz} file with the given SHA256 hash
  5839. (represented in @code{nix-base32} format, @pxref{Invoking guix hash}):
  5840. @example
  5841. http://example.org/file/hello-2.10.tar.gz/sha256/0ssi1@dots{}ndq1i
  5842. @end example
  5843. Obviously, these URLs only work for files that are in the store; in
  5844. other cases, they return 404 (``Not Found'').
  5845. @cindex build logs, publication
  5846. Build logs are available from @code{/log} URLs like:
  5847. @example
  5848. http://example.org/log/gwspk@dots{}-guile-2.2.3
  5849. @end example
  5850. @noindent
  5851. When @command{guix-daemon} is configured to save compressed build logs,
  5852. as is the case by default (@pxref{Invoking guix-daemon}), @code{/log}
  5853. URLs return the compressed log as-is, with an appropriate
  5854. @code{Content-Type} and/or @code{Content-Encoding} header. We recommend
  5855. running @command{guix-daemon} with @code{--log-compression=gzip} since
  5856. Web browsers can automatically decompress it, which is not the case with
  5857. bzip2 compression.
  5858. The following options are available:
  5859. @table @code
  5860. @item --port=@var{port}
  5861. @itemx -p @var{port}
  5862. Listen for HTTP requests on @var{port}.
  5863. @item --listen=@var{host}
  5864. Listen on the network interface for @var{host}. The default is to
  5865. accept connections from any interface.
  5866. @item --user=@var{user}
  5867. @itemx -u @var{user}
  5868. Change privileges to @var{user} as soon as possible---i.e., once the
  5869. server socket is open and the signing key has been read.
  5870. @item --compression[=@var{level}]
  5871. @itemx -C [@var{level}]
  5872. Compress data using the given @var{level}. When @var{level} is zero,
  5873. disable compression. The range 1 to 9 corresponds to different gzip
  5874. compression levels: 1 is the fastest, and 9 is the best (CPU-intensive).
  5875. The default is 3.
  5876. Unless @option{--cache} is used, compression occurs on the fly and
  5877. the compressed streams are not
  5878. cached. Thus, to reduce load on the machine that runs @command{guix
  5879. publish}, it may be a good idea to choose a low compression level, to
  5880. run @command{guix publish} behind a caching proxy, or to use
  5881. @option{--cache}. Using @option{--cache} has the advantage that it
  5882. allows @command{guix publish} to add @code{Content-Length} HTTP header
  5883. to its responses.
  5884. @item --cache=@var{directory}
  5885. @itemx -c @var{directory}
  5886. Cache archives and meta-data (@code{.narinfo} URLs) to @var{directory}
  5887. and only serve archives that are in cache.
  5888. When this option is omitted, archives and meta-data are created
  5889. on-the-fly. This can reduce the available bandwidth, especially when
  5890. compression is enabled, since this may become CPU-bound. Another
  5891. drawback of the default mode is that the length of archives is not known
  5892. in advance, so @command{guix publish} does not add a
  5893. @code{Content-Length} HTTP header to its responses, which in turn
  5894. prevents clients from knowing the amount of data being downloaded.
  5895. Conversely, when @option{--cache} is used, the first request for a store
  5896. item (@i{via} a @code{.narinfo} URL) returns 404 and triggers a
  5897. background process to @dfn{bake} the archive---computing its
  5898. @code{.narinfo} and compressing the archive, if needed. Once the
  5899. archive is cached in @var{directory}, subsequent requests succeed and
  5900. are served directly from the cache, which guarantees that clients get
  5901. the best possible bandwidth.
  5902. The ``baking'' process is performed by worker threads. By default, one
  5903. thread per CPU core is created, but this can be customized. See
  5904. @option{--workers} below.
  5905. When @option{--ttl} is used, cached entries are automatically deleted
  5906. when they have expired.
  5907. @item --workers=@var{N}
  5908. When @option{--cache} is used, request the allocation of @var{N} worker
  5909. threads to ``bake'' archives.
  5910. @item --ttl=@var{ttl}
  5911. Produce @code{Cache-Control} HTTP headers that advertise a time-to-live
  5912. (TTL) of @var{ttl}. @var{ttl} must denote a duration: @code{5d} means 5
  5913. days, @code{1m} means 1 month, and so on.
  5914. This allows the user's Guix to keep substitute information in cache for
  5915. @var{ttl}. However, note that @code{guix publish} does not itself
  5916. guarantee that the store items it provides will indeed remain available
  5917. for as long as @var{ttl}.
  5918. Additionally, when @option{--cache} is used, cached entries that have
  5919. not been accessed for @var{ttl} and that no longer have a corresponding
  5920. item in the store, may be deleted.
  5921. @item --nar-path=@var{path}
  5922. Use @var{path} as the prefix for the URLs of ``nar'' files
  5923. (@pxref{Invoking guix archive, normalized archives}).
  5924. By default, nars are served at a URL such as
  5925. @code{/nar/gzip/@dots{}-coreutils-8.25}. This option allows you to
  5926. change the @code{/nar} part to @var{path}.
  5927. @item --public-key=@var{file}
  5928. @itemx --private-key=@var{file}
  5929. Use the specific @var{file}s as the public/private key pair used to sign
  5930. the store items being published.
  5931. The files must correspond to the same key pair (the private key is used
  5932. for signing and the public key is merely advertised in the signature
  5933. metadata). They must contain keys in the canonical s-expression format
  5934. as produced by @command{guix archive --generate-key} (@pxref{Invoking
  5935. guix archive}). By default, @file{/etc/guix/signing-key.pub} and
  5936. @file{/etc/guix/signing-key.sec} are used.
  5937. @item --repl[=@var{port}]
  5938. @itemx -r [@var{port}]
  5939. Spawn a Guile REPL server (@pxref{REPL Servers,,, guile, GNU Guile
  5940. Reference Manual}) on @var{port} (37146 by default). This is used
  5941. primarily for debugging a running @command{guix publish} server.
  5942. @end table
  5943. Enabling @command{guix publish} on a GuixSD system is a one-liner: just
  5944. instantiate a @code{guix-publish-service-type} service in the @code{services} field
  5945. of the @code{operating-system} declaration (@pxref{guix-publish-service-type,
  5946. @code{guix-publish-service-type}}).
  5947. If you are instead running Guix on a ``foreign distro'', follow these
  5948. instructions:”
  5949. @itemize
  5950. @item
  5951. If your host distro uses the systemd init system:
  5952. @example
  5953. # ln -s ~root/.guix-profile/lib/systemd/system/guix-publish.service \
  5954. /etc/systemd/system/
  5955. # systemctl start guix-publish && systemctl enable guix-publish
  5956. @end example
  5957. @item
  5958. If your host distro uses the Upstart init system:
  5959. @example
  5960. # ln -s ~root/.guix-profile/lib/upstart/system/guix-publish.conf /etc/init/
  5961. # start guix-publish
  5962. @end example
  5963. @item
  5964. Otherwise, proceed similarly with your distro's init system.
  5965. @end itemize
  5966. @node Invoking guix challenge
  5967. @section Invoking @command{guix challenge}
  5968. @cindex reproducible builds
  5969. @cindex verifiable builds
  5970. @cindex @command{guix challenge}
  5971. @cindex challenge
  5972. Do the binaries provided by this server really correspond to the source
  5973. code it claims to build? Is a package build process deterministic?
  5974. These are the questions the @command{guix challenge} command attempts to
  5975. answer.
  5976. The former is obviously an important question: Before using a substitute
  5977. server (@pxref{Substitutes}), one had better @emph{verify} that it
  5978. provides the right binaries, and thus @emph{challenge} it. The latter
  5979. is what enables the former: If package builds are deterministic, then
  5980. independent builds of the package should yield the exact same result,
  5981. bit for bit; if a server provides a binary different from the one
  5982. obtained locally, it may be either corrupt or malicious.
  5983. We know that the hash that shows up in @file{/gnu/store} file names is
  5984. the hash of all the inputs of the process that built the file or
  5985. directory---compilers, libraries, build scripts,
  5986. etc. (@pxref{Introduction}). Assuming deterministic build processes,
  5987. one store file name should map to exactly one build output.
  5988. @command{guix challenge} checks whether there is, indeed, a single
  5989. mapping by comparing the build outputs of several independent builds of
  5990. any given store item.
  5991. The command output looks like this:
  5992. @smallexample
  5993. $ guix challenge --substitute-urls="https://hydra.gnu.org https://guix.example.org"
  5994. updating list of substitutes from 'https://hydra.gnu.org'... 100.0%
  5995. updating list of substitutes from 'https://guix.example.org'... 100.0%
  5996. /gnu/store/@dots{}-openssl-1.0.2d contents differ:
  5997. local hash: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q
  5998. https://hydra.gnu.org/nar/@dots{}-openssl-1.0.2d: 0725l22r5jnzazaacncwsvp9kgf42266ayyp814v7djxs7nk963q
  5999. https://guix.example.org/nar/@dots{}-openssl-1.0.2d: 1zy4fmaaqcnjrzzajkdn3f5gmjk754b43qkq47llbyak9z0qjyim
  6000. /gnu/store/@dots{}-git-2.5.0 contents differ:
  6001. local hash: 00p3bmryhjxrhpn2gxs2fy0a15lnip05l97205pgbk5ra395hyha
  6002. https://hydra.gnu.org/nar/@dots{}-git-2.5.0: 069nb85bv4d4a6slrwjdy8v1cn4cwspm3kdbmyb81d6zckj3nq9f
  6003. https://guix.example.org/nar/@dots{}-git-2.5.0: 0mdqa9w1p6cmli6976v4wi0sw9r4p5prkj7lzfd1877wk11c9c73
  6004. /gnu/store/@dots{}-pius-2.1.1 contents differ:
  6005. local hash: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax
  6006. https://hydra.gnu.org/nar/@dots{}-pius-2.1.1: 0k4v3m9z1zp8xzzizb7d8kjj72f9172xv078sq4wl73vnq9ig3ax
  6007. https://guix.example.org/nar/@dots{}-pius-2.1.1: 1cy25x1a4fzq5rk0pmvc8xhwyffnqz95h2bpvqsz2mpvlbccy0gs
  6008. @dots{}
  6009. 6,406 store items were analyzed:
  6010. - 4,749 (74.1%) were identical
  6011. - 525 (8.2%) differed
  6012. - 1,132 (17.7%) were inconclusive
  6013. @end smallexample
  6014. @noindent
  6015. In this example, @command{guix challenge} first scans the store to
  6016. determine the set of locally-built derivations---as opposed to store
  6017. items that were downloaded from a substitute server---and then queries
  6018. all the substitute servers. It then reports those store items for which
  6019. the servers obtained a result different from the local build.
  6020. @cindex non-determinism, in package builds
  6021. As an example, @code{guix.example.org} always gets a different answer.
  6022. Conversely, @code{hydra.gnu.org} agrees with local builds, except in the
  6023. case of Git. This might indicate that the build process of Git is
  6024. non-deterministic, meaning that its output varies as a function of
  6025. various things that Guix does not fully control, in spite of building
  6026. packages in isolated environments (@pxref{Features}). Most common
  6027. sources of non-determinism include the addition of timestamps in build
  6028. results, the inclusion of random numbers, and directory listings sorted
  6029. by inode number. See @uref{https://reproducible-builds.org/docs/}, for
  6030. more information.
  6031. To find out what is wrong with this Git binary, we can do something along
  6032. these lines (@pxref{Invoking guix archive}):
  6033. @example
  6034. $ wget -q -O - https://hydra.gnu.org/nar/@dots{}-git-2.5.0 \
  6035. | guix archive -x /tmp/git
  6036. $ diff -ur --no-dereference /gnu/store/@dots{}-git.2.5.0 /tmp/git
  6037. @end example
  6038. This command shows the difference between the files resulting from the
  6039. local build, and the files resulting from the build on
  6040. @code{hydra.gnu.org} (@pxref{Overview, Comparing and Merging Files,,
  6041. diffutils, Comparing and Merging Files}). The @command{diff} command
  6042. works great for text files. When binary files differ, a better option
  6043. is @uref{https://diffoscope.org/, Diffoscope}, a tool that helps
  6044. visualize differences for all kinds of files.
  6045. Once you have done that work, you can tell whether the differences are due
  6046. to a non-deterministic build process or to a malicious server. We try
  6047. hard to remove sources of non-determinism in packages to make it easier
  6048. to verify substitutes, but of course, this is a process that
  6049. involves not just Guix, but a large part of the free software community.
  6050. In the meantime, @command{guix challenge} is one tool to help address
  6051. the problem.
  6052. If you are writing packages for Guix, you are encouraged to check
  6053. whether @code{hydra.gnu.org} and other substitute servers obtain the
  6054. same build result as you did with:
  6055. @example
  6056. $ guix challenge @var{package}
  6057. @end example
  6058. @noindent
  6059. where @var{package} is a package specification such as
  6060. @code{guile@@2.0} or @code{glibc:debug}.
  6061. The general syntax is:
  6062. @example
  6063. guix challenge @var{options} [@var{packages}@dots{}]
  6064. @end example
  6065. When a difference is found between the hash of a locally-built item and
  6066. that of a server-provided substitute, or among substitutes provided by
  6067. different servers, the command displays it as in the example above and
  6068. its exit code is 2 (other non-zero exit codes denote other kinds of
  6069. errors.)
  6070. The one option that matters is:
  6071. @table @code
  6072. @item --substitute-urls=@var{urls}
  6073. Consider @var{urls} the whitespace-separated list of substitute source
  6074. URLs to compare to.
  6075. @item --verbose
  6076. @itemx -v
  6077. Show details about matches (identical contents) in addition to
  6078. information about mismatches.
  6079. @end table
  6080. @node Invoking guix copy
  6081. @section Invoking @command{guix copy}
  6082. @cindex copy, of store items, over SSH
  6083. @cindex SSH, copy of store items
  6084. @cindex sharing store items across machines
  6085. @cindex transferring store items across machines
  6086. The @command{guix copy} command copies items from the store of one
  6087. machine to that of another machine over a secure shell (SSH)
  6088. connection@footnote{This command is available only when Guile-SSH was
  6089. found. @xref{Requirements}, for details.}. For example, the following
  6090. command copies the @code{coreutils} package, the user's profile, and all
  6091. their dependencies over to @var{host}, logged in as @var{user}:
  6092. @example
  6093. guix copy --to=@var{user}@@@var{host} \
  6094. coreutils `readlink -f ~/.guix-profile`
  6095. @end example
  6096. If some of the items to be copied are already present on @var{host},
  6097. they are not actually sent.
  6098. The command below retrieves @code{libreoffice} and @code{gimp} from
  6099. @var{host}, assuming they are available there:
  6100. @example
  6101. guix copy --from=@var{host} libreoffice gimp
  6102. @end example
  6103. The SSH connection is established using the Guile-SSH client, which is
  6104. compatible with OpenSSH: it honors @file{~/.ssh/known_hosts} and
  6105. @file{~/.ssh/config}, and uses the SSH agent for authentication.
  6106. The key used to sign items that are sent must be accepted by the remote
  6107. machine. Likewise, the key used by the remote machine to sign items you
  6108. are retrieving must be in @file{/etc/guix/acl} so it is accepted by your
  6109. own daemon. @xref{Invoking guix archive}, for more information about
  6110. store item authentication.
  6111. The general syntax is:
  6112. @example
  6113. guix copy [--to=@var{spec}|--from=@var{spec}] @var{items}@dots{}
  6114. @end example
  6115. You must always specify one of the following options:
  6116. @table @code
  6117. @item --to=@var{spec}
  6118. @itemx --from=@var{spec}
  6119. Specify the host to send to or receive from. @var{spec} must be an SSH
  6120. spec such as @code{example.org}, @code{charlie@@example.org}, or
  6121. @code{charlie@@example.org:2222}.
  6122. @end table
  6123. The @var{items} can be either package names, such as @code{gimp}, or
  6124. store items, such as @file{/gnu/store/@dots{}-idutils-4.6}.
  6125. When specifying the name of a package to send, it is first built if
  6126. needed, unless @option{--dry-run} was specified. Common build options
  6127. are supported (@pxref{Common Build Options}).
  6128. @node Invoking guix container
  6129. @section Invoking @command{guix container}
  6130. @cindex container
  6131. @cindex @command{guix container}
  6132. @quotation Note
  6133. As of version @value{VERSION}, this tool is experimental. The interface
  6134. is subject to radical change in the future.
  6135. @end quotation
  6136. The purpose of @command{guix container} is to manipulate processes
  6137. running within an isolated environment, commonly known as a
  6138. ``container'', typically created by the @command{guix environment}
  6139. (@pxref{Invoking guix environment}) and @command{guix system container}
  6140. (@pxref{Invoking guix system}) commands.
  6141. The general syntax is:
  6142. @example
  6143. guix container @var{action} @var{options}@dots{}
  6144. @end example
  6145. @var{action} specifies the operation to perform with a container, and
  6146. @var{options} specifies the context-specific arguments for the action.
  6147. The following actions are available:
  6148. @table @code
  6149. @item exec
  6150. Execute a command within the context of a running container.
  6151. The syntax is:
  6152. @example
  6153. guix container exec @var{pid} @var{program} @var{arguments}@dots{}
  6154. @end example
  6155. @var{pid} specifies the process ID of the running container.
  6156. @var{program} specifies an executable file name within the root file
  6157. system of the container. @var{arguments} are the additional options that
  6158. will be passed to @var{program}.
  6159. The following command launches an interactive login shell inside a
  6160. GuixSD container, started by @command{guix system container}, and whose
  6161. process ID is 9001:
  6162. @example
  6163. guix container exec 9001 /run/current-system/profile/bin/bash --login
  6164. @end example
  6165. Note that the @var{pid} cannot be the parent process of a container. It
  6166. must be PID 1 of the container or one of its child processes.
  6167. @end table
  6168. @node Invoking guix weather
  6169. @section Invoking @command{guix weather}
  6170. Occasionally you're grumpy because substitutes are lacking and you end
  6171. up building packages by yourself (@pxref{Substitutes}). The
  6172. @command{guix weather} command reports on substitute availability on the
  6173. specified servers so you can have an idea of whether you'll be grumpy
  6174. today. It can sometimes be useful info as a user, but it is primarily
  6175. useful to people running @command{guix publish} (@pxref{Invoking guix
  6176. publish}).
  6177. @cindex statistics, for substitutes
  6178. @cindex availability of substitutes
  6179. @cindex substitute availability
  6180. @cindex weather, substitute availability
  6181. Here's a sample run:
  6182. @example
  6183. $ guix weather --substitute-urls=https://guix.example.org
  6184. computing 5,872 package derivations for x86_64-linux...
  6185. looking for 6,128 store items on https://guix.example.org..
  6186. updating list of substitutes from 'https://guix.example.org'... 100.0%
  6187. https://guix.example.org
  6188. 43.4% substitutes available (2,658 out of 6,128)
  6189. 7,032.5 MiB of nars (compressed)
  6190. 19,824.2 MiB on disk (uncompressed)
  6191. 0.030 seconds per request (182.9 seconds in total)
  6192. 33.5 requests per second
  6193. @end example
  6194. As you can see, it reports the fraction of all the packages for which
  6195. substitutes are available on the server---regardless of whether
  6196. substitutes are enabled, and regardless of whether this server's signing
  6197. key is authorized. It also reports the size of the compressed archives
  6198. (``nars'') provided by the server, the size the corresponding store
  6199. items occupy in the store (assuming deduplication is turned off), and
  6200. the server's throughput.
  6201. To achieve that, @command{guix weather} queries over HTTP(S) meta-data
  6202. (@dfn{narinfos}) for all the relevant store items. Like @command{guix
  6203. challenge}, it ignores signatures on those substitutes, which is
  6204. innocuous since the command only gathers statistics and cannot install
  6205. those substitutes.
  6206. Among other things, it is possible to query specific system types and
  6207. specific package sets. The available options are listed below.
  6208. @table @code
  6209. @item --substitute-urls=@var{urls}
  6210. @var{urls} is the space-separated list of substitute server URLs to
  6211. query. When this option is omitted, the default set of substitute
  6212. servers is queried.
  6213. @item --system=@var{system}
  6214. @itemx -s @var{system}
  6215. Query substitutes for @var{system}---e.g., @code{aarch64-linux}. This
  6216. option can be repeated, in which case @command{guix weather} will query
  6217. substitutes for several system types.
  6218. @item --manifest=@var{file}
  6219. Instead of querying substitutes for all the packages, only ask for those
  6220. specified in @var{file}. @var{file} must contain a @dfn{manifest}, as
  6221. with the @code{-m} option of @command{guix package} (@pxref{Invoking
  6222. guix package}).
  6223. @end table
  6224. @c *********************************************************************
  6225. @node GNU Distribution
  6226. @chapter GNU Distribution
  6227. @cindex Guix System Distribution
  6228. @cindex GuixSD
  6229. Guix comes with a distribution of the GNU system consisting entirely of
  6230. free software@footnote{The term ``free'' here refers to the
  6231. @url{http://www.gnu.org/philosophy/free-sw.html,freedom provided to
  6232. users of that software}.}. The
  6233. distribution can be installed on its own (@pxref{System Installation}),
  6234. but it is also possible to install Guix as a package manager on top of
  6235. an installed GNU/Linux system (@pxref{Installation}). To distinguish
  6236. between the two, we refer to the standalone distribution as the Guix
  6237. System Distribution, or GuixSD.
  6238. The distribution provides core GNU packages such as GNU libc, GCC, and
  6239. Binutils, as well as many GNU and non-GNU applications. The complete
  6240. list of available packages can be browsed
  6241. @url{http://www.gnu.org/software/guix/packages,on-line} or by
  6242. running @command{guix package} (@pxref{Invoking guix package}):
  6243. @example
  6244. guix package --list-available
  6245. @end example
  6246. Our goal is to provide a practical 100% free software distribution of
  6247. Linux-based and other variants of GNU, with a focus on the promotion and
  6248. tight integration of GNU components, and an emphasis on programs and
  6249. tools that help users exert that freedom.
  6250. Packages are currently available on the following platforms:
  6251. @table @code
  6252. @item x86_64-linux
  6253. Intel/AMD @code{x86_64} architecture, Linux-Libre kernel;
  6254. @item i686-linux
  6255. Intel 32-bit architecture (IA32), Linux-Libre kernel;
  6256. @item armhf-linux
  6257. ARMv7-A architecture with hard float, Thumb-2 and NEON,
  6258. using the EABI hard-float application binary interface (ABI),
  6259. and Linux-Libre kernel.
  6260. @item aarch64-linux
  6261. little-endian 64-bit ARMv8-A processors, Linux-Libre kernel. This is
  6262. currently in an experimental stage, with limited support.
  6263. @xref{Contributing}, for how to help!
  6264. @item mips64el-linux
  6265. little-endian 64-bit MIPS processors, specifically the Loongson series,
  6266. n32 ABI, and Linux-Libre kernel.
  6267. @end table
  6268. GuixSD itself is currently only available on @code{i686} and @code{x86_64}.
  6269. @noindent
  6270. For information on porting to other architectures or kernels,
  6271. @pxref{Porting}.
  6272. @menu
  6273. * System Installation:: Installing the whole operating system.
  6274. * System Configuration:: Configuring the operating system.
  6275. * Documentation:: Browsing software user manuals.
  6276. * Installing Debugging Files:: Feeding the debugger.
  6277. * Security Updates:: Deploying security fixes quickly.
  6278. * Package Modules:: Packages from the programmer's viewpoint.
  6279. * Packaging Guidelines:: Growing the distribution.
  6280. * Bootstrapping:: GNU/Linux built from scratch.
  6281. * Porting:: Targeting another platform or kernel.
  6282. @end menu
  6283. Building this distribution is a cooperative effort, and you are invited
  6284. to join! @xref{Contributing}, for information about how you can help.
  6285. @node System Installation
  6286. @section System Installation
  6287. @cindex installing GuixSD
  6288. @cindex Guix System Distribution
  6289. This section explains how to install the Guix System Distribution (GuixSD)
  6290. on a machine. The Guix package manager can
  6291. also be installed on top of a running GNU/Linux system,
  6292. @pxref{Installation}.
  6293. @ifinfo
  6294. @quotation Note
  6295. @c This paragraph is for people reading this from tty2 of the
  6296. @c installation image.
  6297. You are reading this documentation with an Info reader. For details on
  6298. how to use it, hit the @key{RET} key (``return'' or ``enter'') on the
  6299. link that follows: @pxref{Top, Info reader,, info-stnd, Stand-alone GNU
  6300. Info}. Hit @kbd{l} afterwards to come back here.
  6301. Alternately, run @command{info info} in another tty to keep the manual
  6302. available.
  6303. @end quotation
  6304. @end ifinfo
  6305. @menu
  6306. * Limitations:: What you can expect.
  6307. * Hardware Considerations:: Supported hardware.
  6308. * USB Stick and DVD Installation:: Preparing the installation medium.
  6309. * Preparing for Installation:: Networking, partitioning, etc.
  6310. * Proceeding with the Installation:: The real thing.
  6311. * Installing GuixSD in a VM:: GuixSD playground.
  6312. * Building the Installation Image:: How this comes to be.
  6313. @end menu
  6314. @node Limitations
  6315. @subsection Limitations
  6316. As of version @value{VERSION}, the Guix System Distribution (GuixSD) is
  6317. not production-ready. It may contain bugs and lack important
  6318. features. Thus, if you are looking for a stable production system that
  6319. respects your freedom as a computer user, a good solution at this point
  6320. is to consider @url{http://www.gnu.org/distros/free-distros.html, one of
  6321. the more established GNU/Linux distributions}. We hope you can soon switch
  6322. to the GuixSD without fear, of course. In the meantime, you can
  6323. also keep using your distribution and try out the package manager on top
  6324. of it (@pxref{Installation}).
  6325. Before you proceed with the installation, be aware of the following
  6326. noteworthy limitations applicable to version @value{VERSION}:
  6327. @itemize
  6328. @item
  6329. The installation process does not include a graphical user interface and
  6330. requires familiarity with GNU/Linux (see the following subsections to
  6331. get a feel of what that means.)
  6332. @item
  6333. Support for the Logical Volume Manager (LVM) is missing.
  6334. @item
  6335. More and more system services are provided (@pxref{Services}), but some
  6336. may be missing.
  6337. @item
  6338. More than 6,500 packages are available, but you might
  6339. occasionally find that a useful package is missing.
  6340. @item
  6341. GNOME, Xfce, LXDE, and Enlightenment are available (@pxref{Desktop Services}),
  6342. as well as a number of X11 window managers. However, some graphical
  6343. applications may be missing, as well as KDE.
  6344. @end itemize
  6345. You have been warned! But more than a disclaimer, this is an invitation
  6346. to report issues (and success stories!), and to join us in improving it.
  6347. @xref{Contributing}, for more info.
  6348. @node Hardware Considerations
  6349. @subsection Hardware Considerations
  6350. @cindex hardware support on GuixSD
  6351. GNU@tie{}GuixSD focuses on respecting the user's computing freedom. It
  6352. builds around the kernel Linux-libre, which means that only hardware for
  6353. which free software drivers and firmware exist is supported. Nowadays,
  6354. a wide range of off-the-shelf hardware is supported on
  6355. GNU/Linux-libre---from keyboards to graphics cards to scanners and
  6356. Ethernet controllers. Unfortunately, there are still areas where
  6357. hardware vendors deny users control over their own computing, and such
  6358. hardware is not supported on GuixSD.
  6359. @cindex WiFi, hardware support
  6360. One of the main areas where free drivers or firmware are lacking is WiFi
  6361. devices. WiFi devices known to work include those using Atheros chips
  6362. (AR9271 and AR7010), which corresponds to the @code{ath9k} Linux-libre
  6363. driver, and those using Broadcom/AirForce chips (BCM43xx with
  6364. Wireless-Core Revision 5), which corresponds to the @code{b43-open}
  6365. Linux-libre driver. Free firmware exists for both and is available
  6366. out-of-the-box on GuixSD, as part of @var{%base-firmware}
  6367. (@pxref{operating-system Reference, @code{firmware}}).
  6368. @cindex RYF, Respects Your Freedom
  6369. The @uref{https://www.fsf.org/, Free Software Foundation} runs
  6370. @uref{https://www.fsf.org/ryf, @dfn{Respects Your Freedom}} (RYF), a
  6371. certification program for hardware products that respect your freedom
  6372. and your privacy and ensure that you have control over your device. We
  6373. encourage you to check the list of RYF-certified devices.
  6374. Another useful resource is the @uref{https://www.h-node.org/, H-Node}
  6375. web site. It contains a catalog of hardware devices with information
  6376. about their support in GNU/Linux.
  6377. @node USB Stick and DVD Installation
  6378. @subsection USB Stick and DVD Installation
  6379. An ISO-9660 installation image that can be written to a USB stick or
  6380. burnt to a DVD can be downloaded from
  6381. @indicateurl{ftp://alpha.gnu.org/gnu/guix/guixsd-install-@value{VERSION}.@var{system}.iso.xz},
  6382. where @var{system} is one of:
  6383. @table @code
  6384. @item x86_64-linux
  6385. for a GNU/Linux system on Intel/AMD-compatible 64-bit CPUs;
  6386. @item i686-linux
  6387. for a 32-bit GNU/Linux system on Intel-compatible CPUs.
  6388. @end table
  6389. @c start duplication of authentication part from ``Binary Installation''
  6390. Make sure to download the associated @file{.sig} file and to verify the
  6391. authenticity of the image against it, along these lines:
  6392. @example
  6393. $ wget ftp://alpha.gnu.org/gnu/guix/guixsd-install-@value{VERSION}.@var{system}.iso.xz.sig
  6394. $ gpg --verify guixsd-install-@value{VERSION}.@var{system}.iso.xz.sig
  6395. @end example
  6396. If that command fails because you do not have the required public key,
  6397. then run this command to import it:
  6398. @example
  6399. $ gpg --keyserver pgp.mit.edu --recv-keys @value{OPENPGP-SIGNING-KEY-ID}
  6400. @end example
  6401. @noindent
  6402. and rerun the @code{gpg --verify} command.
  6403. @c end duplication
  6404. This image contains the tools necessary for an installation.
  6405. It is meant to be copied @emph{as is} to a large-enough USB stick or DVD.
  6406. @unnumberedsubsubsec Copying to a USB Stick
  6407. To copy the image to a USB stick, follow these steps:
  6408. @enumerate
  6409. @item
  6410. Decompress the image using the @command{xz} command:
  6411. @example
  6412. xz -d guixsd-install-@value{VERSION}.@var{system}.iso.xz
  6413. @end example
  6414. @item
  6415. Insert a USB stick of 1@tie{}GiB or more into your machine, and determine
  6416. its device name. Assuming that the USB stick is known as @file{/dev/sdX},
  6417. copy the image with:
  6418. @example
  6419. dd if=guixsd-install-@value{VERSION}.x86_64-linux.iso of=/dev/sdX
  6420. sync
  6421. @end example
  6422. Access to @file{/dev/sdX} usually requires root privileges.
  6423. @end enumerate
  6424. @unnumberedsubsubsec Burning on a DVD
  6425. To copy the image to a DVD, follow these steps:
  6426. @enumerate
  6427. @item
  6428. Decompress the image using the @command{xz} command:
  6429. @example
  6430. xz -d guixsd-install-@value{VERSION}.@var{system}.iso.xz
  6431. @end example
  6432. @item
  6433. Insert a blank DVD into your machine, and determine
  6434. its device name. Assuming that the DVD drive is known as @file{/dev/srX},
  6435. copy the image with:
  6436. @example
  6437. growisofs -dvd-compat -Z /dev/srX=guixsd-install-@value{VERSION}.x86_64.iso
  6438. @end example
  6439. Access to @file{/dev/srX} usually requires root privileges.
  6440. @end enumerate
  6441. @unnumberedsubsubsec Booting
  6442. Once this is done, you should be able to reboot the system and boot from
  6443. the USB stick or DVD. The latter usually requires you to get in the
  6444. BIOS or UEFI boot menu, where you can choose to boot from the USB stick.
  6445. @xref{Installing GuixSD in a VM}, if, instead, you would like to install
  6446. GuixSD in a virtual machine (VM).
  6447. @node Preparing for Installation
  6448. @subsection Preparing for Installation
  6449. Once you have successfully booted your computer using the installation medium,
  6450. you should end up with a root prompt. Several console TTYs are configured
  6451. and can be used to run commands as root. TTY2 shows this documentation,
  6452. browsable using the Info reader commands (@pxref{Top,,, info-stnd,
  6453. Stand-alone GNU Info}). The installation system runs the GPM mouse
  6454. daemon, which allows you to select text with the left mouse button and
  6455. to paste it with the middle button.
  6456. @quotation Note
  6457. Installation requires access to the Internet so that any missing
  6458. dependencies of your system configuration can be downloaded. See the
  6459. ``Networking'' section below.
  6460. @end quotation
  6461. The installation system includes many common tools needed for this task.
  6462. But it is also a full-blown GuixSD system, which means that you can
  6463. install additional packages, should you need it, using @command{guix
  6464. package} (@pxref{Invoking guix package}).
  6465. @subsubsection Keyboard Layout
  6466. @cindex keyboard layout
  6467. The installation image uses the US qwerty keyboard layout. If you want
  6468. to change it, you can use the @command{loadkeys} command. For example,
  6469. the following command selects the Dvorak keyboard layout:
  6470. @example
  6471. loadkeys dvorak
  6472. @end example
  6473. See the files under @file{/run/current-system/profile/share/keymaps} for
  6474. a list of available keyboard layouts. Run @command{man loadkeys} for
  6475. more information.
  6476. @subsubsection Networking
  6477. Run the following command see what your network interfaces are called:
  6478. @example
  6479. ifconfig -a
  6480. @end example
  6481. @noindent
  6482. @dots{} or, using the GNU/Linux-specific @command{ip} command:
  6483. @example
  6484. ip a
  6485. @end example
  6486. @c http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-net_id.c#n20
  6487. Wired interfaces have a name starting with @samp{e}; for example, the
  6488. interface corresponding to the first on-board Ethernet controller is
  6489. called @samp{eno1}. Wireless interfaces have a name starting with
  6490. @samp{w}, like @samp{w1p2s0}.
  6491. @table @asis
  6492. @item Wired connection
  6493. To configure a wired network run the following command, substituting
  6494. @var{interface} with the name of the wired interface you want to use.
  6495. @example
  6496. ifconfig @var{interface} up
  6497. @end example
  6498. @item Wireless connection
  6499. @cindex wireless
  6500. @cindex WiFi
  6501. To configure wireless networking, you can create a configuration file
  6502. for the @command{wpa_supplicant} configuration tool (its location is not
  6503. important) using one of the available text editors such as
  6504. @command{zile}:
  6505. @example
  6506. zile wpa_supplicant.conf
  6507. @end example
  6508. As an example, the following stanza can go to this file and will work
  6509. for many wireless networks, provided you give the actual SSID and
  6510. passphrase for the network you are connecting to:
  6511. @example
  6512. network=@{
  6513. ssid="@var{my-ssid}"
  6514. key_mgmt=WPA-PSK
  6515. psk="the network's secret passphrase"
  6516. @}
  6517. @end example
  6518. Start the wireless service and run it in the background with the
  6519. following command (substitute @var{interface} with the name of the
  6520. network interface you want to use):
  6521. @example
  6522. wpa_supplicant -c wpa_supplicant.conf -i @var{interface} -B
  6523. @end example
  6524. Run @command{man wpa_supplicant} for more information.
  6525. @end table
  6526. @cindex DHCP
  6527. At this point, you need to acquire an IP address. On a network where IP
  6528. addresses are automatically assigned @i{via} DHCP, you can run:
  6529. @example
  6530. dhclient -v @var{interface}
  6531. @end example
  6532. Try to ping a server to see if networking is up and running:
  6533. @example
  6534. ping -c 3 gnu.org
  6535. @end example
  6536. Setting up network access is almost always a requirement because the
  6537. image does not contain all the software and tools that may be needed.
  6538. @cindex installing over SSH
  6539. If you want to, you can continue the installation remotely by starting
  6540. an SSH server:
  6541. @example
  6542. herd start ssh-daemon
  6543. @end example
  6544. Make sure to either set a password with @command{passwd}, or configure
  6545. OpenSSH public key authentication before logging in.
  6546. @subsubsection Disk Partitioning
  6547. Unless this has already been done, the next step is to partition, and
  6548. then format the target partition(s).
  6549. The installation image includes several partitioning tools, including
  6550. Parted (@pxref{Overview,,, parted, GNU Parted User Manual}),
  6551. @command{fdisk}, and @command{cfdisk}. Run it and set up your disk with
  6552. the partition layout you want:
  6553. @example
  6554. cfdisk
  6555. @end example
  6556. If your disk uses the GUID Partition Table (GPT) format and you plan to
  6557. install BIOS-based GRUB (which is the default), make sure a BIOS Boot
  6558. Partition is available (@pxref{BIOS installation,,, grub, GNU GRUB
  6559. manual}).
  6560. @cindex EFI, installation
  6561. @cindex UEFI, installation
  6562. @cindex ESP, EFI system partition
  6563. If you instead wish to use EFI-based GRUB, a FAT32 @dfn{EFI System Partition}
  6564. (ESP) is required. This partition should be mounted at @file{/boot/efi} and
  6565. must have the @code{esp} flag set. E.g., for @command{parted}:
  6566. @example
  6567. parted /dev/sda set 1 esp on
  6568. @end example
  6569. Once you are done partitioning the target hard disk drive, you have to
  6570. create a file system on the relevant partition(s)@footnote{Currently
  6571. GuixSD only supports ext4 and btrfs file systems. In particular, code
  6572. that reads partition UUIDs and labels only works for these file system
  6573. types.}. For the ESP, if you have one and assuming it is
  6574. @file{/dev/sda2}, run:
  6575. @example
  6576. mkfs.fat -F32 /dev/sda2
  6577. @end example
  6578. Preferably, assign file systems a label so that you can easily and
  6579. reliably refer to them in @code{file-system} declarations (@pxref{File
  6580. Systems}). This is typically done using the @code{-L} option of
  6581. @command{mkfs.ext4} and related commands. So, assuming the target root
  6582. partition lives at @file{/dev/sda1}, a file system with the label
  6583. @code{my-root} can be created with:
  6584. @example
  6585. mkfs.ext4 -L my-root /dev/sda1
  6586. @end example
  6587. @cindex encrypted disk
  6588. If you are instead planning to encrypt the root partition, you can use
  6589. the Cryptsetup/LUKS utilities to do that (see @inlinefmtifelse{html,
  6590. @uref{https://linux.die.net/man/8/cryptsetup, @code{man cryptsetup}},
  6591. @code{man cryptsetup}} for more information.) Assuming you want to
  6592. store the root partition on @file{/dev/sda1}, the command sequence would
  6593. be along these lines:
  6594. @example
  6595. cryptsetup luksFormat /dev/sda1
  6596. cryptsetup open --type luks /dev/sda1 my-partition
  6597. mkfs.ext4 -L my-root /dev/mapper/my-partition
  6598. @end example
  6599. Once that is done, mount the target file system under @file{/mnt}
  6600. with a command like (again, assuming @code{my-root} is the label of the
  6601. root file system):
  6602. @example
  6603. mount LABEL=my-root /mnt
  6604. @end example
  6605. Also mount any other partitions you would like to use on the target
  6606. system relative to this path. If you have @file{/boot} on a separate
  6607. partition for example, mount it at @file{/mnt/boot} now so it is found
  6608. by @code{guix system init} afterwards.
  6609. Finally, if you plan to use one or more swap partitions (@pxref{Memory
  6610. Concepts, swap space,, libc, The GNU C Library Reference Manual}), make
  6611. sure to initialize them with @command{mkswap}. Assuming you have one
  6612. swap partition on @file{/dev/sda2}, you would run:
  6613. @example
  6614. mkswap /dev/sda2
  6615. swapon /dev/sda2
  6616. @end example
  6617. Alternatively, you may use a swap file. For example, assuming that in
  6618. the new system you want to use the file @file{/swapfile} as a swap file,
  6619. you would run@footnote{This example will work for many types of file
  6620. systems (e.g., ext4). However, for copy-on-write file systems (e.g.,
  6621. btrfs), the required steps may be different. For details, see the
  6622. manual pages for @command{mkswap} and @command{swapon}.}:
  6623. @example
  6624. # This is 10 GiB of swap space. Adjust "count" to change the size.
  6625. dd if=/dev/zero of=/mnt/swapfile bs=1MiB count=10240
  6626. # For security, make the file readable and writable only by root.
  6627. chmod 600 /mnt/swapfile
  6628. mkswap /mnt/swapfile
  6629. swapon /mnt/swapfile
  6630. @end example
  6631. Note that if you have encrypted the root partition and created a swap
  6632. file in its file system as described above, then the encryption also
  6633. protects the swap file, just like any other file in that file system.
  6634. @node Proceeding with the Installation
  6635. @subsection Proceeding with the Installation
  6636. With the target partitions ready and the target root mounted on
  6637. @file{/mnt}, we're ready to go. First, run:
  6638. @example
  6639. herd start cow-store /mnt
  6640. @end example
  6641. This makes @file{/gnu/store} copy-on-write, such that packages added to it
  6642. during the installation phase are written to the target disk on @file{/mnt}
  6643. rather than kept in memory. This is necessary because the first phase of
  6644. the @command{guix system init} command (see below) entails downloads or
  6645. builds to @file{/gnu/store} which, initially, is an in-memory file system.
  6646. Next, you have to edit a file and
  6647. provide the declaration of the operating system to be installed. To
  6648. that end, the installation system comes with three text editors: GNU nano
  6649. (@pxref{Top,,, nano, GNU nano Manual}), GNU Zile (an Emacs clone), and
  6650. nvi (a clone of the original BSD @command{vi} editor).
  6651. We strongly recommend storing that file on the target root file system, say,
  6652. as @file{/mnt/etc/config.scm}. Failing to do that, you will have lost your
  6653. configuration file once you have rebooted into the newly-installed system.
  6654. @xref{Using the Configuration System}, for an overview of the
  6655. configuration file. The example configurations discussed in that
  6656. section are available under @file{/etc/configuration} in the
  6657. installation image. Thus, to get started with a system configuration
  6658. providing a graphical display server (a ``desktop'' system), you can run
  6659. something along these lines:
  6660. @example
  6661. # mkdir /mnt/etc
  6662. # cp /etc/configuration/desktop.scm /mnt/etc/config.scm
  6663. # zile /mnt/etc/config.scm
  6664. @end example
  6665. You should pay attention to what your configuration file contains, and
  6666. in particular:
  6667. @itemize
  6668. @item
  6669. Make sure the @code{bootloader-configuration} form refers to the target
  6670. you want to install GRUB on. It should mention @code{grub-bootloader} if
  6671. you are installing GRUB in the legacy way, or @code{grub-efi-bootloader}
  6672. for newer UEFI systems. For legacy systems, the @code{target} field
  6673. names a device, like @code{/dev/sda}; for UEFI systems it names a path
  6674. to a mounted EFI partition, like @code{/boot/efi}, and do make sure the
  6675. path is actually mounted.
  6676. @item
  6677. Be sure that your partition labels match the value of their respective
  6678. @code{device} fields in your @code{file-system} configuration, assuming
  6679. your @code{file-system} configuration sets the value of @code{title} to
  6680. @code{'label}.
  6681. @item
  6682. If there are encrypted or RAID partitions, make sure to add a
  6683. @code{mapped-devices} field to describe them (@pxref{Mapped Devices}).
  6684. @end itemize
  6685. Once you are done preparing the configuration file, the new system must
  6686. be initialized (remember that the target root file system is mounted
  6687. under @file{/mnt}):
  6688. @example
  6689. guix system init /mnt/etc/config.scm /mnt
  6690. @end example
  6691. @noindent
  6692. This copies all the necessary files and installs GRUB on
  6693. @file{/dev/sdX}, unless you pass the @option{--no-bootloader} option. For
  6694. more information, @pxref{Invoking guix system}. This command may trigger
  6695. downloads or builds of missing packages, which can take some time.
  6696. Once that command has completed---and hopefully succeeded!---you can run
  6697. @command{reboot} and boot into the new system. The @code{root} password
  6698. in the new system is initially empty; other users' passwords need to be
  6699. initialized by running the @command{passwd} command as @code{root},
  6700. unless your configuration specifies otherwise
  6701. (@pxref{user-account-password, user account passwords}).
  6702. @cindex upgrading GuixSD
  6703. From then on, you can update GuixSD whenever you want by running
  6704. @command{guix pull} as @code{root} (@pxref{Invoking guix pull}), and
  6705. then running @command{guix system reconfigure} to build a new system
  6706. generation with the latest packages and services (@pxref{Invoking guix
  6707. system}). We recommend doing that regularly so that your system
  6708. includes the latest security updates (@pxref{Security Updates}).
  6709. Join us on @code{#guix} on the Freenode IRC network or on
  6710. @file{guix-devel@@gnu.org} to share your experience---good or not so
  6711. good.
  6712. @node Installing GuixSD in a VM
  6713. @subsection Installing GuixSD in a Virtual Machine
  6714. @cindex virtual machine, GuixSD installation
  6715. @cindex virtual private server (VPS)
  6716. @cindex VPS (virtual private server)
  6717. If you'd like to install GuixSD in a virtual machine (VM) or on a
  6718. virtual private server (VPS) rather than on your beloved machine, this
  6719. section is for you.
  6720. To boot a @uref{http://qemu.org/,QEMU} VM for installing GuixSD in a
  6721. disk image, follow these steps:
  6722. @enumerate
  6723. @item
  6724. First, retrieve and decompress the GuixSD installation image as
  6725. described previously (@pxref{USB Stick and DVD Installation}).
  6726. @item
  6727. Create a disk image that will hold the installed system. To make a
  6728. qcow2-formatted disk image, use the @command{qemu-img} command:
  6729. @example
  6730. qemu-img create -f qcow2 guixsd.img 50G
  6731. @end example
  6732. The resulting file will be much smaller than 50 GB (typically less than
  6733. 1 MB), but it will grow as the virtualized storage device is filled up.
  6734. @item
  6735. Boot the USB installation image in an VM:
  6736. @example
  6737. qemu-system-x86_64 -m 1024 -smp 1 \
  6738. -net user -net nic,model=virtio -boot menu=on \
  6739. -drive file=guixsd-install-@value{VERSION}.@var{system}.iso \
  6740. -drive file=guixsd.img
  6741. @end example
  6742. The ordering of the drives matters.
  6743. In the VM console, quickly press the @kbd{F12} key to enter the boot
  6744. menu. Then press the @kbd{2} key and the @kbd{RET} key to validate your
  6745. selection.
  6746. @item
  6747. You're now root in the VM, proceed with the installation process.
  6748. @xref{Preparing for Installation}, and follow the instructions.
  6749. @end enumerate
  6750. Once installation is complete, you can boot the system that's on your
  6751. @file{guixsd.img} image. @xref{Running GuixSD in a VM}, for how to do
  6752. that.
  6753. @node Building the Installation Image
  6754. @subsection Building the Installation Image
  6755. @cindex installation image
  6756. The installation image described above was built using the @command{guix
  6757. system} command, specifically:
  6758. @example
  6759. guix system disk-image gnu/system/install.scm
  6760. @end example
  6761. Have a look at @file{gnu/system/install.scm} in the source tree,
  6762. and see also @ref{Invoking guix system} for more information
  6763. about the installation image.
  6764. @node System Configuration
  6765. @section System Configuration
  6766. @cindex system configuration
  6767. The Guix System Distribution supports a consistent whole-system configuration
  6768. mechanism. By that we mean that all aspects of the global system
  6769. configuration---such as the available system services, timezone and
  6770. locale settings, user accounts---are declared in a single place. Such
  6771. a @dfn{system configuration} can be @dfn{instantiated}---i.e., effected.
  6772. One of the advantages of putting all the system configuration under the
  6773. control of Guix is that it supports transactional system upgrades, and
  6774. makes it possible to roll back to a previous system instantiation,
  6775. should something go wrong with the new one (@pxref{Features}). Another
  6776. advantage is that it makes it easy to replicate the exact same configuration
  6777. across different machines, or at different points in time, without
  6778. having to resort to additional administration tools layered on top of
  6779. the own tools of the system.
  6780. @c Yes, we're talking of Puppet, Chef, & co. here. ↑
  6781. This section describes this mechanism. First we focus on the system
  6782. administrator's viewpoint---explaining how the system is configured and
  6783. instantiated. Then we show how this mechanism can be extended, for
  6784. instance to support new system services.
  6785. @menu
  6786. * Using the Configuration System:: Customizing your GNU system.
  6787. * operating-system Reference:: Detail of operating-system declarations.
  6788. * File Systems:: Configuring file system mounts.
  6789. * Mapped Devices:: Block device extra processing.
  6790. * User Accounts:: Specifying user accounts.
  6791. * Locales:: Language and cultural convention settings.
  6792. * Services:: Specifying system services.
  6793. * Setuid Programs:: Programs running with root privileges.
  6794. * X.509 Certificates:: Authenticating HTTPS servers.
  6795. * Name Service Switch:: Configuring libc's name service switch.
  6796. * Initial RAM Disk:: Linux-Libre bootstrapping.
  6797. * Bootloader Configuration:: Configuring the boot loader.
  6798. * Invoking guix system:: Instantiating a system configuration.
  6799. * Running GuixSD in a VM:: How to run GuixSD in a virtual machine.
  6800. * Defining Services:: Adding new service definitions.
  6801. @end menu
  6802. @node Using the Configuration System
  6803. @subsection Using the Configuration System
  6804. The operating system is configured by providing an
  6805. @code{operating-system} declaration in a file that can then be passed to
  6806. the @command{guix system} command (@pxref{Invoking guix system}). A
  6807. simple setup, with the default system services, the default Linux-Libre
  6808. kernel, initial RAM disk, and boot loader looks like this:
  6809. @findex operating-system
  6810. @lisp
  6811. @include os-config-bare-bones.texi
  6812. @end lisp
  6813. This example should be self-describing. Some of the fields defined
  6814. above, such as @code{host-name} and @code{bootloader}, are mandatory.
  6815. Others, such as @code{packages} and @code{services}, can be omitted, in
  6816. which case they get a default value.
  6817. Below we discuss the effect of some of the most important fields
  6818. (@pxref{operating-system Reference}, for details about all the available
  6819. fields), and how to @dfn{instantiate} the operating system using
  6820. @command{guix system}.
  6821. @unnumberedsubsubsec Globally-Visible Packages
  6822. @vindex %base-packages
  6823. The @code{packages} field lists packages that will be globally visible
  6824. on the system, for all user accounts---i.e., in every user's @code{PATH}
  6825. environment variable---in addition to the per-user profiles
  6826. (@pxref{Invoking guix package}). The @var{%base-packages} variable
  6827. provides all the tools one would expect for basic user and administrator
  6828. tasks---including the GNU Core Utilities, the GNU Networking Utilities,
  6829. the GNU Zile lightweight text editor, @command{find}, @command{grep},
  6830. etc. The example above adds GNU@tie{}Screen and OpenSSH to those,
  6831. taken from the @code{(gnu packages screen)} and @code{(gnu packages ssh)}
  6832. modules (@pxref{Package Modules}). The
  6833. @code{(list package output)} syntax can be used to add a specific output
  6834. of a package:
  6835. @lisp
  6836. (use-modules (gnu packages))
  6837. (use-modules (gnu packages dns))
  6838. (operating-system
  6839. ;; ...
  6840. (packages (cons (list bind "utils")
  6841. %base-packages)))
  6842. @end lisp
  6843. @findex specification->package
  6844. Referring to packages by variable name, like @var{tcpdump} above, has
  6845. the advantage of being unambiguous; it also allows typos and such to be
  6846. diagnosed right away as ``unbound variables''. The downside is that one
  6847. needs to know which module defines which package, and to augment the
  6848. @code{use-package-modules} line accordingly. To avoid that, one can use
  6849. the @code{specification->package} procedure of the @code{(gnu packages)}
  6850. module, which returns the best package for a given name or name and
  6851. version:
  6852. @lisp
  6853. (use-modules (gnu packages))
  6854. (operating-system
  6855. ;; ...
  6856. (packages (append (map specification->package
  6857. '("tcpdump" "htop" "gnupg@@2.0"))
  6858. %base-packages)))
  6859. @end lisp
  6860. @unnumberedsubsubsec System Services
  6861. @cindex services
  6862. @vindex %base-services
  6863. The @code{services} field lists @dfn{system services} to be made
  6864. available when the system starts (@pxref{Services}).
  6865. The @code{operating-system} declaration above specifies that, in
  6866. addition to the basic services, we want the @command{lshd} secure shell
  6867. daemon listening on port 2222 (@pxref{Networking Services,
  6868. @code{lsh-service}}). Under the hood,
  6869. @code{lsh-service} arranges so that @code{lshd} is started with the
  6870. right command-line options, possibly with supporting configuration files
  6871. generated as needed (@pxref{Defining Services}).
  6872. @cindex customization, of services
  6873. @findex modify-services
  6874. Occasionally, instead of using the base services as is, you will want to
  6875. customize them. To do this, use @code{modify-services} (@pxref{Service
  6876. Reference, @code{modify-services}}) to modify the list.
  6877. For example, suppose you want to modify @code{guix-daemon} and Mingetty
  6878. (the console log-in) in the @var{%base-services} list (@pxref{Base
  6879. Services, @code{%base-services}}). To do that, you can write the
  6880. following in your operating system declaration:
  6881. @lisp
  6882. (define %my-services
  6883. ;; My very own list of services.
  6884. (modify-services %base-services
  6885. (guix-service-type config =>
  6886. (guix-configuration
  6887. (inherit config)
  6888. (use-substitutes? #f)
  6889. (extra-options '("--gc-keep-derivations"))))
  6890. (mingetty-service-type config =>
  6891. (mingetty-configuration
  6892. (inherit config)))))
  6893. (operating-system
  6894. ;; @dots{}
  6895. (services %my-services))
  6896. @end lisp
  6897. This changes the configuration---i.e., the service parameters---of the
  6898. @code{guix-service-type} instance, and that of all the
  6899. @code{mingetty-service-type} instances in the @var{%base-services} list.
  6900. Observe how this is accomplished: first, we arrange for the original
  6901. configuration to be bound to the identifier @code{config} in the
  6902. @var{body}, and then we write the @var{body} so that it evaluates to the
  6903. desired configuration. In particular, notice how we use @code{inherit}
  6904. to create a new configuration which has the same values as the old
  6905. configuration, but with a few modifications.
  6906. @cindex encrypted disk
  6907. The configuration for a typical ``desktop'' usage, with an encrypted
  6908. root partition, the X11 display
  6909. server, GNOME and Xfce (users can choose which of these desktop
  6910. environments to use at the log-in screen by pressing @kbd{F1}), network
  6911. management, power management, and more, would look like this:
  6912. @lisp
  6913. @include os-config-desktop.texi
  6914. @end lisp
  6915. @cindex UEFI
  6916. A graphical UEFI system with a choice of lightweight window managers
  6917. instead of full-blown desktop environments would look like this:
  6918. @lisp
  6919. @include os-config-lightweight-desktop.texi
  6920. @end lisp
  6921. This example refers to the @file{/boot/efi} partition by its UUID,
  6922. @code{1234-ABCD}. Replace this UUID with the right UUID on your system,
  6923. as returned by the @command{blkid} command.
  6924. @xref{Desktop Services}, for the exact list of services provided by
  6925. @var{%desktop-services}. @xref{X.509 Certificates}, for background
  6926. information about the @code{nss-certs} package that is used here.
  6927. Again, @var{%desktop-services} is just a list of service objects. If
  6928. you want to remove services from there, you can do so using the
  6929. procedures for list filtering (@pxref{SRFI-1 Filtering and
  6930. Partitioning,,, guile, GNU Guile Reference Manual}). For instance, the
  6931. following expression returns a list that contains all the services in
  6932. @var{%desktop-services} minus the Avahi service:
  6933. @example
  6934. (remove (lambda (service)
  6935. (eq? (service-kind service) avahi-service-type))
  6936. %desktop-services)
  6937. @end example
  6938. @unnumberedsubsubsec Instantiating the System
  6939. Assuming the @code{operating-system} declaration
  6940. is stored in the @file{my-system-config.scm}
  6941. file, the @command{guix system reconfigure my-system-config.scm} command
  6942. instantiates that configuration, and makes it the default GRUB boot
  6943. entry (@pxref{Invoking guix system}).
  6944. The normal way to change the system configuration is by updating this
  6945. file and re-running @command{guix system reconfigure}. One should never
  6946. have to touch files in @file{/etc} or to run commands that modify the
  6947. system state such as @command{useradd} or @command{grub-install}. In
  6948. fact, you must avoid that since that would not only void your warranty
  6949. but also prevent you from rolling back to previous versions of your
  6950. system, should you ever need to.
  6951. @cindex roll-back, of the operating system
  6952. Speaking of roll-back, each time you run @command{guix system
  6953. reconfigure}, a new @dfn{generation} of the system is created---without
  6954. modifying or deleting previous generations. Old system generations get
  6955. an entry in the bootloader boot menu, allowing you to boot them in case
  6956. something went wrong with the latest generation. Reassuring, no? The
  6957. @command{guix system list-generations} command lists the system
  6958. generations available on disk. It is also possible to roll back the
  6959. system via the commands @command{guix system roll-back} and
  6960. @command{guix system switch-generation}.
  6961. Although the command @command{guix system reconfigure} will not modify
  6962. previous generations, must take care when the current generation is not
  6963. the latest (e.g., after invoking @command{guix system roll-back}), since
  6964. the operation might overwrite a later generation (@pxref{Invoking guix
  6965. system}).
  6966. @unnumberedsubsubsec The Programming Interface
  6967. At the Scheme level, the bulk of an @code{operating-system} declaration
  6968. is instantiated with the following monadic procedure (@pxref{The Store
  6969. Monad}):
  6970. @deffn {Monadic Procedure} operating-system-derivation os
  6971. Return a derivation that builds @var{os}, an @code{operating-system}
  6972. object (@pxref{Derivations}).
  6973. The output of the derivation is a single directory that refers to all
  6974. the packages, configuration files, and other supporting files needed to
  6975. instantiate @var{os}.
  6976. @end deffn
  6977. This procedure is provided by the @code{(gnu system)} module. Along
  6978. with @code{(gnu services)} (@pxref{Services}), this module contains the
  6979. guts of GuixSD. Make sure to visit it!
  6980. @node operating-system Reference
  6981. @subsection @code{operating-system} Reference
  6982. This section summarizes all the options available in
  6983. @code{operating-system} declarations (@pxref{Using the Configuration
  6984. System}).
  6985. @deftp {Data Type} operating-system
  6986. This is the data type representing an operating system configuration.
  6987. By that, we mean all the global system configuration, not per-user
  6988. configuration (@pxref{Using the Configuration System}).
  6989. @table @asis
  6990. @item @code{kernel} (default: @var{linux-libre})
  6991. The package object of the operating system kernel to use@footnote{Currently
  6992. only the Linux-libre kernel is supported. In the future, it will be
  6993. possible to use the GNU@tie{}Hurd.}.
  6994. @item @code{kernel-arguments} (default: @code{'()})
  6995. List of strings or gexps representing additional arguments to pass on
  6996. the command-line of the kernel---e.g., @code{("console=ttyS0")}.
  6997. @item @code{bootloader}
  6998. The system bootloader configuration object. @xref{Bootloader Configuration}.
  6999. @item @code{initrd} (default: @code{base-initrd})
  7000. @cindex initrd
  7001. @cindex initial RAM disk
  7002. A two-argument monadic procedure that returns an initial RAM disk for
  7003. the Linux kernel. @xref{Initial RAM Disk}.
  7004. @item @code{firmware} (default: @var{%base-firmware})
  7005. @cindex firmware
  7006. List of firmware packages loadable by the operating system kernel.
  7007. The default includes firmware needed for Atheros- and Broadcom-based
  7008. WiFi devices (Linux-libre modules @code{ath9k} and @code{b43-open},
  7009. respectively). @xref{Hardware Considerations}, for more info on
  7010. supported hardware.
  7011. @item @code{host-name}
  7012. The host name.
  7013. @item @code{hosts-file}
  7014. @cindex hosts file
  7015. A file-like object (@pxref{G-Expressions, file-like objects}) for use as
  7016. @file{/etc/hosts} (@pxref{Host Names,,, libc, The GNU C Library
  7017. Reference Manual}). The default is a file with entries for
  7018. @code{localhost} and @var{host-name}.
  7019. @item @code{mapped-devices} (default: @code{'()})
  7020. A list of mapped devices. @xref{Mapped Devices}.
  7021. @item @code{file-systems}
  7022. A list of file systems. @xref{File Systems}.
  7023. @item @code{swap-devices} (default: @code{'()})
  7024. @cindex swap devices
  7025. A list of strings identifying devices or files to be used for ``swap
  7026. space'' (@pxref{Memory Concepts,,, libc, The GNU C Library Reference
  7027. Manual}). For example, @code{'("/dev/sda3")} or @code{'("/swapfile")}.
  7028. It is possible to specify a swap file in a file system on a mapped
  7029. device, provided that the necessary device mapping and file system are
  7030. also specified. @xref{Mapped Devices} and @ref{File Systems}.
  7031. @item @code{users} (default: @code{%base-user-accounts})
  7032. @itemx @code{groups} (default: @var{%base-groups})
  7033. List of user accounts and groups. @xref{User Accounts}.
  7034. If the @code{users} list lacks a user account with UID@tie{}0, a
  7035. ``root'' account with UID@tie{}0 is automatically added.
  7036. @item @code{skeletons} (default: @code{(default-skeletons)})
  7037. A list target file name/file-like object tuples (@pxref{G-Expressions,
  7038. file-like objects}). These are the skeleton files that will be added to
  7039. the home directory of newly-created user accounts.
  7040. For instance, a valid value may look like this:
  7041. @example
  7042. `((".bashrc" ,(plain-file "bashrc" "echo Hello\n"))
  7043. (".guile" ,(plain-file "guile"
  7044. "(use-modules (ice-9 readline))
  7045. (activate-readline)")))
  7046. @end example
  7047. @item @code{issue} (default: @var{%default-issue})
  7048. A string denoting the contents of the @file{/etc/issue} file, which is
  7049. displayed when users log in on a text console.
  7050. @item @code{packages} (default: @var{%base-packages})
  7051. The set of packages installed in the global profile, which is accessible
  7052. at @file{/run/current-system/profile}.
  7053. The default set includes core utilities and it is good practice to
  7054. install non-core utilities in user profiles (@pxref{Invoking guix
  7055. package}).
  7056. @item @code{timezone}
  7057. A timezone identifying string---e.g., @code{"Europe/Paris"}.
  7058. You can run the @command{tzselect} command to find out which timezone
  7059. string corresponds to your region. Choosing an invalid timezone name
  7060. causes @command{guix system} to fail.
  7061. @item @code{locale} (default: @code{"en_US.utf8"})
  7062. The name of the default locale (@pxref{Locale Names,,, libc, The GNU C
  7063. Library Reference Manual}). @xref{Locales}, for more information.
  7064. @item @code{locale-definitions} (default: @var{%default-locale-definitions})
  7065. The list of locale definitions to be compiled and that may be used at
  7066. run time. @xref{Locales}.
  7067. @item @code{locale-libcs} (default: @code{(list @var{glibc})})
  7068. The list of GNU@tie{}libc packages whose locale data and tools are used
  7069. to build the locale definitions. @xref{Locales}, for compatibility
  7070. considerations that justify this option.
  7071. @item @code{name-service-switch} (default: @var{%default-nss})
  7072. Configuration of the libc name service switch (NSS)---a
  7073. @code{<name-service-switch>} object. @xref{Name Service Switch}, for
  7074. details.
  7075. @item @code{services} (default: @var{%base-services})
  7076. A list of service objects denoting system services. @xref{Services}.
  7077. @item @code{pam-services} (default: @code{(base-pam-services)})
  7078. @cindex PAM
  7079. @cindex pluggable authentication modules
  7080. Linux @dfn{pluggable authentication module} (PAM) services.
  7081. @c FIXME: Add xref to PAM services section.
  7082. @item @code{setuid-programs} (default: @var{%setuid-programs})
  7083. List of string-valued G-expressions denoting setuid programs.
  7084. @xref{Setuid Programs}.
  7085. @item @code{sudoers-file} (default: @var{%sudoers-specification})
  7086. @cindex sudoers file
  7087. The contents of the @file{/etc/sudoers} file as a file-like object
  7088. (@pxref{G-Expressions, @code{local-file} and @code{plain-file}}).
  7089. This file specifies which users can use the @command{sudo} command, what
  7090. they are allowed to do, and what privileges they may gain. The default
  7091. is that only @code{root} and members of the @code{wheel} group may use
  7092. @code{sudo}.
  7093. @end table
  7094. @end deftp
  7095. @node File Systems
  7096. @subsection File Systems
  7097. The list of file systems to be mounted is specified in the
  7098. @code{file-systems} field of the operating system declaration
  7099. (@pxref{Using the Configuration System}). Each file system is declared
  7100. using the @code{file-system} form, like this:
  7101. @example
  7102. (file-system
  7103. (mount-point "/home")
  7104. (device "/dev/sda3")
  7105. (type "ext4"))
  7106. @end example
  7107. As usual, some of the fields are mandatory---those shown in the example
  7108. above---while others can be omitted. These are described below.
  7109. @deftp {Data Type} file-system
  7110. Objects of this type represent file systems to be mounted. They
  7111. contain the following members:
  7112. @table @asis
  7113. @item @code{type}
  7114. This is a string specifying the type of the file system---e.g.,
  7115. @code{"ext4"}.
  7116. @item @code{mount-point}
  7117. This designates the place where the file system is to be mounted.
  7118. @item @code{device}
  7119. This names the ``source'' of the file system. By default it is the name
  7120. of a node under @file{/dev}, but its meaning depends on the @code{title}
  7121. field described below.
  7122. @item @code{title} (default: @code{'device})
  7123. This is a symbol that specifies how the @code{device} field is to be
  7124. interpreted.
  7125. When it is the symbol @code{device}, then the @code{device} field is
  7126. interpreted as a file name; when it is @code{label}, then @code{device}
  7127. is interpreted as a partition label name; when it is @code{uuid},
  7128. @code{device} is interpreted as a partition unique identifier (UUID).
  7129. UUIDs may be converted from their string representation (as shown by the
  7130. @command{tune2fs -l} command) using the @code{uuid} form@footnote{The
  7131. @code{uuid} form expects 16-byte UUIDs as defined in
  7132. @uref{https://tools.ietf.org/html/rfc4122, RFC@tie{}4122}. This is the
  7133. form of UUID used by the ext2 family of file systems and others, but it
  7134. is different from ``UUIDs'' found in FAT file systems, for instance.},
  7135. like this:
  7136. @example
  7137. (file-system
  7138. (mount-point "/home")
  7139. (type "ext4")
  7140. (title 'uuid)
  7141. (device (uuid "4dab5feb-d176-45de-b287-9b0a6e4c01cb")))
  7142. @end example
  7143. The @code{label} and @code{uuid} options offer a way to refer to disk
  7144. partitions without having to hard-code their actual device
  7145. name@footnote{Note that, while it is tempting to use
  7146. @file{/dev/disk/by-uuid} and similar device names to achieve the same
  7147. result, this is not recommended: These special device nodes are created
  7148. by the udev daemon and may be unavailable at the time the device is
  7149. mounted.}.
  7150. However, when the source of a file system is a mapped device (@pxref{Mapped
  7151. Devices}), its @code{device} field @emph{must} refer to the mapped
  7152. device name---e.g., @file{/dev/mapper/root-partition}---and consequently
  7153. @code{title} must be set to @code{'device}. This is required so that
  7154. the system knows that mounting the file system depends on having the
  7155. corresponding device mapping established.
  7156. @item @code{flags} (default: @code{'()})
  7157. This is a list of symbols denoting mount flags. Recognized flags
  7158. include @code{read-only}, @code{bind-mount}, @code{no-dev} (disallow
  7159. access to special files), @code{no-suid} (ignore setuid and setgid
  7160. bits), and @code{no-exec} (disallow program execution.)
  7161. @item @code{options} (default: @code{#f})
  7162. This is either @code{#f}, or a string denoting mount options.
  7163. @item @code{mount?} (default: @code{#t})
  7164. This value indicates whether to automatically mount the file system when
  7165. the system is brought up. When set to @code{#f}, the file system gets
  7166. an entry in @file{/etc/fstab} (read by the @command{mount} command) but
  7167. is not automatically mounted.
  7168. @item @code{needed-for-boot?} (default: @code{#f})
  7169. This Boolean value indicates whether the file system is needed when
  7170. booting. If that is true, then the file system is mounted when the
  7171. initial RAM disk (initrd) is loaded. This is always the case, for
  7172. instance, for the root file system.
  7173. @item @code{check?} (default: @code{#t})
  7174. This Boolean indicates whether the file system needs to be checked for
  7175. errors before being mounted.
  7176. @item @code{create-mount-point?} (default: @code{#f})
  7177. When true, the mount point is created if it does not exist yet.
  7178. @item @code{dependencies} (default: @code{'()})
  7179. This is a list of @code{<file-system>} or @code{<mapped-device>} objects
  7180. representing file systems that must be mounted or mapped devices that
  7181. must be opened before (and unmounted or closed after) this one.
  7182. As an example, consider a hierarchy of mounts: @file{/sys/fs/cgroup} is
  7183. a dependency of @file{/sys/fs/cgroup/cpu} and
  7184. @file{/sys/fs/cgroup/memory}.
  7185. Another example is a file system that depends on a mapped device, for
  7186. example for an encrypted partition (@pxref{Mapped Devices}).
  7187. @end table
  7188. @end deftp
  7189. The @code{(gnu system file-systems)} exports the following useful
  7190. variables.
  7191. @defvr {Scheme Variable} %base-file-systems
  7192. These are essential file systems that are required on normal systems,
  7193. such as @var{%pseudo-terminal-file-system} and @var{%immutable-store} (see
  7194. below.) Operating system declarations should always contain at least
  7195. these.
  7196. @end defvr
  7197. @defvr {Scheme Variable} %pseudo-terminal-file-system
  7198. This is the file system to be mounted as @file{/dev/pts}. It supports
  7199. @dfn{pseudo-terminals} created @i{via} @code{openpty} and similar
  7200. functions (@pxref{Pseudo-Terminals,,, libc, The GNU C Library Reference
  7201. Manual}). Pseudo-terminals are used by terminal emulators such as
  7202. @command{xterm}.
  7203. @end defvr
  7204. @defvr {Scheme Variable} %shared-memory-file-system
  7205. This file system is mounted as @file{/dev/shm} and is used to support
  7206. memory sharing across processes (@pxref{Memory-mapped I/O,
  7207. @code{shm_open},, libc, The GNU C Library Reference Manual}).
  7208. @end defvr
  7209. @defvr {Scheme Variable} %immutable-store
  7210. This file system performs a read-only ``bind mount'' of
  7211. @file{/gnu/store}, making it read-only for all the users including
  7212. @code{root}. This prevents against accidental modification by software
  7213. running as @code{root} or by system administrators.
  7214. The daemon itself is still able to write to the store: it remounts it
  7215. read-write in its own ``name space.''
  7216. @end defvr
  7217. @defvr {Scheme Variable} %binary-format-file-system
  7218. The @code{binfmt_misc} file system, which allows handling of arbitrary
  7219. executable file types to be delegated to user space. This requires the
  7220. @code{binfmt.ko} kernel module to be loaded.
  7221. @end defvr
  7222. @defvr {Scheme Variable} %fuse-control-file-system
  7223. The @code{fusectl} file system, which allows unprivileged users to mount
  7224. and unmount user-space FUSE file systems. This requires the
  7225. @code{fuse.ko} kernel module to be loaded.
  7226. @end defvr
  7227. @node Mapped Devices
  7228. @subsection Mapped Devices
  7229. @cindex device mapping
  7230. @cindex mapped devices
  7231. The Linux kernel has a notion of @dfn{device mapping}: a block device,
  7232. such as a hard disk partition, can be @dfn{mapped} into another device,
  7233. usually in @code{/dev/mapper/},
  7234. with additional processing over the data that flows through
  7235. it@footnote{Note that the GNU@tie{}Hurd makes no difference between the
  7236. concept of a ``mapped device'' and that of a file system: both boil down
  7237. to @emph{translating} input/output operations made on a file to
  7238. operations on its backing store. Thus, the Hurd implements mapped
  7239. devices, like file systems, using the generic @dfn{translator} mechanism
  7240. (@pxref{Translators,,, hurd, The GNU Hurd Reference Manual}).}. A
  7241. typical example is encryption device mapping: all writes to the mapped
  7242. device are encrypted, and all reads are deciphered, transparently.
  7243. Guix extends this notion by considering any device or set of devices that
  7244. are @dfn{transformed} in some way to create a new device; for instance,
  7245. RAID devices are obtained by @dfn{assembling} several other devices, such
  7246. as hard disks or partitions, into a new one that behaves as one partition.
  7247. Other examples, not yet implemented, are LVM logical volumes.
  7248. Mapped devices are declared using the @code{mapped-device} form,
  7249. defined as follows; for examples, see below.
  7250. @deftp {Data Type} mapped-device
  7251. Objects of this type represent device mappings that will be made when
  7252. the system boots up.
  7253. @table @code
  7254. @item source
  7255. This is either a string specifying the name of the block device to be mapped,
  7256. such as @code{"/dev/sda3"}, or a list of such strings when several devices
  7257. need to be assembled for creating a new one.
  7258. @item target
  7259. This string specifies the name of the resulting mapped device. For
  7260. kernel mappers such as encrypted devices of type @code{luks-device-mapping},
  7261. specifying @code{"my-partition"} leads to the creation of
  7262. the @code{"/dev/mapper/my-partition"} device.
  7263. For RAID devices of type @code{raid-device-mapping}, the full device name
  7264. such as @code{"/dev/md0"} needs to be given.
  7265. @item type
  7266. This must be a @code{mapped-device-kind} object, which specifies how
  7267. @var{source} is mapped to @var{target}.
  7268. @end table
  7269. @end deftp
  7270. @defvr {Scheme Variable} luks-device-mapping
  7271. This defines LUKS block device encryption using the @command{cryptsetup}
  7272. command from the package with the same name. It relies on the
  7273. @code{dm-crypt} Linux kernel module.
  7274. @end defvr
  7275. @defvr {Scheme Variable} raid-device-mapping
  7276. This defines a RAID device, which is assembled using the @code{mdadm}
  7277. command from the package with the same name. It requires a Linux kernel
  7278. module for the appropriate RAID level to be loaded, such as @code{raid456}
  7279. for RAID-4, RAID-5 or RAID-6, or @code{raid10} for RAID-10.
  7280. @end defvr
  7281. @cindex disk encryption
  7282. @cindex LUKS
  7283. The following example specifies a mapping from @file{/dev/sda3} to
  7284. @file{/dev/mapper/home} using LUKS---the
  7285. @url{https://gitlab.com/cryptsetup/cryptsetup,Linux Unified Key Setup}, a
  7286. standard mechanism for disk encryption.
  7287. The @file{/dev/mapper/home}
  7288. device can then be used as the @code{device} of a @code{file-system}
  7289. declaration (@pxref{File Systems}).
  7290. @example
  7291. (mapped-device
  7292. (source "/dev/sda3")
  7293. (target "home")
  7294. (type luks-device-mapping))
  7295. @end example
  7296. Alternatively, to become independent of device numbering, one may obtain
  7297. the LUKS UUID (@dfn{unique identifier}) of the source device by a
  7298. command like:
  7299. @example
  7300. cryptsetup luksUUID /dev/sda3
  7301. @end example
  7302. and use it as follows:
  7303. @example
  7304. (mapped-device
  7305. (source (uuid "cb67fc72-0d54-4c88-9d4b-b225f30b0f44"))
  7306. (target "home")
  7307. (type luks-device-mapping))
  7308. @end example
  7309. @cindex swap encryption
  7310. It is also desirable to encrypt swap space, since swap space may contain
  7311. sensitive data. One way to accomplish that is to use a swap file in a
  7312. file system on a device mapped via LUKS encryption. In this way, the
  7313. swap file is encrypted because the entire device is encrypted.
  7314. @xref{Preparing for Installation,,Disk Partitioning}, for an example.
  7315. A RAID device formed of the partitions @file{/dev/sda1} and @file{/dev/sdb1}
  7316. may be declared as follows:
  7317. @example
  7318. (mapped-device
  7319. (source (list "/dev/sda1" "/dev/sdb1"))
  7320. (target "/dev/md0")
  7321. (type raid-device-mapping))
  7322. @end example
  7323. The @file{/dev/md0} device can then be used as the @code{device} of a
  7324. @code{file-system} declaration (@pxref{File Systems}).
  7325. Note that the RAID level need not be given; it is chosen during the
  7326. initial creation and formatting of the RAID device and is determined
  7327. automatically later.
  7328. @node User Accounts
  7329. @subsection User Accounts
  7330. @cindex users
  7331. @cindex accounts
  7332. @cindex user accounts
  7333. User accounts and groups are entirely managed through the
  7334. @code{operating-system} declaration. They are specified with the
  7335. @code{user-account} and @code{user-group} forms:
  7336. @example
  7337. (user-account
  7338. (name "alice")
  7339. (group "users")
  7340. (supplementary-groups '("wheel" ;allow use of sudo, etc.
  7341. "audio" ;sound card
  7342. "video" ;video devices such as webcams
  7343. "cdrom")) ;the good ol' CD-ROM
  7344. (comment "Bob's sister")
  7345. (home-directory "/home/alice"))
  7346. @end example
  7347. When booting or upon completion of @command{guix system reconfigure},
  7348. the system ensures that only the user accounts and groups specified in
  7349. the @code{operating-system} declaration exist, and with the specified
  7350. properties. Thus, account or group creations or modifications made by
  7351. directly invoking commands such as @command{useradd} are lost upon
  7352. reconfiguration or reboot. This ensures that the system remains exactly
  7353. as declared.
  7354. @deftp {Data Type} user-account
  7355. Objects of this type represent user accounts. The following members may
  7356. be specified:
  7357. @table @asis
  7358. @item @code{name}
  7359. The name of the user account.
  7360. @item @code{group}
  7361. @cindex groups
  7362. This is the name (a string) or identifier (a number) of the user group
  7363. this account belongs to.
  7364. @item @code{supplementary-groups} (default: @code{'()})
  7365. Optionally, this can be defined as a list of group names that this
  7366. account belongs to.
  7367. @item @code{uid} (default: @code{#f})
  7368. This is the user ID for this account (a number), or @code{#f}. In the
  7369. latter case, a number is automatically chosen by the system when the
  7370. account is created.
  7371. @item @code{comment} (default: @code{""})
  7372. A comment about the account, such as the account owner's full name.
  7373. @item @code{home-directory}
  7374. This is the name of the home directory for the account.
  7375. @item @code{create-home-directory?} (default: @code{#t})
  7376. Indicates whether the home directory of this account should be created
  7377. if it does not exist yet.
  7378. @item @code{shell} (default: Bash)
  7379. This is a G-expression denoting the file name of a program to be used as
  7380. the shell (@pxref{G-Expressions}).
  7381. @item @code{system?} (default: @code{#f})
  7382. This Boolean value indicates whether the account is a ``system''
  7383. account. System accounts are sometimes treated specially; for instance,
  7384. graphical login managers do not list them.
  7385. @anchor{user-account-password}
  7386. @item @code{password} (default: @code{#f})
  7387. You would normally leave this field to @code{#f}, initialize user
  7388. passwords as @code{root} with the @command{passwd} command, and then let
  7389. users change it with @command{passwd}. Passwords set with
  7390. @command{passwd} are of course preserved across reboot and
  7391. reconfiguration.
  7392. If you @emph{do} want to have a preset password for an account, then
  7393. this field must contain the encrypted password, as a string.
  7394. @xref{crypt,,, libc, The GNU C Library Reference Manual}, for more information
  7395. on password encryption, and @ref{Encryption,,, guile, GNU Guile Reference
  7396. Manual}, for information on Guile's @code{crypt} procedure.
  7397. @end table
  7398. @end deftp
  7399. @cindex groups
  7400. User group declarations are even simpler:
  7401. @example
  7402. (user-group (name "students"))
  7403. @end example
  7404. @deftp {Data Type} user-group
  7405. This type is for, well, user groups. There are just a few fields:
  7406. @table @asis
  7407. @item @code{name}
  7408. The name of the group.
  7409. @item @code{id} (default: @code{#f})
  7410. The group identifier (a number). If @code{#f}, a new number is
  7411. automatically allocated when the group is created.
  7412. @item @code{system?} (default: @code{#f})
  7413. This Boolean value indicates whether the group is a ``system'' group.
  7414. System groups have low numerical IDs.
  7415. @item @code{password} (default: @code{#f})
  7416. What, user groups can have a password? Well, apparently yes. Unless
  7417. @code{#f}, this field specifies the password of the group.
  7418. @end table
  7419. @end deftp
  7420. For convenience, a variable lists all the basic user groups one may
  7421. expect:
  7422. @defvr {Scheme Variable} %base-groups
  7423. This is the list of basic user groups that users and/or packages expect
  7424. to be present on the system. This includes groups such as ``root'',
  7425. ``wheel'', and ``users'', as well as groups used to control access to
  7426. specific devices such as ``audio'', ``disk'', and ``cdrom''.
  7427. @end defvr
  7428. @defvr {Scheme Variable} %base-user-accounts
  7429. This is the list of basic system accounts that programs may expect to
  7430. find on a GNU/Linux system, such as the ``nobody'' account.
  7431. Note that the ``root'' account is not included here. It is a
  7432. special-case and is automatically added whether or not it is specified.
  7433. @end defvr
  7434. @node Locales
  7435. @subsection Locales
  7436. @cindex locale
  7437. A @dfn{locale} defines cultural conventions for a particular language
  7438. and region of the world (@pxref{Locales,,, libc, The GNU C Library
  7439. Reference Manual}). Each locale has a name that typically has the form
  7440. @code{@var{language}_@var{territory}.@var{codeset}}---e.g.,
  7441. @code{fr_LU.utf8} designates the locale for the French language, with
  7442. cultural conventions from Luxembourg, and using the UTF-8 encoding.
  7443. @cindex locale definition
  7444. Usually, you will want to specify the default locale for the machine
  7445. using the @code{locale} field of the @code{operating-system} declaration
  7446. (@pxref{operating-system Reference, @code{locale}}).
  7447. The selected locale is automatically added to the @dfn{locale
  7448. definitions} known to the system if needed, with its codeset inferred
  7449. from its name---e.g., @code{bo_CN.utf8} will be assumed to use the
  7450. @code{UTF-8} codeset. Additional locale definitions can be specified in
  7451. the @code{locale-definitions} slot of @code{operating-system}---this is
  7452. useful, for instance, if the codeset could not be inferred from the
  7453. locale name. The default set of locale definitions includes some widely
  7454. used locales, but not all the available locales, in order to save space.
  7455. For instance, to add the North Frisian locale for Germany, the value of
  7456. that field may be:
  7457. @example
  7458. (cons (locale-definition
  7459. (name "fy_DE.utf8") (source "fy_DE"))
  7460. %default-locale-definitions)
  7461. @end example
  7462. Likewise, to save space, one might want @code{locale-definitions} to
  7463. list only the locales that are actually used, as in:
  7464. @example
  7465. (list (locale-definition
  7466. (name "ja_JP.eucjp") (source "ja_JP")
  7467. (charset "EUC-JP")))
  7468. @end example
  7469. @vindex LOCPATH
  7470. The compiled locale definitions are available at
  7471. @file{/run/current-system/locale/X.Y}, where @code{X.Y} is the libc
  7472. version, which is the default location where the GNU@tie{}libc provided
  7473. by Guix looks for locale data. This can be overridden using the
  7474. @code{LOCPATH} environment variable (@pxref{locales-and-locpath,
  7475. @code{LOCPATH} and locale packages}).
  7476. The @code{locale-definition} form is provided by the @code{(gnu system
  7477. locale)} module. Details are given below.
  7478. @deftp {Data Type} locale-definition
  7479. This is the data type of a locale definition.
  7480. @table @asis
  7481. @item @code{name}
  7482. The name of the locale. @xref{Locale Names,,, libc, The GNU C Library
  7483. Reference Manual}, for more information on locale names.
  7484. @item @code{source}
  7485. The name of the source for that locale. This is typically the
  7486. @code{@var{language}_@var{territory}} part of the locale name.
  7487. @item @code{charset} (default: @code{"UTF-8"})
  7488. The ``character set'' or ``code set'' for that locale,
  7489. @uref{http://www.iana.org/assignments/character-sets, as defined by
  7490. IANA}.
  7491. @end table
  7492. @end deftp
  7493. @defvr {Scheme Variable} %default-locale-definitions
  7494. A list of commonly used UTF-8 locales, used as the default
  7495. value of the @code{locale-definitions} field of @code{operating-system}
  7496. declarations.
  7497. @cindex locale name
  7498. @cindex normalized codeset in locale names
  7499. These locale definitions use the @dfn{normalized codeset} for the part
  7500. that follows the dot in the name (@pxref{Using gettextized software,
  7501. normalized codeset,, libc, The GNU C Library Reference Manual}). So for
  7502. instance it has @code{uk_UA.utf8} but @emph{not}, say,
  7503. @code{uk_UA.UTF-8}.
  7504. @end defvr
  7505. @subsubsection Locale Data Compatibility Considerations
  7506. @cindex incompatibility, of locale data
  7507. @code{operating-system} declarations provide a @code{locale-libcs} field
  7508. to specify the GNU@tie{}libc packages that are used to compile locale
  7509. declarations (@pxref{operating-system Reference}). ``Why would I
  7510. care?'', you may ask. Well, it turns out that the binary format of
  7511. locale data is occasionally incompatible from one libc version to
  7512. another.
  7513. @c See <https://sourceware.org/ml/libc-alpha/2015-09/msg00575.html>
  7514. @c and <https://lists.gnu.org/archive/html/guix-devel/2015-08/msg00737.html>.
  7515. For instance, a program linked against libc version 2.21 is unable to
  7516. read locale data produced with libc 2.22; worse, that program
  7517. @emph{aborts} instead of simply ignoring the incompatible locale
  7518. data@footnote{Versions 2.23 and later of GNU@tie{}libc will simply skip
  7519. the incompatible locale data, which is already an improvement.}.
  7520. Similarly, a program linked against libc 2.22 can read most, but not
  7521. all, of the locale data from libc 2.21 (specifically, @code{LC_COLLATE}
  7522. data is incompatible); thus calls to @code{setlocale} may fail, but
  7523. programs will not abort.
  7524. The ``problem'' in GuixSD is that users have a lot of freedom: They can
  7525. choose whether and when to upgrade software in their profiles, and might
  7526. be using a libc version different from the one the system administrator
  7527. used to build the system-wide locale data.
  7528. Fortunately, unprivileged users can also install their own locale data
  7529. and define @var{GUIX_LOCPATH} accordingly (@pxref{locales-and-locpath,
  7530. @code{GUIX_LOCPATH} and locale packages}).
  7531. Still, it is best if the system-wide locale data at
  7532. @file{/run/current-system/locale} is built for all the libc versions
  7533. actually in use on the system, so that all the programs can access
  7534. it---this is especially crucial on a multi-user system. To do that, the
  7535. administrator can specify several libc packages in the
  7536. @code{locale-libcs} field of @code{operating-system}:
  7537. @example
  7538. (use-package-modules base)
  7539. (operating-system
  7540. ;; @dots{}
  7541. (locale-libcs (list glibc-2.21 (canonical-package glibc))))
  7542. @end example
  7543. This example would lead to a system containing locale definitions for
  7544. both libc 2.21 and the current version of libc in
  7545. @file{/run/current-system/locale}.
  7546. @node Services
  7547. @subsection Services
  7548. @cindex system services
  7549. An important part of preparing an @code{operating-system} declaration is
  7550. listing @dfn{system services} and their configuration (@pxref{Using the
  7551. Configuration System}). System services are typically daemons launched
  7552. when the system boots, or other actions needed at that time---e.g.,
  7553. configuring network access.
  7554. GuixSD has a broad definition of ``service'' (@pxref{Service
  7555. Composition}), but many services are managed by the GNU@tie{}Shepherd
  7556. (@pxref{Shepherd Services}). On a running system, the @command{herd}
  7557. command allows you to list the available services, show their status,
  7558. start and stop them, or do other specific operations (@pxref{Jump
  7559. Start,,, shepherd, The GNU Shepherd Manual}). For example:
  7560. @example
  7561. # herd status
  7562. @end example
  7563. The above command, run as @code{root}, lists the currently defined
  7564. services. The @command{herd doc} command shows a synopsis of the given
  7565. service:
  7566. @example
  7567. # herd doc nscd
  7568. Run libc's name service cache daemon (nscd).
  7569. @end example
  7570. The @command{start}, @command{stop}, and @command{restart} sub-commands
  7571. have the effect you would expect. For instance, the commands below stop
  7572. the nscd service and restart the Xorg display server:
  7573. @example
  7574. # herd stop nscd
  7575. Service nscd has been stopped.
  7576. # herd restart xorg-server
  7577. Service xorg-server has been stopped.
  7578. Service xorg-server has been started.
  7579. @end example
  7580. The following sections document the available services, starting with
  7581. the core services, that may be used in an @code{operating-system}
  7582. declaration.
  7583. @menu
  7584. * Base Services:: Essential system services.
  7585. * Scheduled Job Execution:: The mcron service.
  7586. * Log Rotation:: The rottlog service.
  7587. * Networking Services:: Network setup, SSH daemon, etc.
  7588. * X Window:: Graphical display.
  7589. * Printing Services:: Local and remote printer support.
  7590. * Desktop Services:: D-Bus and desktop services.
  7591. * Database Services:: SQL databases, key-value stores, etc.
  7592. * Mail Services:: IMAP, POP3, SMTP, and all that.
  7593. * Messaging Services:: Messaging services.
  7594. * Telephony Services:: Telephony services.
  7595. * Monitoring Services:: Monitoring services.
  7596. * Kerberos Services:: Kerberos services.
  7597. * Web Services:: Web servers.
  7598. * Certificate Services:: TLS certificates via Let's Encrypt.
  7599. * DNS Services:: DNS daemons.
  7600. * VPN Services:: VPN daemons.
  7601. * Network File System:: NFS related services.
  7602. * Continuous Integration:: The Cuirass service.
  7603. * Power management Services:: The TLP tool.
  7604. * Audio Services:: The MPD.
  7605. * Virtualization Services:: Virtualization services.
  7606. * Version Control Services:: Providing remote access to Git repositories.
  7607. * Miscellaneous Services:: Other services.
  7608. @end menu
  7609. @node Base Services
  7610. @subsubsection Base Services
  7611. The @code{(gnu services base)} module provides definitions for the basic
  7612. services that one expects from the system. The services exported by
  7613. this module are listed below.
  7614. @defvr {Scheme Variable} %base-services
  7615. This variable contains a list of basic services (@pxref{Service Types
  7616. and Services}, for more information on service objects) one would
  7617. expect from the system: a login service (mingetty) on each tty, syslogd,
  7618. the libc name service cache daemon (nscd), the udev device manager, and
  7619. more.
  7620. This is the default value of the @code{services} field of
  7621. @code{operating-system} declarations. Usually, when customizing a
  7622. system, you will want to append services to @var{%base-services}, like
  7623. this:
  7624. @example
  7625. (cons* (avahi-service) (lsh-service) %base-services)
  7626. @end example
  7627. @end defvr
  7628. @defvr {Scheme Variable} special-files-service-type
  7629. This is the service that sets up ``special files'' such as
  7630. @file{/bin/sh}; an instance of it is part of @code{%base-services}.
  7631. The value associated with @code{special-files-service-type} services
  7632. must be a list of tuples where the first element is the ``special file''
  7633. and the second element is its target. By default it is:
  7634. @cindex @file{/bin/sh}
  7635. @cindex @file{sh}, in @file{/bin}
  7636. @example
  7637. `(("/bin/sh" ,(file-append @var{bash} "/bin/sh")))
  7638. @end example
  7639. @cindex @file{/usr/bin/env}
  7640. @cindex @file{env}, in @file{/usr/bin}
  7641. If you want to add, say, @code{/usr/bin/env} to your system, you can
  7642. change it to:
  7643. @example
  7644. `(("/bin/sh" ,(file-append @var{bash} "/bin/sh"))
  7645. ("/usr/bin/env" ,(file-append @var{coreutils} "/bin/env")))
  7646. @end example
  7647. Since this is part of @code{%base-services}, you can use
  7648. @code{modify-services} to customize the set of special files
  7649. (@pxref{Service Reference, @code{modify-services}}). But the simple way
  7650. to add a special file is @i{via} the @code{extra-special-file} procedure
  7651. (see below.)
  7652. @end defvr
  7653. @deffn {Scheme Procedure} extra-special-file @var{file} @var{target}
  7654. Use @var{target} as the ``special file'' @var{file}.
  7655. For example, adding the following lines to the @code{services} field of
  7656. your operating system declaration leads to a @file{/usr/bin/env}
  7657. symlink:
  7658. @example
  7659. (extra-special-file "/usr/bin/env"
  7660. (file-append coreutils "/bin/env"))
  7661. @end example
  7662. @end deffn
  7663. @deffn {Scheme Procedure} host-name-service @var{name}
  7664. Return a service that sets the host name to @var{name}.
  7665. @end deffn
  7666. @deffn {Scheme Procedure} login-service @var{config}
  7667. Return a service to run login according to @var{config}, a
  7668. @code{<login-configuration>} object, which specifies the message of the day,
  7669. among other things.
  7670. @end deffn
  7671. @deftp {Data Type} login-configuration
  7672. This is the data type representing the configuration of login.
  7673. @table @asis
  7674. @item @code{motd}
  7675. @cindex message of the day
  7676. A file-like object containing the ``message of the day''.
  7677. @item @code{allow-empty-passwords?} (default: @code{#t})
  7678. Allow empty passwords by default so that first-time users can log in when
  7679. the 'root' account has just been created.
  7680. @end table
  7681. @end deftp
  7682. @deffn {Scheme Procedure} mingetty-service @var{config}
  7683. Return a service to run mingetty according to @var{config}, a
  7684. @code{<mingetty-configuration>} object, which specifies the tty to run, among
  7685. other things.
  7686. @end deffn
  7687. @deftp {Data Type} mingetty-configuration
  7688. This is the data type representing the configuration of Mingetty, which
  7689. provides the default implementation of virtual console log-in.
  7690. @table @asis
  7691. @item @code{tty}
  7692. The name of the console this Mingetty runs on---e.g., @code{"tty1"}.
  7693. @item @code{auto-login} (default: @code{#f})
  7694. When true, this field must be a string denoting the user name under
  7695. which the system automatically logs in. When it is @code{#f}, a
  7696. user name and password must be entered to log in.
  7697. @item @code{login-program} (default: @code{#f})
  7698. This must be either @code{#f}, in which case the default log-in program
  7699. is used (@command{login} from the Shadow tool suite), or a gexp denoting
  7700. the name of the log-in program.
  7701. @item @code{login-pause?} (default: @code{#f})
  7702. When set to @code{#t} in conjunction with @var{auto-login}, the user
  7703. will have to press a key before the log-in shell is launched.
  7704. @item @code{mingetty} (default: @var{mingetty})
  7705. The Mingetty package to use.
  7706. @end table
  7707. @end deftp
  7708. @deffn {Scheme Procedure} agetty-service @var{config}
  7709. Return a service to run agetty according to @var{config}, an
  7710. @code{<agetty-configuration>} object, which specifies the tty to run,
  7711. among other things.
  7712. @end deffn
  7713. @deftp {Data Type} agetty-configuration
  7714. This is the data type representing the configuration of agetty, which
  7715. implements virtual and serial console log-in. See the @code{agetty(8)}
  7716. man page for more information.
  7717. @table @asis
  7718. @item @code{tty}
  7719. The name of the console this agetty runs on, as a string---e.g.,
  7720. @code{"ttyS0"}. This argument is mandatory.
  7721. @item @code{baud-rate} (default: @code{#f})
  7722. A string containing a comma-separated list of one or more baud rates, in
  7723. descending order.
  7724. @item @code{term} (default: @code{#f})
  7725. A string containing the value used for the @code{TERM} environment
  7726. variable.
  7727. @item @code{eight-bits?} (default: @code{#f})
  7728. When @code{#t}, the tty is assumed to be 8-bit clean, and parity detection is
  7729. disabled.
  7730. @item @code{auto-login} (default: @code{#f})
  7731. When passed a login name, as a string, the specified user will be logged
  7732. in automatically without prompting for their login name or password.
  7733. @item @code{no-reset?} (default: @code{#f})
  7734. When @code{#t}, don't reset terminal cflags (control modes).
  7735. @item @code{host} (default: @code{#f})
  7736. This accepts a string containing the "login_host", which will be written
  7737. into the @file{/var/run/utmpx} file.
  7738. @item @code{remote?} (default: @code{#f})
  7739. When set to @code{#t} in conjunction with @var{host}, this will add an
  7740. @code{-r} fakehost option to the command line of the login program
  7741. specified in @var{login-program}.
  7742. @item @code{flow-control?} (default: @code{#f})
  7743. When set to @code{#t}, enable hardware (RTS/CTS) flow control.
  7744. @item @code{no-issue?} (default: @code{#f})
  7745. When set to @code{#t}, the contents of the @file{/etc/issue} file will
  7746. not be displayed before presenting the login prompt.
  7747. @item @code{init-string} (default: @code{#f})
  7748. This accepts a string that will be sent to the tty or modem before
  7749. sending anything else. It can be used to initialize a modem.
  7750. @item @code{no-clear?} (default: @code{#f})
  7751. When set to @code{#t}, agetty will not clear the screen before showing
  7752. the login prompt.
  7753. @item @code{login-program} (default: (file-append shadow "/bin/login"))
  7754. This must be either a gexp denoting the name of a log-in program, or
  7755. unset, in which case the default value is the @command{login} from the
  7756. Shadow tool suite.
  7757. @item @code{local-line} (default: @code{#f})
  7758. Control the CLOCAL line flag. This accepts one of three symbols as
  7759. arguments, @code{'auto}, @code{'always}, or @code{'never}. If @code{#f},
  7760. the default value chosen by agetty is @code{'auto}.
  7761. @item @code{extract-baud?} (default: @code{#f})
  7762. When set to @code{#t}, instruct agetty to try to extract the baud rate
  7763. from the status messages produced by certain types of modems.
  7764. @item @code{skip-login?} (default: @code{#f})
  7765. When set to @code{#t}, do not prompt the user for a login name. This
  7766. can be used with @var{login-program} field to use non-standard login
  7767. systems.
  7768. @item @code{no-newline?} (default: @code{#f})
  7769. When set to @code{#t}, do not print a newline before printing the
  7770. @file{/etc/issue} file.
  7771. @c Is this dangerous only when used with login-program, or always?
  7772. @item @code{login-options} (default: @code{#f})
  7773. This option accepts a string containing options that are passed to the
  7774. login program. When used with the @var{login-program}, be aware that a
  7775. malicious user could try to enter a login name containing embedded
  7776. options that could be parsed by the login program.
  7777. @item @code{login-pause} (default: @code{#f})
  7778. When set to @code{#t}, wait for any key before showing the login prompt.
  7779. This can be used in conjunction with @var{auto-login} to save memory by
  7780. lazily spawning shells.
  7781. @item @code{chroot} (default: @code{#f})
  7782. Change root to the specified directory. This option accepts a directory
  7783. path as a string.
  7784. @item @code{hangup?} (default: @code{#f})
  7785. Use the Linux system call @code{vhangup} to do a virtual hangup of the
  7786. specified terminal.
  7787. @item @code{keep-baud?} (default: @code{#f})
  7788. When set to @code{#t}, try to keep the existing baud rate. The baud
  7789. rates from @var{baud-rate} are used when agetty receives a @key{BREAK}
  7790. character.
  7791. @item @code{timeout} (default: @code{#f})
  7792. When set to an integer value, terminate if no user name could be read
  7793. within @var{timeout} seconds.
  7794. @item @code{detect-case?} (default: @code{#f})
  7795. When set to @code{#t}, turn on support for detecting an uppercase-only
  7796. terminal. This setting will detect a login name containing only
  7797. uppercase letters as indicating an uppercase-only terminal and turn on
  7798. some upper-to-lower case conversions. Note that this will not support
  7799. Unicode characters.
  7800. @item @code{wait-cr?} (default: @code{#f})
  7801. When set to @code{#t}, wait for the user or modem to send a
  7802. carriage-return or linefeed character before displaying
  7803. @file{/etc/issue} or login prompt. This is typically used with the
  7804. @var{init-string} option.
  7805. @item @code{no-hints?} (default: @code{#f})
  7806. When set to @code{#t}, do not print hints about Num, Caps, and Scroll
  7807. locks.
  7808. @item @code{no-hostname?} (default: @code{#f})
  7809. By default, the hostname is printed. When this option is set to
  7810. @code{#t}, no hostname will be shown at all.
  7811. @item @code{long-hostname?} (default: @code{#f})
  7812. By default, the hostname is only printed until the first dot. When this
  7813. option is set to @code{#t}, the fully qualified hostname by
  7814. @code{gethostname} or @code{getaddrinfo} is shown.
  7815. @item @code{erase-characters} (default: @code{#f})
  7816. This option accepts a string of additional characters that should be
  7817. interpreted as backspace when the user types their login name.
  7818. @item @code{kill-characters} (default: @code{#f})
  7819. This option accepts a string that should be interpreted to mean "ignore
  7820. all previous characters" (also called a "kill" character) when the types
  7821. their login name.
  7822. @item @code{chdir} (default: @code{#f})
  7823. This option accepts, as a string, a directory path that will be changed
  7824. to before login.
  7825. @item @code{delay} (default: @code{#f})
  7826. This options accepts, as an integer, the number of seconds to sleep
  7827. before opening the tty and displaying the login prompt.
  7828. @item @code{nice} (default: @code{#f})
  7829. This option accepts, as an integer, the nice value with which to run the
  7830. @command{login} program.
  7831. @item @code{extra-options} (default: @code{'()})
  7832. This option provides an "escape hatch" for the user to provide arbitrary
  7833. command-line arguments to @command{agetty} as a list of strings.
  7834. @end table
  7835. @end deftp
  7836. @deffn {Scheme Procedure} kmscon-service-type @var{config}
  7837. Return a service to run @uref{https://www.freedesktop.org/wiki/Software/kmscon,kmscon}
  7838. according to @var{config}, a @code{<kmscon-configuration>} object, which
  7839. specifies the tty to run, among other things.
  7840. @end deffn
  7841. @deftp {Data Type} kmscon-configuration
  7842. This is the data type representing the configuration of Kmscon, which
  7843. implements virtual console log-in.
  7844. @table @asis
  7845. @item @code{virtual-terminal}
  7846. The name of the console this Kmscon runs on---e.g., @code{"tty1"}.
  7847. @item @code{login-program} (default: @code{#~(string-append #$shadow "/bin/login")})
  7848. A gexp denoting the name of the log-in program. The default log-in program is
  7849. @command{login} from the Shadow tool suite.
  7850. @item @code{login-arguments} (default: @code{'("-p")})
  7851. A list of arguments to pass to @command{login}.
  7852. @item @code{hardware-acceleration?} (default: #f)
  7853. Whether to use hardware acceleration.
  7854. @item @code{kmscon} (default: @var{kmscon})
  7855. The Kmscon package to use.
  7856. @end table
  7857. @end deftp
  7858. @cindex name service cache daemon
  7859. @cindex nscd
  7860. @deffn {Scheme Procedure} nscd-service [@var{config}] [#:glibc glibc] @
  7861. [#:name-services '()]
  7862. Return a service that runs the libc name service cache daemon (nscd) with the
  7863. given @var{config}---an @code{<nscd-configuration>} object. @xref{Name
  7864. Service Switch}, for an example.
  7865. @end deffn
  7866. @defvr {Scheme Variable} %nscd-default-configuration
  7867. This is the default @code{<nscd-configuration>} value (see below) used
  7868. by @code{nscd-service}. It uses the caches defined by
  7869. @var{%nscd-default-caches}; see below.
  7870. @end defvr
  7871. @deftp {Data Type} nscd-configuration
  7872. This is the data type representing the name service cache daemon (nscd)
  7873. configuration.
  7874. @table @asis
  7875. @item @code{name-services} (default: @code{'()})
  7876. List of packages denoting @dfn{name services} that must be visible to
  7877. the nscd---e.g., @code{(list @var{nss-mdns})}.
  7878. @item @code{glibc} (default: @var{glibc})
  7879. Package object denoting the GNU C Library providing the @command{nscd}
  7880. command.
  7881. @item @code{log-file} (default: @code{"/var/log/nscd.log"})
  7882. Name of the nscd log file. This is where debugging output goes when
  7883. @code{debug-level} is strictly positive.
  7884. @item @code{debug-level} (default: @code{0})
  7885. Integer denoting the debugging levels. Higher numbers mean that more
  7886. debugging output is logged.
  7887. @item @code{caches} (default: @var{%nscd-default-caches})
  7888. List of @code{<nscd-cache>} objects denoting things to be cached; see
  7889. below.
  7890. @end table
  7891. @end deftp
  7892. @deftp {Data Type} nscd-cache
  7893. Data type representing a cache database of nscd and its parameters.
  7894. @table @asis
  7895. @item @code{database}
  7896. This is a symbol representing the name of the database to be cached.
  7897. Valid values are @code{passwd}, @code{group}, @code{hosts}, and
  7898. @code{services}, which designate the corresponding NSS database
  7899. (@pxref{NSS Basics,,, libc, The GNU C Library Reference Manual}).
  7900. @item @code{positive-time-to-live}
  7901. @itemx @code{negative-time-to-live} (default: @code{20})
  7902. A number representing the number of seconds during which a positive or
  7903. negative lookup result remains in cache.
  7904. @item @code{check-files?} (default: @code{#t})
  7905. Whether to check for updates of the files corresponding to
  7906. @var{database}.
  7907. For instance, when @var{database} is @code{hosts}, setting this flag
  7908. instructs nscd to check for updates in @file{/etc/hosts} and to take
  7909. them into account.
  7910. @item @code{persistent?} (default: @code{#t})
  7911. Whether the cache should be stored persistently on disk.
  7912. @item @code{shared?} (default: @code{#t})
  7913. Whether the cache should be shared among users.
  7914. @item @code{max-database-size} (default: 32@tie{}MiB)
  7915. Maximum size in bytes of the database cache.
  7916. @c XXX: 'suggested-size' and 'auto-propagate?' seem to be expert
  7917. @c settings, so leave them out.
  7918. @end table
  7919. @end deftp
  7920. @defvr {Scheme Variable} %nscd-default-caches
  7921. List of @code{<nscd-cache>} objects used by default by
  7922. @code{nscd-configuration} (see above).
  7923. It enables persistent and aggressive caching of service and host name
  7924. lookups. The latter provides better host name lookup performance,
  7925. resilience in the face of unreliable name servers, and also better
  7926. privacy---often the result of host name lookups is in local cache, so
  7927. external name servers do not even need to be queried.
  7928. @end defvr
  7929. @anchor{syslog-configuration-type}
  7930. @cindex syslog
  7931. @cindex logging
  7932. @deftp {Data Type} syslog-configuration
  7933. This data type represents the configuration of the syslog daemon.
  7934. @table @asis
  7935. @item @code{syslogd} (default: @code{#~(string-append #$inetutils "/libexec/syslogd")})
  7936. The syslog daemon to use.
  7937. @item @code{config-file} (default: @code{%default-syslog.conf})
  7938. The syslog configuration file to use.
  7939. @end table
  7940. @end deftp
  7941. @anchor{syslog-service}
  7942. @cindex syslog
  7943. @deffn {Scheme Procedure} syslog-service @var{config}
  7944. Return a service that runs a syslog daemon according to @var{config}.
  7945. @xref{syslogd invocation,,, inetutils, GNU Inetutils}, for more
  7946. information on the configuration file syntax.
  7947. @end deffn
  7948. @anchor{guix-configuration-type}
  7949. @deftp {Data Type} guix-configuration
  7950. This data type represents the configuration of the Guix build daemon.
  7951. @xref{Invoking guix-daemon}, for more information.
  7952. @table @asis
  7953. @item @code{guix} (default: @var{guix})
  7954. The Guix package to use.
  7955. @item @code{build-group} (default: @code{"guixbuild"})
  7956. Name of the group for build user accounts.
  7957. @item @code{build-accounts} (default: @code{10})
  7958. Number of build user accounts to create.
  7959. @item @code{authorize-key?} (default: @code{#t})
  7960. @cindex substitutes, authorization thereof
  7961. Whether to authorize the substitute keys listed in
  7962. @code{authorized-keys}---by default that of @code{hydra.gnu.org}
  7963. (@pxref{Substitutes}).
  7964. @vindex %default-authorized-guix-keys
  7965. @item @code{authorized-keys} (default: @var{%default-authorized-guix-keys})
  7966. The list of authorized key files for archive imports, as a list of
  7967. string-valued gexps (@pxref{Invoking guix archive}). By default, it
  7968. contains that of @code{hydra.gnu.org} (@pxref{Substitutes}).
  7969. @item @code{use-substitutes?} (default: @code{#t})
  7970. Whether to use substitutes.
  7971. @item @code{substitute-urls} (default: @var{%default-substitute-urls})
  7972. The list of URLs where to look for substitutes by default.
  7973. @item @code{max-silent-time} (default: @code{0})
  7974. @itemx @code{timeout} (default: @code{0})
  7975. The number of seconds of silence and the number of seconds of activity,
  7976. respectively, after which a build process times out. A value of zero
  7977. disables the timeout.
  7978. @item @code{log-compression} (default: @code{'bzip2})
  7979. The type of compression used for build logs---one of @code{gzip},
  7980. @code{bzip2}, or @code{none}.
  7981. @item @code{extra-options} (default: @code{'()})
  7982. List of extra command-line options for @command{guix-daemon}.
  7983. @item @code{log-file} (default: @code{"/var/log/guix-daemon.log"})
  7984. File where @command{guix-daemon}'s standard output and standard error
  7985. are written.
  7986. @item @code{http-proxy} (default: @code{#f})
  7987. The HTTP proxy used for downloading fixed-output derivations and
  7988. substitutes.
  7989. @item @code{tmpdir} (default: @code{#f})
  7990. A directory path where the @command{guix-daemon} will perform builds.
  7991. @end table
  7992. @end deftp
  7993. @deffn {Scheme Procedure} guix-service @var{config}
  7994. Return a service that runs the Guix build daemon according to
  7995. @var{config}.
  7996. @end deffn
  7997. @deffn {Scheme Procedure} udev-service [#:udev @var{eudev} #:rules @code{'()}]
  7998. Run @var{udev}, which populates the @file{/dev} directory dynamically.
  7999. udev rules can be provided as a list of files through the @var{rules}
  8000. variable. The procedures @var{udev-rule} and @var{file->udev-rule} from
  8001. @code{(gnu services base)} simplify the creation of such rule files.
  8002. @deffn {Scheme Procedure} udev-rule [@var{file-name} @var{contents}]
  8003. Return a udev-rule file named @var{file-name} containing the rules
  8004. defined by the @var{contents} literal.
  8005. In the following example, a rule for a USB device is defined to be
  8006. stored in the file @file{90-usb-thing.rules}. The rule runs a script
  8007. upon detecting a USB device with a given product identifier.
  8008. @example
  8009. (define %example-udev-rule
  8010. (udev-rule
  8011. "90-usb-thing.rules"
  8012. (string-append "ACTION==\"add\", SUBSYSTEM==\"usb\", "
  8013. "ATTR@{product@}==\"Example\", "
  8014. "RUN+=\"/path/to/script\"")))
  8015. @end example
  8016. @end deffn
  8017. Here we show how the default @var{udev-service} can be extended with it.
  8018. @example
  8019. (operating-system
  8020. ;; @dots{}
  8021. (services
  8022. (modify-services %desktop-services
  8023. (udev-service-type config =>
  8024. (udev-configuration (inherit config)
  8025. (rules (append (udev-configuration-rules config)
  8026. (list %example-udev-rule))))))))
  8027. @end example
  8028. @deffn {Scheme Procedure} file->udev-rule [@var{file-name} @var{file}]
  8029. Return a udev file named @var{file-name} containing the rules defined
  8030. within @var{file}, a file-like object.
  8031. The following example showcases how we can use an existing rule file.
  8032. @example
  8033. (use-modules (guix download) ;for url-fetch
  8034. (guix packages) ;for origin
  8035. ;; @dots{})
  8036. (define %android-udev-rules
  8037. (file->udev-rule
  8038. "51-android-udev.rules"
  8039. (let ((version "20170910"))
  8040. (origin
  8041. (method url-fetch)
  8042. (uri (string-append "https://raw.githubusercontent.com/M0Rf30/"
  8043. "android-udev-rules/" version "/51-android.rules"))
  8044. (sha256
  8045. (base32 "0lmmagpyb6xsq6zcr2w1cyx9qmjqmajkvrdbhjx32gqf1d9is003"))))))
  8046. @end example
  8047. @end deffn
  8048. Additionally, Guix package definitions can be included in @var{rules} in
  8049. order to extend the udev rules with the definitions found under their
  8050. @file{lib/udev/rules.d} sub-directory. In lieu of the previous
  8051. @var{file->udev-rule} example, we could have used the
  8052. @var{android-udev-rules} package which exists in Guix in the @code{(gnu
  8053. packages android)} module.
  8054. The following example shows how to use the @var{android-udev-rules}
  8055. package so that the Android tool @command{adb} can detect devices
  8056. without root privileges. It also details how to create the
  8057. @code{adbusers} group, which is required for the proper functioning of
  8058. the rules defined within the @var{android-udev-rules} package. To
  8059. create such a group, we must define it both as part of the
  8060. @var{supplementary-groups} of our @var{user-account} declaration, as
  8061. well as in the @var{groups} field of the @var{operating-system} record.
  8062. @example
  8063. (use-modules (gnu packages android) ;for android-udev-rules
  8064. (gnu system shadow) ;for user-group
  8065. ;; @dots{})
  8066. (operating-system
  8067. ;; @dots{}
  8068. (users (cons (user-acount
  8069. ;; @dots{}
  8070. (supplementary-groups
  8071. '("adbusers" ;for adb
  8072. "wheel" "netdev" "audio" "video"))
  8073. ;; @dots{})))
  8074. (groups (cons (user-group (system? #t) (name "adbusers"))
  8075. %base-groups))
  8076. ;; @dots{}
  8077. (services
  8078. (modify-services %desktop-services
  8079. (udev-service-type config =>
  8080. (udev-configuration (inherit config)
  8081. (rules (cons* android-udev-rules
  8082. (udev-configuration-rules config))))))))
  8083. @end example
  8084. @end deffn
  8085. @defvr {Scheme Variable} urandom-seed-service-type
  8086. Save some entropy in @var{%random-seed-file} to seed @file{/dev/urandom}
  8087. when rebooting. It also tries to seed @file{/dev/urandom} from
  8088. @file{/dev/hwrng} while booting, if @file{/dev/hwrng} exists and is
  8089. readable.
  8090. @end defvr
  8091. @defvr {Scheme Variable} %random-seed-file
  8092. This is the name of the file where some random bytes are saved by
  8093. @var{urandom-seed-service} to seed @file{/dev/urandom} when rebooting.
  8094. It defaults to @file{/var/lib/random-seed}.
  8095. @end defvr
  8096. @cindex keymap
  8097. @cindex keyboard
  8098. @deffn {Scheme Procedure} console-keymap-service @var{files} ...
  8099. @cindex keyboard layout
  8100. Return a service to load console keymaps from @var{files} using
  8101. @command{loadkeys} command. Most likely, you want to load some default
  8102. keymap, which can be done like this:
  8103. @example
  8104. (console-keymap-service "dvorak")
  8105. @end example
  8106. Or, for example, for a Swedish keyboard, you may need to combine
  8107. the following keymaps:
  8108. @example
  8109. (console-keymap-service "se-lat6" "se-fi-lat6")
  8110. @end example
  8111. Also you can specify a full file name (or file names) of your keymap(s).
  8112. See @code{man loadkeys} for details.
  8113. @end deffn
  8114. @cindex mouse
  8115. @cindex gpm
  8116. @deffn {Scheme Procedure} gpm-service [#:gpm @var{gpm}] @
  8117. [#:options]
  8118. Run @var{gpm}, the general-purpose mouse daemon, with the given
  8119. command-line @var{options}. GPM allows users to use the mouse in the console,
  8120. notably to select, copy, and paste text. The default value of @var{options}
  8121. uses the @code{ps2} protocol, which works for both USB and PS/2 mice.
  8122. This service is not part of @var{%base-services}.
  8123. @end deffn
  8124. @anchor{guix-publish-service-type}
  8125. @deffn {Scheme Variable} guix-publish-service-type
  8126. This is the service type for @command{guix publish} (@pxref{Invoking
  8127. guix publish}). Its value must be a @code{guix-configuration}
  8128. object, as described below.
  8129. This assumes that @file{/etc/guix} already contains a signing key pair as
  8130. created by @command{guix archive --generate-key} (@pxref{Invoking guix
  8131. archive}). If that is not the case, the service will fail to start.
  8132. @end deffn
  8133. @deftp {Data Type} guix-publish-configuration
  8134. Data type representing the configuration of the @code{guix publish}
  8135. service.
  8136. @table @asis
  8137. @item @code{guix} (default: @code{guix})
  8138. The Guix package to use.
  8139. @item @code{port} (default: @code{80})
  8140. The TCP port to listen for connections.
  8141. @item @code{host} (default: @code{"localhost"})
  8142. The host (and thus, network interface) to listen to. Use
  8143. @code{"0.0.0.0"} to listen on all the network interfaces.
  8144. @item @code{compression-level} (default: @code{3})
  8145. The gzip compression level at which substitutes are compressed. Use
  8146. @code{0} to disable compression altogether, and @code{9} to get the best
  8147. compression ratio at the expense of increased CPU usage.
  8148. @item @code{nar-path} (default: @code{"nar"})
  8149. The URL path at which ``nars'' can be fetched. @xref{Invoking guix
  8150. publish, @code{--nar-path}}, for details.
  8151. @item @code{cache} (default: @code{#f})
  8152. When it is @code{#f}, disable caching and instead generate archives on
  8153. demand. Otherwise, this should be the name of a directory---e.g.,
  8154. @code{"/var/cache/guix/publish"}---where @command{guix publish} caches
  8155. archives and meta-data ready to be sent. @xref{Invoking guix publish,
  8156. @option{--cache}}, for more information on the tradeoffs involved.
  8157. @item @code{workers} (default: @code{#f})
  8158. When it is an integer, this is the number of worker threads used for
  8159. caching; when @code{#f}, the number of processors is used.
  8160. @xref{Invoking guix publish, @option{--workers}}, for more information.
  8161. @item @code{ttl} (default: @code{#f})
  8162. When it is an integer, this denotes the @dfn{time-to-live} of the
  8163. published archives. @xref{Invoking guix publish, @option{--ttl}}, for
  8164. more information.
  8165. @end table
  8166. @end deftp
  8167. @anchor{rngd-service}
  8168. @deffn {Scheme Procedure} rngd-service [#:rng-tools @var{rng-tools}] @
  8169. [#:device "/dev/hwrng"]
  8170. Return a service that runs the @command{rngd} program from @var{rng-tools}
  8171. to add @var{device} to the kernel's entropy pool. The service will fail if
  8172. @var{device} does not exist.
  8173. @end deffn
  8174. @anchor{pam-limits-service}
  8175. @cindex session limits
  8176. @cindex ulimit
  8177. @cindex priority
  8178. @deffn {Scheme Procedure} pam-limits-service [#:limits @code{'()}]
  8179. Return a service that installs a configuration file for the
  8180. @uref{http://linux-pam.org/Linux-PAM-html/sag-pam_limits.html,
  8181. @code{pam_limits} module}. The procedure optionally takes a list of
  8182. @code{pam-limits-entry} values, which can be used to specify
  8183. @code{ulimit} limits and nice priority limits to user sessions.
  8184. The following limits definition sets two hard and soft limits for all
  8185. login sessions of users in the @code{realtime} group:
  8186. @example
  8187. (pam-limits-service
  8188. (list
  8189. (pam-limits-entry "@@realtime" 'both 'rtprio 99)
  8190. (pam-limits-entry "@@realtime" 'both 'memlock 'unlimited)))
  8191. @end example
  8192. The first entry increases the maximum realtime priority for
  8193. non-privileged processes; the second entry lifts any restriction of the
  8194. maximum address space that can be locked in memory. These settings are
  8195. commonly used for real-time audio systems.
  8196. @end deffn
  8197. @node Scheduled Job Execution
  8198. @subsubsection Scheduled Job Execution
  8199. @cindex cron
  8200. @cindex mcron
  8201. @cindex scheduling jobs
  8202. The @code{(gnu services mcron)} module provides an interface to
  8203. GNU@tie{}mcron, a daemon to run jobs at scheduled times (@pxref{Top,,,
  8204. mcron, GNU@tie{}mcron}). GNU@tie{}mcron is similar to the traditional
  8205. Unix @command{cron} daemon; the main difference is that it is
  8206. implemented in Guile Scheme, which provides a lot of flexibility when
  8207. specifying the scheduling of jobs and their actions.
  8208. The example below defines an operating system that runs the
  8209. @command{updatedb} (@pxref{Invoking updatedb,,, find, Finding Files})
  8210. and the @command{guix gc} commands (@pxref{Invoking guix gc}) daily, as
  8211. well as the @command{mkid} command on behalf of an unprivileged user
  8212. (@pxref{mkid invocation,,, idutils, ID Database Utilities}). It uses
  8213. gexps to introduce job definitions that are passed to mcron
  8214. (@pxref{G-Expressions}).
  8215. @lisp
  8216. (use-modules (guix) (gnu) (gnu services mcron))
  8217. (use-package-modules base idutils)
  8218. (define updatedb-job
  8219. ;; Run 'updatedb' at 3AM every day. Here we write the
  8220. ;; job's action as a Scheme procedure.
  8221. #~(job '(next-hour '(3))
  8222. (lambda ()
  8223. (execl (string-append #$findutils "/bin/updatedb")
  8224. "updatedb"
  8225. "--prunepaths=/tmp /var/tmp /gnu/store"))))
  8226. (define garbage-collector-job
  8227. ;; Collect garbage 5 minutes after midnight every day.
  8228. ;; The job's action is a shell command.
  8229. #~(job "5 0 * * *" ;Vixie cron syntax
  8230. "guix gc -F 1G"))
  8231. (define idutils-job
  8232. ;; Update the index database as user "charlie" at 12:15PM
  8233. ;; and 19:15PM. This runs from the user's home directory.
  8234. #~(job '(next-minute-from (next-hour '(12 19)) '(15))
  8235. (string-append #$idutils "/bin/mkid src")
  8236. #:user "charlie"))
  8237. (operating-system
  8238. ;; @dots{}
  8239. (services (cons (mcron-service (list garbage-collector-job
  8240. updatedb-job
  8241. idutils-job))
  8242. %base-services)))
  8243. @end lisp
  8244. @xref{Guile Syntax, mcron job specifications,, mcron, GNU@tie{}mcron},
  8245. for more information on mcron job specifications. Below is the
  8246. reference of the mcron service.
  8247. @deffn {Scheme Procedure} mcron-service @var{jobs} [#:mcron @var{mcron2}]
  8248. Return an mcron service running @var{mcron} that schedules @var{jobs}, a
  8249. list of gexps denoting mcron job specifications.
  8250. This is a shorthand for:
  8251. @example
  8252. (service mcron-service-type
  8253. (mcron-configuration (mcron mcron) (jobs jobs)))
  8254. @end example
  8255. @end deffn
  8256. @defvr {Scheme Variable} mcron-service-type
  8257. This is the type of the @code{mcron} service, whose value is an
  8258. @code{mcron-configuration} object.
  8259. This service type can be the target of a service extension that provides
  8260. it additional job specifications (@pxref{Service Composition}). In
  8261. other words, it is possible to define services that provide additional
  8262. mcron jobs to run.
  8263. @end defvr
  8264. @deftp {Data Type} mcron-configuration
  8265. Data type representing the configuration of mcron.
  8266. @table @asis
  8267. @item @code{mcron} (default: @var{mcron2})
  8268. The mcron package to use.
  8269. @item @code{jobs}
  8270. This is a list of gexps (@pxref{G-Expressions}), where each gexp
  8271. corresponds to an mcron job specification (@pxref{Syntax, mcron job
  8272. specifications,, mcron, GNU@tie{}mcron}).
  8273. @end table
  8274. @end deftp
  8275. @node Log Rotation
  8276. @subsubsection Log Rotation
  8277. @cindex rottlog
  8278. @cindex log rotation
  8279. @cindex logging
  8280. Log files such as those found in @file{/var/log} tend to grow endlessly,
  8281. so it's a good idea to @dfn{rotate} them once in a while---i.e., archive
  8282. their contents in separate files, possibly compressed. The @code{(gnu
  8283. services admin)} module provides an interface to GNU@tie{}Rot[t]log, a
  8284. log rotation tool (@pxref{Top,,, rottlog, GNU Rot[t]log Manual}).
  8285. The example below defines an operating system that provides log rotation
  8286. with the default settings, for commonly encountered log files.
  8287. @lisp
  8288. (use-modules (guix) (gnu))
  8289. (use-service-modules admin mcron)
  8290. (use-package-modules base idutils)
  8291. (operating-system
  8292. ;; @dots{}
  8293. (services (cons* (service mcron-service-type)
  8294. (service rottlog-service-type)
  8295. %base-services)))
  8296. @end lisp
  8297. @defvr {Scheme Variable} rottlog-service-type
  8298. This is the type of the Rottlog service, whose value is a
  8299. @code{rottlog-configuration} object.
  8300. Other services can extend this one with new @code{log-rotation} objects
  8301. (see below), thereby augmenting the set of files to be rotated.
  8302. This service type can define mcron jobs (@pxref{Scheduled Job
  8303. Execution}) to run the rottlog service.
  8304. @end defvr
  8305. @deftp {Data Type} rottlog-configuration
  8306. Data type representing the configuration of rottlog.
  8307. @table @asis
  8308. @item @code{rottlog} (default: @code{rottlog})
  8309. The Rottlog package to use.
  8310. @item @code{rc-file} (default: @code{(file-append rottlog "/etc/rc")})
  8311. The Rottlog configuration file to use (@pxref{Mandatory RC Variables,,,
  8312. rottlog, GNU Rot[t]log Manual}).
  8313. @item @code{rotations} (default: @code{%default-rotations})
  8314. A list of @code{log-rotation} objects as defined below.
  8315. @item @code{jobs}
  8316. This is a list of gexps where each gexp corresponds to an mcron job
  8317. specification (@pxref{Scheduled Job Execution}).
  8318. @end table
  8319. @end deftp
  8320. @deftp {Data Type} log-rotation
  8321. Data type representing the rotation of a group of log files.
  8322. Taking an example from the Rottlog manual (@pxref{Period Related File
  8323. Examples,,, rottlog, GNU Rot[t]log Manual}), a log rotation might be
  8324. defined like this:
  8325. @example
  8326. (log-rotation
  8327. (frequency 'daily)
  8328. (files '("/var/log/apache/*"))
  8329. (options '("storedir apache-archives"
  8330. "rotate 6"
  8331. "notifempty"
  8332. "nocompress")))
  8333. @end example
  8334. The list of fields is as follows:
  8335. @table @asis
  8336. @item @code{frequency} (default: @code{'weekly})
  8337. The log rotation frequency, a symbol.
  8338. @item @code{files}
  8339. The list of files or file glob patterns to rotate.
  8340. @item @code{options} (default: @code{'()})
  8341. The list of rottlog options for this rotation (@pxref{Configuration
  8342. parameters,,, rottlog, GNU Rot[t]lg Manual}).
  8343. @item @code{post-rotate} (default: @code{#f})
  8344. Either @code{#f} or a gexp to execute once the rotation has completed.
  8345. @end table
  8346. @end deftp
  8347. @defvr {Scheme Variable} %default-rotations
  8348. Specifies weekly rotation of @var{%rotated-files} and
  8349. a couple of other files.
  8350. @end defvr
  8351. @defvr {Scheme Variable} %rotated-files
  8352. The list of syslog-controlled files to be rotated. By default it is:
  8353. @code{'("/var/log/messages" "/var/log/secure")}.
  8354. @end defvr
  8355. @node Networking Services
  8356. @subsubsection Networking Services
  8357. The @code{(gnu services networking)} module provides services to configure
  8358. the network interface.
  8359. @cindex DHCP, networking service
  8360. @deffn {Scheme Procedure} dhcp-client-service [#:dhcp @var{isc-dhcp}]
  8361. Return a service that runs @var{dhcp}, a Dynamic Host Configuration
  8362. Protocol (DHCP) client, on all the non-loopback network interfaces.
  8363. @end deffn
  8364. @defvr {Scheme Variable} static-networking-service-type
  8365. This is the type for statically-configured network interfaces.
  8366. @c TODO Document <static-networking> data structures.
  8367. @end defvr
  8368. @deffn {Scheme Procedure} static-networking-service @var{interface} @var{ip} @
  8369. [#:netmask #f] [#:gateway #f] [#:name-servers @code{'()}]
  8370. [#:requirement @code{'(udev)}]
  8371. Return a service that starts @var{interface} with address @var{ip}. If
  8372. @var{netmask} is true, use it as the network mask. If @var{gateway} is true,
  8373. it must be a string specifying the default network gateway. @var{requirement}
  8374. can be used to declare a dependency on another service before configuring the
  8375. interface.
  8376. This procedure can be called several times, one for each network
  8377. interface of interest. Behind the scenes what it does is extend
  8378. @code{static-networking-service-type} with additional network interfaces
  8379. to handle.
  8380. @end deffn
  8381. @cindex wicd
  8382. @cindex wireless
  8383. @cindex WiFi
  8384. @cindex network management
  8385. @deffn {Scheme Procedure} wicd-service [#:wicd @var{wicd}]
  8386. Return a service that runs @url{https://launchpad.net/wicd,Wicd}, a network
  8387. management daemon that aims to simplify wired and wireless networking.
  8388. This service adds the @var{wicd} package to the global profile, providing
  8389. several commands to interact with the daemon and configure networking:
  8390. @command{wicd-client}, a graphical user interface, and the @command{wicd-cli}
  8391. and @command{wicd-curses} user interfaces.
  8392. @end deffn
  8393. @cindex NetworkManager
  8394. @defvr {Scheme Variable} network-manager-service-type
  8395. This is the service type for the
  8396. @uref{https://wiki.gnome.org/Projects/NetworkManager, NetworkManager}
  8397. service. The value for this service type is a
  8398. @code{network-manager-configuration} record.
  8399. This service is part of @code{%desktop-services} (@pxref{Desktop
  8400. Services}).
  8401. @end defvr
  8402. @deftp {Data Type} network-manager-configuration
  8403. Data type representing the configuration of NetworkManager.
  8404. @table @asis
  8405. @item @code{network-manager} (default: @code{network-manager})
  8406. The NetworkManager package to use.
  8407. @item @code{dns} (default: @code{"default"})
  8408. Processing mode for DNS, which affects how NetworkManager uses the
  8409. @code{resolv.conf} configuration file.
  8410. @table @samp
  8411. @item default
  8412. NetworkManager will update @code{resolv.conf} to reflect the nameservers
  8413. provided by currently active connections.
  8414. @item dnsmasq
  8415. NetworkManager will run @code{dnsmasq} as a local caching nameserver,
  8416. using a "split DNS" configuration if you are connected to a VPN, and
  8417. then update @code{resolv.conf} to point to the local nameserver.
  8418. @item none
  8419. NetworkManager will not modify @code{resolv.conf}.
  8420. @end table
  8421. @item @code{vpn-plugins} (default: @code{'()})
  8422. This is the list of available plugins for virtual private networks
  8423. (VPNs). An example of this is the @code{network-manager-openvpn}
  8424. package, which allows NetworkManager to manage VPNs @i{via} OpenVPN.
  8425. @end table
  8426. @end deftp
  8427. @cindex Connman
  8428. @deffn {Scheme Variable} connman-service-type
  8429. This is the service type to run @url{https://01.org/connman,Connman},
  8430. a network connection manager.
  8431. Its value must be an
  8432. @code{connman-configuration} record as in this example:
  8433. @example
  8434. (service connman-service-type
  8435. (connman-configuration
  8436. (disable-vpn? #t)))
  8437. @end example
  8438. See below for details about @code{connman-configuration}.
  8439. @end deffn
  8440. @deftp {Data Type} connman-configuration
  8441. Data Type representing the configuration of connman.
  8442. @table @asis
  8443. @item @code{connman} (default: @var{connman})
  8444. The connman package to use.
  8445. @item @code{disable-vpn?} (default: @code{#f})
  8446. When true, enable connman's vpn plugin.
  8447. @end table
  8448. @end deftp
  8449. @cindex WPA Supplicant
  8450. @defvr {Scheme Variable} wpa-supplicant-service-type
  8451. This is the service type to run @url{https://w1.fi/wpa_supplicant/,WPA
  8452. supplicant}, an authentication daemon required to authenticate against
  8453. encrypted WiFi or ethernet networks. It is configured to listen for
  8454. requests on D-Bus.
  8455. The value of this service is the @code{wpa-supplicant} package to use.
  8456. Thus, it can be instantiated like this:
  8457. @lisp
  8458. (use-modules (gnu services networking))
  8459. (service wpa-supplicant-service-type)
  8460. @end lisp
  8461. @end defvr
  8462. @cindex NTP
  8463. @cindex real time clock
  8464. @deffn {Scheme Procedure} ntp-service [#:ntp @var{ntp}] @
  8465. [#:servers @var{%ntp-servers}] @
  8466. [#:allow-large-adjustment? #f]
  8467. Return a service that runs the daemon from @var{ntp}, the
  8468. @uref{http://www.ntp.org, Network Time Protocol package}. The daemon will
  8469. keep the system clock synchronized with that of @var{servers}.
  8470. @var{allow-large-adjustment?} determines whether @command{ntpd} is allowed to
  8471. make an initial adjustment of more than 1,000 seconds.
  8472. @end deffn
  8473. @defvr {Scheme Variable} %ntp-servers
  8474. List of host names used as the default NTP servers.
  8475. @end defvr
  8476. @cindex inetd
  8477. @deffn {Scheme variable} inetd-service-type
  8478. This service runs the @command{inetd} (@pxref{inetd invocation,,,
  8479. inetutils, GNU Inetutils}) daemon. @command{inetd} listens for
  8480. connections on internet sockets, and lazily starts the specified server
  8481. program when a connection is made on one of these sockets.
  8482. The value of this service is an @code{inetd-configuration} object. The
  8483. following example configures the @command{inetd} daemon to provide the
  8484. built-in @command{echo} service, as well as an smtp service which
  8485. forwards smtp traffic over ssh to a server @code{smtp-server} behind a
  8486. gateway @code{hostname}:
  8487. @example
  8488. (service
  8489. inetd-service-type
  8490. (inetd-configuration
  8491. (entries (list
  8492. (inetd-entry
  8493. (name "echo")
  8494. (socket-type 'stream)
  8495. (protocol "tcp")
  8496. (wait? #f)
  8497. (user "root"))
  8498. (inetd-entry
  8499. (node "127.0.0.1")
  8500. (name "smtp")
  8501. (socket-type 'stream)
  8502. (protocol "tcp")
  8503. (wait? #f)
  8504. (user "root")
  8505. (program (file-append openssh "/bin/ssh"))
  8506. (arguments
  8507. '("ssh" "-qT" "-i" "/path/to/ssh_key"
  8508. "-W" "smtp-server:25" "user@@hostname")))))
  8509. @end example
  8510. See below for more details about @code{inetd-configuration}.
  8511. @end deffn
  8512. @deftp {Data Type} inetd-configuration
  8513. Data type representing the configuration of @command{inetd}.
  8514. @table @asis
  8515. @item @code{program} (default: @code{(file-append inetutils "/libexec/inetd")})
  8516. The @command{inetd} executable to use.
  8517. @item @code{entries} (default: @code{'()})
  8518. A list of @command{inetd} service entries. Each entry should be created
  8519. by the @code{inetd-entry} constructor.
  8520. @end table
  8521. @end deftp
  8522. @deftp {Data Type} inetd-entry
  8523. Data type representing an entry in the @command{inetd} configuration.
  8524. Each entry corresponds to a socket where @command{inetd} will listen for
  8525. requests.
  8526. @table @asis
  8527. @item @code{node} (default: @code{#f})
  8528. Optional string, a comma-separated list of local addresses
  8529. @command{inetd} should use when listening for this service.
  8530. @xref{Configuration file,,, inetutils, GNU Inetutils} for a complete
  8531. description of all options.
  8532. @item @code{name}
  8533. A string, the name must correspond to an entry in @code{/etc/services}.
  8534. @item @code{socket-type}
  8535. One of @code{'stream}, @code{'dgram}, @code{'raw}, @code{'rdm} or
  8536. @code{'seqpacket}.
  8537. @item @code{protocol}
  8538. A string, must correspond to an entry in @code{/etc/protocols}.
  8539. @item @code{wait?} (default: @code{#t})
  8540. Whether @command{inetd} should wait for the server to exit before
  8541. listening to new service requests.
  8542. @item @code{user}
  8543. A string containing the user (and, optionally, group) name of the user
  8544. as whom the server should run. The group name can be specified in a
  8545. suffix, separated by a colon or period, i.e. @code{"user"},
  8546. @code{"user:group"} or @code{"user.group"}.
  8547. @item @code{program} (default: @code{"internal"})
  8548. The server program which will serve the requests, or @code{"internal"}
  8549. if @command{inetd} should use a built-in service.
  8550. @item @code{arguments} (default: @code{'()})
  8551. A list strings or file-like objects, which are the server program's
  8552. arguments, starting with the zeroth argument, i.e. the name of the
  8553. program itself. For @command{inetd}'s internal services, this entry
  8554. must be @code{'()} or @code{'("internal")}.
  8555. @end table
  8556. @xref{Configuration file,,, inetutils, GNU Inetutils} for a more
  8557. detailed discussion of each configuration field.
  8558. @end deftp
  8559. @cindex Tor
  8560. @deffn {Scheme Procedure} tor-service [@var{config-file}] [#:tor @var{tor}]
  8561. Return a service to run the @uref{https://torproject.org, Tor} anonymous
  8562. networking daemon.
  8563. The daemon runs as the @code{tor} unprivileged user. It is passed
  8564. @var{config-file}, a file-like object, with an additional @code{User tor} line
  8565. and lines for hidden services added via @code{tor-hidden-service}. Run
  8566. @command{man tor} for information about the configuration file.
  8567. @end deffn
  8568. @cindex hidden service
  8569. @deffn {Scheme Procedure} tor-hidden-service @var{name} @var{mapping}
  8570. Define a new Tor @dfn{hidden service} called @var{name} and implementing
  8571. @var{mapping}. @var{mapping} is a list of port/host tuples, such as:
  8572. @example
  8573. '((22 "127.0.0.1:22")
  8574. (80 "127.0.0.1:8080"))
  8575. @end example
  8576. In this example, port 22 of the hidden service is mapped to local port 22, and
  8577. port 80 is mapped to local port 8080.
  8578. This creates a @file{/var/lib/tor/hidden-services/@var{name}} directory, where
  8579. the @file{hostname} file contains the @code{.onion} host name for the hidden
  8580. service.
  8581. See @uref{https://www.torproject.org/docs/tor-hidden-service.html.en, the Tor
  8582. project's documentation} for more information.
  8583. @end deffn
  8584. The @code{(gnu services rsync)} module provides the following services:
  8585. You might want an rsync daemon if you have files that you want available
  8586. so anyone (or just yourself) can download existing files or upload new
  8587. files.
  8588. @deffn {Scheme Variable} rsync-service-type
  8589. This is the type for the @uref{https://rsync.samba.org, rsync} rsync daemon,
  8590. @command{rsync-configuration} record as in this example:
  8591. @example
  8592. (service rsync-service-type)
  8593. @end example
  8594. See below for details about @code{rsync-configuration}.
  8595. @end deffn
  8596. @deftp {Data Type} rsync-configuration
  8597. Data type representing the configuration for @code{rsync-service}.
  8598. @table @asis
  8599. @item @code{package} (default: @var{rsync})
  8600. @code{rsync} package to use.
  8601. @item @code{port-number} (default: @code{873})
  8602. TCP port on which @command{rsync} listens for incoming connections. If port
  8603. is less than @code{1024} @command{rsync} needs to be started as the
  8604. @code{root} user and group.
  8605. @item @code{pid-file} (default: @code{"/var/run/rsyncd/rsyncd.pid"})
  8606. Name of the file where @command{rsync} writes its PID.
  8607. @item @code{lock-file} (default: @code{"/var/run/rsyncd/rsyncd.lock"})
  8608. Name of the file where @command{rsync} writes its lock file.
  8609. @item @code{log-file} (default: @code{"/var/log/rsyncd.log"})
  8610. Name of the file where @command{rsync} writes its log file.
  8611. @item @code{use-chroot?} (default: @var{#t})
  8612. Whether to use chroot for @command{rsync} shared directory.
  8613. @item @code{share-path} (default: @file{/srv/rsync})
  8614. Location of the @command{rsync} shared directory.
  8615. @item @code{share-comment} (default: @code{"Rsync share"})
  8616. Comment of the @command{rsync} shared directory.
  8617. @item @code{read-only?} (default: @var{#f})
  8618. Read-write permissions to shared directory.
  8619. @item @code{timeout} (default: @code{300})
  8620. I/O timeout in seconds.
  8621. @item @code{user} (default: @var{"root"})
  8622. Owner of the @code{rsync} process.
  8623. @item @code{group} (default: @var{"root"})
  8624. Group of the @code{rsync} process.
  8625. @item @code{uid} (default: @var{"rsyncd"})
  8626. User name or user ID that file transfers to and from that module should take
  8627. place as when the daemon was run as @code{root}.
  8628. @item @code{gid} (default: @var{"rsyncd"})
  8629. Group name or group ID that will be used when accessing the module.
  8630. @end table
  8631. @end deftp
  8632. Furthermore, @code{(gnu services ssh)} provides the following services.
  8633. @cindex SSH
  8634. @cindex SSH server
  8635. @deffn {Scheme Procedure} lsh-service [#:host-key "/etc/lsh/host-key"] @
  8636. [#:daemonic? #t] [#:interfaces '()] [#:port-number 22] @
  8637. [#:allow-empty-passwords? #f] [#:root-login? #f] @
  8638. [#:syslog-output? #t] [#:x11-forwarding? #t] @
  8639. [#:tcp/ip-forwarding? #t] [#:password-authentication? #t] @
  8640. [#:public-key-authentication? #t] [#:initialize? #t]
  8641. Run the @command{lshd} program from @var{lsh} to listen on port @var{port-number}.
  8642. @var{host-key} must designate a file containing the host key, and readable
  8643. only by root.
  8644. When @var{daemonic?} is true, @command{lshd} will detach from the
  8645. controlling terminal and log its output to syslogd, unless one sets
  8646. @var{syslog-output?} to false. Obviously, it also makes lsh-service
  8647. depend on existence of syslogd service. When @var{pid-file?} is true,
  8648. @command{lshd} writes its PID to the file called @var{pid-file}.
  8649. When @var{initialize?} is true, automatically create the seed and host key
  8650. upon service activation if they do not exist yet. This may take long and
  8651. require interaction.
  8652. When @var{initialize?} is false, it is up to the user to initialize the
  8653. randomness generator (@pxref{lsh-make-seed,,, lsh, LSH Manual}), and to create
  8654. a key pair with the private key stored in file @var{host-key} (@pxref{lshd
  8655. basics,,, lsh, LSH Manual}).
  8656. When @var{interfaces} is empty, lshd listens for connections on all the
  8657. network interfaces; otherwise, @var{interfaces} must be a list of host names
  8658. or addresses.
  8659. @var{allow-empty-passwords?} specifies whether to accept log-ins with empty
  8660. passwords, and @var{root-login?} specifies whether to accept log-ins as
  8661. root.
  8662. The other options should be self-descriptive.
  8663. @end deffn
  8664. @cindex SSH
  8665. @cindex SSH server
  8666. @deffn {Scheme Variable} openssh-service-type
  8667. This is the type for the @uref{http://www.openssh.org, OpenSSH} secure
  8668. shell daemon, @command{sshd}. Its value must be an
  8669. @code{openssh-configuration} record as in this example:
  8670. @example
  8671. (service openssh-service-type
  8672. (openssh-configuration
  8673. (x11-forwarding? #t)
  8674. (permit-root-login 'without-password)
  8675. (authorized-keys
  8676. `(("alice" ,(local-file "alice.pub"))
  8677. ("bob" ,(local-file "bob.pub"))))))
  8678. @end example
  8679. See below for details about @code{openssh-configuration}.
  8680. This service can be extended with extra authorized keys, as in this
  8681. example:
  8682. @example
  8683. (service-extension openssh-service-type
  8684. (const `(("charlie"
  8685. ,(local-file "charlie.pub")))))
  8686. @end example
  8687. @end deffn
  8688. @deftp {Data Type} openssh-configuration
  8689. This is the configuration record for OpenSSH's @command{sshd}.
  8690. @table @asis
  8691. @item @code{pid-file} (default: @code{"/var/run/sshd.pid"})
  8692. Name of the file where @command{sshd} writes its PID.
  8693. @item @code{port-number} (default: @code{22})
  8694. TCP port on which @command{sshd} listens for incoming connections.
  8695. @item @code{permit-root-login} (default: @code{#f})
  8696. This field determines whether and when to allow logins as root. If
  8697. @code{#f}, root logins are disallowed; if @code{#t}, they are allowed.
  8698. If it's the symbol @code{'without-password}, then root logins are
  8699. permitted but not with password-based authentication.
  8700. @item @code{allow-empty-passwords?} (default: @code{#f})
  8701. When true, users with empty passwords may log in. When false, they may
  8702. not.
  8703. @item @code{password-authentication?} (default: @code{#t})
  8704. When true, users may log in with their password. When false, they have
  8705. other authentication methods.
  8706. @item @code{public-key-authentication?} (default: @code{#t})
  8707. When true, users may log in using public key authentication. When
  8708. false, users have to use other authentication method.
  8709. Authorized public keys are stored in @file{~/.ssh/authorized_keys}.
  8710. This is used only by protocol version 2.
  8711. @item @code{x11-forwarding?} (default: @code{#f})
  8712. When true, forwarding of X11 graphical client connections is
  8713. enabled---in other words, @command{ssh} options @option{-X} and
  8714. @option{-Y} will work.
  8715. @item @code{challenge-response-authentication?} (default: @code{#f})
  8716. Specifies whether challenge response authentication is allowed (e.g. via
  8717. PAM).
  8718. @item @code{use-pam?} (default: @code{#t})
  8719. Enables the Pluggable Authentication Module interface. If set to
  8720. @code{#t}, this will enable PAM authentication using
  8721. @code{challenge-response-authentication?} and
  8722. @code{password-authentication?}, in addition to PAM account and session
  8723. module processing for all authentication types.
  8724. Because PAM challenge response authentication usually serves an
  8725. equivalent role to password authentication, you should disable either
  8726. @code{challenge-response-authentication?} or
  8727. @code{password-authentication?}.
  8728. @item @code{print-last-log?} (default: @code{#t})
  8729. Specifies whether @command{sshd} should print the date and time of the
  8730. last user login when a user logs in interactively.
  8731. @item @code{subsystems} (default: @code{'(("sftp" "internal-sftp"))})
  8732. Configures external subsystems (e.g. file transfer daemon).
  8733. This is a list of two-element lists, each of which containing the
  8734. subsystem name and a command (with optional arguments) to execute upon
  8735. subsystem request.
  8736. The command @command{internal-sftp} implements an in-process SFTP
  8737. server. Alternately, one can specify the @command{sftp-server} command:
  8738. @example
  8739. (service openssh-service-type
  8740. (openssh-configuration
  8741. (subsystems
  8742. `(("sftp" ,(file-append openssh "/libexec/sftp-server"))))))
  8743. @end example
  8744. @item @code{authorized-keys} (default: @code{'()})
  8745. @cindex authorized keys, SSH
  8746. @cindex SSH authorized keys
  8747. This is the list of authorized keys. Each element of the list is a user
  8748. name followed by one or more file-like objects that represent SSH public
  8749. keys. For example:
  8750. @example
  8751. (openssh-configuration
  8752. (authorized-keys
  8753. `(("rekado" ,(local-file "rekado.pub"))
  8754. ("chris" ,(local-file "chris.pub"))
  8755. ("root" ,(local-file "rekado.pub") ,(local-file "chris.pub")))))
  8756. @end example
  8757. @noindent
  8758. registers the specified public keys for user accounts @code{rekado},
  8759. @code{chris}, and @code{root}.
  8760. Additional authorized keys can be specified @i{via}
  8761. @code{service-extension}.
  8762. Note that this does @emph{not} interfere with the use of
  8763. @file{~/.ssh/authorized_keys}.
  8764. @end table
  8765. @end deftp
  8766. @deffn {Scheme Procedure} dropbear-service [@var{config}]
  8767. Run the @uref{https://matt.ucc.asn.au/dropbear/dropbear.html,Dropbear SSH
  8768. daemon} with the given @var{config}, a @code{<dropbear-configuration>}
  8769. object.
  8770. For example, to specify a Dropbear service listening on port 1234, add
  8771. this call to the operating system's @code{services} field:
  8772. @example
  8773. (dropbear-service (dropbear-configuration
  8774. (port-number 1234)))
  8775. @end example
  8776. @end deffn
  8777. @deftp {Data Type} dropbear-configuration
  8778. This data type represents the configuration of a Dropbear SSH daemon.
  8779. @table @asis
  8780. @item @code{dropbear} (default: @var{dropbear})
  8781. The Dropbear package to use.
  8782. @item @code{port-number} (default: 22)
  8783. The TCP port where the daemon waits for incoming connections.
  8784. @item @code{syslog-output?} (default: @code{#t})
  8785. Whether to enable syslog output.
  8786. @item @code{pid-file} (default: @code{"/var/run/dropbear.pid"})
  8787. File name of the daemon's PID file.
  8788. @item @code{root-login?} (default: @code{#f})
  8789. Whether to allow @code{root} logins.
  8790. @item @code{allow-empty-passwords?} (default: @code{#f})
  8791. Whether to allow empty passwords.
  8792. @item @code{password-authentication?} (default: @code{#t})
  8793. Whether to enable password-based authentication.
  8794. @end table
  8795. @end deftp
  8796. @defvr {Scheme Variable} %facebook-host-aliases
  8797. This variable contains a string for use in @file{/etc/hosts}
  8798. (@pxref{Host Names,,, libc, The GNU C Library Reference Manual}). Each
  8799. line contains a entry that maps a known server name of the Facebook
  8800. on-line service---e.g., @code{www.facebook.com}---to the local
  8801. host---@code{127.0.0.1} or its IPv6 equivalent, @code{::1}.
  8802. This variable is typically used in the @code{hosts-file} field of an
  8803. @code{operating-system} declaration (@pxref{operating-system Reference,
  8804. @file{/etc/hosts}}):
  8805. @example
  8806. (use-modules (gnu) (guix))
  8807. (operating-system
  8808. (host-name "mymachine")
  8809. ;; ...
  8810. (hosts-file
  8811. ;; Create a /etc/hosts file with aliases for "localhost"
  8812. ;; and "mymachine", as well as for Facebook servers.
  8813. (plain-file "hosts"
  8814. (string-append (local-host-aliases host-name)
  8815. %facebook-host-aliases))))
  8816. @end example
  8817. This mechanism can prevent programs running locally, such as Web
  8818. browsers, from accessing Facebook.
  8819. @end defvr
  8820. The @code{(gnu services avahi)} provides the following definition.
  8821. @deffn {Scheme Procedure} avahi-service [#:avahi @var{avahi}] @
  8822. [#:host-name #f] [#:publish? #t] [#:ipv4? #t] @
  8823. [#:ipv6? #t] [#:wide-area? #f] @
  8824. [#:domains-to-browse '()] [#:debug? #f]
  8825. Return a service that runs @command{avahi-daemon}, a system-wide
  8826. mDNS/DNS-SD responder that allows for service discovery and
  8827. "zero-configuration" host name lookups (see @uref{http://avahi.org/}), and
  8828. extends the name service cache daemon (nscd) so that it can resolve
  8829. @code{.local} host names using
  8830. @uref{http://0pointer.de/lennart/projects/nss-mdns/, nss-mdns}. Additionally,
  8831. add the @var{avahi} package to the system profile so that commands such as
  8832. @command{avahi-browse} are directly usable.
  8833. If @var{host-name} is different from @code{#f}, use that as the host name to
  8834. publish for this machine; otherwise, use the machine's actual host name.
  8835. When @var{publish?} is true, publishing of host names and services is allowed;
  8836. in particular, avahi-daemon will publish the machine's host name and IP
  8837. address via mDNS on the local network.
  8838. When @var{wide-area?} is true, DNS-SD over unicast DNS is enabled.
  8839. Boolean values @var{ipv4?} and @var{ipv6?} determine whether to use IPv4/IPv6
  8840. sockets.
  8841. @end deffn
  8842. @deffn {Scheme Variable} openvswitch-service-type
  8843. This is the type of the @uref{http://www.openvswitch.org, Open vSwitch}
  8844. service, whose value should be an @code{openvswitch-configuration}
  8845. object.
  8846. @end deffn
  8847. @deftp {Data Type} openvswitch-configuration
  8848. Data type representing the configuration of Open vSwitch, a multilayer
  8849. virtual switch which is designed to enable massive network automation
  8850. through programmatic extension.
  8851. @table @asis
  8852. @item @code{package} (default: @var{openvswitch})
  8853. Package object of the Open vSwitch.
  8854. @end table
  8855. @end deftp
  8856. @node X Window
  8857. @subsubsection X Window
  8858. @cindex X11
  8859. @cindex X Window System
  8860. @cindex login manager
  8861. Support for the X Window graphical display system---specifically
  8862. Xorg---is provided by the @code{(gnu services xorg)} module. Note that
  8863. there is no @code{xorg-service} procedure. Instead, the X server is
  8864. started by the @dfn{login manager}, by default SLiM.
  8865. @cindex window manager
  8866. To use X11, you must install at least one @dfn{window manager}---for
  8867. example the @code{windowmaker} or @code{openbox} packages---preferably
  8868. by adding it to the @code{packages} field of your operating system
  8869. definition (@pxref{operating-system Reference, system-wide packages}).
  8870. @defvr {Scheme Variable} slim-service-type
  8871. This is the type for the SLiM graphical login manager for X11.
  8872. @cindex session types (X11)
  8873. @cindex X11 session types
  8874. SLiM looks for @dfn{session types} described by the @file{.desktop} files in
  8875. @file{/run/current-system/profile/share/xsessions} and allows users to
  8876. choose a session from the log-in screen using @kbd{F1}. Packages such
  8877. as @code{xfce}, @code{sawfish}, and @code{ratpoison} provide
  8878. @file{.desktop} files; adding them to the system-wide set of packages
  8879. automatically makes them available at the log-in screen.
  8880. In addition, @file{~/.xsession} files are honored. When available,
  8881. @file{~/.xsession} must be an executable that starts a window manager
  8882. and/or other X clients.
  8883. @end defvr
  8884. @deftp {Data Type} slim-configuration
  8885. Data type representing the configuration of @code{slim-service-type}.
  8886. @table @asis
  8887. @item @code{allow-empty-passwords?} (default: @code{#t})
  8888. Whether to allow logins with empty passwords.
  8889. @item @code{auto-login?} (default: @code{#f})
  8890. @itemx @code{default-user} (default: @code{""})
  8891. When @code{auto-login?} is false, SLiM presents a log-in screen.
  8892. When @code{auto-login?} is true, SLiM logs in directly as
  8893. @code{default-user}.
  8894. @item @code{theme} (default: @code{%default-slim-theme})
  8895. @itemx @code{theme-name} (default: @code{%default-slim-theme-name})
  8896. The graphical theme to use and its name.
  8897. @item @code{auto-login-session} (default: @code{#f})
  8898. If true, this must be the name of the executable to start as the default
  8899. session---e.g., @code{(file-append windowmaker "/bin/windowmaker")}.
  8900. If false, a session described by one of the available @file{.desktop}
  8901. files in @code{/run/current-system/profile} and @code{~/.guix-profile}
  8902. will be used.
  8903. @quotation Note
  8904. You must install at least one window manager in the system profile or in
  8905. your user profile. Failing to do that, if @code{auto-login-session} is
  8906. false, you will be unable to log in.
  8907. @end quotation
  8908. @item @code{startx} (default: @code{(xorg-start-command)})
  8909. The command used to start the X11 graphical server.
  8910. @item @code{xauth} (default: @code{xauth})
  8911. The XAuth package to use.
  8912. @item @code{shepherd} (default: @code{shepherd})
  8913. The Shepherd package used when invoking @command{halt} and
  8914. @command{reboot}.
  8915. @item @code{slim} (default: @code{slim})
  8916. The SLiM package to use.
  8917. @end table
  8918. @end deftp
  8919. @defvr {Scheme Variable} %default-theme
  8920. @defvrx {Scheme Variable} %default-theme-name
  8921. The default SLiM theme and its name.
  8922. @end defvr
  8923. @deftp {Data Type} sddm-configuration
  8924. This is the data type representing the sddm service configuration.
  8925. @table @asis
  8926. @item @code{display-server} (default: "x11")
  8927. Select display server to use for the greeter. Valid values are "x11"
  8928. or "wayland".
  8929. @item @code{numlock} (default: "on")
  8930. Valid values are "on", "off" or "none".
  8931. @item @code{halt-command} (default @code{#~(string-apppend #$shepherd "/sbin/halt")})
  8932. Command to run when halting.
  8933. @item @code{reboot-command} (default @code{#~(string-append #$shepherd "/sbin/reboot")})
  8934. Command to run when rebooting.
  8935. @item @code{theme} (default "maldives")
  8936. Theme to use. Default themes provided by SDDM are "elarun" or "maldives".
  8937. @item @code{themes-directory} (default "/run/current-system/profile/share/sddm/themes")
  8938. Directory to look for themes.
  8939. @item @code{faces-directory} (default "/run/current-system/profile/share/sddm/faces")
  8940. Directory to look for faces.
  8941. @item @code{default-path} (default "/run/current-system/profile/bin")
  8942. Default PATH to use.
  8943. @item @code{minimum-uid} (default 1000)
  8944. Minimum UID to display in SDDM.
  8945. @item @code{maximum-uid} (default 2000)
  8946. Maximum UID to display in SDDM
  8947. @item @code{remember-last-user?} (default #t)
  8948. Remember last user.
  8949. @item @code{remember-last-session?} (default #t)
  8950. Remember last session.
  8951. @item @code{hide-users} (default "")
  8952. Usernames to hide from SDDM greeter.
  8953. @item @code{hide-shells} (default @code{#~(string-append #$shadow "/sbin/nologin")})
  8954. Users with shells listed will be hidden from the SDDM greeter.
  8955. @item @code{session-command} (default @code{#~(string-append #$sddm "/share/sddm/scripts/wayland-session")})
  8956. Script to run before starting a wayland session.
  8957. @item @code{sessions-directory} (default "/run/current-system/profile/share/wayland-sessions")
  8958. Directory to look for desktop files starting wayland sessions.
  8959. @item @code{xorg-server-path} (default @code{xorg-start-command})
  8960. Path to xorg-server.
  8961. @item @code{xauth-path} (default @code{#~(string-append #$xauth "/bin/xauth")})
  8962. Path to xauth.
  8963. @item @code{xephyr-path} (default @code{#~(string-append #$xorg-server "/bin/Xephyr")})
  8964. Path to Xephyr.
  8965. @item @code{xdisplay-start} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xsetup")})
  8966. Script to run after starting xorg-server.
  8967. @item @code{xdisplay-stop} (default @code{#~(string-append #$sddm "/share/sddm/scripts/Xstop")})
  8968. Script to run before stopping xorg-server.
  8969. @item @code{xsession-command} (default: @code{xinitr })
  8970. Script to run before starting a X session.
  8971. @item @code{xsessions-directory} (default: "/run/current-system/profile/share/xsessions")
  8972. Directory to look for desktop files starting X sessions.
  8973. @item @code{minimum-vt} (default: 7)
  8974. Minimum VT to use.
  8975. @item @code{xserver-arguments} (default "-nolisten tcp")
  8976. Arguments to pass to xorg-server.
  8977. @item @code{auto-login-user} (default "")
  8978. User to use for auto-login.
  8979. @item @code{auto-login-session} (default "")
  8980. Desktop file to use for auto-login.
  8981. @item @code{relogin?} (default #f)
  8982. Relogin after logout.
  8983. @end table
  8984. @end deftp
  8985. @cindex login manager
  8986. @cindex X11 login
  8987. @deffn {Scheme Procedure} sddm-service config
  8988. Return a service that spawns the SDDM graphical login manager for config of
  8989. type @code{<sddm-configuration>}.
  8990. @example
  8991. (sddm-service (sddm-configuration
  8992. (auto-login-user "Alice")
  8993. (auto-login-session "xfce.desktop")))
  8994. @end example
  8995. @end deffn
  8996. @deffn {Scheme Procedure} xorg-start-command [#:guile] @
  8997. [#:modules %default-xorg-modules] @
  8998. [#:fonts %default-xorg-fonts] @
  8999. [#:configuration-file (xorg-configuration-file @dots{})] @
  9000. [#:xorg-server @var{xorg-server}]
  9001. Return a @code{startx} script in which @var{modules}, a list of X module
  9002. packages, and @var{fonts}, a list of X font directories, are available. See
  9003. @code{xorg-wrapper} for more details on the arguments. The result should be
  9004. used in place of @code{startx}.
  9005. Usually the X server is started by a login manager.
  9006. @end deffn
  9007. @deffn {Scheme Procedure} xorg-configuration-file @
  9008. [#:modules %default-xorg-modules] @
  9009. [#:fonts %default-xorg-fonts] @
  9010. [#:drivers '()] [#:resolutions '()] [#:extra-config '()]
  9011. Return a configuration file for the Xorg server containing search paths for
  9012. all the common drivers.
  9013. @var{modules} must be a list of @dfn{module packages} loaded by the Xorg
  9014. server---e.g., @code{xf86-video-vesa}, @code{xf86-input-keyboard}, and so on.
  9015. @var{fonts} must be a list of font directories to add to the server's
  9016. @dfn{font path}.
  9017. @var{drivers} must be either the empty list, in which case Xorg chooses a
  9018. graphics driver automatically, or a list of driver names that will be tried in
  9019. this order---e.g., @code{("modesetting" "vesa")}.
  9020. Likewise, when @var{resolutions} is the empty list, Xorg chooses an
  9021. appropriate screen resolution; otherwise, it must be a list of
  9022. resolutions---e.g., @code{((1024 768) (640 480))}.
  9023. Last, @var{extra-config} is a list of strings or objects appended to the
  9024. configuration file. It is used to pass extra text to be
  9025. added verbatim to the configuration file.
  9026. @end deffn
  9027. @deffn {Scheme Procedure} screen-locker-service @var{package} [@var{name}]
  9028. Add @var{package}, a package for a screen-locker or screen-saver whose
  9029. command is @var{program}, to the set of setuid programs and add a PAM entry
  9030. for it. For example:
  9031. @lisp
  9032. (screen-locker-service xlockmore "xlock")
  9033. @end lisp
  9034. makes the good ol' XlockMore usable.
  9035. @end deffn
  9036. @node Printing Services
  9037. @subsubsection Printing Services
  9038. @cindex printer support with CUPS
  9039. The @code{(gnu services cups)} module provides a Guix service definition
  9040. for the CUPS printing service. To add printer support to a GuixSD
  9041. system, add a @code{cups-service} to the operating system definition:
  9042. @deffn {Scheme Variable} cups-service-type
  9043. The service type for the CUPS print server. Its value should be a valid
  9044. CUPS configuration (see below). To use the default settings, simply
  9045. write:
  9046. @example
  9047. (service cups-service-type)
  9048. @end example
  9049. @end deffn
  9050. The CUPS configuration controls the basic things about your CUPS
  9051. installation: what interfaces it listens on, what to do if a print job
  9052. fails, how much logging to do, and so on. To actually add a printer,
  9053. you have to visit the @url{http://localhost:631} URL, or use a tool such
  9054. as GNOME's printer configuration services. By default, configuring a
  9055. CUPS service will generate a self-signed certificate if needed, for
  9056. secure connections to the print server.
  9057. Suppose you want to enable the Web interface of CUPS and also add
  9058. support for HP printers @i{via} the @code{hplip} package. You can do
  9059. that directly, like this (you need to use the @code{(gnu packages cups)}
  9060. module):
  9061. @example
  9062. (service cups-service-type
  9063. (cups-configuration
  9064. (web-interface? #t)
  9065. (extensions
  9066. (list cups-filters hplip))))
  9067. @end example
  9068. The available configuration parameters follow. Each parameter
  9069. definition is preceded by its type; for example, @samp{string-list foo}
  9070. indicates that the @code{foo} parameter should be specified as a list of
  9071. strings. There is also a way to specify the configuration as a string,
  9072. if you have an old @code{cupsd.conf} file that you want to port over
  9073. from some other system; see the end for more details.
  9074. @c The following documentation was initially generated by
  9075. @c (generate-documentation) in (gnu services cups). Manually maintained
  9076. @c documentation is better, so we shouldn't hesitate to edit below as
  9077. @c needed. However if the change you want to make to this documentation
  9078. @c can be done in an automated way, it's probably easier to change
  9079. @c (generate-documentation) than to make it below and have to deal with
  9080. @c the churn as CUPS updates.
  9081. Available @code{cups-configuration} fields are:
  9082. @deftypevr {@code{cups-configuration} parameter} package cups
  9083. The CUPS package.
  9084. @end deftypevr
  9085. @deftypevr {@code{cups-configuration} parameter} package-list extensions
  9086. Drivers and other extensions to the CUPS package.
  9087. @end deftypevr
  9088. @deftypevr {@code{cups-configuration} parameter} files-configuration files-configuration
  9089. Configuration of where to write logs, what directories to use for print
  9090. spools, and related privileged configuration parameters.
  9091. Available @code{files-configuration} fields are:
  9092. @deftypevr {@code{files-configuration} parameter} log-location access-log
  9093. Defines the access log filename. Specifying a blank filename disables
  9094. access log generation. The value @code{stderr} causes log entries to be
  9095. sent to the standard error file when the scheduler is running in the
  9096. foreground, or to the system log daemon when run in the background. The
  9097. value @code{syslog} causes log entries to be sent to the system log
  9098. daemon. The server name may be included in filenames using the string
  9099. @code{%s}, as in @code{/var/log/cups/%s-access_log}.
  9100. Defaults to @samp{"/var/log/cups/access_log"}.
  9101. @end deftypevr
  9102. @deftypevr {@code{files-configuration} parameter} file-name cache-dir
  9103. Where CUPS should cache data.
  9104. Defaults to @samp{"/var/cache/cups"}.
  9105. @end deftypevr
  9106. @deftypevr {@code{files-configuration} parameter} string config-file-perm
  9107. Specifies the permissions for all configuration files that the scheduler
  9108. writes.
  9109. Note that the permissions for the printers.conf file are currently
  9110. masked to only allow access from the scheduler user (typically root).
  9111. This is done because printer device URIs sometimes contain sensitive
  9112. authentication information that should not be generally known on the
  9113. system. There is no way to disable this security feature.
  9114. Defaults to @samp{"0640"}.
  9115. @end deftypevr
  9116. @deftypevr {@code{files-configuration} parameter} log-location error-log
  9117. Defines the error log filename. Specifying a blank filename disables
  9118. access log generation. The value @code{stderr} causes log entries to be
  9119. sent to the standard error file when the scheduler is running in the
  9120. foreground, or to the system log daemon when run in the background. The
  9121. value @code{syslog} causes log entries to be sent to the system log
  9122. daemon. The server name may be included in filenames using the string
  9123. @code{%s}, as in @code{/var/log/cups/%s-error_log}.
  9124. Defaults to @samp{"/var/log/cups/error_log"}.
  9125. @end deftypevr
  9126. @deftypevr {@code{files-configuration} parameter} string fatal-errors
  9127. Specifies which errors are fatal, causing the scheduler to exit. The
  9128. kind strings are:
  9129. @table @code
  9130. @item none
  9131. No errors are fatal.
  9132. @item all
  9133. All of the errors below are fatal.
  9134. @item browse
  9135. Browsing initialization errors are fatal, for example failed connections
  9136. to the DNS-SD daemon.
  9137. @item config
  9138. Configuration file syntax errors are fatal.
  9139. @item listen
  9140. Listen or Port errors are fatal, except for IPv6 failures on the
  9141. loopback or @code{any} addresses.
  9142. @item log
  9143. Log file creation or write errors are fatal.
  9144. @item permissions
  9145. Bad startup file permissions are fatal, for example shared TLS
  9146. certificate and key files with world-read permissions.
  9147. @end table
  9148. Defaults to @samp{"all -browse"}.
  9149. @end deftypevr
  9150. @deftypevr {@code{files-configuration} parameter} boolean file-device?
  9151. Specifies whether the file pseudo-device can be used for new printer
  9152. queues. The URI @uref{file:///dev/null} is always allowed.
  9153. Defaults to @samp{#f}.
  9154. @end deftypevr
  9155. @deftypevr {@code{files-configuration} parameter} string group
  9156. Specifies the group name or ID that will be used when executing external
  9157. programs.
  9158. Defaults to @samp{"lp"}.
  9159. @end deftypevr
  9160. @deftypevr {@code{files-configuration} parameter} string log-file-perm
  9161. Specifies the permissions for all log files that the scheduler writes.
  9162. Defaults to @samp{"0644"}.
  9163. @end deftypevr
  9164. @deftypevr {@code{files-configuration} parameter} log-location page-log
  9165. Defines the page log filename. Specifying a blank filename disables
  9166. access log generation. The value @code{stderr} causes log entries to be
  9167. sent to the standard error file when the scheduler is running in the
  9168. foreground, or to the system log daemon when run in the background. The
  9169. value @code{syslog} causes log entries to be sent to the system log
  9170. daemon. The server name may be included in filenames using the string
  9171. @code{%s}, as in @code{/var/log/cups/%s-page_log}.
  9172. Defaults to @samp{"/var/log/cups/page_log"}.
  9173. @end deftypevr
  9174. @deftypevr {@code{files-configuration} parameter} string remote-root
  9175. Specifies the username that is associated with unauthenticated accesses
  9176. by clients claiming to be the root user. The default is @code{remroot}.
  9177. Defaults to @samp{"remroot"}.
  9178. @end deftypevr
  9179. @deftypevr {@code{files-configuration} parameter} file-name request-root
  9180. Specifies the directory that contains print jobs and other HTTP request
  9181. data.
  9182. Defaults to @samp{"/var/spool/cups"}.
  9183. @end deftypevr
  9184. @deftypevr {@code{files-configuration} parameter} sandboxing sandboxing
  9185. Specifies the level of security sandboxing that is applied to print
  9186. filters, backends, and other child processes of the scheduler; either
  9187. @code{relaxed} or @code{strict}. This directive is currently only
  9188. used/supported on macOS.
  9189. Defaults to @samp{strict}.
  9190. @end deftypevr
  9191. @deftypevr {@code{files-configuration} parameter} file-name server-keychain
  9192. Specifies the location of TLS certificates and private keys. CUPS will
  9193. look for public and private keys in this directory: a @code{.crt} files
  9194. for PEM-encoded certificates and corresponding @code{.key} files for
  9195. PEM-encoded private keys.
  9196. Defaults to @samp{"/etc/cups/ssl"}.
  9197. @end deftypevr
  9198. @deftypevr {@code{files-configuration} parameter} file-name server-root
  9199. Specifies the directory containing the server configuration files.
  9200. Defaults to @samp{"/etc/cups"}.
  9201. @end deftypevr
  9202. @deftypevr {@code{files-configuration} parameter} boolean sync-on-close?
  9203. Specifies whether the scheduler calls fsync(2) after writing
  9204. configuration or state files.
  9205. Defaults to @samp{#f}.
  9206. @end deftypevr
  9207. @deftypevr {@code{files-configuration} parameter} space-separated-string-list system-group
  9208. Specifies the group(s) to use for @code{@@SYSTEM} group authentication.
  9209. @end deftypevr
  9210. @deftypevr {@code{files-configuration} parameter} file-name temp-dir
  9211. Specifies the directory where temporary files are stored.
  9212. Defaults to @samp{"/var/spool/cups/tmp"}.
  9213. @end deftypevr
  9214. @deftypevr {@code{files-configuration} parameter} string user
  9215. Specifies the user name or ID that is used when running external
  9216. programs.
  9217. Defaults to @samp{"lp"}.
  9218. @end deftypevr
  9219. @end deftypevr
  9220. @deftypevr {@code{cups-configuration} parameter} access-log-level access-log-level
  9221. Specifies the logging level for the AccessLog file. The @code{config}
  9222. level logs when printers and classes are added, deleted, or modified and
  9223. when configuration files are accessed or updated. The @code{actions}
  9224. level logs when print jobs are submitted, held, released, modified, or
  9225. canceled, and any of the conditions for @code{config}. The @code{all}
  9226. level logs all requests.
  9227. Defaults to @samp{actions}.
  9228. @end deftypevr
  9229. @deftypevr {@code{cups-configuration} parameter} boolean auto-purge-jobs?
  9230. Specifies whether to purge job history data automatically when it is no
  9231. longer required for quotas.
  9232. Defaults to @samp{#f}.
  9233. @end deftypevr
  9234. @deftypevr {@code{cups-configuration} parameter} browse-local-protocols browse-local-protocols
  9235. Specifies which protocols to use for local printer sharing.
  9236. Defaults to @samp{dnssd}.
  9237. @end deftypevr
  9238. @deftypevr {@code{cups-configuration} parameter} boolean browse-web-if?
  9239. Specifies whether the CUPS web interface is advertised.
  9240. Defaults to @samp{#f}.
  9241. @end deftypevr
  9242. @deftypevr {@code{cups-configuration} parameter} boolean browsing?
  9243. Specifies whether shared printers are advertised.
  9244. Defaults to @samp{#f}.
  9245. @end deftypevr
  9246. @deftypevr {@code{cups-configuration} parameter} string classification
  9247. Specifies the security classification of the server. Any valid banner
  9248. name can be used, including "classified", "confidential", "secret",
  9249. "topsecret", and "unclassified", or the banner can be omitted to disable
  9250. secure printing functions.
  9251. Defaults to @samp{""}.
  9252. @end deftypevr
  9253. @deftypevr {@code{cups-configuration} parameter} boolean classify-override?
  9254. Specifies whether users may override the classification (cover page) of
  9255. individual print jobs using the @code{job-sheets} option.
  9256. Defaults to @samp{#f}.
  9257. @end deftypevr
  9258. @deftypevr {@code{cups-configuration} parameter} default-auth-type default-auth-type
  9259. Specifies the default type of authentication to use.
  9260. Defaults to @samp{Basic}.
  9261. @end deftypevr
  9262. @deftypevr {@code{cups-configuration} parameter} default-encryption default-encryption
  9263. Specifies whether encryption will be used for authenticated requests.
  9264. Defaults to @samp{Required}.
  9265. @end deftypevr
  9266. @deftypevr {@code{cups-configuration} parameter} string default-language
  9267. Specifies the default language to use for text and web content.
  9268. Defaults to @samp{"en"}.
  9269. @end deftypevr
  9270. @deftypevr {@code{cups-configuration} parameter} string default-paper-size
  9271. Specifies the default paper size for new print queues. @samp{"Auto"}
  9272. uses a locale-specific default, while @samp{"None"} specifies there is
  9273. no default paper size. Specific size names are typically
  9274. @samp{"Letter"} or @samp{"A4"}.
  9275. Defaults to @samp{"Auto"}.
  9276. @end deftypevr
  9277. @deftypevr {@code{cups-configuration} parameter} string default-policy
  9278. Specifies the default access policy to use.
  9279. Defaults to @samp{"default"}.
  9280. @end deftypevr
  9281. @deftypevr {@code{cups-configuration} parameter} boolean default-shared?
  9282. Specifies whether local printers are shared by default.
  9283. Defaults to @samp{#t}.
  9284. @end deftypevr
  9285. @deftypevr {@code{cups-configuration} parameter} non-negative-integer dirty-clean-interval
  9286. Specifies the delay for updating of configuration and state files, in
  9287. seconds. A value of 0 causes the update to happen as soon as possible,
  9288. typically within a few milliseconds.
  9289. Defaults to @samp{30}.
  9290. @end deftypevr
  9291. @deftypevr {@code{cups-configuration} parameter} error-policy error-policy
  9292. Specifies what to do when an error occurs. Possible values are
  9293. @code{abort-job}, which will discard the failed print job;
  9294. @code{retry-job}, which will retry the job at a later time;
  9295. @code{retry-this-job}, which retries the failed job immediately; and
  9296. @code{stop-printer}, which stops the printer.
  9297. Defaults to @samp{stop-printer}.
  9298. @end deftypevr
  9299. @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-limit
  9300. Specifies the maximum cost of filters that are run concurrently, which
  9301. can be used to minimize disk, memory, and CPU resource problems. A
  9302. limit of 0 disables filter limiting. An average print to a
  9303. non-PostScript printer needs a filter limit of about 200. A PostScript
  9304. printer needs about half that (100). Setting the limit below these
  9305. thresholds will effectively limit the scheduler to printing a single job
  9306. at any time.
  9307. Defaults to @samp{0}.
  9308. @end deftypevr
  9309. @deftypevr {@code{cups-configuration} parameter} non-negative-integer filter-nice
  9310. Specifies the scheduling priority of filters that are run to print a
  9311. job. The nice value ranges from 0, the highest priority, to 19, the
  9312. lowest priority.
  9313. Defaults to @samp{0}.
  9314. @end deftypevr
  9315. @deftypevr {@code{cups-configuration} parameter} host-name-lookups host-name-lookups
  9316. Specifies whether to do reverse lookups on connecting clients. The
  9317. @code{double} setting causes @code{cupsd} to verify that the hostname
  9318. resolved from the address matches one of the addresses returned for that
  9319. hostname. Double lookups also prevent clients with unregistered
  9320. addresses from connecting to your server. Only set this option to
  9321. @code{#t} or @code{double} if absolutely required.
  9322. Defaults to @samp{#f}.
  9323. @end deftypevr
  9324. @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-kill-delay
  9325. Specifies the number of seconds to wait before killing the filters and
  9326. backend associated with a canceled or held job.
  9327. Defaults to @samp{30}.
  9328. @end deftypevr
  9329. @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-interval
  9330. Specifies the interval between retries of jobs in seconds. This is
  9331. typically used for fax queues but can also be used with normal print
  9332. queues whose error policy is @code{retry-job} or
  9333. @code{retry-current-job}.
  9334. Defaults to @samp{30}.
  9335. @end deftypevr
  9336. @deftypevr {@code{cups-configuration} parameter} non-negative-integer job-retry-limit
  9337. Specifies the number of retries that are done for jobs. This is
  9338. typically used for fax queues but can also be used with normal print
  9339. queues whose error policy is @code{retry-job} or
  9340. @code{retry-current-job}.
  9341. Defaults to @samp{5}.
  9342. @end deftypevr
  9343. @deftypevr {@code{cups-configuration} parameter} boolean keep-alive?
  9344. Specifies whether to support HTTP keep-alive connections.
  9345. Defaults to @samp{#t}.
  9346. @end deftypevr
  9347. @deftypevr {@code{cups-configuration} parameter} non-negative-integer keep-alive-timeout
  9348. Specifies how long an idle client connection remains open, in seconds.
  9349. Defaults to @samp{30}.
  9350. @end deftypevr
  9351. @deftypevr {@code{cups-configuration} parameter} non-negative-integer limit-request-body
  9352. Specifies the maximum size of print files, IPP requests, and HTML form
  9353. data. A limit of 0 disables the limit check.
  9354. Defaults to @samp{0}.
  9355. @end deftypevr
  9356. @deftypevr {@code{cups-configuration} parameter} multiline-string-list listen
  9357. Listens on the specified interfaces for connections. Valid values are
  9358. of the form @var{address}:@var{port}, where @var{address} is either an
  9359. IPv6 address enclosed in brackets, an IPv4 address, or @code{*} to
  9360. indicate all addresses. Values can also be file names of local UNIX
  9361. domain sockets. The Listen directive is similar to the Port directive
  9362. but allows you to restrict access to specific interfaces or networks.
  9363. @end deftypevr
  9364. @deftypevr {@code{cups-configuration} parameter} non-negative-integer listen-back-log
  9365. Specifies the number of pending connections that will be allowed. This
  9366. normally only affects very busy servers that have reached the MaxClients
  9367. limit, but can also be triggered by large numbers of simultaneous
  9368. connections. When the limit is reached, the operating system will
  9369. refuse additional connections until the scheduler can accept the pending
  9370. ones.
  9371. Defaults to @samp{128}.
  9372. @end deftypevr
  9373. @deftypevr {@code{cups-configuration} parameter} location-access-control-list location-access-controls
  9374. Specifies a set of additional access controls.
  9375. Available @code{location-access-controls} fields are:
  9376. @deftypevr {@code{location-access-controls} parameter} file-name path
  9377. Specifies the URI path to which the access control applies.
  9378. @end deftypevr
  9379. @deftypevr {@code{location-access-controls} parameter} access-control-list access-controls
  9380. Access controls for all access to this path, in the same format as the
  9381. @code{access-controls} of @code{operation-access-control}.
  9382. Defaults to @samp{()}.
  9383. @end deftypevr
  9384. @deftypevr {@code{location-access-controls} parameter} method-access-control-list method-access-controls
  9385. Access controls for method-specific access to this path.
  9386. Defaults to @samp{()}.
  9387. Available @code{method-access-controls} fields are:
  9388. @deftypevr {@code{method-access-controls} parameter} boolean reverse?
  9389. If @code{#t}, apply access controls to all methods except the listed
  9390. methods. Otherwise apply to only the listed methods.
  9391. Defaults to @samp{#f}.
  9392. @end deftypevr
  9393. @deftypevr {@code{method-access-controls} parameter} method-list methods
  9394. Methods to which this access control applies.
  9395. Defaults to @samp{()}.
  9396. @end deftypevr
  9397. @deftypevr {@code{method-access-controls} parameter} access-control-list access-controls
  9398. Access control directives, as a list of strings. Each string should be
  9399. one directive, such as "Order allow,deny".
  9400. Defaults to @samp{()}.
  9401. @end deftypevr
  9402. @end deftypevr
  9403. @end deftypevr
  9404. @deftypevr {@code{cups-configuration} parameter} non-negative-integer log-debug-history
  9405. Specifies the number of debugging messages that are retained for logging
  9406. if an error occurs in a print job. Debug messages are logged regardless
  9407. of the LogLevel setting.
  9408. Defaults to @samp{100}.
  9409. @end deftypevr
  9410. @deftypevr {@code{cups-configuration} parameter} log-level log-level
  9411. Specifies the level of logging for the ErrorLog file. The value
  9412. @code{none} stops all logging while @code{debug2} logs everything.
  9413. Defaults to @samp{info}.
  9414. @end deftypevr
  9415. @deftypevr {@code{cups-configuration} parameter} log-time-format log-time-format
  9416. Specifies the format of the date and time in the log files. The value
  9417. @code{standard} logs whole seconds while @code{usecs} logs microseconds.
  9418. Defaults to @samp{standard}.
  9419. @end deftypevr
  9420. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients
  9421. Specifies the maximum number of simultaneous clients that are allowed by
  9422. the scheduler.
  9423. Defaults to @samp{100}.
  9424. @end deftypevr
  9425. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-clients-per-host
  9426. Specifies the maximum number of simultaneous clients that are allowed
  9427. from a single address.
  9428. Defaults to @samp{100}.
  9429. @end deftypevr
  9430. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-copies
  9431. Specifies the maximum number of copies that a user can print of each
  9432. job.
  9433. Defaults to @samp{9999}.
  9434. @end deftypevr
  9435. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-hold-time
  9436. Specifies the maximum time a job may remain in the @code{indefinite}
  9437. hold state before it is canceled. A value of 0 disables cancellation of
  9438. held jobs.
  9439. Defaults to @samp{0}.
  9440. @end deftypevr
  9441. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs
  9442. Specifies the maximum number of simultaneous jobs that are allowed. Set
  9443. to 0 to allow an unlimited number of jobs.
  9444. Defaults to @samp{500}.
  9445. @end deftypevr
  9446. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-printer
  9447. Specifies the maximum number of simultaneous jobs that are allowed per
  9448. printer. A value of 0 allows up to MaxJobs jobs per printer.
  9449. Defaults to @samp{0}.
  9450. @end deftypevr
  9451. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-jobs-per-user
  9452. Specifies the maximum number of simultaneous jobs that are allowed per
  9453. user. A value of 0 allows up to MaxJobs jobs per user.
  9454. Defaults to @samp{0}.
  9455. @end deftypevr
  9456. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-job-time
  9457. Specifies the maximum time a job may take to print before it is
  9458. canceled, in seconds. Set to 0 to disable cancellation of "stuck" jobs.
  9459. Defaults to @samp{10800}.
  9460. @end deftypevr
  9461. @deftypevr {@code{cups-configuration} parameter} non-negative-integer max-log-size
  9462. Specifies the maximum size of the log files before they are rotated, in
  9463. bytes. The value 0 disables log rotation.
  9464. Defaults to @samp{1048576}.
  9465. @end deftypevr
  9466. @deftypevr {@code{cups-configuration} parameter} non-negative-integer multiple-operation-timeout
  9467. Specifies the maximum amount of time to allow between files in a
  9468. multiple file print job, in seconds.
  9469. Defaults to @samp{300}.
  9470. @end deftypevr
  9471. @deftypevr {@code{cups-configuration} parameter} string page-log-format
  9472. Specifies the format of PageLog lines. Sequences beginning with percent
  9473. (@samp{%}) characters are replaced with the corresponding information,
  9474. while all other characters are copied literally. The following percent
  9475. sequences are recognized:
  9476. @table @samp
  9477. @item %%
  9478. insert a single percent character
  9479. @item %@{name@}
  9480. insert the value of the specified IPP attribute
  9481. @item %C
  9482. insert the number of copies for the current page
  9483. @item %P
  9484. insert the current page number
  9485. @item %T
  9486. insert the current date and time in common log format
  9487. @item %j
  9488. insert the job ID
  9489. @item %p
  9490. insert the printer name
  9491. @item %u
  9492. insert the username
  9493. @end table
  9494. A value of the empty string disables page logging. The string @code{%p
  9495. %u %j %T %P %C %@{job-billing@} %@{job-originating-host-name@}
  9496. %@{job-name@} %@{media@} %@{sides@}} creates a page log with the
  9497. standard items.
  9498. Defaults to @samp{""}.
  9499. @end deftypevr
  9500. @deftypevr {@code{cups-configuration} parameter} environment-variables environment-variables
  9501. Passes the specified environment variable(s) to child processes; a list
  9502. of strings.
  9503. Defaults to @samp{()}.
  9504. @end deftypevr
  9505. @deftypevr {@code{cups-configuration} parameter} policy-configuration-list policies
  9506. Specifies named access control policies.
  9507. Available @code{policy-configuration} fields are:
  9508. @deftypevr {@code{policy-configuration} parameter} string name
  9509. Name of the policy.
  9510. @end deftypevr
  9511. @deftypevr {@code{policy-configuration} parameter} string job-private-access
  9512. Specifies an access list for a job's private values. @code{@@ACL} maps
  9513. to the printer's requesting-user-name-allowed or
  9514. requesting-user-name-denied values. @code{@@OWNER} maps to the job's
  9515. owner. @code{@@SYSTEM} maps to the groups listed for the
  9516. @code{system-group} field of the @code{files-config} configuration,
  9517. which is reified into the @code{cups-files.conf(5)} file. Other
  9518. possible elements of the access list include specific user names, and
  9519. @code{@@@var{group}} to indicate members of a specific group. The
  9520. access list may also be simply @code{all} or @code{default}.
  9521. Defaults to @samp{"@@OWNER @@SYSTEM"}.
  9522. @end deftypevr
  9523. @deftypevr {@code{policy-configuration} parameter} string job-private-values
  9524. Specifies the list of job values to make private, or @code{all},
  9525. @code{default}, or @code{none}.
  9526. Defaults to @samp{"job-name job-originating-host-name
  9527. job-originating-user-name phone"}.
  9528. @end deftypevr
  9529. @deftypevr {@code{policy-configuration} parameter} string subscription-private-access
  9530. Specifies an access list for a subscription's private values.
  9531. @code{@@ACL} maps to the printer's requesting-user-name-allowed or
  9532. requesting-user-name-denied values. @code{@@OWNER} maps to the job's
  9533. owner. @code{@@SYSTEM} maps to the groups listed for the
  9534. @code{system-group} field of the @code{files-config} configuration,
  9535. which is reified into the @code{cups-files.conf(5)} file. Other
  9536. possible elements of the access list include specific user names, and
  9537. @code{@@@var{group}} to indicate members of a specific group. The
  9538. access list may also be simply @code{all} or @code{default}.
  9539. Defaults to @samp{"@@OWNER @@SYSTEM"}.
  9540. @end deftypevr
  9541. @deftypevr {@code{policy-configuration} parameter} string subscription-private-values
  9542. Specifies the list of job values to make private, or @code{all},
  9543. @code{default}, or @code{none}.
  9544. Defaults to @samp{"notify-events notify-pull-method notify-recipient-uri
  9545. notify-subscriber-user-name notify-user-data"}.
  9546. @end deftypevr
  9547. @deftypevr {@code{policy-configuration} parameter} operation-access-control-list access-controls
  9548. Access control by IPP operation.
  9549. Defaults to @samp{()}.
  9550. @end deftypevr
  9551. @end deftypevr
  9552. @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-files
  9553. Specifies whether job files (documents) are preserved after a job is
  9554. printed. If a numeric value is specified, job files are preserved for
  9555. the indicated number of seconds after printing. Otherwise a boolean
  9556. value applies indefinitely.
  9557. Defaults to @samp{86400}.
  9558. @end deftypevr
  9559. @deftypevr {@code{cups-configuration} parameter} boolean-or-non-negative-integer preserve-job-history
  9560. Specifies whether the job history is preserved after a job is printed.
  9561. If a numeric value is specified, the job history is preserved for the
  9562. indicated number of seconds after printing. If @code{#t}, the job
  9563. history is preserved until the MaxJobs limit is reached.
  9564. Defaults to @samp{#t}.
  9565. @end deftypevr
  9566. @deftypevr {@code{cups-configuration} parameter} non-negative-integer reload-timeout
  9567. Specifies the amount of time to wait for job completion before
  9568. restarting the scheduler.
  9569. Defaults to @samp{30}.
  9570. @end deftypevr
  9571. @deftypevr {@code{cups-configuration} parameter} string rip-cache
  9572. Specifies the maximum amount of memory to use when converting documents
  9573. into bitmaps for a printer.
  9574. Defaults to @samp{"128m"}.
  9575. @end deftypevr
  9576. @deftypevr {@code{cups-configuration} parameter} string server-admin
  9577. Specifies the email address of the server administrator.
  9578. Defaults to @samp{"root@@localhost.localdomain"}.
  9579. @end deftypevr
  9580. @deftypevr {@code{cups-configuration} parameter} host-name-list-or-* server-alias
  9581. The ServerAlias directive is used for HTTP Host header validation when
  9582. clients connect to the scheduler from external interfaces. Using the
  9583. special name @code{*} can expose your system to known browser-based DNS
  9584. rebinding attacks, even when accessing sites through a firewall. If the
  9585. auto-discovery of alternate names does not work, we recommend listing
  9586. each alternate name with a ServerAlias directive instead of using
  9587. @code{*}.
  9588. Defaults to @samp{*}.
  9589. @end deftypevr
  9590. @deftypevr {@code{cups-configuration} parameter} string server-name
  9591. Specifies the fully-qualified host name of the server.
  9592. Defaults to @samp{"localhost"}.
  9593. @end deftypevr
  9594. @deftypevr {@code{cups-configuration} parameter} server-tokens server-tokens
  9595. Specifies what information is included in the Server header of HTTP
  9596. responses. @code{None} disables the Server header. @code{ProductOnly}
  9597. reports @code{CUPS}. @code{Major} reports @code{CUPS 2}. @code{Minor}
  9598. reports @code{CUPS 2.0}. @code{Minimal} reports @code{CUPS 2.0.0}.
  9599. @code{OS} reports @code{CUPS 2.0.0 (@var{uname})} where @var{uname} is
  9600. the output of the @code{uname} command. @code{Full} reports @code{CUPS
  9601. 2.0.0 (@var{uname}) IPP/2.0}.
  9602. Defaults to @samp{Minimal}.
  9603. @end deftypevr
  9604. @deftypevr {@code{cups-configuration} parameter} string set-env
  9605. Set the specified environment variable to be passed to child processes.
  9606. Defaults to @samp{"variable value"}.
  9607. @end deftypevr
  9608. @deftypevr {@code{cups-configuration} parameter} multiline-string-list ssl-listen
  9609. Listens on the specified interfaces for encrypted connections. Valid
  9610. values are of the form @var{address}:@var{port}, where @var{address} is
  9611. either an IPv6 address enclosed in brackets, an IPv4 address, or
  9612. @code{*} to indicate all addresses.
  9613. Defaults to @samp{()}.
  9614. @end deftypevr
  9615. @deftypevr {@code{cups-configuration} parameter} ssl-options ssl-options
  9616. Sets encryption options. By default, CUPS only supports encryption
  9617. using TLS v1.0 or higher using known secure cipher suites. The
  9618. @code{AllowRC4} option enables the 128-bit RC4 cipher suites, which are
  9619. required for some older clients that do not implement newer ones. The
  9620. @code{AllowSSL3} option enables SSL v3.0, which is required for some
  9621. older clients that do not support TLS v1.0.
  9622. Defaults to @samp{()}.
  9623. @end deftypevr
  9624. @deftypevr {@code{cups-configuration} parameter} boolean strict-conformance?
  9625. Specifies whether the scheduler requires clients to strictly adhere to
  9626. the IPP specifications.
  9627. Defaults to @samp{#f}.
  9628. @end deftypevr
  9629. @deftypevr {@code{cups-configuration} parameter} non-negative-integer timeout
  9630. Specifies the HTTP request timeout, in seconds.
  9631. Defaults to @samp{300}.
  9632. @end deftypevr
  9633. @deftypevr {@code{cups-configuration} parameter} boolean web-interface?
  9634. Specifies whether the web interface is enabled.
  9635. Defaults to @samp{#f}.
  9636. @end deftypevr
  9637. At this point you're probably thinking ``oh dear, Guix manual, I like
  9638. you but you can stop already with the configuration options''. Indeed.
  9639. However, one more point: it could be that you have an existing
  9640. @code{cupsd.conf} that you want to use. In that case, you can pass an
  9641. @code{opaque-cups-configuration} as the configuration of a
  9642. @code{cups-service-type}.
  9643. Available @code{opaque-cups-configuration} fields are:
  9644. @deftypevr {@code{opaque-cups-configuration} parameter} package cups
  9645. The CUPS package.
  9646. @end deftypevr
  9647. @deftypevr {@code{opaque-cups-configuration} parameter} string cupsd.conf
  9648. The contents of the @code{cupsd.conf}, as a string.
  9649. @end deftypevr
  9650. @deftypevr {@code{opaque-cups-configuration} parameter} string cups-files.conf
  9651. The contents of the @code{cups-files.conf} file, as a string.
  9652. @end deftypevr
  9653. For example, if your @code{cupsd.conf} and @code{cups-files.conf} are in
  9654. strings of the same name, you could instantiate a CUPS service like
  9655. this:
  9656. @example
  9657. (service cups-service-type
  9658. (opaque-cups-configuration
  9659. (cupsd.conf cupsd.conf)
  9660. (cups-files.conf cups-files.conf)))
  9661. @end example
  9662. @node Desktop Services
  9663. @subsubsection Desktop Services
  9664. The @code{(gnu services desktop)} module provides services that are
  9665. usually useful in the context of a ``desktop'' setup---that is, on a
  9666. machine running a graphical display server, possibly with graphical user
  9667. interfaces, etc. It also defines services that provide specific desktop
  9668. environments like GNOME, XFCE or MATE.
  9669. To simplify things, the module defines a variable containing the set of
  9670. services that users typically expect on a machine with a graphical
  9671. environment and networking:
  9672. @defvr {Scheme Variable} %desktop-services
  9673. This is a list of services that builds upon @var{%base-services} and
  9674. adds or adjusts services for a typical ``desktop'' setup.
  9675. In particular, it adds a graphical login manager (@pxref{X Window,
  9676. @code{slim-service}}), screen lockers, a network management tool
  9677. (@pxref{Networking Services, @code{network-manager-service-type}}), energy and color
  9678. management services, the @code{elogind} login and seat manager, the
  9679. Polkit privilege service, the GeoClue location service, the
  9680. AccountsService daemon that allows authorized users change system
  9681. passwords, an NTP client (@pxref{Networking Services}), the Avahi
  9682. daemon, and has the name service switch service configured to be able to
  9683. use @code{nss-mdns} (@pxref{Name Service Switch, mDNS}).
  9684. @end defvr
  9685. The @var{%desktop-services} variable can be used as the @code{services}
  9686. field of an @code{operating-system} declaration (@pxref{operating-system
  9687. Reference, @code{services}}).
  9688. Additionally, the @code{gnome-desktop-service},
  9689. @code{xfce-desktop-service} and @code{mate-desktop-service}
  9690. procedures can add GNOME, XFCE and/or MATE to a system.
  9691. To ``add GNOME'' means that system-level services like the
  9692. backlight adjustment helpers and the power management utilities are
  9693. added to the system, extending @code{polkit} and @code{dbus}
  9694. appropriately, allowing GNOME to operate with elevated privileges on a
  9695. limited number of special-purpose system interfaces. Additionally,
  9696. adding a service made by @code{gnome-desktop-service} adds the GNOME
  9697. metapackage to the system profile. Likewise, adding the XFCE service
  9698. not only adds the @code{xfce} metapackage to the system profile, but it
  9699. also gives the Thunar file manager the ability to open a ``root-mode''
  9700. file management window, if the user authenticates using the
  9701. administrator's password via the standard polkit graphical interface.
  9702. To ``add MATE'' means that @code{polkit} and @code{dbus} are extended
  9703. appropriately, allowing MATE to operate with elevated privileges on a
  9704. limited number of special-purpose system interfaces. Additionally,
  9705. adding a service made by @code{mate-desktop-service} adds the MATE
  9706. metapackage to the system profile.
  9707. The desktop environments in Guix use the Xorg display server by
  9708. default. If you'd like to use the newer display server protocol
  9709. called Wayland, you need to use the @code{sddm-service} instead of the
  9710. @code{slim-service} for the graphical login manager. You should then
  9711. select the ``GNOME (Wayland)'' session in SDDM. Currently only GNOME
  9712. has support for Wayland.
  9713. @deffn {Scheme Procedure} gnome-desktop-service
  9714. Return a service that adds the @code{gnome} package to the system
  9715. profile, and extends polkit with the actions from
  9716. @code{gnome-settings-daemon}.
  9717. @end deffn
  9718. @deffn {Scheme Procedure} xfce-desktop-service
  9719. Return a service that adds the @code{xfce} package to the system profile,
  9720. and extends polkit with the ability for @code{thunar} to manipulate the
  9721. file system as root from within a user session, after the user has
  9722. authenticated with the administrator's password.
  9723. @end deffn
  9724. @deffn {Scheme Procedure} mate-desktop-service
  9725. Return a service that adds the @code{mate} package to the system
  9726. profile, and extends polkit with the actions from
  9727. @code{mate-settings-daemon}.
  9728. @end deffn
  9729. Because the GNOME, XFCE and MATE desktop services pull in so many packages,
  9730. the default @code{%desktop-services} variable doesn't include either of
  9731. them by default. To add GNOME, XFCE or MATE, just @code{cons} them onto
  9732. @code{%desktop-services} in the @code{services} field of your
  9733. @code{operating-system}:
  9734. @example
  9735. (use-modules (gnu))
  9736. (use-service-modules desktop)
  9737. (operating-system
  9738. ...
  9739. ;; cons* adds items to the list given as its last argument.
  9740. (services (cons* (gnome-desktop-service)
  9741. (xfce-desktop-service)
  9742. %desktop-services))
  9743. ...)
  9744. @end example
  9745. These desktop environments will then be available as options in the
  9746. graphical login window.
  9747. The actual service definitions included in @code{%desktop-services} and
  9748. provided by @code{(gnu services dbus)} and @code{(gnu services desktop)}
  9749. are described below.
  9750. @deffn {Scheme Procedure} dbus-service [#:dbus @var{dbus}] [#:services '()]
  9751. Return a service that runs the ``system bus'', using @var{dbus}, with
  9752. support for @var{services}.
  9753. @uref{http://dbus.freedesktop.org/, D-Bus} is an inter-process communication
  9754. facility. Its system bus is used to allow system services to communicate
  9755. and to be notified of system-wide events.
  9756. @var{services} must be a list of packages that provide an
  9757. @file{etc/dbus-1/system.d} directory containing additional D-Bus configuration
  9758. and policy files. For example, to allow avahi-daemon to use the system bus,
  9759. @var{services} must be equal to @code{(list avahi)}.
  9760. @end deffn
  9761. @deffn {Scheme Procedure} elogind-service [#:config @var{config}]
  9762. Return a service that runs the @code{elogind} login and
  9763. seat management daemon. @uref{https://github.com/elogind/elogind,
  9764. Elogind} exposes a D-Bus interface that can be used to know which users
  9765. are logged in, know what kind of sessions they have open, suspend the
  9766. system, inhibit system suspend, reboot the system, and other tasks.
  9767. Elogind handles most system-level power events for a computer, for
  9768. example suspending the system when a lid is closed, or shutting it down
  9769. when the power button is pressed.
  9770. The @var{config} keyword argument specifies the configuration for
  9771. elogind, and should be the result of an @code{(elogind-configuration
  9772. (@var{parameter} @var{value})...)} invocation. Available parameters and
  9773. their default values are:
  9774. @table @code
  9775. @item kill-user-processes?
  9776. @code{#f}
  9777. @item kill-only-users
  9778. @code{()}
  9779. @item kill-exclude-users
  9780. @code{("root")}
  9781. @item inhibit-delay-max-seconds
  9782. @code{5}
  9783. @item handle-power-key
  9784. @code{poweroff}
  9785. @item handle-suspend-key
  9786. @code{suspend}
  9787. @item handle-hibernate-key
  9788. @code{hibernate}
  9789. @item handle-lid-switch
  9790. @code{suspend}
  9791. @item handle-lid-switch-docked
  9792. @code{ignore}
  9793. @item power-key-ignore-inhibited?
  9794. @code{#f}
  9795. @item suspend-key-ignore-inhibited?
  9796. @code{#f}
  9797. @item hibernate-key-ignore-inhibited?
  9798. @code{#f}
  9799. @item lid-switch-ignore-inhibited?
  9800. @code{#t}
  9801. @item holdoff-timeout-seconds
  9802. @code{30}
  9803. @item idle-action
  9804. @code{ignore}
  9805. @item idle-action-seconds
  9806. @code{(* 30 60)}
  9807. @item runtime-directory-size-percent
  9808. @code{10}
  9809. @item runtime-directory-size
  9810. @code{#f}
  9811. @item remove-ipc?
  9812. @code{#t}
  9813. @item suspend-state
  9814. @code{("mem" "standby" "freeze")}
  9815. @item suspend-mode
  9816. @code{()}
  9817. @item hibernate-state
  9818. @code{("disk")}
  9819. @item hibernate-mode
  9820. @code{("platform" "shutdown")}
  9821. @item hybrid-sleep-state
  9822. @code{("disk")}
  9823. @item hybrid-sleep-mode
  9824. @code{("suspend" "platform" "shutdown")}
  9825. @end table
  9826. @end deffn
  9827. @deffn {Scheme Procedure} accountsservice-service @
  9828. [#:accountsservice @var{accountsservice}]
  9829. Return a service that runs AccountsService, a system service that can
  9830. list available accounts, change their passwords, and so on.
  9831. AccountsService integrates with PolicyKit to enable unprivileged users
  9832. to acquire the capability to modify their system configuration.
  9833. @uref{https://www.freedesktop.org/wiki/Software/AccountsService/, the
  9834. accountsservice web site} for more information.
  9835. The @var{accountsservice} keyword argument is the @code{accountsservice}
  9836. package to expose as a service.
  9837. @end deffn
  9838. @deffn {Scheme Procedure} polkit-service @
  9839. [#:polkit @var{polkit}]
  9840. Return a service that runs the
  9841. @uref{http://www.freedesktop.org/wiki/Software/polkit/, Polkit privilege
  9842. management service}, which allows system administrators to grant access to
  9843. privileged operations in a structured way. By querying the Polkit service, a
  9844. privileged system component can know when it should grant additional
  9845. capabilities to ordinary users. For example, an ordinary user can be granted
  9846. the capability to suspend the system if the user is logged in locally.
  9847. @end deffn
  9848. @deffn {Scheme Procedure} upower-service [#:upower @var{upower}] @
  9849. [#:watts-up-pro? #f] @
  9850. [#:poll-batteries? #t] @
  9851. [#:ignore-lid? #f] @
  9852. [#:use-percentage-for-policy? #f] @
  9853. [#:percentage-low 10] @
  9854. [#:percentage-critical 3] @
  9855. [#:percentage-action 2] @
  9856. [#:time-low 1200] @
  9857. [#:time-critical 300] @
  9858. [#:time-action 120] @
  9859. [#:critical-power-action 'hybrid-sleep]
  9860. Return a service that runs @uref{http://upower.freedesktop.org/,
  9861. @command{upowerd}}, a system-wide monitor for power consumption and battery
  9862. levels, with the given configuration settings. It implements the
  9863. @code{org.freedesktop.UPower} D-Bus interface, and is notably used by
  9864. GNOME.
  9865. @end deffn
  9866. @deffn {Scheme Procedure} udisks-service [#:udisks @var{udisks}]
  9867. Return a service for @uref{http://udisks.freedesktop.org/docs/latest/,
  9868. UDisks}, a @dfn{disk management} daemon that provides user interfaces with
  9869. notifications and ways to mount/unmount disks. Programs that talk to UDisks
  9870. include the @command{udisksctl} command, part of UDisks, and GNOME Disks.
  9871. @end deffn
  9872. @deffn {Scheme Procedure} colord-service [#:colord @var{colord}]
  9873. Return a service that runs @command{colord}, a system service with a D-Bus
  9874. interface to manage the color profiles of input and output devices such as
  9875. screens and scanners. It is notably used by the GNOME Color Manager graphical
  9876. tool. See @uref{http://www.freedesktop.org/software/colord/, the colord web
  9877. site} for more information.
  9878. @end deffn
  9879. @deffn {Scheme Procedure} geoclue-application name [#:allowed? #t] [#:system? #f] [#:users '()]
  9880. Return a configuration allowing an application to access GeoClue
  9881. location data. @var{name} is the Desktop ID of the application, without
  9882. the @code{.desktop} part. If @var{allowed?} is true, the application
  9883. will have access to location information by default. The boolean
  9884. @var{system?} value indicates whether an application is a system component
  9885. or not. Finally @var{users} is a list of UIDs of all users for which
  9886. this application is allowed location info access. An empty users list
  9887. means that all users are allowed.
  9888. @end deffn
  9889. @defvr {Scheme Variable} %standard-geoclue-applications
  9890. The standard list of well-known GeoClue application configurations,
  9891. granting authority to the GNOME date-and-time utility to ask for the
  9892. current location in order to set the time zone, and allowing the
  9893. IceCat and Epiphany web browsers to request location information.
  9894. IceCat and Epiphany both query the user before allowing a web page to
  9895. know the user's location.
  9896. @end defvr
  9897. @deffn {Scheme Procedure} geoclue-service [#:colord @var{colord}] @
  9898. [#:whitelist '()] @
  9899. [#:wifi-geolocation-url "https://location.services.mozilla.com/v1/geolocate?key=geoclue"] @
  9900. [#:submit-data? #f]
  9901. [#:wifi-submission-url "https://location.services.mozilla.com/v1/submit?key=geoclue"] @
  9902. [#:submission-nick "geoclue"] @
  9903. [#:applications %standard-geoclue-applications]
  9904. Return a service that runs the GeoClue location service. This service
  9905. provides a D-Bus interface to allow applications to request access to a
  9906. user's physical location, and optionally to add information to online
  9907. location databases. See
  9908. @uref{https://wiki.freedesktop.org/www/Software/GeoClue/, the GeoClue
  9909. web site} for more information.
  9910. @end deffn
  9911. @deffn {Scheme Procedure} bluetooth-service [#:bluez @var{bluez}] @
  9912. [@w{#:auto-enable? #f}]
  9913. Return a service that runs the @command{bluetoothd} daemon, which
  9914. manages all the Bluetooth devices and provides a number of D-Bus
  9915. interfaces. When AUTO-ENABLE? is true, the bluetooth controller is
  9916. powered automatically at boot, which can be useful when using a
  9917. bluetooth keyboard or mouse.
  9918. Users need to be in the @code{lp} group to access the D-Bus service.
  9919. @end deffn
  9920. @node Database Services
  9921. @subsubsection Database Services
  9922. @cindex database
  9923. @cindex SQL
  9924. The @code{(gnu services databases)} module provides the following services.
  9925. @deffn {Scheme Procedure} postgresql-service [#:postgresql postgresql] @
  9926. [#:config-file] [#:data-directory ``/var/lib/postgresql/data''] @
  9927. [#:port 5432] [#:locale ``en_US.utf8'']
  9928. Return a service that runs @var{postgresql}, the PostgreSQL database
  9929. server.
  9930. The PostgreSQL daemon loads its runtime configuration from @var{config-file},
  9931. creates a database cluster with @var{locale} as the default
  9932. locale, stored in @var{data-directory}. It then listens on @var{port}.
  9933. @end deffn
  9934. @deffn {Scheme Procedure} mysql-service [#:config (mysql-configuration)]
  9935. Return a service that runs @command{mysqld}, the MySQL or MariaDB
  9936. database server.
  9937. The optional @var{config} argument specifies the configuration for
  9938. @command{mysqld}, which should be a @code{<mysql-configuration>} object.
  9939. @end deffn
  9940. @deftp {Data Type} mysql-configuration
  9941. Data type representing the configuration of @var{mysql-service}.
  9942. @table @asis
  9943. @item @code{mysql} (default: @var{mariadb})
  9944. Package object of the MySQL database server, can be either @var{mariadb}
  9945. or @var{mysql}.
  9946. For MySQL, a temporary root password will be displayed at activation time.
  9947. For MariaDB, the root password is empty.
  9948. @item @code{port} (default: @code{3306})
  9949. TCP port on which the database server listens for incoming connections.
  9950. @end table
  9951. @end deftp
  9952. @defvr {Scheme Variable} memcached-service-type
  9953. This is the service type for the @uref{https://memcached.org/,
  9954. Memcached} service, which provides a distributed in memory cache. The
  9955. value for the service type is a @code{memcached-configuration} object.
  9956. @end defvr
  9957. @example
  9958. (service memcached-service-type)
  9959. @end example
  9960. @deftp {Data Type} memcached-configuration
  9961. Data type representing the configuration of memcached.
  9962. @table @asis
  9963. @item @code{memcached} (default: @code{memcached})
  9964. The Memcached package to use.
  9965. @item @code{interfaces} (default: @code{'("0.0.0.0")})
  9966. Network interfaces on which to listen.
  9967. @item @code{tcp-port} (default: @code{11211})
  9968. Port on which to accept connections on,
  9969. @item @code{udp-port} (default: @code{11211})
  9970. Port on which to accept UDP connections on, a value of 0 will disable
  9971. listening on a UDP socket.
  9972. @item @code{additional-options} (default: @code{'()})
  9973. Additional command line options to pass to @code{memcached}.
  9974. @end table
  9975. @end deftp
  9976. @defvr {Scheme Variable} mongodb-service-type
  9977. This is the service type for @uref{https://www.mongodb.com/, MongoDB}.
  9978. The value for the service type is a @code{mongodb-configuration} object.
  9979. @end defvr
  9980. @example
  9981. (service mongodb-service-type)
  9982. @end example
  9983. @deftp {Data Type} mongodb-configuration
  9984. Data type representing the configuration of mongodb.
  9985. @table @asis
  9986. @item @code{mongodb} (default: @code{mongodb})
  9987. The MongoDB package to use.
  9988. @item @code{config-file} (default: @code{%default-mongodb-configuration-file})
  9989. The configuration file for MongoDB.
  9990. @item @code{data-directory} (default: @code{"/var/lib/mongodb"})
  9991. This value is used to create the directory, so that it exists and is
  9992. owned by the mongodb user. It should match the data-directory which
  9993. MongoDB is configured to use through the configuration file.
  9994. @end table
  9995. @end deftp
  9996. @defvr {Scheme Variable} redis-service-type
  9997. This is the service type for the @uref{https://redis.io/, Redis}
  9998. key/value store, whose value is a @code{redis-configuration} object.
  9999. @end defvr
  10000. @deftp {Data Type} redis-configuration
  10001. Data type representing the configuration of redis.
  10002. @table @asis
  10003. @item @code{redis} (default: @code{redis})
  10004. The Redis package to use.
  10005. @item @code{bind} (default: @code{"127.0.0.1"})
  10006. Network interface on which to listen.
  10007. @item @code{port} (default: @code{6379})
  10008. Port on which to accept connections on, a value of 0 will disable
  10009. listening on a TCP socket.
  10010. @item @code{working-directory} (default: @code{"/var/lib/redis"})
  10011. Directory in which to store the database and related files.
  10012. @end table
  10013. @end deftp
  10014. @node Mail Services
  10015. @subsubsection Mail Services
  10016. @cindex mail
  10017. @cindex email
  10018. The @code{(gnu services mail)} module provides Guix service definitions
  10019. for email services: IMAP, POP3, and LMTP servers, as well as mail
  10020. transport agents (MTAs). Lots of acronyms! These services are detailed
  10021. in the subsections below.
  10022. @subsubheading Dovecot Service
  10023. @deffn {Scheme Procedure} dovecot-service [#:config (dovecot-configuration)]
  10024. Return a service that runs the Dovecot IMAP/POP3/LMTP mail server.
  10025. @end deffn
  10026. By default, Dovecot does not need much configuration; the default
  10027. configuration object created by @code{(dovecot-configuration)} will
  10028. suffice if your mail is delivered to @code{~/Maildir}. A self-signed
  10029. certificate will be generated for TLS-protected connections, though
  10030. Dovecot will also listen on cleartext ports by default. There are a
  10031. number of options, though, which mail administrators might need to change,
  10032. and as is the case with other services, Guix allows the system
  10033. administrator to specify these parameters via a uniform Scheme interface.
  10034. For example, to specify that mail is located at @code{maildir~/.mail},
  10035. one would instantiate the Dovecot service like this:
  10036. @example
  10037. (dovecot-service #:config
  10038. (dovecot-configuration
  10039. (mail-location "maildir:~/.mail")))
  10040. @end example
  10041. The available configuration parameters follow. Each parameter
  10042. definition is preceded by its type; for example, @samp{string-list foo}
  10043. indicates that the @code{foo} parameter should be specified as a list of
  10044. strings. There is also a way to specify the configuration as a string,
  10045. if you have an old @code{dovecot.conf} file that you want to port over
  10046. from some other system; see the end for more details.
  10047. @c The following documentation was initially generated by
  10048. @c (generate-documentation) in (gnu services mail). Manually maintained
  10049. @c documentation is better, so we shouldn't hesitate to edit below as
  10050. @c needed. However if the change you want to make to this documentation
  10051. @c can be done in an automated way, it's probably easier to change
  10052. @c (generate-documentation) than to make it below and have to deal with
  10053. @c the churn as dovecot updates.
  10054. Available @code{dovecot-configuration} fields are:
  10055. @deftypevr {@code{dovecot-configuration} parameter} package dovecot
  10056. The dovecot package.
  10057. @end deftypevr
  10058. @deftypevr {@code{dovecot-configuration} parameter} comma-separated-string-list listen
  10059. A list of IPs or hosts where to listen for connections. @samp{*}
  10060. listens on all IPv4 interfaces, @samp{::} listens on all IPv6
  10061. interfaces. If you want to specify non-default ports or anything more
  10062. complex, customize the address and port fields of the
  10063. @samp{inet-listener} of the specific services you are interested in.
  10064. @end deftypevr
  10065. @deftypevr {@code{dovecot-configuration} parameter} protocol-configuration-list protocols
  10066. List of protocols we want to serve. Available protocols include
  10067. @samp{imap}, @samp{pop3}, and @samp{lmtp}.
  10068. Available @code{protocol-configuration} fields are:
  10069. @deftypevr {@code{protocol-configuration} parameter} string name
  10070. The name of the protocol.
  10071. @end deftypevr
  10072. @deftypevr {@code{protocol-configuration} parameter} string auth-socket-path
  10073. UNIX socket path to the master authentication server to find users.
  10074. This is used by imap (for shared users) and lda.
  10075. It defaults to @samp{"/var/run/dovecot/auth-userdb"}.
  10076. @end deftypevr
  10077. @deftypevr {@code{protocol-configuration} parameter} space-separated-string-list mail-plugins
  10078. Space separated list of plugins to load.
  10079. @end deftypevr
  10080. @deftypevr {@code{protocol-configuration} parameter} non-negative-integer mail-max-userip-connections
  10081. Maximum number of IMAP connections allowed for a user from each IP
  10082. address. NOTE: The username is compared case-sensitively.
  10083. Defaults to @samp{10}.
  10084. @end deftypevr
  10085. @end deftypevr
  10086. @deftypevr {@code{dovecot-configuration} parameter} service-configuration-list services
  10087. List of services to enable. Available services include @samp{imap},
  10088. @samp{imap-login}, @samp{pop3}, @samp{pop3-login}, @samp{auth}, and
  10089. @samp{lmtp}.
  10090. Available @code{service-configuration} fields are:
  10091. @deftypevr {@code{service-configuration} parameter} string kind
  10092. The service kind. Valid values include @code{director},
  10093. @code{imap-login}, @code{pop3-login}, @code{lmtp}, @code{imap},
  10094. @code{pop3}, @code{auth}, @code{auth-worker}, @code{dict},
  10095. @code{tcpwrap}, @code{quota-warning}, or anything else.
  10096. @end deftypevr
  10097. @deftypevr {@code{service-configuration} parameter} listener-configuration-list listeners
  10098. Listeners for the service. A listener is either a
  10099. @code{unix-listener-configuration}, a @code{fifo-listener-configuration}, or
  10100. an @code{inet-listener-configuration}.
  10101. Defaults to @samp{()}.
  10102. Available @code{unix-listener-configuration} fields are:
  10103. @deftypevr {@code{unix-listener-configuration} parameter} string path
  10104. Path to the file, relative to @code{base-dir} field. This is also used as
  10105. the section name.
  10106. @end deftypevr
  10107. @deftypevr {@code{unix-listener-configuration} parameter} string mode
  10108. The access mode for the socket.
  10109. Defaults to @samp{"0600"}.
  10110. @end deftypevr
  10111. @deftypevr {@code{unix-listener-configuration} parameter} string user
  10112. The user to own the socket.
  10113. Defaults to @samp{""}.
  10114. @end deftypevr
  10115. @deftypevr {@code{unix-listener-configuration} parameter} string group
  10116. The group to own the socket.
  10117. Defaults to @samp{""}.
  10118. @end deftypevr
  10119. Available @code{fifo-listener-configuration} fields are:
  10120. @deftypevr {@code{fifo-listener-configuration} parameter} string path
  10121. Path to the file, relative to @code{base-dir} field. This is also used as
  10122. the section name.
  10123. @end deftypevr
  10124. @deftypevr {@code{fifo-listener-configuration} parameter} string mode
  10125. The access mode for the socket.
  10126. Defaults to @samp{"0600"}.
  10127. @end deftypevr
  10128. @deftypevr {@code{fifo-listener-configuration} parameter} string user
  10129. The user to own the socket.
  10130. Defaults to @samp{""}.
  10131. @end deftypevr
  10132. @deftypevr {@code{fifo-listener-configuration} parameter} string group
  10133. The group to own the socket.
  10134. Defaults to @samp{""}.
  10135. @end deftypevr
  10136. Available @code{inet-listener-configuration} fields are:
  10137. @deftypevr {@code{inet-listener-configuration} parameter} string protocol
  10138. The protocol to listen for.
  10139. @end deftypevr
  10140. @deftypevr {@code{inet-listener-configuration} parameter} string address
  10141. The address on which to listen, or empty for all addresses.
  10142. Defaults to @samp{""}.
  10143. @end deftypevr
  10144. @deftypevr {@code{inet-listener-configuration} parameter} non-negative-integer port
  10145. The port on which to listen.
  10146. @end deftypevr
  10147. @deftypevr {@code{inet-listener-configuration} parameter} boolean ssl?
  10148. Whether to use SSL for this service; @samp{yes}, @samp{no}, or
  10149. @samp{required}.
  10150. Defaults to @samp{#t}.
  10151. @end deftypevr
  10152. @end deftypevr
  10153. @deftypevr {@code{service-configuration} parameter} non-negative-integer service-count
  10154. Number of connections to handle before starting a new process.
  10155. Typically the only useful values are 0 (unlimited) or 1. 1 is more
  10156. secure, but 0 is faster. <doc/wiki/LoginProcess.txt>.
  10157. Defaults to @samp{1}.
  10158. @end deftypevr
  10159. @deftypevr {@code{service-configuration} parameter} non-negative-integer process-min-avail
  10160. Number of processes to always keep waiting for more connections.
  10161. Defaults to @samp{0}.
  10162. @end deftypevr
  10163. @deftypevr {@code{service-configuration} parameter} non-negative-integer vsz-limit
  10164. If you set @samp{service-count 0}, you probably need to grow
  10165. this.
  10166. Defaults to @samp{256000000}.
  10167. @end deftypevr
  10168. @end deftypevr
  10169. @deftypevr {@code{dovecot-configuration} parameter} dict-configuration dict
  10170. Dict configuration, as created by the @code{dict-configuration}
  10171. constructor.
  10172. Available @code{dict-configuration} fields are:
  10173. @deftypevr {@code{dict-configuration} parameter} free-form-fields entries
  10174. A list of key-value pairs that this dict should hold.
  10175. Defaults to @samp{()}.
  10176. @end deftypevr
  10177. @end deftypevr
  10178. @deftypevr {@code{dovecot-configuration} parameter} passdb-configuration-list passdbs
  10179. A list of passdb configurations, each one created by the
  10180. @code{passdb-configuration} constructor.
  10181. Available @code{passdb-configuration} fields are:
  10182. @deftypevr {@code{passdb-configuration} parameter} string driver
  10183. The driver that the passdb should use. Valid values include
  10184. @samp{pam}, @samp{passwd}, @samp{shadow}, @samp{bsdauth}, and
  10185. @samp{static}.
  10186. Defaults to @samp{"pam"}.
  10187. @end deftypevr
  10188. @deftypevr {@code{passdb-configuration} parameter} space-separated-string-list args
  10189. Space separated list of arguments to the passdb driver.
  10190. Defaults to @samp{""}.
  10191. @end deftypevr
  10192. @end deftypevr
  10193. @deftypevr {@code{dovecot-configuration} parameter} userdb-configuration-list userdbs
  10194. List of userdb configurations, each one created by the
  10195. @code{userdb-configuration} constructor.
  10196. Available @code{userdb-configuration} fields are:
  10197. @deftypevr {@code{userdb-configuration} parameter} string driver
  10198. The driver that the userdb should use. Valid values include
  10199. @samp{passwd} and @samp{static}.
  10200. Defaults to @samp{"passwd"}.
  10201. @end deftypevr
  10202. @deftypevr {@code{userdb-configuration} parameter} space-separated-string-list args
  10203. Space separated list of arguments to the userdb driver.
  10204. Defaults to @samp{""}.
  10205. @end deftypevr
  10206. @deftypevr {@code{userdb-configuration} parameter} free-form-args override-fields
  10207. Override fields from passwd.
  10208. Defaults to @samp{()}.
  10209. @end deftypevr
  10210. @end deftypevr
  10211. @deftypevr {@code{dovecot-configuration} parameter} plugin-configuration plugin-configuration
  10212. Plug-in configuration, created by the @code{plugin-configuration}
  10213. constructor.
  10214. @end deftypevr
  10215. @deftypevr {@code{dovecot-configuration} parameter} list-of-namespace-configuration namespaces
  10216. List of namespaces. Each item in the list is created by the
  10217. @code{namespace-configuration} constructor.
  10218. Available @code{namespace-configuration} fields are:
  10219. @deftypevr {@code{namespace-configuration} parameter} string name
  10220. Name for this namespace.
  10221. @end deftypevr
  10222. @deftypevr {@code{namespace-configuration} parameter} string type
  10223. Namespace type: @samp{private}, @samp{shared} or @samp{public}.
  10224. Defaults to @samp{"private"}.
  10225. @end deftypevr
  10226. @deftypevr {@code{namespace-configuration} parameter} string separator
  10227. Hierarchy separator to use. You should use the same separator for
  10228. all namespaces or some clients get confused. @samp{/} is usually a good
  10229. one. The default however depends on the underlying mail storage
  10230. format.
  10231. Defaults to @samp{""}.
  10232. @end deftypevr
  10233. @deftypevr {@code{namespace-configuration} parameter} string prefix
  10234. Prefix required to access this namespace. This needs to be
  10235. different for all namespaces. For example @samp{Public/}.
  10236. Defaults to @samp{""}.
  10237. @end deftypevr
  10238. @deftypevr {@code{namespace-configuration} parameter} string location
  10239. Physical location of the mailbox. This is in the same format as
  10240. mail_location, which is also the default for it.
  10241. Defaults to @samp{""}.
  10242. @end deftypevr
  10243. @deftypevr {@code{namespace-configuration} parameter} boolean inbox?
  10244. There can be only one INBOX, and this setting defines which
  10245. namespace has it.
  10246. Defaults to @samp{#f}.
  10247. @end deftypevr
  10248. @deftypevr {@code{namespace-configuration} parameter} boolean hidden?
  10249. If namespace is hidden, it's not advertised to clients via NAMESPACE
  10250. extension. You'll most likely also want to set @samp{list? #f}. This is mostly
  10251. useful when converting from another server with different namespaces
  10252. which you want to deprecate but still keep working. For example you can
  10253. create hidden namespaces with prefixes @samp{~/mail/}, @samp{~%u/mail/}
  10254. and @samp{mail/}.
  10255. Defaults to @samp{#f}.
  10256. @end deftypevr
  10257. @deftypevr {@code{namespace-configuration} parameter} boolean list?
  10258. Show the mailboxes under this namespace with the LIST command. This
  10259. makes the namespace visible for clients that do not support the NAMESPACE
  10260. extension. The special @code{children} value lists child mailboxes, but
  10261. hides the namespace prefix.
  10262. Defaults to @samp{#t}.
  10263. @end deftypevr
  10264. @deftypevr {@code{namespace-configuration} parameter} boolean subscriptions?
  10265. Namespace handles its own subscriptions. If set to @code{#f}, the
  10266. parent namespace handles them. The empty prefix should always have this
  10267. as @code{#t}).
  10268. Defaults to @samp{#t}.
  10269. @end deftypevr
  10270. @deftypevr {@code{namespace-configuration} parameter} mailbox-configuration-list mailboxes
  10271. List of predefined mailboxes in this namespace.
  10272. Defaults to @samp{()}.
  10273. Available @code{mailbox-configuration} fields are:
  10274. @deftypevr {@code{mailbox-configuration} parameter} string name
  10275. Name for this mailbox.
  10276. @end deftypevr
  10277. @deftypevr {@code{mailbox-configuration} parameter} string auto
  10278. @samp{create} will automatically create this mailbox.
  10279. @samp{subscribe} will both create and subscribe to the mailbox.
  10280. Defaults to @samp{"no"}.
  10281. @end deftypevr
  10282. @deftypevr {@code{mailbox-configuration} parameter} space-separated-string-list special-use
  10283. List of IMAP @code{SPECIAL-USE} attributes as specified by RFC 6154.
  10284. Valid values are @code{\All}, @code{\Archive}, @code{\Drafts},
  10285. @code{\Flagged}, @code{\Junk}, @code{\Sent}, and @code{\Trash}.
  10286. Defaults to @samp{()}.
  10287. @end deftypevr
  10288. @end deftypevr
  10289. @end deftypevr
  10290. @deftypevr {@code{dovecot-configuration} parameter} file-name base-dir
  10291. Base directory where to store runtime data.
  10292. Defaults to @samp{"/var/run/dovecot/"}.
  10293. @end deftypevr
  10294. @deftypevr {@code{dovecot-configuration} parameter} string login-greeting
  10295. Greeting message for clients.
  10296. Defaults to @samp{"Dovecot ready."}.
  10297. @end deftypevr
  10298. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-trusted-networks
  10299. List of trusted network ranges. Connections from these IPs are
  10300. allowed to override their IP addresses and ports (for logging and for
  10301. authentication checks). @samp{disable-plaintext-auth} is also ignored
  10302. for these networks. Typically you would specify your IMAP proxy servers
  10303. here.
  10304. Defaults to @samp{()}.
  10305. @end deftypevr
  10306. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-access-sockets
  10307. List of login access check sockets (e.g. tcpwrap).
  10308. Defaults to @samp{()}.
  10309. @end deftypevr
  10310. @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-proctitle?
  10311. Show more verbose process titles (in ps). Currently shows user name
  10312. and IP address. Useful for seeing who is actually using the IMAP
  10313. processes (e.g. shared mailboxes or if the same uid is used for multiple
  10314. accounts).
  10315. Defaults to @samp{#f}.
  10316. @end deftypevr
  10317. @deftypevr {@code{dovecot-configuration} parameter} boolean shutdown-clients?
  10318. Should all processes be killed when Dovecot master process shuts down.
  10319. Setting this to @code{#f} means that Dovecot can be upgraded without
  10320. forcing existing client connections to close (although that could also
  10321. be a problem if the upgrade is e.g. due to a security fix).
  10322. Defaults to @samp{#t}.
  10323. @end deftypevr
  10324. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer doveadm-worker-count
  10325. If non-zero, run mail commands via this many connections to doveadm
  10326. server, instead of running them directly in the same process.
  10327. Defaults to @samp{0}.
  10328. @end deftypevr
  10329. @deftypevr {@code{dovecot-configuration} parameter} string doveadm-socket-path
  10330. UNIX socket or host:port used for connecting to doveadm server.
  10331. Defaults to @samp{"doveadm-server"}.
  10332. @end deftypevr
  10333. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list import-environment
  10334. List of environment variables that are preserved on Dovecot startup
  10335. and passed down to all of its child processes. You can also give
  10336. key=value pairs to always set specific settings.
  10337. @end deftypevr
  10338. @deftypevr {@code{dovecot-configuration} parameter} boolean disable-plaintext-auth?
  10339. Disable LOGIN command and all other plaintext authentications unless
  10340. SSL/TLS is used (LOGINDISABLED capability). Note that if the remote IP
  10341. matches the local IP (i.e. you're connecting from the same computer),
  10342. the connection is considered secure and plaintext authentication is
  10343. allowed. See also ssl=required setting.
  10344. Defaults to @samp{#t}.
  10345. @end deftypevr
  10346. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-cache-size
  10347. Authentication cache size (e.g. @samp{#e10e6}). 0 means it's disabled.
  10348. Note that bsdauth, PAM and vpopmail require @samp{cache-key} to be set
  10349. for caching to be used.
  10350. Defaults to @samp{0}.
  10351. @end deftypevr
  10352. @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-ttl
  10353. Time to live for cached data. After TTL expires the cached record
  10354. is no longer used, *except* if the main database lookup returns internal
  10355. failure. We also try to handle password changes automatically: If
  10356. user's previous authentication was successful, but this one wasn't, the
  10357. cache isn't used. For now this works only with plaintext
  10358. authentication.
  10359. Defaults to @samp{"1 hour"}.
  10360. @end deftypevr
  10361. @deftypevr {@code{dovecot-configuration} parameter} string auth-cache-negative-ttl
  10362. TTL for negative hits (user not found, password mismatch).
  10363. 0 disables caching them completely.
  10364. Defaults to @samp{"1 hour"}.
  10365. @end deftypevr
  10366. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-realms
  10367. List of realms for SASL authentication mechanisms that need them.
  10368. You can leave it empty if you don't want to support multiple realms.
  10369. Many clients simply use the first one listed here, so keep the default
  10370. realm first.
  10371. Defaults to @samp{()}.
  10372. @end deftypevr
  10373. @deftypevr {@code{dovecot-configuration} parameter} string auth-default-realm
  10374. Default realm/domain to use if none was specified. This is used for
  10375. both SASL realms and appending @@domain to username in plaintext
  10376. logins.
  10377. Defaults to @samp{""}.
  10378. @end deftypevr
  10379. @deftypevr {@code{dovecot-configuration} parameter} string auth-username-chars
  10380. List of allowed characters in username. If the user-given username
  10381. contains a character not listed in here, the login automatically fails.
  10382. This is just an extra check to make sure user can't exploit any
  10383. potential quote escaping vulnerabilities with SQL/LDAP databases. If
  10384. you want to allow all characters, set this value to empty.
  10385. Defaults to @samp{"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@@"}.
  10386. @end deftypevr
  10387. @deftypevr {@code{dovecot-configuration} parameter} string auth-username-translation
  10388. Username character translations before it's looked up from
  10389. databases. The value contains series of from -> to characters. For
  10390. example @samp{#@@/@@} means that @samp{#} and @samp{/} characters are
  10391. translated to @samp{@@}.
  10392. Defaults to @samp{""}.
  10393. @end deftypevr
  10394. @deftypevr {@code{dovecot-configuration} parameter} string auth-username-format
  10395. Username formatting before it's looked up from databases. You can
  10396. use the standard variables here, e.g. %Lu would lowercase the username,
  10397. %n would drop away the domain if it was given, or @samp{%n-AT-%d} would
  10398. change the @samp{@@} into @samp{-AT-}. This translation is done after
  10399. @samp{auth-username-translation} changes.
  10400. Defaults to @samp{"%Lu"}.
  10401. @end deftypevr
  10402. @deftypevr {@code{dovecot-configuration} parameter} string auth-master-user-separator
  10403. If you want to allow master users to log in by specifying the master
  10404. username within the normal username string (i.e. not using SASL
  10405. mechanism's support for it), you can specify the separator character
  10406. here. The format is then <username><separator><master username>.
  10407. UW-IMAP uses @samp{*} as the separator, so that could be a good
  10408. choice.
  10409. Defaults to @samp{""}.
  10410. @end deftypevr
  10411. @deftypevr {@code{dovecot-configuration} parameter} string auth-anonymous-username
  10412. Username to use for users logging in with ANONYMOUS SASL
  10413. mechanism.
  10414. Defaults to @samp{"anonymous"}.
  10415. @end deftypevr
  10416. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer auth-worker-max-count
  10417. Maximum number of dovecot-auth worker processes. They're used to
  10418. execute blocking passdb and userdb queries (e.g. MySQL and PAM).
  10419. They're automatically created and destroyed as needed.
  10420. Defaults to @samp{30}.
  10421. @end deftypevr
  10422. @deftypevr {@code{dovecot-configuration} parameter} string auth-gssapi-hostname
  10423. Host name to use in GSSAPI principal names. The default is to use
  10424. the name returned by gethostname(). Use @samp{$ALL} (with quotes) to
  10425. allow all keytab entries.
  10426. Defaults to @samp{""}.
  10427. @end deftypevr
  10428. @deftypevr {@code{dovecot-configuration} parameter} string auth-krb5-keytab
  10429. Kerberos keytab to use for the GSSAPI mechanism. Will use the
  10430. system default (usually @file{/etc/krb5.keytab}) if not specified. You may
  10431. need to change the auth service to run as root to be able to read this
  10432. file.
  10433. Defaults to @samp{""}.
  10434. @end deftypevr
  10435. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-use-winbind?
  10436. Do NTLM and GSS-SPNEGO authentication using Samba's winbind daemon
  10437. and @samp{ntlm-auth} helper.
  10438. <doc/wiki/Authentication/Mechanisms/Winbind.txt>.
  10439. Defaults to @samp{#f}.
  10440. @end deftypevr
  10441. @deftypevr {@code{dovecot-configuration} parameter} file-name auth-winbind-helper-path
  10442. Path for Samba's @samp{ntlm-auth} helper binary.
  10443. Defaults to @samp{"/usr/bin/ntlm_auth"}.
  10444. @end deftypevr
  10445. @deftypevr {@code{dovecot-configuration} parameter} string auth-failure-delay
  10446. Time to delay before replying to failed authentications.
  10447. Defaults to @samp{"2 secs"}.
  10448. @end deftypevr
  10449. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-require-client-cert?
  10450. Require a valid SSL client certificate or the authentication
  10451. fails.
  10452. Defaults to @samp{#f}.
  10453. @end deftypevr
  10454. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-ssl-username-from-cert?
  10455. Take the username from client's SSL certificate, using
  10456. @code{X509_NAME_get_text_by_NID()} which returns the subject's DN's
  10457. CommonName.
  10458. Defaults to @samp{#f}.
  10459. @end deftypevr
  10460. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list auth-mechanisms
  10461. List of wanted authentication mechanisms. Supported mechanisms are:
  10462. @samp{plain}, @samp{login}, @samp{digest-md5}, @samp{cram-md5},
  10463. @samp{ntlm}, @samp{rpa}, @samp{apop}, @samp{anonymous}, @samp{gssapi},
  10464. @samp{otp}, @samp{skey}, and @samp{gss-spnego}. NOTE: See also
  10465. @samp{disable-plaintext-auth} setting.
  10466. @end deftypevr
  10467. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-servers
  10468. List of IPs or hostnames to all director servers, including ourself.
  10469. Ports can be specified as ip:port. The default port is the same as what
  10470. director service's @samp{inet-listener} is using.
  10471. Defaults to @samp{()}.
  10472. @end deftypevr
  10473. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list director-mail-servers
  10474. List of IPs or hostnames to all backend mail servers. Ranges are
  10475. allowed too, like 10.0.0.10-10.0.0.30.
  10476. Defaults to @samp{()}.
  10477. @end deftypevr
  10478. @deftypevr {@code{dovecot-configuration} parameter} string director-user-expire
  10479. How long to redirect users to a specific server after it no longer
  10480. has any connections.
  10481. Defaults to @samp{"15 min"}.
  10482. @end deftypevr
  10483. @deftypevr {@code{dovecot-configuration} parameter} string director-username-hash
  10484. How the username is translated before being hashed. Useful values
  10485. include %Ln if user can log in with or without @@domain, %Ld if mailboxes
  10486. are shared within domain.
  10487. Defaults to @samp{"%Lu"}.
  10488. @end deftypevr
  10489. @deftypevr {@code{dovecot-configuration} parameter} string log-path
  10490. Log file to use for error messages. @samp{syslog} logs to syslog,
  10491. @samp{/dev/stderr} logs to stderr.
  10492. Defaults to @samp{"syslog"}.
  10493. @end deftypevr
  10494. @deftypevr {@code{dovecot-configuration} parameter} string info-log-path
  10495. Log file to use for informational messages. Defaults to
  10496. @samp{log-path}.
  10497. Defaults to @samp{""}.
  10498. @end deftypevr
  10499. @deftypevr {@code{dovecot-configuration} parameter} string debug-log-path
  10500. Log file to use for debug messages. Defaults to
  10501. @samp{info-log-path}.
  10502. Defaults to @samp{""}.
  10503. @end deftypevr
  10504. @deftypevr {@code{dovecot-configuration} parameter} string syslog-facility
  10505. Syslog facility to use if you're logging to syslog. Usually if you
  10506. don't want to use @samp{mail}, you'll use local0..local7. Also other
  10507. standard facilities are supported.
  10508. Defaults to @samp{"mail"}.
  10509. @end deftypevr
  10510. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-verbose?
  10511. Log unsuccessful authentication attempts and the reasons why they
  10512. failed.
  10513. Defaults to @samp{#f}.
  10514. @end deftypevr
  10515. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-verbose-passwords?
  10516. In case of password mismatches, log the attempted password. Valid
  10517. values are no, plain and sha1. sha1 can be useful for detecting brute
  10518. force password attempts vs. user simply trying the same password over
  10519. and over again. You can also truncate the value to n chars by appending
  10520. ":n" (e.g. sha1:6).
  10521. Defaults to @samp{#f}.
  10522. @end deftypevr
  10523. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug?
  10524. Even more verbose logging for debugging purposes. Shows for example
  10525. SQL queries.
  10526. Defaults to @samp{#f}.
  10527. @end deftypevr
  10528. @deftypevr {@code{dovecot-configuration} parameter} boolean auth-debug-passwords?
  10529. In case of password mismatches, log the passwords and used scheme so
  10530. the problem can be debugged. Enabling this also enables
  10531. @samp{auth-debug}.
  10532. Defaults to @samp{#f}.
  10533. @end deftypevr
  10534. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-debug?
  10535. Enable mail process debugging. This can help you figure out why
  10536. Dovecot isn't finding your mails.
  10537. Defaults to @samp{#f}.
  10538. @end deftypevr
  10539. @deftypevr {@code{dovecot-configuration} parameter} boolean verbose-ssl?
  10540. Show protocol level SSL errors.
  10541. Defaults to @samp{#f}.
  10542. @end deftypevr
  10543. @deftypevr {@code{dovecot-configuration} parameter} string log-timestamp
  10544. Prefix for each line written to log file. % codes are in
  10545. strftime(3) format.
  10546. Defaults to @samp{"\"%b %d %H:%M:%S \""}.
  10547. @end deftypevr
  10548. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list login-log-format-elements
  10549. List of elements we want to log. The elements which have a
  10550. non-empty variable value are joined together to form a comma-separated
  10551. string.
  10552. @end deftypevr
  10553. @deftypevr {@code{dovecot-configuration} parameter} string login-log-format
  10554. Login log format. %s contains @samp{login-log-format-elements}
  10555. string, %$ contains the data we want to log.
  10556. Defaults to @samp{"%$: %s"}.
  10557. @end deftypevr
  10558. @deftypevr {@code{dovecot-configuration} parameter} string mail-log-prefix
  10559. Log prefix for mail processes. See doc/wiki/Variables.txt for list
  10560. of possible variables you can use.
  10561. Defaults to @samp{"\"%s(%u)<%@{pid@}><%@{session@}>: \""}.
  10562. @end deftypevr
  10563. @deftypevr {@code{dovecot-configuration} parameter} string deliver-log-format
  10564. Format to use for logging mail deliveries. You can use variables:
  10565. @table @code
  10566. @item %$
  10567. Delivery status message (e.g. @samp{saved to INBOX})
  10568. @item %m
  10569. Message-ID
  10570. @item %s
  10571. Subject
  10572. @item %f
  10573. From address
  10574. @item %p
  10575. Physical size
  10576. @item %w
  10577. Virtual size.
  10578. @end table
  10579. Defaults to @samp{"msgid=%m: %$"}.
  10580. @end deftypevr
  10581. @deftypevr {@code{dovecot-configuration} parameter} string mail-location
  10582. Location for users' mailboxes. The default is empty, which means
  10583. that Dovecot tries to find the mailboxes automatically. This won't work
  10584. if the user doesn't yet have any mail, so you should explicitly tell
  10585. Dovecot the full location.
  10586. If you're using mbox, giving a path to the INBOX
  10587. file (e.g. /var/mail/%u) isn't enough. You'll also need to tell Dovecot
  10588. where the other mailboxes are kept. This is called the "root mail
  10589. directory", and it must be the first path given in the
  10590. @samp{mail-location} setting.
  10591. There are a few special variables you can use, eg.:
  10592. @table @samp
  10593. @item %u
  10594. username
  10595. @item %n
  10596. user part in user@@domain, same as %u if there's no domain
  10597. @item %d
  10598. domain part in user@@domain, empty if there's no domain
  10599. @item %h
  10600. home director
  10601. @end table
  10602. See doc/wiki/Variables.txt for full list. Some examples:
  10603. @table @samp
  10604. @item maildir:~/Maildir
  10605. @item mbox:~/mail:INBOX=/var/mail/%u
  10606. @item mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/%
  10607. @end table
  10608. Defaults to @samp{""}.
  10609. @end deftypevr
  10610. @deftypevr {@code{dovecot-configuration} parameter} string mail-uid
  10611. System user and group used to access mails. If you use multiple,
  10612. userdb can override these by returning uid or gid fields. You can use
  10613. either numbers or names. <doc/wiki/UserIds.txt>.
  10614. Defaults to @samp{""}.
  10615. @end deftypevr
  10616. @deftypevr {@code{dovecot-configuration} parameter} string mail-gid
  10617. Defaults to @samp{""}.
  10618. @end deftypevr
  10619. @deftypevr {@code{dovecot-configuration} parameter} string mail-privileged-group
  10620. Group to enable temporarily for privileged operations. Currently
  10621. this is used only with INBOX when either its initial creation or
  10622. dotlocking fails. Typically this is set to "mail" to give access to
  10623. /var/mail.
  10624. Defaults to @samp{""}.
  10625. @end deftypevr
  10626. @deftypevr {@code{dovecot-configuration} parameter} string mail-access-groups
  10627. Grant access to these supplementary groups for mail processes.
  10628. Typically these are used to set up access to shared mailboxes. Note
  10629. that it may be dangerous to set these if users can create
  10630. symlinks (e.g. if "mail" group is set here, ln -s /var/mail ~/mail/var
  10631. could allow a user to delete others' mailboxes, or ln -s
  10632. /secret/shared/box ~/mail/mybox would allow reading it).
  10633. Defaults to @samp{""}.
  10634. @end deftypevr
  10635. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-full-filesystem-access?
  10636. Allow full file system access to clients. There's no access checks
  10637. other than what the operating system does for the active UID/GID. It
  10638. works with both maildir and mboxes, allowing you to prefix mailboxes
  10639. names with e.g. /path/ or ~user/.
  10640. Defaults to @samp{#f}.
  10641. @end deftypevr
  10642. @deftypevr {@code{dovecot-configuration} parameter} boolean mmap-disable?
  10643. Don't use mmap() at all. This is required if you store indexes to
  10644. shared file systems (NFS or clustered file system).
  10645. Defaults to @samp{#f}.
  10646. @end deftypevr
  10647. @deftypevr {@code{dovecot-configuration} parameter} boolean dotlock-use-excl?
  10648. Rely on @samp{O_EXCL} to work when creating dotlock files. NFS
  10649. supports @samp{O_EXCL} since version 3, so this should be safe to use
  10650. nowadays by default.
  10651. Defaults to @samp{#t}.
  10652. @end deftypevr
  10653. @deftypevr {@code{dovecot-configuration} parameter} string mail-fsync
  10654. When to use fsync() or fdatasync() calls:
  10655. @table @code
  10656. @item optimized
  10657. Whenever necessary to avoid losing important data
  10658. @item always
  10659. Useful with e.g. NFS when write()s are delayed
  10660. @item never
  10661. Never use it (best performance, but crashes can lose data).
  10662. @end table
  10663. Defaults to @samp{"optimized"}.
  10664. @end deftypevr
  10665. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-storage?
  10666. Mail storage exists in NFS. Set this to yes to make Dovecot flush
  10667. NFS caches whenever needed. If you're using only a single mail server
  10668. this isn't needed.
  10669. Defaults to @samp{#f}.
  10670. @end deftypevr
  10671. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-nfs-index?
  10672. Mail index files also exist in NFS. Setting this to yes requires
  10673. @samp{mmap-disable? #t} and @samp{fsync-disable? #f}.
  10674. Defaults to @samp{#f}.
  10675. @end deftypevr
  10676. @deftypevr {@code{dovecot-configuration} parameter} string lock-method
  10677. Locking method for index files. Alternatives are fcntl, flock and
  10678. dotlock. Dotlocking uses some tricks which may create more disk I/O
  10679. than other locking methods. NFS users: flock doesn't work, remember to
  10680. change @samp{mmap-disable}.
  10681. Defaults to @samp{"fcntl"}.
  10682. @end deftypevr
  10683. @deftypevr {@code{dovecot-configuration} parameter} file-name mail-temp-dir
  10684. Directory in which LDA/LMTP temporarily stores incoming mails >128
  10685. kB.
  10686. Defaults to @samp{"/tmp"}.
  10687. @end deftypevr
  10688. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-uid
  10689. Valid UID range for users. This is mostly to make sure that users can't
  10690. log in as daemons or other system users. Note that denying root logins is
  10691. hardcoded to dovecot binary and can't be done even if @samp{first-valid-uid}
  10692. is set to 0.
  10693. Defaults to @samp{500}.
  10694. @end deftypevr
  10695. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-uid
  10696. Defaults to @samp{0}.
  10697. @end deftypevr
  10698. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer first-valid-gid
  10699. Valid GID range for users. Users having non-valid GID as primary group ID
  10700. aren't allowed to log in. If user belongs to supplementary groups with
  10701. non-valid GIDs, those groups are not set.
  10702. Defaults to @samp{1}.
  10703. @end deftypevr
  10704. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer last-valid-gid
  10705. Defaults to @samp{0}.
  10706. @end deftypevr
  10707. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-max-keyword-length
  10708. Maximum allowed length for mail keyword name. It's only forced when
  10709. trying to create new keywords.
  10710. Defaults to @samp{50}.
  10711. @end deftypevr
  10712. @deftypevr {@code{dovecot-configuration} parameter} colon-separated-file-name-list valid-chroot-dirs
  10713. List of directories under which chrooting is allowed for mail
  10714. processes (i.e. /var/mail will allow chrooting to /var/mail/foo/bar
  10715. too). This setting doesn't affect @samp{login-chroot}
  10716. @samp{mail-chroot} or auth chroot settings. If this setting is empty,
  10717. "/./" in home dirs are ignored. WARNING: Never add directories here
  10718. which local users can modify, that may lead to root exploit. Usually
  10719. this should be done only if you don't allow shell access for users.
  10720. <doc/wiki/Chrooting.txt>.
  10721. Defaults to @samp{()}.
  10722. @end deftypevr
  10723. @deftypevr {@code{dovecot-configuration} parameter} string mail-chroot
  10724. Default chroot directory for mail processes. This can be overridden
  10725. for specific users in user database by giving /./ in user's home
  10726. directory (e.g. /home/./user chroots into /home). Note that usually
  10727. there is no real need to do chrooting, Dovecot doesn't allow users to
  10728. access files outside their mail directory anyway. If your home
  10729. directories are prefixed with the chroot directory, append "/." to
  10730. @samp{mail-chroot}. <doc/wiki/Chrooting.txt>.
  10731. Defaults to @samp{""}.
  10732. @end deftypevr
  10733. @deftypevr {@code{dovecot-configuration} parameter} file-name auth-socket-path
  10734. UNIX socket path to master authentication server to find users.
  10735. This is used by imap (for shared users) and lda.
  10736. Defaults to @samp{"/var/run/dovecot/auth-userdb"}.
  10737. @end deftypevr
  10738. @deftypevr {@code{dovecot-configuration} parameter} file-name mail-plugin-dir
  10739. Directory where to look up mail plugins.
  10740. Defaults to @samp{"/usr/lib/dovecot"}.
  10741. @end deftypevr
  10742. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mail-plugins
  10743. List of plugins to load for all services. Plugins specific to IMAP,
  10744. LDA, etc. are added to this list in their own .conf files.
  10745. Defaults to @samp{()}.
  10746. @end deftypevr
  10747. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-cache-min-mail-count
  10748. The minimum number of mails in a mailbox before updates are done to
  10749. cache file. This allows optimizing Dovecot's behavior to do less disk
  10750. writes at the cost of more disk reads.
  10751. Defaults to @samp{0}.
  10752. @end deftypevr
  10753. @deftypevr {@code{dovecot-configuration} parameter} string mailbox-idle-check-interval
  10754. When IDLE command is running, mailbox is checked once in a while to
  10755. see if there are any new mails or other changes. This setting defines
  10756. the minimum time to wait between those checks. Dovecot can also use
  10757. dnotify, inotify and kqueue to find out immediately when changes
  10758. occur.
  10759. Defaults to @samp{"30 secs"}.
  10760. @end deftypevr
  10761. @deftypevr {@code{dovecot-configuration} parameter} boolean mail-save-crlf?
  10762. Save mails with CR+LF instead of plain LF. This makes sending those
  10763. mails take less CPU, especially with sendfile() syscall with Linux and
  10764. FreeBSD. But it also creates a bit more disk I/O which may just make it
  10765. slower. Also note that if other software reads the mboxes/maildirs,
  10766. they may handle the extra CRs wrong and cause problems.
  10767. Defaults to @samp{#f}.
  10768. @end deftypevr
  10769. @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-stat-dirs?
  10770. By default LIST command returns all entries in maildir beginning
  10771. with a dot. Enabling this option makes Dovecot return only entries
  10772. which are directories. This is done by stat()ing each entry, so it
  10773. causes more disk I/O.
  10774. (For systems setting struct @samp{dirent->d_type} this check is free
  10775. and it's done always regardless of this setting).
  10776. Defaults to @samp{#f}.
  10777. @end deftypevr
  10778. @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-copy-with-hardlinks?
  10779. When copying a message, do it with hard links whenever possible.
  10780. This makes the performance much better, and it's unlikely to have any
  10781. side effects.
  10782. Defaults to @samp{#t}.
  10783. @end deftypevr
  10784. @deftypevr {@code{dovecot-configuration} parameter} boolean maildir-very-dirty-syncs?
  10785. Assume Dovecot is the only MUA accessing Maildir: Scan cur/
  10786. directory only when its mtime changes unexpectedly or when we can't find
  10787. the mail otherwise.
  10788. Defaults to @samp{#f}.
  10789. @end deftypevr
  10790. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-read-locks
  10791. Which locking methods to use for locking mbox. There are four
  10792. available:
  10793. @table @code
  10794. @item dotlock
  10795. Create <mailbox>.lock file. This is the oldest and most NFS-safe
  10796. solution. If you want to use /var/mail/ like directory, the users will
  10797. need write access to that directory.
  10798. @item dotlock-try
  10799. Same as dotlock, but if it fails because of permissions or because there
  10800. isn't enough disk space, just skip it.
  10801. @item fcntl
  10802. Use this if possible. Works with NFS too if lockd is used.
  10803. @item flock
  10804. May not exist in all systems. Doesn't work with NFS.
  10805. @item lockf
  10806. May not exist in all systems. Doesn't work with NFS.
  10807. @end table
  10808. You can use multiple locking methods; if you do the order they're declared
  10809. in is important to avoid deadlocks if other MTAs/MUAs are using multiple
  10810. locking methods as well. Some operating systems don't allow using some of
  10811. them simultaneously.
  10812. @end deftypevr
  10813. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list mbox-write-locks
  10814. @end deftypevr
  10815. @deftypevr {@code{dovecot-configuration} parameter} string mbox-lock-timeout
  10816. Maximum time to wait for lock (all of them) before aborting.
  10817. Defaults to @samp{"5 mins"}.
  10818. @end deftypevr
  10819. @deftypevr {@code{dovecot-configuration} parameter} string mbox-dotlock-change-timeout
  10820. If dotlock exists but the mailbox isn't modified in any way,
  10821. override the lock file after this much time.
  10822. Defaults to @samp{"2 mins"}.
  10823. @end deftypevr
  10824. @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-dirty-syncs?
  10825. When mbox changes unexpectedly we have to fully read it to find out
  10826. what changed. If the mbox is large this can take a long time. Since
  10827. the change is usually just a newly appended mail, it'd be faster to
  10828. simply read the new mails. If this setting is enabled, Dovecot does
  10829. this but still safely fallbacks to re-reading the whole mbox file
  10830. whenever something in mbox isn't how it's expected to be. The only real
  10831. downside to this setting is that if some other MUA changes message
  10832. flags, Dovecot doesn't notice it immediately. Note that a full sync is
  10833. done with SELECT, EXAMINE, EXPUNGE and CHECK commands.
  10834. Defaults to @samp{#t}.
  10835. @end deftypevr
  10836. @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-very-dirty-syncs?
  10837. Like @samp{mbox-dirty-syncs}, but don't do full syncs even with SELECT,
  10838. EXAMINE, EXPUNGE or CHECK commands. If this is set,
  10839. @samp{mbox-dirty-syncs} is ignored.
  10840. Defaults to @samp{#f}.
  10841. @end deftypevr
  10842. @deftypevr {@code{dovecot-configuration} parameter} boolean mbox-lazy-writes?
  10843. Delay writing mbox headers until doing a full write sync (EXPUNGE
  10844. and CHECK commands and when closing the mailbox). This is especially
  10845. useful for POP3 where clients often delete all mails. The downside is
  10846. that our changes aren't immediately visible to other MUAs.
  10847. Defaults to @samp{#t}.
  10848. @end deftypevr
  10849. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mbox-min-index-size
  10850. If mbox size is smaller than this (e.g. 100k), don't write index
  10851. files. If an index file already exists it's still read, just not
  10852. updated.
  10853. Defaults to @samp{0}.
  10854. @end deftypevr
  10855. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mdbox-rotate-size
  10856. Maximum dbox file size until it's rotated.
  10857. Defaults to @samp{10000000}.
  10858. @end deftypevr
  10859. @deftypevr {@code{dovecot-configuration} parameter} string mdbox-rotate-interval
  10860. Maximum dbox file age until it's rotated. Typically in days. Day
  10861. begins from midnight, so 1d = today, 2d = yesterday, etc. 0 = check
  10862. disabled.
  10863. Defaults to @samp{"1d"}.
  10864. @end deftypevr
  10865. @deftypevr {@code{dovecot-configuration} parameter} boolean mdbox-preallocate-space?
  10866. When creating new mdbox files, immediately preallocate their size to
  10867. @samp{mdbox-rotate-size}. This setting currently works only in Linux
  10868. with some file systems (ext4, xfs).
  10869. Defaults to @samp{#f}.
  10870. @end deftypevr
  10871. @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-dir
  10872. sdbox and mdbox support saving mail attachments to external files,
  10873. which also allows single instance storage for them. Other backends
  10874. don't support this for now.
  10875. WARNING: This feature hasn't been tested much yet. Use at your own risk.
  10876. Directory root where to store mail attachments. Disabled, if empty.
  10877. Defaults to @samp{""}.
  10878. @end deftypevr
  10879. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer mail-attachment-min-size
  10880. Attachments smaller than this aren't saved externally. It's also
  10881. possible to write a plugin to disable saving specific attachments
  10882. externally.
  10883. Defaults to @samp{128000}.
  10884. @end deftypevr
  10885. @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-fs
  10886. File system backend to use for saving attachments:
  10887. @table @code
  10888. @item posix
  10889. No SiS done by Dovecot (but this might help FS's own deduplication)
  10890. @item sis posix
  10891. SiS with immediate byte-by-byte comparison during saving
  10892. @item sis-queue posix
  10893. SiS with delayed comparison and deduplication.
  10894. @end table
  10895. Defaults to @samp{"sis posix"}.
  10896. @end deftypevr
  10897. @deftypevr {@code{dovecot-configuration} parameter} string mail-attachment-hash
  10898. Hash format to use in attachment filenames. You can add any text and
  10899. variables: @code{%@{md4@}}, @code{%@{md5@}}, @code{%@{sha1@}},
  10900. @code{%@{sha256@}}, @code{%@{sha512@}}, @code{%@{size@}}. Variables can be
  10901. truncated, e.g. @code{%@{sha256:80@}} returns only first 80 bits.
  10902. Defaults to @samp{"%@{sha1@}"}.
  10903. @end deftypevr
  10904. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-process-limit
  10905. Defaults to @samp{100}.
  10906. @end deftypevr
  10907. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-client-limit
  10908. Defaults to @samp{1000}.
  10909. @end deftypevr
  10910. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer default-vsz-limit
  10911. Default VSZ (virtual memory size) limit for service processes.
  10912. This is mainly intended to catch and kill processes that leak memory
  10913. before they eat up everything.
  10914. Defaults to @samp{256000000}.
  10915. @end deftypevr
  10916. @deftypevr {@code{dovecot-configuration} parameter} string default-login-user
  10917. Login user is internally used by login processes. This is the most
  10918. untrusted user in Dovecot system. It shouldn't have access to anything
  10919. at all.
  10920. Defaults to @samp{"dovenull"}.
  10921. @end deftypevr
  10922. @deftypevr {@code{dovecot-configuration} parameter} string default-internal-user
  10923. Internal user is used by unprivileged processes. It should be
  10924. separate from login user, so that login processes can't disturb other
  10925. processes.
  10926. Defaults to @samp{"dovecot"}.
  10927. @end deftypevr
  10928. @deftypevr {@code{dovecot-configuration} parameter} string ssl?
  10929. SSL/TLS support: yes, no, required. <doc/wiki/SSL.txt>.
  10930. Defaults to @samp{"required"}.
  10931. @end deftypevr
  10932. @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert
  10933. PEM encoded X.509 SSL/TLS certificate (public key).
  10934. Defaults to @samp{"</etc/dovecot/default.pem"}.
  10935. @end deftypevr
  10936. @deftypevr {@code{dovecot-configuration} parameter} string ssl-key
  10937. PEM encoded SSL/TLS private key. The key is opened before
  10938. dropping root privileges, so keep the key file unreadable by anyone but
  10939. root.
  10940. Defaults to @samp{"</etc/dovecot/private/default.pem"}.
  10941. @end deftypevr
  10942. @deftypevr {@code{dovecot-configuration} parameter} string ssl-key-password
  10943. If key file is password protected, give the password here.
  10944. Alternatively give it when starting dovecot with -p parameter. Since
  10945. this file is often world-readable, you may want to place this setting
  10946. instead to a different.
  10947. Defaults to @samp{""}.
  10948. @end deftypevr
  10949. @deftypevr {@code{dovecot-configuration} parameter} string ssl-ca
  10950. PEM encoded trusted certificate authority. Set this only if you
  10951. intend to use @samp{ssl-verify-client-cert? #t}. The file should
  10952. contain the CA certificate(s) followed by the matching
  10953. CRL(s). (e.g. @samp{ssl-ca </etc/ssl/certs/ca.pem}).
  10954. Defaults to @samp{""}.
  10955. @end deftypevr
  10956. @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-require-crl?
  10957. Require that CRL check succeeds for client certificates.
  10958. Defaults to @samp{#t}.
  10959. @end deftypevr
  10960. @deftypevr {@code{dovecot-configuration} parameter} boolean ssl-verify-client-cert?
  10961. Request client to send a certificate. If you also want to require
  10962. it, set @samp{auth-ssl-require-client-cert? #t} in auth section.
  10963. Defaults to @samp{#f}.
  10964. @end deftypevr
  10965. @deftypevr {@code{dovecot-configuration} parameter} string ssl-cert-username-field
  10966. Which field from certificate to use for username. commonName and
  10967. x500UniqueIdentifier are the usual choices. You'll also need to set
  10968. @samp{auth-ssl-username-from-cert? #t}.
  10969. Defaults to @samp{"commonName"}.
  10970. @end deftypevr
  10971. @deftypevr {@code{dovecot-configuration} parameter} string ssl-min-protocol
  10972. Minimum SSL protocol version to accept.
  10973. Defaults to @samp{"TLSv1"}.
  10974. @end deftypevr
  10975. @deftypevr {@code{dovecot-configuration} parameter} string ssl-cipher-list
  10976. SSL ciphers to use.
  10977. Defaults to @samp{"ALL:!kRSA:!SRP:!kDHd:!DSS:!aNULL:!eNULL:!EXPORT:!DES:!3DES:!MD5:!PSK:!RC4:!ADH:!LOW@@STRENGTH"}.
  10978. @end deftypevr
  10979. @deftypevr {@code{dovecot-configuration} parameter} string ssl-crypto-device
  10980. SSL crypto device to use, for valid values run "openssl engine".
  10981. Defaults to @samp{""}.
  10982. @end deftypevr
  10983. @deftypevr {@code{dovecot-configuration} parameter} string postmaster-address
  10984. Address to use when sending rejection mails.
  10985. %d expands to recipient domain.
  10986. Defaults to @samp{"postmaster@@%d"}.
  10987. @end deftypevr
  10988. @deftypevr {@code{dovecot-configuration} parameter} string hostname
  10989. Hostname to use in various parts of sent mails (e.g. in Message-Id)
  10990. and in LMTP replies. Default is the system's real hostname@@domain.
  10991. Defaults to @samp{""}.
  10992. @end deftypevr
  10993. @deftypevr {@code{dovecot-configuration} parameter} boolean quota-full-tempfail?
  10994. If user is over quota, return with temporary failure instead of
  10995. bouncing the mail.
  10996. Defaults to @samp{#f}.
  10997. @end deftypevr
  10998. @deftypevr {@code{dovecot-configuration} parameter} file-name sendmail-path
  10999. Binary to use for sending mails.
  11000. Defaults to @samp{"/usr/sbin/sendmail"}.
  11001. @end deftypevr
  11002. @deftypevr {@code{dovecot-configuration} parameter} string submission-host
  11003. If non-empty, send mails via this SMTP host[:port] instead of
  11004. sendmail.
  11005. Defaults to @samp{""}.
  11006. @end deftypevr
  11007. @deftypevr {@code{dovecot-configuration} parameter} string rejection-subject
  11008. Subject: header to use for rejection mails. You can use the same
  11009. variables as for @samp{rejection-reason} below.
  11010. Defaults to @samp{"Rejected: %s"}.
  11011. @end deftypevr
  11012. @deftypevr {@code{dovecot-configuration} parameter} string rejection-reason
  11013. Human readable error message for rejection mails. You can use
  11014. variables:
  11015. @table @code
  11016. @item %n
  11017. CRLF
  11018. @item %r
  11019. reason
  11020. @item %s
  11021. original subject
  11022. @item %t
  11023. recipient
  11024. @end table
  11025. Defaults to @samp{"Your message to <%t> was automatically rejected:%n%r"}.
  11026. @end deftypevr
  11027. @deftypevr {@code{dovecot-configuration} parameter} string recipient-delimiter
  11028. Delimiter character between local-part and detail in email
  11029. address.
  11030. Defaults to @samp{"+"}.
  11031. @end deftypevr
  11032. @deftypevr {@code{dovecot-configuration} parameter} string lda-original-recipient-header
  11033. Header where the original recipient address (SMTP's RCPT TO:
  11034. address) is taken from if not available elsewhere. With dovecot-lda -a
  11035. parameter overrides this. A commonly used header for this is
  11036. X-Original-To.
  11037. Defaults to @samp{""}.
  11038. @end deftypevr
  11039. @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autocreate?
  11040. Should saving a mail to a nonexistent mailbox automatically create
  11041. it?.
  11042. Defaults to @samp{#f}.
  11043. @end deftypevr
  11044. @deftypevr {@code{dovecot-configuration} parameter} boolean lda-mailbox-autosubscribe?
  11045. Should automatically created mailboxes be also automatically
  11046. subscribed?.
  11047. Defaults to @samp{#f}.
  11048. @end deftypevr
  11049. @deftypevr {@code{dovecot-configuration} parameter} non-negative-integer imap-max-line-length
  11050. Maximum IMAP command line length. Some clients generate very long
  11051. command lines with huge mailboxes, so you may need to raise this if you
  11052. get "Too long argument" or "IMAP command line too large" errors
  11053. often.
  11054. Defaults to @samp{64000}.
  11055. @end deftypevr
  11056. @deftypevr {@code{dovecot-configuration} parameter} string imap-logout-format
  11057. IMAP logout format string:
  11058. @table @code
  11059. @item %i
  11060. total number of bytes read from client
  11061. @item %o
  11062. total number of bytes sent to client.
  11063. @end table
  11064. See @file{doc/wiki/Variables.txt} for a list of all the variables you can use.
  11065. Defaults to @samp{"in=%i out=%o deleted=%@{deleted@} expunged=%@{expunged@} trashed=%@{trashed@} hdr_count=%@{fetch_hdr_count@} hdr_bytes=%@{fetch_hdr_bytes@} body_count=%@{fetch_body_count@} body_bytes=%@{fetch_body_bytes@}"}.
  11066. @end deftypevr
  11067. @deftypevr {@code{dovecot-configuration} parameter} string imap-capability
  11068. Override the IMAP CAPABILITY response. If the value begins with '+',
  11069. add the given capabilities on top of the defaults (e.g. +XFOO XBAR).
  11070. Defaults to @samp{""}.
  11071. @end deftypevr
  11072. @deftypevr {@code{dovecot-configuration} parameter} string imap-idle-notify-interval
  11073. How long to wait between "OK Still here" notifications when client
  11074. is IDLEing.
  11075. Defaults to @samp{"2 mins"}.
  11076. @end deftypevr
  11077. @deftypevr {@code{dovecot-configuration} parameter} string imap-id-send
  11078. ID field names and values to send to clients. Using * as the value
  11079. makes Dovecot use the default value. The following fields have default
  11080. values currently: name, version, os, os-version, support-url,
  11081. support-email.
  11082. Defaults to @samp{""}.
  11083. @end deftypevr
  11084. @deftypevr {@code{dovecot-configuration} parameter} string imap-id-log
  11085. ID fields sent by client to log. * means everything.
  11086. Defaults to @samp{""}.
  11087. @end deftypevr
  11088. @deftypevr {@code{dovecot-configuration} parameter} space-separated-string-list imap-client-workarounds
  11089. Workarounds for various client bugs:
  11090. @table @code
  11091. @item delay-newmail
  11092. Send EXISTS/RECENT new mail notifications only when replying to NOOP and
  11093. CHECK commands. Some clients ignore them otherwise, for example OSX
  11094. Mail (<v2.1). Outlook Express breaks more badly though, without this it
  11095. may show user "Message no longer in server" errors. Note that OE6
  11096. still breaks even with this workaround if synchronization is set to
  11097. "Headers Only".
  11098. @item tb-extra-mailbox-sep
  11099. Thunderbird gets somehow confused with LAYOUT=fs (mbox and dbox) and
  11100. adds extra @samp{/} suffixes to mailbox names. This option causes Dovecot to
  11101. ignore the extra @samp{/} instead of treating it as invalid mailbox name.
  11102. @item tb-lsub-flags
  11103. Show \Noselect flags for LSUB replies with LAYOUT=fs (e.g. mbox).
  11104. This makes Thunderbird realize they aren't selectable and show them
  11105. greyed out, instead of only later giving "not selectable" popup error.
  11106. @end table
  11107. Defaults to @samp{()}.
  11108. @end deftypevr
  11109. @deftypevr {@code{dovecot-configuration} parameter} string imap-urlauth-host
  11110. Host allowed in URLAUTH URLs sent by client. "*" allows all.
  11111. Defaults to @samp{""}.
  11112. @end deftypevr
  11113. Whew! Lots of configuration options. The nice thing about it though is
  11114. that GuixSD has a complete interface to Dovecot's configuration
  11115. language. This allows not only a nice way to declare configurations,
  11116. but also offers reflective capabilities as well: users can write code to
  11117. inspect and transform configurations from within Scheme.
  11118. However, it could be that you just want to get a @code{dovecot.conf} up
  11119. and running. In that case, you can pass an
  11120. @code{opaque-dovecot-configuration} as the @code{#:config} parameter to
  11121. @code{dovecot-service}. As its name indicates, an opaque configuration
  11122. does not have easy reflective capabilities.
  11123. Available @code{opaque-dovecot-configuration} fields are:
  11124. @deftypevr {@code{opaque-dovecot-configuration} parameter} package dovecot
  11125. The dovecot package.
  11126. @end deftypevr
  11127. @deftypevr {@code{opaque-dovecot-configuration} parameter} string string
  11128. The contents of the @code{dovecot.conf}, as a string.
  11129. @end deftypevr
  11130. For example, if your @code{dovecot.conf} is just the empty string, you
  11131. could instantiate a dovecot service like this:
  11132. @example
  11133. (dovecot-service #:config
  11134. (opaque-dovecot-configuration
  11135. (string "")))
  11136. @end example
  11137. @subsubheading OpenSMTPD Service
  11138. @deffn {Scheme Variable} opensmtpd-service-type
  11139. This is the type of the @uref{https://www.opensmtpd.org, OpenSMTPD}
  11140. service, whose value should be an @code{opensmtpd-configuration} object
  11141. as in this example:
  11142. @example
  11143. (service opensmtpd-service-type
  11144. (opensmtpd-configuration
  11145. (config-file (local-file "./my-smtpd.conf"))))
  11146. @end example
  11147. @end deffn
  11148. @deftp {Data Type} opensmtpd-configuration
  11149. Data type representing the configuration of opensmtpd.
  11150. @table @asis
  11151. @item @code{package} (default: @var{opensmtpd})
  11152. Package object of the OpenSMTPD SMTP server.
  11153. @item @code{config-file} (default: @var{%default-opensmtpd-file})
  11154. File-like object of the OpenSMTPD configuration file to use. By default
  11155. it listens on the loopback network interface, and allows for mail from
  11156. users and daemons on the local machine, as well as permitting email to
  11157. remote servers. Run @command{man smtpd.conf} for more information.
  11158. @end table
  11159. @end deftp
  11160. @subsubheading Exim Service
  11161. @cindex mail transfer agent (MTA)
  11162. @cindex MTA (mail transfer agent)
  11163. @cindex SMTP
  11164. @deffn {Scheme Variable} exim-service-type
  11165. This is the type of the @uref{https://exim.org, Exim} mail transfer
  11166. agent (MTA), whose value should be an @code{exim-configuration} object
  11167. as in this example:
  11168. @example
  11169. (service exim-service-type
  11170. (exim-configuration
  11171. (config-file (local-file "./my-exim.conf"))))
  11172. @end example
  11173. @end deffn
  11174. In order to use an @code{exim-service-type} service you must also have a
  11175. @code{mail-aliases-service-type} service present in your
  11176. @code{operating-system} (even if it has no aliases).
  11177. @deftp {Data Type} exim-configuration
  11178. Data type representing the configuration of exim.
  11179. @table @asis
  11180. @item @code{package} (default: @var{exim})
  11181. Package object of the Exim server.
  11182. @item @code{config-file} (default: @code{#f})
  11183. File-like object of the Exim configuration file to use. If its value is
  11184. @code{#f} then use the default configuration file from the package
  11185. provided in @code{package}. The resulting configuration file is loaded
  11186. after setting the @code{exim_user} and @code{exim_group} configuration
  11187. variables.
  11188. @end table
  11189. @end deftp
  11190. @subsubheading Mail Aliases Service
  11191. @cindex email aliases
  11192. @cindex aliases, for email addresses
  11193. @deffn {Scheme Variable} mail-aliases-service-type
  11194. This is the type of the service which provides @code{/etc/aliases},
  11195. specifying how to deliver mail to users on this system.
  11196. @example
  11197. (service mail-aliases-service-type
  11198. '(("postmaster" "bob")
  11199. ("bob" "bob@@example.com" "bob@@example2.com")))
  11200. @end example
  11201. @end deffn
  11202. The configuration for a @code{mail-aliases-service-type} service is an
  11203. association list denoting how to deliver mail that comes to this
  11204. system. Each entry is of the form @code{(alias addresses ...)}, with
  11205. @code{alias} specifying the local alias and @code{addresses} specifying
  11206. where to deliver this user's mail.
  11207. The aliases aren't required to exist as users on the local system. In
  11208. the above example, there doesn't need to be a @code{postmaster} entry in
  11209. the @code{operating-system}'s @code{user-accounts} in order to deliver
  11210. the @code{postmaster} mail to @code{bob} (which subsequently would
  11211. deliver mail to @code{bob@@example.com} and @code{bob@@example2.com}).
  11212. @node Messaging Services
  11213. @subsubsection Messaging Services
  11214. @cindex messaging
  11215. @cindex jabber
  11216. @cindex XMPP
  11217. The @code{(gnu services messaging)} module provides Guix service
  11218. definitions for messaging services: currently only Prosody is supported.
  11219. @subsubheading Prosody Service
  11220. @deffn {Scheme Variable} prosody-service-type
  11221. This is the type for the @uref{https://prosody.im, Prosody XMPP
  11222. communication server}. Its value must be a @code{prosody-configuration}
  11223. record as in this example:
  11224. @example
  11225. (service prosody-service-type
  11226. (prosody-configuration
  11227. (modules-enabled (cons "groups" "mam" %default-modules-enabled))
  11228. (int-components
  11229. (list
  11230. (int-component-configuration
  11231. (hostname "conference.example.net")
  11232. (plugin "muc")
  11233. (mod-muc (mod-muc-configuration)))))
  11234. (virtualhosts
  11235. (list
  11236. (virtualhost-configuration
  11237. (domain "example.net"))))))
  11238. @end example
  11239. See below for details about @code{prosody-configuration}.
  11240. @end deffn
  11241. By default, Prosody does not need much configuration. Only one
  11242. @code{virtualhosts} field is needed: it specifies the domain you wish
  11243. Prosody to serve.
  11244. You can perform various sanity checks on the generated configuration
  11245. with the @code{prosodyctl check} command.
  11246. Prosodyctl will also help you to import certificates from the
  11247. @code{letsencrypt} directory so that the @code{prosody} user can access
  11248. them. See @url{https://prosody.im/doc/letsencrypt}.
  11249. @example
  11250. prosodyctl --root cert import /etc/letsencrypt/live
  11251. @end example
  11252. The available configuration parameters follow. Each parameter
  11253. definition is preceded by its type; for example, @samp{string-list foo}
  11254. indicates that the @code{foo} parameter should be specified as a list of
  11255. strings. Types starting with @code{maybe-} denote parameters that won't
  11256. show up in @code{prosody.cfg.lua} when their value is @code{'disabled}.
  11257. There is also a way to specify the configuration as a string, if you
  11258. have an old @code{prosody.cfg.lua} file that you want to port over from
  11259. some other system; see the end for more details.
  11260. @c The following documentation was initially generated by
  11261. @c (generate-documentation) in (gnu services messaging). Manually maintained
  11262. @c documentation is better, so we shouldn't hesitate to edit below as
  11263. @c needed. However if the change you want to make to this documentation
  11264. @c can be done in an automated way, it's probably easier to change
  11265. @c (generate-documentation) than to make it below and have to deal with
  11266. @c the churn as Prosody updates.
  11267. Available @code{prosody-configuration} fields are:
  11268. @deftypevr {@code{prosody-configuration} parameter} package prosody
  11269. The Prosody package.
  11270. @end deftypevr
  11271. @deftypevr {@code{prosody-configuration} parameter} file-name data-path
  11272. Location of the Prosody data storage directory. See
  11273. @url{https://prosody.im/doc/configure}.
  11274. Defaults to @samp{"/var/lib/prosody"}.
  11275. @end deftypevr
  11276. @deftypevr {@code{prosody-configuration} parameter} file-name-list plugin-paths
  11277. Additional plugin directories. They are searched in all the specified
  11278. paths in order. See @url{https://prosody.im/doc/plugins_directory}.
  11279. Defaults to @samp{()}.
  11280. @end deftypevr
  11281. @deftypevr {@code{prosody-configuration} parameter} file-name certificates
  11282. Every virtual host and component needs a certificate so that clients and
  11283. servers can securely verify its identity. Prosody will automatically load
  11284. certificates/keys from the directory specified here.
  11285. Defaults to @samp{"/etc/prosody/certs"}.
  11286. @end deftypevr
  11287. @deftypevr {@code{prosody-configuration} parameter} string-list admins
  11288. This is a list of accounts that are admins for the server. Note that you
  11289. must create the accounts separately. See @url{https://prosody.im/doc/admins} and
  11290. @url{https://prosody.im/doc/creating_accounts}.
  11291. Example: @code{(admins '("user1@@example.com" "user2@@example.net"))}
  11292. Defaults to @samp{()}.
  11293. @end deftypevr
  11294. @deftypevr {@code{prosody-configuration} parameter} boolean use-libevent?
  11295. Enable use of libevent for better performance under high load. See
  11296. @url{https://prosody.im/doc/libevent}.
  11297. Defaults to @samp{#f}.
  11298. @end deftypevr
  11299. @deftypevr {@code{prosody-configuration} parameter} module-list modules-enabled
  11300. This is the list of modules Prosody will load on startup. It looks for
  11301. @code{mod_modulename.lua} in the plugins folder, so make sure that exists too.
  11302. Documentation on modules can be found at:
  11303. @url{https://prosody.im/doc/modules}.
  11304. Defaults to @samp{("roster" "saslauth" "tls" "dialback" "disco" "carbons" "private" "blocklist" "vcard" "version" "uptime" "time" "ping" "pep" "register" "admin_adhoc")}.
  11305. @end deftypevr
  11306. @deftypevr {@code{prosody-configuration} parameter} string-list modules-disabled
  11307. @samp{"offline"}, @samp{"c2s"} and @samp{"s2s"} are auto-loaded, but
  11308. should you want to disable them then add them to this list.
  11309. Defaults to @samp{()}.
  11310. @end deftypevr
  11311. @deftypevr {@code{prosody-configuration} parameter} file-name groups-file
  11312. Path to a text file where the shared groups are defined. If this path is
  11313. empty then @samp{mod_groups} does nothing. See
  11314. @url{https://prosody.im/doc/modules/mod_groups}.
  11315. Defaults to @samp{"/var/lib/prosody/sharedgroups.txt"}.
  11316. @end deftypevr
  11317. @deftypevr {@code{prosody-configuration} parameter} boolean allow-registration?
  11318. Disable account creation by default, for security. See
  11319. @url{https://prosody.im/doc/creating_accounts}.
  11320. Defaults to @samp{#f}.
  11321. @end deftypevr
  11322. @deftypevr {@code{prosody-configuration} parameter} maybe-ssl-configuration ssl
  11323. These are the SSL/TLS-related settings. Most of them are disabled so to
  11324. use Prosody's defaults. If you do not completely understand these options, do
  11325. not add them to your config, it is easy to lower the security of your server
  11326. using them. See @url{https://prosody.im/doc/advanced_ssl_config}.
  11327. Available @code{ssl-configuration} fields are:
  11328. @deftypevr {@code{ssl-configuration} parameter} maybe-string protocol
  11329. This determines what handshake to use.
  11330. @end deftypevr
  11331. @deftypevr {@code{ssl-configuration} parameter} maybe-file-name key
  11332. Path to your private key file.
  11333. @end deftypevr
  11334. @deftypevr {@code{ssl-configuration} parameter} maybe-file-name certificate
  11335. Path to your certificate file.
  11336. @end deftypevr
  11337. @deftypevr {@code{ssl-configuration} parameter} file-name capath
  11338. Path to directory containing root certificates that you wish Prosody to
  11339. trust when verifying the certificates of remote servers.
  11340. Defaults to @samp{"/etc/ssl/certs"}.
  11341. @end deftypevr
  11342. @deftypevr {@code{ssl-configuration} parameter} maybe-file-name cafile
  11343. Path to a file containing root certificates that you wish Prosody to trust.
  11344. Similar to @code{capath} but with all certificates concatenated together.
  11345. @end deftypevr
  11346. @deftypevr {@code{ssl-configuration} parameter} maybe-string-list verify
  11347. A list of verification options (these mostly map to OpenSSL's
  11348. @code{set_verify()} flags).
  11349. @end deftypevr
  11350. @deftypevr {@code{ssl-configuration} parameter} maybe-string-list options
  11351. A list of general options relating to SSL/TLS. These map to OpenSSL's
  11352. @code{set_options()}. For a full list of options available in LuaSec, see the
  11353. LuaSec source.
  11354. @end deftypevr
  11355. @deftypevr {@code{ssl-configuration} parameter} maybe-non-negative-integer depth
  11356. How long a chain of certificate authorities to check when looking for a
  11357. trusted root certificate.
  11358. @end deftypevr
  11359. @deftypevr {@code{ssl-configuration} parameter} maybe-string ciphers
  11360. An OpenSSL cipher string. This selects what ciphers Prosody will offer to
  11361. clients, and in what order.
  11362. @end deftypevr
  11363. @deftypevr {@code{ssl-configuration} parameter} maybe-file-name dhparam
  11364. A path to a file containing parameters for Diffie-Hellman key exchange. You
  11365. can create such a file with:
  11366. @code{openssl dhparam -out /etc/prosody/certs/dh-2048.pem 2048}
  11367. @end deftypevr
  11368. @deftypevr {@code{ssl-configuration} parameter} maybe-string curve
  11369. Curve for Elliptic curve Diffie-Hellman. Prosody's default is
  11370. @samp{"secp384r1"}.
  11371. @end deftypevr
  11372. @deftypevr {@code{ssl-configuration} parameter} maybe-string-list verifyext
  11373. A list of "extra" verification options.
  11374. @end deftypevr
  11375. @deftypevr {@code{ssl-configuration} parameter} maybe-string password
  11376. Password for encrypted private keys.
  11377. @end deftypevr
  11378. @end deftypevr
  11379. @deftypevr {@code{prosody-configuration} parameter} boolean c2s-require-encryption?
  11380. Whether to force all client-to-server connections to be encrypted or not.
  11381. See @url{https://prosody.im/doc/modules/mod_tls}.
  11382. Defaults to @samp{#f}.
  11383. @end deftypevr
  11384. @deftypevr {@code{prosody-configuration} parameter} string-list disable-sasl-mechanisms
  11385. Set of mechanisms that will never be offered. See
  11386. @url{https://prosody.im/doc/modules/mod_saslauth}.
  11387. Defaults to @samp{("DIGEST-MD5")}.
  11388. @end deftypevr
  11389. @deftypevr {@code{prosody-configuration} parameter} boolean s2s-require-encryption?
  11390. Whether to force all server-to-server connections to be encrypted or not.
  11391. See @url{https://prosody.im/doc/modules/mod_tls}.
  11392. Defaults to @samp{#f}.
  11393. @end deftypevr
  11394. @deftypevr {@code{prosody-configuration} parameter} boolean s2s-secure-auth?
  11395. Whether to require encryption and certificate authentication. This
  11396. provides ideal security, but requires servers you communicate with to support
  11397. encryption AND present valid, trusted certificates. See
  11398. @url{https://prosody.im/doc/s2s#security}.
  11399. Defaults to @samp{#f}.
  11400. @end deftypevr
  11401. @deftypevr {@code{prosody-configuration} parameter} string-list s2s-insecure-domains
  11402. Many servers don't support encryption or have invalid or self-signed
  11403. certificates. You can list domains here that will not be required to
  11404. authenticate using certificates. They will be authenticated using DNS. See
  11405. @url{https://prosody.im/doc/s2s#security}.
  11406. Defaults to @samp{()}.
  11407. @end deftypevr
  11408. @deftypevr {@code{prosody-configuration} parameter} string-list s2s-secure-domains
  11409. Even if you leave @code{s2s-secure-auth?} disabled, you can still require
  11410. valid certificates for some domains by specifying a list here. See
  11411. @url{https://prosody.im/doc/s2s#security}.
  11412. Defaults to @samp{()}.
  11413. @end deftypevr
  11414. @deftypevr {@code{prosody-configuration} parameter} string authentication
  11415. Select the authentication backend to use. The default provider stores
  11416. passwords in plaintext and uses Prosody's configured data storage to store the
  11417. authentication data. If you do not trust your server please see
  11418. @url{https://prosody.im/doc/modules/mod_auth_internal_hashed} for information
  11419. about using the hashed backend. See also
  11420. @url{https://prosody.im/doc/authentication}
  11421. Defaults to @samp{"internal_plain"}.
  11422. @end deftypevr
  11423. @deftypevr {@code{prosody-configuration} parameter} maybe-string log
  11424. Set logging options. Advanced logging configuration is not yet supported
  11425. by the GuixSD Prosody Service. See @url{https://prosody.im/doc/logging}.
  11426. Defaults to @samp{"*syslog"}.
  11427. @end deftypevr
  11428. @deftypevr {@code{prosody-configuration} parameter} file-name pidfile
  11429. File to write pid in. See @url{https://prosody.im/doc/modules/mod_posix}.
  11430. Defaults to @samp{"/var/run/prosody/prosody.pid"}.
  11431. @end deftypevr
  11432. @deftypevr {@code{prosody-configuration} parameter} maybe-non-negative-integer http-max-content-size
  11433. Maximum allowed size of the HTTP body (in bytes).
  11434. @end deftypevr
  11435. @deftypevr {@code{prosody-configuration} parameter} maybe-string http-external-url
  11436. Some modules expose their own URL in various ways. This URL is built
  11437. from the protocol, host and port used. If Prosody sits behind a proxy, the
  11438. public URL will be @code{http-external-url} instead. See
  11439. @url{https://prosody.im/doc/http#external_url}.
  11440. @end deftypevr
  11441. @deftypevr {@code{prosody-configuration} parameter} virtualhost-configuration-list virtualhosts
  11442. A host in Prosody is a domain on which user accounts can be created. For
  11443. example if you want your users to have addresses like
  11444. @samp{"john.smith@@example.com"} then you need to add a host
  11445. @samp{"example.com"}. All options in this list will apply only to this host.
  11446. Note: the name "virtual" host is used in configuration to avoid confusion with
  11447. the actual physical host that Prosody is installed on. A single Prosody
  11448. instance can serve many domains, each one defined as a VirtualHost entry in
  11449. Prosody's configuration. Conversely a server that hosts a single domain would
  11450. have just one VirtualHost entry.
  11451. See @url{https://prosody.im/doc/configure#virtual_host_settings}.
  11452. Available @code{virtualhost-configuration} fields are:
  11453. all these @code{prosody-configuration} fields: @code{admins}, @code{use-libevent?}, @code{modules-enabled}, @code{modules-disabled}, @code{groups-file}, @code{allow-registration?}, @code{ssl}, @code{c2s-require-encryption?}, @code{disable-sasl-mechanisms}, @code{s2s-require-encryption?}, @code{s2s-secure-auth?}, @code{s2s-insecure-domains}, @code{s2s-secure-domains}, @code{authentication}, @code{log}, @code{http-max-content-size}, @code{http-external-url}, @code{raw-content}, plus:
  11454. @deftypevr {@code{virtualhost-configuration} parameter} string domain
  11455. Domain you wish Prosody to serve.
  11456. @end deftypevr
  11457. @end deftypevr
  11458. @deftypevr {@code{prosody-configuration} parameter} int-component-configuration-list int-components
  11459. Components are extra services on a server which are available to clients,
  11460. usually on a subdomain of the main server (such as
  11461. @samp{"mycomponent.example.com"}). Example components might be chatroom
  11462. servers, user directories, or gateways to other protocols.
  11463. Internal components are implemented with Prosody-specific plugins. To add an
  11464. internal component, you simply fill the hostname field, and the plugin you wish
  11465. to use for the component.
  11466. See @url{https://prosody.im/doc/components}.
  11467. Defaults to @samp{()}.
  11468. Available @code{int-component-configuration} fields are:
  11469. all these @code{prosody-configuration} fields: @code{admins}, @code{use-libevent?}, @code{modules-enabled}, @code{modules-disabled}, @code{groups-file}, @code{allow-registration?}, @code{ssl}, @code{c2s-require-encryption?}, @code{disable-sasl-mechanisms}, @code{s2s-require-encryption?}, @code{s2s-secure-auth?}, @code{s2s-insecure-domains}, @code{s2s-secure-domains}, @code{authentication}, @code{log}, @code{http-max-content-size}, @code{http-external-url}, @code{raw-content}, plus:
  11470. @deftypevr {@code{int-component-configuration} parameter} string hostname
  11471. Hostname of the component.
  11472. @end deftypevr
  11473. @deftypevr {@code{int-component-configuration} parameter} string plugin
  11474. Plugin you wish to use for the component.
  11475. @end deftypevr
  11476. @deftypevr {@code{int-component-configuration} parameter} maybe-mod-muc-configuration mod-muc
  11477. Multi-user chat (MUC) is Prosody's module for allowing you to create
  11478. hosted chatrooms/conferences for XMPP users.
  11479. General information on setting up and using multi-user chatrooms can be found
  11480. in the "Chatrooms" documentation (@url{https://prosody.im/doc/chatrooms}),
  11481. which you should read if you are new to XMPP chatrooms.
  11482. See also @url{https://prosody.im/doc/modules/mod_muc}.
  11483. Available @code{mod-muc-configuration} fields are:
  11484. @deftypevr {@code{mod-muc-configuration} parameter} string name
  11485. The name to return in service discovery responses.
  11486. Defaults to @samp{"Prosody Chatrooms"}.
  11487. @end deftypevr
  11488. @deftypevr {@code{mod-muc-configuration} parameter} string-or-boolean restrict-room-creation
  11489. If @samp{#t}, this will only allow admins to create new chatrooms.
  11490. Otherwise anyone can create a room. The value @samp{"local"} restricts room
  11491. creation to users on the service's parent domain. E.g. @samp{user@@example.com}
  11492. can create rooms on @samp{rooms.example.com}. The value @samp{"admin"}
  11493. restricts to service administrators only.
  11494. Defaults to @samp{#f}.
  11495. @end deftypevr
  11496. @deftypevr {@code{mod-muc-configuration} parameter} non-negative-integer max-history-messages
  11497. Maximum number of history messages that will be sent to the member that has
  11498. just joined the room.
  11499. Defaults to @samp{20}.
  11500. @end deftypevr
  11501. @end deftypevr
  11502. @end deftypevr
  11503. @deftypevr {@code{prosody-configuration} parameter} ext-component-configuration-list ext-components
  11504. External components use XEP-0114, which most standalone components
  11505. support. To add an external component, you simply fill the hostname field. See
  11506. @url{https://prosody.im/doc/components}.
  11507. Defaults to @samp{()}.
  11508. Available @code{ext-component-configuration} fields are:
  11509. all these @code{prosody-configuration} fields: @code{admins}, @code{use-libevent?}, @code{modules-enabled}, @code{modules-disabled}, @code{groups-file}, @code{allow-registration?}, @code{ssl}, @code{c2s-require-encryption?}, @code{disable-sasl-mechanisms}, @code{s2s-require-encryption?}, @code{s2s-secure-auth?}, @code{s2s-insecure-domains}, @code{s2s-secure-domains}, @code{authentication}, @code{log}, @code{http-max-content-size}, @code{http-external-url}, @code{raw-content}, plus:
  11510. @deftypevr {@code{ext-component-configuration} parameter} string component-secret
  11511. Password which the component will use to log in.
  11512. @end deftypevr
  11513. @deftypevr {@code{ext-component-configuration} parameter} string hostname
  11514. Hostname of the component.
  11515. @end deftypevr
  11516. @end deftypevr
  11517. @deftypevr {@code{prosody-configuration} parameter} non-negative-integer-list component-ports
  11518. Port(s) Prosody listens on for component connections.
  11519. Defaults to @samp{(5347)}.
  11520. @end deftypevr
  11521. @deftypevr {@code{prosody-configuration} parameter} string component-interface
  11522. Interface Prosody listens on for component connections.
  11523. Defaults to @samp{"127.0.0.1"}.
  11524. @end deftypevr
  11525. @deftypevr {@code{prosody-configuration} parameter} maybe-raw-content raw-content
  11526. Raw content that will be added to the configuration file.
  11527. @end deftypevr
  11528. It could be that you just want to get a @code{prosody.cfg.lua}
  11529. up and running. In that case, you can pass an
  11530. @code{opaque-prosody-configuration} record as the value of
  11531. @code{prosody-service-type}. As its name indicates, an opaque configuration
  11532. does not have easy reflective capabilities.
  11533. Available @code{opaque-prosody-configuration} fields are:
  11534. @deftypevr {@code{opaque-prosody-configuration} parameter} package prosody
  11535. The prosody package.
  11536. @end deftypevr
  11537. @deftypevr {@code{opaque-prosody-configuration} parameter} string prosody.cfg.lua
  11538. The contents of the @code{prosody.cfg.lua} to use.
  11539. @end deftypevr
  11540. For example, if your @code{prosody.cfg.lua} is just the empty
  11541. string, you could instantiate a prosody service like this:
  11542. @example
  11543. (service prosody-service-type
  11544. (opaque-prosody-configuration
  11545. (prosody.cfg.lua "")))
  11546. @end example
  11547. @subsubheading BitlBee Service
  11548. @cindex IRC (Internet Relay Chat)
  11549. @cindex IRC gateway
  11550. @url{http://bitlbee.org,BitlBee} is a gateway that provides an IRC
  11551. interface to a variety of messaging protocols such as XMPP.
  11552. @defvr {Scheme Variable} bitlbee-service-type
  11553. This is the service type for the @url{http://bitlbee.org,BitlBee} IRC
  11554. gateway daemon. Its value is a @code{bitlbee-configuration} (see
  11555. below).
  11556. To have BitlBee listen on port 6667 on localhost, add this line to your
  11557. services:
  11558. @example
  11559. (service bitlbee-service-type)
  11560. @end example
  11561. @end defvr
  11562. @deftp {Data Type} bitlbee-configuration
  11563. This is the configuration for BitlBee, with the following fields:
  11564. @table @asis
  11565. @item @code{interface} (default: @code{"127.0.0.1"})
  11566. @itemx @code{port} (default: @code{6667})
  11567. Listen on the network interface corresponding to the IP address
  11568. specified in @var{interface}, on @var{port}.
  11569. When @var{interface} is @code{127.0.0.1}, only local clients can
  11570. connect; when it is @code{0.0.0.0}, connections can come from any
  11571. networking interface.
  11572. @item @code{package} (default: @code{bitlbee})
  11573. The BitlBee package to use.
  11574. @item @code{extra-settings} (default: @code{""})
  11575. Configuration snippet added as-is to the BitlBee configuration file.
  11576. @end table
  11577. @end deftp
  11578. @node Telephony Services
  11579. @subsubsection Telephony Services
  11580. @cindex Murmur (VoIP server)
  11581. @cindex VoIP server
  11582. This section describes how to set up and run a Murmur server. Murmur is
  11583. the server of the @uref{https://mumble.info, Mumble} voice-over-IP
  11584. (VoIP) suite.
  11585. @deftp {Data Type} murmur-configuration
  11586. The service type for the Murmur server. An example configuration can
  11587. look like this:
  11588. @example
  11589. (service murmur-service-type
  11590. (murmur-configuration
  11591. (welcome-text
  11592. "Welcome to this Mumble server running on GuixSD!")
  11593. (cert-required? #t) ;disallow text password logins
  11594. (ssl-cert "/etc/letsencrypt/live/mumble.example.com/fullchain.pem")
  11595. (ssl-key "/etc/letsencrypt/live/mumble.example.com/privkey.pem")))
  11596. @end example
  11597. After reconfiguring your system, you can manually set the murmur @code{SuperUser}
  11598. password with the command that is printed during the activation phase.
  11599. It is recommended to register a normal Mumble user account
  11600. and grant it admin or moderator rights.
  11601. You can use the @code{mumble} client to
  11602. login as new normal user, register yourself, and log out.
  11603. For the next step login with the name @code{SuperUser} use
  11604. the @code{SuperUser} password that you set previously,
  11605. and grant your newly registered mumble user administrator or moderator
  11606. rights and create some channels.
  11607. Available @code{murmur-configuration} fields are:
  11608. @table @asis
  11609. @item @code{package} (default: @code{mumble})
  11610. Package that contains @code{bin/murmurd}.
  11611. @item @code{user} (default: @code{"murmur"})
  11612. User who will run the Murmur server.
  11613. @item @code{group} (default: @code{"murmur"})
  11614. Group of the user who will run the murmur server.
  11615. @item @code{port} (default: @code{64738})
  11616. Port on which the server will listen.
  11617. @item @code{welcome-text} (default: @code{""})
  11618. Welcome text sent to clients when they connect.
  11619. @item @code{server-password} (default: @code{""})
  11620. Password the clients have to enter in order to connect.
  11621. @item @code{max-users} (default: @code{100})
  11622. Maximum of users that can be connected to the server at once.
  11623. @item @code{max-user-bandwidth} (default: @code{#f})
  11624. Maximum voice traffic a user can send per second.
  11625. @item @code{database-file} (default: @code{"/var/lib/murmur/db.sqlite"})
  11626. File name of the sqlite database.
  11627. The service's user will become the owner of the directory.
  11628. @item @code{log-file} (default: @code{"/var/log/murmur/murmur.log"})
  11629. File name of the log file.
  11630. The service's user will become the owner of the directory.
  11631. @item @code{autoban-attempts} (default: @code{10})
  11632. Maximum number of logins a user can make in @code{autoban-timeframe}
  11633. without getting auto banned for @code{autoban-time}.
  11634. @item @code{autoban-timeframe} (default: @code{120})
  11635. Timeframe for autoban in seconds.
  11636. @item @code{autoban-time} (default: @code{300})
  11637. Amount of time in seconds for which a client gets banned
  11638. when violating the autoban limits.
  11639. @item @code{opus-threshold} (default: @code{100})
  11640. Percentage of clients that need to support opus
  11641. before switching over to opus audio codec.
  11642. @item @code{channel-nesting-limit} (default: @code{10})
  11643. How deep channels can be nested at maximum.
  11644. @item @code{channelname-regex} (default: @code{#f})
  11645. A string in from of a Qt regular expression that channel names must conform to.
  11646. @item @code{username-regex} (default: @code{#f})
  11647. A string in from of a Qt regular expression that user names must conform to.
  11648. @item @code{text-message-length} (default: @code{5000})
  11649. Maximum size in bytes that a user can send in one text chat message.
  11650. @item @code{image-message-length} (default: @code{(* 128 1024)})
  11651. Maximum size in bytes that a user can send in one image message.
  11652. @item @code{cert-required?} (default: @code{#f})
  11653. If it is set to @code{#t} clients that use weak password authentification
  11654. will not be accepted. Users must have completed the certificate wizard to join.
  11655. @item @code{remember-channel?} (defualt @code{#f})
  11656. Should murmur remember the last channel each user was in when they disconnected
  11657. and put them into the remembered channel when they rejoin.
  11658. @item @code{allow-html?} (default: @code{#f})
  11659. Should html be allowed in text messages, user comments, and channel descriptions.
  11660. @item @code{allow-ping?} (default: @code{#f})
  11661. Setting to true exposes the current user count, the maximum user count, and
  11662. the server's maximum bandwidth per client to unauthenticated users. In the
  11663. Mumble client, this information is shown in the Connect dialog.
  11664. Disabling this setting will prevent public listing of the server.
  11665. @item @code{bonjour?} (default: @code{#f})
  11666. Should the server advertise itself in the local network through the bonjour protocol.
  11667. @item @code{send-version?} (default: @code{#f})
  11668. Should the murmur server version be exposed in ping requests.
  11669. @item @code{log-days} (default: @code{31})
  11670. Murmur also stores logs in the database, which are accessible via RPC.
  11671. The default is 31 days of months, but you can set this setting to 0 to keep logs forever,
  11672. or -1 to disable logging to the database.
  11673. @item @code{obfuscate-ips?} (default @code{#t})
  11674. Should logged ips be obfuscated to protect the privacy of users.
  11675. @item @code{ssl-cert} (default: @code{#f})
  11676. File name of the SSL/TLS certificate used for encrypted connections.
  11677. @example
  11678. (ssl-cert "/etc/letsencrypt/live/example.com/fullchain.pem")
  11679. @end example
  11680. @item @code{ssl-key} (default: @code{#f})
  11681. Filepath to the ssl private key used for encrypted connections.
  11682. @example
  11683. (ssl-key "/etc/letsencrypt/live/example.com/privkey.pem")
  11684. @end example
  11685. @item @code{ssl-dh-params} (default: @code{#f})
  11686. File name of a PEM-encoded file with Diffie-Hellman parameters
  11687. for the SSL/TLS encryption. Alternatively you set it to
  11688. @code{"@@ffdhe2048"}, @code{"@@ffdhe3072"}, @code{"@@ffdhe4096"}, @code{"@@ffdhe6144"}
  11689. or @code{"@@ffdhe8192"} to use bundled parameters from RFC 7919.
  11690. @item @code{ssl-ciphers} (default: @code{#f})
  11691. The @code{ssl-ciphers} option chooses the cipher suites to make available for use
  11692. in SSL/TLS.
  11693. This option is specified using
  11694. @uref{https://www.openssl.org/docs/apps/ciphers.html#CIPHER-LIST-FORMAT,
  11695. OpenSSL cipher list notation}.
  11696. It is recommended that you try your cipher string using 'openssl ciphers <string>'
  11697. before setting it here, to get a feel for which cipher suites you will get.
  11698. After setting this option, it is recommend that you inspect your Murmur log
  11699. to ensure that Murmur is using the cipher suites that you expected it to.
  11700. Note: Changing this option may impact the backwards compatibility of your
  11701. Murmur server, and can remove the ability for older Mumble clients to be able
  11702. to connect to it.
  11703. @item @code{public-registration} (default: @code{#f})
  11704. Must be a @code{<murmur-public-registration-configuration>} record or @code{#f}.
  11705. You can optionally register your server in the public server list that the
  11706. @code{mumble} client shows on startup.
  11707. You cannot register your server if you have set a @code{server-password},
  11708. or set @code{allow-ping} to @code{#f}.
  11709. It might take a few hours until it shows up in the public list.
  11710. @item @code{file} (default: @code{#f})
  11711. Optional alternative override for this configuration.
  11712. @end table
  11713. @end deftp
  11714. @deftp {Data Type} murmur-public-registration-configuration
  11715. Configuration for public registration of a murmur service.
  11716. @table @asis
  11717. @item @code{name}
  11718. This is a display name for your server. Not to be confused with the hostname.
  11719. @item @code{password}
  11720. A password to identify your registration.
  11721. Subsequent updates will need the same password. Don't lose your password.
  11722. @item @code{url}
  11723. This should be a @code{http://} or @code{https://} link to your web
  11724. site.
  11725. @item @code{hostname} (default: @code{#f})
  11726. By default your server will be listed by its IP address.
  11727. If it is set your server will be linked by this host name instead.
  11728. @end table
  11729. @end deftp
  11730. @node Monitoring Services
  11731. @subsubsection Monitoring Services
  11732. @subsubheading Tailon Service
  11733. @uref{https://tailon.readthedocs.io/, Tailon} is a web application for
  11734. viewing and searching log files.
  11735. The following example will configure the service with default values.
  11736. By default, Tailon can be accessed on port 8080 (@code{http://localhost:8080}).
  11737. @example
  11738. (service tailon-service-type)
  11739. @end example
  11740. The following example customises more of the Tailon configuration,
  11741. adding @command{sed} to the list of allowed commands.
  11742. @example
  11743. (service tailon-service-type
  11744. (tailon-configuration
  11745. (config-file
  11746. (tailon-configuration-file
  11747. (allowed-commands '("tail" "grep" "awk" "sed"))))))
  11748. @end example
  11749. @deftp {Data Type} tailon-configuration
  11750. Data type representing the configuration of Tailon.
  11751. This type has the following parameters:
  11752. @table @asis
  11753. @item @code{config-file} (default: @code{(tailon-configuration-file)})
  11754. The configuration file to use for Tailon. This can be set to a
  11755. @dfn{tailon-configuration-file} record value, or any gexp
  11756. (@pxref{G-Expressions}).
  11757. For example, to instead use a local file, the @code{local-file} function
  11758. can be used:
  11759. @example
  11760. (service tailon-service-type
  11761. (tailon-configuration
  11762. (config-file (local-file "./my-tailon.conf"))))
  11763. @end example
  11764. @item @code{package} (default: @code{tailon})
  11765. The tailon package to use.
  11766. @end table
  11767. @end deftp
  11768. @deftp {Data Type} tailon-configuration-file
  11769. Data type representing the configuration options for Tailon.
  11770. This type has the following parameters:
  11771. @table @asis
  11772. @item @code{files} (default: @code{(list "/var/log")})
  11773. List of files to display. The list can include strings for a single file
  11774. or directory, or a list, where the first item is the name of a
  11775. subsection, and the remaining items are the files or directories in that
  11776. subsection.
  11777. @item @code{bind} (default: @code{"localhost:8080"})
  11778. Address and port to which Tailon should bind on.
  11779. @item @code{relative-root} (default: @code{#f})
  11780. URL path to use for Tailon, set to @code{#f} to not use a path.
  11781. @item @code{allow-transfers?} (default: @code{#t})
  11782. Allow downloading the log files in the web interface.
  11783. @item @code{follow-names?} (default: @code{#t})
  11784. Allow tailing of not-yet existent files.
  11785. @item @code{tail-lines} (default: @code{200})
  11786. Number of lines to read initially from each file.
  11787. @item @code{allowed-commands} (default: @code{(list "tail" "grep" "awk")})
  11788. Commands to allow running. By default, @code{sed} is disabled.
  11789. @item @code{debug?} (default: @code{#f})
  11790. Set @code{debug?} to @code{#t} to show debug messages.
  11791. @item @code{wrap-lines} (default: @code{#t})
  11792. Initial line wrapping state in the web interface. Set to @code{#t} to
  11793. initially wrap lines (the default), or to @code{#f} to initially not
  11794. wrap lines.
  11795. @item @code{http-auth} (default: @code{#f})
  11796. HTTP authentication type to use. Set to @code{#f} to disable
  11797. authentication (the default). Supported values are @code{"digest"} or
  11798. @code{"basic"}.
  11799. @item @code{users} (default: @code{#f})
  11800. If HTTP authentication is enabled (see @code{http-auth}), access will be
  11801. restricted to the credentials provided here. To configure users, use a
  11802. list of pairs, where the first element of the pair is the username, and
  11803. the 2nd element of the pair is the password.
  11804. @example
  11805. (tailon-configuration-file
  11806. (http-auth "basic")
  11807. (users '(("user1" . "password1")
  11808. ("user2" . "password2"))))
  11809. @end example
  11810. @end table
  11811. @end deftp
  11812. @subsubheading Darkstat Service
  11813. @cindex darkstat
  11814. Darkstat is a packet sniffer that captures network traffic, calculates
  11815. statistics about usage, and serves reports over HTTP.
  11816. @defvar {Scheme Variable} darkstat-service-type
  11817. This is the service type for the
  11818. @uref{https://unix4lyfe.org/darkstat/, darkstat}
  11819. service, its value must be a @code{darkstat-configuration} record as in
  11820. this example:
  11821. @example
  11822. (service darkstat-service-type
  11823. (darkstat-configuration
  11824. (interface "eno1")))
  11825. @end example
  11826. @end defvar
  11827. @deftp {Data Type} darkstat-configuration
  11828. Data type representing the configuration of @command{darkstat}.
  11829. @table @asis
  11830. @item @code{package} (default: @code{darkstat})
  11831. The darkstat package to use.
  11832. @item @code{interface}
  11833. Capture traffic on the specified network interface.
  11834. @item @code{port} (default: @code{"667"})
  11835. Bind the web interface to the specified port.
  11836. @item @code{bind-address} (default: @code{"127.0.0.1"})
  11837. Bind the web interface to the specified address.
  11838. @item @code{base} (default: @code{"/"})
  11839. Specify the path of the base URL. This can be useful if
  11840. @command{darkstat} is accessed via a reverse proxy.
  11841. @end table
  11842. @end deftp
  11843. @node Kerberos Services
  11844. @subsubsection Kerberos Services
  11845. @cindex Kerberos
  11846. The @code{(gnu services kerberos)} module provides services relating to
  11847. the authentication protocol @dfn{Kerberos}.
  11848. @subsubheading Krb5 Service
  11849. Programs using a Kerberos client library normally
  11850. expect a configuration file in @file{/etc/krb5.conf}.
  11851. This service generates such a file from a definition provided in the
  11852. operating system declaration.
  11853. It does not cause any daemon to be started.
  11854. No ``keytab'' files are provided by this service---you must explicitly create them.
  11855. This service is known to work with the MIT client library, @code{mit-krb5}.
  11856. Other implementations have not been tested.
  11857. @defvr {Scheme Variable} krb5-service-type
  11858. A service type for Kerberos 5 clients.
  11859. @end defvr
  11860. @noindent
  11861. Here is an example of its use:
  11862. @lisp
  11863. (service krb5-service-type
  11864. (krb5-configuration
  11865. (default-realm "EXAMPLE.COM")
  11866. (allow-weak-crypto? #t)
  11867. (realms (list
  11868. (krb5-realm
  11869. (name "EXAMPLE.COM")
  11870. (admin-server "groucho.example.com")
  11871. (kdc "karl.example.com"))
  11872. (krb5-realm
  11873. (name "ARGRX.EDU")
  11874. (admin-server "kerb-admin.argrx.edu")
  11875. (kdc "keys.argrx.edu"))))))
  11876. @end lisp
  11877. @noindent
  11878. This example provides a Kerberos@tie{}5 client configuration which:
  11879. @itemize
  11880. @item Recognizes two realms, @i{viz:} ``EXAMPLE.COM'' and ``ARGRX.EDU'', both
  11881. of which have distinct administration servers and key distribution centers;
  11882. @item Will default to the realm ``EXAMPLE.COM'' if the realm is not explicitly
  11883. specified by clients;
  11884. @item Accepts services which only support encryption types known to be weak.
  11885. @end itemize
  11886. The @code{krb5-realm} and @code{krb5-configuration} types have many fields.
  11887. Only the most commonly used ones are described here.
  11888. For a full list, and more detailed explanation of each, see the MIT
  11889. @uref{http://web.mit.edu/kerberos/krb5-devel/doc/admin/conf_files/krb5_conf.html,,krb5.conf}
  11890. documentation.
  11891. @deftp {Data Type} krb5-realm
  11892. @cindex realm, kerberos
  11893. @table @asis
  11894. @item @code{name}
  11895. This field is a string identifying the name of the realm.
  11896. A common convention is to use the fully qualified DNS name of your organization,
  11897. converted to upper case.
  11898. @item @code{admin-server}
  11899. This field is a string identifying the host where the administration server is
  11900. running.
  11901. @item @code{kdc}
  11902. This field is a string identifying the key distribution center
  11903. for the realm.
  11904. @end table
  11905. @end deftp
  11906. @deftp {Data Type} krb5-configuration
  11907. @table @asis
  11908. @item @code{allow-weak-crypto?} (default: @code{#f})
  11909. If this flag is @code{#t} then services which only offer encryption algorithms
  11910. known to be weak will be accepted.
  11911. @item @code{default-realm} (default: @code{#f})
  11912. This field should be a string identifying the default Kerberos
  11913. realm for the client.
  11914. You should set this field to the name of your Kerberos realm.
  11915. If this value is @code{#f}
  11916. then a realm must be specified with every Kerberos principal when invoking programs
  11917. such as @command{kinit}.
  11918. @item @code{realms}
  11919. This should be a non-empty list of @code{krb5-realm} objects, which clients may
  11920. access.
  11921. Normally, one of them will have a @code{name} field matching the @code{default-realm}
  11922. field.
  11923. @end table
  11924. @end deftp
  11925. @subsubheading PAM krb5 Service
  11926. @cindex pam-krb5
  11927. The @code{pam-krb5} service allows for login authentication and password
  11928. management via Kerberos.
  11929. You will need this service if you want PAM enabled applications to authenticate
  11930. users using Kerberos.
  11931. @defvr {Scheme Variable} pam-krb5-service-type
  11932. A service type for the Kerberos 5 PAM module.
  11933. @end defvr
  11934. @deftp {Data Type} pam-krb5-configuration
  11935. Data type representing the configuration of the Kerberos 5 PAM module
  11936. This type has the following parameters:
  11937. @table @asis
  11938. @item @code{pam-krb5} (default: @code{pam-krb5})
  11939. The pam-krb5 package to use.
  11940. @item @code{minimum-uid} (default: @code{1000})
  11941. The smallest user ID for which Kerberos authentications should be attempted.
  11942. Local accounts with lower values will silently fail to authenticate.
  11943. @end table
  11944. @end deftp
  11945. @node Web Services
  11946. @subsubsection Web Services
  11947. @cindex web
  11948. @cindex www
  11949. @cindex HTTP
  11950. The @code{(gnu services web)} module provides the nginx web server and
  11951. also a fastcgi wrapper daemon.
  11952. @deffn {Scheme Variable} nginx-service-type
  11953. Service type for the @uref{https://nginx.org/,NGinx} web server. The
  11954. value for this service type is a @code{<nginx-configuration>} record.
  11955. A simple example configuration is given below.
  11956. @example
  11957. (service nginx-service-type
  11958. (nginx-configuration
  11959. (server-blocks
  11960. (list (nginx-server-configuration
  11961. (server-name '("www.example.com"))
  11962. (root "/srv/http/www.example.com"))))))
  11963. @end example
  11964. In addition to adding server blocks to the service configuration
  11965. directly, this service can be extended by other services to add server
  11966. blocks, as in this example:
  11967. @example
  11968. (simple-service 'my-extra-server nginx-service-type
  11969. (list (nginx-server-configuration
  11970. (root "/srv/http/extra-website")
  11971. (try-files (list "$uri" "$uri/index.html")))))
  11972. @end example
  11973. @end deffn
  11974. At startup, @command{nginx} has not yet read its configuration file, so
  11975. it uses a default file to log error messages. If it fails to load its
  11976. configuration file, that is where error messages are logged. After the
  11977. configuration file is loaded, the default error log file changes as per
  11978. configuration. In our case, startup error messages can be found in
  11979. @file{/var/run/nginx/logs/error.log}, and after configuration in
  11980. @file{/var/log/nginx/error.log}. The second location can be changed
  11981. with the @var{log-directory} configuration option.
  11982. @deffn {Data Type} nginx-configuration
  11983. This data type represents the configuration for NGinx. Some
  11984. configuration can be done through this and the other provided record
  11985. types, or alternatively, a config file can be provided.
  11986. @table @asis
  11987. @item @code{nginx} (default: @code{nginx})
  11988. The nginx package to use.
  11989. @item @code{log-directory} (default: @code{"/var/log/nginx"})
  11990. The directory to which NGinx will write log files.
  11991. @item @code{run-directory} (default: @code{"/var/run/nginx"})
  11992. The directory in which NGinx will create a pid file, and write temporary
  11993. files.
  11994. @item @code{server-blocks} (default: @code{'()})
  11995. A list of @dfn{server blocks} to create in the generated configuration
  11996. file, the elements should be of type
  11997. @code{<nginx-server-configuration>}.
  11998. The following example would setup NGinx to serve @code{www.example.com}
  11999. from the @code{/srv/http/www.example.com} directory, without using
  12000. HTTPS.
  12001. @example
  12002. (service nginx-service-type
  12003. (nginx-configuration
  12004. (server-blocks
  12005. (list (nginx-server-configuration
  12006. (server-name '("www.example.com"))
  12007. (root "/srv/http/www.example.com"))))))
  12008. @end example
  12009. @item @code{upstream-blocks} (default: @code{'()})
  12010. A list of @dfn{upstream blocks} to create in the generated configuration
  12011. file, the elements should be of type
  12012. @code{<nginx-upstream-configuration>}.
  12013. Configuring upstreams through the @code{upstream-blocks} can be useful
  12014. when combined with @code{locations} in the
  12015. @code{<nginx-server-configuration>} records. The following example
  12016. creates a server configuration with one location configuration, that
  12017. will proxy requests to a upstream configuration, which will handle
  12018. requests with two servers.
  12019. @example
  12020. (service
  12021. nginx-service-type
  12022. (nginx-configuration
  12023. (server-blocks
  12024. (list (nginx-server-configuration
  12025. (server-name '("www.example.com"))
  12026. (root "/srv/http/www.example.com")
  12027. (locations
  12028. (list
  12029. (nginx-location-configuration
  12030. (uri "/path1")
  12031. (body '("proxy_pass http://server-proxy;"))))))))
  12032. (upstream-blocks
  12033. (list (nginx-upstream-configuration
  12034. (name "server-proxy")
  12035. (servers (list "server1.example.com"
  12036. "server2.example.com")))))))
  12037. @end example
  12038. @item @code{file} (default: @code{#f})
  12039. If a configuration @var{file} is provided, this will be used, rather than
  12040. generating a configuration file from the provided @code{log-directory},
  12041. @code{run-directory}, @code{server-blocks} and @code{upstream-blocks}. For
  12042. proper operation, these arguments should match what is in @var{file} to ensure
  12043. that the directories are created when the service is activated.
  12044. This can be useful if you have an existing configuration file, or it's
  12045. not possible to do what is required through the other parts of the
  12046. nginx-configuration record.
  12047. @item @code{server-names-hash-bucket-size} (default: @code{#f})
  12048. Bucket size for the server names hash tables, defaults to @code{#f} to
  12049. use the size of the processors cache line.
  12050. @item @code{server-names-hash-bucket-max-size} (default: @code{#f})
  12051. Maximum bucket size for the server names hash tables.
  12052. @end table
  12053. @end deffn
  12054. @deftp {Data Type} nginx-server-configuration
  12055. Data type representing the configuration of an nginx server block.
  12056. This type has the following parameters:
  12057. @table @asis
  12058. @item @code{listen} (default: @code{'("80" "443 ssl")})
  12059. Each @code{listen} directive sets the address and port for IP, or the
  12060. path for a UNIX-domain socket on which the server will accept requests.
  12061. Both address and port, or only address or only port can be specified.
  12062. An address may also be a hostname, for example:
  12063. @example
  12064. '("127.0.0.1:8000" "127.0.0.1" "8000" "*:8000" "localhost:8000")
  12065. @end example
  12066. @item @code{server-name} (default: @code{(list 'default)})
  12067. A list of server names this server represents. @code{'default} represents the
  12068. default server for connections matching no other server.
  12069. @item @code{root} (default: @code{"/srv/http"})
  12070. Root of the website nginx will serve.
  12071. @item @code{locations} (default: @code{'()})
  12072. A list of @dfn{nginx-location-configuration} or
  12073. @dfn{nginx-named-location-configuration} records to use within this
  12074. server block.
  12075. @item @code{index} (default: @code{(list "index.html")})
  12076. Index files to look for when clients ask for a directory. If it cannot be found,
  12077. Nginx will send the list of files in the directory.
  12078. @item @code{try-files} (default: @code{'()})
  12079. A list of files whose existence is checked in the specified order.
  12080. @code{nginx} will use the first file it finds to process the request.
  12081. @item @code{ssl-certificate} (default: @code{#f})
  12082. Where to find the certificate for secure connections. Set it to @code{#f} if
  12083. you don't have a certificate or you don't want to use HTTPS.
  12084. @item @code{ssl-certificate-key} (default: @code{#f})
  12085. Where to find the private key for secure connections. Set it to @code{#f} if
  12086. you don't have a key or you don't want to use HTTPS.
  12087. @item @code{server-tokens?} (default: @code{#f})
  12088. Whether the server should add its configuration to response.
  12089. @item @code{raw-content} (default: @code{'()})
  12090. A list of raw lines added to the server block.
  12091. @end table
  12092. @end deftp
  12093. @deftp {Data Type} nginx-upstream-configuration
  12094. Data type representing the configuration of an nginx @code{upstream}
  12095. block. This type has the following parameters:
  12096. @table @asis
  12097. @item @code{name}
  12098. Name for this group of servers.
  12099. @item @code{servers}
  12100. Specify the addresses of the servers in the group. The address can be
  12101. specified as a IP address (e.g. @samp{127.0.0.1}), domain name
  12102. (e.g. @samp{backend1.example.com}) or a path to a UNIX socket using the
  12103. prefix @samp{unix:}. For addresses using an IP address or domain name,
  12104. the default port is 80, and a different port can be specified
  12105. explicitly.
  12106. @end table
  12107. @end deftp
  12108. @deftp {Data Type} nginx-location-configuration
  12109. Data type representing the configuration of an nginx @code{location}
  12110. block. This type has the following parameters:
  12111. @table @asis
  12112. @item @code{uri}
  12113. URI which this location block matches.
  12114. @anchor{nginx-location-configuration body}
  12115. @item @code{body}
  12116. Body of the location block, specified as a list of strings. This can contain
  12117. many
  12118. configuration directives. For example, to pass requests to a upstream
  12119. server group defined using an @code{nginx-upstream-configuration} block,
  12120. the following directive would be specified in the body @samp{(list "proxy_pass
  12121. http://upstream-name;")}.
  12122. @end table
  12123. @end deftp
  12124. @deftp {Data Type} nginx-named-location-configuration
  12125. Data type representing the configuration of an nginx named location
  12126. block. Named location blocks are used for request redirection, and not
  12127. used for regular request processing. This type has the following
  12128. parameters:
  12129. @table @asis
  12130. @item @code{name}
  12131. Name to identify this location block.
  12132. @item @code{body}
  12133. @xref{nginx-location-configuration body}, as the body for named location
  12134. blocks can be used in a similar way to the
  12135. @code{nginx-location-configuration body}. One restriction is that the
  12136. body of a named location block cannot contain location blocks.
  12137. @end table
  12138. @end deftp
  12139. @cindex fastcgi
  12140. @cindex fcgiwrap
  12141. FastCGI is an interface between the front-end and the back-end of a web
  12142. service. It is a somewhat legacy facility; new web services should
  12143. generally just talk HTTP between the front-end and the back-end.
  12144. However there are a number of back-end services such as PHP or the
  12145. optimized HTTP Git repository access that use FastCGI, so we have
  12146. support for it in Guix.
  12147. To use FastCGI, you configure the front-end web server (e.g., nginx) to
  12148. dispatch some subset of its requests to the fastcgi backend, which
  12149. listens on a local TCP or UNIX socket. There is an intermediary
  12150. @code{fcgiwrap} program that sits between the actual backend process and
  12151. the web server. The front-end indicates which backend program to run,
  12152. passing that information to the @code{fcgiwrap} process.
  12153. @defvr {Scheme Variable} fcgiwrap-service-type
  12154. A service type for the @code{fcgiwrap} FastCGI proxy.
  12155. @end defvr
  12156. @deftp {Data Type} fcgiwrap-configuration
  12157. Data type representing the configuration of the @code{fcgiwrap} serice.
  12158. This type has the following parameters:
  12159. @table @asis
  12160. @item @code{package} (default: @code{fcgiwrap})
  12161. The fcgiwrap package to use.
  12162. @item @code{socket} (default: @code{tcp:127.0.0.1:9000})
  12163. The socket on which the @code{fcgiwrap} process should listen, as a
  12164. string. Valid @var{socket} values include
  12165. @code{unix:@var{/path/to/unix/socket}},
  12166. @code{tcp:@var{dot.ted.qu.ad}:@var{port}} and
  12167. @code{tcp6:[@var{ipv6_addr}]:port}.
  12168. @item @code{user} (default: @code{fcgiwrap})
  12169. @itemx @code{group} (default: @code{fcgiwrap})
  12170. The user and group names, as strings, under which to run the
  12171. @code{fcgiwrap} process. The @code{fastcgi} service will ensure that if
  12172. the user asks for the specific user or group names @code{fcgiwrap} that
  12173. the corresponding user and/or group is present on the system.
  12174. It is possible to configure a FastCGI-backed web service to pass HTTP
  12175. authentication information from the front-end to the back-end, and to
  12176. allow @code{fcgiwrap} to run the back-end process as a corresponding
  12177. local user. To enable this capability on the back-end., run
  12178. @code{fcgiwrap} as the @code{root} user and group. Note that this
  12179. capability also has to be configured on the front-end as well.
  12180. @end table
  12181. @end deftp
  12182. @cindex php-fpm
  12183. PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation
  12184. with some additional features useful for sites of any size.
  12185. These features include:
  12186. @itemize @bullet
  12187. @item Adaptive process spawning
  12188. @item Basic statistics (similar to Apache's mod_status)
  12189. @item Advanced process management with graceful stop/start
  12190. @item Ability to start workers with different uid/gid/chroot/environment
  12191. and different php.ini (replaces safe_mode)
  12192. @item Stdout & stderr logging
  12193. @item Emergency restart in case of accidental opcode cache destruction
  12194. @item Accelerated upload support
  12195. @item Support for a "slowlog"
  12196. @item Enhancements to FastCGI, such as fastcgi_finish_request() -
  12197. a special function to finish request & flush all data while continuing to do
  12198. something time-consuming (video converting, stats processing, etc.)
  12199. @end itemize
  12200. ... and much more.
  12201. @defvr {Scheme Variable} php-fpm-service-type
  12202. A Service type for @code{php-fpm}.
  12203. @end defvr
  12204. @deftp {Data Type} php-fpm-configuration
  12205. Data Type for php-fpm service configuration.
  12206. @table @asis
  12207. @item @code{php} (default: @code{php})
  12208. The php package to use.
  12209. @item @code{socket} (default: @code{(string-append "/var/run/php" (version-major (package-version php)) "-fpm.sock")})
  12210. The address on which to accept FastCGI requests. Valid syntaxes are:
  12211. @table @asis
  12212. @item @code{"ip.add.re.ss:port"}
  12213. Listen on a TCP socket to a specific address on a specific port.
  12214. @item @code{"port"}
  12215. Listen on a TCP socket to all addresses on a specific port.
  12216. @item @code{"/path/to/unix/socket"}
  12217. Listen on a unix socket.
  12218. @end table
  12219. @item @code{user} (default: @code{php-fpm})
  12220. User who will own the php worker processes.
  12221. @item @code{group} (default: @code{php-fpm})
  12222. Group of the worker processes.
  12223. @item @code{socket-user} (default: @code{php-fpm})
  12224. User who can speak to the php-fpm socket.
  12225. @item @code{socket-group} (default: @code{php-fpm})
  12226. Group that can speak to the php-fpm socket.
  12227. @item @code{pid-file} (default: @code{(string-append "/var/run/php" (version-major (package-version php)) "-fpm.pid")})
  12228. The process id of the php-fpm process is written to this file
  12229. once the service has started.
  12230. @item @code{log-file} (default: @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.log")})
  12231. Log for the php-fpm master process.
  12232. @item @code{process-manager} (default: @code{(php-fpm-dynamic-process-manager-configuration)})
  12233. Detailed settings for the php-fpm process manager.
  12234. Must be either:
  12235. @table @asis
  12236. @item @code{<php-fpm-dynamic-process-manager-configuration>}
  12237. @item @code{<php-fpm-static-process-manager-configuration>}
  12238. @item @code{<php-fpm-on-demand-process-manager-configuration>}
  12239. @end table
  12240. @item @code{display-errors} (default @code{#f})
  12241. Determines wether php errors and warning should be sent to clients
  12242. and displayed in their browsers.
  12243. This is useful for local php development, but a security risk for public sites,
  12244. as error messages can reveal passwords and personal data.
  12245. @item @code{workers-logfile} (default @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.www.log")})
  12246. This file will log the @code{stderr} outputs of php worker processes.
  12247. Can be set to @code{#f} to disable logging.
  12248. @item @code{file} (default @code{#f})
  12249. An optional override of the whole configuration.
  12250. You can use the @code{mixed-text-file} function or an absolute filepath for it.
  12251. @end table
  12252. @end deftp
  12253. @deftp {Data type} php-fpm-dynamic-process-manager-configuration
  12254. Data Type for the @code{dynamic} php-fpm process manager. With the
  12255. @code{dynamic} process manager, spare worker processes are kept around
  12256. based on it's configured limits.
  12257. @table @asis
  12258. @item @code{max-children} (default: @code{5})
  12259. Maximum of worker processes.
  12260. @item @code{start-servers} (default: @code{2})
  12261. How many worker processes should be started on start-up.
  12262. @item @code{min-spare-servers} (default: @code{1})
  12263. How many spare worker processes should be kept around at minimum.
  12264. @item @code{max-spare-servers} (default: @code{3})
  12265. How many spare worker processes should be kept around at maximum.
  12266. @end table
  12267. @end deftp
  12268. @deftp {Data type} php-fpm-static-process-manager-configuration
  12269. Data Type for the @code{static} php-fpm process manager. With the
  12270. @code{static} process manager, an unchanging number of worker processes
  12271. are created.
  12272. @table @asis
  12273. @item @code{max-children} (default: @code{5})
  12274. Maximum of worker processes.
  12275. @end table
  12276. @end deftp
  12277. @deftp {Data type} php-fpm-on-demand-process-manager-configuration
  12278. Data Type for the @code{on-demand} php-fpm process manager. With the
  12279. @code{on-demand} process manager, worker processes are only created as
  12280. requests arrive.
  12281. @table @asis
  12282. @item @code{max-children} (default: @code{5})
  12283. Maximum of worker processes.
  12284. @item @code{process-idle-timeout} (default: @code{10})
  12285. The time in seconds after which a process with no requests is killed.
  12286. @end table
  12287. @end deftp
  12288. @deffn {Scheme Procedure} nginx-php-fpm-location @
  12289. [#:nginx-package nginx] @
  12290. [socket (string-append "/var/run/php" @
  12291. (version-major (package-version php)) @
  12292. "-fpm.sock")]
  12293. A helper function to quickly add php to an @code{nginx-server-configuration}.
  12294. @end deffn
  12295. A simple services setup for nginx with php can look like this:
  12296. @example
  12297. (services (cons* (dhcp-client-service)
  12298. (service php-fpm-service-type)
  12299. (service nginx-service-type
  12300. (nginx-server-configuration
  12301. (server-name '("example.com"))
  12302. (root "/srv/http/")
  12303. (locations
  12304. (list (nginx-php-location)))
  12305. (https-port #f)
  12306. (ssl-certificate #f)
  12307. (ssl-certificate-key #f)))
  12308. %base-services))
  12309. @end example
  12310. @node Certificate Services
  12311. @subsubsection Certificate Services
  12312. @cindex Web
  12313. @cindex HTTP, HTTPS
  12314. @cindex Let's Encrypt
  12315. @cindex TLS certificates
  12316. The @code{(gnu services certbot)} module provides a service to
  12317. automatically obtain a valid TLS certificate from the Let's Encrypt
  12318. certificate authority. These certificates can then be used to serve
  12319. content securely over HTTPS or other TLS-based protocols, with the
  12320. knowledge that the client will be able to verify the server's
  12321. authenticity.
  12322. @url{https://letsencrypt.org/, Let's Encrypt} provides the
  12323. @code{certbot} tool to automate the certification process. This tool
  12324. first securely generates a key on the server. It then makes a request
  12325. to the Let's Encrypt certificate authority (CA) to sign the key. The CA
  12326. checks that the request originates from the host in question by using a
  12327. challenge-response protocol, requiring the server to provide its
  12328. response over HTTP. If that protocol completes successfully, the CA
  12329. signs the key, resulting in a certificate. That certificate is valid
  12330. for a limited period of time, and therefore to continue to provide TLS
  12331. services, the server needs to periodically ask the CA to renew its
  12332. signature.
  12333. The certbot service automates this process: the initial key
  12334. generation, the initial certification request to the Let's Encrypt
  12335. service, the web server challenge/response integration, writing the
  12336. certificate to disk, and the automated periodic renewals.
  12337. @defvr {Scheme Variable} certbot-service-type
  12338. A service type for the @code{certbot} Let's Encrypt client.
  12339. @end defvr
  12340. @deftp {Data Type} certbot-configuration
  12341. Data type representing the configuration of the @code{certbot} serice.
  12342. This type has the following parameters:
  12343. @table @asis
  12344. @item @code{package} (default: @code{certbot})
  12345. The certbot package to use.
  12346. @item @code{webroot} (default: @code{/var/www})
  12347. The directory from which to serve the Let's Encrypt challenge/response
  12348. files.
  12349. @item @code{hosts} (default: @code{()})
  12350. A list of hosts for which to generate certificates and request
  12351. signatures.
  12352. @item @code{default-location} (default: @i{see below})
  12353. The default @code{nginx-location-configuration}. Because @code{certbot}
  12354. needs to be able to serve challenges and responses, it needs to be able
  12355. to run a web server. It does so by extending the @code{nginx} web
  12356. service with an @code{nginx-server-configuration} listening on the
  12357. @var{hosts} on port 80, and which has a
  12358. @code{nginx-location-configuration} for the @code{/.well-known/} URI
  12359. path subspace used by Let's Encrypt. @xref{Web Services}, for more on
  12360. these nginx configuration data types.
  12361. Requests to other URL paths will be matched by the
  12362. @code{default-location}, which if present is added to all
  12363. @code{nginx-server-configuration}s.
  12364. By default, the @code{default-location} will issue a redirect from
  12365. @code{http://@var{host}/...} to @code{https://@var{host}/...}, leaving
  12366. you to define what to serve on your site via @code{https}.
  12367. Pass @code{#f} to not issue a default location.
  12368. @end table
  12369. @end deftp
  12370. The public key and its signatures will be written to
  12371. @code{/etc/letsencrypt/live/@var{host}/fullchain.pem}, for each
  12372. @var{host} in the configuration. The private key is written to
  12373. @code{/etc/letsencrypt/live/@var{host}/privkey.pem}.
  12374. @node DNS Services
  12375. @subsubsection DNS Services
  12376. @cindex DNS (domain name system)
  12377. @cindex domain name system (DNS)
  12378. The @code{(gnu services dns)} module provides services related to the
  12379. @dfn{domain name system} (DNS). It provides a server service for hosting
  12380. an @emph{authoritative} DNS server for multiple zones, slave or master.
  12381. This service uses @uref{https://www.knot-dns.cz/, Knot DNS}.
  12382. An example configuration of an authoritative server for two zones, one master
  12383. and one slave, is:
  12384. @lisp
  12385. (define-zone-entries example.org.zone
  12386. ;; Name TTL Class Type Data
  12387. ("@@" "" "IN" "A" "127.0.0.1")
  12388. ("@@" "" "IN" "NS" "ns")
  12389. ("ns" "" "IN" "A" "127.0.0.1"))
  12390. (define master-zone
  12391. (knot-zone-configuration
  12392. (domain "example.org")
  12393. (zone (zone-file
  12394. (origin "example.org")
  12395. (entries example.org.zone)))))
  12396. (define slave-zone
  12397. (knot-zone-configuration
  12398. (domain "plop.org")
  12399. (dnssec-policy "default")
  12400. (master (list "plop-master"))))
  12401. (define plop-master
  12402. (knot-remote-configuration
  12403. (id "plop-master")
  12404. (address (list "208.76.58.171"))))
  12405. (operating-system
  12406. ;; ...
  12407. (services (cons* (service knot-service-type
  12408. (knot-configuration
  12409. (remotes (list plop-master))
  12410. (zones (list master-zone slave-zone))))
  12411. ;; ...
  12412. %base-services)))
  12413. @end lisp
  12414. @deffn {Scheme Variable} knot-service-type
  12415. This is the type for the Knot DNS server.
  12416. Knot DNS is an authoritative DNS server, meaning that it can serve multiple
  12417. zones, that is to say domain names you would buy from a registrar. This server
  12418. is not a resolver, meaning that it can only resolve names for which it is
  12419. authoritative. This server can be configured to serve zones as a master server
  12420. or a slave server as a per-zone basis. Slave zones will get their data from
  12421. masters, and will serve it as an authoritative server. From the point of view
  12422. of a resolver, there is no difference between master and slave.
  12423. The following data types are used to configure the Knot DNS server:
  12424. @end deffn
  12425. @deftp {Data Type} knot-key-configuration
  12426. Data type representing a key.
  12427. This type has the following parameters:
  12428. @table @asis
  12429. @item @code{id} (default: @code{""})
  12430. An identifier for other configuration fields to refer to this key. IDs must
  12431. be unique and must not be empty.
  12432. @item @code{algorithm} (default: @code{#f})
  12433. The algorithm to use. Choose between @code{#f}, @code{'hmac-md5},
  12434. @code{'hmac-sha1}, @code{'hmac-sha224}, @code{'hmac-sha256}, @code{'hmac-sha384}
  12435. and @code{'hmac-sha512}.
  12436. @item @code{secret} (default: @code{""})
  12437. The secret key itself.
  12438. @end table
  12439. @end deftp
  12440. @deftp {Data Type} knot-acl-configuration
  12441. Data type representing an Access Control List (ACL) configuration.
  12442. This type has the following parameters:
  12443. @table @asis
  12444. @item @code{id} (default: @code{""})
  12445. An identifier for ether configuration fields to refer to this key. IDs must be
  12446. unique and must not be empty.
  12447. @item @code{address} (default: @code{'()})
  12448. An ordered list of IP addresses, network subnets, or network ranges represented
  12449. with strings. The query must match one of them. Empty value means that
  12450. address match is not required.
  12451. @item @code{key} (default: @code{'()})
  12452. An ordered list of references to keys represented with strings. The string
  12453. must match a key ID defined in a @code{knot-key-configuration}. No key means
  12454. that a key is not require to match that ACL.
  12455. @item @code{action} (default: @code{'()})
  12456. An ordered list of actions that are permitted or forbidden by this ACL. Possible
  12457. values are lists of zero or more elements from @code{'transfer}, @code{'notify}
  12458. and @code{'update}.
  12459. @item @code{deny?} (default: @code{#f})
  12460. When true, the ACL defines restrictions. Listed actions are forbidden. When
  12461. false, listed actions are allowed.
  12462. @end table
  12463. @end deftp
  12464. @deftp {Data Type} zone-entry
  12465. Data type represnting a record entry in a zone file.
  12466. This type has the following parameters:
  12467. @table @asis
  12468. @item @code{name} (default: @code{"@@"})
  12469. The name of the record. @code{"@@"} refers to the origin of the zone. Names
  12470. are relative to the origin of the zone. For example, in the @code{example.org}
  12471. zone, @code{"ns.example.org"} actually refers to @code{ns.example.org.example.org}.
  12472. Names ending with a dot are absolute, which means that @code{"ns.example.org."}
  12473. refers to @code{ns.example.org}.
  12474. @item @code{ttl} (default: @code{""})
  12475. The Time-To-Live (TTL) of this record. If not set, the default TTL is used.
  12476. @item @code{class} (default: @code{"IN"})
  12477. The class of the record. Knot currently supports only @code{"IN"} and
  12478. partially @code{"CH"}.
  12479. @item @code{type} (default: @code{"A"})
  12480. The type of the record. Common types include A (IPv4 address), AAAA (IPv6
  12481. address), NS (Name Server) and MX (Mail eXchange). Many other types are
  12482. defined.
  12483. @item @code{data} (default: @code{""})
  12484. The data contained in the record. For instance an IP address associated with
  12485. an A record, or a domain name associated with an NS record. Remember that
  12486. domain names are relative to the origin unless they end with a dot.
  12487. @end table
  12488. @end deftp
  12489. @deftp {Data Type} zone-file
  12490. Data type representing the content of a zone file.
  12491. This type has the following parameters:
  12492. @table @asis
  12493. @item @code{entries} (default: @code{'()})
  12494. The list of entries. The SOA record is taken care of, so you don't need to
  12495. put it in the list of entries. This list should probably contain an entry
  12496. for your primary authoritative DNS server. Other than using a list of entries
  12497. directly, you can use @code{define-zone-entries} to define a object containing
  12498. the list of entries more easily, that you can later pass to the @code{entries}
  12499. field of the @code{zone-file}.
  12500. @item @code{origin} (default: @code{""})
  12501. The name of your zone. This parameter cannot be empty.
  12502. @item @code{ns} (default: @code{"ns"})
  12503. The domain of your primary authoritative DNS server. The name is relative to
  12504. the origin, unless it ends with a dot. It is mandatory that this primary
  12505. DNS server corresponds to an NS record in the zone and that it is associated
  12506. to an IP address in the list of entries.
  12507. @item @code{mail} (default: @code{"hostmaster"})
  12508. An email address people can contact you at, as the owner of the zone. This
  12509. is translated as @code{<mail>@@<origin>}.
  12510. @item @code{serial} (default: @code{1})
  12511. The serial number of the zone. As this is used to keep track of changes by
  12512. both slaves and resolvers, it is mandatory that it @emph{never} decreases.
  12513. Always increment it when you make a change in your zone.
  12514. @item @code{refresh} (default: @code{(* 2 24 3600)})
  12515. The frequency at which slaves will do a zone transfer. This value is a number
  12516. of seconds. It can be computed by multiplications or with
  12517. @code{(string->duration)}.
  12518. @item @code{retry} (default: @code{(* 15 60)})
  12519. The period after which a slave will retry to contact its master when it fails
  12520. to do so a first time.
  12521. @item @code{expiry} (default: @code{(* 14 24 3600)})
  12522. Default TTL of records. Existing records are considered correct for at most
  12523. this amount of time. After this period, resolvers will invalidate their cache
  12524. and check again that it still exists.
  12525. @item @code{nx} (default: @code{3600})
  12526. Default TTL of inexistant records. This delay is usually short because you want
  12527. your new domains to reach everyone quickly.
  12528. @end table
  12529. @end deftp
  12530. @deftp {Data Type} knot-remote-configuration
  12531. Data type representing a remote configuration.
  12532. This type has the following parameters:
  12533. @table @asis
  12534. @item @code{id} (default: @code{""})
  12535. An identifier for other configuration fields to refer to this remote. IDs must
  12536. be unique and must not be empty.
  12537. @item @code{address} (default: @code{'()})
  12538. An ordered list of destination IP addresses. Addresses are tried in sequence.
  12539. An optional port can be given with the @@ separator. For instance:
  12540. @code{(list "1.2.3.4" "2.3.4.5@@53")}. Default port is 53.
  12541. @item @code{via} (default: @code{'()})
  12542. An ordered list of source IP addresses. An empty list will have Knot choose
  12543. an appropriate source IP. An optional port can be given with the @@ separator.
  12544. The default is to choose at random.
  12545. @item @code{key} (default: @code{#f})
  12546. A reference to a key, that is a string containing the identifier of a key
  12547. defined in a @code{knot-key-configuration} field.
  12548. @end table
  12549. @end deftp
  12550. @deftp {Data Type} knot-keystore-configuration
  12551. Data type representing a keystore to hold dnssec keys.
  12552. This type has the following parameters:
  12553. @table @asis
  12554. @item @code{id} (default: @code{""})
  12555. The id of the keystore. It must not be empty.
  12556. @item @code{backend} (default: @code{'pem})
  12557. The backend to store the keys in. Can be @code{'pem} or @code{'pkcs11}.
  12558. @item @code{config} (default: @code{"/var/lib/knot/keys/keys"})
  12559. The configuration string of the backend. An example for the PKCS#11 is:
  12560. @code{"pkcs11:token=knot;pin-value=1234 /gnu/store/.../lib/pkcs11/libsofthsm2.so"}.
  12561. For the pem backend, the string reprensents a path in the filesystem.
  12562. @end table
  12563. @end deftp
  12564. @deftp {Data Type} knot-policy-configuration
  12565. Data type representing a dnssec policy. Knot DNS is able to automatically
  12566. sign your zones. It can either generate and manage your keys automatically or
  12567. use keys that you generate.
  12568. Dnssec is usually implemented using two keys: a Key Signing Key (KSK) that is
  12569. used to sign the second, and a Zone Signing Key (ZSK) that is used to sign the
  12570. zone. In order to be trusted, the KSK needs to be present in the parent zone
  12571. (usually a top-level domain). If your registrar supports dnssec, you will
  12572. have to send them your KSK's hash so they can add a DS record in their zone.
  12573. This is not automated and need to be done each time you change your KSK.
  12574. The policy also defines the lifetime of keys. Usually, ZSK can be changed
  12575. easily and use weaker cryptographic functions (they use lower parameters) in
  12576. order to sign records quickly, so they are changed often. The KSK however
  12577. requires manual interaction with the registrar, so they are changed less often
  12578. and use stronger parameters because they sign only one record.
  12579. This type has the following parameters:
  12580. @table @asis
  12581. @item @code{id} (default: @code{""})
  12582. The id of the policy. It must not be empty.
  12583. @item @code{keystore} (default: @code{"default"})
  12584. A reference to a keystore, that is a string containing the identifier of a
  12585. keystore defined in a @code{knot-keystore-configuration} field. The
  12586. @code{"default"} identifier means the default keystore (a kasp database that
  12587. was setup by this service).
  12588. @item @code{manual?} (default: @code{#f})
  12589. Whether the key management is manual or automatic.
  12590. @item @code{single-type-signing?} (default: @code{#f})
  12591. When @code{#t}, use the Single-Type Signing Scheme.
  12592. @item @code{algorithm} (default: @code{"ecdsap256sha256"})
  12593. An algorithm of signing keys and issued signatures.
  12594. @item @code{ksk-size} (default: @code{256})
  12595. The length of the KSK. Note that this value is correct for the default
  12596. algorithm, but would be unsecure for other algorithms.
  12597. @item @code{zsk-size} (default: @code{256})
  12598. The length of the ZSK. Note that this value is correct for the default
  12599. algorithm, but would be unsecure for other algorithms.
  12600. @item @code{dnskey-ttl} (default: @code{'default})
  12601. The TTL value for DNSKEY records added into zone apex. The special
  12602. @code{'default} value means same as the zone SOA TTL.
  12603. @item @code{zsk-lifetime} (default: @code{(* 30 24 3600)})
  12604. The period between ZSK publication and the next rollover initiation.
  12605. @item @code{propagation-delay} (default: @code{(* 24 3600)})
  12606. An extra delay added for each key rollover step. This value should be high
  12607. enough to cover propagation of data from the master server to all slaves.
  12608. @item @code{rrsig-lifetime} (default: @code{(* 14 24 3600)})
  12609. A validity period of newly issued signatures.
  12610. @item @code{rrsig-refresh} (default: @code{(* 7 24 3600)})
  12611. A period how long before a signature expiration the signature will be refreshed.
  12612. @item @code{nsec3?} (default: @code{#f})
  12613. When @code{#t}, NSEC3 will be used instead of NSEC.
  12614. @item @code{nsec3-iterations} (default: @code{5})
  12615. The number of additional times the hashing is performed.
  12616. @item @code{nsec3-salt-length} (default: @code{8})
  12617. The length of a salt field in octets, which is appended to the original owner
  12618. name before hashing.
  12619. @item @code{nsec3-salt-lifetime} (default: @code{(* 30 24 3600)})
  12620. The validity period of newly issued salt field.
  12621. @end table
  12622. @end deftp
  12623. @deftp {Data Type} knot-zone-configuration
  12624. Data type representing a zone served by Knot.
  12625. This type has the following parameters:
  12626. @table @asis
  12627. @item @code{domain} (default: @code{""})
  12628. The domain served by this configuration. It must not be empty.
  12629. @item @code{file} (default: @code{""})
  12630. The file where this zone is saved. This parameter is ignored by master zones.
  12631. Empty means default location that depends on the domain name.
  12632. @item @code{zone} (default: @code{(zone-file)})
  12633. The content of the zone file. This parameter is ignored by slave zones. It
  12634. must contain a zone-file record.
  12635. @item @code{master} (default: @code{'()})
  12636. A list of master remotes. When empty, this zone is a master. When set, this
  12637. zone is a slave. This is a list of remotes identifiers.
  12638. @item @code{ddns-master} (default: @code{#f})
  12639. The main master. When empty, it defaults to the first master in the list of
  12640. masters.
  12641. @item @code{notify} (default: @code{'()})
  12642. A list of slave remote identifiers.
  12643. @item @code{acl} (default: @code{'()})
  12644. A list of acl identifiers.
  12645. @item @code{semantic-checks?} (default: @code{#f})
  12646. When set, this adds more semantic checks to the zone.
  12647. @item @code{disable-any?} (default: @code{#f})
  12648. When set, this forbids queries of the ANY type.
  12649. @item @code{zonefile-sync} (default: @code{0})
  12650. The delay between a modification in memory and on disk. 0 means immediate
  12651. synchronization.
  12652. @item @code{serial-policy} (default: @code{'increment})
  12653. A policy between @code{'increment} and @code{'unixtime}.
  12654. @end table
  12655. @end deftp
  12656. @deftp {Data Type} knot-configuration
  12657. Data type representing the Knot configuration.
  12658. This type has the following parameters:
  12659. @table @asis
  12660. @item @code{knot} (default: @code{knot})
  12661. The Knot package.
  12662. @item @code{run-directory} (default: @code{"/var/run/knot"})
  12663. The run directory. This directory will be used for pid file and sockets.
  12664. @item @code{listen-v4} (default: @code{"0.0.0.0"})
  12665. An ip address on which to listen.
  12666. @item @code{listen-v6} (default: @code{"::"})
  12667. An ip address on which to listen.
  12668. @item @code{listen-port} (default: @code{53})
  12669. A port on which to listen.
  12670. @item @code{keys} (default: @code{'()})
  12671. The list of knot-key-configuration used by this configuration.
  12672. @item @code{acls} (default: @code{'()})
  12673. The list of knot-acl-configuration used by this configuration.
  12674. @item @code{remotes} (default: @code{'()})
  12675. The list of knot-remote-configuration used by this configuration.
  12676. @item @code{zones} (default: @code{'()})
  12677. The list of knot-zone-configuration used by this configuration.
  12678. @end table
  12679. @end deftp
  12680. @node VPN Services
  12681. @subsubsection VPN Services
  12682. @cindex VPN (virtual private network)
  12683. @cindex virtual private network (VPN)
  12684. The @code{(gnu services vpn)} module provides services related to
  12685. @dfn{virtual private networks} (VPNs). It provides a @emph{client} service for
  12686. your machine to connect to a VPN, and a @emph{servire} service for your machine
  12687. to host a VPN. Both services use @uref{https://openvpn.net/, OpenVPN}.
  12688. @deffn {Scheme Procedure} openvpn-client-service @
  12689. [#:config (openvpn-client-configuration)]
  12690. Return a service that runs @command{openvpn}, a VPN daemon, as a client.
  12691. @end deffn
  12692. @deffn {Scheme Procedure} openvpn-server-service @
  12693. [#:config (openvpn-server-configuration)]
  12694. Return a service that runs @command{openvpn}, a VPN daemon, as a server.
  12695. Both can be run simultaneously.
  12696. @end deffn
  12697. @c %automatically generated documentation
  12698. Available @code{openvpn-client-configuration} fields are:
  12699. @deftypevr {@code{openvpn-client-configuration} parameter} package openvpn
  12700. The OpenVPN package.
  12701. @end deftypevr
  12702. @deftypevr {@code{openvpn-client-configuration} parameter} string pid-file
  12703. The OpenVPN pid file.
  12704. Defaults to @samp{"/var/run/openvpn/openvpn.pid"}.
  12705. @end deftypevr
  12706. @deftypevr {@code{openvpn-client-configuration} parameter} proto proto
  12707. The protocol (UDP or TCP) used to open a channel between clients and
  12708. servers.
  12709. Defaults to @samp{udp}.
  12710. @end deftypevr
  12711. @deftypevr {@code{openvpn-client-configuration} parameter} dev dev
  12712. The device type used to represent the VPN connection.
  12713. Defaults to @samp{tun}.
  12714. @end deftypevr
  12715. @deftypevr {@code{openvpn-client-configuration} parameter} string ca
  12716. The certificate authority to check connections against.
  12717. Defaults to @samp{"/etc/openvpn/ca.crt"}.
  12718. @end deftypevr
  12719. @deftypevr {@code{openvpn-client-configuration} parameter} string cert
  12720. The certificate of the machine the daemon is running on. It should be
  12721. signed by the authority given in @code{ca}.
  12722. Defaults to @samp{"/etc/openvpn/client.crt"}.
  12723. @end deftypevr
  12724. @deftypevr {@code{openvpn-client-configuration} parameter} string key
  12725. The key of the machine the daemon is running on. It must be the key whose
  12726. certificate is @code{cert}.
  12727. Defaults to @samp{"/etc/openvpn/client.key"}.
  12728. @end deftypevr
  12729. @deftypevr {@code{openvpn-client-configuration} parameter} boolean comp-lzo?
  12730. Whether to use the lzo compression algorithm.
  12731. Defaults to @samp{#t}.
  12732. @end deftypevr
  12733. @deftypevr {@code{openvpn-client-configuration} parameter} boolean persist-key?
  12734. Don't re-read key files across SIGUSR1 or --ping-restart.
  12735. Defaults to @samp{#t}.
  12736. @end deftypevr
  12737. @deftypevr {@code{openvpn-client-configuration} parameter} boolean persist-tun?
  12738. Don't close and reopen TUN/TAP device or run up/down scripts across
  12739. SIGUSR1 or --ping-restart restarts.
  12740. Defaults to @samp{#t}.
  12741. @end deftypevr
  12742. @deftypevr {@code{openvpn-client-configuration} parameter} number verbosity
  12743. Verbosity level.
  12744. Defaults to @samp{3}.
  12745. @end deftypevr
  12746. @deftypevr {@code{openvpn-client-configuration} parameter} tls-auth-client tls-auth
  12747. Add an additional layer of HMAC authentication on top of the TLS control
  12748. channel to protect against DoS attacks.
  12749. Defaults to @samp{#f}.
  12750. @end deftypevr
  12751. @deftypevr {@code{openvpn-client-configuration} parameter} key-usage verify-key-usage?
  12752. Whether to check the server certificate has server usage extension.
  12753. Defaults to @samp{#t}.
  12754. @end deftypevr
  12755. @deftypevr {@code{openvpn-client-configuration} parameter} bind bind?
  12756. Bind to a specific local port number.
  12757. Defaults to @samp{#f}.
  12758. @end deftypevr
  12759. @deftypevr {@code{openvpn-client-configuration} parameter} resolv-retry resolv-retry?
  12760. Retry resolving server address.
  12761. Defaults to @samp{#t}.
  12762. @end deftypevr
  12763. @deftypevr {@code{openvpn-client-configuration} parameter} openvpn-remote-list remote
  12764. A list of remote servers to connect to.
  12765. Defaults to @samp{()}.
  12766. Available @code{openvpn-remote-configuration} fields are:
  12767. @deftypevr {@code{openvpn-remote-configuration} parameter} string name
  12768. Server name.
  12769. Defaults to @samp{"my-server"}.
  12770. @end deftypevr
  12771. @deftypevr {@code{openvpn-remote-configuration} parameter} number port
  12772. Port number the server listens to.
  12773. Defaults to @samp{1194}.
  12774. @end deftypevr
  12775. @end deftypevr
  12776. @c %end of automatic openvpn-client documentation
  12777. @c %automatically generated documentation
  12778. Available @code{openvpn-server-configuration} fields are:
  12779. @deftypevr {@code{openvpn-server-configuration} parameter} package openvpn
  12780. The OpenVPN package.
  12781. @end deftypevr
  12782. @deftypevr {@code{openvpn-server-configuration} parameter} string pid-file
  12783. The OpenVPN pid file.
  12784. Defaults to @samp{"/var/run/openvpn/openvpn.pid"}.
  12785. @end deftypevr
  12786. @deftypevr {@code{openvpn-server-configuration} parameter} proto proto
  12787. The protocol (UDP or TCP) used to open a channel between clients and
  12788. servers.
  12789. Defaults to @samp{udp}.
  12790. @end deftypevr
  12791. @deftypevr {@code{openvpn-server-configuration} parameter} dev dev
  12792. The device type used to represent the VPN connection.
  12793. Defaults to @samp{tun}.
  12794. @end deftypevr
  12795. @deftypevr {@code{openvpn-server-configuration} parameter} string ca
  12796. The certificate authority to check connections against.
  12797. Defaults to @samp{"/etc/openvpn/ca.crt"}.
  12798. @end deftypevr
  12799. @deftypevr {@code{openvpn-server-configuration} parameter} string cert
  12800. The certificate of the machine the daemon is running on. It should be
  12801. signed by the authority given in @code{ca}.
  12802. Defaults to @samp{"/etc/openvpn/client.crt"}.
  12803. @end deftypevr
  12804. @deftypevr {@code{openvpn-server-configuration} parameter} string key
  12805. The key of the machine the daemon is running on. It must be the key whose
  12806. certificate is @code{cert}.
  12807. Defaults to @samp{"/etc/openvpn/client.key"}.
  12808. @end deftypevr
  12809. @deftypevr {@code{openvpn-server-configuration} parameter} boolean comp-lzo?
  12810. Whether to use the lzo compression algorithm.
  12811. Defaults to @samp{#t}.
  12812. @end deftypevr
  12813. @deftypevr {@code{openvpn-server-configuration} parameter} boolean persist-key?
  12814. Don't re-read key files across SIGUSR1 or --ping-restart.
  12815. Defaults to @samp{#t}.
  12816. @end deftypevr
  12817. @deftypevr {@code{openvpn-server-configuration} parameter} boolean persist-tun?
  12818. Don't close and reopen TUN/TAP device or run up/down scripts across
  12819. SIGUSR1 or --ping-restart restarts.
  12820. Defaults to @samp{#t}.
  12821. @end deftypevr
  12822. @deftypevr {@code{openvpn-server-configuration} parameter} number verbosity
  12823. Verbosity level.
  12824. Defaults to @samp{3}.
  12825. @end deftypevr
  12826. @deftypevr {@code{openvpn-server-configuration} parameter} tls-auth-server tls-auth
  12827. Add an additional layer of HMAC authentication on top of the TLS control
  12828. channel to protect against DoS attacks.
  12829. Defaults to @samp{#f}.
  12830. @end deftypevr
  12831. @deftypevr {@code{openvpn-server-configuration} parameter} number port
  12832. Specifies the port number on which the server listens.
  12833. Defaults to @samp{1194}.
  12834. @end deftypevr
  12835. @deftypevr {@code{openvpn-server-configuration} parameter} ip-mask server
  12836. An ip and mask specifying the subnet inside the virtual network.
  12837. Defaults to @samp{"10.8.0.0 255.255.255.0"}.
  12838. @end deftypevr
  12839. @deftypevr {@code{openvpn-server-configuration} parameter} cidr6 server-ipv6
  12840. A CIDR notation specifying the IPv6 subnet inside the virtual network.
  12841. Defaults to @samp{#f}.
  12842. @end deftypevr
  12843. @deftypevr {@code{openvpn-server-configuration} parameter} string dh
  12844. The Diffie-Hellman parameters file.
  12845. Defaults to @samp{"/etc/openvpn/dh2048.pem"}.
  12846. @end deftypevr
  12847. @deftypevr {@code{openvpn-server-configuration} parameter} string ifconfig-pool-persist
  12848. The file that records client IPs.
  12849. Defaults to @samp{"/etc/openvpn/ipp.txt"}.
  12850. @end deftypevr
  12851. @deftypevr {@code{openvpn-server-configuration} parameter} gateway redirect-gateway?
  12852. When true, the server will act as a gateway for its clients.
  12853. Defaults to @samp{#f}.
  12854. @end deftypevr
  12855. @deftypevr {@code{openvpn-server-configuration} parameter} boolean client-to-client?
  12856. When true, clients are allowed to talk to each other inside the VPN.
  12857. Defaults to @samp{#f}.
  12858. @end deftypevr
  12859. @deftypevr {@code{openvpn-server-configuration} parameter} keepalive keepalive
  12860. Causes ping-like messages to be sent back and forth over the link so
  12861. that each side knows when the other side has gone down. @code{keepalive}
  12862. requires a pair. The first element is the period of the ping sending,
  12863. and the second element is the timeout before considering the other side
  12864. down.
  12865. @end deftypevr
  12866. @deftypevr {@code{openvpn-server-configuration} parameter} number max-clients
  12867. The maximum number of clients.
  12868. Defaults to @samp{100}.
  12869. @end deftypevr
  12870. @deftypevr {@code{openvpn-server-configuration} parameter} string status
  12871. The status file. This file shows a small report on current connection.
  12872. It is truncated and rewritten every minute.
  12873. Defaults to @samp{"/var/run/openvpn/status"}.
  12874. @end deftypevr
  12875. @deftypevr {@code{openvpn-server-configuration} parameter} openvpn-ccd-list client-config-dir
  12876. The list of configuration for some clients.
  12877. Defaults to @samp{()}.
  12878. Available @code{openvpn-ccd-configuration} fields are:
  12879. @deftypevr {@code{openvpn-ccd-configuration} parameter} string name
  12880. Client name.
  12881. Defaults to @samp{"client"}.
  12882. @end deftypevr
  12883. @deftypevr {@code{openvpn-ccd-configuration} parameter} ip-mask iroute
  12884. Client own network
  12885. Defaults to @samp{#f}.
  12886. @end deftypevr
  12887. @deftypevr {@code{openvpn-ccd-configuration} parameter} ip-mask ifconfig-push
  12888. Client VPN IP.
  12889. Defaults to @samp{#f}.
  12890. @end deftypevr
  12891. @end deftypevr
  12892. @c %end of automatic openvpn-server documentation
  12893. @node Network File System
  12894. @subsubsection Network File System
  12895. @cindex NFS
  12896. The @code{(gnu services nfs)} module provides the following services,
  12897. which are most commonly used in relation to mounting or exporting
  12898. directory trees as @dfn{network file systems} (NFS).
  12899. @subsubheading RPC Bind Service
  12900. @cindex rpcbind
  12901. The RPC Bind service provides a facility to map program numbers into
  12902. universal addresses.
  12903. Many NFS related services use this facility. Hence it is automatically
  12904. started when a dependent service starts.
  12905. @defvr {Scheme Variable} rpcbind-service-type
  12906. A service type for the RPC portmapper daemon.
  12907. @end defvr
  12908. @deftp {Data Type} rpcbind-configuration
  12909. Data type representing the configuration of the RPC Bind Service.
  12910. This type has the following parameters:
  12911. @table @asis
  12912. @item @code{rpcbind} (default: @code{rpcbind})
  12913. The rpcbind package to use.
  12914. @item @code{warm-start?} (default: @code{#t})
  12915. If this parameter is @code{#t}, then the daemon will read a
  12916. state file on startup thus reloading state information saved by a previous
  12917. instance.
  12918. @end table
  12919. @end deftp
  12920. @subsubheading Pipefs Pseudo File System
  12921. @cindex pipefs
  12922. @cindex rpc_pipefs
  12923. The pipefs file system is used to transfer NFS related data
  12924. between the kernel and user space programs.
  12925. @defvr {Scheme Variable} pipefs-service-type
  12926. A service type for the pipefs pseudo file system.
  12927. @end defvr
  12928. @deftp {Data Type} pipefs-configuration
  12929. Data type representing the configuration of the pipefs pseudo file system service.
  12930. This type has the following parameters:
  12931. @table @asis
  12932. @item @code{mount-point} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  12933. The directory to which the file system is to be attached.
  12934. @end table
  12935. @end deftp
  12936. @subsubheading GSS Daemon Service
  12937. @cindex GSSD
  12938. @cindex GSS
  12939. @cindex global security system
  12940. The @dfn{global security system} (GSS) daemon provides strong security for RPC
  12941. based protocols.
  12942. Before exchanging RPC requests an RPC client must establish a security
  12943. context. Typically this is done using the Kerberos command @command{kinit}
  12944. or automatically at login time using PAM services (@pxref{Kerberos Services}).
  12945. @defvr {Scheme Variable} gss-service-type
  12946. A service type for the Global Security System (GSS) daemon.
  12947. @end defvr
  12948. @deftp {Data Type} gss-configuration
  12949. Data type representing the configuration of the GSS daemon service.
  12950. This type has the following parameters:
  12951. @table @asis
  12952. @item @code{nfs-utils} (default: @code{nfs-utils})
  12953. The package in which the @command{rpc.gssd} command is to be found.
  12954. @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  12955. The directory where the pipefs file system is mounted.
  12956. @end table
  12957. @end deftp
  12958. @subsubheading IDMAP Daemon Service
  12959. @cindex idmapd
  12960. @cindex name mapper
  12961. The idmap daemon service provides mapping between user IDs and user names.
  12962. Typically it is required in order to access file systems mounted via NFSv4.
  12963. @defvr {Scheme Variable} idmap-service-type
  12964. A service type for the Identity Mapper (IDMAP) daemon.
  12965. @end defvr
  12966. @deftp {Data Type} idmap-configuration
  12967. Data type representing the configuration of the IDMAP daemon service.
  12968. This type has the following parameters:
  12969. @table @asis
  12970. @item @code{nfs-utils} (default: @code{nfs-utils})
  12971. The package in which the @command{rpc.idmapd} command is to be found.
  12972. @item @code{pipefs-directory} (default: @code{"/var/lib/nfs/rpc_pipefs"})
  12973. The directory where the pipefs file system is mounted.
  12974. @item @code{domain} (default: @code{#f})
  12975. The local NFSv4 domain name.
  12976. This must be a string or @code{#f}.
  12977. If it is @code{#f} then the daemon will use the host's fully qualified domain name.
  12978. @end table
  12979. @end deftp
  12980. @node Continuous Integration
  12981. @subsubsection Continuous Integration
  12982. @cindex continuous integration
  12983. @uref{https://notabug.org/mthl/cuirass, Cuirass} is a continuous
  12984. integration tool for Guix. It can be used both for development and for
  12985. providing substitutes to others (@pxref{Substitutes}).
  12986. The @code{(gnu services cuirass)} module provides the following service.
  12987. @defvr {Scheme Procedure} cuirass-service-type
  12988. The type of the Cuirass service. Its value must be a
  12989. @code{cuirass-configuration} object, as described below.
  12990. @end defvr
  12991. To add build jobs, you have to set the @code{specifications} field of
  12992. the configuration. Here is an example of a service defining a build job
  12993. based on a specification that can be found in Cuirass source tree. This
  12994. service polls the Guix repository and builds a subset of the Guix
  12995. packages, as prescribed in the @file{gnu-system.scm} example spec:
  12996. @example
  12997. (let ((spec #~((#:name . "guix")
  12998. (#:url . "git://git.savannah.gnu.org/guix.git")
  12999. (#:load-path . ".")
  13000. (#:file . "build-aux/cuirass/gnu-system.scm")
  13001. (#:proc . cuirass-jobs)
  13002. (#:arguments (subset . "hello"))
  13003. (#:branch . "master"))))
  13004. (service cuirass-service-type
  13005. (cuirass-configuration
  13006. (specifications #~(list '#$spec)))))
  13007. @end example
  13008. While information related to build jobs is located directly in the
  13009. specifications, global settings for the @command{cuirass} process are
  13010. accessible in other @code{cuirass-configuration} fields.
  13011. @deftp {Data Type} cuirass-configuration
  13012. Data type representing the configuration of Cuirass.
  13013. @table @asis
  13014. @item @code{log-file} (default: @code{"/var/log/cuirass.log"})
  13015. Location of the log file.
  13016. @item @code{cache-directory} (default: @code{"/var/cache/cuirass"})
  13017. Location of the repository cache.
  13018. @item @code{user} (default: @code{"cuirass"})
  13019. Owner of the @code{cuirass} process.
  13020. @item @code{group} (default: @code{"cuirass"})
  13021. Owner's group of the @code{cuirass} process.
  13022. @item @code{interval} (default: @code{60})
  13023. Number of seconds between the poll of the repositories followed by the
  13024. Cuirass jobs.
  13025. @item @code{database} (default: @code{"/var/run/cuirass/cuirass.db"})
  13026. Location of sqlite database which contains the build results and previously
  13027. added specifications.
  13028. @item @code{port} (default: @code{8081})
  13029. Port number used by the HTTP server.
  13030. @item --listen=@var{host}
  13031. Listen on the network interface for @var{host}. The default is to
  13032. accept connections from localhost.
  13033. @item @code{specifications} (default: @code{#~'()})
  13034. A gexp (@pxref{G-Expressions}) that evaluates to a list of specifications,
  13035. where a specification is an association list
  13036. (@pxref{Associations Lists,,, guile, GNU Guile Reference Manual}) whose
  13037. keys are keywords (@code{#:keyword-example}) as shown in the example
  13038. above.
  13039. @item @code{use-substitutes?} (default: @code{#f})
  13040. This allows using substitutes to avoid building every dependencies of a job
  13041. from source.
  13042. @item @code{one-shot?} (default: @code{#f})
  13043. Only evaluate specifications and build derivations once.
  13044. @item @code{fallback?} (default: @code{#f})
  13045. When substituting a pre-built binary fails, fall back to building
  13046. packages locally.
  13047. @item @code{load-path} (default: @code{'()})
  13048. This allows users to define their own packages and make them visible to
  13049. cuirass as in @command{guix build} command.
  13050. @item @code{cuirass} (default: @code{cuirass})
  13051. The Cuirass package to use.
  13052. @end table
  13053. @end deftp
  13054. @node Power management Services
  13055. @subsubsection Power management Services
  13056. @cindex power management with TLP
  13057. The @code{(gnu services pm)} module provides a Guix service definition
  13058. for the Linux power management tool TLP.
  13059. TLP enables various powersaving modes in userspace and kernel.
  13060. Contrary to @code{upower-service}, it is not a passive,
  13061. monitoring tool, as it will apply custom settings each time a new power
  13062. source is detected. More information can be found at
  13063. @uref{http://linrunner.de/en/tlp/tlp.html, TLP home page}.
  13064. @deffn {Scheme Variable} tlp-service-type
  13065. The service type for the TLP tool. Its value should be a valid
  13066. TLP configuration (see below). To use the default settings, simply
  13067. write:
  13068. @example
  13069. (service tlp-service-type)
  13070. @end example
  13071. @end deffn
  13072. By default TLP does not need much configuration but most TLP parameters
  13073. can be tweaked using @code{tlp-configuration}.
  13074. Each parameter definition is preceded by its type; for example,
  13075. @samp{boolean foo} indicates that the @code{foo} parameter
  13076. should be specified as a boolean. Types starting with
  13077. @code{maybe-} denote parameters that won't show up in TLP config file
  13078. when their value is @code{'disabled}.
  13079. @c The following documentation was initially generated by
  13080. @c (generate-tlp-documentation) in (gnu services pm). Manually maintained
  13081. @c documentation is better, so we shouldn't hesitate to edit below as
  13082. @c needed. However if the change you want to make to this documentation
  13083. @c can be done in an automated way, it's probably easier to change
  13084. @c (generate-documentation) than to make it below and have to deal with
  13085. @c the churn as TLP updates.
  13086. Available @code{tlp-configuration} fields are:
  13087. @deftypevr {@code{tlp-configuration} parameter} package tlp
  13088. The TLP package.
  13089. @end deftypevr
  13090. @deftypevr {@code{tlp-configuration} parameter} boolean tlp-enable?
  13091. Set to true if you wish to enable TLP.
  13092. Defaults to @samp{#t}.
  13093. @end deftypevr
  13094. @deftypevr {@code{tlp-configuration} parameter} string tlp-default-mode
  13095. Default mode when no power supply can be detected. Alternatives are AC
  13096. and BAT.
  13097. Defaults to @samp{"AC"}.
  13098. @end deftypevr
  13099. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer disk-idle-secs-on-ac
  13100. Number of seconds Linux kernel has to wait after the disk goes idle,
  13101. before syncing on AC.
  13102. Defaults to @samp{0}.
  13103. @end deftypevr
  13104. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer disk-idle-secs-on-bat
  13105. Same as @code{disk-idle-ac} but on BAT mode.
  13106. Defaults to @samp{2}.
  13107. @end deftypevr
  13108. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer max-lost-work-secs-on-ac
  13109. Dirty pages flushing periodicity, expressed in seconds.
  13110. Defaults to @samp{15}.
  13111. @end deftypevr
  13112. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer max-lost-work-secs-on-bat
  13113. Same as @code{max-lost-work-secs-on-ac} but on BAT mode.
  13114. Defaults to @samp{60}.
  13115. @end deftypevr
  13116. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list cpu-scaling-governor-on-ac
  13117. CPU frequency scaling governor on AC mode. With intel_pstate driver,
  13118. alternatives are powersave and performance. With acpi-cpufreq driver,
  13119. alternatives are ondemand, powersave, performance and conservative.
  13120. Defaults to @samp{disabled}.
  13121. @end deftypevr
  13122. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list cpu-scaling-governor-on-bat
  13123. Same as @code{cpu-scaling-governor-on-ac} but on BAT mode.
  13124. Defaults to @samp{disabled}.
  13125. @end deftypevr
  13126. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-min-freq-on-ac
  13127. Set the min available frequency for the scaling governor on AC.
  13128. Defaults to @samp{disabled}.
  13129. @end deftypevr
  13130. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-max-freq-on-ac
  13131. Set the max available frequency for the scaling governor on AC.
  13132. Defaults to @samp{disabled}.
  13133. @end deftypevr
  13134. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-min-freq-on-bat
  13135. Set the min available frequency for the scaling governor on BAT.
  13136. Defaults to @samp{disabled}.
  13137. @end deftypevr
  13138. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-scaling-max-freq-on-bat
  13139. Set the max available frequency for the scaling governor on BAT.
  13140. Defaults to @samp{disabled}.
  13141. @end deftypevr
  13142. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-min-perf-on-ac
  13143. Limit the min P-state to control the power dissipation of the CPU, in AC
  13144. mode. Values are stated as a percentage of the available performance.
  13145. Defaults to @samp{disabled}.
  13146. @end deftypevr
  13147. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-max-perf-on-ac
  13148. Limit the max P-state to control the power dissipation of the CPU, in AC
  13149. mode. Values are stated as a percentage of the available performance.
  13150. Defaults to @samp{disabled}.
  13151. @end deftypevr
  13152. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-min-perf-on-bat
  13153. Same as @code{cpu-min-perf-on-ac} on BAT mode.
  13154. Defaults to @samp{disabled}.
  13155. @end deftypevr
  13156. @deftypevr {@code{tlp-configuration} parameter} maybe-non-negative-integer cpu-max-perf-on-bat
  13157. Same as @code{cpu-max-perf-on-ac} on BAT mode.
  13158. Defaults to @samp{disabled}.
  13159. @end deftypevr
  13160. @deftypevr {@code{tlp-configuration} parameter} maybe-boolean cpu-boost-on-ac?
  13161. Enable CPU turbo boost feature on AC mode.
  13162. Defaults to @samp{disabled}.
  13163. @end deftypevr
  13164. @deftypevr {@code{tlp-configuration} parameter} maybe-boolean cpu-boost-on-bat?
  13165. Same as @code{cpu-boost-on-ac?} on BAT mode.
  13166. Defaults to @samp{disabled}.
  13167. @end deftypevr
  13168. @deftypevr {@code{tlp-configuration} parameter} boolean sched-powersave-on-ac?
  13169. Allow Linux kernel to minimize the number of CPU cores/hyper-threads
  13170. used under light load conditions.
  13171. Defaults to @samp{#f}.
  13172. @end deftypevr
  13173. @deftypevr {@code{tlp-configuration} parameter} boolean sched-powersave-on-bat?
  13174. Same as @code{sched-powersave-on-ac?} but on BAT mode.
  13175. Defaults to @samp{#t}.
  13176. @end deftypevr
  13177. @deftypevr {@code{tlp-configuration} parameter} boolean nmi-watchdog?
  13178. Enable Linux kernel NMI watchdog.
  13179. Defaults to @samp{#f}.
  13180. @end deftypevr
  13181. @deftypevr {@code{tlp-configuration} parameter} maybe-string phc-controls
  13182. For Linux kernels with PHC patch applied, change CPU voltages. An
  13183. example value would be @samp{"F:V F:V F:V F:V"}.
  13184. Defaults to @samp{disabled}.
  13185. @end deftypevr
  13186. @deftypevr {@code{tlp-configuration} parameter} string energy-perf-policy-on-ac
  13187. Set CPU performance versus energy saving policy on AC. Alternatives are
  13188. performance, normal, powersave.
  13189. Defaults to @samp{"performance"}.
  13190. @end deftypevr
  13191. @deftypevr {@code{tlp-configuration} parameter} string energy-perf-policy-on-bat
  13192. Same as @code{energy-perf-policy-ac} but on BAT mode.
  13193. Defaults to @samp{"powersave"}.
  13194. @end deftypevr
  13195. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disks-devices
  13196. Hard disk devices.
  13197. @end deftypevr
  13198. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disk-apm-level-on-ac
  13199. Hard disk advanced power management level.
  13200. @end deftypevr
  13201. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list disk-apm-level-on-bat
  13202. Same as @code{disk-apm-bat} but on BAT mode.
  13203. @end deftypevr
  13204. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-spindown-timeout-on-ac
  13205. Hard disk spin down timeout. One value has to be specified for each
  13206. declared hard disk.
  13207. Defaults to @samp{disabled}.
  13208. @end deftypevr
  13209. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-spindown-timeout-on-bat
  13210. Same as @code{disk-spindown-timeout-on-ac} but on BAT mode.
  13211. Defaults to @samp{disabled}.
  13212. @end deftypevr
  13213. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list disk-iosched
  13214. Select IO scheduler for disk devices. One value has to be specified for
  13215. each declared hard disk. Example alternatives are cfq, deadline and
  13216. noop.
  13217. Defaults to @samp{disabled}.
  13218. @end deftypevr
  13219. @deftypevr {@code{tlp-configuration} parameter} string sata-linkpwr-on-ac
  13220. SATA aggressive link power management (ALPM) level. Alternatives are
  13221. min_power, medium_power, max_performance.
  13222. Defaults to @samp{"max_performance"}.
  13223. @end deftypevr
  13224. @deftypevr {@code{tlp-configuration} parameter} string sata-linkpwr-on-bat
  13225. Same as @code{sata-linkpwr-ac} but on BAT mode.
  13226. Defaults to @samp{"min_power"}.
  13227. @end deftypevr
  13228. @deftypevr {@code{tlp-configuration} parameter} maybe-string sata-linkpwr-blacklist
  13229. Exclude specified SATA host devices for link power management.
  13230. Defaults to @samp{disabled}.
  13231. @end deftypevr
  13232. @deftypevr {@code{tlp-configuration} parameter} maybe-on-off-boolean ahci-runtime-pm-on-ac?
  13233. Enable Runtime Power Management for AHCI controller and disks on AC
  13234. mode.
  13235. Defaults to @samp{disabled}.
  13236. @end deftypevr
  13237. @deftypevr {@code{tlp-configuration} parameter} maybe-on-off-boolean ahci-runtime-pm-on-bat?
  13238. Same as @code{ahci-runtime-pm-on-ac} on BAT mode.
  13239. Defaults to @samp{disabled}.
  13240. @end deftypevr
  13241. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer ahci-runtime-pm-timeout
  13242. Seconds of inactivity before disk is suspended.
  13243. Defaults to @samp{15}.
  13244. @end deftypevr
  13245. @deftypevr {@code{tlp-configuration} parameter} string pcie-aspm-on-ac
  13246. PCI Express Active State Power Management level. Alternatives are
  13247. default, performance, powersave.
  13248. Defaults to @samp{"performance"}.
  13249. @end deftypevr
  13250. @deftypevr {@code{tlp-configuration} parameter} string pcie-aspm-on-bat
  13251. Same as @code{pcie-aspm-ac} but on BAT mode.
  13252. Defaults to @samp{"powersave"}.
  13253. @end deftypevr
  13254. @deftypevr {@code{tlp-configuration} parameter} string radeon-power-profile-on-ac
  13255. Radeon graphics clock speed level. Alternatives are low, mid, high,
  13256. auto, default.
  13257. Defaults to @samp{"high"}.
  13258. @end deftypevr
  13259. @deftypevr {@code{tlp-configuration} parameter} string radeon-power-profile-on-bat
  13260. Same as @code{radeon-power-ac} but on BAT mode.
  13261. Defaults to @samp{"low"}.
  13262. @end deftypevr
  13263. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-state-on-ac
  13264. Radeon dynamic power management method (DPM). Alternatives are battery,
  13265. performance.
  13266. Defaults to @samp{"performance"}.
  13267. @end deftypevr
  13268. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-state-on-bat
  13269. Same as @code{radeon-dpm-state-ac} but on BAT mode.
  13270. Defaults to @samp{"battery"}.
  13271. @end deftypevr
  13272. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-perf-level-on-ac
  13273. Radeon DPM performance level. Alternatives are auto, low, high.
  13274. Defaults to @samp{"auto"}.
  13275. @end deftypevr
  13276. @deftypevr {@code{tlp-configuration} parameter} string radeon-dpm-perf-level-on-bat
  13277. Same as @code{radeon-dpm-perf-ac} but on BAT mode.
  13278. Defaults to @samp{"auto"}.
  13279. @end deftypevr
  13280. @deftypevr {@code{tlp-configuration} parameter} on-off-boolean wifi-pwr-on-ac?
  13281. Wifi power saving mode.
  13282. Defaults to @samp{#f}.
  13283. @end deftypevr
  13284. @deftypevr {@code{tlp-configuration} parameter} on-off-boolean wifi-pwr-on-bat?
  13285. Same as @code{wifi-power-ac?} but on BAT mode.
  13286. Defaults to @samp{#t}.
  13287. @end deftypevr
  13288. @deftypevr {@code{tlp-configuration} parameter} y-n-boolean wol-disable?
  13289. Disable wake on LAN.
  13290. Defaults to @samp{#t}.
  13291. @end deftypevr
  13292. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer sound-power-save-on-ac
  13293. Timeout duration in seconds before activating audio power saving on
  13294. Intel HDA and AC97 devices. A value of 0 disables power saving.
  13295. Defaults to @samp{0}.
  13296. @end deftypevr
  13297. @deftypevr {@code{tlp-configuration} parameter} non-negative-integer sound-power-save-on-bat
  13298. Same as @code{sound-powersave-ac} but on BAT mode.
  13299. Defaults to @samp{1}.
  13300. @end deftypevr
  13301. @deftypevr {@code{tlp-configuration} parameter} y-n-boolean sound-power-save-controller?
  13302. Disable controller in powersaving mode on Intel HDA devices.
  13303. Defaults to @samp{#t}.
  13304. @end deftypevr
  13305. @deftypevr {@code{tlp-configuration} parameter} boolean bay-poweroff-on-bat?
  13306. Enable optical drive in UltraBay/MediaBay on BAT mode. Drive can be
  13307. powered on again by releasing (and reinserting) the eject lever or by
  13308. pressing the disc eject button on newer models.
  13309. Defaults to @samp{#f}.
  13310. @end deftypevr
  13311. @deftypevr {@code{tlp-configuration} parameter} string bay-device
  13312. Name of the optical drive device to power off.
  13313. Defaults to @samp{"sr0"}.
  13314. @end deftypevr
  13315. @deftypevr {@code{tlp-configuration} parameter} string runtime-pm-on-ac
  13316. Runtime Power Management for PCI(e) bus devices. Alternatives are on
  13317. and auto.
  13318. Defaults to @samp{"on"}.
  13319. @end deftypevr
  13320. @deftypevr {@code{tlp-configuration} parameter} string runtime-pm-on-bat
  13321. Same as @code{runtime-pm-ac} but on BAT mode.
  13322. Defaults to @samp{"auto"}.
  13323. @end deftypevr
  13324. @deftypevr {@code{tlp-configuration} parameter} boolean runtime-pm-all?
  13325. Runtime Power Management for all PCI(e) bus devices, except blacklisted
  13326. ones.
  13327. Defaults to @samp{#t}.
  13328. @end deftypevr
  13329. @deftypevr {@code{tlp-configuration} parameter} maybe-space-separated-string-list runtime-pm-blacklist
  13330. Exclude specified PCI(e) device addresses from Runtime Power Management.
  13331. Defaults to @samp{disabled}.
  13332. @end deftypevr
  13333. @deftypevr {@code{tlp-configuration} parameter} space-separated-string-list runtime-pm-driver-blacklist
  13334. Exclude PCI(e) devices assigned to the specified drivers from Runtime
  13335. Power Management.
  13336. @end deftypevr
  13337. @deftypevr {@code{tlp-configuration} parameter} boolean usb-autosuspend?
  13338. Enable USB autosuspend feature.
  13339. Defaults to @samp{#t}.
  13340. @end deftypevr
  13341. @deftypevr {@code{tlp-configuration} parameter} maybe-string usb-blacklist
  13342. Exclude specified devices from USB autosuspend.
  13343. Defaults to @samp{disabled}.
  13344. @end deftypevr
  13345. @deftypevr {@code{tlp-configuration} parameter} boolean usb-blacklist-wwan?
  13346. Exclude WWAN devices from USB autosuspend.
  13347. Defaults to @samp{#t}.
  13348. @end deftypevr
  13349. @deftypevr {@code{tlp-configuration} parameter} maybe-string usb-whitelist
  13350. Include specified devices into USB autosuspend, even if they are already
  13351. excluded by the driver or via @code{usb-blacklist-wwan?}.
  13352. Defaults to @samp{disabled}.
  13353. @end deftypevr
  13354. @deftypevr {@code{tlp-configuration} parameter} maybe-boolean usb-autosuspend-disable-on-shutdown?
  13355. Enable USB autosuspend before shutdown.
  13356. Defaults to @samp{disabled}.
  13357. @end deftypevr
  13358. @deftypevr {@code{tlp-configuration} parameter} boolean restore-device-state-on-startup?
  13359. Restore radio device state (bluetooth, wifi, wwan) from previous
  13360. shutdown on system startup.
  13361. Defaults to @samp{#f}.
  13362. @end deftypevr
  13363. The @code{(gnu services pm)} module provides an interface to
  13364. thermald, a CPU frequency scaling service which helps prevent overheating.
  13365. @defvr {Scheme Variable} thermald-service-type
  13366. This is the service type for
  13367. @uref{https://01.org/linux-thermal-daemon/, thermald}, the Linux
  13368. Thermal Daemon, which is responsible for controlling the thermal state
  13369. of processors and preventing overheating.
  13370. @end defvr
  13371. @deftp {Data Type} thermald-configuration
  13372. Data type representing the configuration of @code{thermald-service-type}.
  13373. @table @asis
  13374. @item @code{ignore-cpuid-check?} (default: @code{#f})
  13375. Ignore cpuid check for supported CPU models.
  13376. @item @code{thermald} (default: @var{thermald})
  13377. Package object of thermald.
  13378. @end table
  13379. @end deftp
  13380. @node Audio Services
  13381. @subsubsection Audio Services
  13382. The @code{(gnu services audio)} module provides a service to start MPD
  13383. (the Music Player Daemon).
  13384. @cindex mpd
  13385. @subsubheading Music Player Daemon
  13386. The Music Player Daemon (MPD) is a service that can play music while
  13387. being controlled from the local machine or over the network by a variety
  13388. of clients.
  13389. The following example shows how one might run @code{mpd} as user
  13390. @code{"bob"} on port @code{6666}. It uses pulseaudio for output.
  13391. @example
  13392. (service mpd-service-type
  13393. (mpd-configuration
  13394. (user "bob")
  13395. (port "6666")))
  13396. @end example
  13397. @defvr {Scheme Variable} mpd-service-type
  13398. The service type for @command{mpd}
  13399. @end defvr
  13400. @deftp {Data Type} mpd-configuration
  13401. Data type representing the configuration of @command{mpd}.
  13402. @table @asis
  13403. @item @code{user} (default: @code{"mpd"})
  13404. The user to run mpd as.
  13405. @item @code{music-dir} (default: @code{"~/Music"})
  13406. The directory to scan for music files.
  13407. @item @code{playlist-dir} (default: @code{"~/.mpd/playlists"})
  13408. The directory to store playlists.
  13409. @item @code{port} (default: @code{"6600"})
  13410. The port to run mpd on.
  13411. @item @code{address} (default: @code{"any"})
  13412. The address that mpd will bind to. To use a Unix domain socket,
  13413. an absolute path can be specified here.
  13414. @end table
  13415. @end deftp
  13416. @node Virtualization Services
  13417. @subsubsection Virtualization services
  13418. The @code{(gnu services virtualization)} module provides services for
  13419. the libvirt and virtlog daemons, as well as other virtualization-related
  13420. services.
  13421. @subsubheading Libvirt daemon
  13422. @code{libvirtd} is the server side daemon component of the libvirt
  13423. virtualization management system. This daemon runs on host servers
  13424. and performs required management tasks for virtualized guests.
  13425. @deffn {Scheme Variable} libvirt-service-type
  13426. This is the type of the @uref{https://libvirt.org, libvirt daemon}.
  13427. Its value must be a @code{libvirt-configuration}.
  13428. @example
  13429. (service libvirt-service-type
  13430. (libvirt-configuration
  13431. (unix-sock-group "libvirt")
  13432. (tls-port "16555")))
  13433. @end example
  13434. @end deffn
  13435. @c Auto-generated with (generate-libvirt-documentation)
  13436. Available @code{libvirt-configuration} fields are:
  13437. @deftypevr {@code{libvirt-configuration} parameter} package libvirt
  13438. Libvirt package.
  13439. @end deftypevr
  13440. @deftypevr {@code{libvirt-configuration} parameter} boolean listen-tls?
  13441. Flag listening for secure TLS connections on the public TCP/IP port.
  13442. must set @code{listen} for this to have any effect.
  13443. It is necessary to setup a CA and issue server certificates before using
  13444. this capability.
  13445. Defaults to @samp{#t}.
  13446. @end deftypevr
  13447. @deftypevr {@code{libvirt-configuration} parameter} boolean listen-tcp?
  13448. Listen for unencrypted TCP connections on the public TCP/IP port. must
  13449. set @code{listen} for this to have any effect.
  13450. Using the TCP socket requires SASL authentication by default. Only SASL
  13451. mechanisms which support data encryption are allowed. This is
  13452. DIGEST_MD5 and GSSAPI (Kerberos5)
  13453. Defaults to @samp{#f}.
  13454. @end deftypevr
  13455. @deftypevr {@code{libvirt-configuration} parameter} string tls-port
  13456. Port for accepting secure TLS connections This can be a port number, or
  13457. service name
  13458. Defaults to @samp{"16514"}.
  13459. @end deftypevr
  13460. @deftypevr {@code{libvirt-configuration} parameter} string tcp-port
  13461. Port for accepting insecure TCP connections This can be a port number,
  13462. or service name
  13463. Defaults to @samp{"16509"}.
  13464. @end deftypevr
  13465. @deftypevr {@code{libvirt-configuration} parameter} string listen-addr
  13466. IP address or hostname used for client connections.
  13467. Defaults to @samp{"0.0.0.0"}.
  13468. @end deftypevr
  13469. @deftypevr {@code{libvirt-configuration} parameter} boolean mdns-adv?
  13470. Flag toggling mDNS advertisement of the libvirt service.
  13471. Alternatively can disable for all services on a host by stopping the
  13472. Avahi daemon.
  13473. Defaults to @samp{#f}.
  13474. @end deftypevr
  13475. @deftypevr {@code{libvirt-configuration} parameter} string mdns-name
  13476. Default mDNS advertisement name. This must be unique on the immediate
  13477. broadcast network.
  13478. Defaults to @samp{"Virtualization Host <hostname>"}.
  13479. @end deftypevr
  13480. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-group
  13481. UNIX domain socket group ownership. This can be used to allow a
  13482. 'trusted' set of users access to management capabilities without
  13483. becoming root.
  13484. Defaults to @samp{"root"}.
  13485. @end deftypevr
  13486. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-ro-perms
  13487. UNIX socket permissions for the R/O socket. This is used for monitoring
  13488. VM status only.
  13489. Defaults to @samp{"0777"}.
  13490. @end deftypevr
  13491. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-rw-perms
  13492. UNIX socket permissions for the R/W socket. Default allows only root.
  13493. If PolicyKit is enabled on the socket, the default will change to allow
  13494. everyone (eg, 0777)
  13495. Defaults to @samp{"0770"}.
  13496. @end deftypevr
  13497. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-admin-perms
  13498. UNIX socket permissions for the admin socket. Default allows only owner
  13499. (root), do not change it unless you are sure to whom you are exposing
  13500. the access to.
  13501. Defaults to @samp{"0777"}.
  13502. @end deftypevr
  13503. @deftypevr {@code{libvirt-configuration} parameter} string unix-sock-dir
  13504. The directory in which sockets will be found/created.
  13505. Defaults to @samp{"/var/run/libvirt"}.
  13506. @end deftypevr
  13507. @deftypevr {@code{libvirt-configuration} parameter} string auth-unix-ro
  13508. Authentication scheme for UNIX read-only sockets. By default socket
  13509. permissions allow anyone to connect
  13510. Defaults to @samp{"polkit"}.
  13511. @end deftypevr
  13512. @deftypevr {@code{libvirt-configuration} parameter} string auth-unix-rw
  13513. Authentication scheme for UNIX read-write sockets. By default socket
  13514. permissions only allow root. If PolicyKit support was compiled into
  13515. libvirt, the default will be to use 'polkit' auth.
  13516. Defaults to @samp{"polkit"}.
  13517. @end deftypevr
  13518. @deftypevr {@code{libvirt-configuration} parameter} string auth-tcp
  13519. Authentication scheme for TCP sockets. If you don't enable SASL, then
  13520. all TCP traffic is cleartext. Don't do this outside of a dev/test
  13521. scenario.
  13522. Defaults to @samp{"sasl"}.
  13523. @end deftypevr
  13524. @deftypevr {@code{libvirt-configuration} parameter} string auth-tls
  13525. Authentication scheme for TLS sockets. TLS sockets already have
  13526. encryption provided by the TLS layer, and limited authentication is done
  13527. by certificates.
  13528. It is possible to make use of any SASL authentication mechanism as well,
  13529. by using 'sasl' for this option
  13530. Defaults to @samp{"none"}.
  13531. @end deftypevr
  13532. @deftypevr {@code{libvirt-configuration} parameter} optional-list access-drivers
  13533. API access control scheme.
  13534. By default an authenticated user is allowed access to all APIs. Access
  13535. drivers can place restrictions on this.
  13536. Defaults to @samp{()}.
  13537. @end deftypevr
  13538. @deftypevr {@code{libvirt-configuration} parameter} string key-file
  13539. Server key file path. If set to an empty string, then no private key is
  13540. loaded.
  13541. Defaults to @samp{""}.
  13542. @end deftypevr
  13543. @deftypevr {@code{libvirt-configuration} parameter} string cert-file
  13544. Server key file path. If set to an empty string, then no certificate is
  13545. loaded.
  13546. Defaults to @samp{""}.
  13547. @end deftypevr
  13548. @deftypevr {@code{libvirt-configuration} parameter} string ca-file
  13549. Server key file path. If set to an empty string, then no CA certificate
  13550. is loaded.
  13551. Defaults to @samp{""}.
  13552. @end deftypevr
  13553. @deftypevr {@code{libvirt-configuration} parameter} string crl-file
  13554. Certificate revocation list path. If set to an empty string, then no
  13555. CRL is loaded.
  13556. Defaults to @samp{""}.
  13557. @end deftypevr
  13558. @deftypevr {@code{libvirt-configuration} parameter} boolean tls-no-sanity-cert
  13559. Disable verification of our own server certificates.
  13560. When libvirtd starts it performs some sanity checks against its own
  13561. certificates.
  13562. Defaults to @samp{#f}.
  13563. @end deftypevr
  13564. @deftypevr {@code{libvirt-configuration} parameter} boolean tls-no-verify-cert
  13565. Disable verification of client certificates.
  13566. Client certificate verification is the primary authentication mechanism.
  13567. Any client which does not present a certificate signed by the CA will be
  13568. rejected.
  13569. Defaults to @samp{#f}.
  13570. @end deftypevr
  13571. @deftypevr {@code{libvirt-configuration} parameter} optional-list tls-allowed-dn-list
  13572. Whitelist of allowed x509 Distinguished Name.
  13573. Defaults to @samp{()}.
  13574. @end deftypevr
  13575. @deftypevr {@code{libvirt-configuration} parameter} optional-list sasl-allowed-usernames
  13576. Whitelist of allowed SASL usernames. The format for username depends on
  13577. the SASL authentication mechanism.
  13578. Defaults to @samp{()}.
  13579. @end deftypevr
  13580. @deftypevr {@code{libvirt-configuration} parameter} string tls-priority
  13581. Override the compile time default TLS priority string. The default is
  13582. usually "NORMAL" unless overridden at build time. Only set this is it
  13583. is desired for libvirt to deviate from the global default settings.
  13584. Defaults to @samp{"NORMAL"}.
  13585. @end deftypevr
  13586. @deftypevr {@code{libvirt-configuration} parameter} integer max-clients
  13587. Maximum number of concurrent client connections to allow over all
  13588. sockets combined.
  13589. Defaults to @samp{5000}.
  13590. @end deftypevr
  13591. @deftypevr {@code{libvirt-configuration} parameter} integer max-queued-clients
  13592. Maximum length of queue of connections waiting to be accepted by the
  13593. daemon. Note, that some protocols supporting retransmission may obey
  13594. this so that a later reattempt at connection succeeds.
  13595. Defaults to @samp{1000}.
  13596. @end deftypevr
  13597. @deftypevr {@code{libvirt-configuration} parameter} integer max-anonymous-clients
  13598. Maximum length of queue of accepted but not yet authenticated clients.
  13599. Set this to zero to turn this feature off
  13600. Defaults to @samp{20}.
  13601. @end deftypevr
  13602. @deftypevr {@code{libvirt-configuration} parameter} integer min-workers
  13603. Number of workers to start up initially.
  13604. Defaults to @samp{5}.
  13605. @end deftypevr
  13606. @deftypevr {@code{libvirt-configuration} parameter} integer max-workers
  13607. Maximum number of worker threads.
  13608. If the number of active clients exceeds @code{min-workers}, then more
  13609. threads are spawned, up to max_workers limit. Typically you'd want
  13610. max_workers to equal maximum number of clients allowed.
  13611. Defaults to @samp{20}.
  13612. @end deftypevr
  13613. @deftypevr {@code{libvirt-configuration} parameter} integer prio-workers
  13614. Number of priority workers. If all workers from above pool are stuck,
  13615. some calls marked as high priority (notably domainDestroy) can be
  13616. executed in this pool.
  13617. Defaults to @samp{5}.
  13618. @end deftypevr
  13619. @deftypevr {@code{libvirt-configuration} parameter} integer max-requests
  13620. Total global limit on concurrent RPC calls.
  13621. Defaults to @samp{20}.
  13622. @end deftypevr
  13623. @deftypevr {@code{libvirt-configuration} parameter} integer max-client-requests
  13624. Limit on concurrent requests from a single client connection. To avoid
  13625. one client monopolizing the server this should be a small fraction of
  13626. the global max_requests and max_workers parameter.
  13627. Defaults to @samp{5}.
  13628. @end deftypevr
  13629. @deftypevr {@code{libvirt-configuration} parameter} integer admin-min-workers
  13630. Same as @code{min-workers} but for the admin interface.
  13631. Defaults to @samp{1}.
  13632. @end deftypevr
  13633. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-workers
  13634. Same as @code{max-workers} but for the admin interface.
  13635. Defaults to @samp{5}.
  13636. @end deftypevr
  13637. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-clients
  13638. Same as @code{max-clients} but for the admin interface.
  13639. Defaults to @samp{5}.
  13640. @end deftypevr
  13641. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-queued-clients
  13642. Same as @code{max-queued-clients} but for the admin interface.
  13643. Defaults to @samp{5}.
  13644. @end deftypevr
  13645. @deftypevr {@code{libvirt-configuration} parameter} integer admin-max-client-requests
  13646. Same as @code{max-client-requests} but for the admin interface.
  13647. Defaults to @samp{5}.
  13648. @end deftypevr
  13649. @deftypevr {@code{libvirt-configuration} parameter} integer log-level
  13650. Logging level. 4 errors, 3 warnings, 2 information, 1 debug.
  13651. Defaults to @samp{3}.
  13652. @end deftypevr
  13653. @deftypevr {@code{libvirt-configuration} parameter} string log-filters
  13654. Logging filters.
  13655. A filter allows to select a different logging level for a given category
  13656. of logs The format for a filter is one of:
  13657. @itemize @bullet
  13658. @item
  13659. x:name
  13660. @item
  13661. x:+name
  13662. @end itemize
  13663. where @code{name} is a string which is matched against the category
  13664. given in the @code{VIR_LOG_INIT()} at the top of each libvirt source
  13665. file, e.g., "remote", "qemu", or "util.json" (the name in the filter can
  13666. be a substring of the full category name, in order to match multiple
  13667. similar categories), the optional "+" prefix tells libvirt to log stack
  13668. trace for each message matching name, and @code{x} is the minimal level
  13669. where matching messages should be logged:
  13670. @itemize @bullet
  13671. @item
  13672. 1: DEBUG
  13673. @item
  13674. 2: INFO
  13675. @item
  13676. 3: WARNING
  13677. @item
  13678. 4: ERROR
  13679. @end itemize
  13680. Multiple filters can be defined in a single filters statement, they just
  13681. need to be separated by spaces.
  13682. Defaults to @samp{"3:remote 4:event"}.
  13683. @end deftypevr
  13684. @deftypevr {@code{libvirt-configuration} parameter} string log-outputs
  13685. Logging outputs.
  13686. An output is one of the places to save logging information The format
  13687. for an output can be:
  13688. @table @code
  13689. @item x:stderr
  13690. output goes to stderr
  13691. @item x:syslog:name
  13692. use syslog for the output and use the given name as the ident
  13693. @item x:file:file_path
  13694. output to a file, with the given filepath
  13695. @item x:journald
  13696. output to journald logging system
  13697. @end table
  13698. In all case the x prefix is the minimal level, acting as a filter
  13699. @itemize @bullet
  13700. @item
  13701. 1: DEBUG
  13702. @item
  13703. 2: INFO
  13704. @item
  13705. 3: WARNING
  13706. @item
  13707. 4: ERROR
  13708. @end itemize
  13709. Multiple outputs can be defined, they just need to be separated by
  13710. spaces.
  13711. Defaults to @samp{"3:stderr"}.
  13712. @end deftypevr
  13713. @deftypevr {@code{libvirt-configuration} parameter} integer audit-level
  13714. Allows usage of the auditing subsystem to be altered
  13715. @itemize @bullet
  13716. @item
  13717. 0: disable all auditing
  13718. @item
  13719. 1: enable auditing, only if enabled on host
  13720. @item
  13721. 2: enable auditing, and exit if disabled on host.
  13722. @end itemize
  13723. Defaults to @samp{1}.
  13724. @end deftypevr
  13725. @deftypevr {@code{libvirt-configuration} parameter} boolean audit-logging
  13726. Send audit messages via libvirt logging infrastructure.
  13727. Defaults to @samp{#f}.
  13728. @end deftypevr
  13729. @deftypevr {@code{libvirt-configuration} parameter} optional-string host-uuid
  13730. Host UUID. UUID must not have all digits be the same.
  13731. Defaults to @samp{""}.
  13732. @end deftypevr
  13733. @deftypevr {@code{libvirt-configuration} parameter} string host-uuid-source
  13734. Source to read host UUID.
  13735. @itemize @bullet
  13736. @item
  13737. @code{smbios}: fetch the UUID from @code{dmidecode -s system-uuid}
  13738. @item
  13739. @code{machine-id}: fetch the UUID from @code{/etc/machine-id}
  13740. @end itemize
  13741. If @code{dmidecode} does not provide a valid UUID a temporary UUID will
  13742. be generated.
  13743. Defaults to @samp{"smbios"}.
  13744. @end deftypevr
  13745. @deftypevr {@code{libvirt-configuration} parameter} integer keepalive-interval
  13746. A keepalive message is sent to a client after @code{keepalive_interval}
  13747. seconds of inactivity to check if the client is still responding. If
  13748. set to -1, libvirtd will never send keepalive requests; however clients
  13749. can still send them and the daemon will send responses.
  13750. Defaults to @samp{5}.
  13751. @end deftypevr
  13752. @deftypevr {@code{libvirt-configuration} parameter} integer keepalive-count
  13753. Maximum number of keepalive messages that are allowed to be sent to the
  13754. client without getting any response before the connection is considered
  13755. broken.
  13756. In other words, the connection is automatically closed approximately
  13757. after @code{keepalive_interval * (keepalive_count + 1)} seconds since
  13758. the last message received from the client. When @code{keepalive-count}
  13759. is set to 0, connections will be automatically closed after
  13760. @code{keepalive-interval} seconds of inactivity without sending any
  13761. keepalive messages.
  13762. Defaults to @samp{5}.
  13763. @end deftypevr
  13764. @deftypevr {@code{libvirt-configuration} parameter} integer admin-keepalive-interval
  13765. Same as above but for admin interface.
  13766. Defaults to @samp{5}.
  13767. @end deftypevr
  13768. @deftypevr {@code{libvirt-configuration} parameter} integer admin-keepalive-count
  13769. Same as above but for admin interface.
  13770. Defaults to @samp{5}.
  13771. @end deftypevr
  13772. @deftypevr {@code{libvirt-configuration} parameter} integer ovs-timeout
  13773. Timeout for Open vSwitch calls.
  13774. The @code{ovs-vsctl} utility is used for the configuration and its
  13775. timeout option is set by default to 5 seconds to avoid potential
  13776. infinite waits blocking libvirt.
  13777. Defaults to @samp{5}.
  13778. @end deftypevr
  13779. @c %end of autogenerated docs
  13780. @subsubheading Virtlog daemon
  13781. The virtlogd service is a server side daemon component of libvirt that is
  13782. used to manage logs from virtual machine consoles.
  13783. This daemon is not used directly by libvirt client applications, rather it
  13784. is called on their behalf by @code{libvirtd}. By maintaining the logs in a
  13785. standalone daemon, the main @code{libvirtd} daemon can be restarted without
  13786. risk of losing logs. The @code{virtlogd} daemon has the ability to re-exec()
  13787. itself upon receiving @code{SIGUSR1}, to allow live upgrades without downtime.
  13788. @deffn {Scheme Variable} virtlog-service-type
  13789. This is the type of the virtlog daemon.
  13790. Its value must be a @code{virtlog-configuration}.
  13791. @example
  13792. (service virtlog-service-type
  13793. (virtlog-configuration
  13794. (max-clients 1000)))
  13795. @end example
  13796. @end deffn
  13797. @deftypevr {@code{virtlog-configuration} parameter} integer log-level
  13798. Logging level. 4 errors, 3 warnings, 2 information, 1 debug.
  13799. Defaults to @samp{3}.
  13800. @end deftypevr
  13801. @deftypevr {@code{virtlog-configuration} parameter} string log-filters
  13802. Logging filters.
  13803. A filter allows to select a different logging level for a given category
  13804. of logs The format for a filter is one of:
  13805. @itemize @bullet
  13806. @item
  13807. x:name
  13808. @item
  13809. x:+name
  13810. @end itemize
  13811. where @code{name} is a string which is matched against the category
  13812. given in the @code{VIR_LOG_INIT()} at the top of each libvirt source
  13813. file, e.g., "remote", "qemu", or "util.json" (the name in the filter can
  13814. be a substring of the full category name, in order to match multiple
  13815. similar categories), the optional "+" prefix tells libvirt to log stack
  13816. trace for each message matching name, and @code{x} is the minimal level
  13817. where matching messages should be logged:
  13818. @itemize @bullet
  13819. @item
  13820. 1: DEBUG
  13821. @item
  13822. 2: INFO
  13823. @item
  13824. 3: WARNING
  13825. @item
  13826. 4: ERROR
  13827. @end itemize
  13828. Multiple filters can be defined in a single filters statement, they just
  13829. need to be separated by spaces.
  13830. Defaults to @samp{"3:remote 4:event"}.
  13831. @end deftypevr
  13832. @deftypevr {@code{virtlog-configuration} parameter} string log-outputs
  13833. Logging outputs.
  13834. An output is one of the places to save logging information The format
  13835. for an output can be:
  13836. @table @code
  13837. @item x:stderr
  13838. output goes to stderr
  13839. @item x:syslog:name
  13840. use syslog for the output and use the given name as the ident
  13841. @item x:file:file_path
  13842. output to a file, with the given filepath
  13843. @item x:journald
  13844. output to journald logging system
  13845. @end table
  13846. In all case the x prefix is the minimal level, acting as a filter
  13847. @itemize @bullet
  13848. @item
  13849. 1: DEBUG
  13850. @item
  13851. 2: INFO
  13852. @item
  13853. 3: WARNING
  13854. @item
  13855. 4: ERROR
  13856. @end itemize
  13857. Multiple outputs can be defined, they just need to be separated by
  13858. spaces.
  13859. Defaults to @samp{"3:stderr"}.
  13860. @end deftypevr
  13861. @deftypevr {@code{virtlog-configuration} parameter} integer max-clients
  13862. Maximum number of concurrent client connections to allow over all
  13863. sockets combined.
  13864. Defaults to @samp{1024}.
  13865. @end deftypevr
  13866. @deftypevr {@code{virtlog-configuration} parameter} integer max-size
  13867. Maximum file size before rolling over.
  13868. Defaults to @samp{2MB}
  13869. @end deftypevr
  13870. @deftypevr {@code{virtlog-configuration} parameter} integer max-backups
  13871. Maximum number of backup files to keep.
  13872. Defaults to @samp{3}
  13873. @end deftypevr
  13874. @subsubheading Transparent Emulation with QEMU
  13875. @cindex emulation
  13876. @cindex @code{binfmt_misc}
  13877. @code{qemu-binfmt-service-type} provides support for transparent
  13878. emulation of program binaries built for different architectures---e.g.,
  13879. it allows you to transparently execute an ARMv7 program on an x86_64
  13880. machine. It achieves this by combining the @uref{https://www.qemu.org,
  13881. QEMU} emulator and the @code{binfmt_misc} feature of the kernel Linux.
  13882. @defvr {Scheme Variable} qemu-binfmt-service-type
  13883. This is the type of the QEMU/binfmt service for transparent emulation.
  13884. Its value must be a @code{qemu-binfmt-configuration} object, which
  13885. specifies the QEMU package to use as well as the architecture we want to
  13886. emulated:
  13887. @example
  13888. (service qemu-binfmt-service-type
  13889. (qemu-binfmt-configuration
  13890. (platforms (lookup-qemu-platforms "arm" "aarch64" "ppc"))))
  13891. @end example
  13892. In this example, we enable transparent emulation for the ARM and aarch64
  13893. platforms. Running @code{herd stop qemu-binfmt} turns it off, and
  13894. running @code{herd start qemu-binfmt} turns it back on (@pxref{Invoking
  13895. herd, the @command{herd} command,, shepherd, The GNU Shepherd Manual}).
  13896. @end defvr
  13897. @deftp {Data Type} qemu-binfmt-configuration
  13898. This is the configuration for the @code{qemu-binfmt} service.
  13899. @table @asis
  13900. @item @code{platforms} (default: @code{'()})
  13901. The list of emulated QEMU platforms. Each item must be a @dfn{platform
  13902. object} as returned by @code{lookup-qemu-platforms} (see below).
  13903. @item @code{guix-support?} (default: @code{#f})
  13904. When it is true, QEMU and all its dependencies are added to the build
  13905. environment of @command{guix-daemon} (@pxref{Invoking guix-daemon,
  13906. @code{--chroot-directory} option}). This allows the @code{binfmt_misc}
  13907. handlers to be used within the build environment, which in turn means
  13908. that you can transparently build programs for another architecture.
  13909. For example, let's suppose you're on an x86_64 machine and you have this
  13910. service:
  13911. @example
  13912. (service qemu-binfmt-service-type
  13913. (qemu-binfmt-configuration
  13914. (platforms (lookup-qemu-platforms "arm"))
  13915. (qemu-support? #t)))
  13916. @end example
  13917. You can run:
  13918. @example
  13919. guix build -s armhf-linux inkscape
  13920. @end example
  13921. @noindent
  13922. and it will build Inkscape for ARMv7 @emph{as if it were a native
  13923. build}, transparently using QEMU to emulate the ARMv7 CPU. Pretty handy
  13924. if you'd like to test a package build for an architecture you don't have
  13925. access to!
  13926. @item @code{qemu} (default: @code{qemu})
  13927. The QEMU package to use.
  13928. @end table
  13929. @end deftp
  13930. @deffn {Scheme Procedure} lookup-qemu-platforms @var{platforms}@dots{}
  13931. Return the list of QEMU platform objects corresponding to
  13932. @var{platforms}@dots{}. @var{platforms} must be a list of strings
  13933. corresponding to platform names, such as @code{"arm"}, @code{"sparc"},
  13934. @code{"mips64el"}, and so on.
  13935. @end deffn
  13936. @deffn {Scheme Procedure} qemu-platform? @var{obj}
  13937. Return true if @var{obj} is a platform object.
  13938. @end deffn
  13939. @deffn {Scheme Procedure} qemu-platform-name @var{platform}
  13940. Return the name of @var{platform}---a string such as @code{"arm"}.
  13941. @end deffn
  13942. @node Version Control Services
  13943. @subsubsection Version Control Services
  13944. The @code{(gnu services version-control)} module provides a service to
  13945. allow remote access to local Git repositories. There are two options:
  13946. the @code{git-daemon-service}, which provides access to repositories via
  13947. the @code{git://} unsecured TCP-based protocol, or extending the
  13948. @code{nginx} web server to proxy some requests to
  13949. @code{git-http-backend}.
  13950. @deffn {Scheme Procedure} git-daemon-service [#:config (git-daemon-configuration)]
  13951. Return a service that runs @command{git daemon}, a simple TCP server to
  13952. expose repositories over the Git protocol for anonymous access.
  13953. The optional @var{config} argument should be a
  13954. @code{<git-daemon-configuration>} object, by default it allows read-only
  13955. access to exported@footnote{By creating the magic file
  13956. "git-daemon-export-ok" in the repository directory.} repositories under
  13957. @file{/srv/git}.
  13958. @end deffn
  13959. @deftp {Data Type} git-daemon-configuration
  13960. Data type representing the configuration for @code{git-daemon-service}.
  13961. @table @asis
  13962. @item @code{package} (default: @var{git})
  13963. Package object of the Git distributed version control system.
  13964. @item @code{export-all?} (default: @var{#f})
  13965. Whether to allow access for all Git repositories, even if they do not
  13966. have the @file{git-daemon-export-ok} file.
  13967. @item @code{base-path} (default: @file{/srv/git})
  13968. Whether to remap all the path requests as relative to the given path.
  13969. If you run git daemon with @var{(base-path "/srv/git")} on example.com,
  13970. then if you later try to pull @code{git://example.com/hello.git}, git
  13971. daemon will interpret the path as @code{/srv/git/hello.git}.
  13972. @item @code{user-path} (default: @var{#f})
  13973. Whether to allow @code{~user} notation to be used in requests. When
  13974. specified with empty string, requests to @code{git://host/~alice/foo} is
  13975. taken as a request to access @code{foo} repository in the home directory
  13976. of user @code{alice}. If @var{(user-path "path")} is specified, the
  13977. same request is taken as a request to access @code{path/foo} repository
  13978. in the home directory of user @code{alice}.
  13979. @item @code{listen} (default: @var{'()})
  13980. Whether to listen on specific IP addresses or hostnames, defaults to
  13981. all.
  13982. @item @code{port} (default: @var{#f})
  13983. Whether to listen on an alternative port, which defaults to 9418.
  13984. @item @code{whitelist} (default: @var{'()})
  13985. If not empty, only allow access to this list of directories.
  13986. @item @code{extra-options} (default: @var{'()})
  13987. Extra options will be passed to @code{git daemon}, please run
  13988. @command{man git-daemon} for more information.
  13989. @end table
  13990. @end deftp
  13991. The @code{git://} protocol lacks authentication. When you pull from a
  13992. repository fetched via @code{git://}, you don't know that the data you
  13993. receive was modified is really coming from the specified host, and you
  13994. have your connection is subject to eavesdropping. It's better to use an
  13995. authenticated and encrypted transport, such as @code{https}. Although Git allows you
  13996. to serve repositories using unsophisticated file-based web servers,
  13997. there is a faster protocol implemented by the @code{git-http-backend}
  13998. program. This program is the back-end of a proper Git web service. It
  13999. is designed to sit behind a FastCGI proxy. @xref{Web Services}, for more
  14000. on running the necessary @code{fcgiwrap} daemon.
  14001. Guix has a separate configuration data type for serving Git repositories
  14002. over HTTP.
  14003. @deftp {Data Type} git-http-configuration
  14004. Data type representing the configuration for @code{git-http-service}.
  14005. @table @asis
  14006. @item @code{package} (default: @var{git})
  14007. Package object of the Git distributed version control system.
  14008. @item @code{git-root} (default: @file{/srv/git})
  14009. Directory containing the Git repositories to expose to the world.
  14010. @item @code{export-all?} (default: @var{#f})
  14011. Whether to expose access for all Git repositories in @var{git-root},
  14012. even if they do not have the @file{git-daemon-export-ok} file.
  14013. @item @code{uri-path} (default: @file{/git/})
  14014. Path prefix for Git access. With the default @code{/git/} prefix, this
  14015. will map @code{http://@var{server}/git/@var{repo}.git} to
  14016. @code{/srv/git/@var{repo}.git}. Requests whose URI paths do not begin
  14017. with this prefix are not passed on to this Git instance.
  14018. @item @code{fcgiwrap-socket} (default: @code{127.0.0.1:9000})
  14019. The socket on which the @code{fcgiwrap} daemon is listening. @xref{Web
  14020. Services}.
  14021. @end table
  14022. @end deftp
  14023. There is no @code{git-http-service-type}, currently; instead you can
  14024. create an @code{nginx-location-configuration} from a
  14025. @code{git-http-configuration} and then add that location to a web
  14026. server.
  14027. @deffn {Scheme Procedure} git-http-nginx-location-configuration @
  14028. [config=(git-http-configuration)]
  14029. Compute an @code{nginx-location-configuration} that corresponds to the
  14030. given Git http configuration. An example nginx service definition to
  14031. serve the default @file{/srv/git} over HTTPS might be:
  14032. @example
  14033. (service nginx-service-type
  14034. (nginx-configuration
  14035. (server-blocks
  14036. (list
  14037. (nginx-server-configuration
  14038. (listen '("443 ssl"))
  14039. (server-name "git.my-host.org")
  14040. (ssl-certificate
  14041. "/etc/letsencrypt/live/git.my-host.org/fullchain.pem")
  14042. (ssl-certificate-key
  14043. "/etc/letsencrypt/live/git.my-host.org/privkey.pem")
  14044. (locations
  14045. (list
  14046. (git-http-nginx-location-configuration
  14047. (git-http-configuration (uri-path "/"))))))))))
  14048. @end example
  14049. This example assumes that you are using Let's Encrypt to get your TLS
  14050. certificate. @xref{Certificate Services}. The default @code{certbot}
  14051. service will redirect all HTTP traffic on @code{git.my-host.org} to
  14052. HTTPS. You will also need to add an @code{fcgiwrap} proxy to your
  14053. system services. @xref{Web Services}.
  14054. @end deffn
  14055. @node Miscellaneous Services
  14056. @subsubsection Miscellaneous Services
  14057. @cindex sysctl
  14058. @subsubheading System Control Service
  14059. The @code{(gnu services sysctl)} provides a service to configure kernel
  14060. parameters at boot.
  14061. @defvr {Scheme Variable} sysctl-service-type
  14062. The service type for @command{sysctl}, which modifies kernel parameters
  14063. under @file{/proc/sys/}. To enable IPv4 forwarding, it can be
  14064. instantiated as:
  14065. @example
  14066. (service sysctl-service-type
  14067. (sysctl-configuration
  14068. (settings '(("net.ipv4.ip_forward" . "1")))))
  14069. @end example
  14070. @end defvr
  14071. @deftp {Data Type} sysctl-configuration
  14072. The data type representing the configuration of @command{sysctl}.
  14073. @table @asis
  14074. @item @code{sysctl} (default: @code{(file-append procps "/sbin/sysctl"})
  14075. The @command{sysctl} executable to use.
  14076. @item @code{settings} (default: @code{'()})
  14077. An association list specifies kernel parameters and their values.
  14078. @end table
  14079. @end deftp
  14080. @cindex lirc
  14081. @subsubheading Lirc Service
  14082. The @code{(gnu services lirc)} module provides the following service.
  14083. @deffn {Scheme Procedure} lirc-service [#:lirc lirc] @
  14084. [#:device #f] [#:driver #f] [#:config-file #f] @
  14085. [#:extra-options '()]
  14086. Return a service that runs @url{http://www.lirc.org,LIRC}, a daemon that
  14087. decodes infrared signals from remote controls.
  14088. Optionally, @var{device}, @var{driver} and @var{config-file}
  14089. (configuration file name) may be specified. See @command{lircd} manual
  14090. for details.
  14091. Finally, @var{extra-options} is a list of additional command-line options
  14092. passed to @command{lircd}.
  14093. @end deffn
  14094. @cindex spice
  14095. @subsubheading Spice Service
  14096. The @code{(gnu services spice)} module provides the following service.
  14097. @deffn {Scheme Procedure} spice-vdagent-service [#:spice-vdagent]
  14098. Returns a service that runs @url{http://www.spice-space.org,VDAGENT}, a daemon
  14099. that enables sharing the clipboard with a vm and setting the guest display
  14100. resolution when the graphical console window resizes.
  14101. @end deffn
  14102. @subsubsection Dictionary Services
  14103. @cindex dictionary
  14104. The @code{(gnu services dict)} module provides the following service:
  14105. @deffn {Scheme Procedure} dicod-service [#:config (dicod-configuration)]
  14106. Return a service that runs the @command{dicod} daemon, an implementation
  14107. of DICT server (@pxref{Dicod,,, dico, GNU Dico Manual}).
  14108. The optional @var{config} argument specifies the configuration for
  14109. @command{dicod}, which should be a @code{<dicod-configuration>} object, by
  14110. default it serves the GNU Collaborative International Dictonary of English.
  14111. You can add @command{open localhost} to your @file{~/.dico} file to make
  14112. @code{localhost} the default server for @command{dico} client
  14113. (@pxref{Initialization File,,, dico, GNU Dico Manual}).
  14114. @end deffn
  14115. @deftp {Data Type} dicod-configuration
  14116. Data type representing the configuration of dicod.
  14117. @table @asis
  14118. @item @code{dico} (default: @var{dico})
  14119. Package object of the GNU Dico dictionary server.
  14120. @item @code{interfaces} (default: @var{'("localhost")})
  14121. This is the list of IP addresses and ports and possibly socket file
  14122. names to listen to (@pxref{Server Settings, @code{listen} directive,,
  14123. dico, GNU Dico Manual}).
  14124. @item @code{handlers} (default: @var{'()})
  14125. List of @code{<dicod-handler>} objects denoting handlers (module instances).
  14126. @item @code{databases} (default: @var{(list %dicod-database:gcide)})
  14127. List of @code{<dicod-database>} objects denoting dictionaries to be served.
  14128. @end table
  14129. @end deftp
  14130. @deftp {Data Type} dicod-handler
  14131. Data type representing a dictionary handler (module instance).
  14132. @table @asis
  14133. @item @code{name}
  14134. Name of the handler (module instance).
  14135. @item @code{module} (default: @var{#f})
  14136. Name of the dicod module of the handler (instance). If it is @code{#f},
  14137. the module has the same name as the handler.
  14138. (@pxref{Modules,,, dico, GNU Dico Manual}).
  14139. @item @code{options}
  14140. List of strings or gexps representing the arguments for the module handler
  14141. @end table
  14142. @end deftp
  14143. @deftp {Data Type} dicod-database
  14144. Data type representing a dictionary database.
  14145. @table @asis
  14146. @item @code{name}
  14147. Name of the database, will be used in DICT commands.
  14148. @item @code{handler}
  14149. Name of the dicod handler (module instance) used by this database
  14150. (@pxref{Handlers,,, dico, GNU Dico Manual}).
  14151. @item @code{complex?} (default: @var{#f})
  14152. Whether the database configuration complex. The complex configuration
  14153. will need a corresponding @code{<dicod-handler>} object, otherwise not.
  14154. @item @code{options}
  14155. List of strings or gexps representing the arguments for the database
  14156. (@pxref{Databases,,, dico, GNU Dico Manual}).
  14157. @end table
  14158. @end deftp
  14159. @defvr {Scheme Variable} %dicod-database:gcide
  14160. A @code{<dicod-database>} object serving the GNU Collaborative International
  14161. Dictionary of English using the @code{gcide} package.
  14162. @end defvr
  14163. The following is an example @code{dicod-service} configuration.
  14164. @example
  14165. (dicod-service #:config
  14166. (dicod-configuration
  14167. (handlers (list (dicod-handler
  14168. (name "wordnet")
  14169. (module "dictorg")
  14170. (options
  14171. (list #~(string-append "dbdir=" #$wordnet))))))
  14172. (databases (list (dicod-database
  14173. (name "wordnet")
  14174. (complex? #t)
  14175. (handler "wordnet")
  14176. (options '("database=wn")))
  14177. %dicod-database:gcide))))
  14178. @end example
  14179. @subsubheading Cgit Service
  14180. @cindex Cgit service
  14181. @cindex Git, web interface
  14182. @uref{https://git.zx2c4.com/cgit/, Cgit} is a web frontend for Git
  14183. repositories written in C.
  14184. The following example will configure the service with default values.
  14185. By default, Cgit can be accessed on port 80 (@code{http://localhost:80}).
  14186. @example
  14187. (service nginx-service-type)
  14188. (service fcgiwrap-service-type)
  14189. (service cgit-service-type)
  14190. @end example
  14191. @deftp {Data Type} cgit-configuration
  14192. Data type representing the configuration of Cgit.
  14193. This type has the following parameters:
  14194. @table @asis
  14195. @item @code{config-file} (default: @code{(cgit-configuration-file)})
  14196. The configuration file to use for Cgit. This can be set to a
  14197. @dfn{cgit-configuration-file} record value, or any gexp
  14198. (@pxref{G-Expressions}).
  14199. For example, to instead use a local file, the @code{local-file} function
  14200. can be used:
  14201. @example
  14202. (service cgit-service-type
  14203. (cgit-configuration
  14204. (config-file (local-file "./my-cgitrc.conf"))))
  14205. @end example
  14206. @item @code{package} (default: @code{cgit})
  14207. The Cgit package to use.
  14208. @end table
  14209. @end deftp
  14210. @deftp {Data Type} cgit-configuration-file
  14211. Data type representing the configuration options for Cgit.
  14212. This type has the following parameters:
  14213. @table @asis
  14214. @item @code{css} (default: @code{"/share/cgit/cgit.css"})
  14215. URL which specifies the css document to include in all Cgit pages.
  14216. @item @code{logo} (default: @code{"/share/cgit/cgit.png"})
  14217. URL which specifies the source of an image which will be used as a logo
  14218. on all Cgit pages.
  14219. @item @code{virtual-root} (default: @code{"/"})
  14220. URL which, if specified, will be used as root for all Cgit links.
  14221. @item @code{repository-directory} (default: @code{"/srv/git"})
  14222. Name of the directory to scan for repositories.
  14223. @item @code{robots} (default: @code{(list "noindex" "nofollow")})
  14224. Text used as content for the ``robots'' meta-tag.
  14225. @end table
  14226. @end deftp
  14227. @node Setuid Programs
  14228. @subsection Setuid Programs
  14229. @cindex setuid programs
  14230. Some programs need to run with ``root'' privileges, even when they are
  14231. launched by unprivileged users. A notorious example is the
  14232. @command{passwd} program, which users can run to change their
  14233. password, and which needs to access the @file{/etc/passwd} and
  14234. @file{/etc/shadow} files---something normally restricted to root, for
  14235. obvious security reasons. To address that, these executables are
  14236. @dfn{setuid-root}, meaning that they always run with root privileges
  14237. (@pxref{How Change Persona,,, libc, The GNU C Library Reference Manual},
  14238. for more info about the setuid mechanism.)
  14239. The store itself @emph{cannot} contain setuid programs: that would be a
  14240. security issue since any user on the system can write derivations that
  14241. populate the store (@pxref{The Store}). Thus, a different mechanism is
  14242. used: instead of changing the setuid bit directly on files that are in
  14243. the store, we let the system administrator @emph{declare} which programs
  14244. should be setuid root.
  14245. The @code{setuid-programs} field of an @code{operating-system}
  14246. declaration contains a list of G-expressions denoting the names of
  14247. programs to be setuid-root (@pxref{Using the Configuration System}).
  14248. For instance, the @command{passwd} program, which is part of the Shadow
  14249. package, can be designated by this G-expression (@pxref{G-Expressions}):
  14250. @example
  14251. #~(string-append #$shadow "/bin/passwd")
  14252. @end example
  14253. A default set of setuid programs is defined by the
  14254. @code{%setuid-programs} variable of the @code{(gnu system)} module.
  14255. @defvr {Scheme Variable} %setuid-programs
  14256. A list of G-expressions denoting common programs that are setuid-root.
  14257. The list includes commands such as @command{passwd}, @command{ping},
  14258. @command{su}, and @command{sudo}.
  14259. @end defvr
  14260. Under the hood, the actual setuid programs are created in the
  14261. @file{/run/setuid-programs} directory at system activation time. The
  14262. files in this directory refer to the ``real'' binaries, which are in the
  14263. store.
  14264. @node X.509 Certificates
  14265. @subsection X.509 Certificates
  14266. @cindex HTTPS, certificates
  14267. @cindex X.509 certificates
  14268. @cindex TLS
  14269. Web servers available over HTTPS (that is, HTTP over the transport-layer
  14270. security mechanism, TLS) send client programs an @dfn{X.509 certificate}
  14271. that the client can then use to @emph{authenticate} the server. To do
  14272. that, clients verify that the server's certificate is signed by a
  14273. so-called @dfn{certificate authority} (CA). But to verify the CA's
  14274. signature, clients must have first acquired the CA's certificate.
  14275. Web browsers such as GNU@tie{}IceCat include their own set of CA
  14276. certificates, such that they are able to verify CA signatures
  14277. out-of-the-box.
  14278. However, most other programs that can talk HTTPS---@command{wget},
  14279. @command{git}, @command{w3m}, etc.---need to be told where CA
  14280. certificates can be found.
  14281. @cindex @code{nss-certs}
  14282. In GuixSD, this is done by adding a package that provides certificates
  14283. to the @code{packages} field of the @code{operating-system} declaration
  14284. (@pxref{operating-system Reference}). GuixSD includes one such package,
  14285. @code{nss-certs}, which is a set of CA certificates provided as part of
  14286. Mozilla's Network Security Services.
  14287. Note that it is @emph{not} part of @var{%base-packages}, so you need to
  14288. explicitly add it. The @file{/etc/ssl/certs} directory, which is where
  14289. most applications and libraries look for certificates by default, points
  14290. to the certificates installed globally.
  14291. Unprivileged users, including users of Guix on a foreign distro,
  14292. can also install their own certificate package in
  14293. their profile. A number of environment variables need to be defined so
  14294. that applications and libraries know where to find them. Namely, the
  14295. OpenSSL library honors the @code{SSL_CERT_DIR} and @code{SSL_CERT_FILE}
  14296. variables. Some applications add their own environment variables; for
  14297. instance, the Git version control system honors the certificate bundle
  14298. pointed to by the @code{GIT_SSL_CAINFO} environment variable. Thus, you
  14299. would typically run something like:
  14300. @example
  14301. $ guix package -i nss-certs
  14302. $ export SSL_CERT_DIR="$HOME/.guix-profile/etc/ssl/certs"
  14303. $ export SSL_CERT_FILE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt"
  14304. $ export GIT_SSL_CAINFO="$SSL_CERT_FILE"
  14305. @end example
  14306. As another example, R requires the @code{CURL_CA_BUNDLE} environment
  14307. variable to point to a certificate bundle, so you would have to run
  14308. something like this:
  14309. @example
  14310. $ guix package -i nss-certs
  14311. $ export CURL_CA_BUNDLE="$HOME/.guix-profile/etc/ssl/certs/ca-certificates.crt"
  14312. @end example
  14313. For other applications you may want to look up the required environment
  14314. variable in the relevant documentation.
  14315. @node Name Service Switch
  14316. @subsection Name Service Switch
  14317. @cindex name service switch
  14318. @cindex NSS
  14319. The @code{(gnu system nss)} module provides bindings to the
  14320. configuration file of the libc @dfn{name service switch} or @dfn{NSS}
  14321. (@pxref{NSS Configuration File,,, libc, The GNU C Library Reference
  14322. Manual}). In a nutshell, the NSS is a mechanism that allows libc to be
  14323. extended with new ``name'' lookup methods for system databases, which
  14324. includes host names, service names, user accounts, and more (@pxref{Name
  14325. Service Switch, System Databases and Name Service Switch,, libc, The GNU
  14326. C Library Reference Manual}).
  14327. The NSS configuration specifies, for each system database, which lookup
  14328. method is to be used, and how the various methods are chained
  14329. together---for instance, under which circumstances NSS should try the
  14330. next method in the list. The NSS configuration is given in the
  14331. @code{name-service-switch} field of @code{operating-system} declarations
  14332. (@pxref{operating-system Reference, @code{name-service-switch}}).
  14333. @cindex nss-mdns
  14334. @cindex .local, host name lookup
  14335. As an example, the declaration below configures the NSS to use the
  14336. @uref{http://0pointer.de/lennart/projects/nss-mdns/, @code{nss-mdns}
  14337. back-end}, which supports host name lookups over multicast DNS (mDNS)
  14338. for host names ending in @code{.local}:
  14339. @example
  14340. (name-service-switch
  14341. (hosts (list %files ;first, check /etc/hosts
  14342. ;; If the above did not succeed, try
  14343. ;; with 'mdns_minimal'.
  14344. (name-service
  14345. (name "mdns_minimal")
  14346. ;; 'mdns_minimal' is authoritative for
  14347. ;; '.local'. When it returns "not found",
  14348. ;; no need to try the next methods.
  14349. (reaction (lookup-specification
  14350. (not-found => return))))
  14351. ;; Then fall back to DNS.
  14352. (name-service
  14353. (name "dns"))
  14354. ;; Finally, try with the "full" 'mdns'.
  14355. (name-service
  14356. (name "mdns")))))
  14357. @end example
  14358. Do not worry: the @code{%mdns-host-lookup-nss} variable (see below)
  14359. contains this configuration, so you will not have to type it if all you
  14360. want is to have @code{.local} host lookup working.
  14361. Note that, in this case, in addition to setting the
  14362. @code{name-service-switch} of the @code{operating-system} declaration,
  14363. you also need to use @code{avahi-service} (@pxref{Networking Services,
  14364. @code{avahi-service}}), or @var{%desktop-services}, which includes it
  14365. (@pxref{Desktop Services}). Doing this makes @code{nss-mdns} accessible
  14366. to the name service cache daemon (@pxref{Base Services,
  14367. @code{nscd-service}}).
  14368. For convenience, the following variables provide typical NSS
  14369. configurations.
  14370. @defvr {Scheme Variable} %default-nss
  14371. This is the default name service switch configuration, a
  14372. @code{name-service-switch} object.
  14373. @end defvr
  14374. @defvr {Scheme Variable} %mdns-host-lookup-nss
  14375. This is the name service switch configuration with support for host name
  14376. lookup over multicast DNS (mDNS) for host names ending in @code{.local}.
  14377. @end defvr
  14378. The reference for name service switch configuration is given below. It
  14379. is a direct mapping of the configuration file format of the C library , so
  14380. please refer to the C library manual for more information (@pxref{NSS
  14381. Configuration File,,, libc, The GNU C Library Reference Manual}).
  14382. Compared to the configuration file format of libc NSS, it has the advantage
  14383. not only of adding this warm parenthetic feel that we like, but also
  14384. static checks: you will know about syntax errors and typos as soon as you
  14385. run @command{guix system}.
  14386. @deftp {Data Type} name-service-switch
  14387. This is the data type representation the configuration of libc's name
  14388. service switch (NSS). Each field below represents one of the supported
  14389. system databases.
  14390. @table @code
  14391. @item aliases
  14392. @itemx ethers
  14393. @itemx group
  14394. @itemx gshadow
  14395. @itemx hosts
  14396. @itemx initgroups
  14397. @itemx netgroup
  14398. @itemx networks
  14399. @itemx password
  14400. @itemx public-key
  14401. @itemx rpc
  14402. @itemx services
  14403. @itemx shadow
  14404. The system databases handled by the NSS. Each of these fields must be a
  14405. list of @code{<name-service>} objects (see below).
  14406. @end table
  14407. @end deftp
  14408. @deftp {Data Type} name-service
  14409. This is the data type representing an actual name service and the
  14410. associated lookup action.
  14411. @table @code
  14412. @item name
  14413. A string denoting the name service (@pxref{Services in the NSS
  14414. configuration,,, libc, The GNU C Library Reference Manual}).
  14415. Note that name services listed here must be visible to nscd. This is
  14416. achieved by passing the @code{#:name-services} argument to
  14417. @code{nscd-service} the list of packages providing the needed name
  14418. services (@pxref{Base Services, @code{nscd-service}}).
  14419. @item reaction
  14420. An action specified using the @code{lookup-specification} macro
  14421. (@pxref{Actions in the NSS configuration,,, libc, The GNU C Library
  14422. Reference Manual}). For example:
  14423. @example
  14424. (lookup-specification (unavailable => continue)
  14425. (success => return))
  14426. @end example
  14427. @end table
  14428. @end deftp
  14429. @node Initial RAM Disk
  14430. @subsection Initial RAM Disk
  14431. @cindex initrd
  14432. @cindex initial RAM disk
  14433. For bootstrapping purposes, the Linux-Libre kernel is passed an
  14434. @dfn{initial RAM disk}, or @dfn{initrd}. An initrd contains a temporary
  14435. root file system as well as an initialization script. The latter is
  14436. responsible for mounting the real root file system, and for loading any
  14437. kernel modules that may be needed to achieve that.
  14438. The @code{initrd} field of an @code{operating-system} declaration allows
  14439. you to specify which initrd you would like to use. The @code{(gnu
  14440. system linux-initrd)} module provides three ways to build an initrd: the
  14441. high-level @code{base-initrd} procedure and the low-level
  14442. @code{raw-initrd} and @code{expression->initrd} procedures.
  14443. The @code{base-initrd} procedure is intended to cover most common uses.
  14444. For example, if you want to add a bunch of kernel modules to be loaded
  14445. at boot time, you can define the @code{initrd} field of the operating
  14446. system declaration like this:
  14447. @example
  14448. (initrd (lambda (file-systems . rest)
  14449. ;; Create a standard initrd that has modules "foo.ko"
  14450. ;; and "bar.ko", as well as their dependencies, in
  14451. ;; addition to the modules available by default.
  14452. (apply base-initrd file-systems
  14453. #:extra-modules '("foo" "bar")
  14454. rest)))
  14455. @end example
  14456. The @code{base-initrd} procedure also handles common use cases that
  14457. involves using the system as a QEMU guest, or as a ``live'' system with
  14458. volatile root file system.
  14459. The @code{base-initrd} procedure is built from @code{raw-initrd} procedure.
  14460. Unlike @code{base-initrd}, @code{raw-initrd} doesn't do anything high-level,
  14461. such as trying to guess which kernel modules and packages should be included
  14462. to the initrd. An example use of @code{raw-initrd} is when a user has
  14463. a custom Linux kernel configuration and default kernel modules included by
  14464. @code{base-initrd} are not available.
  14465. The initial RAM disk produced by @code{base-initrd} or @code{raw-initrd}
  14466. honors several options passed on the Linux kernel command line
  14467. (that is, arguments passed @i{via} the @code{linux} command of GRUB, or the
  14468. @code{-append} option of QEMU), notably:
  14469. @table @code
  14470. @item --load=@var{boot}
  14471. Tell the initial RAM disk to load @var{boot}, a file containing a Scheme
  14472. program, once it has mounted the root file system.
  14473. GuixSD uses this option to yield control to a boot program that runs the
  14474. service activation programs and then spawns the GNU@tie{}Shepherd, the
  14475. initialization system.
  14476. @item --root=@var{root}
  14477. Mount @var{root} as the root file system. @var{root} can be a
  14478. device name like @code{/dev/sda1}, a partition label, or a partition
  14479. UUID.
  14480. @item --system=@var{system}
  14481. Have @file{/run/booted-system} and @file{/run/current-system} point to
  14482. @var{system}.
  14483. @item modprobe.blacklist=@var{modules}@dots{}
  14484. @cindex module, black-listing
  14485. @cindex black list, of kernel modules
  14486. Instruct the initial RAM disk as well as the @command{modprobe} command
  14487. (from the kmod package) to refuse to load @var{modules}. @var{modules}
  14488. must be a comma-separated list of module names---e.g.,
  14489. @code{usbkbd,9pnet}.
  14490. @item --repl
  14491. Start a read-eval-print loop (REPL) from the initial RAM disk before it
  14492. tries to load kernel modules and to mount the root file system. Our
  14493. marketing team calls it @dfn{boot-to-Guile}. The Schemer in you will
  14494. love it. @xref{Using Guile Interactively,,, guile, GNU Guile Reference
  14495. Manual}, for more information on Guile's REPL.
  14496. @end table
  14497. Now that you know all the features that initial RAM disks produced by
  14498. @code{base-initrd} and @code{raw-initrd} provide,
  14499. here is how to use it and customize it further.
  14500. @cindex initrd
  14501. @cindex initial RAM disk
  14502. @deffn {Monadic Procedure} raw-initrd @var{file-systems} @
  14503. [#:linux-modules '()] [#:mapped-devices '()] @
  14504. [#:helper-packages '()] [#:qemu-networking? #f] [#:volatile-root? #f]
  14505. Return a monadic derivation that builds a raw initrd. @var{file-systems} is
  14506. a list of file systems to be mounted by the initrd, possibly in addition to
  14507. the root file system specified on the kernel command line via @code{--root}.
  14508. @var{linux-modules} is a list of kernel modules to be loaded at boot time.
  14509. @var{mapped-devices} is a list of device mappings to realize before
  14510. @var{file-systems} are mounted (@pxref{Mapped Devices}).
  14511. @var{helper-packages} is a list of packages to be copied in the initrd. It may
  14512. include @code{e2fsck/static} or other packages needed by the initrd to check
  14513. root partition.
  14514. When @var{qemu-networking?} is true, set up networking with the standard QEMU
  14515. parameters. When @var{virtio?} is true, load additional modules so that the
  14516. initrd can be used as a QEMU guest with para-virtualized I/O drivers.
  14517. When @var{volatile-root?} is true, the root file system is writable but any changes
  14518. to it are lost.
  14519. @end deffn
  14520. @deffn {Monadic Procedure} base-initrd @var{file-systems} @
  14521. [#:mapped-devices '()] [#:qemu-networking? #f] [#:volatile-root? #f]@
  14522. [#:virtio? #t] [#:extra-modules '()]
  14523. Return a monadic derivation that builds a generic initrd. @var{file-systems} is
  14524. a list of file systems to be mounted by the initrd like for @code{raw-initrd}.
  14525. @var{mapped-devices}, @var{qemu-networking?} and @var{volatile-root?}
  14526. also behaves as in @code{raw-initrd}.
  14527. When @var{virtio?} is true, load additional modules so that the
  14528. initrd can be used as a QEMU guest with para-virtualized I/O drivers.
  14529. The initrd is automatically populated with all the kernel modules necessary
  14530. for @var{file-systems} and for the given options. However, additional kernel
  14531. modules can be listed in @var{extra-modules}. They will be added to the initrd, and
  14532. loaded at boot time in the order in which they appear.
  14533. @end deffn
  14534. Needless to say, the initrds we produce and use embed a
  14535. statically-linked Guile, and the initialization program is a Guile
  14536. program. That gives a lot of flexibility. The
  14537. @code{expression->initrd} procedure builds such an initrd, given the
  14538. program to run in that initrd.
  14539. @deffn {Monadic Procedure} expression->initrd @var{exp} @
  14540. [#:guile %guile-static-stripped] [#:name "guile-initrd"]
  14541. Return a derivation that builds a Linux initrd (a gzipped cpio archive)
  14542. containing @var{guile} and that evaluates @var{exp}, a G-expression,
  14543. upon booting. All the derivations referenced by @var{exp} are
  14544. automatically copied to the initrd.
  14545. @end deffn
  14546. @node Bootloader Configuration
  14547. @subsection Bootloader Configuration
  14548. @cindex bootloader
  14549. @cindex boot loader
  14550. The operating system supports multiple bootloaders. The bootloader is
  14551. configured using @code{bootloader-configuration} declaration. All the
  14552. fields of this structure are bootloader agnostic except for one field,
  14553. @code{bootloader} that indicates the bootloader to be configured and
  14554. installed.
  14555. Some of the bootloaders do not honor every field of
  14556. @code{bootloader-configuration}. For instance, the extlinux
  14557. bootloader does not support themes and thus ignores the @code{theme}
  14558. field.
  14559. @deftp {Data Type} bootloader-configuration
  14560. The type of a bootloader configuration declaration.
  14561. @table @asis
  14562. @item @code{bootloader}
  14563. @cindex EFI, bootloader
  14564. @cindex UEFI, bootloader
  14565. @cindex BIOS, bootloader
  14566. The bootloader to use, as a @code{bootloader} object. For now
  14567. @code{grub-bootloader}, @code{grub-efi-bootloader},
  14568. @code{extlinux-bootloader} and @code{u-boot-bootloader} are supported.
  14569. @code{grub-efi-bootloader} allows to boot on modern systems using the
  14570. @dfn{Unified Extensible Firmware Interface} (UEFI).
  14571. Available bootloaders are described in @code{(gnu bootloader @dots{})}
  14572. modules.
  14573. @item @code{target}
  14574. This is a string denoting the target onto which to install the
  14575. bootloader. The exact interpretation depends on the bootloader in
  14576. question; for @code{grub-bootloader}, for example, it should be a device
  14577. name understood by the bootloader @command{installer} command, such as
  14578. @code{/dev/sda} or @code{(hd0)} (for GRUB, @pxref{Invoking
  14579. grub-install,,, grub, GNU GRUB Manual}). For
  14580. @code{grub-efi-bootloader}, it should be the path to a mounted EFI file
  14581. system.
  14582. @item @code{menu-entries} (default: @code{()})
  14583. A possibly empty list of @code{menu-entry} objects (see below), denoting
  14584. entries to appear in the bootloader menu, in addition to the current
  14585. system entry and the entry pointing to previous system generations.
  14586. @item @code{default-entry} (default: @code{0})
  14587. The index of the default boot menu entry. Index 0 is for the entry of the
  14588. current system.
  14589. @item @code{timeout} (default: @code{5})
  14590. The number of seconds to wait for keyboard input before booting. Set to
  14591. 0 to boot immediately, and to -1 to wait indefinitely.
  14592. @item @code{theme} (default: @var{#f})
  14593. The bootloader theme object describing the theme to use. If no theme
  14594. is provided, some bootloaders might use a default theme, that's true
  14595. for GRUB.
  14596. @item @code{terminal-outputs} (default: @code{'gfxterm})
  14597. The output terminals used for the bootloader boot menu, as a list of
  14598. symbols. GRUB accepts the values: @code{console}, @code{serial},
  14599. @code{serial_@{0-3@}}, @code{gfxterm}, @code{vga_text},
  14600. @code{mda_text}, @code{morse}, and @code{pkmodem}. This field
  14601. corresponds to the GRUB variable GRUB_TERMINAL_OUTPUT (@pxref{Simple
  14602. configuration,,, grub,GNU GRUB manual}).
  14603. @item @code{terminal-inputs} (default: @code{'()})
  14604. The input terminals used for the bootloader boot menu, as a list of
  14605. symbols. For GRUB, the default is the native platform terminal as
  14606. determined at run-time. GRUB accepts the values: @code{console},
  14607. @code{serial}, @code{serial_@{0-3@}}, @code{at_keyboard}, and
  14608. @code{usb_keyboard}. This field corresponds to the GRUB variable
  14609. GRUB_TERMINAL_INPUT (@pxref{Simple configuration,,, grub,GNU GRUB
  14610. manual}).
  14611. @item @code{serial-unit} (default: @code{#f})
  14612. The serial unit used by the bootloader, as an integer from 0 to 3.
  14613. For GRUB, it is chosen at run-time; currently GRUB chooses 0, which
  14614. corresponds to COM1 (@pxref{Serial terminal,,, grub,GNU GRUB manual}).
  14615. @item @code{serial-speed} (default: @code{#f})
  14616. The speed of the serial interface, as an integer. For GRUB, the
  14617. default value is chosen at run-time; currently GRUB chooses
  14618. 9600@tie{}bps (@pxref{Serial terminal,,, grub,GNU GRUB manual}).
  14619. @end table
  14620. @end deftp
  14621. @cindex dual boot
  14622. @cindex boot menu
  14623. Should you want to list additional boot menu entries @i{via} the
  14624. @code{menu-entries} field above, you will need to create them with the
  14625. @code{menu-entry} form. For example, imagine you want to be able to
  14626. boot another distro (hard to imagine!), you can define a menu entry
  14627. along these lines:
  14628. @example
  14629. (menu-entry
  14630. (label "The Other Distro")
  14631. (linux "/boot/old/vmlinux-2.6.32")
  14632. (linux-arguments '("root=/dev/sda2"))
  14633. (initrd "/boot/old/initrd"))
  14634. @end example
  14635. Details below.
  14636. @deftp {Data Type} menu-entry
  14637. The type of an entry in the bootloader menu.
  14638. @table @asis
  14639. @item @code{label}
  14640. The label to show in the menu---e.g., @code{"GNU"}.
  14641. @item @code{linux}
  14642. The Linux kernel image to boot, for example:
  14643. @example
  14644. (file-append linux-libre "/bzImage")
  14645. @end example
  14646. For GRUB, it is also possible to specify a device explicitly in the
  14647. file path using GRUB's device naming convention (@pxref{Naming
  14648. convention,,, grub, GNU GRUB manual}), for example:
  14649. @example
  14650. "(hd0,msdos1)/boot/vmlinuz"
  14651. @end example
  14652. If the device is specified explicitly as above, then the @code{device}
  14653. field is ignored entirely.
  14654. @item @code{linux-arguments} (default: @code{()})
  14655. The list of extra Linux kernel command-line arguments---e.g.,
  14656. @code{("console=ttyS0")}.
  14657. @item @code{initrd}
  14658. A G-Expression or string denoting the file name of the initial RAM disk
  14659. to use (@pxref{G-Expressions}).
  14660. @item @code{device} (default: @code{#f})
  14661. The device where the kernel and initrd are to be found---i.e., for GRUB,
  14662. @dfn{root} for this menu entry (@pxref{root,,, grub, GNU GRUB manual}).
  14663. This may be a file system label (a string), a file system UUID (a
  14664. bytevector, @pxref{File Systems}), or @code{#f}, in which case
  14665. the bootloader will search the device containing the file specified by
  14666. the @code{linux} field (@pxref{search,,, grub, GNU GRUB manual}). It
  14667. must @emph{not} be an OS device name such as @file{/dev/sda1}.
  14668. @end table
  14669. @end deftp
  14670. @c FIXME: Write documentation once it's stable.
  14671. Fow now only GRUB has theme support. GRUB themes are created using
  14672. the @code{grub-theme} form, which is not documented yet.
  14673. @defvr {Scheme Variable} %default-theme
  14674. This is the default GRUB theme used by the operating system if no
  14675. @code{theme} field is specified in @code{bootloader-configuration}
  14676. record.
  14677. It comes with a fancy background image displaying the GNU and Guix
  14678. logos.
  14679. @end defvr
  14680. @node Invoking guix system
  14681. @subsection Invoking @code{guix system}
  14682. Once you have written an operating system declaration as seen in the
  14683. previous section, it can be @dfn{instantiated} using the @command{guix
  14684. system} command. The synopsis is:
  14685. @example
  14686. guix system @var{options}@dots{} @var{action} @var{file}
  14687. @end example
  14688. @var{file} must be the name of a file containing an
  14689. @code{operating-system} declaration. @var{action} specifies how the
  14690. operating system is instantiated. Currently the following values are
  14691. supported:
  14692. @table @code
  14693. @item search
  14694. Display available service type definitions that match the given regular
  14695. expressions, sorted by relevance:
  14696. @example
  14697. $ guix system search console font
  14698. name: console-fonts
  14699. location: gnu/services/base.scm:729:2
  14700. extends: shepherd-root
  14701. description: Install the given fonts on the specified ttys (fonts are
  14702. + per virtual console on GNU/Linux). The value of this service is a list
  14703. + of tty/font pairs like:
  14704. +
  14705. + '(("tty1" . "LatGrkCyr-8x16"))
  14706. relevance: 20
  14707. name: mingetty
  14708. location: gnu/services/base.scm:1048:2
  14709. extends: shepherd-root
  14710. description: Provide console login using the `mingetty' program.
  14711. relevance: 2
  14712. name: login
  14713. location: gnu/services/base.scm:775:2
  14714. extends: pam
  14715. description: Provide a console log-in service as specified by its
  14716. + configuration value, a `login-configuration' object.
  14717. relevance: 2
  14718. @dots{}
  14719. @end example
  14720. As for @command{guix package --search}, the result is written in
  14721. @code{recutils} format, which makes it easy to filter the output
  14722. (@pxref{Top, GNU recutils databases,, recutils, GNU recutils manual}).
  14723. @item reconfigure
  14724. Build the operating system described in @var{file}, activate it, and
  14725. switch to it@footnote{This action (and the related actions
  14726. @code{switch-generation} and @code{roll-back}) are usable only on
  14727. systems already running GuixSD.}.
  14728. This effects all the configuration specified in @var{file}: user
  14729. accounts, system services, global package list, setuid programs, etc.
  14730. The command starts system services specified in @var{file} that are not
  14731. currently running; if a service is currently running, it does not
  14732. attempt to upgrade it since this would not be possible without stopping it
  14733. first.
  14734. This command creates a new generation whose number is one greater than
  14735. the current generation (as reported by @command{guix system
  14736. list-generations}). If that generation already exists, it will be
  14737. overwritten. This behavior mirrors that of @command{guix package}
  14738. (@pxref{Invoking guix package}).
  14739. It also adds a bootloader menu entry for the new OS configuration,
  14740. ---unless @option{--no-bootloader} is passed. For GRUB, it moves
  14741. entries for older configurations to a submenu, allowing you to choose
  14742. an older system generation at boot time should you need it.
  14743. @quotation Note
  14744. @c The paragraph below refers to the problem discussed at
  14745. @c <http://lists.gnu.org/archive/html/guix-devel/2014-08/msg00057.html>.
  14746. It is highly recommended to run @command{guix pull} once before you run
  14747. @command{guix system reconfigure} for the first time (@pxref{Invoking
  14748. guix pull}). Failing to do that you would see an older version of Guix
  14749. once @command{reconfigure} has completed.
  14750. @end quotation
  14751. @item switch-generation
  14752. @cindex generations
  14753. Switch to an existing system generation. This action atomically
  14754. switches the system profile to the specified system generation. It
  14755. also rearranges the system's existing bootloader menu entries. It
  14756. makes the menu entry for the specified system generation the default,
  14757. and it moves the entries for the other generatiors to a submenu, if
  14758. supported by the bootloader being used. The next time the system
  14759. boots, it will use the specified system generation.
  14760. The bootloader itself is not being reinstalled when using this
  14761. command. Thus, the installed bootloader is used with an updated
  14762. configuration file.
  14763. The target generation can be specified explicitly by its generation
  14764. number. For example, the following invocation would switch to system
  14765. generation 7:
  14766. @example
  14767. guix system switch-generation 7
  14768. @end example
  14769. The target generation can also be specified relative to the current
  14770. generation with the form @code{+N} or @code{-N}, where @code{+3} means
  14771. ``3 generations ahead of the current generation,'' and @code{-1} means
  14772. ``1 generation prior to the current generation.'' When specifying a
  14773. negative value such as @code{-1}, you must precede it with @code{--} to
  14774. prevent it from being parsed as an option. For example:
  14775. @example
  14776. guix system switch-generation -- -1
  14777. @end example
  14778. Currently, the effect of invoking this action is @emph{only} to switch
  14779. the system profile to an existing generation and rearrange the
  14780. bootloader menu entries. To actually start using the target system
  14781. generation, you must reboot after running this action. In the future,
  14782. it will be updated to do the same things as @command{reconfigure},
  14783. like activating and deactivating services.
  14784. This action will fail if the specified generation does not exist.
  14785. @item roll-back
  14786. @cindex rolling back
  14787. Switch to the preceding system generation. The next time the system
  14788. boots, it will use the preceding system generation. This is the inverse
  14789. of @command{reconfigure}, and it is exactly the same as invoking
  14790. @command{switch-generation} with an argument of @code{-1}.
  14791. Currently, as with @command{switch-generation}, you must reboot after
  14792. running this action to actually start using the preceding system
  14793. generation.
  14794. @item build
  14795. Build the derivation of the operating system, which includes all the
  14796. configuration files and programs needed to boot and run the system.
  14797. This action does not actually install anything.
  14798. @item init
  14799. Populate the given directory with all the files necessary to run the
  14800. operating system specified in @var{file}. This is useful for first-time
  14801. installations of GuixSD. For instance:
  14802. @example
  14803. guix system init my-os-config.scm /mnt
  14804. @end example
  14805. copies to @file{/mnt} all the store items required by the configuration
  14806. specified in @file{my-os-config.scm}. This includes configuration
  14807. files, packages, and so on. It also creates other essential files
  14808. needed for the system to operate correctly---e.g., the @file{/etc},
  14809. @file{/var}, and @file{/run} directories, and the @file{/bin/sh} file.
  14810. This command also installs bootloader on the target specified in
  14811. @file{my-os-config}, unless the @option{--no-bootloader} option was
  14812. passed.
  14813. @item vm
  14814. @cindex virtual machine
  14815. @cindex VM
  14816. @anchor{guix system vm}
  14817. Build a virtual machine that contains the operating system declared in
  14818. @var{file}, and return a script to run that virtual machine (VM).
  14819. Arguments given to the script are passed to QEMU as in the example
  14820. below, which enables networking and requests 1@tie{}GiB of RAM for the
  14821. emulated machine:
  14822. @example
  14823. $ /gnu/store/@dots{}-run-vm.sh -m 1024 -net user
  14824. @end example
  14825. The VM shares its store with the host system.
  14826. Additional file systems can be shared between the host and the VM using
  14827. the @code{--share} and @code{--expose} command-line options: the former
  14828. specifies a directory to be shared with write access, while the latter
  14829. provides read-only access to the shared directory.
  14830. The example below creates a VM in which the user's home directory is
  14831. accessible read-only, and where the @file{/exchange} directory is a
  14832. read-write mapping of @file{$HOME/tmp} on the host:
  14833. @example
  14834. guix system vm my-config.scm \
  14835. --expose=$HOME --share=$HOME/tmp=/exchange
  14836. @end example
  14837. On GNU/Linux, the default is to boot directly to the kernel; this has
  14838. the advantage of requiring only a very tiny root disk image since the
  14839. store of the host can then be mounted.
  14840. The @code{--full-boot} option forces a complete boot sequence, starting
  14841. with the bootloader. This requires more disk space since a root image
  14842. containing at least the kernel, initrd, and bootloader data files must
  14843. be created. The @code{--image-size} option can be used to specify the
  14844. size of the image.
  14845. @item vm-image
  14846. @itemx disk-image
  14847. Return a virtual machine or disk image of the operating system declared
  14848. in @var{file} that stands alone. By default, @command{guix system}
  14849. estimates the size of the image needed to store the system, but you can
  14850. use the @option{--image-size} option to specify a value.
  14851. You can specify the root file system type by using the
  14852. @option{--file-system-type} option. It defaults to @code{ext4}.
  14853. When using @code{vm-image}, the returned image is in qcow2 format, which
  14854. the QEMU emulator can efficiently use. @xref{Running GuixSD in a VM},
  14855. for more information on how to run the image in a virtual machine.
  14856. When using @code{disk-image}, a raw disk image is produced; it can be
  14857. copied as is to a USB stick, for instance. Assuming @code{/dev/sdc} is
  14858. the device corresponding to a USB stick, one can copy the image to it
  14859. using the following command:
  14860. @example
  14861. # dd if=$(guix system disk-image my-os.scm) of=/dev/sdc
  14862. @end example
  14863. @item container
  14864. Return a script to run the operating system declared in @var{file}
  14865. within a container. Containers are a set of lightweight isolation
  14866. mechanisms provided by the kernel Linux-libre. Containers are
  14867. substantially less resource-demanding than full virtual machines since
  14868. the kernel, shared objects, and other resources can be shared with the
  14869. host system; this also means they provide thinner isolation.
  14870. Currently, the script must be run as root in order to support more than
  14871. a single user and group. The container shares its store with the host
  14872. system.
  14873. As with the @code{vm} action (@pxref{guix system vm}), additional file
  14874. systems to be shared between the host and container can be specified
  14875. using the @option{--share} and @option{--expose} options:
  14876. @example
  14877. guix system container my-config.scm \
  14878. --expose=$HOME --share=$HOME/tmp=/exchange
  14879. @end example
  14880. @quotation Note
  14881. This option requires Linux-libre 3.19 or newer.
  14882. @end quotation
  14883. @end table
  14884. @var{options} can contain any of the common build options (@pxref{Common
  14885. Build Options}). In addition, @var{options} can contain one of the
  14886. following:
  14887. @table @option
  14888. @item --expression=@var{expr}
  14889. @itemx -e @var{expr}
  14890. Consider the operating-system @var{expr} evaluates to.
  14891. This is an alternative to specifying a file which evaluates to an
  14892. operating system.
  14893. This is used to generate the GuixSD installer @pxref{Building the
  14894. Installation Image}).
  14895. @item --system=@var{system}
  14896. @itemx -s @var{system}
  14897. Attempt to build for @var{system} instead of the host system type.
  14898. This works as per @command{guix build} (@pxref{Invoking guix build}).
  14899. @item --derivation
  14900. @itemx -d
  14901. Return the derivation file name of the given operating system without
  14902. building anything.
  14903. @item --file-system-type=@var{type}
  14904. @itemx -t @var{type}
  14905. For the @code{disk-image} action, create a file system of the given
  14906. @var{type} on the image.
  14907. When this option is omitted, @command{guix system} uses @code{ext4}.
  14908. @cindex ISO-9660 format
  14909. @cindex CD image format
  14910. @cindex DVD image format
  14911. @code{--file-system-type=iso9660} produces an ISO-9660 image, suitable
  14912. for burning on CDs and DVDs.
  14913. @item --image-size=@var{size}
  14914. For the @code{vm-image} and @code{disk-image} actions, create an image
  14915. of the given @var{size}. @var{size} may be a number of bytes, or it may
  14916. include a unit as a suffix (@pxref{Block size, size specifications,,
  14917. coreutils, GNU Coreutils}).
  14918. When this option is omitted, @command{guix system} computes an estimate
  14919. of the image size as a function of the size of the system declared in
  14920. @var{file}.
  14921. @item --root=@var{file}
  14922. @itemx -r @var{file}
  14923. Make @var{file} a symlink to the result, and register it as a garbage
  14924. collector root.
  14925. @item --on-error=@var{strategy}
  14926. Apply @var{strategy} when an error occurs when reading @var{file}.
  14927. @var{strategy} may be one of the following:
  14928. @table @code
  14929. @item nothing-special
  14930. Report the error concisely and exit. This is the default strategy.
  14931. @item backtrace
  14932. Likewise, but also display a backtrace.
  14933. @item debug
  14934. Report the error and enter Guile's debugger. From there, you can run
  14935. commands such as @code{,bt} to get a backtrace, @code{,locals} to
  14936. display local variable values, and more generally inspect the state of the
  14937. program. @xref{Debug Commands,,, guile, GNU Guile Reference Manual}, for
  14938. a list of available debugging commands.
  14939. @end table
  14940. @end table
  14941. @quotation Note
  14942. All the actions above, except @code{build} and @code{init},
  14943. can use KVM support in the Linux-libre kernel. Specifically, if the
  14944. machine has hardware virtualization support, the corresponding
  14945. KVM kernel module should be loaded, and the @file{/dev/kvm} device node
  14946. must exist and be readable and writable by the user and by the
  14947. build users of the daemon (@pxref{Build Environment Setup}).
  14948. @end quotation
  14949. Once you have built, configured, re-configured, and re-re-configured
  14950. your GuixSD installation, you may find it useful to list the operating
  14951. system generations available on disk---and that you can choose from the
  14952. bootloader boot menu:
  14953. @table @code
  14954. @item list-generations
  14955. List a summary of each generation of the operating system available on
  14956. disk, in a human-readable way. This is similar to the
  14957. @option{--list-generations} option of @command{guix package}
  14958. (@pxref{Invoking guix package}).
  14959. Optionally, one can specify a pattern, with the same syntax that is used
  14960. in @command{guix package --list-generations}, to restrict the list of
  14961. generations displayed. For instance, the following command displays
  14962. generations that are up to 10 days old:
  14963. @example
  14964. $ guix system list-generations 10d
  14965. @end example
  14966. @end table
  14967. The @command{guix system} command has even more to offer! The following
  14968. sub-commands allow you to visualize how your system services relate to
  14969. each other:
  14970. @anchor{system-extension-graph}
  14971. @table @code
  14972. @item extension-graph
  14973. Emit in Dot/Graphviz format to standard output the @dfn{service
  14974. extension graph} of the operating system defined in @var{file}
  14975. (@pxref{Service Composition}, for more information on service
  14976. extensions.)
  14977. The command:
  14978. @example
  14979. $ guix system extension-graph @var{file} | dot -Tpdf > services.pdf
  14980. @end example
  14981. produces a PDF file showing the extension relations among services.
  14982. @anchor{system-shepherd-graph}
  14983. @item shepherd-graph
  14984. Emit in Dot/Graphviz format to standard output the @dfn{dependency
  14985. graph} of shepherd services of the operating system defined in
  14986. @var{file}. @xref{Shepherd Services}, for more information and for an
  14987. example graph.
  14988. @end table
  14989. @node Running GuixSD in a VM
  14990. @subsection Running GuixSD in a Virtual Machine
  14991. @cindex virtual machine
  14992. To run GuixSD in a virtual machine (VM), one can either use the
  14993. pre-built GuixSD VM image distributed at
  14994. @indicateurl{ftp://alpha.gnu.org/guix/guixsd-vm-image-@value{VERSION}.@var{system}.tar.xz}
  14995. , or build their own virtual machine image using @command{guix system
  14996. vm-image} (@pxref{Invoking guix system}). The returned image is in
  14997. qcow2 format, which the @uref{http://qemu.org/, QEMU emulator} can
  14998. efficiently use.
  14999. @cindex QEMU
  15000. If you built your own image, you must copy it out of the store
  15001. (@pxref{The Store}) and give yourself permission to write to the copy
  15002. before you can use it. When invoking QEMU, you must choose a system
  15003. emulator that is suitable for your hardware platform. Here is a minimal
  15004. QEMU invocation that will boot the result of @command{guix system
  15005. vm-image} on x86_64 hardware:
  15006. @example
  15007. $ qemu-system-x86_64 \
  15008. -net user -net nic,model=virtio \
  15009. -enable-kvm -m 256 /tmp/qemu-image
  15010. @end example
  15011. Here is what each of these options means:
  15012. @table @code
  15013. @item qemu-system-x86_64
  15014. This specifies the hardware platform to emulate. This should match the
  15015. host.
  15016. @item -net user
  15017. Enable the unprivileged user-mode network stack. The guest OS can
  15018. access the host but not vice versa. This is the simplest way to get the
  15019. guest OS online.
  15020. @item -net nic,model=virtio
  15021. You must create a network interface of a given model. If you do not
  15022. create a NIC, the boot will fail. Assuming your hardware platform is
  15023. x86_64, you can get a list of available NIC models by running
  15024. @command{qemu-system-x86_64 -net nic,model=help}.
  15025. @item -enable-kvm
  15026. If your system has hardware virtualization extensions, enabling the
  15027. virtual machine support (KVM) of the Linux kernel will make things run
  15028. faster.
  15029. @item -m 256
  15030. RAM available to the guest OS, in mebibytes. Defaults to 128@tie{}MiB,
  15031. which may be insufficient for some operations.
  15032. @item /tmp/qemu-image
  15033. The file name of the qcow2 image.
  15034. @end table
  15035. The default @command{run-vm.sh} script that is returned by an invocation of
  15036. @command{guix system vm} does not add a @command{-net user} flag by default.
  15037. To get network access from within the vm add the @code{(dhcp-client-service)}
  15038. to your system definition and start the VM using
  15039. @command{`guix system vm config.scm` -net user}. An important caveat of using
  15040. @command{-net user} for networking is that @command{ping} will not work, because
  15041. it uses the ICMP protocol. You'll have to use a different command to check for
  15042. network connectivity, for example @command{guix download}.
  15043. @subsubsection Connecting Through SSH
  15044. @cindex SSH
  15045. @cindex SSH server
  15046. To enable SSH inside a VM you need to add a SSH server like @code{(dropbear-service)}
  15047. or @code{(lsh-service)} to your VM. The @code{(lsh-service}) doesn't currently
  15048. boot unsupervised. It requires you to type some characters to initialize the
  15049. randomness generator. In addition you need to forward the SSH port, 22 by
  15050. default, to the host. You can do this with
  15051. @example
  15052. `guix system vm config.scm` -net user,hostfwd=tcp::10022-:22
  15053. @end example
  15054. To connect to the VM you can run
  15055. @example
  15056. ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 10022
  15057. @end example
  15058. The @command{-p} tells @command{ssh} the port you want to connect to.
  15059. @command{-o UserKnownHostsFile=/dev/null} prevents @command{ssh} from complaining
  15060. every time you modify your @command{config.scm} file and the
  15061. @command{-o StrictHostKeyChecking=no} prevents you from having to allow a
  15062. connection to an unknown host every time you connect.
  15063. @subsubsection Using @command{virt-viewer} with Spice
  15064. As an alternative to the default @command{qemu} graphical client you can
  15065. use the @command{remote-viewer} from the @command{virt-viewer} package. To
  15066. connect pass the @command{-spice port=5930,disable-ticketing} flag to
  15067. @command{qemu}. See previous section for further information on how to do this.
  15068. Spice also allows you to do some nice stuff like share your clipboard with your
  15069. VM. To enable that you'll also have to pass the following flags to @command{qemu}:
  15070. @example
  15071. -device virtio-serial-pci,id=virtio-serial0,max_ports=16,bus=pci.0,addr=0x5
  15072. -chardev spicevmc,name=vdagent,id=vdagent
  15073. -device virtserialport,nr=1,bus=virtio-serial0.0,chardev=vdagent,
  15074. name=com.redhat.spice.0
  15075. @end example
  15076. You'll also need to add the @pxref{Miscellaneous Services, Spice service}.
  15077. @node Defining Services
  15078. @subsection Defining Services
  15079. The previous sections show the available services and how one can combine
  15080. them in an @code{operating-system} declaration. But how do we define
  15081. them in the first place? And what is a service anyway?
  15082. @menu
  15083. * Service Composition:: The model for composing services.
  15084. * Service Types and Services:: Types and services.
  15085. * Service Reference:: API reference.
  15086. * Shepherd Services:: A particular type of service.
  15087. @end menu
  15088. @node Service Composition
  15089. @subsubsection Service Composition
  15090. @cindex services
  15091. @cindex daemons
  15092. Here we define a @dfn{service} as, broadly, something that extends the
  15093. functionality of the operating system. Often a service is a process---a
  15094. @dfn{daemon}---started when the system boots: a secure shell server, a
  15095. Web server, the Guix build daemon, etc. Sometimes a service is a daemon
  15096. whose execution can be triggered by another daemon---e.g., an FTP server
  15097. started by @command{inetd} or a D-Bus service activated by
  15098. @command{dbus-daemon}. Occasionally, a service does not map to a
  15099. daemon. For instance, the ``account'' service collects user accounts
  15100. and makes sure they exist when the system runs; the ``udev'' service
  15101. collects device management rules and makes them available to the eudev
  15102. daemon; the @file{/etc} service populates the @file{/etc} directory
  15103. of the system.
  15104. @cindex service extensions
  15105. GuixSD services are connected by @dfn{extensions}. For instance, the
  15106. secure shell service @emph{extends} the Shepherd---the GuixSD
  15107. initialization system, running as PID@tie{}1---by giving it the command
  15108. lines to start and stop the secure shell daemon (@pxref{Networking
  15109. Services, @code{lsh-service}}); the UPower service extends the D-Bus
  15110. service by passing it its @file{.service} specification, and extends the
  15111. udev service by passing it device management rules (@pxref{Desktop
  15112. Services, @code{upower-service}}); the Guix daemon service extends the
  15113. Shepherd by passing it the command lines to start and stop the daemon,
  15114. and extends the account service by passing it a list of required build
  15115. user accounts (@pxref{Base Services}).
  15116. All in all, services and their ``extends'' relations form a directed
  15117. acyclic graph (DAG). If we represent services as boxes and extensions
  15118. as arrows, a typical system might provide something like this:
  15119. @image{images/service-graph,,5in,Typical service extension graph.}
  15120. @cindex system service
  15121. At the bottom, we see the @dfn{system service}, which produces the
  15122. directory containing everything to run and boot the system, as returned
  15123. by the @command{guix system build} command. @xref{Service Reference},
  15124. to learn about the other service types shown here.
  15125. @xref{system-extension-graph, the @command{guix system extension-graph}
  15126. command}, for information on how to generate this representation for a
  15127. particular operating system definition.
  15128. @cindex service types
  15129. Technically, developers can define @dfn{service types} to express these
  15130. relations. There can be any number of services of a given type on the
  15131. system---for instance, a system running two instances of the GNU secure
  15132. shell server (lsh) has two instances of @var{lsh-service-type}, with
  15133. different parameters.
  15134. The following section describes the programming interface for service
  15135. types and services.
  15136. @node Service Types and Services
  15137. @subsubsection Service Types and Services
  15138. A @dfn{service type} is a node in the DAG described above. Let us start
  15139. with a simple example, the service type for the Guix build daemon
  15140. (@pxref{Invoking guix-daemon}):
  15141. @example
  15142. (define guix-service-type
  15143. (service-type
  15144. (name 'guix)
  15145. (extensions
  15146. (list (service-extension shepherd-root-service-type guix-shepherd-service)
  15147. (service-extension account-service-type guix-accounts)
  15148. (service-extension activation-service-type guix-activation)))
  15149. (default-value (guix-configuration))))
  15150. @end example
  15151. @noindent
  15152. It defines three things:
  15153. @enumerate
  15154. @item
  15155. A name, whose sole purpose is to make inspection and debugging easier.
  15156. @item
  15157. A list of @dfn{service extensions}, where each extension designates the
  15158. target service type and a procedure that, given the parameters of the
  15159. service, returns a list of objects to extend the service of that type.
  15160. Every service type has at least one service extension. The only
  15161. exception is the @dfn{boot service type}, which is the ultimate service.
  15162. @item
  15163. Optionally, a default value for instances of this type.
  15164. @end enumerate
  15165. In this example, @var{guix-service-type} extends three services:
  15166. @table @var
  15167. @item shepherd-root-service-type
  15168. The @var{guix-shepherd-service} procedure defines how the Shepherd
  15169. service is extended. Namely, it returns a @code{<shepherd-service>}
  15170. object that defines how @command{guix-daemon} is started and stopped
  15171. (@pxref{Shepherd Services}).
  15172. @item account-service-type
  15173. This extension for this service is computed by @var{guix-accounts},
  15174. which returns a list of @code{user-group} and @code{user-account}
  15175. objects representing the build user accounts (@pxref{Invoking
  15176. guix-daemon}).
  15177. @item activation-service-type
  15178. Here @var{guix-activation} is a procedure that returns a gexp, which is
  15179. a code snippet to run at ``activation time''---e.g., when the service is
  15180. booted.
  15181. @end table
  15182. A service of this type is instantiated like this:
  15183. @example
  15184. (service guix-service-type
  15185. (guix-configuration
  15186. (build-accounts 5)
  15187. (use-substitutes? #f)))
  15188. @end example
  15189. The second argument to the @code{service} form is a value representing
  15190. the parameters of this specific service instance.
  15191. @xref{guix-configuration-type, @code{guix-configuration}}, for
  15192. information about the @code{guix-configuration} data type. When the
  15193. value is omitted, the default value specified by
  15194. @code{guix-service-type} is used:
  15195. @example
  15196. (service guix-service-type)
  15197. @end example
  15198. @var{guix-service-type} is quite simple because it extends other
  15199. services but is not extensible itself.
  15200. @c @subsubsubsection Extensible Service Types
  15201. The service type for an @emph{extensible} service looks like this:
  15202. @example
  15203. (define udev-service-type
  15204. (service-type (name 'udev)
  15205. (extensions
  15206. (list (service-extension shepherd-root-service-type
  15207. udev-shepherd-service)))
  15208. (compose concatenate) ;concatenate the list of rules
  15209. (extend (lambda (config rules)
  15210. (match config
  15211. (($ <udev-configuration> udev initial-rules)
  15212. (udev-configuration
  15213. (udev udev) ;the udev package to use
  15214. (rules (append initial-rules rules)))))))))
  15215. @end example
  15216. This is the service type for the
  15217. @uref{https://wiki.gentoo.org/wiki/Project:Eudev, eudev device
  15218. management daemon}. Compared to the previous example, in addition to an
  15219. extension of @var{shepherd-root-service-type}, we see two new fields:
  15220. @table @code
  15221. @item compose
  15222. This is the procedure to @dfn{compose} the list of extensions to
  15223. services of this type.
  15224. Services can extend the udev service by passing it lists of rules; we
  15225. compose those extensions simply by concatenating them.
  15226. @item extend
  15227. This procedure defines how the value of the service is @dfn{extended} with
  15228. the composition of the extensions.
  15229. Udev extensions are composed into a list of rules, but the udev service
  15230. value is itself a @code{<udev-configuration>} record. So here, we
  15231. extend that record by appending the list of rules it contains to the
  15232. list of contributed rules.
  15233. @item description
  15234. This is a string giving an overview of the service type. The string can
  15235. contain Texinfo markup (@pxref{Overview,,, texinfo, GNU Texinfo}). The
  15236. @command{guix system search} command searches these strings and displays
  15237. them (@pxref{Invoking guix system}).
  15238. @end table
  15239. There can be only one instance of an extensible service type such as
  15240. @var{udev-service-type}. If there were more, the
  15241. @code{service-extension} specifications would be ambiguous.
  15242. Still here? The next section provides a reference of the programming
  15243. interface for services.
  15244. @node Service Reference
  15245. @subsubsection Service Reference
  15246. We have seen an overview of service types (@pxref{Service Types and
  15247. Services}). This section provides a reference on how to manipulate
  15248. services and service types. This interface is provided by the
  15249. @code{(gnu services)} module.
  15250. @deffn {Scheme Procedure} service @var{type} [@var{value}]
  15251. Return a new service of @var{type}, a @code{<service-type>} object (see
  15252. below.) @var{value} can be any object; it represents the parameters of
  15253. this particular service instance.
  15254. When @var{value} is omitted, the default value specified by @var{type}
  15255. is used; if @var{type} does not specify a default value, an error is
  15256. raised.
  15257. For instance, this:
  15258. @example
  15259. (service openssh-service-type)
  15260. @end example
  15261. @noindent
  15262. is equivalent to this:
  15263. @example
  15264. (service openssh-service-type
  15265. (openssh-configuration))
  15266. @end example
  15267. In both cases the result is an instance of @code{openssh-service-type}
  15268. with the default configuration.
  15269. @end deffn
  15270. @deffn {Scheme Procedure} service? @var{obj}
  15271. Return true if @var{obj} is a service.
  15272. @end deffn
  15273. @deffn {Scheme Procedure} service-kind @var{service}
  15274. Return the type of @var{service}---i.e., a @code{<service-type>} object.
  15275. @end deffn
  15276. @deffn {Scheme Procedure} service-value @var{service}
  15277. Return the value associated with @var{service}. It represents its
  15278. parameters.
  15279. @end deffn
  15280. Here is an example of how a service is created and manipulated:
  15281. @example
  15282. (define s
  15283. (service nginx-service-type
  15284. (nginx-configuration
  15285. (nginx nginx)
  15286. (log-directory log-directory)
  15287. (run-directory run-directory)
  15288. (file config-file))))
  15289. (service? s)
  15290. @result{} #t
  15291. (eq? (service-kind s) nginx-service-type)
  15292. @result{} #t
  15293. @end example
  15294. The @code{modify-services} form provides a handy way to change the
  15295. parameters of some of the services of a list such as
  15296. @var{%base-services} (@pxref{Base Services, @code{%base-services}}). It
  15297. evaluates to a list of services. Of course, you could always use
  15298. standard list combinators such as @code{map} and @code{fold} to do that
  15299. (@pxref{SRFI-1, List Library,, guile, GNU Guile Reference Manual});
  15300. @code{modify-services} simply provides a more concise form for this
  15301. common pattern.
  15302. @deffn {Scheme Syntax} modify-services @var{services} @
  15303. (@var{type} @var{variable} => @var{body}) @dots{}
  15304. Modify the services listed in @var{services} according to the given
  15305. clauses. Each clause has the form:
  15306. @example
  15307. (@var{type} @var{variable} => @var{body})
  15308. @end example
  15309. where @var{type} is a service type---e.g.,
  15310. @code{guix-service-type}---and @var{variable} is an identifier that is
  15311. bound within the @var{body} to the service parameters---e.g., a
  15312. @code{guix-configuration} instance---of the original service of that
  15313. @var{type}.
  15314. The @var{body} should evaluate to the new service parameters, which will
  15315. be used to configure the new service. This new service will replace the
  15316. original in the resulting list. Because a service's service parameters
  15317. are created using @code{define-record-type*}, you can write a succinct
  15318. @var{body} that evaluates to the new service parameters by using the
  15319. @code{inherit} feature that @code{define-record-type*} provides.
  15320. @xref{Using the Configuration System}, for example usage.
  15321. @end deffn
  15322. Next comes the programming interface for service types. This is
  15323. something you want to know when writing new service definitions, but not
  15324. necessarily when simply looking for ways to customize your
  15325. @code{operating-system} declaration.
  15326. @deftp {Data Type} service-type
  15327. @cindex service type
  15328. This is the representation of a @dfn{service type} (@pxref{Service Types
  15329. and Services}).
  15330. @table @asis
  15331. @item @code{name}
  15332. This is a symbol, used only to simplify inspection and debugging.
  15333. @item @code{extensions}
  15334. A non-empty list of @code{<service-extension>} objects (see below).
  15335. @item @code{compose} (default: @code{#f})
  15336. If this is @code{#f}, then the service type denotes services that cannot
  15337. be extended---i.e., services that do not receive ``values'' from other
  15338. services.
  15339. Otherwise, it must be a one-argument procedure. The procedure is called
  15340. by @code{fold-services} and is passed a list of values collected from
  15341. extensions. It must return a value that is a valid parameter value for
  15342. the service instance.
  15343. @item @code{extend} (default: @code{#f})
  15344. If this is @code{#f}, services of this type cannot be extended.
  15345. Otherwise, it must be a two-argument procedure: @code{fold-services}
  15346. calls it, passing it the initial value of the service as the first argument
  15347. and the result of applying @code{compose} to the extension values as the
  15348. second argument.
  15349. @end table
  15350. @xref{Service Types and Services}, for examples.
  15351. @end deftp
  15352. @deffn {Scheme Procedure} service-extension @var{target-type} @
  15353. @var{compute}
  15354. Return a new extension for services of type @var{target-type}.
  15355. @var{compute} must be a one-argument procedure: @code{fold-services}
  15356. calls it, passing it the value associated with the service that provides
  15357. the extension; it must return a valid value for the target service.
  15358. @end deffn
  15359. @deffn {Scheme Procedure} service-extension? @var{obj}
  15360. Return true if @var{obj} is a service extension.
  15361. @end deffn
  15362. Occasionally, you might want to simply extend an existing service. This
  15363. involves creating a new service type and specifying the extension of
  15364. interest, which can be verbose; the @code{simple-service} procedure
  15365. provides a shorthand for this.
  15366. @deffn {Scheme Procedure} simple-service @var{name} @var{target} @var{value}
  15367. Return a service that extends @var{target} with @var{value}. This works
  15368. by creating a singleton service type @var{name}, of which the returned
  15369. service is an instance.
  15370. For example, this extends mcron (@pxref{Scheduled Job Execution}) with
  15371. an additional job:
  15372. @example
  15373. (simple-service 'my-mcron-job mcron-service-type
  15374. #~(job '(next-hour (3)) "guix gc -F 2G"))
  15375. @end example
  15376. @end deffn
  15377. At the core of the service abstraction lies the @code{fold-services}
  15378. procedure, which is responsible for ``compiling'' a list of services
  15379. down to a single directory that contains everything needed to boot and
  15380. run the system---the directory shown by the @command{guix system build}
  15381. command (@pxref{Invoking guix system}). In essence, it propagates
  15382. service extensions down the service graph, updating each node parameters
  15383. on the way, until it reaches the root node.
  15384. @deffn {Scheme Procedure} fold-services @var{services} @
  15385. [#:target-type @var{system-service-type}]
  15386. Fold @var{services} by propagating their extensions down to the root of
  15387. type @var{target-type}; return the root service adjusted accordingly.
  15388. @end deffn
  15389. Lastly, the @code{(gnu services)} module also defines several essential
  15390. service types, some of which are listed below.
  15391. @defvr {Scheme Variable} system-service-type
  15392. This is the root of the service graph. It produces the system directory
  15393. as returned by the @command{guix system build} command.
  15394. @end defvr
  15395. @defvr {Scheme Variable} boot-service-type
  15396. The type of the ``boot service'', which produces the @dfn{boot script}.
  15397. The boot script is what the initial RAM disk runs when booting.
  15398. @end defvr
  15399. @defvr {Scheme Variable} etc-service-type
  15400. The type of the @file{/etc} service. This service is used to create
  15401. files under @file{/etc} and can be extended by
  15402. passing it name/file tuples such as:
  15403. @example
  15404. (list `("issue" ,(plain-file "issue" "Welcome!\n")))
  15405. @end example
  15406. In this example, the effect would be to add an @file{/etc/issue} file
  15407. pointing to the given file.
  15408. @end defvr
  15409. @defvr {Scheme Variable} setuid-program-service-type
  15410. Type for the ``setuid-program service''. This service collects lists of
  15411. executable file names, passed as gexps, and adds them to the set of
  15412. setuid-root programs on the system (@pxref{Setuid Programs}).
  15413. @end defvr
  15414. @defvr {Scheme Variable} profile-service-type
  15415. Type of the service that populates the @dfn{system profile}---i.e., the
  15416. programs under @file{/run/current-system/profile}. Other services can
  15417. extend it by passing it lists of packages to add to the system profile.
  15418. @end defvr
  15419. @node Shepherd Services
  15420. @subsubsection Shepherd Services
  15421. @cindex shepherd services
  15422. @cindex PID 1
  15423. @cindex init system
  15424. The @code{(gnu services shepherd)} module provides a way to define
  15425. services managed by the GNU@tie{}Shepherd, which is the GuixSD
  15426. initialization system---the first process that is started when the
  15427. system boots, also known as PID@tie{}1
  15428. (@pxref{Introduction,,, shepherd, The GNU Shepherd Manual}).
  15429. Services in the Shepherd can depend on each other. For instance, the
  15430. SSH daemon may need to be started after the syslog daemon has been
  15431. started, which in turn can only happen once all the file systems have
  15432. been mounted. The simple operating system defined earlier (@pxref{Using
  15433. the Configuration System}) results in a service graph like this:
  15434. @image{images/shepherd-graph,,5in,Typical shepherd service graph.}
  15435. You can actually generate such a graph for any operating system
  15436. definition using the @command{guix system shepherd-graph} command
  15437. (@pxref{system-shepherd-graph, @command{guix system shepherd-graph}}).
  15438. The @var{%shepherd-root-service} is a service object representing
  15439. PID@tie{}1, of type @var{shepherd-root-service-type}; it can be extended
  15440. by passing it lists of @code{<shepherd-service>} objects.
  15441. @deftp {Data Type} shepherd-service
  15442. The data type representing a service managed by the Shepherd.
  15443. @table @asis
  15444. @item @code{provision}
  15445. This is a list of symbols denoting what the service provides.
  15446. These are the names that may be passed to @command{herd start},
  15447. @command{herd status}, and similar commands (@pxref{Invoking herd,,,
  15448. shepherd, The GNU Shepherd Manual}). @xref{Slots of services, the
  15449. @code{provides} slot,, shepherd, The GNU Shepherd Manual}, for details.
  15450. @item @code{requirements} (default: @code{'()})
  15451. List of symbols denoting the Shepherd services this one depends on.
  15452. @item @code{respawn?} (default: @code{#t})
  15453. Whether to restart the service when it stops, for instance when the
  15454. underlying process dies.
  15455. @item @code{start}
  15456. @itemx @code{stop} (default: @code{#~(const #f)})
  15457. The @code{start} and @code{stop} fields refer to the Shepherd's
  15458. facilities to start and stop processes (@pxref{Service De- and
  15459. Constructors,,, shepherd, The GNU Shepherd Manual}). They are given as
  15460. G-expressions that get expanded in the Shepherd configuration file
  15461. (@pxref{G-Expressions}).
  15462. @item @code{documentation}
  15463. A documentation string, as shown when running:
  15464. @example
  15465. herd doc @var{service-name}
  15466. @end example
  15467. where @var{service-name} is one of the symbols in @var{provision}
  15468. (@pxref{Invoking herd,,, shepherd, The GNU Shepherd Manual}).
  15469. @item @code{modules} (default: @var{%default-modules})
  15470. This is the list of modules that must be in scope when @code{start} and
  15471. @code{stop} are evaluated.
  15472. @end table
  15473. @end deftp
  15474. @defvr {Scheme Variable} shepherd-root-service-type
  15475. The service type for the Shepherd ``root service''---i.e., PID@tie{}1.
  15476. This is the service type that extensions target when they want to create
  15477. shepherd services (@pxref{Service Types and Services}, for an example).
  15478. Each extension must pass a list of @code{<shepherd-service>}.
  15479. @end defvr
  15480. @defvr {Scheme Variable} %shepherd-root-service
  15481. This service represents PID@tie{}1.
  15482. @end defvr
  15483. @node Documentation
  15484. @section Documentation
  15485. @cindex documentation, searching for
  15486. @cindex searching for documentation
  15487. @cindex Info, documentation format
  15488. @cindex man pages
  15489. @cindex manual pages
  15490. In most cases packages installed with Guix come with documentation.
  15491. There are two main documentation formats: ``Info'', a browseable
  15492. hypertext format used for GNU software, and ``manual pages'' (or ``man
  15493. pages''), the linear documentation format traditionally found on Unix.
  15494. Info manuals are accessed with the @command{info} command or with Emacs,
  15495. and man pages are accessed using @command{man}.
  15496. You can look for documentation of software installed on your system by
  15497. keyword. For example, the following command searches for information
  15498. about ``TLS'' in Info manuals:
  15499. @example
  15500. $ info -k TLS
  15501. "(emacs)Network Security" -- STARTTLS
  15502. "(emacs)Network Security" -- TLS
  15503. "(gnutls)Core TLS API" -- gnutls_certificate_set_verify_flags
  15504. "(gnutls)Core TLS API" -- gnutls_certificate_set_verify_function
  15505. @dots{}
  15506. @end example
  15507. @noindent
  15508. The command below searches for the same keyword in man pages:
  15509. @example
  15510. $ man -k TLS
  15511. SSL (7) - OpenSSL SSL/TLS library
  15512. certtool (1) - GnuTLS certificate tool
  15513. @dots {}
  15514. @end example
  15515. These searches are purely local to your computer so you have the
  15516. guarantee that documentation you find corresponds to what you have
  15517. actually installed, you can access it off-line, and your privacy is
  15518. respected.
  15519. Once you have these results, you can view the relevant documentation by
  15520. running, say:
  15521. @example
  15522. $ info "(gnutls)Core TLS API"
  15523. @end example
  15524. @noindent
  15525. or:
  15526. @example
  15527. $ man certtool
  15528. @end example
  15529. Info manuals contain sections and indices as well as hyperlinks like
  15530. those found in Web pages. The @command{info} reader (@pxref{Top, Info
  15531. reader,, info-stnd, Stand-alone GNU Info}) and its Emacs counterpart
  15532. (@pxref{Misc Help,,, emacs, The GNU Emacs Manual}) provide intuitive key
  15533. bindings to navigate manuals. @xref{Getting Started,,, info, Info: An
  15534. Introduction}, for an introduction to Info navigation.
  15535. @node Installing Debugging Files
  15536. @section Installing Debugging Files
  15537. @cindex debugging files
  15538. Program binaries, as produced by the GCC compilers for instance, are
  15539. typically written in the ELF format, with a section containing
  15540. @dfn{debugging information}. Debugging information is what allows the
  15541. debugger, GDB, to map binary code to source code; it is required to
  15542. debug a compiled program in good conditions.
  15543. The problem with debugging information is that is takes up a fair amount
  15544. of disk space. For example, debugging information for the GNU C Library
  15545. weighs in at more than 60 MiB. Thus, as a user, keeping all the
  15546. debugging info of all the installed programs is usually not an option.
  15547. Yet, space savings should not come at the cost of an impediment to
  15548. debugging---especially in the GNU system, which should make it easier
  15549. for users to exert their computing freedom (@pxref{GNU Distribution}).
  15550. Thankfully, the GNU Binary Utilities (Binutils) and GDB provide a
  15551. mechanism that allows users to get the best of both worlds: debugging
  15552. information can be stripped from the binaries and stored in separate
  15553. files. GDB is then able to load debugging information from those files,
  15554. when they are available (@pxref{Separate Debug Files,,, gdb, Debugging
  15555. with GDB}).
  15556. The GNU distribution takes advantage of this by storing debugging
  15557. information in the @code{lib/debug} sub-directory of a separate package
  15558. output unimaginatively called @code{debug} (@pxref{Packages with
  15559. Multiple Outputs}). Users can choose to install the @code{debug} output
  15560. of a package when they need it. For instance, the following command
  15561. installs the debugging information for the GNU C Library and for GNU
  15562. Guile:
  15563. @example
  15564. guix package -i glibc:debug guile:debug
  15565. @end example
  15566. GDB must then be told to look for debug files in the user's profile, by
  15567. setting the @code{debug-file-directory} variable (consider setting it
  15568. from the @file{~/.gdbinit} file, @pxref{Startup,,, gdb, Debugging with
  15569. GDB}):
  15570. @example
  15571. (gdb) set debug-file-directory ~/.guix-profile/lib/debug
  15572. @end example
  15573. From there on, GDB will pick up debugging information from the
  15574. @code{.debug} files under @file{~/.guix-profile/lib/debug}.
  15575. In addition, you will most likely want GDB to be able to show the source
  15576. code being debugged. To do that, you will have to unpack the source
  15577. code of the package of interest (obtained with @code{guix build
  15578. --source}, @pxref{Invoking guix build}), and to point GDB to that source
  15579. directory using the @code{directory} command (@pxref{Source Path,
  15580. @code{directory},, gdb, Debugging with GDB}).
  15581. @c XXX: keep me up-to-date
  15582. The @code{debug} output mechanism in Guix is implemented by the
  15583. @code{gnu-build-system} (@pxref{Build Systems}). Currently, it is
  15584. opt-in---debugging information is available only for the packages
  15585. with definitions explicitly declaring a @code{debug} output. This may be
  15586. changed to opt-out in the future if our build farm servers can handle
  15587. the load. To check whether a package has a @code{debug} output, use
  15588. @command{guix package --list-available} (@pxref{Invoking guix package}).
  15589. @node Security Updates
  15590. @section Security Updates
  15591. @cindex security updates
  15592. @cindex security vulnerabilities
  15593. Occasionally, important security vulnerabilities are discovered in software
  15594. packages and must be patched. Guix developers try hard to keep track of
  15595. known vulnerabilities and to apply fixes as soon as possible in the
  15596. @code{master} branch of Guix (we do not yet provide a ``stable'' branch
  15597. containing only security updates.) The @command{guix lint} tool helps
  15598. developers find out about vulnerable versions of software packages in the
  15599. distribution:
  15600. @smallexample
  15601. $ guix lint -c cve
  15602. gnu/packages/base.scm:652:2: glibc@@2.21: probably vulnerable to CVE-2015-1781, CVE-2015-7547
  15603. gnu/packages/gcc.scm:334:2: gcc@@4.9.3: probably vulnerable to CVE-2015-5276
  15604. gnu/packages/image.scm:312:2: openjpeg@@2.1.0: probably vulnerable to CVE-2016-1923, CVE-2016-1924
  15605. @dots{}
  15606. @end smallexample
  15607. @xref{Invoking guix lint}, for more information.
  15608. @quotation Note
  15609. As of version @value{VERSION}, the feature described below is considered
  15610. ``beta''.
  15611. @end quotation
  15612. Guix follows a functional
  15613. package management discipline (@pxref{Introduction}), which implies
  15614. that, when a package is changed, @emph{every package that depends on it}
  15615. must be rebuilt. This can significantly slow down the deployment of
  15616. fixes in core packages such as libc or Bash, since basically the whole
  15617. distribution would need to be rebuilt. Using pre-built binaries helps
  15618. (@pxref{Substitutes}), but deployment may still take more time than
  15619. desired.
  15620. @cindex grafts
  15621. To address this, Guix implements @dfn{grafts}, a mechanism that allows
  15622. for fast deployment of critical updates without the costs associated
  15623. with a whole-distribution rebuild. The idea is to rebuild only the
  15624. package that needs to be patched, and then to ``graft'' it onto packages
  15625. explicitly installed by the user and that were previously referring to
  15626. the original package. The cost of grafting is typically very low, and
  15627. order of magnitudes lower than a full rebuild of the dependency chain.
  15628. @cindex replacements of packages, for grafts
  15629. For instance, suppose a security update needs to be applied to Bash.
  15630. Guix developers will provide a package definition for the ``fixed''
  15631. Bash, say @var{bash-fixed}, in the usual way (@pxref{Defining
  15632. Packages}). Then, the original package definition is augmented with a
  15633. @code{replacement} field pointing to the package containing the bug fix:
  15634. @example
  15635. (define bash
  15636. (package
  15637. (name "bash")
  15638. ;; @dots{}
  15639. (replacement bash-fixed)))
  15640. @end example
  15641. From there on, any package depending directly or indirectly on Bash---as
  15642. reported by @command{guix gc --requisites} (@pxref{Invoking guix
  15643. gc})---that is installed is automatically ``rewritten'' to refer to
  15644. @var{bash-fixed} instead of @var{bash}. This grafting process takes
  15645. time proportional to the size of the package, usually less than a
  15646. minute for an ``average'' package on a recent machine. Grafting is
  15647. recursive: when an indirect dependency requires grafting, then grafting
  15648. ``propagates'' up to the package that the user is installing.
  15649. Currently, the length of the name and version of the graft and that of
  15650. the package it replaces (@var{bash-fixed} and @var{bash} in the example
  15651. above) must be equal. This restriction mostly comes from the fact that
  15652. grafting works by patching files, including binary files, directly.
  15653. Other restrictions may apply: for instance, when adding a graft to a
  15654. package providing a shared library, the original shared library and its
  15655. replacement must have the same @code{SONAME} and be binary-compatible.
  15656. The @option{--no-grafts} command-line option allows you to forcefully
  15657. avoid grafting (@pxref{Common Build Options, @option{--no-grafts}}).
  15658. Thus, the command:
  15659. @example
  15660. guix build bash --no-grafts
  15661. @end example
  15662. @noindent
  15663. returns the store file name of the original Bash, whereas:
  15664. @example
  15665. guix build bash
  15666. @end example
  15667. @noindent
  15668. returns the store file name of the ``fixed'', replacement Bash. This
  15669. allows you to distinguish between the two variants of Bash.
  15670. To verify which Bash your whole profile refers to, you can run
  15671. (@pxref{Invoking guix gc}):
  15672. @example
  15673. guix gc -R `readlink -f ~/.guix-profile` | grep bash
  15674. @end example
  15675. @noindent
  15676. @dots{} and compare the store file names that you get with those above.
  15677. Likewise for a complete GuixSD system generation:
  15678. @example
  15679. guix gc -R `guix system build my-config.scm` | grep bash
  15680. @end example
  15681. Lastly, to check which Bash running processes are using, you can use the
  15682. @command{lsof} command:
  15683. @example
  15684. lsof | grep /gnu/store/.*bash
  15685. @end example
  15686. @node Package Modules
  15687. @section Package Modules
  15688. From a programming viewpoint, the package definitions of the
  15689. GNU distribution are provided by Guile modules in the @code{(gnu packages
  15690. @dots{})} name space@footnote{Note that packages under the @code{(gnu
  15691. packages @dots{})} module name space are not necessarily ``GNU
  15692. packages''. This module naming scheme follows the usual Guile module
  15693. naming convention: @code{gnu} means that these modules are distributed
  15694. as part of the GNU system, and @code{packages} identifies modules that
  15695. define packages.} (@pxref{Modules, Guile modules,, guile, GNU Guile
  15696. Reference Manual}). For instance, the @code{(gnu packages emacs)}
  15697. module exports a variable named @code{emacs}, which is bound to a
  15698. @code{<package>} object (@pxref{Defining Packages}).
  15699. The @code{(gnu packages @dots{})} module name space is
  15700. automatically scanned for packages by the command-line tools. For
  15701. instance, when running @code{guix package -i emacs}, all the @code{(gnu
  15702. packages @dots{})} modules are scanned until one that exports a package
  15703. object whose name is @code{emacs} is found. This package search
  15704. facility is implemented in the @code{(gnu packages)} module.
  15705. @cindex customization, of packages
  15706. @cindex package module search path
  15707. Users can store package definitions in modules with different
  15708. names---e.g., @code{(my-packages emacs)}@footnote{Note that the file
  15709. name and module name must match. For instance, the @code{(my-packages
  15710. emacs)} module must be stored in a @file{my-packages/emacs.scm} file
  15711. relative to the load path specified with @option{--load-path} or
  15712. @code{GUIX_PACKAGE_PATH}. @xref{Modules and the File System,,,
  15713. guile, GNU Guile Reference Manual}, for details.}. These package definitions
  15714. will not be visible by default. Users can invoke commands such as
  15715. @command{guix package} and @command{guix build} with the
  15716. @code{-e} option so that they know where to find the package. Better
  15717. yet, they can use the
  15718. @code{-L} option of these commands to make those modules visible
  15719. (@pxref{Invoking guix build, @code{--load-path}}), or define the
  15720. @code{GUIX_PACKAGE_PATH} environment variable. This environment
  15721. variable makes it easy to extend or customize the distribution and is
  15722. honored by all the user interfaces.
  15723. @defvr {Environment Variable} GUIX_PACKAGE_PATH
  15724. This is a colon-separated list of directories to search for additional
  15725. package modules. Directories listed in this variable take precedence
  15726. over the own modules of the distribution.
  15727. @end defvr
  15728. The distribution is fully @dfn{bootstrapped} and @dfn{self-contained}:
  15729. each package is built based solely on other packages in the
  15730. distribution. The root of this dependency graph is a small set of
  15731. @dfn{bootstrap binaries}, provided by the @code{(gnu packages
  15732. bootstrap)} module. For more information on bootstrapping,
  15733. @pxref{Bootstrapping}.
  15734. @node Packaging Guidelines
  15735. @section Packaging Guidelines
  15736. @cindex packages, creating
  15737. The GNU distribution is nascent and may well lack some of your favorite
  15738. packages. This section describes how you can help make the distribution
  15739. grow. @xref{Contributing}, for additional information on how you can
  15740. help.
  15741. Free software packages are usually distributed in the form of
  15742. @dfn{source code tarballs}---typically @file{tar.gz} files that contain
  15743. all the source files. Adding a package to the distribution means
  15744. essentially two things: adding a @dfn{recipe} that describes how to
  15745. build the package, including a list of other packages required to build
  15746. it, and adding @dfn{package metadata} along with that recipe, such as a
  15747. description and licensing information.
  15748. In Guix all this information is embodied in @dfn{package definitions}.
  15749. Package definitions provide a high-level view of the package. They are
  15750. written using the syntax of the Scheme programming language; in fact,
  15751. for each package we define a variable bound to the package definition,
  15752. and export that variable from a module (@pxref{Package Modules}).
  15753. However, in-depth Scheme knowledge is @emph{not} a prerequisite for
  15754. creating packages. For more information on package definitions,
  15755. @pxref{Defining Packages}.
  15756. Once a package definition is in place, stored in a file in the Guix
  15757. source tree, it can be tested using the @command{guix build} command
  15758. (@pxref{Invoking guix build}). For example, assuming the new package is
  15759. called @code{gnew}, you may run this command from the Guix build tree
  15760. (@pxref{Running Guix Before It Is Installed}):
  15761. @example
  15762. ./pre-inst-env guix build gnew --keep-failed
  15763. @end example
  15764. Using @code{--keep-failed} makes it easier to debug build failures since
  15765. it provides access to the failed build tree. Another useful
  15766. command-line option when debugging is @code{--log-file}, to access the
  15767. build log.
  15768. If the package is unknown to the @command{guix} command, it may be that
  15769. the source file contains a syntax error, or lacks a @code{define-public}
  15770. clause to export the package variable. To figure it out, you may load
  15771. the module from Guile to get more information about the actual error:
  15772. @example
  15773. ./pre-inst-env guile -c '(use-modules (gnu packages gnew))'
  15774. @end example
  15775. Once your package builds correctly, please send us a patch
  15776. (@pxref{Contributing}). Well, if you need help, we will be happy to
  15777. help you too. Once the patch is committed in the Guix repository, the
  15778. new package automatically gets built on the supported platforms by
  15779. @url{http://hydra.gnu.org/jobset/gnu/master, our continuous integration
  15780. system}.
  15781. @cindex substituter
  15782. Users can obtain the new package definition simply by running
  15783. @command{guix pull} (@pxref{Invoking guix pull}). When
  15784. @code{hydra.gnu.org} is done building the package, installing the
  15785. package automatically downloads binaries from there
  15786. (@pxref{Substitutes}). The only place where human intervention is
  15787. needed is to review and apply the patch.
  15788. @menu
  15789. * Software Freedom:: What may go into the distribution.
  15790. * Package Naming:: What's in a name?
  15791. * Version Numbers:: When the name is not enough.
  15792. * Synopses and Descriptions:: Helping users find the right package.
  15793. * Python Modules:: A touch of British comedy.
  15794. * Perl Modules:: Little pearls.
  15795. * Java Packages:: Coffee break.
  15796. * Fonts:: Fond of fonts.
  15797. @end menu
  15798. @node Software Freedom
  15799. @subsection Software Freedom
  15800. @c Adapted from http://www.gnu.org/philosophy/philosophy.html.
  15801. @cindex free software
  15802. The GNU operating system has been developed so that users can have
  15803. freedom in their computing. GNU is @dfn{free software}, meaning that
  15804. users have the @url{http://www.gnu.org/philosophy/free-sw.html,four
  15805. essential freedoms}: to run the program, to study and change the program
  15806. in source code form, to redistribute exact copies, and to distribute
  15807. modified versions. Packages found in the GNU distribution provide only
  15808. software that conveys these four freedoms.
  15809. In addition, the GNU distribution follow the
  15810. @url{http://www.gnu.org/distros/free-system-distribution-guidelines.html,free
  15811. software distribution guidelines}. Among other things, these guidelines
  15812. reject non-free firmware, recommendations of non-free software, and
  15813. discuss ways to deal with trademarks and patents.
  15814. Some otherwise free upstream package sources contain a small and optional
  15815. subset that violates the above guidelines, for instance because this subset
  15816. is itself non-free code. When that happens, the offending items are removed
  15817. with appropriate patches or code snippets in the @code{origin} form of the
  15818. package (@pxref{Defining Packages}). This way, @code{guix
  15819. build --source} returns the ``freed'' source rather than the unmodified
  15820. upstream source.
  15821. @node Package Naming
  15822. @subsection Package Naming
  15823. @cindex package name
  15824. A package has actually two names associated with it:
  15825. First, there is the name of the @emph{Scheme variable}, the one following
  15826. @code{define-public}. By this name, the package can be made known in the
  15827. Scheme code, for instance as input to another package. Second, there is
  15828. the string in the @code{name} field of a package definition. This name
  15829. is used by package management commands such as
  15830. @command{guix package} and @command{guix build}.
  15831. Both are usually the same and correspond to the lowercase conversion of
  15832. the project name chosen upstream, with underscores replaced with
  15833. hyphens. For instance, GNUnet is available as @code{gnunet}, and
  15834. SDL_net as @code{sdl-net}.
  15835. We do not add @code{lib} prefixes for library packages, unless these are
  15836. already part of the official project name. But @pxref{Python
  15837. Modules} and @ref{Perl Modules} for special rules concerning modules for
  15838. the Python and Perl languages.
  15839. Font package names are handled differently, @pxref{Fonts}.
  15840. @node Version Numbers
  15841. @subsection Version Numbers
  15842. @cindex package version
  15843. We usually package only the latest version of a given free software
  15844. project. But sometimes, for instance for incompatible library versions,
  15845. two (or more) versions of the same package are needed. These require
  15846. different Scheme variable names. We use the name as defined
  15847. in @ref{Package Naming}
  15848. for the most recent version; previous versions use the same name, suffixed
  15849. by @code{-} and the smallest prefix of the version number that may
  15850. distinguish the two versions.
  15851. The name inside the package definition is the same for all versions of a
  15852. package and does not contain any version number.
  15853. For instance, the versions 2.24.20 and 3.9.12 of GTK+ may be packaged as follows:
  15854. @example
  15855. (define-public gtk+
  15856. (package
  15857. (name "gtk+")
  15858. (version "3.9.12")
  15859. ...))
  15860. (define-public gtk+-2
  15861. (package
  15862. (name "gtk+")
  15863. (version "2.24.20")
  15864. ...))
  15865. @end example
  15866. If we also wanted GTK+ 3.8.2, this would be packaged as
  15867. @example
  15868. (define-public gtk+-3.8
  15869. (package
  15870. (name "gtk+")
  15871. (version "3.8.2")
  15872. ...))
  15873. @end example
  15874. @c See <https://lists.gnu.org/archive/html/guix-devel/2016-01/msg00425.html>,
  15875. @c for a discussion of what follows.
  15876. @cindex version number, for VCS snapshots
  15877. Occasionally, we package snapshots of upstream's version control system
  15878. (VCS) instead of formal releases. This should remain exceptional,
  15879. because it is up to upstream developers to clarify what the stable
  15880. release is. Yet, it is sometimes necessary. So, what should we put in
  15881. the @code{version} field?
  15882. Clearly, we need to make the commit identifier of the VCS snapshot
  15883. visible in the version string, but we also need to make sure that the
  15884. version string is monotonically increasing so that @command{guix package
  15885. --upgrade} can determine which version is newer. Since commit
  15886. identifiers, notably with Git, are not monotonically increasing, we add
  15887. a revision number that we increase each time we upgrade to a newer
  15888. snapshot. The resulting version string looks like this:
  15889. @example
  15890. 2.0.11-3.cabba9e
  15891. ^ ^ ^
  15892. | | `-- upstream commit ID
  15893. | |
  15894. | `--- Guix package revision
  15895. |
  15896. latest upstream version
  15897. @end example
  15898. It is a good idea to strip commit identifiers in the @code{version}
  15899. field to, say, 7 digits. It avoids an aesthetic annoyance (assuming
  15900. aesthetics have a role to play here) as well as problems related to OS
  15901. limits such as the maximum shebang length (127 bytes for the Linux
  15902. kernel.) It is best to use the full commit identifiers in
  15903. @code{origin}s, though, to avoid ambiguities. A typical package
  15904. definition may look like this:
  15905. @example
  15906. (define my-package
  15907. (let ((commit "c3f29bc928d5900971f65965feaae59e1272a3f7")
  15908. (revision "1")) ;Guix package revision
  15909. (package
  15910. (version (git-version "0.9" revision commit))
  15911. (source (origin
  15912. (method git-fetch)
  15913. (uri (git-reference
  15914. (url "git://example.org/my-package.git")
  15915. (commit commit)))
  15916. (sha256 (base32 "1mbikn@dots{}"))
  15917. (file-name (git-file-name name version))))
  15918. ;; @dots{}
  15919. )))
  15920. @end example
  15921. @node Synopses and Descriptions
  15922. @subsection Synopses and Descriptions
  15923. @cindex package description
  15924. @cindex package synopsis
  15925. As we have seen before, each package in GNU@tie{}Guix includes a
  15926. synopsis and a description (@pxref{Defining Packages}). Synopses and
  15927. descriptions are important: They are what @command{guix package
  15928. --search} searches, and a crucial piece of information to help users
  15929. determine whether a given package suits their needs. Consequently,
  15930. packagers should pay attention to what goes into them.
  15931. Synopses must start with a capital letter and must not end with a
  15932. period. They must not start with ``a'' or ``the'', which usually does
  15933. not bring anything; for instance, prefer ``File-frobbing tool'' over ``A
  15934. tool that frobs files''. The synopsis should say what the package
  15935. is---e.g., ``Core GNU utilities (file, text, shell)''---or what it is
  15936. used for---e.g., the synopsis for GNU@tie{}grep is ``Print lines
  15937. matching a pattern''.
  15938. Keep in mind that the synopsis must be meaningful for a very wide
  15939. audience. For example, ``Manipulate alignments in the SAM format''
  15940. might make sense for a seasoned bioinformatics researcher, but might be
  15941. fairly unhelpful or even misleading to a non-specialized audience. It
  15942. is a good idea to come up with a synopsis that gives an idea of the
  15943. application domain of the package. In this example, this might give
  15944. something like ``Manipulate nucleotide sequence alignments'', which
  15945. hopefully gives the user a better idea of whether this is what they are
  15946. looking for.
  15947. Descriptions should take between five and ten lines. Use full
  15948. sentences, and avoid using acronyms without first introducing them.
  15949. Please avoid marketing phrases such as ``world-leading'',
  15950. ``industrial-strength'', and ``next-generation'', and avoid superlatives
  15951. like ``the most advanced''---they are not helpful to users looking for a
  15952. package and may even sound suspicious. Instead, try to be factual,
  15953. mentioning use cases and features.
  15954. @cindex Texinfo markup, in package descriptions
  15955. Descriptions can include Texinfo markup, which is useful to introduce
  15956. ornaments such as @code{@@code} or @code{@@dfn}, bullet lists, or
  15957. hyperlinks (@pxref{Overview,,, texinfo, GNU Texinfo}). However you
  15958. should be careful when using some characters for example @samp{@@} and
  15959. curly braces which are the basic special characters in Texinfo
  15960. (@pxref{Special Characters,,, texinfo, GNU Texinfo}). User interfaces
  15961. such as @command{guix package --show} take care of rendering it
  15962. appropriately.
  15963. Synopses and descriptions are translated by volunteers
  15964. @uref{http://translationproject.org/domain/guix-packages.html, at the
  15965. Translation Project} so that as many users as possible can read them in
  15966. their native language. User interfaces search them and display them in
  15967. the language specified by the current locale.
  15968. To allow @command{xgettext} to extract them as translatable strings,
  15969. synopses and descriptions @emph{must be literal strings}. This means
  15970. that you cannot use @code{string-append} or @code{format} to construct
  15971. these strings:
  15972. @lisp
  15973. (package
  15974. ;; @dots{}
  15975. (synopsis "This is translatable")
  15976. (description (string-append "This is " "*not*" " translatable.")))
  15977. @end lisp
  15978. Translation is a lot of work so, as a packager, please pay even more
  15979. attention to your synopses and descriptions as every change may entail
  15980. additional work for translators. In order to help them, it is possible
  15981. to make recommendations or instructions visible to them by inserting
  15982. special comments like this (@pxref{xgettext Invocation,,, gettext, GNU
  15983. Gettext}):
  15984. @example
  15985. ;; TRANSLATORS: "X11 resize-and-rotate" should not be translated.
  15986. (description "ARandR is designed to provide a simple visual front end
  15987. for the X11 resize-and-rotate (RandR) extension. @dots{}")
  15988. @end example
  15989. @node Python Modules
  15990. @subsection Python Modules
  15991. @cindex python
  15992. We currently package Python 2 and Python 3, under the Scheme variable names
  15993. @code{python-2} and @code{python} as explained in @ref{Version Numbers}.
  15994. To avoid confusion and naming clashes with other programming languages, it
  15995. seems desirable that the name of a package for a Python module contains
  15996. the word @code{python}.
  15997. Some modules are compatible with only one version of Python, others with both.
  15998. If the package Foo compiles only with Python 3, we name it
  15999. @code{python-foo}; if it compiles only with Python 2, we name it
  16000. @code{python2-foo}. If it is compatible with both versions, we create two
  16001. packages with the corresponding names.
  16002. If a project already contains the word @code{python}, we drop this;
  16003. for instance, the module python-dateutil is packaged under the names
  16004. @code{python-dateutil} and @code{python2-dateutil}. If the project name
  16005. starts with @code{py} (e.g. @code{pytz}), we keep it and prefix it as
  16006. described above.
  16007. @subsubsection Specifying Dependencies
  16008. @cindex inputs, for Python packages
  16009. Dependency information for Python packages is usually available in the
  16010. package source tree, with varying degrees of accuracy: in the
  16011. @file{setup.py} file, in @file{requirements.txt}, or in @file{tox.ini}.
  16012. Your mission, when writing a recipe for a Python package, is to map
  16013. these dependencies to the appropriate type of ``input'' (@pxref{package
  16014. Reference, inputs}). Although the @code{pypi} importer normally does a
  16015. good job (@pxref{Invoking guix import}), you may want to check the
  16016. following check list to determine which dependency goes where.
  16017. @itemize
  16018. @item
  16019. We currently package Python 2 with @code{setuptools} and @code{pip}
  16020. installed like Python 3.4 has per default. Thus you don't need to
  16021. specify either of these as an input. @command{guix lint} will warn you
  16022. if you do.
  16023. @item
  16024. Python dependencies required at run time go into
  16025. @code{propagated-inputs}. They are typically defined with the
  16026. @code{install_requires} keyword in @file{setup.py}, or in the
  16027. @file{requirements.txt} file.
  16028. @item
  16029. Python packages required only at build time---e.g., those listed with
  16030. the @code{setup_requires} keyword in @file{setup.py}---or only for
  16031. testing---e.g., those in @code{tests_require}---go into
  16032. @code{native-inputs}. The rationale is that (1) they do not need to be
  16033. propagated because they are not needed at run time, and (2) in a
  16034. cross-compilation context, it's the ``native'' input that we'd want.
  16035. Examples are the @code{pytest}, @code{mock}, and @code{nose} test
  16036. frameworks. Of course if any of these packages is also required at
  16037. run-time, it needs to go to @code{propagated-inputs}.
  16038. @item
  16039. Anything that does not fall in the previous categories goes to
  16040. @code{inputs}, for example programs or C libraries required for building
  16041. Python packages containing C extensions.
  16042. @item
  16043. If a Python package has optional dependencies (@code{extras_require}),
  16044. it is up to you to decide whether to add them or not, based on their
  16045. usefulness/overhead ratio (@pxref{Submitting Patches, @command{guix
  16046. size}}).
  16047. @end itemize
  16048. @node Perl Modules
  16049. @subsection Perl Modules
  16050. @cindex perl
  16051. Perl programs standing for themselves are named as any other package,
  16052. using the lowercase upstream name.
  16053. For Perl packages containing a single class, we use the lowercase class name,
  16054. replace all occurrences of @code{::} by dashes and prepend the prefix
  16055. @code{perl-}.
  16056. So the class @code{XML::Parser} becomes @code{perl-xml-parser}.
  16057. Modules containing several classes keep their lowercase upstream name and
  16058. are also prepended by @code{perl-}. Such modules tend to have the word
  16059. @code{perl} somewhere in their name, which gets dropped in favor of the
  16060. prefix. For instance, @code{libwww-perl} becomes @code{perl-libwww}.
  16061. @node Java Packages
  16062. @subsection Java Packages
  16063. @cindex java
  16064. Java programs standing for themselves are named as any other package,
  16065. using the lowercase upstream name.
  16066. To avoid confusion and naming clashes with other programming languages,
  16067. it is desirable that the name of a package for a Java package is
  16068. prefixed with @code{java-}. If a project already contains the word
  16069. @code{java}, we drop this; for instance, the package @code{ngsjava} is
  16070. packaged under the name @code{java-ngs}.
  16071. For Java packages containing a single class or a small class hierarchy,
  16072. we use the lowercase class name, replace all occurrences of @code{.} by
  16073. dashes and prepend the prefix @code{java-}. So the class
  16074. @code{apache.commons.cli} becomes package
  16075. @code{java-apache-commons-cli}.
  16076. @node Fonts
  16077. @subsection Fonts
  16078. @cindex fonts
  16079. For fonts that are in general not installed by a user for typesetting
  16080. purposes, or that are distributed as part of a larger software package,
  16081. we rely on the general packaging rules for software; for instance, this
  16082. applies to the fonts delivered as part of the X.Org system or fonts that
  16083. are part of TeX Live.
  16084. To make it easier for a user to search for fonts, names for other packages
  16085. containing only fonts are constructed as follows, independently of the
  16086. upstream package name.
  16087. The name of a package containing only one font family starts with
  16088. @code{font-}; it is followed by the foundry name and a dash @code{-}
  16089. if the foundry is known, and the font family name, in which spaces are
  16090. replaced by dashes (and as usual, all upper case letters are transformed
  16091. to lower case).
  16092. For example, the Gentium font family by SIL is packaged under the name
  16093. @code{font-sil-gentium}.
  16094. For a package containing several font families, the name of the collection
  16095. is used in the place of the font family name.
  16096. For instance, the Liberation fonts consist of three families,
  16097. Liberation Sans, Liberation Serif and Liberation Mono.
  16098. These could be packaged separately under the names
  16099. @code{font-liberation-sans} and so on; but as they are distributed together
  16100. under a common name, we prefer to package them together as
  16101. @code{font-liberation}.
  16102. In the case where several formats of the same font family or font collection
  16103. are packaged separately, a short form of the format, prepended by a dash,
  16104. is added to the package name. We use @code{-ttf} for TrueType fonts,
  16105. @code{-otf} for OpenType fonts and @code{-type1} for PostScript Type 1
  16106. fonts.
  16107. @node Bootstrapping
  16108. @section Bootstrapping
  16109. @c Adapted from the ELS 2013 paper.
  16110. @cindex bootstrapping
  16111. Bootstrapping in our context refers to how the distribution gets built
  16112. ``from nothing''. Remember that the build environment of a derivation
  16113. contains nothing but its declared inputs (@pxref{Introduction}). So
  16114. there's an obvious chicken-and-egg problem: how does the first package
  16115. get built? How does the first compiler get compiled? Note that this is
  16116. a question of interest only to the curious hacker, not to the regular
  16117. user, so you can shamelessly skip this section if you consider yourself
  16118. a ``regular user''.
  16119. @cindex bootstrap binaries
  16120. The GNU system is primarily made of C code, with libc at its core. The
  16121. GNU build system itself assumes the availability of a Bourne shell and
  16122. command-line tools provided by GNU Coreutils, Awk, Findutils, `sed', and
  16123. `grep'. Furthermore, build programs---programs that run
  16124. @code{./configure}, @code{make}, etc.---are written in Guile Scheme
  16125. (@pxref{Derivations}). Consequently, to be able to build anything at
  16126. all, from scratch, Guix relies on pre-built binaries of Guile, GCC,
  16127. Binutils, libc, and the other packages mentioned above---the
  16128. @dfn{bootstrap binaries}.
  16129. These bootstrap binaries are ``taken for granted'', though we can also
  16130. re-create them if needed (more on that later).
  16131. @unnumberedsubsec Preparing to Use the Bootstrap Binaries
  16132. @c As of Emacs 24.3, Info-mode displays the image, but since it's a
  16133. @c large image, it's hard to scroll. Oh well.
  16134. @image{images/bootstrap-graph,6in,,Dependency graph of the early bootstrap derivations}
  16135. The figure above shows the very beginning of the dependency graph of the
  16136. distribution, corresponding to the package definitions of the @code{(gnu
  16137. packages bootstrap)} module. A similar figure can be generated with
  16138. @command{guix graph} (@pxref{Invoking guix graph}), along the lines of:
  16139. @example
  16140. guix graph -t derivation \
  16141. -e '(@@@@ (gnu packages bootstrap) %bootstrap-gcc)' \
  16142. | dot -Tps > t.ps
  16143. @end example
  16144. At this level of detail, things are
  16145. slightly complex. First, Guile itself consists of an ELF executable,
  16146. along with many source and compiled Scheme files that are dynamically
  16147. loaded when it runs. This gets stored in the @file{guile-2.0.7.tar.xz}
  16148. tarball shown in this graph. This tarball is part of Guix's ``source''
  16149. distribution, and gets inserted into the store with @code{add-to-store}
  16150. (@pxref{The Store}).
  16151. But how do we write a derivation that unpacks this tarball and adds it
  16152. to the store? To solve this problem, the @code{guile-bootstrap-2.0.drv}
  16153. derivation---the first one that gets built---uses @code{bash} as its
  16154. builder, which runs @code{build-bootstrap-guile.sh}, which in turn calls
  16155. @code{tar} to unpack the tarball. Thus, @file{bash}, @file{tar},
  16156. @file{xz}, and @file{mkdir} are statically-linked binaries, also part of
  16157. the Guix source distribution, whose sole purpose is to allow the Guile
  16158. tarball to be unpacked.
  16159. Once @code{guile-bootstrap-2.0.drv} is built, we have a functioning
  16160. Guile that can be used to run subsequent build programs. Its first task
  16161. is to download tarballs containing the other pre-built binaries---this
  16162. is what the @code{.tar.xz.drv} derivations do. Guix modules such as
  16163. @code{ftp-client.scm} are used for this purpose. The
  16164. @code{module-import.drv} derivations import those modules in a directory
  16165. in the store, using the original layout. The
  16166. @code{module-import-compiled.drv} derivations compile those modules, and
  16167. write them in an output directory with the right layout. This
  16168. corresponds to the @code{#:modules} argument of
  16169. @code{build-expression->derivation} (@pxref{Derivations}).
  16170. Finally, the various tarballs are unpacked by the
  16171. derivations @code{gcc-bootstrap-0.drv}, @code{glibc-bootstrap-0.drv},
  16172. etc., at which point we have a working C tool chain.
  16173. @unnumberedsubsec Building the Build Tools
  16174. Bootstrapping is complete when we have a full tool chain that does not
  16175. depend on the pre-built bootstrap tools discussed above. This
  16176. no-dependency requirement is verified by checking whether the files of
  16177. the final tool chain contain references to the @file{/gnu/store}
  16178. directories of the bootstrap inputs. The process that leads to this
  16179. ``final'' tool chain is described by the package definitions found in
  16180. the @code{(gnu packages commencement)} module.
  16181. The @command{guix graph} command allows us to ``zoom out'' compared to
  16182. the graph above, by looking at the level of package objects instead of
  16183. individual derivations---remember that a package may translate to
  16184. several derivations, typically one derivation to download its source,
  16185. one to build the Guile modules it needs, and one to actually build the
  16186. package from source. The command:
  16187. @example
  16188. guix graph -t bag \
  16189. -e '(@@@@ (gnu packages commencement)
  16190. glibc-final-with-bootstrap-bash)' | dot -Tps > t.ps
  16191. @end example
  16192. @noindent
  16193. produces the dependency graph leading to the ``final'' C
  16194. library@footnote{You may notice the @code{glibc-intermediate} label,
  16195. suggesting that it is not @emph{quite} final, but as a good
  16196. approximation, we will consider it final.}, depicted below.
  16197. @image{images/bootstrap-packages,6in,,Dependency graph of the early packages}
  16198. @c See <http://lists.gnu.org/archive/html/gnu-system-discuss/2012-10/msg00000.html>.
  16199. The first tool that gets built with the bootstrap binaries is
  16200. GNU@tie{}Make---noted @code{make-boot0} above---which is a prerequisite
  16201. for all the following packages. From there Findutils and Diffutils get
  16202. built.
  16203. Then come the first-stage Binutils and GCC, built as pseudo cross
  16204. tools---i.e., with @code{--target} equal to @code{--host}. They are
  16205. used to build libc. Thanks to this cross-build trick, this libc is
  16206. guaranteed not to hold any reference to the initial tool chain.
  16207. From there the final Binutils and GCC (not shown above) are built.
  16208. GCC uses @code{ld}
  16209. from the final Binutils, and links programs against the just-built libc.
  16210. This tool chain is used to build the other packages used by Guix and by
  16211. the GNU Build System: Guile, Bash, Coreutils, etc.
  16212. And voilà! At this point we have the complete set of build tools that
  16213. the GNU Build System expects. These are in the @code{%final-inputs}
  16214. variable of the @code{(gnu packages commencement)} module, and are
  16215. implicitly used by any package that uses @code{gnu-build-system}
  16216. (@pxref{Build Systems, @code{gnu-build-system}}).
  16217. @unnumberedsubsec Building the Bootstrap Binaries
  16218. @cindex bootstrap binaries
  16219. Because the final tool chain does not depend on the bootstrap binaries,
  16220. those rarely need to be updated. Nevertheless, it is useful to have an
  16221. automated way to produce them, should an update occur, and this is what
  16222. the @code{(gnu packages make-bootstrap)} module provides.
  16223. The following command builds the tarballs containing the bootstrap
  16224. binaries (Guile, Binutils, GCC, libc, and a tarball containing a mixture
  16225. of Coreutils and other basic command-line tools):
  16226. @example
  16227. guix build bootstrap-tarballs
  16228. @end example
  16229. The generated tarballs are those that should be referred to in the
  16230. @code{(gnu packages bootstrap)} module mentioned at the beginning of
  16231. this section.
  16232. Still here? Then perhaps by now you've started to wonder: when do we
  16233. reach a fixed point? That is an interesting question! The answer is
  16234. unknown, but if you would like to investigate further (and have
  16235. significant computational and storage resources to do so), then let us
  16236. know.
  16237. @unnumberedsubsec Reducing the Set of Bootstrap Binaries
  16238. Our bootstrap binaries currently include GCC, Guile, etc. That's a lot
  16239. of binary code! Why is that a problem? It's a problem because these
  16240. big chunks of binary code are practically non-auditable, which makes it
  16241. hard to establish what source code produced them. Every unauditable
  16242. binary also leaves us vulnerable to compiler backdoors as described by
  16243. Ken Thompson in the 1984 paper @emph{Reflections on Trusting Trust}.
  16244. This is mitigated by the fact that our bootstrap binaries were generated
  16245. from an earlier Guix revision. Nevertheless it lacks the level of
  16246. transparency that we get in the rest of the package dependency graph,
  16247. where Guix always gives us a source-to-binary mapping. Thus, our goal
  16248. is to reduce the set of bootstrap binaries to the bare minimum.
  16249. The @uref{http://bootstrappable.org, Bootstrappable.org web site} lists
  16250. on-going projects to do that. One of these is about replacing the
  16251. bootstrap GCC with a sequence of assemblers, interpreters, and compilers
  16252. of increasing complexity, which could be built from source starting from
  16253. a simple and auditable assembler. Your help is welcome!
  16254. @node Porting
  16255. @section Porting to a New Platform
  16256. As discussed above, the GNU distribution is self-contained, and
  16257. self-containment is achieved by relying on pre-built ``bootstrap
  16258. binaries'' (@pxref{Bootstrapping}). These binaries are specific to an
  16259. operating system kernel, CPU architecture, and application binary
  16260. interface (ABI). Thus, to port the distribution to a platform that is
  16261. not yet supported, one must build those bootstrap binaries, and update
  16262. the @code{(gnu packages bootstrap)} module to use them on that platform.
  16263. Fortunately, Guix can @emph{cross compile} those bootstrap binaries.
  16264. When everything goes well, and assuming the GNU tool chain supports the
  16265. target platform, this can be as simple as running a command like this
  16266. one:
  16267. @example
  16268. guix build --target=armv5tel-linux-gnueabi bootstrap-tarballs
  16269. @end example
  16270. For this to work, the @code{glibc-dynamic-linker} procedure in
  16271. @code{(gnu packages bootstrap)} must be augmented to return the right
  16272. file name for libc's dynamic linker on that platform; likewise,
  16273. @code{system->linux-architecture} in @code{(gnu packages linux)} must be
  16274. taught about the new platform.
  16275. Once these are built, the @code{(gnu packages bootstrap)} module needs
  16276. to be updated to refer to these binaries on the target platform. That
  16277. is, the hashes and URLs of the bootstrap tarballs for the new platform
  16278. must be added alongside those of the currently supported platforms. The
  16279. bootstrap Guile tarball is treated specially: it is expected to be
  16280. available locally, and @file{gnu/local.mk} has rules do download it for
  16281. the supported architectures; a rule for the new platform must be added
  16282. as well.
  16283. In practice, there may be some complications. First, it may be that the
  16284. extended GNU triplet that specifies an ABI (like the @code{eabi} suffix
  16285. above) is not recognized by all the GNU tools. Typically, glibc
  16286. recognizes some of these, whereas GCC uses an extra @code{--with-abi}
  16287. configure flag (see @code{gcc.scm} for examples of how to handle this).
  16288. Second, some of the required packages could fail to build for that
  16289. platform. Lastly, the generated binaries could be broken for some
  16290. reason.
  16291. @c *********************************************************************
  16292. @include contributing.texi
  16293. @c *********************************************************************
  16294. @node Acknowledgments
  16295. @chapter Acknowledgments
  16296. Guix is based on the @uref{http://nixos.org/nix/, Nix package manager},
  16297. which was designed and
  16298. implemented by Eelco Dolstra, with contributions from other people (see
  16299. the @file{nix/AUTHORS} file in Guix.) Nix pioneered functional package
  16300. management, and promoted unprecedented features, such as transactional
  16301. package upgrades and rollbacks, per-user profiles, and referentially
  16302. transparent build processes. Without this work, Guix would not exist.
  16303. The Nix-based software distributions, Nixpkgs and NixOS, have also been
  16304. an inspiration for Guix.
  16305. GNU@tie{}Guix itself is a collective work with contributions from a
  16306. number of people. See the @file{AUTHORS} file in Guix for more
  16307. information on these fine people. The @file{THANKS} file lists people
  16308. who have helped by reporting bugs, taking care of the infrastructure,
  16309. providing artwork and themes, making suggestions, and more---thank you!
  16310. @c *********************************************************************
  16311. @node GNU Free Documentation License
  16312. @appendix GNU Free Documentation License
  16313. @cindex license, GNU Free Documentation License
  16314. @include fdl-1.3.texi
  16315. @c *********************************************************************
  16316. @node Concept Index
  16317. @unnumbered Concept Index
  16318. @printindex cp
  16319. @node Programming Index
  16320. @unnumbered Programming Index
  16321. @syncodeindex tp fn
  16322. @syncodeindex vr fn
  16323. @printindex fn
  16324. @bye
  16325. @c Local Variables:
  16326. @c ispell-local-dictionary: "american";
  16327. @c End: