-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
167 lines (145 loc) · 5.2 KB
/
flake.nix
File metadata and controls
167 lines (145 loc) · 5.2 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
{
description = "Nix flake for the openit command-line tool";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
self,
nixpkgs,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
};
lib = pkgs.lib;
cargoToml = lib.importTOML ./Cargo.toml;
crateName = cargoToml.package.name;
crateVersion = cargoToml.package.version;
nativeBuildInputs = with pkgs; [ pkg-config ];
# GTK4 dependencies only needed for icon-picker feature
buildInputs = with pkgs; [
openssl
];
# Base package without icon-picker
cratePackage = pkgs.rustPlatform.buildRustPackage {
pname = crateName;
version = crateVersion;
src = lib.cleanSource ./.;
cargoLock.lockFile = ./Cargo.lock;
cargoHash = lib.fakeSha256;
inherit nativeBuildInputs;
buildInputs = [ ];
meta = with lib; {
description = "Small helper to launch applications with custom rules";
license = licenses.mit;
maintainers = [ ];
};
};
# Package with icon-picker feature enabled
cratePackageWithIconPicker = pkgs.rustPlatform.buildRustPackage {
pname = "${crateName}-with-icon-picker";
version = crateVersion;
src = lib.cleanSource ./.;
cargoLock.lockFile = ./Cargo.lock;
cargoHash = lib.fakeSha256;
buildFeatures = [ "icon-picker" ];
inherit nativeBuildInputs;
buildInputs = buildInputs;
meta = with lib; {
description = "Small helper to launch applications with custom rules (with icon-picker)";
license = licenses.mit;
maintainers = [ ];
};
};
# Cross-compilation helper function
mkCrossPackage =
crossPkgs: targetName:
crossPkgs.rustPlatform.buildRustPackage {
pname = "${crateName}-${targetName}";
version = crateVersion;
src = lib.cleanSource ./.;
cargoLock.lockFile = ./Cargo.lock;
cargoHash = lib.fakeSha256;
# Don't include pkg-config for cross-compilation as it often fails
# and isn't needed for static Rust binaries
nativeBuildInputs = [ ];
buildInputs = [ ];
meta = with lib; {
description = "Small helper to launch applications with custom rules (${targetName})";
license = licenses.mit;
maintainers = [ ];
};
};
# Android build helper function using Nix cross-compilation
mkAndroidPackage =
androidPkgs: targetName:
androidPkgs.rustPlatform.buildRustPackage {
pname = "${crateName}-android-${targetName}";
version = crateVersion;
src = lib.cleanSource ./.;
cargoLock.lockFile = ./Cargo.lock;
cargoHash = lib.fakeSha256;
nativeBuildInputs = [ ];
buildInputs = [ ];
# Disable tests for cross-compilation
doCheck = false;
meta = with lib; {
description = "Small helper to launch applications with custom rules (Android ${targetName})";
license = licenses.mit;
maintainers = [ ];
};
};
in
{
packages = {
default = cratePackage;
with-icon-picker = cratePackageWithIconPicker;
# Cross-platform builds
# Windows
windows-x86_64 = mkCrossPackage pkgs.pkgsCross.mingwW64 "windows-x86_64";
# macOS
macos-aarch64 = mkCrossPackage pkgs.pkgsCross.aarch64-darwin "macos-aarch64";
macos-x86_64 = mkCrossPackage pkgs.pkgsCross.x86_64-darwin "macos-x86_64";
# Linux
linux-x86_64 = mkCrossPackage pkgs.pkgsCross.gnu64 "linux-x86_64";
linux-aarch64 = mkCrossPackage pkgs.pkgsCross.aarch64-multiplatform "linux-aarch64";
# Android builds for common architectures
android-aarch64 = mkAndroidPackage pkgs.pkgsCross.aarch64-android-prebuilt "aarch64";
android-armv7 = mkAndroidPackage pkgs.pkgsCross.armv7a-android-prebuilt "armv7";
android-x86_64 = mkAndroidPackage pkgs.pkgsCross.x86_64-android-prebuilt "x86_64";
};
apps.default = {
type = "app";
program = "${cratePackage}/bin/${crateName}";
};
devShells.default = pkgs.mkShell {
packages = with pkgs; [
rustc
cargo
clippy
rustfmt
rust-analyzer
cargo-edit
cargo-deny
cargo-audit
cargo-tarpaulin
cargo-ndk
rustup
tokei
];
# Include GTK4 in dev shell for icon-picker development
buildInputs = buildInputs;
inherit nativeBuildInputs;
};
formatter = pkgs.alejandra;
checks.build = cratePackage;
}
);
}