Skip to content

Commit

Permalink
Add cheat sheets (#7)
Browse files Browse the repository at this point in the history
* Got the new cheat sheet to build.

* Fix inkscape/Fontconfig warnings.

* Use filesets to restrict the files in the cheat sheet derivation.

* Clean up main tex file.

* Extracted paper and color styling from the main tex file.

* add .gitignore

* Renamed files for consistency.

* Cheat sheets now available as the product of a4/letter and color/bw.

* Remove unnecessary attributes from callPackage.

* Fixed the dollar to pound sign bug.

* Patched out pygment formatting on comments and strings. Didn't like the way the fonts looked.

* The grayscale/bw name from bw to print.

* Change variables named 'set' to 's' so as to not confuse the reader. They might think 'set' is a keyword.
  • Loading branch information
djacu authored May 22, 2024
1 parent 04d7c79 commit b52cc9e
Show file tree
Hide file tree
Showing 12 changed files with 1,080 additions and 0 deletions.
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

0 comments on commit b52cc9e

Please sign in to comment.