% Author: Florian Guthmann <florian.guthmann@fau.de>
% URL:    https://wwwcip.cs.fau.de/~oc45ujef/talks/nix/talk.tex
\RequirePackage[l2tabu, orthodox]{nag}

\def\RCS$#1: #2 ${\expandafter\def\csname RCS#1\endcsname{\mbox{\$#1: #2\$}}}
\RCS$Id: talk.tex,v 1.6 2025/05/26 18:05:16 flo Exp $
\documentclass[12pt,c,aspectratio=43, dvipsnames]{beamer}
\usepackage{polyglossia}
\setdefaultlanguage{english}
\setotherlanguage[spelling=new, babelshorthands=true]{german}
\usepackage{fontspec}
\setmainfont{EB Garamond}
\usepackage{microtype}
\usepackage{ulem}

\usetheme{default}
\beamertemplatenavigationsymbolsempty{}
\usefonttheme{serif}
\usefonttheme{structurebold}

\definecolor[named]{foreground}{HTML}{303030}
\definecolor[named]{foreground-alt}{HTML}{505050}
\colorlet{background}{white}
\definecolor[named]{background-alt}{HTML}{f0f0f0}
\definecolor[named]{primary}{HTML}{3a5a40}
\definecolor[named]{secondary}{HTML}{e76f51}
\definecolor[named]{hl-primary}{HTML}{f4a261}
\definecolor[named]{hl-secondary}{HTML}{e9c46a}
\definecolor[named]{hl-tertiary}{HTML}{3acbba}
\colorlet{accent}{primary}

