Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
presentation-slides
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
GitLab upgrade completed. Current version is 17.11.3.
Show more breadcrumbs
nix-tutorial
presentation-slides
Commits
8f882a87
Commit
8f882a87
authored
5 years ago
by
Faure Adrien
Browse files
Options
Downloads
Patches
Plain Diff
finish slides
parent
33bcb350
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
slides.tex
+131
-227
131 additions, 227 deletions
slides.tex
with
131 additions
and
227 deletions
slides.tex
+
131
−
227
View file @
8f882a87
...
...
@@ -165,32 +165,6 @@ The Problem:
% \center\Large\sc The Nix Ecosystem. {\url{https://nixos.org}}
\end{frame}
% \begin{frame}{Nix - Programming Language}
%
% What?
% \begin{itemize}
% \item Is a Domain Specific Language (DSL)
% \item Functional, Turing complete language.
% \item Dynamically typed. int, bool, path, string, set, list, lambda.
% \item Large built-in and standard lib. \texttt{stdenv, fetchTarball, fromJson, fromGitHub, assert, test..}
% \end{itemize}
% \end{frame}
%
% \begin{frame}{Nix - Language}
% \begin{tcolorbox}[colframe=black,colback=gray!10,coltext=black]
% {Nix - The Expression Language }
% \end{tcolorbox}
% Why?
% \begin{itemize}
% \item Packaging is complex.
% \item Abstraction layers.
% \item Better reusability, factorization.
% \item (Readable and Maintainable)
% \end{itemize}
% \end{frame}
\subsection
{
Nix Concepts
}
\begin{frame}
{
Main Concepts
}
...
...
@@ -207,7 +181,6 @@ The Problem:
\item
No side effects
\begin{itemize}
\item
Undeclared dependencies
$
\rightarrow
$
fail
% \item Undeclared dependencies $\rightarrow$ fail
\end{itemize}
\item
Packages are written in Nix
\end{itemize}
...
...
@@ -215,6 +188,7 @@ The Problem:
\end{frame}
\subsection
{
Packages
}
\begin{frame}
[fragile]
{
Package Definition Example
}
% It is a Nix attribute set describing how to build a package.
\vspace
{
-1em
}
...
...
@@ -233,6 +207,8 @@ stdenv.mkDerivation {
\end{frame}
\subsection
{
Store
}
\begin{frame}
[fragile]
{
Store
}
\begin{tcolorbox}
[colframe=black,colback=gray!10,coltext=black]
...
...
@@ -241,28 +217,24 @@ stdenv.mkDerivation {
\vspace
{
1em
}
Isolated packages
\\
\emph
{
Hash(inputs, source code)-packagename
}
\begin{itemize}
\item
Isolated packages
\\
\item
\emph
{
Hash(inputs, source code)-packagename
}
\item
Package names known before build
$
\rightarrow
$
binary cache
\end{itemize}
% \begin{lstlisting}[basicstyle=\small]
%/nix/store/hash-packagename/..
% /bin/package
% /lib/package.so
% /share/
% .
% \end{lstlisting}
\center
\includegraphics
[width=0.7\textwidth]
{
./figures/example
_
tree.png
}
\end{frame}
\begin{frame}
[fragile]
{
Store
}
\begin{columns}
\begin{column}
{
0.5
\textwidth
}
\begin{}
\begin{tcolorbox}
[colframe=black,colback=gray!10,coltext=black]
Package
are tree
Package
s depends on other packages
\end{tcolorbox}
\end{column}
...
...
@@ -270,240 +242,80 @@ stdenv.mkDerivation {
\begin{center}
\vspace
{
-4em
}
\includegraphics
[scale=0.6]
{
./figures/store-zoom.png
}
\end{center}
\end{center}
\end{column}
\end{columns}
\end{frame}
\begin{frame}
[fragile]
{
Store
}
\begin{tcolorbox}
[colframe=black,colback=gray!10,coltext=black]
The store can be used as a binary cache.
\end{tcolorbox}
\vspace
{
1em
}
Thanks to the name of a package.
\begin{lstlisting}
[basicstyle=
\small
]
/nix/store/hash-packagename
\end{lstlisting}
\vspace
{
1em
}
Missing dependencies can be identified and downloaded from a remote store.
\end{frame}
\begin{frame}
[fragile]
{
Nix Build: build packages
}
\vspace
{
1em
}
\includegraphics
[width=1\textwidth]
{
./figures/nix-build.pdf
}
%The result of the build action is automatically placed into the nix store.
%
% \begin{lstlisting}[basicstyle=\small]
% /nix/store/
% \end{lstlisting}
\end{frame}
\subsection
{
NixPkgs
}
\begin{frame}
[fragile]
{
Nixpkgs
}
How and where can we get a derivation?
\pause
\vspace
{
1em
}
Derivations are source code:
\begin{itemize}
\item
Packages are source code
\item
Decentralized repository
\end{itemize}
\vspace
{
1em
}
Official Nix Git Repository:
\begin{tcolorbox}
[colframe=black,colback=gray!10,coltext=black]
\center
https://github.com/NixOS/nixpkgs
\\
\textit
{
A.K.A
}
\textbf
{
NixPkgs
}
\end{tcolorbox}
\vspace
{
1em
}
NixPkgs contains the derivations of all application (and libraries)
\emph
{
officially
}
available with Nix.
\end{frame}
\begin{frame}
[fragile]
{
Channels
}
\only
<1>
{
\vspace
{
1em
}
\begin{tcolorbox}
[colframe=black,colback=gray!10,coltext=black]
\center
A
\textbf
{
channel
}
is link to branch of NixPkgs tested with continuous integration.
\end{tcolorbox}
\vspace
{
1em
}
Channels are useful to downloaded latest packaged version of a software.
\\
\vspace
{
1em
}
\begin{itemize}
\item
nixpkgs-unstable (feeling lucky?)
\item
nixpkgs-19.03 (current stable)
\item
nixpkgs-18.09 (outdated)
\item
Maintained by the community
\item
+10K packages
\end{itemize}
\vspace
{
1em
}
(Channels benefit from binary cache.)
}
\only
<2>
{
\begin{tcolorbox}
[colframe=red!37,colback=red!10,coltext=black]
\center
Channels are not fully reproducible, as they are subject to updates.
\end{tcolorbox}
\vspace
{
1em
}
As experimenters, we will use another mechanism called pinning.
}
\end{frame}
% \begin{frame}{}
% A derivation is a build action written in Nix. \\
% \vspace{1em}
% Used to build package. \\
% \vspace{1em}
% The resulting package is stocked in the store, \\
% identified with a unique path. \\
% \vspace{1em}
% In which it can refer to other packages.
% \vspace{1em}
% \end{frame}
\begin{frame}
{
Key points
}
\subsection
{
Nix tools
}
\begin{enumerate}
\item
Applies functional paradigm to package management system.
\item
Packages are called derivations, written in Nix lang.
\item
Such derivation defines a building process.
\item
A built derivation is located to the nix store into a dedicated directory.
\item
The directory name is generated from a hash of its inputs and its nix file.
\item
Packages can have reference on other packages from the store.
\item
The list of existing packages are into NixPkgs repository.
\end{enumerate}
\end{frame}
\begin{frame}
{
Nix - Command line interface
}
How do we use Nix ?
\vspace
{
1em
}
\begin{itemize}
\item
\textit
{
nix-build
}
: build a derivation (that will be placed to the nix store),
\item
\textit
{
nix-env
}
: install a package (in your current environment)
\note
{
Speak about profiles?
}
,
\item
\textit
{
nix search
}
: search for available packages.
\item
\textit
{
nix-shell
}
: start a shell in the build environment of a derivation,
\end{itemize}
\end{frame}
\begin{frame}
[fragile]
{
Nix shell
}
\begin{tcolorbox}
[colframe=black,colback=gray!10,coltext=black]
\center
Virtualenv on steroids.
\end{tcolorbox}
\vspace
{
1em
}
Start an interactive session within the build environment of a derivation.
\begin{frame}
[fragile]
{
Nix Build: build packages
}
\vspace
{
1em
}
Enables to describe environment, in which we can start a shell.
\vspace
{
-1em
}
\begin{lstlisting}
[language=Nix,basicstyle=
\small
]
{
pkgs ? import (fetchTarball
https://github.com/archive/e860b629bc0d1f9b.tar.gz)
{}
}
:
pkgs.mkShell rec
{
buildInputs = [ valgrind gdb cmake ];
}
\end{lstlisting}
\includegraphics
[width=1\textwidth]
{
./figures/nix-build.pdf
}
\end{frame}
\begin{frame}
[fragile]
{
Why it is reproducible ?
}
Writting a package for an application requires to state down every dependencies.
\\
\vspace
{
1em
}
The build process of the application is also incorporated within the derivation.
\note
{
The second point makes it easy to rebuild your application.
}
\begin{frame}
[fragile]
{
Nix shell: Virtualenv on steroids
}
\includegraphics
[width=1\textwidth]
{
./figures/nix-shell.pdf
}
\end{frame}
\begin{frame}
[fragile]
{
Why it is reproducible ?
}
\vspace
{
1em
}
The source of your application can be fixed:
\begin{lstlisting}
[language=Nix,basicstyle=
\small
]
\begin{itemize}
\item
Package = traceable dependencies
\item
Automated package build
\item
fixed application source
\begin{lstlisting}
[language=Nix,basicstyle=
\small
]
src = fetgit
{
url = "https://gitlab.com/me/chord.tar.gz";
sha256 = "1h2jgq5pspyiskffq777nhi5rf0y8h...";
}
;
\end{lstlisting}
\vspace
{
1em
}
The source of the Nixpkgs repository can be pinned.
\item
pinned Nixpkgs
\begin{lstlisting}
[language=Nix,basicstyle=
\small
]
{
pkgs ? import (
fetchTarball
"https://github.com/achive/e
860b629bc0d
1f9b.tar.gz"
)
)
pkgs ? import (fetchTarball
"https://github.com/a
r
chive/e
6b20
1f9b.tar.gz"
)
}
:
\end{lstlisting}
\end{frame}
\begin{frame}
[fragile]
Pros:
\begin{tcolorbox}
[colframe=black,colback=gray!10,coltext=black]
\begin{itemize}
\item
Defining and sharing complex environments easily.
\item
Environments are reconstructible .
\item
Writing derivations requires to state every dependencies.
\end{itemize}
\end{tcolorbox}
\vspace
{
1em
}
\end{frame}
C
ons
:
\begin{
tcolorbox}
[colframe=red!37,colback=red!10,coltext=black]
\subsection
{
Limitati
ons
}
\begin{
frame}
[fragile]
{
Limitations
}
\begin{itemize}
\item
The entry cost is high.
\item
It is contaminating (heavily depends on the nix store).
\item
No kernel version control
\item
Require deterministic build process
\item
Can depends on external dependencies
\end{itemize}
\end{tcolorbox}
% Nix ensures the reproducibility of software environments.
\vspace
{
1em
}
%\begin{tcolorbox}[colframe=red!37,colback=red!10,coltext=black]
% Nix is not a runtime, \\
%\end{tcolorbox}
\note
{
Nix is not a runtime, (Results will be stored in the store also, hard to distributes etc)
\\
Nix offers nothing to deals with data
}
\end{frame}
\begin{frame}
[fragile,noframenumbering]
\center
Thanks.
\end{frame}
...
...
@@ -585,5 +397,97 @@ src = fetgit {
\end{tabular}
\end{frame}
\begin{frame}
[fragile]
{
Channels
}
\only
<1>
{
\vspace
{
1em
}
\begin{tcolorbox}
[colframe=black,colback=gray!10,coltext=black]
\center
A
\textbf
{
channel
}
is link to branch of NixPkgs tested with continuous integration.
\end{tcolorbox}
\vspace
{
1em
}
Channels are useful to downloaded latest packaged version of a software.
\\
\vspace
{
1em
}
\begin{itemize}
\item
nixpkgs-unstable (feeling lucky?)
\item
nixpkgs-19.03 (current stable)
\item
nixpkgs-18.09 (outdated)
\end{itemize}
\vspace
{
1em
}
(Channels benefit from binary cache.)
}
\only
<2>
{
\begin{tcolorbox}
[colframe=red!37,colback=red!10,coltext=black]
\center
Channels are not fully reproducible, as they are subject to updates.
\end{tcolorbox}
\vspace
{
1em
}
As experimenters, we will use another mechanism called pinning.
}
\end{frame}
\begin{frame}
{
Key points
}
\begin{enumerate}
\item
Applies functional paradigm to package management system.
\item
Packages are called derivations, written in Nix lang.
\item
Such derivation defines a building process.
\item
A built derivation is located to the nix store into a dedicated directory.
\item
The directory name is generated from a hash of its inputs and its nix file.
\item
Packages can have reference on other packages from the store.
\item
The list of existing packages are into NixPkgs repository.
\end{enumerate}
\end{frame}
\begin{frame}
{
Nix - Command line interface
}
How do we use Nix ?
\vspace
{
1em
}
\begin{itemize}
\item
\textit
{
nix-build
}
: build a derivation (that will be placed to the nix store),
\item
\textit
{
nix-env
}
: install a package (in your current environment)
\note
{
Speak about profiles?
}
,
\item
\textit
{
nix search
}
: search for available packages.
\item
\textit
{
nix-shell
}
: start a shell in the build environment of a derivation,
\end{itemize}
\end{frame}
\begin{frame}
[fragile]
{
Nix shell
}
\begin{tcolorbox}
[colframe=black,colback=gray!10,coltext=black]
\center
Virtualenv on steroids.
\end{tcolorbox}
\vspace
{
1em
}
Start an interactive session within the build environment of a derivation.
\vspace
{
1em
}
Enables to describe environment, in which we can start a shell.
\vspace
{
-1em
}
\begin{lstlisting}
[language=Nix,basicstyle=
\small
]
{
pkgs ? import (fetchTarball
https://github.com/archive/e860b629bc0d1f9b.tar.gz)
{}
}
:
pkgs.mkShell rec
{
buildInputs = [ valgrind gdb cmake ];
}
\end{lstlisting}
\end{frame}
\end{document}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment