diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rwxr-xr-x | build.sh | 9 | ||||
-rw-r--r-- | slides.md | 187 |
3 files changed, 176 insertions, 22 deletions
@@ -1,5 +1,7 @@ | |||
1 | *.sty | 1 | *.sty |
2 | /slides.pdf | 2 | /slides.pdf |
3 | /slides.tex | ||
4 | /build | ||
3 | 5 | ||
4 | result | 6 | result |
5 | result-* | 7 | result-* |
@@ -12,4 +12,11 @@ | |||
12 | # dependencies | 12 | # dependencies |
13 | 13 | ||
14 | 14 | ||
15 | pandoc slides.md -t beamer -so slides.pdf --highlight-style breezedark --pdf-engine xelatex "$@" | 15 | pandoc slides.md -t beamer -so slides.tex \ |
16 | --highlight-style breezedark \ | ||
17 | --pdf-engine xelatex \ | ||
18 | --pdf-engine-opt=-aux-directory=./build \ | ||
19 | --pdf-engine-opt=-shell-escape \ | ||
20 | "$@" | ||
21 | |||
22 | latexmk -shell-escape -xelatex -8bit -output-directory=./build slides | ||
@@ -4,17 +4,23 @@ author: Rémi Nicole | |||
4 | date: 2019-10-09 | 4 | date: 2019-10-09 |
5 | slide-level: 2 | 5 | slide-level: 2 |
6 | aspectratio: 169 | 6 | aspectratio: 169 |
7 | |||
7 | theme: metropolis | 8 | theme: metropolis |
9 | colortheme: owl | ||
10 | beameroption: "show notes on second screen=right" | ||
11 | |||
8 | toc: true | 12 | toc: true |
9 | highlightstyle: breezedark | 13 | highlightstyle: breezedark |
10 | lang: en-US | 14 | lang: en-US |
11 | 15 | ||
16 | |||
12 | header-includes: | | 17 | header-includes: | |
18 | ```{=latex} | ||
13 | \usepackage{csquotes} | 19 | \usepackage{csquotes} |
14 | \usepackage{pgfpages} | 20 | \usepackage{pgfpages} |
15 | \setbeameroption{show notes on second screen=right} | 21 | \usepackage{dirtree} |
22 | %\usepackage{beamerarticle} | ||
16 | 23 | ||
17 | \usecolortheme{owl} | ||
18 | \setbeamercolor{section in toc}{ | 24 | \setbeamercolor{section in toc}{ |
19 | use=normal text, | 25 | use=normal text, |
20 | fg=normal text.fg | 26 | fg=normal text.fg |
@@ -25,6 +31,12 @@ header-includes: | | |||
25 | } | 31 | } |
26 | 32 | ||
27 | \usepackage{fvextra} | 33 | \usepackage{fvextra} |
34 | |||
35 | \usepackage[outputdir=build]{minted} | ||
36 | \usemintedstyle{dracula} | ||
37 | \definecolor{mybg}{rgb}{0.207843, 0.219608, 0.27451} | ||
38 | \setminted{bgcolor=mybg,tabsize=4,breaklines} | ||
39 | ``` | ||
28 | --- | 40 | --- |
29 | 41 | ||
30 | # Projects and concepts | 42 | # Projects and concepts |
@@ -171,18 +183,23 @@ of the "package function". | |||
171 | 183 | ||
172 | ## Nix---Example output paths | 184 | ## Nix---Example output paths |
173 | 185 | ||
186 | ```{=latex} | ||
187 | \dirtree{% | ||
188 | .1 /nix/store/8is5yfpd095i8pcg71pb9wxv6y6d4gfv-openssh-7.9p1. | ||
189 | .2 bin. | ||
190 | .3 ssh. | ||
191 | .3 \ldots. | ||
192 | .2 etc. | ||
193 | .3 ssh. | ||
194 | .4 ssh\_config. | ||
195 | .5 \ldots. | ||
196 | .2 share. | ||
197 | .3 man. | ||
198 | .4 \ldots. | ||
199 | } | ||
200 | ``` | ||
201 | |||
174 | ``` | 202 | ``` |
175 | /nix/store/8is5yfpd095i8pcg71pb9wxv6y6d4gfv-openssh-7.9p1 | ||
176 | ├── bin | ||
177 | │ ├── ssh | ||
178 | │ └── ... | ||
179 | ├── etc | ||
180 | │ └── ssh | ||
181 | │ ├── ssh_config | ||
182 | │ └── ... | ||
183 | └── share | ||
184 | └── man | ||
185 | └── ... | ||
186 | /nix/store/chdjidjcmjs610024chncbin4bx211f2-asound.conf | 203 | /nix/store/chdjidjcmjs610024chncbin4bx211f2-asound.conf |
187 | /nix/store/486r3d12gc042yric302jg14in7j3jwm-i3.conf | 204 | /nix/store/486r3d12gc042yric302jg14in7j3jwm-i3.conf |
188 | ``` | 205 | ``` |
@@ -433,6 +450,62 @@ derive2 { | |||
433 | 450 | ||
434 | ::: | 451 | ::: |
435 | 452 | ||
453 | ## Examples with non dependencies parameters | ||
454 | |||
455 | ```{=latex} | ||
456 | \begin{minted}{nix} | ||
457 | { stdenv, cmake, ninja, fetchFromGitHub | ||
458 | , static ? false }: | ||
459 | |||
460 | stdenv.mkDerivation rec { | ||
461 | pname = "gtest"; | ||
462 | version = "1.8.1"; | ||
463 | outputs = [ "out" "dev" ]; | ||
464 | nativeBuildInputs = [ cmake ninja ]; | ||
465 | |||
466 | cmakeFlags = stdenv.lib.optional (!static) "-DBUILD_SHARED_LIBS=ON"; | ||
467 | # src = ...; | ||
468 | # patches = [ ... ]; | ||
469 | # meta = ...; | ||
470 | } | ||
471 | \end{minted} | ||
472 | ``` | ||
473 | |||
474 | ``` | ||
475 | ``` | ||
476 | |||
477 | --- | ||
478 | |||
479 | ```{=latex} | ||
480 | \begin{minted}{nix} | ||
481 | { stdenv, fetchurl, perl, libiconv, zlib, popt | ||
482 | , enableACLs ? !(stdenv.isDarwin || stdenv.isSunOS || stdenv.isFreeBSD) | ||
483 | , acl ? null, enableCopyDevicesPatch ? false }: | ||
484 | |||
485 | assert enableACLs -> acl != null; | ||
486 | with stdenv.lib; | ||
487 | stdenv.mkDerivation rec { | ||
488 | # pname = "rsync"; ... | ||
489 | srcs = [mainSrc] ++ optional enableCopyDevicesPatch patchesSrc; | ||
490 | patches = optional enableCopyDevicesPatch "./patches/copy-devices.diff"; | ||
491 | |||
492 | buildInputs = [libiconv zlib popt] ++ optional enableACLs acl; | ||
493 | } | ||
494 | \end{minted} | ||
495 | ``` | ||
496 | |||
497 | ``` | ||
498 | ``` | ||
499 | |||
500 | ::: notes | ||
501 | |||
502 | - Some usual examples include: | ||
503 | - Build static / shared versions | ||
504 | - Build documentation (usually in its own output) | ||
505 | - Enable / Disable compilation features (helps reduce dependencies) | ||
506 | |||
507 | ::: | ||
508 | |||
436 | ## How do you call the function | 509 | ## How do you call the function |
437 | 510 | ||
438 | default.nix: | 511 | default.nix: |
@@ -446,8 +519,10 @@ in | |||
446 | 519 | ||
447 | We run: | 520 | We run: |
448 | 521 | ||
449 | ```bash | 522 | ```{=latex} |
450 | nix build --file default.nix | 523 | \begin{minted}{console} |
524 | $ nix build --file default.nix | ||
525 | \end{minted} | ||
451 | ``` | 526 | ``` |
452 | 527 | ||
453 | ::: notes | 528 | ::: notes |
@@ -472,10 +547,12 @@ writeShellScriptBin "myScript" "echo 'Hello, World!'" | |||
472 | 547 | ||
473 | We get as output path: | 548 | We get as output path: |
474 | 549 | ||
475 | ``` | 550 | ```{=latex} |
476 | ./result/ | 551 | \dirtree{% |
477 | └── bin | 552 | .1 ./result/. |
478 | └── myScript | 553 | .2 bin. |
554 | .3 myScript. | ||
555 | } | ||
479 | ``` | 556 | ``` |
480 | 557 | ||
481 | ``` | 558 | ``` |
@@ -523,10 +600,75 @@ echo 'Hello, World!' | |||
523 | 600 | ||
524 | ## Overlays | 601 | ## Overlays |
525 | 602 | ||
526 | TODO | 603 | ```nix |
604 | let | ||
605 | pkgs = import <nixpkgs> { | ||
606 | overlays = [ | ||
607 | (self: super: { | ||
608 | myAlias = super.pandoc; | ||
609 | inherit (super.llvmPackages_7) | ||
610 | clang libclang llvm; | ||
611 | myPackage = self.callPackage ./myProject/default.nix { }; | ||
612 | } ) | ||
613 | ]; | ||
614 | }; | ||
615 | in | ||
616 | pkgs.myPackage | ||
617 | ``` | ||
618 | |||
619 | ::: notes | ||
620 | |||
621 | - Because the `callPackage` is from `self`, `myPackage` is able to use | ||
622 | `myAlias` and if it uses `clang`, `libclang`, or `llvm`, it will be from | ||
623 | version 7. | ||
624 | - Also, every package that doesn't explicitly specify its `llvm` version will | ||
625 | now use version 7. | ||
626 | - This might not be what we want. | ||
627 | |||
628 | |||
629 | ::: | ||
630 | |||
631 | ## Overriding parameters | ||
632 | |||
633 | ```nix | ||
634 | self: super: { | ||
635 | gtest = super.gtest.override { static = true; }; | ||
636 | myRsync = super.rsync.override { enableACLs = false; }; | ||
637 | |||
638 | myGimp = super.gimp-with-plugins.override { | ||
639 | plugins = [ super.gimpPlugins.gmic ]; | ||
640 | }; | ||
641 | |||
642 | rsnapshot = super.rsnapshot.override { rsync = self.myRsync; }; | ||
643 | } | ||
644 | ``` | ||
645 | |||
646 | ## Overriding attributes | ||
647 | |||
648 | ```nix | ||
649 | self: super: { | ||
650 | myRedshift = super.redshift.overrideAttrs (oldAttrs: { | ||
651 | src = self.fetchFromGitHub { | ||
652 | owner = "minus7"; | ||
653 | repo = "redshift"; | ||
654 | rev = "..."; | ||
655 | sha256 = "..."; | ||
656 | }; | ||
657 | }); | ||
658 | } | ||
659 | ``` | ||
660 | |||
661 | ::: notes | ||
662 | |||
663 | - Useful for ie. adding patches without having to copy the definition. | ||
664 | |||
665 | |||
666 | ::: | ||
527 | 667 | ||
528 | ## Using different versions of the same package---Generic | 668 | ## Using different versions of the same package---Generic |
529 | 669 | ||
670 | . . . | ||
671 | |||
530 | ```bash | 672 | ```bash |
531 | #! /nix/store/...-bash-4.4-p23/bin/bash -e | 673 | #! /nix/store/...-bash-4.4-p23/bin/bash -e |
532 | export PATH='/nix/store/...-python-2.7.16/bin: | 674 | export PATH='/nix/store/...-python-2.7.16/bin: |
@@ -544,7 +686,10 @@ exec -a "$0" "/nix/store/...-kodi-18.1/bin/.kodi-wrapped" \ | |||
544 | ::: notes | 686 | ::: notes |
545 | 687 | ||
546 | - This is actually called by another wrapper who tells Kodi where to find its | 688 | - This is actually called by another wrapper who tells Kodi where to find its |
547 | data | 689 | data. |
690 | - Everything you see here is automated, writing derivations is much much less | ||
691 | complicated. | ||
692 | |||
548 | 693 | ||
549 | ::: | 694 | ::: |
550 | 695 | ||