-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
88 lines (79 loc) · 2.25 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
{
description = "Environment for building talks";
inputs.flake-utils.url = github:numtide/flake-utils;
outputs = {
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system: let
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
in let
texlive = pkgs.texlive.combine {
inherit (pkgs.texlive) scheme-medium mdframed etoolbox zref needspace tikz-cd;
};
in let
vscodeExtensions = [
pkgs.vscode-extensions.vscodevim.vim
pkgs.vscode-extensions.james-yu.latex-workshop
];
in let
vscode =
pkgs.vscode-with-extensions.override {
vscodeExtensions = vscodeExtensions;
};
in {
packages = flake-utils.lib.flattenTree {
gitAndTools = pkgs.gitAndTools;
};
devShell =
pkgs.mkShell {buildInputs = [texlive vscode];};
defaultPackage = let
createShellScript = name: contents:
pkgs.stdenv.mkDerivation {
pname = name;
version = "0.1.0";
src = contents;
buildInputs = [
pkgs.shellcheck
];
phases = ["configurePhase" "buildPhase" "installPhase"];
configurePhase = ''
${pkgs.shellcheck}/bin/shellcheck "${contents}"
'';
buildPhase = ''
cp "${contents}" run.sh
patchShebangs run.sh
sed -i 's_"/bin/sh"_"${pkgs.bash}/bin/sh"_' run.sh
'';
installPhase = ''
mkdir -p $out
mv run.sh $out/run.sh
'';
};
in let
buildLatex =
createShellScript "latex" ./build.sh;
in
pkgs.stdenv.mkDerivation {
pname = "patrick-talks";
version = "0.1.0";
src = ./.;
buildInputs = [
texlive
];
buildPhase = ''
${pkgs.bash}/bin/sh ${buildLatex}/run.sh .
'';
installPhase = ''
mkdir -p $out
mv ./* $out
'';
};
}
);
}