-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathflake.nix
More file actions
150 lines (130 loc) · 3.88 KB
/
flake.nix
File metadata and controls
150 lines (130 loc) · 3.88 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
{
nixConfig.bash-prompt = "\[selfprivacy\]$ ";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
inputs.systems.url = "github:nix-systems/default-linux";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.flake-utils.inputs.systems.follows = "systems"; # only build for linux as `buildFlutterApplication` is broken on darwin
outputs =
{
self,
nixpkgs,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
lib = nixpkgs.lib;
fromYAML =
path:
lib.importJSON (
pkgs.runCommand "yml2json" {
nativeBuildInputs = [ pkgs.yq ];
src = path;
} ''cat $src | yq . > $out''
);
pubSpec = fromYAML ./pubspec.yaml;
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
config.android_sdk.accept_license = true;
};
spFlutter = pkgs.flutter335;
androidComposition = pkgs.androidenv.composeAndroidPackages {
platformToolsVersion = "34.0.5";
buildToolsVersions = [ "34.0.0" ];
platformVersions = [
"34"
"33"
"32"
"31"
"30"
];
};
buildDeps = with pkgs; [
gtk3
glib
pcre
util-linux
libselinux
libsepol
libthai
libdatrie
xorg.libXdmcp
xorg.libXtst
libxkbcommon
dbus
at-spi2-core
libsecret
jsoncpp
xorg.libX11
libepoxy
libgcrypt
libgpg-error
];
nativeBuildDeps = with pkgs; [
spFlutter
spFlutter.dart
bash
curl
git
unzip
which
xz
cmake
ninja
pkg-config
wrapGAppsHook3
autoPatchelfHook
androidComposition.androidsdk
openjdk11_headless
clang
xdg-user-dirs
];
releaseDerivation = spFlutter.buildFlutterApplication rec {
pname = pubSpec.name;
version = pubSpec.version;
autoPubspecLock = ./pubspec.lock;
src = ./.;
gitHashes = {
"sp_lints" = "sha256-henUl8JcN6YRSnymnVAiNjm8bmRJGPPjVhLP0EJcZk0=";
};
desktopItem = pkgs.makeDesktopItem {
name = "${pname}";
exec = "@out@/bin/${pname}";
desktopName = "SelfPrivacy";
};
postInstall = ''
patchShebangs $out/bin/$pname
chmod +x $out/bin/$pname
wrapProgram $out/bin/$pname --set PATH ${pkgs.lib.makeBinPath [ pkgs.xdg-user-dirs ]}
mkdir -p $out/share/applications
cp $desktopItem/share/applications/*.desktop $out/share/applications
substituteInPlace $out/share/applications/*.desktop --subst-var out
'';
};
in
{
packages = {
release = releaseDerivation;
};
defaultPackage = releaseDerivation;
devShell = pkgs.mkShell {
buildInputs = buildDeps;
nativeBuildInputs = nativeBuildDeps;
JAVA_HOME = "${pkgs.openjdk11_headless.home}";
ANDROID_HOME = "${androidComposition.androidsdk}/libexec/android-sdk";
ANDROID_SDK_ROOT = "${androidComposition.androidsdk}/libexec/android-sdk";
NIX_LDFLAGS = "-rpath ${pkgs.lib.makeLibraryPath buildDeps}";
NIX_CFLAGS_COMPILE = "-I${pkgs.xorg.libX11}/include";
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildDeps;
shellHook = ''
export TMP=$(mktemp -d)
export HOME="$TMP"
export PUB_CACHE=''${PUB_CACHE:-"$HOME/.pub-cache"}
export ANDROID_EMULATOR_USE_SYSTEM_LIBS=1
'';
};
}
);
}