-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdefault.nix
More file actions
101 lines (88 loc) · 2.56 KB
/
default.nix
File metadata and controls
101 lines (88 loc) · 2.56 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
{
headless ? false,
release ? true,
sources ? import ./npins,
pkgs ? import sources.nixpkgs { },
fmt ? import ./fmt.nix { inherit sources pkgs; },
supervisord ? import sources.nix-supervisord { inherit pkgs; },
leptos_ssg ? import sources.leptos_ssg { inherit sources pkgs headless; },
cargo_nix ? pkgs.callPackage ./Cargo.nix { inherit release; },
}:
let
supervisordProject = supervisord.mkSupervisor {
project_name = "deadbaed-blog";
paths = supervisord.mkPaths { };
programs = [
{
name = "watchexec";
command = "${pkgs.watchexec}/bin/watchexec -N -w content/ cargo run";
}
{
name = "webserver";
command = "${pkgs.python3}/bin/python -m http.server --directory ./target/blog 4343";
}
(
let
path = "./target/blog";
in
{
name = "tailwind";
command = "cat ${leptos_ssg.tailwind.tailwindLeptosSsg}/style.css > ${path}/style.css";
pre_commands = [ "mkdir -p ${path}" ];
start_secs = 0;
}
)
];
};
createSymlink = pkgs.writeShellScriptBin "createSymlink" ''
ln -s $(npins get-path leptos_ssg) "$@"
'';
updateLockfiles = pkgs.writeShellScriptBin "updateLockfiles" ''
set -xe
symlink="leptos_ssg"
test -L $symlink && rm $symlink && ${createSymlink}/bin/createSymlink $symlink
cargo build
crate2nix generate
'';
blogCrate = cargo_nix.rootCrate.build.override {
features = [
"prod"
];
};
buildWithOpengraph = pkgs.writeShellScriptBin "buildWithOpengraph" ''
set -x
opengraph_css=$(mktemp)
${leptos_ssg.tailwind.copyTailwindOpengraph}/bin/cp-tailwind-opengraph $opengraph_css
${leptos_ssg.opengraph.runWithGeckodriver}/bin/runWithGeckodriver ${blogCrate}/bin/blog $opengraph_css
${leptos_ssg.tailwind.copyTailwindLeptosSsg}/bin/cp-tailwind-leptos_ssg target/blog/www/style.css
rm $opengraph_css
'';
in
{
productionShell = pkgs.mkShellNoCC {
packages = [ buildWithOpengraph ];
shellHook = leptos_ssg.opengraph.supervisordShellHook;
};
shell = pkgs.mkShellNoCC {
inherit (leptos_ssg) env;
packages =
with pkgs;
[
# formatter
fmt
# nix
npins
nil
nixfmt-rfc-style
crate2nix
supervisordProject.supervisord-wrapper
supervisordProject.supervisorctl-wrapper
supervisordProject.supervisord-kill
lnav
createSymlink
updateLockfiles
]
++ leptos_ssg.rustTools;
shellHook = supervisordProject.shellHook;
};
}