1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
|
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>GNU Guix, package manager, system distribution and more</title>
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/black.css">
<style>
.reveal h1 {
text-transform: unset;
}
.reveal h2 {
text-transform: unset;
}
.reveal h3 {
text-transform: unset;
}
img {
background: none !important;
border: none !important;
box-shadow: none !important;
}
pre {
background: none !important;
border: none !important;
box-shadow: none !important;
font-size: 0.4em !important;
}
.caption {
display: block;
clear: both;
font-size: large !important;
}
.string {
color: #00cc99;
}
.yellow-keyboard {
color: #ffff33;
}
</style>
<!-- Theme used for syntax highlighting of code -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
</head>
<body>
<div class="reveal">
<div class="slides">
<section>
<span style="font-size: 4em;">
<img src="perl.svg" style="background: unset; margin: unset; border: unset; box-shadow: unset; width: 1.05em;"><span style="vertical-align: 0.2em; margin-left: 0.15em;">+</span><img src="Guix.svg" style="background: unset; margin: unset; border: unset; box-shadow: unset;">
</span>
<h1>Perl software in<br>GNU Guix</h1>
<aside class="notes" data-markdown>
Hello, my name is Chris, and I'm talking about GNU Guix
and Perl, mostly Guix.
You might know Perl, it's a very established programming
language.
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>
<h2>Through Guix you can...</h2>
<p>Get and use Perl</p>
<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>
<h2>Getting Perl</h2>
<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>
<h2>Using Perl modules</h2>
<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">
<img src="ikiwiki.svg" alt="Ikiwiki" style="width: 14em;" />
<ul>
<li>Wiki compiler</li>
<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>
<pre>
cbaines pushed a change to branch master
in repository guix.
from 921bb35 gnu: linux-libre@4.9: Fix hash.
new 31d3a7c gnu: Add discount.
new 9d46919 gnu: Add perl-text-markdown-discount.
new 19d81cf gnu: Add perl-test-cpan-meta-json.
new d5b5020 gnu: Add perl-test-cpan-meta.
new b4387d8 gnu: Add perl-devel-cycle.
new 3d74955 gnu: Add perl-test-memory-cycle.
new 8800255 gnu: Add perl-test-notabs.
new 7d1f9c9 gnu: Add perl-test-eol.
new 4f0ee1b gnu: Add perl-html-scrubber.
new 86bd64b gnu: Add perl-yaml-libyaml.
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>
<pre>
<span class="fragment fade-in-then-semi-out">(<span class="yellow-keyboard">define-public</span> ikiwiki
(package</span>
<span class="fragment fade-in-then-semi-out">(name <span class="string">"ikiwiki"</span>)
(version <span class="string">"3.20190228"</span>)</span>
<span class="fragment fade-in-then-semi-out">(source
(origin
(method url-fetch)
(uri (string-append <span class="string">"http://snapshot.debian.org/archive/debian/"</span>
<span class="string">"20190301T035241Z/pool/main/i/ikiwiki/ikiwiki_"</span>
version <span class="string">".orig.tar.xz"</span>))
(sha256
(base32
<span class="string">"17pyblaqhkb61lxl63bzndiffism8k859p54k3k4sghclq6lsynh"</span>))))</span>
<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
(package</span>
...
<span class="fragment fade-in-then-semi-out">(build-system perl-build-system)</span>
<span class="fragment fade-in-then-semi-out">(arguments
`(#:phases
(modify-phases %standard-phases</span>
<span class="fragment fade-in-then-semi-out">(add-after 'unpack 'include-PERL5LIB-in-wrapper
(<span class="yellow-keyboard">lambda</span> _
(substitute* <span class="string">"IkiWiki/Wrapper.pm"</span>
((<span class="string">"^@wrapper\\_hooks"</span>)
(string-append
<span class="string">"@wrapper_hooks\n"</span>
<span class="string">" addenv(\"PERL5LIB\", \""</span>
(getenv <span class="string">"PERL5LIB"</span>)
<span class="string">"\");"</span>)))))</span>
<span class="fragment fade-in-then-semi-out">(add-after 'patch-source-shebangs 'patch-Makefile
(<span class="yellow-keyboard">lambda</span> _
(substitute* <span class="string">"Makefile.PL"</span>
((<span class="string">"SYSCONFDIR\\?="</span>) <span class="string">"SYSCONFDIR?=$(PREFIX)"</span>))
#t))</span>
<span class="fragment fade-in-then-semi-out">(add-after 'install 'wrap-programs
(<span class="yellow-keyboard">lambda*</span> (#:key outputs #:allow-other-keys)
(<span class="yellow-keyboard">let*</span> ((out (assoc-ref outputs <span class="string">"out"</span>))
(bin (string-append out <span class="string">"/bin/"</span>))
(path (getenv <span class="string">"PERL5LIB"</span>)))
(for-each (lambda (file)
(wrap-program file
`(<span class="string">"PERL5LIB"</span> <span class="string">":"</span> prefix (,path))))
(find-files bin))
#t))))))</span>
<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
(package</span>
...
<span class="fragment fade-in-then-semi-out">(native-inputs
`((<span class="string">"which"</span> ,which)
(<span class="string">"perl-html-tagset"</span> ,perl-html-tagset)
(<span class="string">"perl-timedate"</span> ,perl-timedate)
(<span class="string">"perl-xml-sax"</span> ,perl-xml-sax)
(<span class="string">"perl-xml-simple"</span> ,perl-xml-simple)
(<span class="string">"gettext"</span> ,gettext-minimal)
(<span class="string">"subversion"</span> ,subversion)
(<span class="string">"git"</span> ,git)
(<span class="string">"bazaar"</span> ,bazaar)
(<span class="string">"cvs"</span> ,cvs)
(<span class="string">"mercurial"</span> ,mercurial)))</span>
<span class="fragment fade-in-then-semi-out">(inputs
`((<span class="string">"python"</span> ,python-wrapper)
(<span class="string">"perl-cgi-formbuilder"</span> ,perl-cgi-formbuilder)
(<span class="string">"perl-cgi-session"</span> ,perl-cgi-session)
(<span class="string">"perl-cgi-simple"</span> ,perl-cgi-simple)
(<span class="string">"perl-db-file"</span> ,perl-db-file)
(<span class="string">"perl-html-parser"</span> ,perl-html-parser)
(<span class="string">"perl-html-scrubber"</span> ,perl-html-scrubber)
(<span class="string">"perl-html-template"</span> ,perl-html-template)
(<span class="string">"perl-image-magick"</span> ,perl-image-magick)
(<span class="string">"perl-json"</span> ,perl-json)
(<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>
<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
(package</span>
...
<span class="fragment fade-in-then-semi-out">(home-page <span class="string">"https://ikiwiki.info/"</span>)
(synopsis <span class="string">"Wiki compiler, capable of generating HTML"</span>)
(description
<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>
<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>
<pre>
→ guix build ikiwiki
<span class="fragment fade-in-then-semi-out">...</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>
<pre>
/gnu/store/hcrv2cqzbisdb35hg2xmbxp1r2z7ijzd-ikiwiki-3.20190228
├── bin
│ ├── ikiwiki
│ ├── ikiwiki-calendar
│ ├── ikiwiki-comment
│ ├── ikiwiki-makerepo
│ ├── ikiwiki-transition
│ └── ikiwiki-update-wikilist
├── etc
│ └── ikiwiki
│ └── ...
├── lib
│ ├── ikiwiki
│ │ └── ...
│ ├── perl5
│ │ └── ...
│ └── w3m
│ └── cgi-bin
│ └── ikiwiki-w3m.cgi
├── sbin
│ └── ikiwiki-mass-rebuild
└── share
├── ikiwiki
│ └── ...
├── locale
│ └── ...
└── man
├── man1
│ └── ...
└── 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>
<pre>
cbaines pushed a change to branch master
in repository guix.
from 1b7436a gnu: wine-staging: Update to 4.6.
new 41c685f gnu: Add perl-http-tinyish.
new ef9902d gnu: Add perl-config-gitlike.
new 366b76c gnu: Add perl-cpan-distnameinfo.
new 54a5178 gnu: Add perl-tie-handle-offset.
new f73d4b1 gnu: Add perl-io-pager.
new e748fbe gnu: Add perl-string-formatter.
new 9273ebf gnu: Add perl-template-tiny.
new ce6bea4 gnu: Add perl-uri-nested.
new 618d52a gnu: Add perl-uri-db.
new c1a4e78 gnu: Add perl-test-checkdeps.
new 9c5551c gnu: Add perl-test-dir.
new 402cfeb gnu: Add perl-test-file.
new 709a9e9 gnu: Add perl-test-file-contents.
new 3840c51 gnu: Add perl-test-version.
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>
<pre class="stretch">
→ guix import cpan HTTP::Tinyish
Starting download of /tmp/guix-file.f6bYLw
From http://www.cpan.org/authors/id/M/MI/MIYAGAWA/HTTP-Tinyish-0.15.tar.gz...
…-0.15.tar.gz 16KiB 722KiB/s 00:00 [##################] 100.0%
(package
(name <span class="string">"perl-http-tinyish"</span>)
(version <span class="string">"0.15"</span>)
(source
(origin
(method url-fetch)
(uri (string-append
<span class="string">"mirror://cpan/authors/id/M/MI/MIYAGAWA/HTTP-Tinyish-"</span>
version
<span class="string">".tar.gz"</span>))
(sha256
(base32
<span class="string">"199sa722amvwhq0czjfb7psj3hbqmvni5vxkrm579r5943pg0rax"</span>))))
(build-system perl-build-system)
(propagated-inputs
`((<span class="string">"perl-file-which"</span> ,perl-file-which)
(<span class="string">"perl-ipc-run3"</span> ,perl-ipc-run3)))
(home-page
<span class="string">"https://metacpan.org/release/HTTP-Tinyish"</span>)
(synopsis
<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>
<h2>Recap: Through Guix you can...</h2>
<p>Get and use Perl</p>
<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>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.js"></script>
<script>
// More info about config & dependencies:
// - https://github.com/hakimel/reveal.js#configuration
// - https://github.com/hakimel/reveal.js#dependencies
Reveal.initialize({
controls: false,
history: true,
//showNotes: true,
dependencies: [
{ src: 'plugin/markdown/marked.js' },
{ src: 'plugin/markdown/markdown.js' },
{ src: 'plugin/notes/notes.js', async: true },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'plugin/tagcloud/tagcloud.js', async: true }
]
});
</script>
</body>
</html>
|