-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
69 lines (58 loc) · 1.72 KB
/
flake.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
{
description = "mkdocs-numtide";
inputs.nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable";
outputs = { self, nixpkgs }:
let
eachSystem = f:
nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed (system:
f nixpkgs.legacyPackages.${system}
);
in
{
packages = eachSystem (pkgs: {
default = import ./. { inherit pkgs; };
docs = self.lib.${pkgs.system}.mkDocs {
name = "mkdocs-numtide";
src = ./.;
};
});
lib = eachSystem (pkgs: {
mkDocs =
# Function that builds the docs for a repo.
#
# It assumes that we want to import the src/mkdocs.yml and all of
# the src/docs folder.
{ name, src }:
pkgs.stdenv.mkDerivation {
inherit name;
src = builtins.path {
name = "src-${name}-docs";
path = src + "/docs";
};
# Re-create the folder structure since mkdocs insists on having the
# mkdocs.yml at the root of the repo.
unpackPhase = ''
cp -r --no-preserve=mode $src docs
cp ${src + "/mkdocs.yml"} mkdocs.yml
'';
nativeBuildInputs = [
self.packages.${pkgs.system}.default
];
buildPhase = ''
mkdocs build
'';
installPhase = ''
mv site $out
'';
passthru.mkdocs = self.packages.${pkgs.system}.default;
};
});
devShells = eachSystem (pkgs: {
default = pkgs.mkShellNoCC {
packages = [
self.packages.${pkgs.system}.default
];
};
});
};
}