Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cheat sheets #7

Merged
merged 13 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
### Nix ###
result*
45 changes: 45 additions & 0 deletions cheatsheet/background.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions cheatsheet/color-default.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
\usepackage{minted}
\usemintedstyle{default}

% Define colors
\usepackage{xcolor}
\definecolor{nixdarkblue}{HTML}{5277C3}
\definecolor{codelight}{HTML}{f8f8f8}
7 changes: 7 additions & 0 deletions cheatsheet/color-print.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
\usepackage{minted}
\usemintedstyle{bw}

% Define colors
\usepackage{xcolor}
\definecolor{nixdarkblue}{HTML}{747474}
\definecolor{codelight}{HTML}{ffffff}
95 changes: 95 additions & 0 deletions cheatsheet/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{ pkgs }:
let
tex = pkgs.texlive.combine {
inherit (pkgs.texlive)
scheme-basic
environ
etoolbox
fancyvrb
koma-script
latexmk
listings
listingsutf8
metafont
hyperref
minted
pdfcol
pgf
svg
tcolorbox
texlive-scripts
tikzfill
transparent
upquote
xcolor
;
};

pygments = pkgs.python3Packages.pygments.overridePythonAttrs (old: {
patches = (old.patches or [ ]) ++ [
# removed bold and italics formatting for comments and strings
./unformatted-comments-strings.patch
];
});

inherit (pkgs) lib;

combinations = lib.cartesianProduct {
paper = [
"a4"
"letter"
];
color = [
"default"
"print"
];
};
in
lib.listToAttrs (
builtins.map (elem: {
name = "cheat-sheet-${elem.paper}-${elem.color}";

value = pkgs.stdenvNoCC.mkDerivation {
name = "nixos-cheat-sheet";

src = lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.unions [
./main.tex
./paper-${elem.paper}.tex
./color-${elem.color}.tex
./nixos.svg
./background.svg
];
};

buildInputs = [
tex
pkgs.inkscape # for svg images
pygments # for minted code blocks
];

# HOME needs to be set to keep inkscape/Fontconfig from complaining
buildPhase = ''
mv paper-${elem.paper}.tex paper.tex
mv color-${elem.color}.tex color.tex

DIR=$(mktemp -d)
env TEXMFHOME="$DIR/.cache" \
TEXMFVAR="$DIR/.cache/texmf-var" \
HOME="$DIR/home" \
latexmk \
-interaction=nonstopmode \
-pdf -pdflatex \
-output-directory="." \
-shell-escape \
main.tex
'';

installPhase = ''
mkdir $out
cp main.pdf $out/cheat-sheet-${elem.paper}-${elem.color}.pdf
'';
};
}) combinations
)
Loading