summaryrefslogtreecommitdiffstats
path: root/slides.md
diff options
context:
space:
mode:
Diffstat (limited to 'slides.md')
-rw-r--r--slides.md132
1 files changed, 132 insertions, 0 deletions
diff --git a/slides.md b/slides.md
index f190e85..9d8774b 100644
--- a/slides.md
+++ b/slides.md
@@ -517,6 +517,10 @@ echo 'Hello, World!'
517 517
518::: 518:::
519 519
520## Overlays
521
522TODO
523
520## Using different versions of the same package---Generic 524## Using different versions of the same package---Generic
521 525
522```bash 526```bash
@@ -770,6 +774,114 @@ Introducing: the module system!
770 774
771::: 775:::
772 776
777## More examples
778
779```nix
780{ ... }:
781{
782 systemd.services.myService = {
783 description = "My really awesome service";
784 wantedBy = [ "multi-user.target" ];
785 after = [ "network.target" ];
786 serviceConfig = {
787 ExecStart = "${myPackage}/bin/myExec";
788 DynamicUser = true;
789 };
790 };
791}
792```
793
794::: notes
795
796- In the previous example, the openssh module created a systemd service for us.
797 Now we create or own systemd service.
798- In fact the openssh module will (in part) "modify" the systemd module.
799- And in turn, the systemd module will "modify" the module that sets up `/etc`.
800- There is no defined "order" / "hierarchy" of modules, the laziness of the Nix
801 language permits that (this can theoretically lead to infinite loops).
802- So really, the Nix language does this in reverse (activation script -> `/etc`
803 -> systemd -> openssh -> maybe higher level concepts)
804
805
806:::
807
808## Moaaar examples
809
810```nix
811{ ... }:
812{
813 containers = {
814 myContainer = {
815 config = { ... }: { services.postgresql.enable = true; };
816 };
817 myOtherContainer = {
818 config = { ... }: { services.nginx.enable = true; };
819 forwardPorts = [
820 { containerPort = 80; hostPort = 8080; protocol = "tcp"; }
821 ];
822 };
823 };
824}
825```
826
827## Composition
828
829```nix
830{ ... }:
831{
832 imports = [
833 ./hardware-configuration.nix
834 ./usecases/ssh-server.nix
835 ./usecases/web-interface.nix
836 ];
837}
838```
839
840## "Overridability"---Provided
841
842```nix
843{ ... }:
844{
845 hardware.bluetooth = {
846 enable = true;
847 package = myBluezFork;
848 };
849}
850```
851
852## "Overridability"---Forced
853
854```nix
855{ lib, ... }:
856{
857 services.unbound.enable = true;
858 # These tricks are done by "professionals".
859 # Don't try this at home
860 systemd.services.unbound.serviceConfig.ProtectSystem =
861 lib.mkForce false;
862}
863```
864
865## "Overridability"---Commando mode
866
867```nix
868{ ... }:
869{
870 nixpkgs.overlays = [ (self: super: {
871 bluez = myBluezFork;
872 } ) ];
873}
874```
875
876Otherwise, you can just copy and edit the official module file.
877
878::: notes
879
880- Changing things in overlays also changes packages dependencies, which in the
881 case of Bluez, there are quite a lot.
882
883:::
884
773## Assertions 885## Assertions
774 886
775``` 887```
@@ -780,6 +892,26 @@ Failed assertions:
780 892
781# The embedded world 893# The embedded world
782 894
895## Proper project structure
896
897<https://github.com/illegalprime/nixos-on-arm>
898
899```nix
900{ ... }:
901{
902 imports = [
903 <machine>
904 <image>
905 ];
906}
907```
908
909```
910$ nix build -f default.nix \
911 -I machine=./machines/MY_BOARD \
912 -I image=./images/MY_CONFIGURATION
913```
914
783## TODO 915## TODO
784 916
785- [x] Use good Markdown / Beamer template 917- [x] Use good Markdown / Beamer template