Using NixOS for declarative deployment and testing

Sander van der Burg
Sander van der BurgSoftware Engineer and Researcher at Mendix
Using NixOS for declarative deployment and
testing
Sander van der Burg Eelco Dolstra
Delft University of Technology, EEMCS,
Department of Software Technology
February 5, 2010
Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
Linux distributions
There are a wide range of Linux distributions available, each
having different properties and goals.
Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
Software deployment
Software deployment
All of the activities that make a software system available for use
Carzaninga et al.
Activities
Install a Linux distribution with some desired packages
Adapt/tweak configuration files
Install custom pieces of software
Upgrade a system
Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
Deployment scenario
Single installation
Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
Deployment scenario
Multiple installations
Machines are connected and dependent on each other
Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
Deployment scenario
Virtual machines
Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
Challenges
Deploying a single machine is hard
Takes some effort
Upgrading may break the system
Deploying a distributed environment is even harder
Machines may be dependent on each other, e.g. web
application using a database
While upgrading, downtimes may occur
Deploying (a network of) virtual machines is also hard
Takes quite some effort to perform system integration tests
Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
NixOS
A GNU/Linux distribution using the Nix package manager
Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
Nix store
Main idea: store all packages
in isolation from each other:
/nix/store/rpdqxnilb0cg...
-firefox-3.5.4
Paths contain a 160-bit
cryptographic hash of all
inputs used to build the
package:
Sources
Libraries
Compilers
Build scripts
. . .
/nix/store
l9w6773m1msy...-openssh-4.6p1
bin
ssh
sbin
sshd
smkabrbibqv7...-openssl-0.9.8e
lib
libssl.so.0.9.8
c6jbqm2mc0a7...-zlib-1.2.3
lib
libz.so.1.2.3
im276akmsrhv...-glibc-2.5
lib
libc.so.6
Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
Nix expressions
openssh.nix
{ stdenv, fetchurl, openssl, zlib }:
stdenv.mkDerivation {
name = "openssh-4.6p1";
src = fetchurl {
url = http://.../openssh-4.6p1.tar.gz;
sha256 = "0fpjlr3bfind0y94bk442x2p...";
};
buildCommand = ’’
tar xjf $src
./configure --prefix=$out --with-openssl=${openssl}
make; make install
’’;
}
Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
Nix expressions
all-packages.nix
openssh = import ../tools/networking/openssh {
inherit fetchurl stdenv openssl zlib;
};
openssl = import ../development/libraries/openssl {
inherit fetchurl stdenv perl;
};
stdenv = ...;
openssl = ...;
zlib = ...;
perl = ...;
nix-env -f all-packages.nix -iA openssh
Produces a /nix/store/l9w6773m1msy...-openssh-4.6p1
package in the Nix store.
Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
NixOS
In NixOS, all packages including the Linux kernel and
configuration files are managed by Nix.
NixOS does not have directories such as: /lib and /usr
NixOS has a minimal /bin and /etc
But NixOS is more then just a distribution managed by Nix
Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
NixOS configuration
/etc/nixos/configuration.nix
{pkgs, ...}:
{
boot.loader.grub.device = "/dev/sda";
fileSystems = [ { mountPoint = "/"; device = "/dev/sda2"; } ];
swapDevices = [ { device = "/dev/sda1"; } ];
services = {
openssh.enable = true;
xserver = {
enable = true;
desktopManager.kde4.enable = true;
};
};
environment.systemPackages = [ pkgs.mc pkgs.firefox ];
}
Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
NixOS configuration
nixos-rebuild switch
Nix package manager builds a complete system configuration
Includes all packages and generates all configuration files, e.g.
OpenSSH configuration
Upgrades are (almost) atomic
Components are stored safely next to each other, due to hashes
No files are automatically removed or overwritten
Users can switch to older generations of system configurations
not garbage collected yet
Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
NixOS bootloader
Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
Distributed deployment
NixOS has good properties for deployment of a single system
Can we extend these properties to distributed systems?
Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
Motivating example: Trac
Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
Motivating example: Trac
Trac can be deployed in a distributed environment:
Subversion server
Database server
Web server
Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
Distributed NixOS configuration
network.nix
{ storage = {pkgs, ...}:
{
services.nfsKernel.server.enable = true; ...
};
postgresql = {pkgs, ...}:
{
services.postgresql.enable = true; ...
};
webserver = {pkgs, ...}:
{
fileSystems = [
{ mountPoint = "/repos"; device = "storage:/repos"; } ];
services.httpd.enable = true;
services.httpd.extraSubservices = [ { serviceType = "trac"; } ]; ...
};
...
}
Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
Distributed deployment
nixos-deploy-network network.nix
Build system configurations by the Nix package manager
Transfer complete system and all dependencies to target
machines in the network
Efficient: only missing store paths must be transferred
Safe: Existing configuration is not affected, because no files
are overwritten or removed
Activate new system configuration
In case of a failure, roll back all configurations
Relatively cheap operation, because old configuration is stored
next to new configuration
Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
Virtualization
nixos-build-vms network.nix; ./result/bin/nixos-run-vms
Builds a network of QEMU-KVM virtual machines closely
resembling the network of NixOS configurations
We don’t create disk images
The VM mounts the Nix store of the host system using
SMB/CIFS
Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
Virtualization
nixos-build-vms network.nix; ./result/bin/nixos-run-vms
Possible because complete configuration is in the Nix store
This is efficient and safe due to the nature of the Nix store
Components with same hash codes are shared between VMs
The hash part of the name isolates components from each
other
Difficult to do for imperative Linux distributions, which have
/etc, /usr, /lib directories.
Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
Virtualization
Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
Testing
trac.nix
testScript = ’’
$postgresql→waitForJob("postgresql");
$postgresql→mustSucceed("createdb trac");
$webserver→mustSucceed("mkdir -p /repos/trac");
$webserver→mustSucceed("svnadmin create /repos/trac");
$webserver→waitForFile("/var/trac");
$webserver→mustSucceed("mkdir -p /var/trac/projects/test");
$webserver→mustSucceed("trac-admin /var/trac/projects/test initenv ".
"Test postgres://root@postgresql/trac svn /repos/trac");
$client→waitForX;
$client→execute("konqueror http://webserver/projects/test &");
$client→waitForWindow(qr/Test.*Konqueror/);
$client→screenshot("screen");
’’;
Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
Testing
nix-build tests.nix -A trac
Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
Experience
Distributed deployment of a Hydra build environment
Continuous integration and testing of NixOS
NixOS installer
OpenSSH
Trac
NFS server
Continuous integration and testing of various GNU projects
Install NixOS system with bleeding edge glibc
Other free software projects
Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
Related work
Examples:
Cfengine
Stork
Related work uses convergent models
NixOS models are congruent
Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
Conclusion
NixOS. A GNU/Linux distribution used to reliably deploy a
complete system from a declarative specification
nixos-deploy-network. Efficiently/Reliably deploy a
network of NixOS machines
nixos-build-vms. Efficiently generate a network of cheap
NixOS virtual machines instances
NixOS test driver. Perform distributed test cases in a network
of NixOS virtual machines
Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
References
NixOS website: http://nixos.org
Nix. A purely functional package manager
Nixpkgs. Nix packages collection
NixOS. Nix based GNU/Linux distribution
Hydra. Nix based continuous build and integration server
Disnix. Nix based distributed service deployment
Software available under free and open-source licenses
(LGPL/X11)
Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
References
Nix package manager can be used on any Linux system,
FreeBSD, OpenSolaris, Darwin and Cygwin
Virtualization features can be used on any Linux system
running the Nix package manager and KVM.
Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
Questions
Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
1 of 31

