Skip to content

Commit 4308a6a

Browse files
committed
add prebuild hook
1 parent edc8d80 commit 4308a6a

3 files changed

Lines changed: 26 additions & 5 deletions

File tree

flake.nix

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,7 @@
7979
sourcePreference = "wheel";
8080
};
8181

82-
pyprojectOverrides = import ./uv-overrides.nix;
83-
84-
python = pkgs.python312;
82+
python = pkgs.python3;
8583

8684
pythonSet =
8785
(pkgs.callPackage inputs.pyproject-nix.build.packages {
@@ -91,7 +89,8 @@
9189
lib.composeManyExtensions [
9290
inputs.pyproject-build-systems.overlays.default
9391
overlay
94-
pyprojectOverrides
92+
(import ./uv-overrides.nix)
93+
(import ./python-fix-overlay.nix)
9594
]
9695
);
9796

modules/documentation.nix

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ in
3030
description = "The mkdocs package to use.";
3131
};
3232

33+
mkdocs-preBuildHook = lib.mkOption {
34+
type = lib.types.lines;
35+
default = "";
36+
description = "script to run in build directory before calling mkdocs. Can be used to prepare .cache directory with Google fonts so mkdocs does not attempt to download them.";
37+
};
38+
3339
strict = lib.mkEnableOption ''
3440
Build the documentation with `--strict`
3541
@@ -39,8 +45,13 @@ in
3945
};
4046

4147
config = lib.mkIf (cfg.mkdocs-root != null) {
48+
# some mkdocs plugins want to create a .cache folder.
49+
# so we link to the project from the build dir.
50+
# the hook allows the user to prepopulate font files to help avoid mkdocs
51+
# connecting to the internet.
4252
packages.documentation = pkgs.runCommand "mkdocs-flake-documentation" { } ''
43-
cd ${cfg.mkdocs-root}
53+
cp -as ${cfg.mkdocs-root}/* .
54+
eval "${cfg.mkdocs-preBuildHook}"
4455
${cfg.mkdocs-package}/bin/mkdocs build ${strict} --site-dir $out
4556
'';
4657

python-fix-overlay.nix

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
final: prev: {
2+
cairocffi = prev.cairocffi.overrideAttrs (_old: {
3+
postInstall = ''
4+
(
5+
cd $out/lib/python3*/site-packages/cairocffi
6+
patch="${builtins.head final.pkgs.python3Packages.cairocffi.patches}"
7+
patch -p2 < "$patch"
8+
)
9+
'';
10+
});
11+
}

0 commit comments

Comments
 (0)