nixos/azure: improve code readability

This commit is contained in:
codgician 2024-12-29 19:07:38 +08:00
parent c198f97a75
commit 6c443658e6
No known key found for this signature in database
2 changed files with 7 additions and 12 deletions

View file

@ -5,7 +5,6 @@
... ...
}: }:
with lib;
let let
cfg = config.virtualisation.azure; cfg = config.virtualisation.azure;
mlxDrivers = [ mlxDrivers = [
@ -16,7 +15,7 @@ let
in in
{ {
options.virtualisation.azure = { options.virtualisation.azure = {
acceleratedNetworking = mkOption { acceleratedNetworking = lib.mkOption {
default = false; default = false;
description = "Whether the machine's network interface has enabled accelerated networking."; description = "Whether the machine's network interface has enabled accelerated networking.";
}; };
@ -68,7 +67,7 @@ in
services.openssh.settings.ClientAliveInterval = 180; services.openssh.settings.ClientAliveInterval = 180;
# Force getting the hostname from Azure # Force getting the hostname from Azure
networking.hostName = mkDefault ""; networking.hostName = lib.mkDefault "";
# Always include cryptsetup so that NixOps can use it. # Always include cryptsetup so that NixOps can use it.
# sg_scan is needed to finalize disk removal on older kernels # sg_scan is needed to finalize disk removal on older kernels
@ -79,12 +78,8 @@ in
networking.usePredictableInterfaceNames = false; networking.usePredictableInterfaceNames = false;
services.udev.extraRules = services.udev.extraRules = lib.concatMapStrings (i: ''
with builtins; ENV{DEVTYPE}=="disk", KERNEL!="sda" SUBSYSTEM=="block", SUBSYSTEMS=="scsi", KERNELS=="?:0:0:${toString i}", ATTR{removable}=="0", SYMLINK+="disk/by-lun/${toString i}"
concatStringsSep "\n" ( '') (lib.range 1 15);
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)
);
}; };
} }

View file

@ -13,6 +13,6 @@
"${modulesPath}/virtualisation/azure-image.nix" "${modulesPath}/virtualisation/azure-image.nix"
]; ];
# Please update the VM Generation to the actual value # Please set the VM Generation to the actual value
virtualisation.azureImage.vmGeneration = "v1"; # virtualisation.azureImage.vmGeneration = "v1";
} }