Recommended

Nix for Python developers by
Nix for Python developersNix for Python developers
Nix for Python developersAsko Soukka
5.5K views41 slides
Deploying NPM packages with the Nix package manager by
Deploying NPM packages with the Nix package managerDeploying NPM packages with the Nix package manager
Deploying NPM packages with the Nix package managerSander van der Burg
5.4K views51 slides
The NixOS project and deploying systems declaratively by
The NixOS project and deploying systems declarativelyThe NixOS project and deploying systems declaratively
The NixOS project and deploying systems declarativelySander van der Burg
35.8K views48 slides
The Nix project by
The Nix projectThe Nix project
The Nix projectSander van der Burg
592 views42 slides
The Nix project by
The Nix projectThe Nix project
The Nix projectSander van der Burg
962 views49 slides
Deploying (micro)services with Disnix by
Deploying (micro)services with DisnixDeploying (micro)services with Disnix
Deploying (micro)services with DisnixSander van der Burg
4.3K views54 slides

More Related Content

What's hot

nix-processmgmt: An experimental Nix-based process manager-agnostic framework by
nix-processmgmt: An experimental Nix-based process manager-agnostic frameworknix-processmgmt: An experimental Nix-based process manager-agnostic framework
nix-processmgmt: An experimental Nix-based process manager-agnostic frameworkSander van der Burg
1.8K views30 slides
DockerVC Hackathon Presentation by
DockerVC Hackathon PresentationDockerVC Hackathon Presentation
DockerVC Hackathon PresentationYu-Hsin Hung
339 views12 slides
Hydra: Continuous Integration and Testing for Demanding People: The Basics by
Hydra: Continuous Integration and Testing for Demanding People: The BasicsHydra: Continuous Integration and Testing for Demanding People: The Basics
Hydra: Continuous Integration and Testing for Demanding People: The BasicsSander van der Burg
2K views25 slides
"Containers do not contain" by
"Containers do not contain""Containers do not contain"
"Containers do not contain"Maciej Lasyk
14.8K views37 slides
Docker Security: Are Your Containers Tightly Secured to the Ship? by
Docker Security: Are Your Containers Tightly Secured to the Ship?Docker Security: Are Your Containers Tightly Secured to the Ship?
Docker Security: Are Your Containers Tightly Secured to the Ship?Michael Boelen
8.7K views44 slides
Docker: the road ahead by
Docker: the road aheadDocker: the road ahead
Docker: the road aheadshykes
46.4K views50 slides

