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
| | # SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: 2022-2025 Alyssa Ross <hi@alyssa.is>
import ../lib/call-package.nix (
{ src, lib, stdenv, fetchCrate, fetchurl, runCommand, buildPackages
, meson, ninja, pkg-config, rustc
, clang-tools, clippy
, dbus
, appSupport ? true
, hostSupport ? false
}:
let
packageCache = [
(fetchCrate {
pname = "itoa";
version = "1.0.11";
unpack = false;
hash = "sha256-SfHxSHMzVFRQDVlhHxz0pLD3hvmsEfQxKnjkzyVmaVs=";
})
(fetchurl {
name = "miniserde-0.1.41.tar.gz";
url = "https://github.com/dtolnay/miniserde/archive/0.1.41.tar.gz";
hash = "sha256-2u3mIyslKzImtTJpK4M2nwN1PZJhJPa0ZxUDP/TaCAk=";
})
(fetchCrate {
pname = "proc-macro2";
version = "1.0.93";
unpack = false;
hash = "sha256-YJRqaOX50osNwcIbuKl+59AYqLMi+leDi6McyHjiLZk=";
})
(fetchCrate {
pname = "quote";
version = "1.0.38";
unpack = false;
hash = "sha256-Dk3Mqq+JUU9UbGk93BQPcp+VjCR5GKEzgMzMYHg5Gsw=";
})
(fetchCrate {
pname = "ryu";
version = "1.0.17";
unpack = false;
hash = "sha256-6GaXyRYBmoWIyZtfrDzq107AtLgZcHpoL9TSP6DOG6E=";
})
(fetchCrate {
pname = "syn";
version = "2.0.58";
unpack = false;
hash = "sha256-RM+5PzgHC+7jaz/vfU9aFvJ3UdlLGHtmalzF6bDTBoc=";
})
(fetchCrate {
pname = "unicode-ident";
version = "1.0.12";
unpack = false;
hash = "sha256-M1S5rD+uH/Z1XLbbU2g622YWNPZ1V5Qt6k+s6+wP7ks=";
})
];
in
stdenv.mkDerivation (finalAttrs: {
name = "spectrum-tools";
src = lib.fileset.toSource {
root = ../.;
fileset = lib.fileset.intersection src (lib.fileset.unions ([
./meson.build
./meson_options.txt
] ++ lib.optionals appSupport [
./xdg-desktop-portal-spectrum
] ++ lib.optionals hostSupport [
./lsvm
./start-vmm
./subprojects
]));
};
sourceRoot = "source/tools";
depsBuildBuild = lib.optionals hostSupport [ buildPackages.stdenv.cc ];
nativeBuildInputs = [ meson ninja ]
++ lib.optionals appSupport [ pkg-config ]
++ lib.optionals hostSupport [ rustc ];
buildInputs = lib.optionals appSupport [ dbus ];
postPatch = lib.optionals hostSupport (lib.concatMapStringsSep "\n" (crate: ''
mkdir -p subprojects/packagecache
ln -s ${crate} subprojects/packagecache/${crate.name}
'') packageCache);
mesonFlags = [
(lib.mesonBool "app" appSupport)
(lib.mesonBool "host" hostSupport)
"-Dhostfsrootdir=/run/virtiofs/virtiofs0"
"-Dtests=false"
"-Dunwind=false"
"-Dwerror=true"
];
passthru.tests = {
clang-tidy = finalAttrs.finalPackage.overrideAttrs (
{ name, src, nativeBuildInputs ? [], ... }:
{
name = "${name}-clang-tidy";
src = lib.fileset.toSource {
root = ../.;
fileset = lib.fileset.union (lib.fileset.fromSource src) ../.clang-tidy;
};
nativeBuildInputs = nativeBuildInputs ++ [ clang-tools ];
buildPhase = ''
clang-tidy --warnings-as-errors='*' ../**/*.c
touch $out
exit 0
'';
}
);
tests = finalAttrs.finalPackage.overrideAttrs (
{ name, mesonFlags ? [], ... }:
{
name = "${name}-tests";
mesonFlags = mesonFlags ++ [
"-Dunwind=true"
"-Dtests=true"
];
doCheck = true;
}
);
} // lib.optionalAttrs hostSupport {
clippy = finalAttrs.finalPackage.overrideAttrs (
{ name, nativeBuildInputs ? [], ... }:
{
name = "${name}-clippy";
nativeBuildInputs = nativeBuildInputs ++ [ clippy ];
dontBuild = true;
doCheck = true;
dontUseMesonCheck = true;
checkTarget = "clippy";
installPhase = ''touch $out && exit 0'';
}
);
};
meta = with lib; {
description = "First-party Spectrum programs";
license = licenses.eupl12;
maintainers = with maintainers; [ qyliss ];
platforms = platforms.linux;
};
})
) (_: {})
|