declarative-talk/presentation.md

227 lines
4.4 KiB
Markdown
Raw Permalink Normal View History

2023-09-29 04:06:07 +00:00
---
marp: true
2023-09-29 13:58:28 +00:00
title: Declarative Distributions
description: Declarative Distributions
2023-09-29 04:06:07 +00:00
theme: uncover
class:
- invert
transition: fade
paginate: true
---
# <!--fit--> Declarative Distros
2023-09-29 04:06:07 +00:00
![bg right 80%](nix.png)
![bg right 80%](guix.png)
---
2023-09-29 19:28:02 +00:00
# Quick Disclaimer
2023-09-29 04:06:07 +00:00
We are both GNU Guix Users
While we will try to talk about generalities of declarative operating system paradigms, Guix and Nix specific things, etc, we may get some Nix (and even Guix) things wrong.
---
# What is a Declarative Distro?
### What does it mean?
---
- A operating system defined by configuration
2023-09-29 04:24:16 +00:00
- Without state
- System is reproducible
---
2023-09-29 13:46:45 +00:00
# Declarative v. Imperative
- Most distros are imperative
- You give them commands to get a result
- Nix and Guix are declarative
- You define a wanted end state and Guix/Nix gets you there its way
---
2023-09-29 04:24:16 +00:00
# Reproducible
- Systems have a given configuration
2023-09-29 14:09:11 +00:00
- Configuration can produce identical systems
- If you pin versions, you can make your system completely reproducible
2023-09-29 04:54:41 +00:00
- Everything is isolated
2023-09-29 04:24:16 +00:00
---
# Reproducible
![w:25em](diagram.png)
2023-09-29 04:54:41 +00:00
---
# Isolation
- Packages are built in isolated packages
- No random spare files in file system
- Anything not being used by a profile is eligible for garbage-collection
2023-09-29 04:54:41 +00:00
- All state is containted
- Preserves state-less root
2023-09-29 14:09:11 +00:00
- Can be further extended to your home directory
2023-09-29 04:54:41 +00:00
---
# Stability
- Reproducibility and Isolation ensure the ability to rollback
- Always have some working system state
- Since any transaction is atomic, it either works or doesn't
- Your system will never be left in a half updated state that is difficult to recover
2023-09-29 14:09:11 +00:00
- When updating, the actual "commit" is changing a symlink around
2023-09-29 04:54:41 +00:00
---
# NixOS
- Released Jun 2003
- Eelco Dolstra
- Nix package manager (nix)
- Nix language
- Systemd
2023-09-29 13:46:45 +00:00
- Wrote like an entire research paper on the theory behind Nix
2023-09-29 04:54:41 +00:00
![bg left 40%](nix.png)
---
# Guix
- Released 2012
- Forked from Nix
- Guix package manager (guix)
- GNU Guile (scheme/lisp)
- GNU Shepherd
- Not GNU/Herd
![bg left 40%](guix.png)
---
# Declarative Package Management
## `nix` and `guix` commands
---
### Declarative Package Management
- Update system repositories
- Build and/or install packages
- Manage `the store`
---
### Distro Store
- Guix `/gnu/store`
- Nix `/nix/store`
- Stores all package and system files
2023-09-29 14:09:11 +00:00
- Contents are based off of configuration
2023-09-29 04:54:41 +00:00
---
2023-09-29 13:58:28 +00:00
### What is the store like?
- Lots of files that look like {hash}-package-version
2023-09-29 14:09:11 +00:00
---
### Example
```
/gnu/store/spxcaq8gnmckhzz9a1wm3qc9dmz5bvsd-gcc-toolchain-12.3.0
```
---
### What is the store like?
2023-09-29 13:58:28 +00:00
- Hash is derived from a build dependency graph
- A program can use any version of a library it needs
- A program build hash is unique, if any dependency changes the hash will as well.
2023-09-29 19:28:02 +00:00
- This means new updates never overwrite old versions
2023-09-29 13:58:28 +00:00
2023-09-29 14:09:11 +00:00
---
### Profile
2023-09-29 04:54:41 +00:00
- Guix `~/.guix-profile`
- Nix `~/.nix-profile`
- Symlink Read only system
- Links store to current profile
- Based off configuration
---
2023-09-29 13:58:28 +00:00
- Store holds system and package files
2023-09-29 04:54:41 +00:00
- Profile links to those files
---
### Multidirection
```bash
$ which gcc
/home/tylerm/.guix-home/profile/bin/gcc # profile
$ readlink /home/tylerm/.guix-home/profile/bin/gcc
/gnu/store/spxcaq8gnmckhzz9a1wm3qc9dmz5bvsd-gcc-toolchain-12.3.0/bin/gcc # store
```
---
## Multiple Profiles
- System Profile (All users)
- Good to contain system needed pacakges
- Graphics drivers
- Zsh
- User Profile (Specific user)
- Good to contain all user data
- Browser
- Applications
- DE/WM
---
## To Build The System
- Package manager takes in user and system configuration
- Downloads needed data into store
2023-09-29 13:46:45 +00:00
- Prebuilt, signed binaries are called "substitutes"
2023-09-29 04:54:41 +00:00
- Build any needed packages
2023-09-29 13:23:51 +00:00
- Symlinks the user and system profiles
---
## Temporary Packages
- Nix and Guix allow installing packages temporarily
- Uses contained environment
- `guix shell <package>`
- `nix shell -p <package>`
2023-09-29 13:46:45 +00:00
---
2023-09-29 13:58:28 +00:00
## What is a package?
2023-09-29 13:46:45 +00:00
2023-09-29 13:58:28 +00:00
- Since Nix and Scheme are functional, packages are immutable pure functions
- They define everything from:
- Inputs
- Dependencies
- Expected Outputs
- Build environment
- Builds are completely isolated from one another
- You cannot forget to define a dependency
2023-09-29 19:28:02 +00:00
- You can guarantee that package will build for everyone once you get it working
- Also means everyone can reproduce the same bugs as you