Fireship · @fireship

Nix in 100 Seconds

Uploaded August 21, 2024 · Length 3:33

Nix in 100 Seconds

Summary

Nix package manager explained in 100 seconds: reproducible, declarative, and transactional system configuration.

  • nix package manager
  • nixos
  • declarative configuration
  • reproducible builds
  • linux distro

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    NYX a purely functional package manager

  2. 0:02

    and system configuration tool that

  3. 0:04

    allows developers to say it works on my

  4. 0:06

    machine with absolute confidence it was

  5. 0:09

    created in 2003 by eel cdra who wrote

  6. 0:12

    his PhD thesis on a purely functional

  7. 0:14

    software deployment model 20 years later

  8. 0:16

    it's used by tons of software projects

  9. 0:18

    like Mozilla Firefox Google's idx and of

  10. 0:21

    course NYX OS a complete Linux distro

  11. 0:24

    based on this package manager but why

  12. 0:26

    NYX when you set up your own Linux

  13. 0:28

    server the default approach is to sh

  14. 0:30

    into it and start running a bunch of

  15. 0:31

    commands that you copied from random

  16. 0:33

    places on the internet the problem is

  17. 0:35

    that it quickly becomes impossible to

  18. 0:36

    reproduce the state of your machine and

  19. 0:38

    if you mess something up there's no undo

  20. 0:40

    button NYX users don't have these

  21. 0:42

    problems because it provides its own

  22. 0:43

    declarative language to Define packages

  23. 0:46

    network settings the file system

  24. 0:48

    environment variables users and

  25. 0:50

    everything else you need in a NX file

  26. 0:52

    this file is like a blueprint that can

  27. 0:53

    now reproduce the same machine over and

  28. 0:55

    over again now any changes to this

  29. 0:57

    config are transactional or atomic

  30. 0:59

    meaning everything succeeds or fails

  31. 1:02

    together a huge advantage of that is

  32. 1:03

    when you screw something up you can

  33. 1:05

    easily roll back to the previous state

  34. 1:07

    it's like having a time machine for your

  35. 1:08

    machine this is possible because in the

  36. 1:10

    nyck store each package and its

  37. 1:12

    dependencies are stored in a separate

  38. 1:14

    directory identified by a unique

  39. 1:16

    cryptographic hash which guarantees that

  40. 1:18

    packages won't interfere with each other

  41. 1:20

    and with Nick shell you can create

  42. 1:21

    unique environments for all of your

  43. 1:23

    projects that means side by-side

  44. 1:25

    installation for all of your tools in

  45. 1:27

    their different versions without the

  46. 1:28

    need for version managers like NVM

  47. 1:30

    virtual EnV or rust up because it's all

  48. 1:33

    declarative and deterministic you can

  49. 1:34

    organize your configs as Flakes and then

  50. 1:36

    trade them with your friends like their

  51. 1:38

    Pokémon cards to get started install the

  52. 1:40

    Nyx package manager or better yet live

  53. 1:42

    boot NYX OS to try it out as a full

  54. 1:44

    Linux drro inside the ETC directory

  55. 1:47

    you'll find a configuration.nix file you

  56. 1:49

    can think of this file as a function

  57. 1:51

    that returns a dictionary or hashmap at

  58. 1:53

    the top we have parameters for config

  59. 1:55

    which gives us access to the entire

  60. 1:57

    configuration and packages which

  61. 1:59

    includes all theack packages available