From 64e18ca9ffa1d4c4538c18118c105ebedb0fc5db Mon Sep 17 00:00:00 2001 From: Matthew_Cash Date: Sun, 4 Aug 2024 15:21:33 -0700 Subject: [PATCH] hyperv-daemons: fix fcopy build and nixfmt-rfc-style After https://github.com/torvalds/linux/commit/82b0945ce2c2d636d5e893ad50210875c929f257 and https://github.com/torvalds/linux/commit/ec314f61e4fc2d3dd6ea78aa18a5ac276eb1a8e3, the hv_fcopy dameon was renamed to hv_uio_fcopy, breaking hyperv-daemons. I added a check to change the binary name based on the kernel version and to only run the service if the FCOPY_UIO path exists. The path doesn't exist on my machine (not sure why), so I'm not actually able to test the daemon but I think this is better than hyperv being broken for now. --- .../linux/hyperv-daemons/default.nix | 46 +++++++++++++++---- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/pkgs/os-specific/linux/hyperv-daemons/default.nix b/pkgs/os-specific/linux/hyperv-daemons/default.nix index 619318d7e04c..5539e605ca0e 100644 --- a/pkgs/os-specific/linux/hyperv-daemons/default.nix +++ b/pkgs/os-specific/linux/hyperv-daemons/default.nix @@ -1,9 +1,20 @@ -{ stdenv, lib, python2, python3, kernel, makeWrapper, writeText -, gawk, iproute2 }: +{ + stdenv, + lib, + python2, + python3, + kernel, + makeWrapper, + writeText, + gawk, + iproute2, +}: let libexec = "libexec/hypervkvpd"; + fcopy_name = (if lib.versionOlder kernel.version "6.10" then "fcopy" else "fcopy_uio"); + daemons = stdenv.mkDerivation rec { pname = "hyperv-daemons-bin"; inherit (kernel) src version; @@ -26,7 +37,7 @@ let installPhase = '' runHook preInstall - for f in fcopy kvp vss ; do + for f in ${fcopy_name} kvp vss ; do install -Dm755 hv_''${f}_daemon -t $out/bin done @@ -39,11 +50,17 @@ let postFixup = '' wrapProgram $out/bin/hv_kvp_daemon \ - --prefix PATH : $out/bin:${lib.makeBinPath [ gawk iproute2 ]} + --prefix PATH : $out/bin:${ + lib.makeBinPath [ + gawk + iproute2 + ] + } ''; }; - service = bin: title: check: + service = + bin: title: check: writeText "hv-${bin}.service" '' [Unit] Description=Hyper-V ${title} daemon @@ -61,21 +78,30 @@ let WantedBy=hyperv-daemons.target ''; -in stdenv.mkDerivation { +in +stdenv.mkDerivation { pname = "hyperv-daemons"; inherit (kernel) version; # we just stick the bins into out as well as it requires "out" - outputs = [ "bin" "lib" "out" ]; + outputs = [ + "bin" + "lib" + "out" + ]; buildInputs = [ daemons ]; buildCommand = '' system=$lib/lib/systemd/system - install -Dm444 ${service "fcopy" "file copy (FCOPY)" "hv_fcopy" } $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 + 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 <