SlideShare a Scribd company logo
NIXNIX
SAME; SAMESAME; SAME NOTNOT DIFFERENTDIFFERENT
@Keidrych Anton@Keidrych Anton
REMINDER:REMINDER:
DEPENDENCY HELLDEPENDENCY HELL
“When people stop valuing simplicity over complexity“When people stop valuing simplicity over complexity
~ Barbara Liskov”~ Barbara Liskov”
SOLVEDSOLVED
via Atomicity / Transactionalityvia Atomicity / Transactionality
via System Rollback / Versioningvia System Rollback / Versioning
Provided Atomicity / Transactionality existsProvided Atomicity / Transactionality exists
State of system is justState of system is just versioned snapshotsversioned snapshots
Package manager = transition functionPackage manager = transition function
betweenbetween snapshotssnapshots
WHY SO MUCH PAIN?WHY SO MUCH PAIN?
Filesystem Hierarchy Standard (FHS) - via Linux -Filesystem Hierarchy Standard (FHS) - via Linux -
fundamentally incompatible with reproducibilityfundamentally incompatible with reproducibility
Version?Version?
Libraries used?Libraries used?
Flags during build?Flags during build?
NIXNIX
“NIX can be the future of computing… if we can nd a“NIX can be the future of computing… if we can nd a
better way to explain it ~ Burke Libbey”better way to explain it ~ Burke Libbey”
EXPLAININGEXPLAINING
Maintenance / Upgrading a carMaintenance / Upgrading a car
Debian et al: Working on your car in yourDebian et al: Working on your car in your
own garage… results can varyown garage… results can vary
NIX: 3D Printing a new car every timeNIX: 3D Printing a new car every time
something changessomething changes
SDLC NIRVANASDLC NIRVANA
Same Dev Environment for all DevelopersSame Dev Environment for all Developers
Same CI Environment for all jobsSame CI Environment for all jobs
Not Di erent Code Paths in ProductionNot Di erent Code Paths in Production
&&&& CompliantCompliant12 Factor12 Factor GitOpsGitOps
SDLC NIRVANASDLC NIRVANA
IsolateIsolate directorydirectory from OS via Shellfrom OS via Shell
Install DependenciesInstall Dependencies
BuildBuild
RunRun
Debug ToolingDebug Tooling
Enable Development ModeEnable Development Mode
1:1:
— DirEnv - unclutter your .pro le
DIRENVDIRENV
[direnv] augments existing shells with a[direnv] augments existing shells with a
new feature that can load and unloadnew feature that can load and unload
environment variables depending onenvironment variables depending on
the current directory.the current directory.
ENABLEENABLE
viavia nix env i nixpkgs.direnvnix env i nixpkgs.direnv
~/.bashrc
.envrc
RunRun direnv allowdirenv allow rst time entering directoryrst time entering directory
# Add as last shell manipulation at end of file
eval "$(direnv hook bash)"
use nix
watch_file shell.nix
2:2:
Development replacement forDevelopment replacement for nix shellnix shell
Tracks Global Nix Channel updatesTracks Global Nix Channel updates
Protects directory from premature GarbageProtects directory from premature Garbage
CollectionCollection
Editor Integration via DirEnvEditor Integration via DirEnv
LORRILORRI
ENABLEENABLE
viavia nix env i lorrinix env i lorri
Foreground:Foreground: lorri watchlorri watch
Daemon:Daemon:
services.lorri.enable = trueservices.lorri.enable = true
lorri initlorri init
shell.nix
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
buildInputs = [
pkgs.hello
# keep this line if you use bash
pkgs.bashInteractive
];
}
.envrc
eval "$(lorri direnv)"
3: DEPENDENCIES3: DEPENDENCIES
Option(s)Option(s)
Channels:Channels: nix channelnix channel - Users subscribe- Users subscribe
to your/to your/nixpkgsnixpkgs latest published updateslatest published updates
fetchX:fetchX: ||||
Nix:Nix: - New World -- New World - stabilizingstabilizing --
Hermetic & reproducible evaluationHermetic & reproducible evaluation
nivniv nix-wranglenix-wrangle
Nix FlakesNix Flakes
FETCHXFETCHX
/nix/default.nix
let
sources = import ./sources.nix;
callPackage = (import sources.nixpkgs {}).callPackage;
in
import sources.nixpkgs {
overlays = [
(
final: prev: {
dockerTools = (import sources.pinnedDockerTools {}).docke
k6 = prev.k6.overrideAttrs (
old: {
name = "patched-k6-${old.version}";
src = sources.k6;
}
);
s6-overlay = sources.s6-overlay;
shell.nix
Update to latest SHA of Git Branches viaUpdate to latest SHA of Git Branches via
{ pkgs ? import ./nix }:
with pkgs;
mkShell rec
{
name = "impureEnv";
buildInputs = [ hello ];
}
niv update
SAME (NOT) SAMESAME (NOT) SAME
Build:Build: nix buildnix build
Run:Run: nix shell (execute binary)nix shell (execute binary)
Debug Tooling: bundled viaDebug Tooling: bundled via shell.nixshell.nix
Dev Mode: viaDev Mode: via direnv / lorridirenv / lorri
Hermetic:Hermetic: maybemaybe
FLAKESFLAKES
— https://github.com/NixOS/rfcs/pull/49
Flakes allow hermetic, reproducibleFlakes allow hermetic, reproducible
evaluation of multi-repository Nixevaluation of multi-repository Nix
projects; impose a discoverable,projects; impose a discoverable,
standard structure on Nix projects; andstandard structure on Nix projects; and
replace previous mechanisms such asreplace previous mechanisms such as
Nix channels and the Nix search pathNix channels and the Nix search path
Runnable applicationsRunnable applications nix (name)nix (name)
Tests stdout = stdoutTests stdout = stdout
NixOS ModulesNixOS Modules
CI Linked build to publish versionsCI Linked build to publish versions
to Nix 1.xto Nix 1.x
Cachix integratedCachix integrated
BackportedBackported
Flake UtilsFlake Utils
ake.nix
Update to latest SHA of Git Branches viaUpdate to latest SHA of Git Branches via
{
description = "impureEnv";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nixpkgs.url = "github:NixOS/nixpkgs-channels?rev=72b9660
inputs.pinnedDockerTools.url = "github:xxxxx";
inputs.pinnedDockerTools.flake = false;
# s6-overlay & k6 same process as dockerTools
outputs = { self, nixpkgs, flake-utils }:
let
overlay = final: prev: {
dockerTools = (import pinnedDockerTools {}).dockerTools;
k6 = prev.k6.overrideAttrs (
old: {
name = "patched-k6-${old.version}";
nix flake update --recreate-lock-file
SAME (NOT) SAMESAME (NOT) SAME
Build:Build: nix buildnix build
Run:Run: nix developnix develop
Debug Tooling: bundled viaDebug Tooling: bundled via shell.nixshell.nix
Dev Mode: viaDev Mode: via direnv / lorridirenv / lorri
Hermetic: alwaysHermetic: always

More Related Content

PDF
PDF
Understanding LXC & Docker
PDF
Rebuild - Simplifying Embedded and IoT Development Using Linux Containers
PDF
Docker: the road ahead
PDF
Containers technologies
PDF
Linux Container Technology 101
PPTX
PDF
Evoluation of Linux Container Virtualization
Understanding LXC & Docker
Rebuild - Simplifying Embedded and IoT Development Using Linux Containers
Docker: the road ahead
Containers technologies
Linux Container Technology 101
Evoluation of Linux Container Virtualization

What's hot (20)

PPTX
KVM and docker LXC Benchmarking with OpenStack
PDF
Docker 1.11 Meetup: Containerd and runc, by Arnaud Porterie and Michael Crosby
PDF
Intro to containerization
PDF
Lxc- Introduction
PDF
How Secure Is Your Container? ContainerCon Berlin 2016
PDF
Docker introduction
PDF
Docker 101 @KACST Saudi HPC 2016
PDF
Docker Introduction
PDF
Unikernels: Rise of the Library Hypervisor
PDF
Advanced Docker Developer Workflows on MacOS X and Windows
PPTX
Linux Container Brief for IEEE WG P2302
PDF
runC: The little engine that could (run Docker containers) by Docker Captain ...
PPTX
Cgroups, namespaces and beyond: what are containers made from?
PDF
Lxc- Linux Containers
PDF
PaaSTA: Running applications at Yelp
PDF
Introduction to OCI Image Technologies Serving Container
PPTX
Docker introduction
PDF
Docker 原理與實作
PDF
Real-World Docker: 10 Things We've Learned
PPTX
Lxc – next gen virtualization for cloud intro (cloudexpo)
KVM and docker LXC Benchmarking with OpenStack
Docker 1.11 Meetup: Containerd and runc, by Arnaud Porterie and Michael Crosby
Intro to containerization
Lxc- Introduction
How Secure Is Your Container? ContainerCon Berlin 2016
Docker introduction
Docker 101 @KACST Saudi HPC 2016
Docker Introduction
Unikernels: Rise of the Library Hypervisor
Advanced Docker Developer Workflows on MacOS X and Windows
Linux Container Brief for IEEE WG P2302
runC: The little engine that could (run Docker containers) by Docker Captain ...
Cgroups, namespaces and beyond: what are containers made from?
Lxc- Linux Containers
PaaSTA: Running applications at Yelp
Introduction to OCI Image Technologies Serving Container
Docker introduction
Docker 原理與實作
Real-World Docker: 10 Things We've Learned
Lxc – next gen virtualization for cloud intro (cloudexpo)
Ad

Similar to Nix same; same not different (20)

PDF
The Nix project
PDF
From Zero To Production (NixOS, Erlang) @ Erlang Factory SF 2016
PDF
From Zero to Application Delivery with NixOS
PDF
Functional Operations (Functional Programming at Comcast Labs Connect)
PDF
The Nix project
PDF
The NixOS project and deploying systems declaratively
PDF
CI/CD Using Ansible and Jenkins for Infrastructure
PDF
Automating Mendix application deployments with Nix
PDF
Using NixOS for declarative deployment and testing
PPTX
Perforce on Tour 2015 - DVCS in the Enterprise: Introducing Helix DVCS and Gi...
PDF
Rc094 010d-git 2 - desconocido
PDF
NIX: Absolution From Dependency Hell
PPTX
2015-ghci-presentation-git_gerritJenkins_final
PDF
Enterprise git
PDF
CICD_1670665418.pdf
PDF
Deploy Application Files with Git
PDF
Gitlab ci, cncf.sk
PDF
138-03 Python, Git, GitHub and CI-CD.pdf
PPTX
Git session 1
PPTX
Introduction khgjkhygkjiyhgikjyhgikygkii
The Nix project
From Zero To Production (NixOS, Erlang) @ Erlang Factory SF 2016
From Zero to Application Delivery with NixOS
Functional Operations (Functional Programming at Comcast Labs Connect)
The Nix project
The NixOS project and deploying systems declaratively
CI/CD Using Ansible and Jenkins for Infrastructure
Automating Mendix application deployments with Nix
Using NixOS for declarative deployment and testing
Perforce on Tour 2015 - DVCS in the Enterprise: Introducing Helix DVCS and Gi...
Rc094 010d-git 2 - desconocido
NIX: Absolution From Dependency Hell
2015-ghci-presentation-git_gerritJenkins_final
Enterprise git
CICD_1670665418.pdf
Deploy Application Files with Git
Gitlab ci, cncf.sk
138-03 Python, Git, GitHub and CI-CD.pdf
Git session 1
Introduction khgjkhygkjiyhgikjyhgikygkii
Ad

Recently uploaded (20)

PPTX
Introduction to Artificial Intelligence
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
AI in Product Development-omnex systems
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PPTX
Odoo POS Development Services by CandidRoot Solutions
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
L1 - Introduction to python Backend.pptx
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Introduction to Artificial Intelligence
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Operating system designcfffgfgggggggvggggggggg
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Which alternative to Crystal Reports is best for small or large businesses.pdf
AI in Product Development-omnex systems
Navsoft: AI-Powered Business Solutions & Custom Software Development
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Odoo POS Development Services by CandidRoot Solutions
CHAPTER 2 - PM Management and IT Context
How to Choose the Right IT Partner for Your Business in Malaysia
L1 - Introduction to python Backend.pptx
Wondershare Filmora 15 Crack With Activation Key [2025
PTS Company Brochure 2025 (1).pdf.......
Understanding Forklifts - TECH EHS Solution
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Design an Analysis of Algorithms II-SECS-1021-03
Upgrade and Innovation Strategies for SAP ERP Customers
Design an Analysis of Algorithms I-SECS-1021-03
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025

Nix same; same not different

  • 1. NIXNIX SAME; SAMESAME; SAME NOTNOT DIFFERENTDIFFERENT @Keidrych Anton@Keidrych Anton
  • 2. REMINDER:REMINDER: DEPENDENCY HELLDEPENDENCY HELL “When people stop valuing simplicity over complexity“When people stop valuing simplicity over complexity ~ Barbara Liskov”~ Barbara Liskov”
  • 3. SOLVEDSOLVED via Atomicity / Transactionalityvia Atomicity / Transactionality via System Rollback / Versioningvia System Rollback / Versioning Provided Atomicity / Transactionality existsProvided Atomicity / Transactionality exists State of system is justState of system is just versioned snapshotsversioned snapshots Package manager = transition functionPackage manager = transition function betweenbetween snapshotssnapshots
  • 4. WHY SO MUCH PAIN?WHY SO MUCH PAIN? Filesystem Hierarchy Standard (FHS) - via Linux -Filesystem Hierarchy Standard (FHS) - via Linux - fundamentally incompatible with reproducibilityfundamentally incompatible with reproducibility Version?Version? Libraries used?Libraries used? Flags during build?Flags during build?
  • 5. NIXNIX “NIX can be the future of computing… if we can nd a“NIX can be the future of computing… if we can nd a better way to explain it ~ Burke Libbey”better way to explain it ~ Burke Libbey”
  • 6. EXPLAININGEXPLAINING Maintenance / Upgrading a carMaintenance / Upgrading a car Debian et al: Working on your car in yourDebian et al: Working on your car in your own garage… results can varyown garage… results can vary NIX: 3D Printing a new car every timeNIX: 3D Printing a new car every time something changessomething changes
  • 7. SDLC NIRVANASDLC NIRVANA Same Dev Environment for all DevelopersSame Dev Environment for all Developers Same CI Environment for all jobsSame CI Environment for all jobs Not Di erent Code Paths in ProductionNot Di erent Code Paths in Production &&&& CompliantCompliant12 Factor12 Factor GitOpsGitOps
  • 8. SDLC NIRVANASDLC NIRVANA IsolateIsolate directorydirectory from OS via Shellfrom OS via Shell Install DependenciesInstall Dependencies BuildBuild RunRun Debug ToolingDebug Tooling Enable Development ModeEnable Development Mode
  • 9. 1:1: — DirEnv - unclutter your .pro le DIRENVDIRENV [direnv] augments existing shells with a[direnv] augments existing shells with a new feature that can load and unloadnew feature that can load and unload environment variables depending onenvironment variables depending on the current directory.the current directory.
  • 10. ENABLEENABLE viavia nix env i nixpkgs.direnvnix env i nixpkgs.direnv ~/.bashrc .envrc RunRun direnv allowdirenv allow rst time entering directoryrst time entering directory # Add as last shell manipulation at end of file eval "$(direnv hook bash)" use nix watch_file shell.nix
  • 11. 2:2: Development replacement forDevelopment replacement for nix shellnix shell Tracks Global Nix Channel updatesTracks Global Nix Channel updates Protects directory from premature GarbageProtects directory from premature Garbage CollectionCollection Editor Integration via DirEnvEditor Integration via DirEnv LORRILORRI
  • 12. ENABLEENABLE viavia nix env i lorrinix env i lorri Foreground:Foreground: lorri watchlorri watch Daemon:Daemon: services.lorri.enable = trueservices.lorri.enable = true lorri initlorri init
  • 13. shell.nix { pkgs ? import <nixpkgs> {} }: pkgs.mkShell { buildInputs = [ pkgs.hello # keep this line if you use bash pkgs.bashInteractive ]; }
  • 15. 3: DEPENDENCIES3: DEPENDENCIES Option(s)Option(s) Channels:Channels: nix channelnix channel - Users subscribe- Users subscribe to your/to your/nixpkgsnixpkgs latest published updateslatest published updates fetchX:fetchX: |||| Nix:Nix: - New World -- New World - stabilizingstabilizing -- Hermetic & reproducible evaluationHermetic & reproducible evaluation nivniv nix-wranglenix-wrangle Nix FlakesNix Flakes
  • 16. FETCHXFETCHX /nix/default.nix let sources = import ./sources.nix; callPackage = (import sources.nixpkgs {}).callPackage; in import sources.nixpkgs { overlays = [ ( final: prev: { dockerTools = (import sources.pinnedDockerTools {}).docke k6 = prev.k6.overrideAttrs ( old: { name = "patched-k6-${old.version}"; src = sources.k6; } ); s6-overlay = sources.s6-overlay;
  • 17. shell.nix Update to latest SHA of Git Branches viaUpdate to latest SHA of Git Branches via { pkgs ? import ./nix }: with pkgs; mkShell rec { name = "impureEnv"; buildInputs = [ hello ]; } niv update
  • 18. SAME (NOT) SAMESAME (NOT) SAME Build:Build: nix buildnix build Run:Run: nix shell (execute binary)nix shell (execute binary) Debug Tooling: bundled viaDebug Tooling: bundled via shell.nixshell.nix Dev Mode: viaDev Mode: via direnv / lorridirenv / lorri Hermetic:Hermetic: maybemaybe
  • 19. FLAKESFLAKES — https://github.com/NixOS/rfcs/pull/49 Flakes allow hermetic, reproducibleFlakes allow hermetic, reproducible evaluation of multi-repository Nixevaluation of multi-repository Nix projects; impose a discoverable,projects; impose a discoverable, standard structure on Nix projects; andstandard structure on Nix projects; and replace previous mechanisms such asreplace previous mechanisms such as Nix channels and the Nix search pathNix channels and the Nix search path
  • 20. Runnable applicationsRunnable applications nix (name)nix (name) Tests stdout = stdoutTests stdout = stdout NixOS ModulesNixOS Modules CI Linked build to publish versionsCI Linked build to publish versions to Nix 1.xto Nix 1.x Cachix integratedCachix integrated BackportedBackported Flake UtilsFlake Utils
  • 21. ake.nix Update to latest SHA of Git Branches viaUpdate to latest SHA of Git Branches via { description = "impureEnv"; inputs.flake-utils.url = "github:numtide/flake-utils"; inputs.nixpkgs.url = "github:NixOS/nixpkgs-channels?rev=72b9660 inputs.pinnedDockerTools.url = "github:xxxxx"; inputs.pinnedDockerTools.flake = false; # s6-overlay & k6 same process as dockerTools outputs = { self, nixpkgs, flake-utils }: let overlay = final: prev: { dockerTools = (import pinnedDockerTools {}).dockerTools; k6 = prev.k6.overrideAttrs ( old: { name = "patched-k6-${old.version}"; nix flake update --recreate-lock-file
  • 22. SAME (NOT) SAMESAME (NOT) SAME Build:Build: nix buildnix build Run:Run: nix developnix develop Debug Tooling: bundled viaDebug Tooling: bundled via shell.nixshell.nix Dev Mode: viaDev Mode: via direnv / lorridirenv / lorri Hermetic: alwaysHermetic: always