-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
94 lines (91 loc) · 2.94 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
93
94
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-parts = {
url = "github:hercules-ci/flake-parts";
};
imprecv = {
url = "github:jskherman/imprecv?ref=0031d46d8ecd53bee5f7570681f764c4e288be0f";
flake = false;
};
};
outputs =
inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "x86_64-linux" ];
perSystem =
{
lib,
config,
self',
inputs',
pkgs,
system,
...
}:
let
packageJSON = builtins.fromJSON (builtins.readFile ./package.json);
fs = lib.fileset;
r = ./.;
src = fs.toSource {
root = r;
fileset = fs.intersection (fs.fromSource (lib.sources.cleanSource r)) (
fs.unions [
./src
./public
(fs.fileFilter (file: file.hasExt "mts") r)
(fs.fileFilter (file: file.hasExt "json") r)
]
);
};
in
{
packages.default = pkgs.buildNpmPackage {
pname = packageJSON.name;
version = packageJSON.version;
inherit src;
npmDeps = pkgs.importNpmLock { npmRoot = src; };
npmConfigHook = pkgs.importNpmLock.npmConfigHook;
postInstall = ''
cp -vf ${config.packages.resume}/resume.pdf $out/lib/node_modules/${packageJSON.name}/dist/resume.pdf
'';
env = {
ASTRO_TELEMETRY_DISABLED = true;
};
};
packages.resume = pkgs.stdenv.mkDerivation {
pname = "${packageJSON.name}-resume";
version = packageJSON.version;
src = ./src/data/resume;
buildInputs = [ pkgs.typst ];
XDG_CACHE_HOME = pkgs.stdenv.mkDerivation {
name = "typst-packages-cache";
src = inputs.imprecv;
dontBuild = true;
installPhase = ''
export imprecv="$out/typst/packages/preview/imprecv/1.0.1"
mkdir -p "$imprecv"
cp -LR --reflink=auto --no-preserve=mode -t "$imprecv" "$src"/*
'';
};
TYPST_FONT_PATHS = src;
buildCommand = builtins.readFile ./src/data/resume/_resume.sh;
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# typst compile --pdf-standard a-2b $src/_resume.typ $out/resume.pdf
};
devShells.default =
let
packages = [
pkgs.netlify-cli
pkgs.nodejs
pkgs.sops
pkgs.yq
];
in
pkgs.mkShell {
NIX_CONFIG = "experimental-features = nix-command flakes";
nativeBuildInputs = packages ++ config.packages.resume.buildInputs;
};
};
};
}