-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
229 lines (215 loc) · 6.8 KB
/
flake.nix
File metadata and controls
229 lines (215 loc) · 6.8 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
{
description = "Temporis rust flake with slint support";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
crane = {
url = "github:ipetkov/crane";
};
gitignore.url = "github:hercules-ci/gitignore.nix";
gitignore.inputs.nixpkgs.follows = "nixpkgs";
};
outputs =
inputs@{
flake-parts,
crane,
gitignore,
self,
...
}:
let
systems = [
"x86_64-linux"
"aarch64-darwin"
"x86_64-darwin"
];
in
# https://flake.parts/
flake-parts.lib.mkFlake { inherit inputs; } {
debug = true;
systems = systems;
perSystem =
{
pkgs,
inputs',
self',
system,
...
}:
let
gitignoreSource = gitignore.lib.gitignoreSource;
nodejs = pkgs.nodejs_latest;
# rust
rustChannel = "stable";
fenix = inputs'.fenix.packages;
rustToolchain = (
fenix.combine [
fenix.${rustChannel}.toolchain
# https://doc.rust-lang.org/rustc/platform-support.html
# For more targets add:
# fenix.targets.aarch64-linux-android."${rustChannel}".rust-std
# fenix.targets.wasm32-wasip1."${rustChannel}".rust-std
]
);
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
ldLibraryPath =
with pkgs;
lib.makeLibraryPath [
wayland
libxkbcommon
fontconfig
libGL
libx11
libxcursor
libxi
alsa-lib
libinput
libgbm
freetype
# libinput-gestures
# glibc
];
# app
meta = {
description = "A Pomodoro application helping you stay focused, fresh and healthy";
longDescription = "Temporis is a Pomodoro application designed to help you seamlessly switch between focused work and periods of diffused thinking";
homepage = "https://github.com/reciperium/temporis";
license = with pkgs; lib.licenses.gpl3;
platforms = systems;
mainProgram = "temporis";
};
temporis-desktop-file = pkgs.makeDesktopItem {
name = "com.reciperium.temporis";
exec = "temporis"; # recommended way, so users can wrap around it?
desktopName = "Temporis";
genericName = "Pomodoro Application";
icon = "com.reciperium.temporis";
comment = "A pomodoro timer focused on attention and well-being";
categories = [ "Utility" ];
terminal = false;
keywords = [
"pomodoro"
"timer"
"productivity"
];
};
src = pkgs.lib.fileset.toSource {
root = ./.;
fileset = pkgs.lib.fileset.unions [
./site
./assets/icons
./assets/images
];
};
in
{
packages = {
temporis-bin = craneLib.buildPackage {
# name = "temporis";
src = gitignoreSource ./.;
strictDeps = true;
nativeBuildInputs = with pkgs; [
# fontconfig
pkg-config
rustPlatform.bindgenHook
llvmPackages.bintools
];
buildInputs =
with pkgs;
[ ]
++ lib.optionals stdenv.isLinux [
fontconfig
alsa-lib
makeWrapper
];
meta = meta;
env = pkgs.lib.optionalAttrs (system == "x86_64-linux") {
RUSTFLAGS = "-C link-self-contained=-linker";
};
};
# installable for NixOS
temporis-desktop = pkgs.stdenv.mkDerivation {
name = "temporis-desktop";
nativeBuildInputs = with pkgs; [ ] ++ lib.optionals stdenv.isLinux [ copyDesktopItems ];
buildInputs =
with pkgs;
[ ]
++ lib.optionals stdenv.isLinux [
makeWrapper
];
src = self;
buildPhase = ''
mkdir -p "$out/bin"
install -Dm755 ${self'.packages.temporis-bin}/bin/temporis $out/bin/temporis
'';
desktopItems = [ temporis-desktop-file ];
installPhase =
with pkgs;
''
# install icon
mkdir -p "$out/share/icons/hicolor/scalable/apps"
install -Dm644 assets/icons/logo.svg $out/share/icons/hicolor/scalable/apps/com.reciperium.temporis.svg
''
+ lib.optionalString stdenv.isLinux ''
wrapProgram $out/bin/temporis --set LD_LIBRARY_PATH "${ldLibraryPath}"
''
+ ''
runHook postInstall
'';
meta = meta;
};
site = pkgs.buildNpmPackage {
name = "site";
src = src;
sourceRoot = "${src.name}/site";
npmDeps = pkgs.importNpmLock {
npmRoot = ./site;
};
npmConfigHook = pkgs.importNpmLock.npmConfigHook;
buildPhase = ''
${nodejs}/bin/npm run build --unsafe-perm=true
'';
installPhase = ''
mkdir -p $out
cp -R dist/* $out
'';
nodejs = nodejs;
};
temporis-desktop-file = temporis-desktop-file;
default = self'.packages.temporis-desktop;
};
devShells = {
default = pkgs.mkShell {
name = "dev";
# Available packages on https://search.nixos.org/packages
buildInputs = with pkgs; [
just
rustToolchain
alsa-lib
slint-viewer
slint-lsp
bacon
jq
cachix
gettext
commitizen
nodejs
];
shellHook = ''
echo "Welcome to the rust devshell!"
'';
LD_LIBRARY_PATH = "\$LD_LIBRARY_PATH:${ldLibraryPath}";
};
};
};
};
nixConfig = {
extra-substituters = [ "https://reciperium.cachix.org" ];
extra-trusted-public-keys = [
"reciperium.cachix.org-1:xAmT5McauMNqMlXkkyVzDzoDNO6G+Zo7gCAUYaPsGxQ="
];
};
}