-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
175 lines (144 loc) · 5.54 KB
/
flake.nix
File metadata and controls
175 lines (144 loc) · 5.54 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
{
description = "m'Queue — A privacy-focused native Linux Gmail client";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane.url = "github:ipetkov/crane";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, crane, flake-utils, rust-overlay, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ rust-overlay.overlays.default ];
};
# Use a recent stable Rust toolchain (gtk4-rs 0.11 requires Rust >= 1.92)
rustToolchain = pkgs.rust-bin.stable.latest.default.override {
extensions = [ "rust-src" "rust-analyzer" ];
};
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
# Common native build inputs needed for linking
nativeBuildInputs = with pkgs; [
pkg-config
wrapGAppsHook4
];
# Libraries needed at build time and runtime
buildInputs = with pkgs; [
gtk4
libadwaita
webkitgtk_6_0
sqlite
openssl
glib
dbus
gdk-pixbuf
pango
cairo
graphene
];
# Filter source to include Rust files + data directory
src = pkgs.lib.cleanSourceWith {
src = ./.;
filter = path: type:
(craneLib.filterCargoSources path type)
|| (builtins.match ".*\\.desktop$" path != null)
|| (builtins.match ".*\\.metainfo\\.xml$" path != null)
|| (builtins.match ".*\\.svg$" path != null)
|| (builtins.match ".*\\.css$" path != null)
|| (builtins.match ".*\\.sql$" path != null)
|| (builtins.match ".*/data/.*" path != null);
};
commonArgs = {
inherit src nativeBuildInputs buildInputs;
strictDeps = true;
};
# Build just the cargo dependencies for caching
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
appId = "com.mqmail.MqMail";
# Build the full package
mq-mail = craneLib.buildPackage (commonArgs // {
inherit cargoArtifacts;
# Run tests as part of the build
doCheck = true;
# Install desktop integration files after cargo build
postInstall = ''
# Desktop file
install -Dm644 data/${appId}.desktop \
$out/share/applications/${appId}.desktop
# AppStream metainfo
install -Dm644 data/${appId}.metainfo.xml \
$out/share/metainfo/${appId}.metainfo.xml
# Application icon
install -Dm644 data/${appId}.svg \
$out/share/icons/hicolor/scalable/apps/${appId}.svg
# CSS stylesheet
install -Dm644 data/resources/style.css \
$out/share/mq-mail/style.css
# Bundled fallback icons (used when the user's icon theme
# doesn't include symbolic variants)
cp -r data/icons $out/share/mq-mail/icons
'';
meta = with pkgs.lib; {
description = "m'Queue — A privacy-focused native Linux Gmail client";
license = licenses.gpl3Plus;
platforms = platforms.linux;
mainProgram = "mq-mail";
};
});
in
{
packages = {
default = mq-mail;
mq-mail = mq-mail;
};
devShells.default = craneLib.devShell {
# Inherit all build inputs from the main package
inputsFrom = [ mq-mail ];
packages = with pkgs; [
# Rust development tools (rust-analyzer included via toolchain overlay)
cargo-watch
cargo-nextest
# Debugging
gdb
# GTK4 development
gtk4.dev
libadwaita.dev
# GIO modules needed by WebKitGTK at runtime (TLS, etc.)
glib-networking
# D-Bus debugging
dbus
];
shellHook = ''
# WebKitGTK needs GIO modules at runtime (TLS, etc.).
# wrapGAppsHook4 sets these for the built binary, but cargo run
# runs unwrapped, so we set them here for development.
export GIO_EXTRA_MODULES="${pkgs.glib-networking}/lib/gio/modules''${GIO_EXTRA_MODULES:+:$GIO_EXTRA_MODULES}"
# GTK4 GSettings schemas (EmojiChooser, FileChooser, etc.) must
# be in XDG_DATA_DIRS for cargo run to work.
export XDG_DATA_DIRS="${pkgs.gtk4}/share/gsettings-schemas/${pkgs.gtk4.name}:${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/${pkgs.gsettings-desktop-schemas.name}:${pkgs.glib.out}/share''${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}:/usr/local/share:/usr/share"
echo "m'Queue dev shell ready (Rust $(rustc --version)). Run 'cargo build' to build."
'';
};
checks = {
inherit mq-mail;
mq-mail-clippy = craneLib.cargoClippy (commonArgs // {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
});
mq-mail-fmt = craneLib.cargoFmt {
inherit src;
};
};
}
) // {
overlays.default = final: prev: {
mq-mail = self.packages.${final.system}.default;
};
nixosModules.default = import ./nix/module.nix self;
homeManagerModules.default = import ./nix/module.nix self;
};
}