-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
126 lines (109 loc) · 3.16 KB
/
flake.nix
File metadata and controls
126 lines (109 loc) · 3.16 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
{
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; };
runtimeLibs = with pkgs; [
vulkan-loader
libxkbcommon
wayland
libGL
mesa
libx11
libxcursor
libxi
libxrandr
];
runtimeLibPath = pkgs.lib.makeLibraryPath runtimeLibs;
cc-viewer-unwrapped = pkgs.rustPlatform.buildRustPackage {
pname = "cc-viewer";
version = "0.1.0";
src = pkgs.lib.cleanSource ./.;
cargoLock.lockFile = ./Cargo.lock;
nativeBuildInputs = with pkgs; [
pkg-config
];
buildInputs = with pkgs; [
wayland
libxkbcommon
];
};
cc-viewer = pkgs.writeShellScriptBin "cc-viewer" ''
export LD_LIBRARY_PATH="${runtimeLibPath}''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
exec ${cc-viewer-unwrapped}/bin/cc-viewer "$@"
'';
docs = pkgs.stdenv.mkDerivation {
pname = "cc-viewer-docs";
version = "0.1.0";
src = ./docs;
nativeBuildInputs = [ pkgs.mdbook ];
buildPhase = ''
mdbook build
'';
installPhase = ''
cp -r book $out
'';
};
serve-docs = pkgs.writeShellScriptBin "cc-viewer-docs" ''
echo "Serving docs at http://localhost:3000"
${pkgs.python3}/bin/python3 -m http.server 3000 -b 127.0.0.1 -d ${docs}
'';
take-screenshots = pkgs.writeShellScriptBin "cc-viewer-screenshots" ''
export PATH="${pkgs.lib.makeBinPath [
cc-viewer
pkgs.xorg.xorgserver
pkgs.xdotool
pkgs.imagemagick
pkgs.coreutils
]}:$PATH"
export LD_LIBRARY_PATH="${runtimeLibPath}''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
exec ${./scripts/screenshots.sh}
'';
in {
packages = {
default = cc-viewer;
inherit cc-viewer docs;
unwrapped = cc-viewer-unwrapped;
};
apps = {
default = {
type = "app";
program = "${cc-viewer}/bin/cc-viewer";
};
docs = {
type = "app";
program = "${serve-docs}/bin/cc-viewer-docs";
};
screenshots = {
type = "app";
program = "${take-screenshots}/bin/cc-viewer-screenshots";
};
};
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
rustc
cargo
rust-analyzer
clippy
rustfmt
pkg-config
overmind
tmux
mdbook
gh
xvfb-run
xorg.xorgserver
imagemagick
xdotool
];
nativeBuildInputs = with pkgs; [
pkg-config
];
LD_LIBRARY_PATH = runtimeLibPath;
};
});
}