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
|
{ craneLib, lib, rustc
, pkg-config, wrapGAppsHook4, meson, ninja, gettext
, desktop-file-utils
, gtk4, libadwaita, libpanel, libsoup_3, libsecret
, librsvg, glib-networking
}:
let
src = let
suffixes = [ "meson.options" "meson.build" ".sh" ".po" ".pot" ".in" "LINGUAS" ];
suffixFilter = name: type: let
base = baseNameOf (toString name);
in type == "directory" || lib.any (ext: lib.hasSuffix ext base) suffixes;
in lib.cleanSourceWith {
src = ./.; # The original, unfiltered source
filter = path: type: (suffixFilter path type) || (craneLib.filterCargoSources path type);
name = "source"; # Be reproducible, regardless of the directory name
};
args = {
# pname and version are read from Cargo.toml
inherit src;
dummySrc = craneLib.mkDummySrc {
inherit src;
extraDummyScript = ''
cp -r ${./icons.toml} $out/icons.toml
'';
};
strictDeps = true;
# cargoExtraArgs can be used to inject features
buildInputs = [
gtk4 libadwaita libsoup_3 libsecret
librsvg glib-networking
gettext
];
nativeBuildInputs = [ pkg-config wrapGAppsHook4 gettext meson ninja ];
meta = with lib.meta; {
maintainers = with lib.maintainers; [ vikanezrimaya ];
platforms = ["aarch64-linux" "x86_64-linux"];
mainProgram = "bowl";
};
};
cargoArtifacts = craneLib.buildDepsOnly args;
args' = args // { inherit cargoArtifacts; };
in craneLib.mkCargoDerivation (args' // {
# This is the magic sauce to integrate Crane and Meson builds
# (see `src/meson.build` for details on how we call Cargo)
# Use source replacement so we can use the crane vendor tarball
postConfigure = ''
mkdir -p cargo-home
cp $CARGO_HOME/config.toml cargo-home/config.toml
'';
# Move intermediate artefacts from Cargo to the Meson build folder
preBuild = ''
mv ../target/release src/release
'';
# Use standard Meson and Ninja build phases
configurePhase = "mesonConfigurePhase";
buildPhase = "ninjaBuildPhase";
buildPhaseCargoCommand = "# unused";
doCheck = true;
checkPhase = "mesonCheckPhase";
installPhase = "mesonInstallPhase";
nativeBuildInputs = args'.nativeBuildInputs ++ [
rustc # Only needed for Meson to successfully detect the Rust toolchain
# Auxiliary packages
desktop-file-utils
];
doInstallCargoArtifacts = false;
passthru = {
inherit src cargoArtifacts;
clippy = craneLib.cargoClippy args';
};
})
|