2024-12-31 19:17:37 -08:00
|
|
|
{
|
2024-12-31 19:19:34 -08:00
|
|
|
description = "Youwen Wu's CV";
|
2024-12-31 19:17:37 -08:00
|
|
|
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
|
|
|
|
|
|
typix = {
|
|
|
|
url = "github:loqusion/typix";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
|
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
|
|
|
|
|
|
font-awesome = {
|
|
|
|
url = "github:FortAwesome/Font-Awesome";
|
|
|
|
flake = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
typst-packages = {
|
|
|
|
url = "github:typst/packages";
|
|
|
|
flake = false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
outputs =
|
|
|
|
inputs@{
|
|
|
|
nixpkgs,
|
|
|
|
typix,
|
|
|
|
flake-utils,
|
|
|
|
self,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
flake-utils.lib.eachDefaultSystem (
|
|
|
|
system:
|
|
|
|
let
|
|
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
|
|
|
inherit (pkgs) lib;
|
|
|
|
|
|
|
|
typixLib = typix.lib.${system};
|
|
|
|
|
|
|
|
src = typixLib.cleanTypstSource ./.;
|
|
|
|
commonArgs = {
|
|
|
|
typstSource = "cv.typ";
|
|
|
|
|
|
|
|
fontPaths = [
|
|
|
|
# Add paths to fonts here
|
|
|
|
# "${pkgs.roboto}/share/fonts/truetype"
|
|
|
|
"${inputs.font-awesome}/otfs"
|
|
|
|
];
|
|
|
|
|
|
|
|
virtualPaths = [
|
|
|
|
# Add paths that must be locally accessible to typst here
|
|
|
|
{
|
|
|
|
dest = "icons";
|
|
|
|
src = "${inputs.font-awesome}/svgs/regular";
|
|
|
|
}
|
|
|
|
];
|
2024-12-31 19:51:09 -08:00
|
|
|
|
|
|
|
typstOpts = {
|
|
|
|
input = ''GIT_REV=${if (self ? rev) then self.rev else "GIT_UNSTABLE_DONT_USE"}'';
|
|
|
|
};
|
2024-12-31 19:17:37 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
typstPackagesSrc = "${inputs.typst-packages}/packages";
|
|
|
|
|
|
|
|
typstPackagesCache = pkgs.stdenvNoCC.mkDerivation {
|
|
|
|
name = "typst-packages-cache";
|
|
|
|
src = typstPackagesSrc;
|
|
|
|
dontBuild = true;
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p "$out/typst/packages"
|
|
|
|
cp -LR --reflink=auto --no-preserve=mode -t "$out/typst/packages" "$src"/*
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
# Compile a Typst project, *without* copying the result
|
|
|
|
# to the current directory
|
|
|
|
build-drv = typixLib.buildTypstProject (
|
|
|
|
commonArgs
|
|
|
|
// {
|
|
|
|
inherit src;
|
2024-12-31 19:44:35 -08:00
|
|
|
|
|
|
|
XDG_CACHE_HOME = typstPackagesCache;
|
|
|
|
|
|
|
|
SOURCE_DATE_EPOCH = builtins.toString self.lastModified;
|
2024-12-31 19:17:37 -08:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
# Compile a Typst project, and then copy the result
|
|
|
|
# to the current directory
|
|
|
|
build-script = typixLib.buildTypstProjectLocal (
|
|
|
|
commonArgs
|
|
|
|
// {
|
|
|
|
inherit src;
|
2024-12-31 19:44:35 -08:00
|
|
|
|
|
|
|
XDG_CACHE_HOME = typstPackagesCache;
|
|
|
|
|
|
|
|
SOURCE_DATE_EPOCH = builtins.toString self.lastModified;
|
2024-12-31 19:17:37 -08:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
# Watch a project and recompile on changes
|
|
|
|
watch-script = typixLib.watchTypstProject commonArgs;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
checks = {
|
|
|
|
inherit build-drv build-script watch-script;
|
|
|
|
};
|
|
|
|
|
|
|
|
packages.default = build-drv;
|
|
|
|
|
|
|
|
apps = rec {
|
|
|
|
default = watch;
|
|
|
|
build = flake-utils.lib.mkApp {
|
|
|
|
drv = build-script;
|
|
|
|
};
|
|
|
|
watch = flake-utils.lib.mkApp {
|
|
|
|
drv = watch-script;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
devShells.default = typixLib.devShell {
|
|
|
|
inherit (commonArgs) fontPaths virtualPaths;
|
|
|
|
packages = [
|
|
|
|
# WARNING: Don't run `typst-build` directly, instead use `nix run .#build`
|
|
|
|
# See https://github.com/loqusion/typix/issues/2
|
|
|
|
# build-script
|
|
|
|
watch-script
|
|
|
|
# More packages can be added here, like typstfmt
|
|
|
|
# pkgs.typstfmt
|
|
|
|
];
|
|
|
|
};
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|