cv/flake.nix

109 lines
2.6 KiB
Nix
Raw Normal View History

2025-02-19 13:22:17 +01:00
{
2025-02-19 16:33:58 +01:00
description = "felschr's CV";
2025-02-19 13:22:17 +01:00
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
2025-02-19 16:33:58 +01:00
typix = {
url = "github:loqusion/typix";
inputs.nixpkgs.follows = "nixpkgs";
};
typst-packages = {
url = "github:typst/packages";
flake = false;
};
2025-02-19 13:22:17 +01:00
};
outputs =
inputs:
inputs.flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import inputs.nixpkgs { inherit system; };
2025-02-28 12:07:28 +01:00
inherit (pkgs) lib;
2025-02-19 16:33:58 +01:00
typixLib = inputs.typix.lib.${system};
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"/*
'';
};
2025-02-28 12:07:28 +01:00
src = lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.unions [
(lib.fileset.fromSource (typixLib.cleanTypstSource ./.))
./src/info.toml
2025-04-09 11:16:23 +02:00
# ./src/signature.svg
2025-02-28 12:07:28 +01:00
];
};
2025-02-19 16:33:58 +01:00
commonArgs = {
2025-02-24 11:56:28 +01:00
typstSource = "src/main.typ";
typstOutput = "out/main.pdf";
2025-02-19 16:33:58 +01:00
fontPaths = [
"${pkgs.work-sans}/share/fonts/opentype"
];
2025-02-19 16:33:58 +01:00
virtualPaths = [ ];
};
commonBuildArgs = commonArgs // {
XDG_CACHE_HOME = typstPackagesCache;
};
build-drv = typixLib.buildTypstProject (
commonBuildArgs
// {
inherit src;
}
);
build-script = typixLib.buildTypstProjectLocal (
commonBuildArgs
// {
inherit src;
}
);
watch-script = typixLib.watchTypstProject commonArgs;
2025-02-19 13:22:17 +01:00
in
{
2025-02-19 16:33:58 +01:00
checks = {
inherit build-drv build-script watch-script;
};
2025-02-19 13:22:17 +01:00
2025-02-19 16:33:58 +01:00
packages.default = build-drv;
2025-02-19 13:22:17 +01:00
2025-02-19 16:33:58 +01:00
apps = rec {
default = watch;
build = inputs.flake-utils.lib.mkApp {
drv = build-script;
2025-02-19 13:22:17 +01:00
};
2025-02-19 16:33:58 +01:00
watch = inputs.flake-utils.lib.mkApp {
drv = watch-script;
};
};
devShells.default = typixLib.devShell {
inherit (commonArgs) fontPaths virtualPaths;
packages = [
watch-script
2025-02-24 11:38:31 +01:00
pkgs.typstyle
2025-02-19 16:33:58 +01:00
pkgs.tinymist
pkgs.nixfmt-rfc-style
];
2025-02-19 13:22:17 +01:00
};
formatter = pkgs.nixfmt-rfc-style;
}
);
}