77 testers ,
88 which ,
99 fetchgit ,
10- fetchpatch ,
1110
1211 # Xen
1312 acpica-tools ,
6564 withSeaBIOS ? true ,
6665 withOVMF ? true ,
6766 withIPXE ? true ,
68- useDefaultPatchList ? true ,
6967 rev ,
7068 hash ,
7169 patches ? [ ] ,
7270 meta ? { } ,
7371} :
7472
7573let
76- # Inherit helper functions from lib and builtins.
77- inherit ( builtins ) elemAt isAttrs ;
74+ inherit ( lib . meta ) getExe' ;
75+ inherit ( lib . lists ) optional optionals ;
76+ inherit ( lib . systems . inspect . patterns ) isLinux isAarch64 ;
77+ inherit ( lib ) teams ;
7878 inherit ( lib . strings )
79- concatLines
8079 enableFeature
8180 makeSearchPathOutput
8281 optionalString
83- removeSuffix
8482 versionOlder
8583 ;
86- inherit ( lib . platforms ) linux aarch64 ;
87- inherit ( lib ) teams ;
8884 inherit ( lib . licenses )
8985 cc-by-40
9086 gpl2Only
9187 lgpl21Only
9288 mit
9389 ;
94- inherit ( lib . meta ) getExe' ;
95- inherit ( lib . lists )
96- count
97- flatten
98- optional
99- optionals
100- range
101- remove
102- zipListsWith
103- ;
104- inherit ( lib . attrsets ) attrByPath ;
10590
10691 # Mark versions older than minSupportedVersion as EOL.
10792 minSupportedVersion = "4.16" ;
10893
109- ## Generic Patch Handling ##
110-
111- upstreamPatches = import ./patches.nix {
112- inherit lib fetchpatch ;
113- } ;
114-
115- upstreamPatchList = flatten (
116- with upstreamPatches ;
117- [
118- QUBES_REPRODUCIBLE_BUILDS
119- XSA_460
120- XSA_461
121- XSA_462
122- XSA_464
123- ]
124- ) ;
125-
126- ## XSA Patches Description Builder ##
127-
128- # Simple counter for the number of attrsets (patches) in the patches list after normalisation.
129- numberOfPatches = count ( patch : isAttrs patch ) upstreamPatchList ;
130-
131- # builtins.elemAt's index begins at 0, so we subtract 1 from the number of patches in order to
132- # produce the range that will be used in the following builtin.map calls.
133- availablePatchesToTry = range 0 ( numberOfPatches - 1 ) ;
134-
135- # Takes in an attrByPath input, and outputs the attribute value for each patch in a list.
136- # If a patch does not have a given attribute, returns `null`. Use lib.lists.remove null
137- # to remove these junk values, if necessary.
138- retrievePatchAttributes =
139- attributeName :
140- map ( x : attrByPath attributeName null ( elemAt upstreamPatchList x ) ) availablePatchesToTry ;
141-
142- # Produces a list of newline-separated strings that lists the vulnerabilities this
143- # Xen is NOT affected by, due to the applied Xen Security Advisory patches. This is
144- # then used in meta.longDescription, to let users know their Xen is patched against
145- # known vulnerabilities, as the package version isn't always the best indicator.
146- #
147- # Produces something like this: (one string for each XSA)
148- # * [Xen Security Advisory #1](https://xenbits.xenproject.org/xsa/advisory-1.html): **Title for XSA.**
149- # >Description of issue in XSA
150- #Extra lines
151- #are not indented,
152- #but markdown should be
153- #fine with it.
154- # Fixes:
155- # * [CVE-1999-00001](https://www.cve.org/CVERecord?id=CVE-1999-00001)
156- # * [CVE-1999-00002](https://www.cve.org/CVERecord?id=CVE-1999-00002)
157- # * [CVE-1999-00003](https://www.cve.org/CVERecord?id=CVE-1999-00003)
158- writeAdvisoryDescription =
159- if ( remove null ( retrievePatchAttributes [ "xsa" ] ) != [ ] ) then
160- zipListsWith ( a : b : a + b )
161- ( zipListsWith ( a : b : a + "**" + b + ".**\n >" )
162- ( zipListsWith ( a : b : "* [Xen Security Advisory #" + a + "](" + b + "): " )
163- ( remove null ( retrievePatchAttributes [ "xsa" ] ) )
164- (
165- remove null ( retrievePatchAttributes [
166- "meta"
167- "homepage"
168- ] )
169- )
170- )
171- (
172- remove null ( retrievePatchAttributes [
173- "meta"
174- "description"
175- ] )
176- )
177- )
178- (
179- remove null ( retrievePatchAttributes [
180- "meta"
181- "longDescription"
182- ] )
183- )
184- else
185- [ ] ;
186-
18794 #TODO: fix paths instead.
18895 scriptEnvPath = makeSearchPathOutput "out" "bin" [
18996 bridge-utils
205112in
206113
207114stdenv . mkDerivation ( finalAttrs : {
208- inherit pname version ;
115+ inherit pname version patches ;
209116
210- # TODO: Split $out in $bin for binaries and $lib for libraries.
211- # TODO: Python package to be in separate output/package.
212117 outputs = [
213118 "out"
214119 "man"
@@ -217,14 +122,11 @@ stdenv.mkDerivation (finalAttrs: {
217122 "boot"
218123 ] ;
219124
220- # Main Xen source.
221125 src = fetchgit {
222126 url = "https://xenbits.xenproject.org/git-http/xen.git" ;
223127 inherit rev hash ;
224128 } ;
225129
226- patches = optionals useDefaultPatchList upstreamPatchList ++ patches ;
227-
228130 nativeBuildInputs = [
229131 autoPatchelfHook
230132 bison
@@ -265,7 +167,7 @@ stdenv.mkDerivation (finalAttrs: {
265167 "--with-system-qemu"
266168 ( if withSeaBIOS then "--with-system-seabios=${ systemSeaBIOS . firmware } " else "--disable-seabios" )
267169 ( if withOVMF then "--with-system-ovmf=${ OVMF . firmware } " else "--disable-ovmf" )
268- ( if withIPXE then "--with-system-ipxe=${ ipxe } " else "--disable-ipxe" )
170+ ( if withIPXE then "--with-system-ipxe=${ ipxe . firmware } " else "--disable-ipxe" )
269171 ( enableFeature withFlask "xsmpolicy" )
270172 ] ;
271173
@@ -436,14 +338,7 @@ stdenv.mkDerivation (finalAttrs: {
436338 + optionalString withFlask "\n * `xsm-flask`: The [FLASK Xen Security Module](https://wiki.xenproject.org/wiki/Xen_Security_Modules_:_XSM-FLASK). The `xenpolicy-${ version } ` file is available on the `boot` output of this package."
437339 + optionalString withSeaBIOS "\n * `seabios`: Support for the SeaBIOS boot firmware on HVM domains."
438340 + optionalString withOVMF "\n * `ovmf`: Support for the OVMF UEFI boot firmware on HVM domains."
439- + optionalString withIPXE "\n * `ipxe`: Support for the iPXE boot firmware on HVM domains."
440- # Finally, we write a notice explaining which vulnerabilities this Xen is NOT vulnerable to.
441- # This will hopefully give users the peace of mind that their Xen is secure, without needing
442- # to search the source code for the XSA patches.
443- + optionalString ( writeAdvisoryDescription != [ ] ) (
444- "\n \n This Xen Project Hypervisor (${ version } ) has been patched against the following known security vulnerabilities:\n "
445- + removeSuffix "\n " ( concatLines writeAdvisoryDescription )
446- ) ;
341+ + optionalString withIPXE "\n * `ipxe`: Support for the iPXE boot firmware on HVM domains." ;
447342
448343 homepage = "https://xenproject.org/" ;
449344 downloadPage = "https://downloads.xenproject.org/release/xen/${ version } /" ;
@@ -465,8 +360,7 @@ stdenv.mkDerivation (finalAttrs: {
465360
466361 mainProgram = "xl" ;
467362
468- #TODO: Migrate meta.platforms to the new lib.systems.inspect.patterns.* format.
469- platforms = linux ;
470- badPlatforms = aarch64 ;
363+ platforms = [ isLinux ] ;
364+ badPlatforms = [ isAarch64 ] ;
471365 } // meta ;
472366} )
0 commit comments