Skip to content

Commit

Permalink
(WIP): xen: move to by-name
Browse files Browse the repository at this point in the history
According to all known laws of aviation, there is no way a bee should be
able to fly.
Its wings are too small to get its fat little body off the ground.
The bee, of course, flies anyway because bees don't care what humans
think is impossible.
Yellow, black. Yellow, black. Yellow, black. Yellow, black.
Ooh, black and yellow!
Let's shake it up a little.
Barry! Breakfast is ready!
Coming!
Hang on a second.
Hello?
Barry?
Adam?
Can you believe this is happening?
I can't.
I'll pick you up.
Looking sharp.
Use the stairs, Your father paid good money for those.
Sorry. I'm excited.
Here's the graduate.
We're very proud of you, son.
A perfect report card, all B's.
Very proud.
Ma! I got a thing going here.
You got lint on your fuzz.
Ow! That's me!
Wave to us! We'll be in row 118,000.
Bye!

Signed-off-by: Fernando Rodrigues <[email protected]>
  • Loading branch information
SigmaSquadron committed Sep 28, 2024
1 parent 1b5d35d commit 6d5681b
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ versionDefinition:
which,

fetchgit,
fetchpatch,
fetchFromGitHub,

# Xen
Expand All @@ -32,21 +33,23 @@ versionDefinition:
zlib,
zstd,

slim ? false,

# Xen Optional
withInternalQEMU ? true,
withInternalQEMU ? !slim,
pixman,
glib,

withInternalSeaBIOS ? true,
withInternalSeaBIOS ? !slim,
withSeaBIOS ? !withInternalSeaBIOS,
seabios,

withInternalOVMF ? true,
withInternalOVMF ? !slim,
withOVMF ? !withInternalOVMF,
OVMF,
nasm,

withInternalIPXE ? true,
withInternalIPXE ? !slim,
withIPXE ? !withInternalIPXE,
ipxe,

Expand Down Expand Up @@ -103,12 +106,23 @@ let
branch
version
latest
genericPatchList
pkg
;

# Mark versions older than minSupportedVersion as EOL.
minSupportedVersion = "4.17";

## Generic Patch Handling ##

mappedGenericPatches = builtins.map (patch: upstreamPatches.${patch}) genericPatchList;

upstreamPatches = import ./patches.nix {
inherit lib fetchpatch;
};

upstreamPatchList = lib.lists.flatten mappedGenericPatches;

## Pre-fetched Source Handling ##

