-
Notifications
You must be signed in to change notification settings - Fork 601
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Someone has requested me to build this book, since they didn't have Nix. So when looking at the Nix expressions I found that there was only a shell.nix and the default.nix was essentially just aliasing the shell.nix but without the pinning. However, with Nix flakes we no longer need to do pinning like this and we instead have a flake.lock file, which essentially pins the corresponding revisions. I also added a default.nix, which uses flake-compat to make sure that nix-shell and nix-build work as before. Since so far the way to build the PDF(s) was to get into a Nix shell and run make accordingly. For me however it's unacceptable to build random code without the Nix sandbox, so while writing a proper default.nix I decided it would be better to turn it into a Nix flake. Apart from the previous ways to build this project we now have: $ nix develop # To get a Nix shell (similar to nix-shell but cached) $ nix build # The default edition $ nix build .\#ctfp-scala # The Scala edition $ nix build .\#ctfp-ocaml # The OCaml edition Signed-off-by: aszlig <[email protected]>
- Loading branch information
Showing
6 changed files
with
190 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# nix-shell --pure --command 'cd src; make' | ||
let | ||
nixpkgs = import <nixpkgs> {}; | ||
in | ||
nixpkgs.callPackage ./shell.nix {} | ||
rev = "cecfd08d13ddef8a79f277e67b8084bd9afa1586"; | ||
url = "https://github.com/edolstra/flake-compat/archive/${rev}.tar.gz"; | ||
flake = import (fetchTarball url) { src = ./.; }; | ||
inNixShell = builtins.getEnv "IN_NIX_SHELL" != ""; | ||
in if inNixShell then flake.shellNix else flake.defaultNix |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
{ | ||
description = "Category Theory for Programmers"; | ||
|
||
inputs.nixpkgs.url = "nixpkgs/nixos-20.03"; | ||
inputs.utils.url = "github:numtide/flake-utils"; | ||
|
||
outputs = { self, nixpkgs, utils }: utils.lib.eachDefaultSystem (system: let | ||
pkgs = nixpkgs.legacyPackages.${system}; | ||
inherit (nixpkgs) lib; | ||
|
||
########################################################################### | ||
# LaTeX Environment | ||
texliveEnv = pkgs.texlive.combine { | ||
inherit (pkgs.texlive) | ||
bookcover | ||
textpos | ||
fgruler | ||
tcolorbox | ||
fvextra | ||
framed | ||
newtx | ||
nowidow | ||
emptypage | ||
wrapfig | ||
subfigure | ||
adjustbox | ||
collectbox | ||
tikz-cd | ||
imakeidx | ||
idxlayout | ||
titlesec | ||
subfiles | ||
lettrine | ||
upquote | ||
libertine | ||
mweights | ||
fontaxes | ||
mdframed | ||
needspace | ||
xifthen | ||
ifnextok | ||
currfile | ||
noindentafter | ||
ifmtarg | ||
scheme-medium | ||
listings | ||
minted | ||
microtype | ||
babel | ||
todonotes | ||
chngcntr | ||
ifplatform | ||
xstring | ||
minifp | ||
titlecaps | ||
enumitem | ||
environ | ||
trimspaces | ||
l3packages | ||
zref | ||
catchfile | ||
import | ||
; | ||
}; | ||
|
||
########################################################################### | ||
# Python Environment | ||
|
||
# Pin the Python version and its associated package set in a single place. | ||
python = pkgs.python38; | ||
pythonPkgs = pkgs.python38Packages; | ||
|
||
pygments-style-github = pythonPkgs.buildPythonPackage rec { | ||
pname = "pygments-style-github"; | ||
version = "0.4"; | ||
|
||
doCheck = false; # Hopefully someone else has run the tests. | ||
|
||
src = pythonPkgs.fetchPypi { | ||
inherit pname version; | ||
sha256 = "19zl8l5fyb8z3j8pdlm0zbgag669af66f8gn81ichm3x2hivvjhg"; | ||
}; | ||
|
||
# Anything depending on this derivation is probably also gonna want | ||
# pygments to be available. | ||
propagatedBuildInputs = with pythonPkgs; [ pygments ]; | ||
}; | ||
|
||
pythonEnv = python.withPackages ( | ||
pyPkgs: with pyPkgs; [ | ||
pygments | ||
pygments-style-github | ||
] | ||
); | ||
|
||
mkPackageName = edition: | ||
"ctfp${lib.optionalString (edition != null) "-${edition}"}"; | ||
|
||
mkPackage = isShell: edition: pkgs.stdenv.mkDerivation { | ||
name = mkPackageName edition; | ||
src = if isShell then null else self; | ||
|
||
makeFlags = [ | ||
"-C" "src" "OUTPUT_DIR=$(out)" | ||
"GIT_VER=${self.rev or self.lastModifiedDate}" | ||
]; | ||
|
||
buildFlags = lib.optional (edition != null) edition; | ||
|
||
dontInstall = true; | ||
|
||
FONTCONFIG_FILE = pkgs.makeFontsConf { | ||
fontDirectories = with pkgs; [ inconsolata-lgc libertine libertinus ]; | ||
}; | ||
|
||
buildInputs = with pkgs; [ | ||
# Misc. build tooling. | ||
gnumake | ||
git | ||
python3Packages.virtualenv | ||
which | ||
# LaTeX Environment (with all associated libraries and packages). | ||
texliveEnv | ||
# Python Environment (with all associated libraries and packages). | ||
pythonEnv | ||
]; | ||
}; | ||
|
||
editions = [ null "scala" "ocaml" ]; | ||
|
||
in { | ||
packages = lib.listToAttrs (map (edition: { | ||
name = mkPackageName edition; | ||
value = mkPackage false edition; | ||
}) editions); | ||
defaultPackage = self.packages.${system}.ctfp; | ||
devShell = mkPackage true null; | ||
}); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters