This repository was archived by the owner on Sep 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
80 lines (67 loc) · 1.98 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
70
71
72
73
74
75
76
77
78
79
80
{
description = "Virtual use space driver for boox devices";
inputs = {
rust-overlay.url = "github:oxalica/rust-overlay";
};
outputs = { self, nixpkgs, systems, rust-overlay }: let
overlays = [ rust-overlay.overlays.default ];
forAllSystems = fn:
nixpkgs.lib.genAttrs (import systems) (system: fn {
pkgs = import nixpkgs {
inherit system overlays;
};
inherit system;
});
in {
devShells = forAllSystems ({ pkgs, system }: with pkgs; {
default = mkShell {
buildInputs = [
rust-bin.nightly.latest.default
rust-analyzer
android-tools
];
nativeBuildInputs = [
pkg-config
];
shellHook = ''
exec ash
'';
};
});
packages = forAllSystems ({ pkgs, system }: with pkgs; rec {
default = daemon;
vboox-bin = rustPlatform.buildRustPackage {
pname = "vboox";
version = "0.1.0";
src = ./.;
cargoLock = {
lockFile = ./Cargo.lock;
};
nativeBuildInputs = [ pkg-config ];
buildInputs = [];
};
daemon = let
inherit vboox-bin;
builder-script = pkgs.writeShellScriptBin "builder" ''
$busybox cp -r $run_vbooxd $out
'';
in derivation rec {
name = "vbooxd";
busybox = "${pkgs.busybox}/bin/busybox";
adb = "${pkgs.android-tools}/bin/adb";
vbooxd = pkgs.writeShellScriptBin "vbooxd" (builtins.readFile ./vbooxd.sh);
run_vbooxd = pkgs.writeShellScriptBin "run-vbooxd" ''
set -e
export PATH=$PATH:${pkgs.android-tools}/bin
export vboox_bin_path=${vboox-bin}/bin/vboox
${busybox} setsid sh -c "exec ${vbooxd}/bin/vbooxd $1" &
'';
builder = "${builder-script}/bin/builder";
inherit system;
};
});
overlays.default = final: prev: {
run-vbooxd = self.packages.${final.stdenv.system}.daemon;
};
};
}