\setbeamercolor{normal text}{bg=background, fg=foreground}
\setbeamercolor{titlelike}{fg=primary}
\setbeamercolor{block title}{fg=primary}
\setbeamercolor{subtitle}{fg=foreground}
\setbeamercolor{itemize item}{fg=primary}
\setbeamercolor{emph}{fg=accent}
\renewcommand<>{\emph}[1]{{\usebeamercolor[fg]{emph}\only#2{\itshape}#1}}

\setbeamertemplate{footline}{%
  \raisebox{5pt}{\makebox[\paperwidth]{
      {\color{gray} \insertsection}\hfill
      \makebox[20pt]{\color{gray}
        \scriptsize\insertframenumber}}}\hspace*{5pt}}

\setbeamertemplate{itemize items}[circle]
\setbeamertemplate{caption}{\raggedright\insertcaption\par}

\newcommand{\hl}[2]{\tikz[scale=.8, baseline=(hl.base)]
  \node[fill=#1, rounded corners, rectangle] (hl) {#2};}
\newcommand<>\hlbox[2]{\alt#3{\hl{#1}{#2}}{#2}}

\usepackage{tikz}
\usetikzlibrary{babel, calc, positioning}

\title{Keine Ahnung von Nix}
\subtitle{An Introduction to Nix by the Least Enthusiastic Nix User}
\author{\texttt{\href{https://commenting.onthe.incoherenceofthe.net/@flo}{@flo@commenting.onthe.incoherenceofthe.net}}}
\date{2025-05-22}

\setbeamertemplate{title page}{
  \begin{center}
    {
      \begin{tikzpicture}[overlay, remember picture]
        \node[
        fill=background-alt,
        fill opacity=.9,
        text opacity=1,
        align=center,
        inner sep=10pt,
        anchor=south
        ] (title) at (current page.south)
        {
          {\usebeamerfont{title}\usebeamercolor[fg]{title}\inserttitle{}}\\
          {\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}\insertsubtitle{}}\\\\
          {\usebeamerfont{author}\usebeamercolor[fg]{author}\insertauthor{}}\\
          \insertdate{}\\
          {\usebeamerfont{footline}\color{gray}\texttt{\RCSId}}
        };
      \end{tikzpicture}
    }

  \end{center}
}

\begin{document}
{
  \setbeamertemplate{footline}{}
  \setbeamertemplate{background}
  {
    \includegraphics[width=\paperwidth]{img/aquinas}
  }
  \frame{\titlepage}
}
\part{Prolegomena}
\frame{\partpage{}}

\begin{frame}
  \frametitle{Nixology}
  \begin{center}
    \begin{tikzpicture}[blob/.style = {
        draw=primary, circle,
        inner sep=.1em, minimum size=5em,
        fill=background-alt,
        align=center
      },
      every path/.append style = {double, double distance=1em}]
      \node[blob, minimum size=4em] (nix) {Nix};
      \node[blob] (nixos) at (30:3) {NixOS};
      \node[blob] (nixpkgs) at (150:3) {Nixpkgs};
      \node[blob] (nixl) at (270:3) {Nix\\(Language)};
      \draw (nix) to node[sloped] {\footnotesize{}EST} (nixl);
      \draw (nix) to node[sloped] {\footnotesize{}EST} (nixpkgs);
      \draw (nix) to node[sloped] {\footnotesize{}EST} (nixos);
      \draw (nixpkgs) to node[sloped] {\footnotesize{}NON EST} (nixos);
      \draw (nixos) to node[sloped] {\footnotesize{}NON EST} (nixl);
      \draw (nixl) to node[sloped] {\footnotesize{}NON EST} (nixpkgs);
    \end{tikzpicture}
  \end{center}
\end{frame}

\section{Nix (Language)}
\begin{frame}
  \frametitle{Nix (Language)}
  \begin{center} JSON with functions \(\sim\) Untyped (lazy)
    \(\lambda\)-calculus with records
  \end{center}
\end{frame}

\begin{frame}[fragile]
  \frametitle{Functions}
  \begin{tikzpicture}[remember picture, overlay]
    \node[anchor=north east] at (current page.north east)
    {
      \includegraphics[width=0.25\textwidth]{img/mockingbird}
    };
  \end{tikzpicture}

\begin{semiverbatim}
id = x: x

add = x: y: x + y

omega = x: x x

k = x: y: x

bb = a: b: c: d: a (b c d)
\end{semiverbatim}
\end{frame}

\begin{frame}[fragile]
  \frametitle{\sout{Records} \emph{Attribute Sets}}
\begin{verbatim}
{
  string = "hello";
  integer = 1;
  float = 3.141;
  bool = true;
  list = [ 1 "two" false ];
  attribute-set = {
    a = "hello";
    b = 2;
    c = 2.718;
    d = false;
  }; # comments are supported
}
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
  \frametitle{Derivations}
\begin{verbatim}
derivation {
  name = "hello";
  system = "x86_64-linux";
  builder = "/bin/sh";
  args = [ "-c" "echo foo > $out"];
}
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\begin{semiverbatim}
$ cat der.nix
derivation \{
  name = "hello";
  system = "x86_64-linux";
  builder = "/bin/sh";
  args = [ "-c" "echo foo > $out"];
\}
$ nix-build der.nix
this derivation will be built:
  /nix/store/\hlbox{hl-primary}{hash}-hello.drv
building '/nix/store/\hlbox{hl-secondary}{hash'}-hello.drv'...
/nix/store/\hlbox{hl-secondary}{hash'}-hello
$ cat /nix/store/\hlbox{hl-secondary}{hash'}-hello
foo
\end{semiverbatim}
\end{frame}

\begin{frame}
  \frametitle{Builder execution}
  \begin{enumerate}
  \item set \texttt{\$PWD} to a temporary directory
  \item clear environment, set according to derivation
  \item execute \texttt{builder} with \texttt{args}, write output to \texttt{\$out}
  \item set \texttt{\$out} to be read-only\ldots
  \end{enumerate}
\end{frame}

\section{Nixpkgs}
\begin{frame}
  \frametitle{Nixpkgs}
  \begin{center}
    A collection of over 120.000 \texttt{nix} packages/derivations
  \end{center}
\end{frame}

\section{NixOS}
\begin{frame}
  \frametitle{NixOS}
  \begin{center}
    A systemd/Linux distribution built on top of \texttt{nixpkgs}
  \end{center}
\end{frame}

\part{Polemics}
\frame{\partpage{}}

\begin{frame}
  \frametitle{Hujjat al-Nix}
  \begin{tikzpicture}[remember picture, overlay]
    \node[anchor=north east] at (current page.north east)
    {
      \includegraphics[width=0.2\textwidth]{img/alghazali}
    };
  \end{tikzpicture}

  \begin{itemize}
  \item<+-> Purely functional package management is a good idea
  \item<+-> Rollbacks are trivial
  \item<+-> Derivations are reproducible\footnote{mostly}
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Annoyances}
  \begin{itemize}
  \item<+-> 120.000 packages --- because \emph{everything} has to be packaged
  \item<+-> Documentation all over the place
  \item<+-> Nix is not a good programming language
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Guix}
  \begin{tikzpicture}[remember picture, overlay]
    \node[anchor=north east] at (current page.north east)
    {
      \reflectbox{\includegraphics[width=0.25\textwidth]{img/averroes}}
    };
  \end{tikzpicture}
  \begin{itemize}
  \item<+-> A \emph{sane} configuration/programming language\footnote{Guile Scheme}
  \item<+-> More unified ecosystem
  \item<+-> Submission to GNU zealots is required
  \item<+-> Noone knows how to pronounce the name
  \end{itemize}
\end{frame}

\begin{frame}[fragile]
  \frametitle{Why I use Nix\{,OS\}}
  \begin{center}
    \begin{tikzpicture}
      \draw[scale=2,domain=-1.35:1.64, smooth, thick, variable=\x] plot ({\x}, {-\x^6 + 3*\x^4 + 0.5*\x^3 - 2*\x^2 });
      \node[circle, fill=secondary] at (1.12, -0.335) {};
    \end{tikzpicture}
  \end{center}
\end{frame}

\begin{frame}
  \frametitle{The Ballad of Frankie Lee and Judas Priest}
  \begin{center}
    \includegraphics[width=.8\textwidth]{img/xkcd}
    {\scriptsize \url{https://xkcd.com/1768}}
  \end{center}
\end{frame}
\end{document}

%%% Local Variables:
%%% mode: LaTeX
%%% TeX-engine: xetex
%%% TeX-master: t
%%% End:
