-
Notifications
You must be signed in to change notification settings - Fork 7
/
flake.nix
135 lines (134 loc) · 4.52 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
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
127
128
129
130
131
132
133
134
135
{
inputs = {
flakeCompat = {
url = "github:edolstra/flake-compat";
flake = false;
};
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nixCargoIntegration = {
url = "github:yusdacra/nix-cargo-integration";
inputs.nixpkgs.follows = "nixpkgs";
};
/*androidPkgs = {
url = "github:tadfisher/android-nixpkgs";
inputs.nixpkgs.follows = "nixpkgs";
};*/
};
outputs = inputs:
let
outputs = inputs.nixCargoIntegration.lib.makeOutputs {
root = ./.;
buildPlatform = "crate2nix";
overrides = {
pkgs = common: prev: {
overlays = prev.overlays ++ [
(_: prev: {
android-sdk = inputs.androidPkgs.sdk.${prev.system} (sdkPkgs: with sdkPkgs; [
cmdline-tools-latest
build-tools-32-0-0
platform-tools
platforms-android-32
emulator
ndk-bundle
]);
})
(_: prev: {
trunk = prev.nciUtils.buildCrate {
root = builtins.fetchGit {
url = "https://github.com/kristoff3r/trunk.git";
ref = "rust_worker";
rev = "0ff1842640553dfefcf0e0b13aee619b17916844";
};
release = true;
};
twiggy = prev.nciUtils.buildCrate {
root = builtins.fetchGit {
url = "https://github.com/rustwasm/twiggy.git";
ref = "master";
rev = "195feee4045f0b89d7cba7492900131ac89803dd";
};
memberName = "twiggy";
release = true;
};
})
];
};
crateOverrides = common: _: {
loqui = prev: {
nativeBuildInputs = (prev.nativeBuildInputs or [ ]) ++ (with common.pkgs; [ makeWrapper wrapGAppsHook ]);
postInstall = with common.pkgs; ''
if [ -f $out/bin/loqui ]; then
wrapProgram $out/bin/loqui\
--set LD_LIBRARY_PATH ${lib.makeLibraryPath common.runtimeLibs}\
--set XDG_DATA_DIRS ${hicolor-icon-theme}/share:${gnome3.adwaita-icon-theme}/share
fi
'';
};
};
shell = common: prev: with common.pkgs; {
#packages = [ android-sdk ];
env = prev.env ++ [
{
name = "XDG_DATA_DIRS";
eval = "$GSETTINGS_SCHEMAS_PATH:$XDG_DATA_DIRS:${hicolor-icon-theme}/share:${gnome3.adwaita-icon-theme}/share";
}
/*{
name = "ANDROID_HOME";
value = "${android-sdk}/share/android-sdk";
}
{
name = "ANDROID_SDK_ROOT";
value = "${android-sdk}/share/android-sdk";
}
{
name = "JAVA_HOME";
value = jdk11.home;
}*/
];
commands = prev.commands ++ [
{
name = "local-dev";
command = "SSL_CERT_FILE=~/.local/share/mkcert/rootCA.pem cargo r";
}
{
help = "Build for the web.";
package = trunk;
}
{
help = "Profile binary size.";
package = twiggy;
}
{
name = "cargo-mobile";
help = "Build for mobile.";
command = "$HOME/.cargo/bin/cargo-mobile $@";
}
];
};
};
};
in
outputs // {
apps = outputs.apps // {
x86_64-linux = outputs.apps.x86_64-linux // {
run-latest =
let
pkgs = import inputs.nixpkgs { system = "x86_64-linux"; config = { allowUnfree = true; }; };
cmd =
pkgs.writeScriptBin "run-loqui-latest" ''
#!${pkgs.stdenv.shell}
mkdir -p /tmp/loqui-binary
cd /tmp/loqui-binary
${pkgs.curl}/bin/curl -L https://github.com/harmony-development/Loqui/releases/download/continuous/loqui-linux > loqui
chmod +x loqui
${pkgs.steam-run}/bin/steam-run ./loqui
'';
in
{
type = "app";
program = "${cmd}/bin/run-loqui-latest";
};
};
};
};
}