What's hot(20)

nix-processmgmt: An experimental Nix-based process manager-agnostic framework by Sander van der Burg
nix-processmgmt: An experimental Nix-based process manager-agnostic frameworknix-processmgmt: An experimental Nix-based process manager-agnostic framework
nix-processmgmt: An experimental Nix-based process manager-agnostic framework
Sander van der Burg1.8K views
DockerVC Hackathon Presentation by Yu-Hsin Hung
DockerVC Hackathon PresentationDockerVC Hackathon Presentation
DockerVC Hackathon Presentation
Yu-Hsin Hung339 views
Hydra: Continuous Integration and Testing for Demanding People: The Basics by Sander van der Burg
Hydra: Continuous Integration and Testing for Demanding People: The BasicsHydra: Continuous Integration and Testing for Demanding People: The Basics
Hydra: Continuous Integration and Testing for Demanding People: The Basics
"Containers do not contain" by Maciej Lasyk
"Containers do not contain""Containers do not contain"
"Containers do not contain"
Maciej Lasyk14.8K views
Docker Security: Are Your Containers Tightly Secured to the Ship? by Michael Boelen
Docker Security: Are Your Containers Tightly Secured to the Ship?Docker Security: Are Your Containers Tightly Secured to the Ship?
Docker Security: Are Your Containers Tightly Secured to the Ship?
Michael Boelen8.7K views
Docker: the road ahead by shykes
Docker: the road aheadDocker: the road ahead
Docker: the road ahead
shykes46.4K views
Ryan Koop's Docker Chicago Meetup Demo March 12 2014 by Cohesive Networks
Ryan Koop's Docker Chicago Meetup Demo March 12 2014Ryan Koop's Docker Chicago Meetup Demo March 12 2014
Ryan Koop's Docker Chicago Meetup Demo March 12 2014
Cohesive Networks451 views
Raspberry pi x kubernetes x tensorflow by 霈萱 蔡
Raspberry pi x kubernetes x tensorflowRaspberry pi x kubernetes x tensorflow
Raspberry pi x kubernetes x tensorflow
霈萱 蔡527 views
Introduction to Docker and all things containers, Docker Meetup at RelateIQ by dotCloud
Introduction to Docker and all things containers, Docker Meetup at RelateIQIntroduction to Docker and all things containers, Docker Meetup at RelateIQ
Introduction to Docker and all things containers, Docker Meetup at RelateIQ
dotCloud2.2K views
The State of Rootless Containers by Akihiro Suda
The State of Rootless ContainersThe State of Rootless Containers
The State of Rootless Containers
Akihiro Suda2.5K views
PaaSTA: Running applications at Yelp by Nathan Handler
PaaSTA: Running applications at YelpPaaSTA: Running applications at Yelp
PaaSTA: Running applications at Yelp
Nathan Handler1.1K views
Security in a containerized world - Jessie Frazelle by Paris Container Day
Security in a containerized world - Jessie FrazelleSecurity in a containerized world - Jessie Frazelle
Security in a containerized world - Jessie Frazelle
Rootless Containers & Unresolved issues by Akihiro Suda
Rootless Containers & Unresolved issuesRootless Containers & Unresolved issues
Rootless Containers & Unresolved issues
Akihiro Suda1.4K views
[KubeCon NA 2020] containerd: Rootless Containers 2020 by Akihiro Suda
[KubeCon NA 2020] containerd: Rootless Containers 2020[KubeCon NA 2020] containerd: Rootless Containers 2020
[KubeCon NA 2020] containerd: Rootless Containers 2020
Akihiro Suda1.1K views
Find the Hacker by Sysdig
Find the HackerFind the Hacker
Find the Hacker
Sysdig 301 views
Containers, Docker, and Security: State Of The Union (LinuxCon and ContainerC... by Jérôme Petazzoni
Containers, Docker, and Security: State Of The Union (LinuxCon and ContainerC...Containers, Docker, and Security: State Of The Union (LinuxCon and ContainerC...
Containers, Docker, and Security: State Of The Union (LinuxCon and ContainerC...
Jérôme Petazzoni7.4K views
A Gentle Introduction To Docker And All Things Containers by Jérôme Petazzoni
A Gentle Introduction To Docker And All Things ContainersA Gentle Introduction To Docker And All Things Containers
A Gentle Introduction To Docker And All Things Containers
Jérôme Petazzoni60.6K views
Docker Networking in OpenStack: What you need to know now by PLUMgrid
Docker Networking in OpenStack: What you need to know nowDocker Networking in OpenStack: What you need to know now
Docker Networking in OpenStack: What you need to know now
PLUMgrid2.4K views
[Paris Container Day 2021] nerdctl: yet another Docker & Docker Compose imple... by Akihiro Suda
[Paris Container Day 2021] nerdctl: yet another Docker & Docker Compose imple...[Paris Container Day 2021] nerdctl: yet another Docker & Docker Compose imple...
[Paris Container Day 2021] nerdctl: yet another Docker & Docker Compose imple...
Akihiro Suda2.9K views

Similar to Using NixOS for declarative deployment and testing

Deploying .NET applications with the Nix package manager by
Deploying .NET applications with the Nix package managerDeploying .NET applications with the Nix package manager
Deploying .NET applications with the Nix package managerSander van der Burg
1.8K views36 slides
A Reference Architecture for Distributed Software Deployment by
A Reference Architecture for Distributed Software DeploymentA Reference Architecture for Distributed Software Deployment
A Reference Architecture for Distributed Software DeploymentSander van der Burg
1.6K views56 slides
Techniques and lessons for improvement of deployment processes by
Techniques and lessons for improvement of deployment processesTechniques and lessons for improvement of deployment processes
Techniques and lessons for improvement of deployment processesSander van der Burg
444 views19 slides
Automating Mendix application deployments with Nix by
Automating Mendix application deployments with NixAutomating Mendix application deployments with Nix
Automating Mendix application deployments with NixSander van der Burg
2.4K views33 slides
Docker dDessi november 2015 by
Docker dDessi november 2015Docker dDessi november 2015
Docker dDessi november 2015Massimiliano Dessì
1.3K views43 slides
OpenNebulaConf 2016 - The Lightweight Approach to Build Cloud CyberSecurity E... by
OpenNebulaConf 2016 - The Lightweight Approach to Build Cloud CyberSecurity E...OpenNebulaConf 2016 - The Lightweight Approach to Build Cloud CyberSecurity E...
OpenNebulaConf 2016 - The Lightweight Approach to Build Cloud CyberSecurity E...OpenNebula Project
475 views41 slides

Similar to Using NixOS for declarative deployment and testing(20)

Deploying .NET applications with the Nix package manager by Sander van der Burg
Deploying .NET applications with the Nix package managerDeploying .NET applications with the Nix package manager
Deploying .NET applications with the Nix package manager
Sander van der Burg1.8K views
A Reference Architecture for Distributed Software Deployment by Sander van der Burg
A Reference Architecture for Distributed Software DeploymentA Reference Architecture for Distributed Software Deployment
A Reference Architecture for Distributed Software Deployment
Sander van der Burg1.6K views
Techniques and lessons for improvement of deployment processes by Sander van der Burg
Techniques and lessons for improvement of deployment processesTechniques and lessons for improvement of deployment processes
Techniques and lessons for improvement of deployment processes
Automating Mendix application deployments with Nix by Sander van der Burg
Automating Mendix application deployments with NixAutomating Mendix application deployments with Nix
Automating Mendix application deployments with Nix
Sander van der Burg2.4K views
OpenNebulaConf 2016 - The Lightweight Approach to Build Cloud CyberSecurity E... by OpenNebula Project
OpenNebulaConf 2016 - The Lightweight Approach to Build Cloud CyberSecurity E...OpenNebulaConf 2016 - The Lightweight Approach to Build Cloud CyberSecurity E...
OpenNebulaConf 2016 - The Lightweight Approach to Build Cloud CyberSecurity E...
OpenNebula Project475 views
The Future of Security and Productivity in Our Newly Remote World by DevOps.com
The Future of Security and Productivity in Our Newly Remote WorldThe Future of Security and Productivity in Our Newly Remote World
The Future of Security and Productivity in Our Newly Remote World
DevOps.com208 views
NCS: NEtwork Control System Hands-on Labs by Cisco Canada
NCS:  NEtwork Control System Hands-on Labs NCS:  NEtwork Control System Hands-on Labs
NCS: NEtwork Control System Hands-on Labs
Cisco Canada8.4K views
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic... by Codemotion
Why everyone is excited about Docker (and you should too...) -  Carlo Bonamic...Why everyone is excited about Docker (and you should too...) -  Carlo Bonamic...
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
Codemotion765 views
2015 DockerCon Using Docker in production at bity.com by Mathieu Buffenoir
2015 DockerCon Using Docker in production at bity.com2015 DockerCon Using Docker in production at bity.com
2015 DockerCon Using Docker in production at bity.com
Mathieu Buffenoir1.1K views
DCSF 19 Building Your Development Pipeline by Docker, Inc.
DCSF 19 Building Your Development Pipeline  DCSF 19 Building Your Development Pipeline
DCSF 19 Building Your Development Pipeline
Docker, Inc.467 views
Webinar: Development Swarm Cluster with Docker Compose V3 by Codefresh
Webinar: Development Swarm Cluster with Docker Compose V3Webinar: Development Swarm Cluster with Docker Compose V3
Webinar: Development Swarm Cluster with Docker Compose V3
Codefresh441 views
Docker on Mesos With OpenVNet (eng) by skipping classes
Docker on Mesos With OpenVNet (eng)Docker on Mesos With OpenVNet (eng)
Docker on Mesos With OpenVNet (eng)
skipping classes1.4K views
Dysnomia: complementing Nix deployments with state deployment by Sander van der Burg
Dysnomia: complementing Nix deployments with state deploymentDysnomia: complementing Nix deployments with state deployment
Dysnomia: complementing Nix deployments with state deployment
Docker intro by Frei Zhang
Docker introDocker intro
Docker intro
Frei Zhang1.1K views

More from Sander van der Burg

The Monitoring Playground by
The Monitoring PlaygroundThe Monitoring Playground
The Monitoring PlaygroundSander van der Burg
1.2K views37 slides
A Reference Architecture for Distributed Software Deployment by
A Reference Architecture for Distributed Software DeploymentA Reference Architecture for Distributed Software Deployment
A Reference Architecture for Distributed Software DeploymentSander van der Burg
471 views24 slides
A Generic Approach for Deploying and Upgrading Mutable Software Components by
A Generic Approach for Deploying and Upgrading Mutable Software ComponentsA Generic Approach for Deploying and Upgrading Mutable Software Components
A Generic Approach for Deploying and Upgrading Mutable Software ComponentsSander van der Burg
462 views28 slides
Deploying .NET services with Disnix by
Deploying .NET services with DisnixDeploying .NET services with Disnix
Deploying .NET services with DisnixSander van der Burg
522 views51 slides
A Self-Adaptive Deployment Framework for Service-Oriented Systems by
A Self-Adaptive Deployment Framework for Service-Oriented SystemsA Self-Adaptive Deployment Framework for Service-Oriented Systems
A Self-Adaptive Deployment Framework for Service-Oriented SystemsSander van der Burg
557 views25 slides
Pull Deployment of Services by
Pull Deployment of ServicesPull Deployment of Services
Pull Deployment of ServicesSander van der Burg
408 views16 slides

More from Sander van der Burg(14)

A Reference Architecture for Distributed Software Deployment by Sander van der Burg
A Reference Architecture for Distributed Software DeploymentA Reference Architecture for Distributed Software Deployment
A Reference Architecture for Distributed Software Deployment
A Generic Approach for Deploying and Upgrading Mutable Software Components by Sander van der Burg
A Generic Approach for Deploying and Upgrading Mutable Software ComponentsA Generic Approach for Deploying and Upgrading Mutable Software Components
A Generic Approach for Deploying and Upgrading Mutable Software Components
A Self-Adaptive Deployment Framework for Service-Oriented Systems by Sander van der Burg
A Self-Adaptive Deployment Framework for Service-Oriented SystemsA Self-Adaptive Deployment Framework for Service-Oriented Systems
A Self-Adaptive Deployment Framework for Service-Oriented Systems
Automated Deployment of Hetergeneous Service-Oriented System by Sander van der Burg
Automated Deployment of Hetergeneous Service-Oriented SystemAutomated Deployment of Hetergeneous Service-Oriented System
Automated Deployment of Hetergeneous Service-Oriented System
Pull Deployment of Services: Introduction, Progress and Challenges by Sander van der Burg
Pull Deployment of Services: Introduction, Progress and ChallengesPull Deployment of Services: Introduction, Progress and Challenges
Pull Deployment of Services: Introduction, Progress and Challenges
Model-driven Distributed Software Deployment laymen's talk by Sander van der Burg
Model-driven Distributed Software Deployment laymen's talkModel-driven Distributed Software Deployment laymen's talk
Model-driven Distributed Software Deployment laymen's talk

Recently uploaded

Open Access Publishing in Astrophysics by
Open Access Publishing in AstrophysicsOpen Access Publishing in Astrophysics
Open Access Publishing in AstrophysicsPeter Coles
808 views26 slides
MODULE-9-Biotechnology, Genetically Modified Organisms, and Gene Therapy.pdf by
MODULE-9-Biotechnology, Genetically Modified Organisms, and Gene Therapy.pdfMODULE-9-Biotechnology, Genetically Modified Organisms, and Gene Therapy.pdf
MODULE-9-Biotechnology, Genetically Modified Organisms, and Gene Therapy.pdfKerryNuez1
24 views5 slides
PRINCIPLES-OF ASSESSMENT by
PRINCIPLES-OF ASSESSMENTPRINCIPLES-OF ASSESSMENT
PRINCIPLES-OF ASSESSMENTrbalmagro
12 views12 slides
Light Pollution for LVIS students by
Light Pollution for LVIS studentsLight Pollution for LVIS students
Light Pollution for LVIS studentsCWBarthlmew
6 views12 slides
A Ready-to-Analyze High-Plex Spatial Signature Development Workflow for Cance... by
A Ready-to-Analyze High-Plex Spatial Signature Development Workflow for Cance...A Ready-to-Analyze High-Plex Spatial Signature Development Workflow for Cance...
A Ready-to-Analyze High-Plex Spatial Signature Development Workflow for Cance...InsideScientific
49 views62 slides
Pollination By Nagapradheesh.M.pptx by
Pollination By Nagapradheesh.M.pptxPollination By Nagapradheesh.M.pptx
Pollination By Nagapradheesh.M.pptxMNAGAPRADHEESH
16 views9 slides

Recently uploaded(20)

Open Access Publishing in Astrophysics by Peter Coles
Open Access Publishing in AstrophysicsOpen Access Publishing in Astrophysics
Open Access Publishing in Astrophysics
Peter Coles808 views
MODULE-9-Biotechnology, Genetically Modified Organisms, and Gene Therapy.pdf by KerryNuez1
MODULE-9-Biotechnology, Genetically Modified Organisms, and Gene Therapy.pdfMODULE-9-Biotechnology, Genetically Modified Organisms, and Gene Therapy.pdf
MODULE-9-Biotechnology, Genetically Modified Organisms, and Gene Therapy.pdf
KerryNuez124 views
PRINCIPLES-OF ASSESSMENT by rbalmagro
PRINCIPLES-OF ASSESSMENTPRINCIPLES-OF ASSESSMENT
PRINCIPLES-OF ASSESSMENT
rbalmagro12 views
Light Pollution for LVIS students by CWBarthlmew
Light Pollution for LVIS studentsLight Pollution for LVIS students
Light Pollution for LVIS students
CWBarthlmew6 views
A Ready-to-Analyze High-Plex Spatial Signature Development Workflow for Cance... by InsideScientific
A Ready-to-Analyze High-Plex Spatial Signature Development Workflow for Cance...A Ready-to-Analyze High-Plex Spatial Signature Development Workflow for Cance...
A Ready-to-Analyze High-Plex Spatial Signature Development Workflow for Cance...
InsideScientific49 views
Pollination By Nagapradheesh.M.pptx by MNAGAPRADHEESH
Pollination By Nagapradheesh.M.pptxPollination By Nagapradheesh.M.pptx
Pollination By Nagapradheesh.M.pptx
MNAGAPRADHEESH16 views
Distinct distributions of elliptical and disk galaxies across the Local Super... by Sérgio Sacani
Distinct distributions of elliptical and disk galaxies across the Local Super...Distinct distributions of elliptical and disk galaxies across the Local Super...
Distinct distributions of elliptical and disk galaxies across the Local Super...
Sérgio Sacani31 views
How to be(come) a successful PhD student by Tom Mens
How to be(come) a successful PhD studentHow to be(come) a successful PhD student
How to be(come) a successful PhD student
Tom Mens473 views
별헤는 사람들 2023년 12월호 전명원 교수 자료 by sciencepeople
별헤는 사람들 2023년 12월호 전명원 교수 자료별헤는 사람들 2023년 12월호 전명원 교수 자료
별헤는 사람들 2023년 12월호 전명원 교수 자료
sciencepeople37 views
himalay baruah acid fast staining.pptx by HimalayBaruah
himalay baruah acid fast staining.pptxhimalay baruah acid fast staining.pptx
himalay baruah acid fast staining.pptx
HimalayBaruah7 views
Metatheoretical Panda-Samaneh Borji.pdf by samanehborji
Metatheoretical Panda-Samaneh Borji.pdfMetatheoretical Panda-Samaneh Borji.pdf
Metatheoretical Panda-Samaneh Borji.pdf
samanehborji16 views
Small ruminant keepers’ knowledge, attitudes and practices towards peste des ... by ILRI
Small ruminant keepers’ knowledge, attitudes and practices towards peste des ...Small ruminant keepers’ knowledge, attitudes and practices towards peste des ...
Small ruminant keepers’ knowledge, attitudes and practices towards peste des ...
ILRI5 views
Artificial Intelligence Helps in Drug Designing and Discovery.pptx by abhinashsahoo2001
Artificial Intelligence Helps in Drug Designing and Discovery.pptxArtificial Intelligence Helps in Drug Designing and Discovery.pptx
Artificial Intelligence Helps in Drug Designing and Discovery.pptx
abhinashsahoo2001126 views
Synthesis and Characterization of Magnetite-Magnesium Sulphate-Sodium Dodecyl... by GIFT KIISI NKIN
Synthesis and Characterization of Magnetite-Magnesium Sulphate-Sodium Dodecyl...Synthesis and Characterization of Magnetite-Magnesium Sulphate-Sodium Dodecyl...
Synthesis and Characterization of Magnetite-Magnesium Sulphate-Sodium Dodecyl...
GIFT KIISI NKIN22 views
CSF -SHEEBA.D presentation.pptx by SheebaD7
CSF -SHEEBA.D presentation.pptxCSF -SHEEBA.D presentation.pptx
CSF -SHEEBA.D presentation.pptx
SheebaD711 views
Experimental animal Guinea pigs.pptx by Mansee Arya
Experimental animal Guinea pigs.pptxExperimental animal Guinea pigs.pptx
Experimental animal Guinea pigs.pptx
Mansee Arya15 views

Using NixOS for declarative deployment and testing

  • 1. Using NixOS for declarative deployment and testing Sander van der Burg Eelco Dolstra Delft University of Technology, EEMCS, Department of Software Technology February 5, 2010 Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
  • 2. Linux distributions There are a wide range of Linux distributions available, each having different properties and goals. Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
  • 3. Software deployment Software deployment All of the activities that make a software system available for use Carzaninga et al. Activities Install a Linux distribution with some desired packages Adapt/tweak configuration files Install custom pieces of software Upgrade a system Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
  • 4. Deployment scenario Single installation Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
  • 5. Deployment scenario Multiple installations Machines are connected and dependent on each other Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
  • 6. Deployment scenario Virtual machines Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
  • 7. Challenges Deploying a single machine is hard Takes some effort Upgrading may break the system Deploying a distributed environment is even harder Machines may be dependent on each other, e.g. web application using a database While upgrading, downtimes may occur Deploying (a network of) virtual machines is also hard Takes quite some effort to perform system integration tests Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
  • 8. NixOS A GNU/Linux distribution using the Nix package manager Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
  • 9. Nix store Main idea: store all packages in isolation from each other: /nix/store/rpdqxnilb0cg... -firefox-3.5.4 Paths contain a 160-bit cryptographic hash of all inputs used to build the package: Sources Libraries Compilers Build scripts . . . /nix/store l9w6773m1msy...-openssh-4.6p1 bin ssh sbin sshd smkabrbibqv7...-openssl-0.9.8e lib libssl.so.0.9.8 c6jbqm2mc0a7...-zlib-1.2.3 lib libz.so.1.2.3 im276akmsrhv...-glibc-2.5 lib libc.so.6 Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
  • 10. Nix expressions openssh.nix { stdenv, fetchurl, openssl, zlib }: stdenv.mkDerivation { name = "openssh-4.6p1"; src = fetchurl { url = http://.../openssh-4.6p1.tar.gz; sha256 = "0fpjlr3bfind0y94bk442x2p..."; }; buildCommand = ’’ tar xjf $src ./configure --prefix=$out --with-openssl=${openssl} make; make install ’’; } Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
  • 11. Nix expressions all-packages.nix openssh = import ../tools/networking/openssh { inherit fetchurl stdenv openssl zlib; }; openssl = import ../development/libraries/openssl { inherit fetchurl stdenv perl; }; stdenv = ...; openssl = ...; zlib = ...; perl = ...; nix-env -f all-packages.nix -iA openssh Produces a /nix/store/l9w6773m1msy...-openssh-4.6p1 package in the Nix store. Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
  • 12. NixOS In NixOS, all packages including the Linux kernel and configuration files are managed by Nix. NixOS does not have directories such as: /lib and /usr NixOS has a minimal /bin and /etc But NixOS is more then just a distribution managed by Nix Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
  • 13. NixOS configuration /etc/nixos/configuration.nix {pkgs, ...}: { boot.loader.grub.device = "/dev/sda"; fileSystems = [ { mountPoint = "/"; device = "/dev/sda2"; } ]; swapDevices = [ { device = "/dev/sda1"; } ]; services = { openssh.enable = true; xserver = { enable = true; desktopManager.kde4.enable = true; }; }; environment.systemPackages = [ pkgs.mc pkgs.firefox ]; } Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
  • 14. NixOS configuration nixos-rebuild switch Nix package manager builds a complete system configuration Includes all packages and generates all configuration files, e.g. OpenSSH configuration Upgrades are (almost) atomic Components are stored safely next to each other, due to hashes No files are automatically removed or overwritten Users can switch to older generations of system configurations not garbage collected yet Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
  • 15. NixOS bootloader Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
  • 16. Distributed deployment NixOS has good properties for deployment of a single system Can we extend these properties to distributed systems? Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
  • 17. Motivating example: Trac Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
  • 18. Motivating example: Trac Trac can be deployed in a distributed environment: Subversion server Database server Web server Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
  • 19. Distributed NixOS configuration network.nix { storage = {pkgs, ...}: { services.nfsKernel.server.enable = true; ... }; postgresql = {pkgs, ...}: { services.postgresql.enable = true; ... }; webserver = {pkgs, ...}: { fileSystems = [ { mountPoint = "/repos"; device = "storage:/repos"; } ]; services.httpd.enable = true; services.httpd.extraSubservices = [ { serviceType = "trac"; } ]; ... }; ... } Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
  • 20. Distributed deployment nixos-deploy-network network.nix Build system configurations by the Nix package manager Transfer complete system and all dependencies to target machines in the network Efficient: only missing store paths must be transferred Safe: Existing configuration is not affected, because no files are overwritten or removed Activate new system configuration In case of a failure, roll back all configurations Relatively cheap operation, because old configuration is stored next to new configuration Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
  • 21. Virtualization nixos-build-vms network.nix; ./result/bin/nixos-run-vms Builds a network of QEMU-KVM virtual machines closely resembling the network of NixOS configurations We don’t create disk images The VM mounts the Nix store of the host system using SMB/CIFS Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
  • 22. Virtualization nixos-build-vms network.nix; ./result/bin/nixos-run-vms Possible because complete configuration is in the Nix store This is efficient and safe due to the nature of the Nix store Components with same hash codes are shared between VMs The hash part of the name isolates components from each other Difficult to do for imperative Linux distributions, which have /etc, /usr, /lib directories. Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
  • 23. Virtualization Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
  • 24. Testing trac.nix testScript = ’’ $postgresql→waitForJob("postgresql"); $postgresql→mustSucceed("createdb trac"); $webserver→mustSucceed("mkdir -p /repos/trac"); $webserver→mustSucceed("svnadmin create /repos/trac"); $webserver→waitForFile("/var/trac"); $webserver→mustSucceed("mkdir -p /var/trac/projects/test"); $webserver→mustSucceed("trac-admin /var/trac/projects/test initenv ". "Test postgres://root@postgresql/trac svn /repos/trac"); $client→waitForX; $client→execute("konqueror http://webserver/projects/test &"); $client→waitForWindow(qr/Test.*Konqueror/); $client→screenshot("screen"); ’’; Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
  • 25. Testing nix-build tests.nix -A trac Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
  • 26. Experience Distributed deployment of a Hydra build environment Continuous integration and testing of NixOS NixOS installer OpenSSH Trac NFS server Continuous integration and testing of various GNU projects Install NixOS system with bleeding edge glibc Other free software projects Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
  • 27. Related work Examples: Cfengine Stork Related work uses convergent models NixOS models are congruent Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
  • 28. Conclusion NixOS. A GNU/Linux distribution used to reliably deploy a complete system from a declarative specification nixos-deploy-network. Efficiently/Reliably deploy a network of NixOS machines nixos-build-vms. Efficiently generate a network of cheap NixOS virtual machines instances NixOS test driver. Perform distributed test cases in a network of NixOS virtual machines Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
  • 29. References NixOS website: http://nixos.org Nix. A purely functional package manager Nixpkgs. Nix packages collection NixOS. Nix based GNU/Linux distribution Hydra. Nix based continuous build and integration server Disnix. Nix based distributed service deployment Software available under free and open-source licenses (LGPL/X11) Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
  • 30. References Nix package manager can be used on any Linux system, FreeBSD, OpenSolaris, Darwin and Cygwin Virtualization features can be used on any Linux system running the Nix package manager and KVM. Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing
  • 31. Questions Sander van der Burg, Eelco Dolstra Using NixOS for declarative deployment and testing