-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
70 lines (63 loc) · 1.92 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 = "Simple REPL shell for untyped lambda expressions.";
inputs = {
nixpkgs.url = "nixpkgs";
cf.url = "github:jzbor/cornflakes";
cf.inputs.nixpkgs.follows = "nixpkgs";
crane.url = "github:ipetkov/crane";
};
outputs = { self, nixpkgs, cf, crane }:
(cf.mkLib nixpkgs).flakeForDefaultSystems (system:
with builtins;
let
pkgs = nixpkgs.legacyPackages.${system};
craneLib = crane.mkLib pkgs;
nativeBuildInputs = with pkgs; [
clang
];
in {
### PACKAGES ###
packages = {
default = craneLib.buildPackage {
pname = "lash";
src = ./.;
# Add extra inputs here or any other derivation settings
# doCheck = true;
inherit nativeBuildInputs;
};
docs = pkgs.stdenvNoCC.mkDerivation {
name = "lash-docs";
src = ./.;
buildPhase = "${pkgs.mdbook}/bin/mdbook build book";
installPhase = "mkdir -p $out; cp -rf book/book/* $out/";
};
};
### DEVELOPMENT SHELLS ###
devShells.default = pkgs.mkShellNoCC {
inherit (self.packages.${system}.default) name;
inherit nativeBuildInputs;
};
apps.open-docs = let
port = "8080";
script = pkgs.writeShellApplication {
name = "open-docs";
text = ''
(while ! ${pkgs.lsof}/bin/lsof -i:${port} >/dev/null; do true; done; xdg-open localhost:${port}) &
if ! ${pkgs.lsof}/bin/lsof -i:${port} >/dev/null; then
${pkgs.caddy}/bin/caddy file-server --listen :${port} --root "${self.packages.${system}.docs}" "$@"
else
echo "A server is already running"
fi
'';
};
in {
type = "app";
program = "${script}/bin/open-docs";
};
}) // {
nixConfig = {
extra-substituters = [ "https://cache.jzbor.de/public" ];
extra-trusted-public-keys = [ "public:AdkE6qSLmWKFX4AptLFl+n+RTPIo1lrBhT2sPgfg5s4=" ];
};
};
}