# Main attribute set for sources needed to build tools and firmwares.
Expand Down Expand Up @@ -335,7 +349,7 @@ stdenv.mkDerivation (finalAttrs: {
# Generic Xen patches that apply to all Xen versions.
[ ./0000-xen-ipxe-src-generic.patch ]
# Gets the patches from the pkg.xen.patches attribute from the versioned files.
++ lib.lists.optionals (lib.attrsets.hasAttrByPath [ "patches" ] pkg.xen) pkg.xen.patches;
++ lib.lists.optionals (lib.attrsets.hasAttrByPath [ "patches" ] pkg.xen) pkg.xen.patches ++ upstreamPatchList;

nativeBuildInputs =
[
Expand Down Expand Up @@ -390,7 +404,7 @@ stdenv.mkDerivation (finalAttrs: {
]
++ lib.lists.optional (!withInternalQEMU) "--with-system-qemu"

++ lib.lists.optional withSeaBIOS "--with-system-seabios=${seabios}/share/seabios"
++ lib.lists.optional withSeaBIOS "--with-system-seabios=${seabios.firmware}"
++ lib.lists.optional (!withInternalSeaBIOS && !withSeaBIOS) "--disable-seabios"

++ lib.lists.optional withOVMF "--with-system-ovmf=${OVMF.firmware}"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,38 +1,25 @@
{
lib,
fetchpatch,
callPackage,
buildXenPackage,
ocaml-ng,
...
}@genericDefinition:

let
upstreamPatches = import ../generic/patches.nix {
inherit lib;
inherit fetchpatch;
};

upstreamPatchList = lib.lists.flatten (
with upstreamPatches;
[
QUBES_REPRODUCIBLE_BUILDS
XSA_460
XSA_461
XSA_462
]
);
in

callPackage (import ../generic/default.nix {
buildXenPackage {
pname = "xen";
branch = "4.19";
version = "4.19.0";
genericPatchList = [
"QUBES_REPRODUCIBLE_BUILDS"
"XSA_460"
"XSA_461"
"XSA_462"
];
latest = true;
pkg = {
xen = {
rev = "026c9fa29716b0ff0f8b7c687908e71ba29cf239";
hash = "sha256-Q6x+2fZ4ITBz6sKICI0NHGx773Rc919cl+wzI89UY+Q=";
patches = [ ] ++ upstreamPatchList;
patches = [ ];
};
qemu = {
rev = "0df9387c8983e1b1e72d8c574356f572342c03e6";
Expand All @@ -55,4 +42,4 @@ callPackage (import ../generic/default.nix {
patches = [ ];
};
};
}) ({ ocamlPackages = ocaml-ng.ocamlPackages_4_14; } // genericDefinition)
} ({ ocamlPackages = ocaml-ng.ocamlPackages_4_14; } // genericDefinition)
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ are requested by the main Xen build.
Building `xen.efi` requires an `ld` with PE support.[^2]

We use a `makeFlag` to override the `$LD` environment variable to point to our
patched `efiBinutils`. For more information, see the comment in `./generic/default.nix`.
patched `efiBinutils`. For more information, see the comment in `pkgs/build-support/xen/default.nix`.

> [!TIP]
> If you are certain you will not be running Xen in an x86 EFI environment, disable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,19 @@ in
rec {
xen_4_19 = callPackage ./4.19/default.nix { inherit (standard) meta; };
xen_4_19-slim = xen_4_19.override {
withInternalQEMU = false;
withInternalSeaBIOS = false;
withInternalOVMF = false;
withInternalIPXE = false;
slim = true;
inherit (slim) meta;
};

xen_4_18 = callPackage ./4.18/default.nix { inherit (standard) meta; };
xen_4_18-slim = xen_4_18.override {
withInternalQEMU = false;
withInternalSeaBIOS = false;
withInternalOVMF = false;
withInternalIPXE = false;
slim = true;
inherit (slim) meta;
};

xen_4_17 = callPackage ./4.17/default.nix { inherit (standard) meta; };
xen_4_17-slim = xen_4_17.override {
withInternalQEMU = false;
withInternalSeaBIOS = false;
withInternalOVMF = false;
withInternalIPXE = false;
slim = true;
inherit (slim) meta;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ set -o nounset
# This script expects to be called in an interactive terminal somewhere inside Nixpkgs.
echo "Preparing..."
nixpkgs=$(git rev-parse --show-toplevel)
xenPath="$nixpkgs/pkgs/applications/virtualization/xen"
xenPath="$nixpkgs/pkgs/by-name/xe/xen"
rm -rf /tmp/xenUpdateScript
mkdir /tmp/xenUpdateScript

Expand All @@ -34,7 +34,7 @@ latestVersion=$(echo "$versionList" | tr ' ' '\n' | tail --lines=1)
branchList=($(echo "$versionList" | tr ' ' '\n' | sed s/\.[0-9]*$//g | awk '!seen[$0]++'))

# Figure out which versions we're actually going to install.
minSupportedBranch="$(grep " minSupportedVersion = " "$xenPath"/generic/default.nix | sed s/' minSupportedVersion = "'//g | sed s/'";'//g)"
minSupportedBranch="$(grep " minSupportedVersion = " "$nixpkgs"/pkgs/build-support/xen/default.nix | sed s/' minSupportedVersion = "'//g | sed s/'";'//g)"
supportedBranches=($(for version in "${branchList[@]}"; do if [ "$(printf '%s\n' "$minSupportedBranch" "$version" | sort -V | head -n1)" = "$minSupportedBranch" ]; then echo "$version"; fi; done))
supportedVersions=($(for version in "${supportedBranches[@]}"; do echo "$versionList" | tr ' ' '\n' | grep "$version" | tail --lines=1; done))

Expand Down Expand Up @@ -127,7 +127,7 @@ for version in "${supportedVersions[@]}"; do
echo -e "Found the following patches:\n \e[1;32mXen\e[0m: \e[1;33m$discoveredXenPatchesEcho\e[0m\n \e[1;36mQEMU\e[0m: \e[1;33m$discoveredQEMUPatchesEcho\e[0m\n \e[1;36mSeaBIOS\e[0m: \e[1;33m$discoveredSeaBIOSPatchesEcho\e[0m\n \e[1;36mOVMF\e[0m: \e[1;33m$discoveredOVMFPatchesEcho\e[0m\n \e[1;36miPXE\e[0m: \e[1;33m$discoveredIPXEPatchesEcho\e[0m"

# Prepare patches that are called in ./patches.nix.
defaultPatchListInit=("QUBES_REPRODUCIBLE_BUILDS" "XSA_460" "XSA_461" )
defaultPatchListInit=('"QUBES_REPRODUCIBLE_BUILDS"' '"XSA_460"' '"XSA_461"' )
read -r -a defaultPatchList -p $'\nWould you like to override the \e[1;34mupstreamPatches\e[0m list for \e[1;32mXen '"$version"$'\e[0m? If no, press \e[1;34menter\e[0m to use the default patch list: [ \e[1;34m'"${defaultPatchListInit[*]}"$' \e[0m]: '
defaultPatchList=(${defaultPatchList[@]:-${defaultPatchListInit[@]}})
upstreamPatches=${defaultPatchList[*]}
Expand All @@ -138,32 +138,22 @@ for version in "${supportedVersions[@]}"; do
{
lib,
fetchpatch,
callPackage,
buildXenPackage,
ocaml-ng,
...
}@genericDefinition:
let
upstreamPatches = import ../generic/patches.nix {
inherit lib;
inherit fetchpatch;
};
upstreamPatchList = lib.lists.flatten (with upstreamPatches; [
$upstreamPatches
]);
in
callPackage (import ../generic/default.nix {
buildXenPackage {
pname = "xen";
branch = "$branch";
version = "$version";
latest = $latest;
genericPatchList = [ $upstreamPatches ]
pkg = {
xen = {
rev = "$finalVersion";
hash = "$hash";
patches = [ $discoveredXenPatches ] ++ upstreamPatchList;
patches = [ $discoveredXenPatches ];
};
qemu = {
rev = "$finalQEMUVersion";
Expand Down
16 changes: 12 additions & 4 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -34021,10 +34021,18 @@ with pkgs;

xdotool = callPackage ../tools/X11/xdotool { };

xenPackages = recurseIntoAttrs (callPackage ../applications/virtualization/xen/packages.nix {});

xen = xenPackages.xen_4_19;
xen-slim = xenPackages.xen_4_19-slim;
buildXenPackage = callPackage ../build-support/xen { };

inherit (callPackages ../by-name/xe/xen/package.nix { })
xen_4_19
xen_4_18
xen_4_17
xen_4_19-slim
xen_4_18-slim
xen_4_17-slim;

xen = xen_4_19;
xen-slim = xen_4_19-slim;

xkbset = callPackage ../tools/X11/xkbset { };

Expand Down

0 comments on commit 6d5681b

Please sign in to comment.