Skip to content

Commit

Permalink
linuxPackages.hyperv-daemons: Fix aarch64 builds on latest kernel (Ni…
Browse files Browse the repository at this point in the history
  • Loading branch information
ElvishJerricco authored Jan 9, 2025
2 parents 1fe90f7 + 9ebccc2 commit 271ad8a
Showing 1 changed file with 25 additions and 26 deletions.
51 changes: 25 additions & 26 deletions pkgs/os-specific/linux/hyperv-daemons/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
let
libexec = "libexec/hypervkvpd";

fcopy_name = (if lib.versionOlder kernel.version "6.10" then "fcopy" else "fcopy_uio");
fcopy_name =
if lib.versionOlder kernel.version "6.10" then
"fcopy"
else
# The fcopy program is explicitly left out in the Makefile on aarch64
(if stdenv.hostPlatform.isAarch64 then null else "fcopy_uio");

daemons = stdenv.mkDerivation rec {
pname = "hyperv-daemons-bin";
Expand All @@ -21,31 +26,18 @@ let
nativeBuildInputs = [ makeWrapper ];
buildInputs = [ python3 ];

# as of 4.9 compilation will fail due to -Werror=format-security
hardeningDisable = [ "format" ];

postPatch = ''
cd tools/hv
substituteInPlace hv_kvp_daemon.c \
--replace /usr/libexec/hypervkvpd/ $out/${libexec}/
'';

# We don't actually need the hv_get_{dhcp,dns}_info scripts on NixOS in
# their current incarnation but with them in place, we stop the spam of
# errors in the log.
installPhase = ''
runHook preInstall
for f in ${fcopy_name} kvp vss ; do
install -Dm755 hv_''${f}_daemon -t $out/bin
done
install -Dm755 lsvmbus $out/bin/lsvmbus
install -Dm755 hv_get_dhcp_info.sh $out/${libexec}/hv_get_dhcp_info
install -Dm755 hv_get_dns_info.sh $out/${libexec}/hv_get_dns_info
runHook postInstall
'';
makeFlags = [
"ARCH=${stdenv.hostPlatform.parsed.cpu.name}"
"DESTDIR=$(out)"
"sbindir=/bin"
"libexecdir=/libexec"
];

postFixup = ''
wrapProgram $out/bin/hv_kvp_daemon \
Expand Down Expand Up @@ -90,22 +82,29 @@ stdenv.mkDerivation {
];

buildInputs = [ daemons ];
passthru = {
inherit daemons;
};

buildCommand = ''
system=$lib/lib/systemd/system
install -Dm444 ${
service "${
fcopy_name
}" "file copy (FCOPY)" "/sys/bus/vmbus/devices/eb765408-105f-49b6-b4aa-c123b64d17d4/uio"
} $system/hv-fcopy.service
${lib.optionalString (fcopy_name != null) ''
install -Dm444 ${
service fcopy_name "file copy (FCOPY)"
"/sys/bus/vmbus/devices/eb765408-105f-49b6-b4aa-c123b64d17d4/uio"
} $system/hv-fcopy.service
''}
install -Dm444 ${service "kvp" "key-value pair (KVP)" "hv_kvp"} $system/hv-kvp.service
install -Dm444 ${service "vss" "volume shadow copy (VSS)" "hv_vss"} $system/hv-vss.service
cat > $system/hyperv-daemons.target <<EOF
[Unit]
Description=Hyper-V Daemons
Wants=hv-fcopy.service hv-kvp.service hv-vss.service
Wants=hv-kvp.service hv-vss.service
${lib.optionalString (fcopy_name != null) ''
Wants=hv-fcopy.service
''}
EOF
for f in $lib/lib/systemd/system/*.service ; do
Expand Down

0 comments on commit 271ad8a

Please sign in to comment.