diff options
author | Minijackson <minijackson@riseup.net> | 2019-10-05 10:52:44 +0200 |
---|---|---|
committer | Minijackson <minijackson@riseup.net> | 2019-10-06 19:52:48 +0200 |
commit | 25cf13479e5876dc526a23657f6d10e2630cd940 (patch) | |
tree | 1563bf23a9f7cc1f69ee12cabce52dd0da464f03 /slides.md | |
parent | 42c6c8fa075737bca03bc06a54e4915c0d7202ae (diff) | |
download | nixos-embedded-slides-25cf13479e5876dc526a23657f6d10e2630cd940.tar.gz nixos-embedded-slides-25cf13479e5876dc526a23657f6d10e2630cd940.zip |
Switch everything to minted
Diffstat (limited to 'slides.md')
-rw-r--r-- | slides.md | 238 |
1 files changed, 196 insertions, 42 deletions
@@ -206,7 +206,8 @@ of the "package function". | |||
206 | 206 | ||
207 | ## Nix---Language (Types) | 207 | ## Nix---Language (Types) |
208 | 208 | ||
209 | ```nix | 209 | ```{=latex} |
210 | \begin{minted}{nix} | ||
210 | { | 211 | { |
211 | int = 1; | 212 | int = 1; |
212 | boolean = true; | 213 | boolean = true; |
@@ -217,9 +218,13 @@ of the "package function". | |||
217 | ''; | 218 | ''; |
218 | "attribute set" = { a = 1; b = 2; }; | 219 | "attribute set" = { a = 1; b = 2; }; |
219 | list = [ 1 2 "hello" ]; | 220 | list = [ 1 2 "hello" ]; |
220 | function = a: builtins.toString a; | 221 | function = a: toString a; |
221 | "function w/ named parameters" = { a, b, c ? "default"}: a; | 222 | "function w/ named parameters" = { a, b, c ? "default"}: a; |
222 | } | 223 | } |
224 | \end{minted} | ||
225 | ``` | ||
226 | |||
227 | ``` | ||
223 | ``` | 228 | ``` |
224 | 229 | ||
225 | ::: notes | 230 | ::: notes |
@@ -239,7 +244,8 @@ a function that returns a function ("currying"), or use named parameters. | |||
239 | :::::: {.columns} | 244 | :::::: {.columns} |
240 | ::: {.column width="60%"} | 245 | ::: {.column width="60%"} |
241 | 246 | ||
242 | ```nix | 247 | ```{=latex} |
248 | \begin{minted}{nix} | ||
243 | let | 249 | let |
244 | a = 1; | 250 | a = 1; |
245 | b = a + 1; | 251 | b = a + 1; |
@@ -249,6 +255,7 @@ in | |||
249 | d = if a == 1 then 2 else 3; | 255 | d = if a == 1 then 2 else 3; |
250 | e = c "world"; | 256 | e = c "world"; |
251 | } | 257 | } |
258 | \end{minted} | ||
252 | ``` | 259 | ``` |
253 | 260 | ||
254 | ::: | 261 | ::: |
@@ -256,11 +263,16 @@ in | |||
256 | 263 | ||
257 | Gives: | 264 | Gives: |
258 | 265 | ||
259 | ```nix | 266 | ```{=latex} |
267 | \begin{minted}{nix} | ||
260 | { | 268 | { |
261 | d = 2; | 269 | d = 2; |
262 | e = "hello world!"; | 270 | e = "hello world!"; |
263 | } | 271 | } |
272 | \end{minted} | ||
273 | ``` | ||
274 | |||
275 | ``` | ||
264 | ``` | 276 | ``` |
265 | 277 | ||
266 | ::: | 278 | ::: |
@@ -287,7 +299,8 @@ Gives: | |||
287 | :::::: {.columns} | 299 | :::::: {.columns} |
288 | ::: {.column witdh="60%"} | 300 | ::: {.column witdh="60%"} |
289 | 301 | ||
290 | ```nix | 302 | ```{=latex} |
303 | \begin{minted}{nix} | ||
291 | let | 304 | let |
292 | a = 1; | 305 | a = 1; |
293 | b = a + 1; | 306 | b = a + 1; |
@@ -298,6 +311,10 @@ in | |||
298 | e = with c; d + 3; | 311 | e = with c; d + 3; |
299 | f = e + 1; | 312 | f = e + 1; |
300 | } | 313 | } |
314 | \end{minted} | ||
315 | ``` | ||
316 | |||
317 | ``` | ||
301 | ``` | 318 | ``` |
302 | 319 | ||
303 | ::: | 320 | ::: |
@@ -305,12 +322,17 @@ in | |||
305 | 322 | ||
306 | Gives: | 323 | Gives: |
307 | 324 | ||
308 | ```nix | 325 | ```{=latex} |
326 | \begin{minted}{nix} | ||
309 | { | 327 | { |
310 | b = 2; | 328 | b = 2; |
311 | e = 45; | 329 | e = 45; |
312 | f = 46; | 330 | f = 46; |
313 | } | 331 | } |
332 | \end{minted} | ||
333 | ``` | ||
334 | |||
335 | ``` | ||
314 | ``` | 336 | ``` |
315 | 337 | ||
316 | ::: | 338 | ::: |
@@ -327,12 +349,17 @@ Gives: | |||
327 | 349 | ||
328 | What does that do? | 350 | What does that do? |
329 | 351 | ||
330 | ```nix | 352 | ```{=latex} |
353 | \begin{minted}{nix} | ||
331 | rec { | 354 | rec { |
332 | a = { | 355 | a = { |
333 | inherit a; | 356 | inherit a; |
334 | }; | 357 | }; |
335 | } | 358 | } |
359 | \end{minted} | ||
360 | ``` | ||
361 | |||
362 | ``` | ||
336 | ``` | 363 | ``` |
337 | 364 | ||
338 | ::: notes | 365 | ::: notes |
@@ -346,7 +373,8 @@ rec { | |||
346 | 373 | ||
347 | ## An example Nixpkgs derivation | 374 | ## An example Nixpkgs derivation |
348 | 375 | ||
349 | ```nix | 376 | ```{=latex} |
377 | \begin{minted}{nix} | ||
350 | { stdenv, fetchurl }: | 378 | { stdenv, fetchurl }: |
351 | 379 | ||
352 | stdenv.mkDerivation rec { | 380 | stdenv.mkDerivation rec { |
@@ -359,6 +387,10 @@ stdenv.mkDerivation rec { | |||
359 | }; | 387 | }; |
360 | 388 | ||
361 | doCheck = true; | 389 | doCheck = true; |
390 | \end{minted} | ||
391 | ``` | ||
392 | |||
393 | ``` | ||
362 | ``` | 394 | ``` |
363 | 395 | ||
364 | ::: notes | 396 | ::: notes |
@@ -378,7 +410,8 @@ stdenv.mkDerivation rec { | |||
378 | 410 | ||
379 | --- | 411 | --- |
380 | 412 | ||
381 | ```nix | 413 | ```{=latex} |
414 | \begin{minted}{nix} | ||
382 | meta = with stdenv.lib; { | 415 | meta = with stdenv.lib; { |
383 | description = "A program that produces a familiar, friendly greeting"; | 416 | description = "A program that produces a familiar, friendly greeting"; |
384 | longDescription = '' | 417 | longDescription = '' |
@@ -391,6 +424,10 @@ stdenv.mkDerivation rec { | |||
391 | platforms = platforms.all; | 424 | platforms = platforms.all; |
392 | }; | 425 | }; |
393 | } | 426 | } |
427 | \end{minted} | ||
428 | ``` | ||
429 | |||
430 | ``` | ||
394 | ``` | 431 | ``` |
395 | 432 | ||
396 | ## Other examples {.shrink} | 433 | ## Other examples {.shrink} |
@@ -399,7 +436,8 @@ stdenv.mkDerivation rec { | |||
399 | :::::: {.columns} | 436 | :::::: {.columns} |
400 | ::: {.column} | 437 | ::: {.column} |
401 | 438 | ||
402 | ```nix | 439 | ```{=latex} |
440 | \begin{minted}{nix} | ||
403 | { stdenv, meson, ninja, pkgconfig | 441 | { stdenv, meson, ninja, pkgconfig |
404 | , qtbase, qtconnectivity }: | 442 | , qtbase, qtconnectivity }: |
405 | 443 | ||
@@ -413,12 +451,17 @@ stdenv.mkDerivation rec { | |||
413 | mesonBuildType = "debug"; | 451 | mesonBuildType = "debug"; |
414 | src = ./.; | 452 | src = ./.; |
415 | } | 453 | } |
454 | \end{minted} | ||
455 | ``` | ||
456 | |||
457 | ``` | ||
416 | ``` | 458 | ``` |
417 | 459 | ||
418 | ::: | 460 | ::: |
419 | ::: {.column} | 461 | ::: {.column} |
420 | 462 | ||
421 | ```nix | 463 | ```{=latex} |
464 | \begin{minted}{nix} | ||
422 | derive2 { | 465 | derive2 { |
423 | name = "ggplot2"; | 466 | name = "ggplot2"; |
424 | version = "3.2.0"; | 467 | version = "3.2.0"; |
@@ -428,6 +471,10 @@ derive2 { | |||
428 | scales tibble viridisLite | 471 | scales tibble viridisLite |
429 | withr ]; | 472 | withr ]; |
430 | }; | 473 | }; |
474 | \end{minted} | ||
475 | ``` | ||
476 | |||
477 | ``` | ||
431 | ``` | 478 | ``` |
432 | 479 | ||
433 | ::: | 480 | ::: |
@@ -510,11 +557,13 @@ stdenv.mkDerivation rec { | |||
510 | 557 | ||
511 | default.nix: | 558 | default.nix: |
512 | 559 | ||
513 | ```nix | 560 | ```{=latex} |
561 | \begin{minted}{nix} | ||
514 | let | 562 | let |
515 | pkgs = import <nixpkgs> {}; | 563 | pkgs = import <nixpkgs> {}; |
516 | in | 564 | in |
517 | pkgs.callPackage ./derivation.nix {} | 565 | pkgs.callPackage ./derivation.nix {} |
566 | \end{minted} | ||
518 | ``` | 567 | ``` |
519 | 568 | ||
520 | We run: | 569 | We run: |
@@ -539,10 +588,12 @@ $ nix build --file default.nix | |||
539 | 588 | ||
540 | If we have derivation.nix: | 589 | If we have derivation.nix: |
541 | 590 | ||
542 | ```nix | 591 | ```{=latex} |
592 | \begin{minted}{nix} | ||
543 | { writeShellScriptBin }: | 593 | { writeShellScriptBin }: |
544 | 594 | ||
545 | writeShellScriptBin "myScript" "echo 'Hello, World!'" | 595 | writeShellScriptBin "myScript" "echo 'Hello, World!'" |
596 | \end{minted} | ||
546 | ``` | 597 | ``` |
547 | 598 | ||
548 | We get as output path: | 599 | We get as output path: |
@@ -555,9 +606,11 @@ We get as output path: | |||
555 | } | 606 | } |
556 | ``` | 607 | ``` |
557 | 608 | ||
558 | ``` | 609 | ```{=latex} |
610 | \begin{minted}{console} | ||
559 | $ ./result/bin/myScript | 611 | $ ./result/bin/myScript |
560 | Hello, World! | 612 | Hello, World! |
613 | \end{minted} | ||
561 | ``` | 614 | ``` |
562 | 615 | ||
563 | ::: notes | 616 | ::: notes |
@@ -569,18 +622,20 @@ Hello, World! | |||
569 | 622 | ||
570 | --- | 623 | --- |
571 | 624 | ||
572 | ``` | 625 | ```{=latex} |
626 | \begin{minted}{console} | ||
573 | $ ls -l result | 627 | $ ls -l result |
574 | result -> /nix/store/a7db5d4v5b2pxppl8drb30ljx9z0kwg0-myScript | 628 | result -> /nix/store/a7db5d4v5b2pxppl8drb30ljx9z0kwg0-myScript |
629 | \end{minted} | ||
575 | ``` | 630 | ``` |
576 | 631 | ||
577 | . . . | ||
578 | |||
579 | `./result/bin/myScript` is: | 632 | `./result/bin/myScript` is: |
580 | 633 | ||
581 | ```bash | 634 | ```{=latex} |
635 | \begin{minted}{bash} | ||
582 | #!/nix/store/cinw572b38aln37glr0zb8lxwrgaffl4-bash-4.4-p23/bin/bash | 636 | #!/nix/store/cinw572b38aln37glr0zb8lxwrgaffl4-bash-4.4-p23/bin/bash |
583 | echo 'Hello, World!' | 637 | echo 'Hello, World!' |
638 | \end{minted} | ||
584 | ``` | 639 | ``` |
585 | 640 | ||
586 | ::: notes | 641 | ::: notes |
@@ -600,7 +655,8 @@ echo 'Hello, World!' | |||
600 | 655 | ||
601 | ## Overlays | 656 | ## Overlays |
602 | 657 | ||
603 | ```nix | 658 | ```{=latex} |
659 | \begin{minted}{nix} | ||
604 | let | 660 | let |
605 | pkgs = import <nixpkgs> { | 661 | pkgs = import <nixpkgs> { |
606 | overlays = [ | 662 | overlays = [ |
@@ -614,6 +670,10 @@ let | |||
614 | }; | 670 | }; |
615 | in | 671 | in |
616 | pkgs.myPackage | 672 | pkgs.myPackage |
673 | \end{minted} | ||
674 | ``` | ||
675 | |||
676 | ``` | ||
617 | ``` | 677 | ``` |
618 | 678 | ||
619 | ::: notes | 679 | ::: notes |
@@ -630,7 +690,8 @@ in | |||
630 | 690 | ||
631 | ## Overriding parameters | 691 | ## Overriding parameters |
632 | 692 | ||
633 | ```nix | 693 | ```{=latex} |
694 | \begin{minted}{nix} | ||
634 | self: super: { | 695 | self: super: { |
635 | gtest = super.gtest.override { static = true; }; | 696 | gtest = super.gtest.override { static = true; }; |
636 | myRsync = super.rsync.override { enableACLs = false; }; | 697 | myRsync = super.rsync.override { enableACLs = false; }; |
@@ -641,11 +702,16 @@ self: super: { | |||
641 | 702 | ||
642 | rsnapshot = super.rsnapshot.override { rsync = self.myRsync; }; | 703 | rsnapshot = super.rsnapshot.override { rsync = self.myRsync; }; |
643 | } | 704 | } |
705 | \end{minted} | ||
706 | ``` | ||
707 | |||
708 | ``` | ||
644 | ``` | 709 | ``` |
645 | 710 | ||
646 | ## Overriding attributes | 711 | ## Overriding attributes |
647 | 712 | ||
648 | ```nix | 713 | ```{=latex} |
714 | \begin{minted}{nix} | ||
649 | self: super: { | 715 | self: super: { |
650 | myRedshift = super.redshift.overrideAttrs (oldAttrs: { | 716 | myRedshift = super.redshift.overrideAttrs (oldAttrs: { |
651 | src = self.fetchFromGitHub { | 717 | src = self.fetchFromGitHub { |
@@ -656,6 +722,10 @@ self: super: { | |||
656 | }; | 722 | }; |
657 | }); | 723 | }); |
658 | } | 724 | } |
725 | \end{minted} | ||
726 | ``` | ||
727 | |||
728 | ``` | ||
659 | ``` | 729 | ``` |
660 | 730 | ||
661 | ::: notes | 731 | ::: notes |
@@ -669,7 +739,8 @@ self: super: { | |||
669 | 739 | ||
670 | . . . | 740 | . . . |
671 | 741 | ||
672 | ```bash | 742 | ```{=latex} |
743 | \begin{minted}{bash} | ||
673 | #! /nix/store/...-bash-4.4-p23/bin/bash -e | 744 | #! /nix/store/...-bash-4.4-p23/bin/bash -e |
674 | export PATH='/nix/store/...-python-2.7.16/bin: | 745 | export PATH='/nix/store/...-python-2.7.16/bin: |
675 | /nix/store/...-glxinfo-8.4.0/bin: | 746 | /nix/store/...-glxinfo-8.4.0/bin: |
@@ -681,6 +752,10 @@ export LD_LIBRARY_PATH='/nix/store/...-curl-7.64.0/lib: | |||
681 | ...'${LD_LIBRARY_PATH:+':'}$LD_LIBRARY_PATH | 752 | ...'${LD_LIBRARY_PATH:+':'}$LD_LIBRARY_PATH |
682 | exec -a "$0" "/nix/store/...-kodi-18.1/bin/.kodi-wrapped" \ | 753 | exec -a "$0" "/nix/store/...-kodi-18.1/bin/.kodi-wrapped" \ |
683 | "${extraFlagsArray[@]}" "$@" | 754 | "${extraFlagsArray[@]}" "$@" |
755 | \end{minted} | ||
756 | ``` | ||
757 | |||
758 | ``` | ||
684 | ``` | 759 | ``` |
685 | 760 | ||
686 | ::: notes | 761 | ::: notes |
@@ -695,7 +770,8 @@ exec -a "$0" "/nix/store/...-kodi-18.1/bin/.kodi-wrapped" \ | |||
695 | 770 | ||
696 | ## Using different versions of the same package---ELF | 771 | ## Using different versions of the same package---ELF |
697 | 772 | ||
698 | ``` | 773 | ```{=latex} |
774 | \begin{minted}{text} | ||
699 | $ readelf -d coreutils | 775 | $ readelf -d coreutils |
700 | ... | 776 | ... |
701 | Bibliothèque partagée: [librt.so.1] | 777 | Bibliothèque partagée: [librt.so.1] |
@@ -709,11 +785,16 @@ Bibliothèque runpath:[ | |||
709 | /nix/store/...-glibc-2.27/lib | 785 | /nix/store/...-glibc-2.27/lib |
710 | ] | 786 | ] |
711 | ... | 787 | ... |
788 | \end{minted} | ||
789 | ``` | ||
790 | |||
791 | ``` | ||
712 | ``` | 792 | ``` |
713 | 793 | ||
714 | ## Using different versions of the same package---Python | 794 | ## Using different versions of the same package---Python |
715 | 795 | ||
716 | ```python | 796 | ```{=latex} |
797 | \begin{minted}{python} | ||
717 | # imports... | 798 | # imports... |
718 | sys.argv[0] = '/nix/store/...-carla-2.0.0/share/carla/carla' | 799 | sys.argv[0] = '/nix/store/...-carla-2.0.0/share/carla/carla' |
719 | functools.reduce( | 800 | functools.reduce( |
@@ -726,6 +807,10 @@ functools.reduce( | |||
726 | ], | 807 | ], |
727 | site._init_pathinfo()) | 808 | site._init_pathinfo()) |
728 | # ... | 809 | # ... |
810 | \end{minted} | ||
811 | ``` | ||
812 | |||
813 | ``` | ||
729 | ``` | 814 | ``` |
730 | 815 | ||
731 | ::: notes | 816 | ::: notes |
@@ -745,16 +830,20 @@ functools.reduce( | |||
745 | 830 | ||
746 | ## Adding yourself to the environment---Symbolic links | 831 | ## Adding yourself to the environment---Symbolic links |
747 | 832 | ||
748 | ``` | 833 | ```{=latex} |
834 | \begin{minted}{console} | ||
749 | $ ls -l /etc/static/ssh/ssh_config | 835 | $ ls -l /etc/static/ssh/ssh_config |
750 | /etc/static/ssh/ssh_config -> /nix/store/...-etc-ssh_config | 836 | /etc/static/ssh/ssh_config -> /nix/store/...-etc-ssh_config |
837 | \end{minted} | ||
751 | ``` | 838 | ``` |
752 | 839 | ||
753 | --- | ||
754 | |||
755 | ``` | 840 | ``` |
756 | $ systemctl cat sshd.service | 841 | ``` |
757 | 842 | ||
843 | --- | ||
844 | |||
845 | ```{=latex} | ||
846 | \begin{minted}{ini} | ||
758 | # /nix/store/...-unit-sshd.service/sshd.service | 847 | # /nix/store/...-unit-sshd.service/sshd.service |
759 | # ... | 848 | # ... |
760 | [Service] | 849 | [Service] |
@@ -766,6 +855,10 @@ ExecStartPre=/nix/store/...-unit-script-sshd-pre-start | |||
766 | KillMode=process | 855 | KillMode=process |
767 | Restart=always | 856 | Restart=always |
768 | Type=simple | 857 | Type=simple |
858 | \end{minted} | ||
859 | ``` | ||
860 | |||
861 | ``` | ||
769 | ``` | 862 | ``` |
770 | 863 | ||
771 | ::: notes | 864 | ::: notes |
@@ -782,7 +875,8 @@ Type=simple | |||
782 | 875 | ||
783 | ## Adding yourself to the environment---Environment variables | 876 | ## Adding yourself to the environment---Environment variables |
784 | 877 | ||
785 | ``` | 878 | ```{=latex} |
879 | \begin{minted}{console} | ||
786 | $ echo $PATH | 880 | $ echo $PATH |
787 | /home/minijackson/bin: | 881 | /home/minijackson/bin: |
788 | /run/wrappers/bin: | 882 | /run/wrappers/bin: |
@@ -790,6 +884,10 @@ $ echo $PATH | |||
790 | /etc/profiles/per-user/minijackson/bin: | 884 | /etc/profiles/per-user/minijackson/bin: |
791 | /nix/var/nix/profiles/default/bin: | 885 | /nix/var/nix/profiles/default/bin: |
792 | /run/current-system/sw/bin | 886 | /run/current-system/sw/bin |
887 | \end{minted} | ||
888 | ``` | ||
889 | |||
890 | ``` | ||
793 | ``` | 891 | ``` |
794 | 892 | ||
795 | ::: notes | 893 | ::: notes |
@@ -828,11 +926,16 @@ Introducing: the module system! | |||
828 | 926 | ||
829 | . . . | 927 | . . . |
830 | 928 | ||
831 | ```nix | 929 | ```{=latex} |
930 | \begin{minted}{nix} | ||
832 | { ... }: | 931 | { ... }: |
833 | { | 932 | { |
834 | services.openssh.enable = true; | 933 | services.openssh.enable = true; |
835 | } | 934 | } |
935 | \end{minted} | ||
936 | ``` | ||
937 | |||
938 | ``` | ||
836 | ``` | 939 | ``` |
837 | 940 | ||
838 | ::: notes | 941 | ::: notes |
@@ -860,18 +963,24 @@ Introducing: the module system! | |||
860 | 963 | ||
861 | ## Being pedantic | 964 | ## Being pedantic |
862 | 965 | ||
863 | ```nix | 966 | ```{=latex} |
967 | \begin{minted}{nix} | ||
864 | { ... }: | 968 | { ... }: |
865 | { | 969 | { |
866 | fileSystems."/".fsType = "tmpfs"; | 970 | fileSystems."/".fsType = "tmpfs"; |
867 | boot.loader.grub.enable = false; | 971 | boot.loader.grub.enable = false; |
868 | services.openssh.enable = true; | 972 | services.openssh.enable = true; |
869 | } | 973 | } |
974 | \end{minted} | ||
975 | ``` | ||
976 | |||
977 | ``` | ||
870 | ``` | 978 | ``` |
871 | 979 | ||
872 | ## Customizing the SSH server config | 980 | ## Customizing the SSH server config |
873 | 981 | ||
874 | ```nix | 982 | ```{=latex} |
983 | \begin{minted}{nix} | ||
875 | { ... }: | 984 | { ... }: |
876 | { | 985 | { |
877 | services.openssh = { | 986 | services.openssh = { |
@@ -884,6 +993,10 @@ Introducing: the module system! | |||
884 | ''; | 993 | ''; |
885 | } | 994 | } |
886 | } | 995 | } |
996 | \end{minted} | ||
997 | ``` | ||
998 | |||
999 | ``` | ||
887 | ``` | 1000 | ``` |
888 | 1001 | ||
889 | ::: notes | 1002 | ::: notes |
@@ -896,7 +1009,8 @@ Introducing: the module system! | |||
896 | 1009 | ||
897 | ## Customizing the SSH server config | 1010 | ## Customizing the SSH server config |
898 | 1011 | ||
899 | ```nix | 1012 | ```{=latex} |
1013 | \begin{minted}{nix} | ||
900 | { ... }: | 1014 | { ... }: |
901 | { | 1015 | { |
902 | services.openssh = { | 1016 | services.openssh = { |
@@ -909,6 +1023,7 @@ Introducing: the module system! | |||
909 | ]; | 1023 | ]; |
910 | } | 1024 | } |
911 | } | 1025 | } |
1026 | \end{minted} | ||
912 | ``` | 1027 | ``` |
913 | 1028 | ||
914 | ::: notes | 1029 | ::: notes |
@@ -925,7 +1040,8 @@ Introducing: the module system! | |||
925 | 1040 | ||
926 | ## More examples | 1041 | ## More examples |
927 | 1042 | ||
928 | ```nix | 1043 | ```{=latex} |
1044 | \begin{minted}{nix} | ||
929 | { ... }: | 1045 | { ... }: |
930 | { | 1046 | { |
931 | systemd.services.myService = { | 1047 | systemd.services.myService = { |
@@ -938,6 +1054,7 @@ Introducing: the module system! | |||
938 | }; | 1054 | }; |
939 | }; | 1055 | }; |
940 | } | 1056 | } |
1057 | \end{minted} | ||
941 | ``` | 1058 | ``` |
942 | 1059 | ||
943 | ::: notes | 1060 | ::: notes |
@@ -956,7 +1073,8 @@ Introducing: the module system! | |||
956 | 1073 | ||
957 | ## Moaaar examples | 1074 | ## Moaaar examples |
958 | 1075 | ||
959 | ```nix | 1076 | ```{=latex} |
1077 | \begin{minted}{nix} | ||
960 | { ... }: | 1078 | { ... }: |
961 | { | 1079 | { |
962 | containers = { | 1080 | containers = { |
@@ -971,11 +1089,16 @@ Introducing: the module system! | |||
971 | }; | 1089 | }; |
972 | }; | 1090 | }; |
973 | } | 1091 | } |
1092 | \end{minted} | ||
1093 | ``` | ||
1094 | |||
1095 | ``` | ||
974 | ``` | 1096 | ``` |
975 | 1097 | ||
976 | ## Composition | 1098 | ## Composition |
977 | 1099 | ||
978 | ```nix | 1100 | ```{=latex} |
1101 | \begin{minted}{nix} | ||
979 | { ... }: | 1102 | { ... }: |
980 | { | 1103 | { |
981 | imports = [ | 1104 | imports = [ |
@@ -984,11 +1107,16 @@ Introducing: the module system! | |||
984 | ./usecases/web-interface.nix | 1107 | ./usecases/web-interface.nix |
985 | ]; | 1108 | ]; |
986 | } | 1109 | } |
1110 | \end{minted} | ||
1111 | ``` | ||
1112 | |||
1113 | ``` | ||
987 | ``` | 1114 | ``` |
988 | 1115 | ||
989 | ## "Overridability"---Provided | 1116 | ## "Overridability"---Provided |
990 | 1117 | ||
991 | ```nix | 1118 | ```{=latex} |
1119 | \begin{minted}{nix} | ||
992 | { ... }: | 1120 | { ... }: |
993 | { | 1121 | { |
994 | hardware.bluetooth = { | 1122 | hardware.bluetooth = { |
@@ -996,11 +1124,16 @@ Introducing: the module system! | |||
996 | package = myBluezFork; | 1124 | package = myBluezFork; |
997 | }; | 1125 | }; |
998 | } | 1126 | } |
1127 | \end{minted} | ||
1128 | ``` | ||
1129 | |||
1130 | ``` | ||
999 | ``` | 1131 | ``` |
1000 | 1132 | ||
1001 | ## "Overridability"---Forced | 1133 | ## "Overridability"---Forced |
1002 | 1134 | ||
1003 | ```nix | 1135 | ```{=latex} |
1136 | \begin{minted}{nix} | ||
1004 | { lib, ... }: | 1137 | { lib, ... }: |
1005 | { | 1138 | { |
1006 | services.unbound.enable = true; | 1139 | services.unbound.enable = true; |
@@ -1009,17 +1142,26 @@ Introducing: the module system! | |||
1009 | systemd.services.unbound.serviceConfig.ProtectSystem = | 1142 | systemd.services.unbound.serviceConfig.ProtectSystem = |
1010 | lib.mkForce false; | 1143 | lib.mkForce false; |
1011 | } | 1144 | } |
1145 | \end{minted} | ||
1146 | ``` | ||
1147 | |||
1148 | ``` | ||
1012 | ``` | 1149 | ``` |
1013 | 1150 | ||
1014 | ## "Overridability"---Commando mode | 1151 | ## "Overridability"---Commando mode |
1015 | 1152 | ||
1016 | ```nix | 1153 | ```{=latex} |
1154 | \begin{minted}{nix} | ||
1017 | { ... }: | 1155 | { ... }: |
1018 | { | 1156 | { |
1019 | nixpkgs.overlays = [ (self: super: { | 1157 | nixpkgs.overlays = [ (self: super: { |
1020 | bluez = myBluezFork; | 1158 | bluez = myBluezFork; |
1021 | } ) ]; | 1159 | } ) ]; |
1022 | } | 1160 | } |
1161 | \end{minted} | ||
1162 | ``` | ||
1163 | |||
1164 | ``` | ||
1023 | ``` | 1165 | ``` |
1024 | 1166 | ||
1025 | Otherwise, you can just copy and edit the official module file. | 1167 | Otherwise, you can just copy and edit the official module file. |
@@ -1033,10 +1175,15 @@ Otherwise, you can just copy and edit the official module file. | |||
1033 | 1175 | ||
1034 | ## Assertions | 1176 | ## Assertions |
1035 | 1177 | ||
1036 | ``` | 1178 | ```{=latex} |
1179 | \begin{minted}{text} | ||
1037 | Failed assertions: | 1180 | Failed assertions: |
1038 | - services.xserver.xkbOptions = "eurosign:e" is useless on fr/ch | 1181 | - services.xserver.xkbOptions = "eurosign:e" is useless on fr/ch |
1039 | layouts and plays badly with bépo | 1182 | layouts and plays badly with bépo |
1183 | \end{minted} | ||
1184 | ``` | ||
1185 | |||
1186 | ``` | ||
1040 | ``` | 1187 | ``` |
1041 | 1188 | ||
1042 | # The embedded world | 1189 | # The embedded world |
@@ -1045,7 +1192,8 @@ Failed assertions: | |||
1045 | 1192 | ||
1046 | <https://github.com/illegalprime/nixos-on-arm> | 1193 | <https://github.com/illegalprime/nixos-on-arm> |
1047 | 1194 | ||
1048 | ```nix | 1195 | ```{=latex} |
1196 | \begin{minted}{nix} | ||
1049 | { ... }: | 1197 | { ... }: |
1050 | { | 1198 | { |
1051 | imports = [ | 1199 | imports = [ |
@@ -1053,12 +1201,18 @@ Failed assertions: | |||
1053 | <image> | 1201 | <image> |
1054 | ]; | 1202 | ]; |
1055 | } | 1203 | } |
1204 | \end{minted} | ||
1056 | ``` | 1205 | ``` |
1057 | 1206 | ||
1058 | ``` | 1207 | ```{=latex} |
1208 | \begin{minted}{console} | ||
1059 | $ nix build -f default.nix \ | 1209 | $ nix build -f default.nix \ |
1060 | -I machine=./machines/MY_BOARD \ | 1210 | -I machine=./machines/MY_BOARD \ |
1061 | -I image=./images/MY_CONFIGURATION | 1211 | -I image=./images/MY_CONFIGURATION |
1212 | \end{minted} | ||
1213 | ``` | ||
1214 | |||
1215 | ``` | ||
1062 | ``` | 1216 | ``` |
1063 | 1217 | ||
1064 | ## TODO | 1218 | ## TODO |