/
flake.nix
36 lines (31 loc) · 1.27 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
{
inputs.nixpkgs.url = "github:nixos/nixpkgs";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { self, nixpkgs, flake-utils, ... }: flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-darwin" ] (system:
let
pkgs = import nixpkgs { inherit system; };
mdoc = pkgs.callPackage ./mdoc.nix { inherit (pkgs.callPackage ./coursier.nix { }) coursier-tools; };
page = { base-url ? null }: pkgs.stdenv.mkDerivation {
name = "kubukoz-blog";
buildInputs = [ pkgs.zola ];
src = self;
inherit (mdoc) mdoc_outputs;
buildPhase =
let baseUrlString = if base-url == null then "" else "--base-url ${base-url}"; in
''
cp -rL $mdoc_outputs/* content
ls -alG $mdoc_outputs
zola build --output-dir $out ${baseUrlString}
'';
dontInstall = true;
};
in
{
# Intermediate package with just mdoc, for "watch" mode
packages.mdoc_outputs = mdoc.mdoc_outputs;
packages.default = page { };
packages.preview = page { base-url = "https://blog.kubukoz.com/preview"; };
devShells.generate_shas = pkgs.mkShell { packages = with pkgs; [ scala-cli coursier nix ]; };
checks.default = self.packages.${system}.default;
});
}