From 6b9a77767abaa07847b2353344ca9b07b2c3231a Mon Sep 17 00:00:00 2001 From: codgician <15964984+codgician@users.noreply.github.com> Date: Wed, 27 Nov 2024 21:23:30 +0800 Subject: [PATCH 01/10] nixos/azure: move image specific config out of azure-common --- nixos/modules/virtualisation/azure-common.nix | 88 +++++++++---------- .../virtualisation/azure-config-user.nix | 8 +- nixos/modules/virtualisation/azure-image.nix | 37 +++++++- 3 files changed, 84 insertions(+), 49 deletions(-) diff --git a/nixos/modules/virtualisation/azure-common.nix b/nixos/modules/virtualisation/azure-common.nix index d8d835dd303d..cde10f25ea44 100644 --- a/nixos/modules/virtualisation/azure-common.nix +++ b/nixos/modules/virtualisation/azure-common.nix @@ -1,9 +1,18 @@ -{ config, lib, pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: with lib; let cfg = config.virtualisation.azure; - mlxDrivers = [ "mlx4_en" "mlx4_core" "mlx5_core" ]; + mlxDrivers = [ + "mlx4_en" + "mlx4_core" + "mlx5_core" + ]; in { options.virtualisation.azure = { @@ -13,16 +22,25 @@ in }; }; - imports = [ - ../profiles/headless.nix - ./azure-agent.nix - ]; - config = { - virtualisation.azure.agent.enable = true; + services.waagent.enable = true; + services.cloud-init.enable = true; + services.cloud-init.network.enable = true; + systemd.services.cloud-config.serviceConfig.Restart = "on-failure"; - boot.kernelParams = [ "console=ttyS0" "earlyprintk=ttyS0" "rootdelay=300" "panic=1" "boot.panic_on_fail" ]; - boot.initrd.kernelModules = [ "hv_vmbus" "hv_netvsc" "hv_utils" "hv_storvsc" ]; + boot.kernelParams = [ + "console=ttyS0" + "earlyprintk=ttyS0" + "rootdelay=300" + "panic=1" + "boot.panic_on_fail" + ]; + boot.initrd.kernelModules = [ + "hv_vmbus" + "hv_netvsc" + "hv_utils" + "hv_storvsc" + ]; boot.initrd.availableKernelModules = lib.optionals cfg.acceleratedNetworking mlxDrivers; # Accelerated networking @@ -30,19 +48,9 @@ in matchConfig.Driver = mlxDrivers; linkConfig.Unmanaged = "yes"; }; - networking.networkmanager.unmanaged = lib.mkIf cfg.acceleratedNetworking - (builtins.map (drv: "driver:${drv}") mlxDrivers); - - # Generate a GRUB menu. - boot.loader.grub.device = "/dev/sda"; - - boot.growPartition = true; - - fileSystems."/" = { - device = "/dev/disk/by-label/nixos"; - fsType = "ext4"; - autoResize = true; - }; + networking.networkmanager.unmanaged = lib.mkIf cfg.acceleratedNetworking ( + builtins.map (drv: "driver:${drv}") mlxDrivers + ); # Allow root logins only using the SSH key that the user specified # at instance creation time, ping client connections to avoid timeouts @@ -55,31 +63,19 @@ in # Always include cryptsetup so that NixOps can use it. # sg_scan is needed to finalize disk removal on older kernels - environment.systemPackages = [ pkgs.cryptsetup pkgs.sg3_utils ]; + environment.systemPackages = [ + pkgs.cryptsetup + pkgs.sg3_utils + ]; networking.usePredictableInterfaceNames = false; - services.udev.extraRules = '' - ENV{DEVTYPE}=="disk", KERNEL!="sda" SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNELS=="?:0:0:0", ATTR{removable}=="0", SYMLINK+="disk/by-lun/0", - ENV{DEVTYPE}=="disk", KERNEL!="sda" SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNELS=="?:0:0:1", ATTR{removable}=="0", SYMLINK+="disk/by-lun/1", - ENV{DEVTYPE}=="disk", KERNEL!="sda" SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNELS=="?:0:0:2", ATTR{removable}=="0", SYMLINK+="disk/by-lun/2" - ENV{DEVTYPE}=="disk", KERNEL!="sda" SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNELS=="?:0:0:3", ATTR{removable}=="0", SYMLINK+="disk/by-lun/3" - - ENV{DEVTYPE}=="disk", KERNEL!="sda" SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNELS=="?:0:0:4", ATTR{removable}=="0", SYMLINK+="disk/by-lun/4" - ENV{DEVTYPE}=="disk", KERNEL!="sda" SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNELS=="?:0:0:5", ATTR{removable}=="0", SYMLINK+="disk/by-lun/5" - ENV{DEVTYPE}=="disk", KERNEL!="sda" SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNELS=="?:0:0:6", ATTR{removable}=="0", SYMLINK+="disk/by-lun/6" - ENV{DEVTYPE}=="disk", KERNEL!="sda" SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNELS=="?:0:0:7", ATTR{removable}=="0", SYMLINK+="disk/by-lun/7" - - ENV{DEVTYPE}=="disk", KERNEL!="sda" SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNELS=="?:0:0:8", ATTR{removable}=="0", SYMLINK+="disk/by-lun/8" - ENV{DEVTYPE}=="disk", KERNEL!="sda" SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNELS=="?:0:0:9", ATTR{removable}=="0", SYMLINK+="disk/by-lun/9" - ENV{DEVTYPE}=="disk", KERNEL!="sda" SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNELS=="?:0:0:10", ATTR{removable}=="0", SYMLINK+="disk/by-lun/10" - ENV{DEVTYPE}=="disk", KERNEL!="sda" SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNELS=="?:0:0:11", ATTR{removable}=="0", SYMLINK+="disk/by-lun/11" - - ENV{DEVTYPE}=="disk", KERNEL!="sda" SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNELS=="?:0:0:12", ATTR{removable}=="0", SYMLINK+="disk/by-lun/12" - ENV{DEVTYPE}=="disk", KERNEL!="sda" SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNELS=="?:0:0:13", ATTR{removable}=="0", SYMLINK+="disk/by-lun/13" - ENV{DEVTYPE}=="disk", KERNEL!="sda" SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNELS=="?:0:0:14", ATTR{removable}=="0", SYMLINK+="disk/by-lun/14" - ENV{DEVTYPE}=="disk", KERNEL!="sda" SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNELS=="?:0:0:15", ATTR{removable}=="0", SYMLINK+="disk/by-lun/15" - - ''; + services.udev.extraRules = + with builtins; + concatStringsSep "\n" ( + map (i: '' + ENV{DEVTYPE}=="disk", KERNEL!="sda" SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNELS=="?:0:0:${toString i}", ATTR{removable}=="0", SYMLINK+="disk/by-lun/${toString i}" + '') (lib.range 1 15) + ); }; } diff --git a/nixos/modules/virtualisation/azure-config-user.nix b/nixos/modules/virtualisation/azure-config-user.nix index 267ba50ae025..aa00ac1f4061 100644 --- a/nixos/modules/virtualisation/azure-config-user.nix +++ b/nixos/modules/virtualisation/azure-config-user.nix @@ -8,5 +8,11 @@ # This configures everything but bootstrap services, # which only need to be run once and have already finished # if you are able to see this comment. - imports = [ "${modulesPath}/virtualisation/azure-common.nix" ]; + imports = [ + "${modulesPath}/virtualisation/azure-common.nix" + "${modulesPath}/virtualisation/azure-image.nix" + ]; + + # Please update the VM Generation to the actual value + virtualisation.azureImage.vmGeneration = "v1"; } diff --git a/nixos/modules/virtualisation/azure-image.nix b/nixos/modules/virtualisation/azure-image.nix index 53021e635b07..59e41c063747 100644 --- a/nixos/modules/virtualisation/azure-image.nix +++ b/nixos/modules/virtualisation/azure-image.nix @@ -46,6 +46,14 @@ in ''; }; + label = mkOption { + type = types.str; + default = "nixos"; + description = '' + NixOS partition label. + ''; + }; + vmGeneration = mkOption { type = with types; @@ -76,11 +84,36 @@ in format = "raw"; bootSize = "${toString cfg.bootSize}M"; - partitionTableType = if cfg.vmGeneration == "v2" then "efi" else "legacy"; + partitionTableType = if (cfg.vmGeneration == "v2") then "efi" else "legacy"; - inherit (cfg) contents; + inherit (cfg) contents label; inherit (config.virtualisation) diskSize; inherit config lib pkgs; }; + + boot.growPartition = true; + boot.loader.grub = rec { + efiSupport = (cfg.vmGeneration == "v2"); + device = if efiSupport then "nodev" else "/dev/sda"; + efiInstallAsRemovable = efiSupport; + extraConfig = '' + serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1 + terminal_input --append serial + terminal_output --append serial + ''; + }; + + fileSystems = { + "/" = { + device = "/dev/disk/by-label/${cfg.label}"; + fsType = "ext4"; + autoResize = true; + }; + + "/boot" = lib.mkIf (cfg.vmGeneration == "v2") { + device = "/dev/disk/by-label/ESP"; + fsType = "vfat"; + }; + }; }; } From 0a0f6543ad671e7435fdb131590a2d5bccd9140a Mon Sep 17 00:00:00 2001 From: codgician <15964984+codgician@users.noreply.github.com> Date: Thu, 28 Nov 2024 01:05:58 +0800 Subject: [PATCH 02/10] azure-image: set font & splashImage to null to force text mode, so console for Gen 2 VM could work --- nixos/modules/virtualisation/azure-image.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nixos/modules/virtualisation/azure-image.nix b/nixos/modules/virtualisation/azure-image.nix index 59e41c063747..4ae8849d5004 100644 --- a/nixos/modules/virtualisation/azure-image.nix +++ b/nixos/modules/virtualisation/azure-image.nix @@ -96,7 +96,9 @@ in efiSupport = (cfg.vmGeneration == "v2"); device = if efiSupport then "nodev" else "/dev/sda"; efiInstallAsRemovable = efiSupport; - extraConfig = '' + font = null; + splashImage = null; + extraConfig = lib.mkIf (!efiSupport) '' serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1 terminal_input --append serial terminal_output --append serial From 538efe32631b54a44b5eef7a829d9189abb32454 Mon Sep 17 00:00:00 2001 From: codgician <15964984+codgician@users.noreply.github.com> Date: Fri, 29 Nov 2024 10:18:18 +0800 Subject: [PATCH 03/10] nixos/azure: improve documentation --- nixos/doc/manual/release-notes/rl-2505.section.md | 2 ++ nixos/modules/virtualisation/azure-common.nix | 13 +++++++++++-- nixos/modules/virtualisation/azure-image.nix | 11 ++++++++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/nixos/doc/manual/release-notes/rl-2505.section.md b/nixos/doc/manual/release-notes/rl-2505.section.md index 97e0ca92469f..c6c9692c7e19 100644 --- a/nixos/doc/manual/release-notes/rl-2505.section.md +++ b/nixos/doc/manual/release-notes/rl-2505.section.md @@ -151,6 +151,8 @@ - Support for CUDA 10 has been dropped, as announced in the 24.11 release notes. +- `virtualisation/azure-common.nix`'s filesystem and grub configurations have been moved to `virtualisation/azure-image.nix`. This makes `azure-common.nix` more generic so it could be used for users who generate Azure image using other methods (e.g. nixos-generators and disko). For existing users depending on these configurations, please also import `azure-image.nix`. + - `zammad` has had its support for MySQL removed, since it was never working correctly and is now deprecated upstream. Check the [migration guide](https://docs.zammad.org/en/latest/appendix/migrate-to-postgresql.html) for how to convert your database to PostgreSQL. - The `earlyoom` service is now using upstream systemd service, which enables diff --git a/nixos/modules/virtualisation/azure-common.nix b/nixos/modules/virtualisation/azure-common.nix index cde10f25ea44..6d36838f9eaa 100644 --- a/nixos/modules/virtualisation/azure-common.nix +++ b/nixos/modules/virtualisation/azure-common.nix @@ -24,10 +24,16 @@ in config = { services.waagent.enable = true; + + # Enable cloud-init by default for waagent. + # Otherwise waagent would try manage networking using ifupdown, + # which is currently not availeble in nixpkgs. services.cloud-init.enable = true; services.cloud-init.network.enable = true; systemd.services.cloud-config.serviceConfig.Restart = "on-failure"; + # Ensure kernel outputs to ttyS0 (Azure Serial Console), + # and reboot machine upon fatal boot issues boot.kernelParams = [ "console=ttyS0" "earlyprintk=ttyS0" @@ -35,15 +41,18 @@ in "panic=1" "boot.panic_on_fail" ]; + + # Load Hyper-V kernel modules boot.initrd.kernelModules = [ "hv_vmbus" "hv_netvsc" "hv_utils" "hv_storvsc" ]; - boot.initrd.availableKernelModules = lib.optionals cfg.acceleratedNetworking mlxDrivers; - # Accelerated networking + # Accelerated networking, configured following: + # https://learn.microsoft.com/en-us/azure/virtual-network/accelerated-networking-overview + boot.initrd.availableKernelModules = lib.optionals cfg.acceleratedNetworking mlxDrivers; systemd.network.networks."99-azure-unmanaged-devices.network" = lib.mkIf cfg.acceleratedNetworking { matchConfig.Driver = mlxDrivers; linkConfig.Unmanaged = "yes"; diff --git a/nixos/modules/virtualisation/azure-image.nix b/nixos/modules/virtualisation/azure-image.nix index 4ae8849d5004..252381d0f198 100644 --- a/nixos/modules/virtualisation/azure-image.nix +++ b/nixos/modules/virtualisation/azure-image.nix @@ -76,12 +76,15 @@ in system.build.azureImage = import ../../lib/make-disk-image.nix { name = "azure-image"; inherit (config.image) baseName; + + # Azure expects vhd format with fixed size, + # generating raw format and convert with subformat args afterwards + format = "raw"; postVM = '' ${pkgs.vmTools.qemu}/bin/qemu-img convert -f raw -o subformat=fixed,force_size -O vpc $diskImage $out/${config.image.fileName} rm $diskImage ''; configFile = ./azure-config-user.nix; - format = "raw"; bootSize = "${toString cfg.bootSize}M"; partitionTableType = if (cfg.vmGeneration == "v2") then "efi" else "legacy"; @@ -96,8 +99,13 @@ in efiSupport = (cfg.vmGeneration == "v2"); device = if efiSupport then "nodev" else "/dev/sda"; efiInstallAsRemovable = efiSupport; + # Force grub to run in text mode and output to console + # by disabling font and splash image font = null; splashImage = null; + # For Gen 1 VM, configurate grub output to serial_com0. + # Not needed for Gen 2 VM wbere serial_com0 does not exist, + # and outputing to console is enough to make Azure Serial Console working extraConfig = lib.mkIf (!efiSupport) '' serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1 terminal_input --append serial @@ -108,6 +116,7 @@ in fileSystems = { "/" = { device = "/dev/disk/by-label/${cfg.label}"; + inherit (cfg) label; fsType = "ext4"; autoResize = true; }; From 2249c0859e81d94b4167d966a6e17ca23c9d8d7c Mon Sep 17 00:00:00 2001 From: codgician <15964984+codgician@users.noreply.github.com> Date: Mon, 16 Dec 2024 12:16:20 +0800 Subject: [PATCH 04/10] nixos/waagent: specify OS.OpensslPath by default --- nixos/modules/virtualisation/waagent.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/nixos/modules/virtualisation/waagent.nix b/nixos/modules/virtualisation/waagent.nix index afdcfd6ebe35..e3436a21d9c2 100644 --- a/nixos/modules/virtualisation/waagent.nix +++ b/nixos/modules/virtualisation/waagent.nix @@ -192,6 +192,15 @@ let If set to `null`, the system defaults are used. ''; }; + + OpensslPath = lib.mkOption { + type = types.nullOr types.path; + default = lib.getExe pkgs.openssl; + defaultText = literalExpression "lib.getExe pkgs.openssl"; + description = '' + Specify a path for the openssl binary to use for cryptographic operations. + ''; + }; }; HttpProxy = { From d3d6adec3691b85a548b9b563bba6a107474b144 Mon Sep 17 00:00:00 2001 From: codgician <15964984+codgician@users.noreply.github.com> Date: Mon, 16 Dec 2024 19:49:19 +0800 Subject: [PATCH 05/10] waagent: fix typo --- nixos/modules/virtualisation/waagent.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/virtualisation/waagent.nix b/nixos/modules/virtualisation/waagent.nix index e3436a21d9c2..c90f7a999a42 100644 --- a/nixos/modules/virtualisation/waagent.nix +++ b/nixos/modules/virtualisation/waagent.nix @@ -31,7 +31,7 @@ let attrsOf ( either atom (attrsOf atom) // { - description = atom.description + "or an attribute set of them"; + description = atom.description + " or an attribute set of them"; } ); generate = From c198f97a75a6c5461a0b20c886e3e672c7e1e29b Mon Sep 17 00:00:00 2001 From: codgician <15964984+codgician@users.noreply.github.com> Date: Fri, 20 Dec 2024 19:27:53 +0800 Subject: [PATCH 06/10] waagent: remove passthru.updateScript as it is not needed for nixpkgs-update --- pkgs/by-name/wa/waagent/package.nix | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/pkgs/by-name/wa/waagent/package.nix b/pkgs/by-name/wa/waagent/package.nix index 9b21d6a53a8f..e4240e932f61 100644 --- a/pkgs/by-name/wa/waagent/package.nix +++ b/pkgs/by-name/wa/waagent/package.nix @@ -4,7 +4,6 @@ lib, python3, bash, - gitUpdater, nixosTests, }: @@ -65,13 +64,8 @@ python.pkgs.buildPythonApplication rec { dontWrapPythonPrograms = false; - passthru = { - tests = { - inherit (nixosTests) waagent; - }; - updateScript = gitUpdater { - rev-prefix = "v"; - }; + passthru.tests = { + inherit (nixosTests) waagent; }; meta = { From 6c443658e6ed54bbe0ddb5f07dca91ca4db7ef8f Mon Sep 17 00:00:00 2001 From: codgician <15964984+codgician@users.noreply.github.com> Date: Sun, 29 Dec 2024 19:07:38 +0800 Subject: [PATCH 07/10] nixos/azure: improve code readability --- nixos/modules/virtualisation/azure-common.nix | 15 +++++---------- .../modules/virtualisation/azure-config-user.nix | 4 ++-- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/nixos/modules/virtualisation/azure-common.nix b/nixos/modules/virtualisation/azure-common.nix index 6d36838f9eaa..654adb65ed29 100644 --- a/nixos/modules/virtualisation/azure-common.nix +++ b/nixos/modules/virtualisation/azure-common.nix @@ -5,7 +5,6 @@ ... }: -with lib; let cfg = config.virtualisation.azure; mlxDrivers = [ @@ -16,7 +15,7 @@ let in { options.virtualisation.azure = { - acceleratedNetworking = mkOption { + acceleratedNetworking = lib.mkOption { default = false; description = "Whether the machine's network interface has enabled accelerated networking."; }; @@ -68,7 +67,7 @@ in services.openssh.settings.ClientAliveInterval = 180; # Force getting the hostname from Azure - networking.hostName = mkDefault ""; + networking.hostName = lib.mkDefault ""; # Always include cryptsetup so that NixOps can use it. # sg_scan is needed to finalize disk removal on older kernels @@ -79,12 +78,8 @@ in networking.usePredictableInterfaceNames = false; - services.udev.extraRules = - with builtins; - concatStringsSep "\n" ( - map (i: '' - ENV{DEVTYPE}=="disk", KERNEL!="sda" SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNELS=="?:0:0:${toString i}", ATTR{removable}=="0", SYMLINK+="disk/by-lun/${toString i}" - '') (lib.range 1 15) - ); + services.udev.extraRules = lib.concatMapStrings (i: '' + ENV{DEVTYPE}=="disk", KERNEL!="sda" SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNELS=="?:0:0:${toString i}", ATTR{removable}=="0", SYMLINK+="disk/by-lun/${toString i}" + '') (lib.range 1 15); }; } diff --git a/nixos/modules/virtualisation/azure-config-user.nix b/nixos/modules/virtualisation/azure-config-user.nix index aa00ac1f4061..75bbc716bf7f 100644 --- a/nixos/modules/virtualisation/azure-config-user.nix +++ b/nixos/modules/virtualisation/azure-config-user.nix @@ -13,6 +13,6 @@ "${modulesPath}/virtualisation/azure-image.nix" ]; - # Please update the VM Generation to the actual value - virtualisation.azureImage.vmGeneration = "v1"; + # Please set the VM Generation to the actual value + # virtualisation.azureImage.vmGeneration = "v1"; } From b5592e11652930dd8ce1ddcd91086967ec7b306b Mon Sep 17 00:00:00 2001 From: codgician <15964984+codgician@users.noreply.github.com> Date: Sun, 12 Jan 2025 11:47:55 +0800 Subject: [PATCH 08/10] nixos/azure: enable networking.useNetworkd --- nixos/modules/virtualisation/azure-common.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nixos/modules/virtualisation/azure-common.nix b/nixos/modules/virtualisation/azure-common.nix index 654adb65ed29..80196d74a139 100644 --- a/nixos/modules/virtualisation/azure-common.nix +++ b/nixos/modules/virtualisation/azure-common.nix @@ -31,6 +31,9 @@ in services.cloud-init.network.enable = true; systemd.services.cloud-config.serviceConfig.Restart = "on-failure"; + # cloud-init.network.enable also enables systemd-networkd + networking.useNetworkd = true; + # Ensure kernel outputs to ttyS0 (Azure Serial Console), # and reboot machine upon fatal boot issues boot.kernelParams = [ From b5a03db80725b5f798468f9badbac6dbf5da7f8a Mon Sep 17 00:00:00 2001 From: codgician <15964984+codgician@users.noreply.github.com> Date: Tue, 21 Jan 2025 21:33:50 +0800 Subject: [PATCH 09/10] waagent: patch openssl path --- nixos/modules/virtualisation/waagent.nix | 9 --------- pkgs/by-name/wa/waagent/package.nix | 11 +++++++---- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/nixos/modules/virtualisation/waagent.nix b/nixos/modules/virtualisation/waagent.nix index c90f7a999a42..8baa8381c294 100644 --- a/nixos/modules/virtualisation/waagent.nix +++ b/nixos/modules/virtualisation/waagent.nix @@ -192,15 +192,6 @@ let If set to `null`, the system defaults are used. ''; }; - - OpensslPath = lib.mkOption { - type = types.nullOr types.path; - default = lib.getExe pkgs.openssl; - defaultText = literalExpression "lib.getExe pkgs.openssl"; - description = '' - Specify a path for the openssl binary to use for cryptographic operations. - ''; - }; }; HttpProxy = { diff --git a/pkgs/by-name/wa/waagent/package.nix b/pkgs/by-name/wa/waagent/package.nix index e4240e932f61..dab0a9cc2384 100644 --- a/pkgs/by-name/wa/waagent/package.nix +++ b/pkgs/by-name/wa/waagent/package.nix @@ -4,6 +4,7 @@ lib, python3, bash, + openssl, nixosTests, }: @@ -30,11 +31,13 @@ python.pkgs.buildPythonApplication rec { # Replace tools used in udev rules with their full path and ensure they are present. postPatch = '' substituteInPlace config/66-azure-storage.rules \ - --replace-fail readlink ${coreutils}/bin/readlink \ - --replace-fail cut ${coreutils}/bin/cut \ - --replace-fail /bin/sh ${bash}/bin/sh + --replace-fail readlink '${coreutils}/bin/readlink' \ + --replace-fail cut '${coreutils}/bin/cut' \ + --replace-fail '/bin/sh' '${bash}/bin/sh' substituteInPlace config/99-azure-product-uuid.rules \ - --replace-fail "/bin/chmod" "${coreutils}/bin/chmod" + --replace-fail '/bin/chmod' '${coreutils}/bin/chmod' + substituteInPlace azurelinuxagent/common/conf.py \ + --replace-fail '/usr/bin/openssl' '${openssl}/bin/openssl' ''; propagatedBuildInputs = [ python.pkgs.distro ]; From 1460db45f63a3d402aaff35b7463805c2b6d98a1 Mon Sep 17 00:00:00 2001 From: codgician <15964984+codgician@users.noreply.github.com> Date: Sun, 2 Feb 2025 16:12:00 +0800 Subject: [PATCH 10/10] waagent: optimize option descriptions --- nixos/modules/virtualisation/waagent.nix | 70 +++++++++++++++--------- 1 file changed, 44 insertions(+), 26 deletions(-) diff --git a/nixos/modules/virtualisation/waagent.nix b/nixos/modules/virtualisation/waagent.nix index 8baa8381c294..5d08bb544b3d 100644 --- a/nixos/modules/virtualisation/waagent.nix +++ b/nixos/modules/virtualisation/waagent.nix @@ -110,14 +110,18 @@ let }; ResourceDisk = { - Format = mkEnableOption '' - If set to `true`, waagent formats and mounts the resource disk that the platform provides, - unless the file system type in `ResourceDisk.FileSystem` is set to `ntfs`. - The agent makes a single Linux partition (ID 83) available on the disk. - This partition isn't formatted if it can be successfully mounted. + Format = mkOption { + type = types.bool; + default = false; + description = '' + If set to `true`, waagent formats and mounts the resource disk that the platform provides, + unless the file system type in `ResourceDisk.FileSystem` is set to `ntfs`. + The agent makes a single Linux partition (ID 83) available on the disk. + This partition isn't formatted if it can be successfully mounted. - This configuration has no effect if resource disk is managed by cloud-init. - ''; + This configuration has no effect if resource disk is managed by cloud-init. + ''; + }; FileSystem = mkOption { type = types.str; @@ -155,12 +159,16 @@ let ''; }; - EnableSwap = mkEnableOption '' - If enabled, the agent creates a swap file (`/swapfile`) on the resource disk - and adds it to the system swap space. + EnableSwap = mkOption { + type = types.bool; + default = false; + description = '' + If enabled, the agent creates a swap file (`/swapfile`) on the resource disk + and adds it to the system swap space. - This configuration has no effect if resource disk is managed by cloud-init. - ''; + This configuration has no effect if resource disk is managed by cloud-init. + ''; + }; SwapSizeMB = mkOption { type = types.int; @@ -173,16 +181,24 @@ let }; }; - Logs.Verbose = lib.mkEnableOption '' - If you set this option, log verbosity is boosted. - Waagent logs to `/var/log/waagent.log` and uses the system logrotate functionality to rotate logs. - ''; + Logs.Verbose = lib.mkOption { + type = types.bool; + default = false; + description = '' + If you set this option, log verbosity is boosted. + Waagent logs to `/var/log/waagent.log` and uses the system logrotate functionality to rotate logs. + ''; + }; OS = { - EnableRDMA = lib.mkEnableOption '' - If enabled, the agent attempts to install and then load an RDMA kernel driver - that matches the version of the firmware on the underlying hardware. - ''; + EnableRDMA = lib.mkOption { + type = types.bool; + default = false; + description = '' + If enabled, the agent attempts to install and then load an RDMA kernel driver + that matches the version of the firmware on the underlying hardware. + ''; + }; RootDeviceScsiTimeout = lib.mkOption { type = types.nullOr types.int; @@ -212,17 +228,19 @@ let }; }; - AutoUpdate.Enable = lib.mkEnableOption '' - Enable or disable autoupdate for goal state processing. - ''; + AutoUpdate.Enable = lib.mkOption { + type = types.bool; + default = false; + description = '' + Whether or not to enable autoupdate for goal state processing. + ''; + }; }; }; in { options.services.waagent = { - enable = lib.mkEnableOption '' - Whether to enable the Windows Azure Linux Agent. - ''; + enable = lib.mkEnableOption "Windows Azure Linux Agent"; package = lib.mkPackageOption pkgs "waagent" { };