-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
41 lines (34 loc) · 1.17 KB
/
default.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
{ src ? fetchGit ./., siteURL ? "https://wdtz.org", relativeURLs ? false }:
let
fetchNixpkgs = import ./nix/fetch-nixpkgs.nix;
pkgs = import fetchNixpkgs { };
in
with pkgs;
assert !relativeURLs -> siteURL != null;
let
version = src.shortRev;
sourceFilter = name: type: let baseName = baseNameOf (toString name); in
(lib.cleanSourceFilter name type) &&
!(
(type == "directory" && (lib.hasPrefix "output" baseName ||
lib.hasPrefix "__pycache__" baseName))
);
in stdenv.mkDerivation {
name = "wdtz-${version}";
inherit version;
src = builtins.filterSource sourceFilter ./.;
nativeBuildInputs = with python3.pkgs; [ pelican lxml typogrify optipng mozjpeg ];
# TODO: Just properly generate the config instead of patching the existing one
patchPhase = ''
substituteInPlace publishconf.py \
--replace "SITEURL = 'https://wdtz.org'" "${lib.optionalString (siteURL != null) "SITEURL = '${siteURL}'"}" \
--replace "RELATIVE_URLS = False" "RELATIVE_URLS = ${if relativeURLs then "True" else "False"}"
'';
buildPhase = ''
make clean
make publish
'';
installPhase = ''
mv output/ $out
'';
}