summaryrefslogtreecommitdiff
path: root/flake.nix
diff options
context:
space:
mode:
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix101
1 files changed, 60 insertions, 41 deletions
diff --git a/flake.nix b/flake.nix
index 271ef18..74ca45f 100644
--- a/flake.nix
+++ b/flake.nix
@@ -3,34 +3,28 @@
3 3
4 inputs = { 4 inputs = {
5 nixpkgs.url = "github:nixos/nixpkgs"; 5 nixpkgs.url = "github:nixos/nixpkgs";
6 utils.url = "github:numtide/flake-utils";
7 gitignore = {
8 url = "github:hercules-ci/gitignore";
9 flake = false;
10 };
11 }; 6 };
12 7
13 outputs = { self, nixpkgs, utils, gitignore, ... }: 8 outputs = { self, nixpkgs, ... }:
14 utils.lib.eachDefaultSystem (system: 9 let
15 let 10 supportedSystems = [ "x86_64-linux" "x86_64-darwin" ];
16 pname = "presentation"; 11 forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system);
17 version = "0.1.0"; 12 pname = "report";
18 pkgs = nixpkgs.legacyPackages."${system}"; 13 version = "0.1.0";
19 inherit (import gitignore { inherit (pkgs) lib; }) gitignoreSource; 14
20 nativeBuildInputs = with pkgs; [ 15 nixpkgsFor = forAllSystems (system:
21 (texlive.combine { 16 import nixpkgs {
22 inherit (texlive) 17 inherit system;
23 scheme-medium 18 overlays = [ self.overlay ];
24 multirow 19 }
25 hyperref 20 );
26 blindtext 21
27 etoolbox 22 in
28 topiclongtable 23 rec {
29 beamer; 24
30 }) 25 overlay = final: prev: {
31 gnumake 26
32 ]; 27 watcher = with final; pkgs.writeScriptBin "watch" ''
33 watcher = pkgs.writeScriptBin "watch" ''
34 out=".latexmkout" 28 out=".latexmkout"
35 mkdir "$out" 29 mkdir "$out"
36 latexmk \ 30 latexmk \
@@ -41,29 +35,54 @@
41 -use-make ${pname}.tex 35 -use-make ${pname}.tex
42 rm -r "$out" 36 rm -r "$out"
43 ''; 37 '';
44 in 38
45 rec { 39 buildLatex = with final; pkgs.stdenv.mkDerivation {
46 defaultPackage = pkgs.stdenv.mkDerivation {
47 inherit pname version; 40 inherit pname version;
48 src = gitignoreSource ./.; 41
49 buildInputs = nativeBuildInputs; 42 src = ./.;
43
44 nativeBuildInputs = with pkgs; [
45 (texlive.combine {
46 inherit (texlive)
47 scheme-medium
48 multirow
49 hyperref
50 blindtext
51 fancyhdr
52 etoolbox
53 topiclongtable
54 beamer;
55 })
56 gnumake
57 ];
58
50 buildPhase = '' 59 buildPhase = ''
51 latexmk \ 60 latexmk \
52 -pdf \ 61 -pdf \
53 -pdflatex="pdflatex -interaction=nonstopmode" \ 62 -pdflatex="pdflatex -interaction=nonstopmode" \
54 -use-make ${pname}.tex 63 -use-make ${pname}.tex
55 ''; 64 '';
56 installPhase = '' 65 installPhase = ''
57 mkdir -p $out 66 install -Dm444 -t $out ${pname}.pdf
58 cp ${pname}.pdf $out/
59 ''; 67 '';
60 }; 68 };
61 apps.watch = { 69
70 };
71
72 packages = forAllSystems (system: {
73 inherit (nixpkgsFor.${system}) watcher buildLatex;
74 });
75
76 defaultPackage =
77 forAllSystems (system: self.packages."${system}".buildLatex);
78
79
80 apps = forAllSystems (system: {
81 watch = {
62 type = "app"; 82 type = "app";
63 program = "${watcher}/bin/watch"; 83 program = "${self.packages."${system}".watcher}/bin/watch";
64 };
65 devShell = pkgs.mkShell {
66 nativeBuildInputs = nativeBuildInputs;
67 }; 84 };
68 }); 85 });
86
87 };
69} 88}