-
Notifications
You must be signed in to change notification settings - Fork 15
/
flake.nix
55 lines (47 loc) · 1.38 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
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
myEmacs = pkgs.emacs28WithPackages (epkgs: [
epkgs.org
epkgs.htmlize
]);
buildInputs = [ myEmacs ];
site = pkgs.stdenv.mkDerivation {
name = "site";
src = ./.;
installPhase = ''
${myEmacs}/bin/emacs -Q --script ./build-site.el
# Avoid Jekyll styling on platforms like GitHub
touch dist/.nojekyll
mkdir $out
cp -R dist/* $out
'';
};
serve = pkgs.writeShellScriptBin "serve" ''
if test -n "$1"; then
SITE_DIR=$1
else
SITE_DIR="${site}"
fi
cd $SITE_DIR && ${pkgs.python3}/bin/python3 -m http.server
'';
in
{
packages.site = site;
defaultPackage = self.packages.${system}.site;
apps.serve = {
type = "app";
program = "${serve}/bin/serve";
};
defaultApp = self.apps.${system}.serve;
devShell = pkgs.mkShell {
buildInputs = buildInputs ++ [ serve ];
};
});
}