Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Nix/NixOS

Sibi
January 08, 2022

 Nix/NixOS

Sibi

January 08, 2022
Tweet

More Decks by Sibi

Other Decks in Technology

Transcript

  1. NIX/NIXOS
    ILUGC
    Sibi Prabakaran
    Jan 8, 2022

    View Slide

  2. View Slide

  3. AGENDA
    My experience with Nix/NixOS
    Introduction
    Why Nix

    View Slide

  4. MY EXPERIENCE
    Tried NixOS around 5 years ago
    Initially used nixpkgs in Ubuntu
    For around ~1.5 years
    Using NixOS for ~ 1 year
    Maintainer of various packages

    View Slide

  5. NIX/NIXPKGS/NIXOS
    Nix:
    Pure, lazy functional language.
    Not a general purpose language!
    Used for package description, composition
    Nixpkgs: Collection of packages.
    NixOS:
    Linux + nixpkgs
    System configuration also managed via Nix

    View Slide

  6. WHY NIX/NIXOS
    Reproducibility
    bit identical
    Multiple versions of a software
    Atomic upgrades and rollbacks
    Declarative

    View Slide

  7. BASIC WORKFLOW
    configuration.nix
    home manager
    writing script
    Usage is pretty similar to other distros.

    View Slide

  8. NIX LANGUAGE
    Lazy, Functional and Pure
    Functions, Sets, Lists etc.
    Reference:
    https://nixos.wiki/wiki/Nix_Expression_Language

    View Slide

  9. NIX EXPRESSION
    Code written in Nix language
    ❯ nix-instantiate --eval --expr "2 + 2"

    4

    ❯ cat example.nix

    2 + 2

    ❯ nix-instantiate --eval example.nix

    4

    View Slide

  10. REAL WORLD NIX
    CODE
    Package:
    systemd service:
    amber
    cnx

    View Slide

  11. NIX DERIVATIONS
    Recipe to build the end product.
    Reproducible & Deterministic
    ❯ fd -e drv nix /nix/store | head -n 5

    /nix/store/ix9j7fmxpfp7c0b2rn95wyy5y1803mya-nixos-
    manual.desktop.drv
    /nix/store/2a6ylyfsxb8knnana40fbnmk8ka7q1na-etc-
    nixos.conf.drv
    /nix/store/6r57mn57p9rgijr0lsfihkdkk2djkv86-nixos-
    manpages.drv
    /nix/store/ppsdnzviyi9q2xqak9qk0w16hpj30frj-nixos.conf.drv

    /nix/store/bp7flklzjxhm966b0d0pxi85dg4zbqpa-nix-prefetch-
    cvs.drv

    View Slide

  12. DERVIATION..
    ❯ nix show-derivation derivation

    View Slide

  13. COMMUNITY
    80,000 packages
    Easy to add package as compared to other
    distributions
    Images available for cloud providers
    nix-community organization

    View Slide

  14. DISADVANTAGES
    No secure boot.
    Nix specific issues!
    Learning curve
    Debugging experience
    Size of user community
    Things are still changing: Flakes!

    View Slide

  15. QUESTIONS

    View Slide