diff options
-rw-r--r-- | index.html | 256 |
1 files changed, 240 insertions, 16 deletions
@@ -31,7 +31,7 @@ background: none !important; border: none !important; box-shadow: none !important; - font-size: 0.45em !important; + font-size: 0.4em !important; } .caption { @@ -71,15 +71,16 @@ <h1>Perl software in<br>GNU Guix</h1> <aside class="notes" data-markdown> - Hello, my name is Chris, and I'm talking about package - management with GNU Guix. + Hello, my name is Chris, and I'm talking about GNU Guix + and Perl, mostly Guix. - I first found out about Guix sometime in late 2015, early - 2016. + You might know Perl, it's a very established programming + language. - I remember installing it the night before FOSDEM back in - 2016 and I started using and contributing to Guix soon - after. + GNU Guix is a more recent project, it started in + 2012. It's a package manager, and distribution of the GNU + system. + </aside> </section> <section> @@ -89,6 +90,20 @@ <p>Get and use Perl modules</p> <p>Get and use tools and applications written in Perl</p> + + <aside class="notes" data-markdown> + Perl is an important component for Guix as a package + manager, as many other packages depend on Perl at build + time, or runtime. + + It's also something Guix can help you use. If you want to + run Perl, you can use Guix to install it. + + Guix also packages some Perl (around 700) modules. + + There's also software packaged for Guix that's written in + Perl, and I'll mention a couple of examples. + </aside> </section> <section> @@ -96,12 +111,20 @@ <pre>→ guix install perl +... + → perl --version This is perl 5, version 28, subversion 0 (v5.28.0) built for x86_64-linux-thread-multi ...</pre> + + <aside class="notes" data-markdown> + Back to getting Perl though. Installing packages through + Guix is quite simple, you can run the `guix install` + command with the name of the package. + </aside> </section> <section> @@ -110,11 +133,31 @@ x86_64-linux-thread-multi <pre> → guix install perl perl-uri +... + → echo $PERL5LIB /gnu/store/h3ryiwyhp8qcxyf74sxyv746171zpazr-profile/lib/perl5/site_perl → ls /gnu/store/h3r...azr-profile/lib/perl5/site_perl/5.28.0/ URI URI.pm x86_64-linux-thread-multi</pre> + + <aside class="notes" data-markdown> + Installing Perl with some modules is very similar. + + Note here that these modules have to be specifically + packaged for Guix, more about that later. + + If you're familiar with other distributions that use a + more standard filesystem hierarchy, Guix isn't like that. + + Most things end up in the `/gnu/store` directory. Guix + however, does understand that Perl uses the PERL5LIB + environment variable to find things within the `lib/perl5/site_perl` + directory within packages, so when it creates a profile, a + grouping together of packages, it'll group the Perl + modules together, and include the appropriate value for + the `PERL5LIB` environment variable. + </aside> </section> <section data-background="white"> @@ -125,6 +168,18 @@ URI URI.pm x86_64-linux-thread-multi</pre> <li>Static site generator</li> <li>I occasionally use it for blogging</li> </ul> + + <aside class="notes" data-markdown> + On to some software that's written in Perl. + + Ikiwiki is a wiki compiler, built around a flexible static + site generator. I personally use it for simple websites + and blogs. + + It's written in Perl, and I was using it before I started + using Guix. It was also absent from Guix back then, so I + packaged it, and some of it's missing dependencies. + </aside> </section> <section> @@ -146,6 +201,14 @@ in repository guix. new f0539b6 gnu: Add perl-cgi-session. new 909dcf5 gnu: Add ikiwiki. </pre> + + <aside class="notes" data-markdown> + I don't want to spend too much time on this, but I thought + it might be useful to skim over the Guix package + definition for Ikiwiki. It's too long to fit on one slide, + but hopefully this'll give you an idea of what goes in to + a Guix package. + </aside> </section> <section> @@ -163,12 +226,37 @@ in repository guix. (sha256 (base32 <span class="string">"17pyblaqhkb61lxl63bzndiffism8k859p54k3k4sghclq6lsynh"</span>))))</span> -<span class="fragment fade-in">...</span> -</pre></section> + <span class="fragment fade-in">...</span></pre> + + <aside class="notes" data-markdown> + Packages in Guix are defined through a record type in + Guile scheme. I've only done a little bit of Perl + programming, but I think it has a concept of a record as + well. + + So, `define-public ikiwiki` is defining a value called + `ikiwiki`, which is a package. + + (next) + + Next there are some fields in the package record. The + package has a name, and the version is also specified. + + (next) + + Then the `source` is defined. This says to fetch something + from a URL. In this case, the Ikiwiki package is a little + odd. Normally this would be a release tarball from the + upstream authors, not the snapshot.debian.org site. + + Importantly, the expected hash of the file is also + specified. This means there'll be no surprises, and that + the behaviour will be consistent in to the future. + </aside> + </section> <section> - <pre> -<span style="opacity: 0.5;">(<span class="yellow-keyboard">define-public</span> ikiwiki + <pre><span style="opacity: 0.5;">(<span class="yellow-keyboard">define-public</span> ikiwiki (package</span> ... <span class="fragment fade-in-then-semi-out">(build-system perl-build-system)</span> @@ -199,7 +287,40 @@ in repository guix. `(<span class="string">"PERL5LIB"</span> <span class="string">":"</span> prefix (,path)))) (find-files bin)) #t))))))</span> -<span class="fragment fade-in">...</span></pre></section> + <span class="fragment fade-in">...</span></pre> + + <aside class="notes" data-markdown> + Moving on, each package has a build system. There are + quite a few build systems, each representing common build + steps that apply to multiple packages. + + In this case, Ikiwiki uses the perl-build-system. This + will look for files like Build.PL and Makefile.PL, and use + them if they exist. + + (next) + + The build system can be passed some arguments. Here, some + of the phases of the build process are being tweaked. + + (next) + + After the `'unpack` phase, there's a small change being + made to the source code. The value of the PERL5LIB + environment variable is being included in a file. This is + so Ikiwiki can find the modules it requires at runtime. + + (next) + + The Makefile is then patched to have the example + configuration installed. Often this isn't necessary. + + Finally, one common step is wrapping the files within the + bin directory with the value of the PERL5LIB environment + variable. This is also to ensure that Ikiwiki can find the + modules it requires at runtime. + </aside> + </section> <section> <pre><span style="opacity: 0.5;">(<span class="yellow-keyboard">define-public</span> ikiwiki @@ -231,7 +352,46 @@ in repository guix. (<span class="string">"perl-text-markdown-discount"</span> ,perl-text-markdown-discount) (<span class="string">"perl-uri"</span> ,perl-uri) (<span class="string">"perl-yaml-libyaml"</span> ,perl-yaml-libyaml)))</span> -<span class="fragment fade-in">...</span></pre></section> + <span class="fragment fade-in">...</span></pre> + + <aside class="notes" data-markdown> + Next come the inputs to the package. + + The terminology comes from the "functional" package + management paradigm that Guix uses. If you consider a + building a package a function, the dependencies are inputs + to that function, and the output of the function is the + built package in the store. + + There are multiple types of inputs, native-inputs are + those that are just used at build time. Whereas inputs are + used at runtime, and maybe also when the package is being + built. + + The distinction is mostly important when cross compiling, + something which the Perl build system doesn't currently + support as far as I'm aware. + + Thinking back to the use of the PERL5LIB environment + variable on the previous slide, these are the modules + which will be mentioned in the value of that environment + variable. + + When building a Guix package, the build process takes + place in an isolated environment, with only the store + items that the package and build system explicitly + require, along with their dependnecies. + + Guix will ensure that any store item referenced by the + generated outputs exists within the store. Which it's why + it's important for the Ikiwiki package to reference the + modules it requires explicitly. + + This is similar to what other package managers do with the + notion of dependencies, except in Guix it's much more + specific and unchanging. + </aside> + </section> <section> <pre><span style="opacity: 0.5;">(<span class="yellow-keyboard">define-public</span> ikiwiki @@ -243,8 +403,13 @@ in repository guix. <span class="string">"Ikiwiki is a wiki compiler, capable of generating a static set of web pages, but also incorporating dynamic features like a web based editor and commenting."</span>) - (license license:gpl2+)))</span> - </pre> + (license license:gpl2+)))</span></pre> + +<aside class="notes" data-markdown> + Moving on, the last few fields within the package record are some + metadata, the home page, and license for the package, along with a + short synopsis and longer description. +</aside> </section> <section> @@ -255,6 +420,20 @@ commenting."</span>) <span class="fragment fade-right">/gnu/store/hcrv2cqzbisdb35hg2xmbxp1r2z7ijzd-ikiwiki-3.20190228</span> </pre> + + <aside class="notes" data-markdown> + With this definition, we can instruct Guix to build the + Ikiwiki package. + + Stuff may happen, then you should see the store item that + has been created. + + The hash here in the name represents the process that's + gone in to creating this package. Including all the + inputs, the build system and the arguments in the package + definition. Change any of that, the hash will change, and + you'll get a different store item. + </aside> </section> <section> @@ -291,10 +470,28 @@ commenting."</span>) └── man8 └── ikiwiki-mass-rebuild.8.gz </pre> + + <aside class="notes" data-markdown> + While Guix doesn't follow the same filesystem hierachy as + other distributions of GNU, what you find within the store + item for a package might be more familiar. Particularly + the bin, lib and share directories. + + (Any questions about Ikiwiki?) + </aside> </section> <section data-background="white"> <img src="sqitch-logo.svg" alt="Sqitch" style="width: 15em;" /> + + <ul> + <li>Sensible database change management</li> + </ul> + + <aside class="notes" data-markdown> + Next, I thought I'd mention Sqitch. It's a database change + management tool that I've recently started using. + </aside> </section> <section> @@ -320,6 +517,13 @@ in repository guix. new 55916fa gnu: Add perl-mysql-config. new 7b23313 gnu: Add perl-string-shellquote. new cabe8f1 gnu: Add sqitch.</pre> + + <aside class="notes" data-markdown> + It's written in Perl, and I recently packaged it for + Guix. The process and package definition is similar to + Ikiwiki, this time, let's look at packaging one of the + missing modules required by Sqitch. + </aside> </section> <section> @@ -352,6 +556,20 @@ From http://www.cpan.org/authors/id/M/MI/MIYAGAWA/HTTP-Tinyish-0.15.tar.gz... <span class="string">"HTTP::Tiny compatible HTTP client wrappers"</span>) (description fill-in-yourself!) (license perl-license))</pre> + + <aside class="notes" data-markdown> + Guix has several importers. These importers utilise the + information that already exists about packages to help + creating Guix package definitions. + + In this case, the information from CPAN is used to fill in + some of the parts of the perl-http-tinyish package + definition. + + Importers can make it much easier to create package + definitions for Perl modules, as well as lots of other + languages. + </aside> </section> <section> @@ -361,6 +579,12 @@ From http://www.cpan.org/authors/id/M/MI/MIYAGAWA/HTTP-Tinyish-0.15.tar.gz... <p>Get and use Perl modules</p> <p>Get and use tools and applications written in Perl</p> + + <aside class="notes" data-markdown> + So to recap, I haven't gone much in to the more general + what and why around Guix, but hopefully some of these Perl + examples have been useful. + </aside> </section> </div> </div> |