summaryrefslogtreecommitdiff
path: root/flake.nix
diff options
context:
space:
mode:
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix100
1 files changed, 59 insertions, 41 deletions
diff --git a/flake.nix b/flake.nix
index 3179176..09f7610 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 = "report"; 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 fancyhdr 22 in
28 etoolbox 23 rec {
29 topiclongtable; 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,53 @@
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 })
55 gnumake
56 ];
57
50 buildPhase = '' 58 buildPhase = ''
51 latexmk \ 59 latexmk \
52 -pdf \ 60 -pdf \
53 -pdflatex="pdflatex -interaction=nonstopmode" \ 61 -pdflatex="pdflatex -interaction=nonstopmode" \
54 -use-make ${pname}.tex 62 -use-make ${pname}.tex
55 ''; 63 '';
56 installPhase = '' 64 installPhase = ''
57 mkdir -p $out 65 install -Dm444 -t $out ${pname}.pdf
58 cp ${pname}.pdf $out/
59 ''; 66 '';
60 }; 67 };
61 apps.watch = { 68
69 };
70
71 packages = forAllSystems (system: {
72 inherit (nixpkgsFor.${system}) watcher buildLatex;
73 });
74
75 defaultPackage =
76 forAllSystems (system: self.packages."${system}".buildLatex);
77
78
79 apps = forAllSystems (system: {
80 watch = {
62 type = "app"; 81 type = "app";
63 program = "${watcher}/bin/watch"; 82 program = "${self.packages."${system}".watcher}/bin/watch";
64 };
65 devShell = pkgs.mkShell {
66 nativeBuildInputs = nativeBuildInputs;
67 }; 83 };
68 }); 84 });
85
86 };
69} 87}