From 45b59c867260c8899a27631548e5e680ce447668 Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Sun, 8 Oct 2023 13:29:27 +0100 Subject: [PATCH] feat: slides for this evening --- src/slides/skynet/2_nix.md | 163 +++++++++++++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 src/slides/skynet/2_nix.md diff --git a/src/slides/skynet/2_nix.md b/src/slides/skynet/2_nix.md new file mode 100644 index 0000000..4fd5f71 --- /dev/null +++ b/src/slides/skynet/2_nix.md @@ -0,0 +1,163 @@ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +title = "Skynet: Nix" +date = 2023-10-08 +slides = false +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +# *nix, Nix and Nixos + +---------------------------------------------------------------------------- + +## *nix + +---------------------------------------------------------------------------- + +Skynet runs on a flavor of Linux called NixOS + +---------------------------------------------------------------------------- + +Normal linux commands apply (basic primer) + +---------------------------------------------------------------------------- + +``cd`` - change directory + +---------------------------------------------------------------------------- + +``mkdir`` - make directory + +---------------------------------------------------------------------------- + +``ls`` - list directory + +---------------------------------------------------------------------------- + +``touch {filename}`` - create file named {filename} + +---------------------------------------------------------------------------- + +``nano {filename}`` - edit {filename} + +---------------------------------------------------------------------------- + +``history`` - view history of previous commands + +---------------------------------------------------------------------------- + +``grep "{query}" {filename/path}`` - find {query} in a file + +---------------------------------------------------------------------------- + +There is also piping where the output of one command is piped into another command + +---------------------------------------------------------------------------- + +Often called [Unix philosophy][1] + +---------------------------------------------------------------------------- + +Can make really powerful programs from smaller simple programs. + +---------------------------------------------------------------------------- + +``history | grep "nano"`` - search the history for any mention of ``nano`` + +---------------------------------------------------------------------------- + +## Nix + +---------------------------------------------------------------------------- + +Nix is a (lazy) functional language + +---------------------------------------------------------------------------- + +```nix +a = 1 # int +b = 1.001 # float +c = /path/to/thing # path +d = "42" # string +e = true # boolean +``` + +---------------------------------------------------------------------------- + +```nix +double = x: x*2 +mul = a: b: a*b + +double 2 +mul 2 3 +``` + +---------------------------------------------------------------------------- + +```nix +s = { foo = "bar"; biz = "baz"; } +s.foo # bar +s.biz # baz +``` + +---------------------------------------------------------------------------- + +Info: +1. [Offical guide][2] +2. [Nix Pills][3] + +---------------------------------------------------------------------------- + +## NixOS + +---------------------------------------------------------------------------- + +Some crazy person saw Nix and thought "I want to make an OS with that" + +---------------------------------------------------------------------------- + +In essence a giant function is created with an OS as the output + +---------------------------------------------------------------------------- + +This does have quite a few advantages + +---------------------------------------------------------------------------- + +* Config as Code +* Deterministic +* Reproducible + +---------------------------------------------------------------------------- + +Skynet 2.0 had its config spread across different servers making it hard to get a good overview + +---------------------------------------------------------------------------- + +Skynet 3.0 is fully source controlled on [gitlab.skynet.ie][4] + +---------------------------------------------------------------------------- + +Deterministic and Reproducible go hand in hand. + +---------------------------------------------------------------------------- + +Deterministic means that for the same inputs you get the same output. + +---------------------------------------------------------------------------- + +Reproducible is that you are able to create the same output from the source code. + +---------------------------------------------------------------------------- + +We use Flakes, which adds a lockfile, reduces hassle for the dev. + +---------------------------------------------------------------------------- + +Questions? + +---------------------------------------------------------------------------- + + +[1]: https://en.wikipedia.org/wiki/Unix_philosophy +[2]: https://nix.dev/tutorials/first-steps/ +[3]: https://nixos.org/guides/nix-pills/# +[4]: https://gitlab.skynet.ie/compsoc1/skynet/nixos \ No newline at end of file