-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
92 lines (87 loc) · 2.54 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
89
90
91
92
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
devshell = {
url = "github:numtide/devshell";
inputs.nixpkgs.follows = "nixpkgs";
};
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs @ {flake-parts, ...}:
flake-parts.lib.mkFlake {inherit inputs;} {
systems = ["x86_64-linux"];
imports = [
inputs.devshell.flakeModule
inputs.pre-commit-hooks.flakeModule
];
perSystem = {
pkgs,
config,
...
}: let
srcfile = "main.typ";
outfile = "Završni rad.pdf";
in {
packages.default = pkgs.stdenv.mkDerivation {
pname = "zavrsni-rad";
version = "1.0.0";
src = ./.;
buildInputs = [pkgs.typst];
buildPhase = ''
typst compile ${srcfile} "${outfile}"
'';
installPhase = ''
source $stdenv/setup
mkdir -p "$out"
mv "${outfile}" "$out/"
'';
};
devshells.default = {
name = "zavrsni-sh";
devshell.startup.pre-commit-install.text =
config.pre-commit.installationScript;
commands = [
{package = pkgs.lazygit;}
{package = pkgs.typst;}
{
name = "build";
help = "Compile the typst code into a PDF";
category = "development";
command = ''
${pkgs.typst}/bin/typst compile ${srcfile} "${outfile}"
'';
}
{
name = "develop";
help = "Watch the inputs and recompile the PDF on changes";
category = "development";
command = ''
${pkgs.typst}/bin/typst watch ${srcfile} "${outfile}"
'';
}
{
name = "clean";
help = "Clean up build results";
category = "development";
command = ''
rm "${outfile}"
'';
}
];
}; # end of devshells.default
formatter = pkgs.alejandra;
pre-commit = {
check.enable = true;
settings.hooks = {
alejandra.enable = true;
statix.enable = true;
deadnix.enable = true;
};
}; # end of pre-commit
}; # end of perSystem
}; # end of flake-parts.lib.mkFlake
}