Skip to content

Commit

Permalink
nixos/azure: improve code readability
Browse files Browse the repository at this point in the history
  • Loading branch information
codgician committed Dec 29, 2024
1 parent 592f23d commit cda9f47
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
16 changes: 6 additions & 10 deletions nixos/modules/virtualisation/azure-common.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
...
}:

with lib;
let
cfg = config.virtualisation.azure;
mlxDrivers = [
Expand All @@ -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.";
};
Expand All @@ -31,6 +30,7 @@ in
services.cloud-init.enable = true;
services.cloud-init.network.enable = true;
systemd.services.cloud-config.serviceConfig.Restart = "on-failure";
networking.useNetworkd = config.systemd.network.enable;

# Ensure kernel outputs to ttyS0 (Azure Serial Console),
# and reboot machine upon fatal boot issues
Expand Down Expand Up @@ -68,7 +68,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
Expand All @@ -79,12 +79,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);
};
}
4 changes: 2 additions & 2 deletions nixos/modules/virtualisation/azure-config-user.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}

0 comments on commit cda9f47

Please sign in to comment.