Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
200 lines (184 loc) · 6.08 KB
/
Copy pathflake.nix
File metadata and controls
200 lines (184 loc) · 6.08 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
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05";
utils.url = "github:numtide/flake-utils";
naersk.url = "github:nix-community/naersk";
naersk.inputs.nixpkgs.follows = "nixpkgs";
rust-overlay.url = "github:oxalica/rust-overlay";
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
cross-naersk.url = "github:icewind1991/cross-naersk";
cross-naersk.inputs.nixpkgs.follows = "nixpkgs";
cross-naersk.inputs.naersk.follows = "naersk";
};
outputs = inputs @ {
self,
nixpkgs,
utils,
naersk,
rust-overlay,
cross-naersk,
}:
utils.lib.eachDefaultSystem (
system: let
overlays = [
(import rust-overlay)
(import ./nix/overlay.nix)
];
pkgs = import nixpkgs {
inherit system overlays;
};
lib = pkgs.lib;
hostTarget = pkgs.stdenv.hostPlatform.config;
targets = [
"x86_64-unknown-linux-musl"
"i686-unknown-linux-musl"
"armv7-unknown-linux-musleabihf"
"aarch64-unknown-linux-musl"
"x86_64-unknown-freebsd"
];
clientTargets = [
"x86_64-unknown-linux-musl"
"i686-unknown-linux-musl"
"armv7-unknown-linux-musleabihf"
"aarch64-unknown-linux-musl"
"x86_64-unknown-freebsd"
"x86_64-pc-windows-gnu"
];
inherit (builtins) listToAttrs fromTOML readFile;
inherit (lib.attrsets) genAttrs nameValuePair;
inherit (lib.lists) map;
inherit (cross-naersk') execSufficForTarget;
artifactForTarget = target: "notify_push";
assetNameForTarget = target: "notify_push-${target}";
cross-naersk' = pkgs.callPackage cross-naersk {
inherit naersk;
toolchain = pkgs.rust-bin.stable.latest.default;
};
src = lib.sources.sourceByRegex (lib.cleanSource ./.) [
"Cargo.*"
"(src|tests|test_client|build.rs|appinfo)(/.*)?"
];
nearskOpt = {
pname = "notify_push";
inherit src;
};
testClientOpts =
nearskOpt
// {
cargoBuildOptions = x:
x
++ [
"-p"
"test_client"
];
};
buildServer = target: (cross-naersk'.buildPackage target) nearskOpt;
buildTestClient = target: (cross-naersk'.buildPackage target) testClientOpts;
hostNaersk = cross-naersk'.hostNaersk;
checks = [
"check"
"clippy"
"test"
];
msrv = (fromTOML (readFile ./Cargo.toml)).package.rust-version;
msrvToolchain = pkgs.rust-bin.stable."${msrv}".default;
naerskMsrv = let
toolchain = msrvToolchain;
in
pkgs.callPackage naersk {
cargo = toolchain;
rustc = toolchain;
};
testClientArtifactForTarget = target: "test_client${execSufficForTarget target}";
in {
# `nix build`
packages =
# cross compile notify_push for all targets
(genAttrs targets buildServer)
//
# cross compile build test_client for all test_client-targets
(listToAttrs (
map (target: nameValuePair "test_client-${target}" (buildTestClient target)) clientTargets
))
//
# check,test,clippy for notify_push
(genAttrs checks (mode: hostNaersk.buildPackage (nearskOpt // {inherit mode;})))
//
# check,test,clippy for test_client
(listToAttrs (
map (
mode:
nameValuePair "test_client-${mode}" (hostNaersk.buildPackage (testClientOpts // {inherit mode;}))
)
checks
))
// rec {
notify_push = hostNaersk.buildPackage nearskOpt;
test_client = hostNaersk.buildPackage testClientOpts;
checkMsrv = naerskMsrv.buildPackage (
nearskOpt
// {
mode = "check";
}
);
default = notify_push;
nixPkgs = pkgs.nextcloud-notify_push;
};
inherit targets clientTargets;
testClientMatrix = {
include =
map (target: {
inherit target;
extension = execSufficForTarget target;
})
clientTargets;
};
checks = {
nixosTest = pkgs.nextcloud-notify_push.tests.with-postgresql-and-redis34.extendNixOS {
module = {
services.nextcloud = {
notify_push.package = hostNaersk.buildPackage nearskOpt;
extraApps.notify_push = lib.mkForce (pkgs.stdenvNoCC.mkDerivation {
pname = "notify_push";
version = "develop";
src = lib.sources.sourceByRegex (lib.cleanSource ./.) [
"(appinfo|lib|img)(/.*)?"
];
phases = [
"unpackPhase"
"installPhase"
];
installPhase = "cp -R ./ $out";
meta = {
license = "agpl3Plus";
homepage = "https://github.com/nextcloud/notify_push";
url = "https://github.com/nextcloud-releases/notify_push";
description = "Push update support for desktop app";
};
});
};
};
};
};
devShells = {
default = cross-naersk'.mkShell ["x86_64-unknown-linux-gnu"] {
nativeBuildInputs = with pkgs; [
(rust-bin.stable.latest.default.override {targets = targets ++ [hostTarget];})
krankerl
cargo-edit
cargo-outdated
cargo-audit
bacon
php
phpPackages.composer
];
};
msrv = cross-naersk'.mkShell ["x86_64-unknown-linux-gnu"] {
nativeBuildInputs = [
msrvToolchain
];
};
};
}
);
}