diff --git a/pkgs/applications/virtualization/xen/generic/0000-xen-ipxe-src-generic.patch b/pkgs/build-support/xen/0000-xen-ipxe-src-generic.patch similarity index 100% rename from pkgs/applications/virtualization/xen/generic/0000-xen-ipxe-src-generic.patch rename to pkgs/build-support/xen/0000-xen-ipxe-src-generic.patch diff --git a/pkgs/applications/virtualization/xen/generic/default.nix b/pkgs/build-support/xen/default.nix similarity index 98% rename from pkgs/applications/virtualization/xen/generic/default.nix rename to pkgs/build-support/xen/default.nix index 250e5a41bfc1fd9..123fc0450a17811 100644 --- a/pkgs/applications/virtualization/xen/generic/default.nix +++ b/pkgs/build-support/xen/default.nix @@ -10,6 +10,7 @@ versionDefinition: which, fetchgit, + fetchpatch, fetchFromGitHub, # Xen @@ -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, @@ -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. @@ -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 = [ @@ -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}" diff --git a/pkgs/applications/virtualization/xen/generic/patches.nix b/pkgs/build-support/xen/patches.nix similarity index 100% rename from pkgs/applications/virtualization/xen/generic/patches.nix rename to pkgs/build-support/xen/patches.nix diff --git a/pkgs/applications/virtualization/xen/4.17/default.nix b/pkgs/by-name/xe/xen/4.17/default.nix similarity index 100% rename from pkgs/applications/virtualization/xen/4.17/default.nix rename to pkgs/by-name/xe/xen/4.17/default.nix diff --git a/pkgs/applications/virtualization/xen/4.18/default.nix b/pkgs/by-name/xe/xen/4.18/default.nix similarity index 100% rename from pkgs/applications/virtualization/xen/4.18/default.nix rename to pkgs/by-name/xe/xen/4.18/default.nix diff --git a/pkgs/applications/virtualization/xen/4.19/default.nix b/pkgs/by-name/xe/xen/4.19/default.nix similarity index 66% rename from pkgs/applications/virtualization/xen/4.19/default.nix rename to pkgs/by-name/xe/xen/4.19/default.nix index a1b133704285524..0e9dd2bbfb0423d 100644 --- a/pkgs/applications/virtualization/xen/4.19/default.nix +++ b/pkgs/by-name/xe/xen/4.19/default.nix @@ -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"; @@ -55,4 +42,4 @@ callPackage (import ../generic/default.nix { patches = [ ]; }; }; -}) ({ ocamlPackages = ocaml-ng.ocamlPackages_4_14; } // genericDefinition) +} ({ ocamlPackages = ocaml-ng.ocamlPackages_4_14; } // genericDefinition) diff --git a/pkgs/applications/virtualization/xen/README.md b/pkgs/by-name/xe/xen/README.md similarity index 99% rename from pkgs/applications/virtualization/xen/README.md rename to pkgs/by-name/xe/xen/README.md index 07087e2fee23014..3176173c2f65383 100644 --- a/pkgs/applications/virtualization/xen/README.md +++ b/pkgs/by-name/xe/xen/README.md @@ -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 diff --git a/pkgs/applications/virtualization/xen/packages.nix b/pkgs/by-name/xe/xen/package.nix similarity index 81% rename from pkgs/applications/virtualization/xen/packages.nix rename to pkgs/by-name/xe/xen/package.nix index 7402edc8bc70f1a..2a37baec0cb3daa 100644 --- a/pkgs/applications/virtualization/xen/packages.nix +++ b/pkgs/by-name/xe/xen/package.nix @@ -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; }; } diff --git a/pkgs/applications/virtualization/xen/update.sh b/pkgs/by-name/xe/xen/update.sh similarity index 94% rename from pkgs/applications/virtualization/xen/update.sh rename to pkgs/by-name/xe/xen/update.sh index e5012768b4e857f..468aa9bd0205462 100755 --- a/pkgs/applications/virtualization/xen/update.sh +++ b/pkgs/by-name/xe/xen/update.sh @@ -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 @@ -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)) @@ -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[*]} @@ -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"; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index b79143c50a5fcd1..a7d88e9942196b9 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -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 { };