generated from me/nix-flake-typst-template
48 lines
1.5 KiB
Nix
48 lines
1.5 KiB
Nix
# SPDX-FileCopyrightText: 2025 Ethan Reece <contact@ethanreece.com>
|
|
#
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
{ flake-parts-lib, ... }:
|
|
let
|
|
entries = builtins.attrNames (builtins.readDir ./.);
|
|
modules = builtins.filter (dir: builtins.pathExists (./. + "/${dir}/default.nix")) entries;
|
|
in
|
|
{
|
|
imports = builtins.map (
|
|
module-name: flake-parts-lib.importApply (./. + "/${module-name}") { inherit module-name; }
|
|
) modules;
|
|
perSystem =
|
|
{ config, pkgs, ... }:
|
|
{
|
|
languages.typst.entrypoints = builtins.listToAttrs (
|
|
map (name: {
|
|
inherit name;
|
|
value = "resumes/${name}/main.typ";
|
|
}) modules
|
|
);
|
|
packages = builtins.listToAttrs (
|
|
map (name: {
|
|
inherit name;
|
|
value = pkgs.stdenvNoCC.mkDerivation (
|
|
let
|
|
compileCommand = "typst compile --ignore-system-fonts --font-path ${config.languages.typst.fonts}/share/fonts --root=../../ --input region=US resumes/${name}/main.typ";
|
|
in
|
|
{
|
|
name = "resume-${name}";
|
|
src = ./..;
|
|
nativeBuildInputs = [ config.languages.typst.package ];
|
|
buildPhase = ''
|
|
${compileCommand} --input lang=en resume.en_US.pdf
|
|
${compileCommand} --input lang=eo resume.eo.pdf
|
|
'';
|
|
installPhase = ''
|
|
mkdir -p $out
|
|
cp resume.en_US.pdf $out/resume.en_US.pdf
|
|
cp resume.eo.pdf $out/resume.eo.pdf
|
|
'';
|
|
}
|
|
);
|
|
}) modules
|
|
);
|
|
};
|
|
}
|