mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-12 20:55:31 +03:00
azure-image: fix, split into bootstrap and regular configurations
Conflicts: nixos/modules/virtualisation/azure-image.nix
This commit is contained in:
parent
db991a4024
commit
2fe9084397
2 changed files with 61 additions and 31 deletions
60
nixos/modules/virtualisation/azure-common.nix
Normal file
60
nixos/modules/virtualisation/azure-common.nix
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
{
|
||||||
|
imports = [ ../profiles/headless.nix ];
|
||||||
|
|
||||||
|
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" ];
|
||||||
|
|
||||||
|
# Generate a GRUB menu.
|
||||||
|
boot.loader.grub.device = "/dev/sda";
|
||||||
|
boot.loader.grub.version = 2;
|
||||||
|
boot.loader.grub.timeout = 0;
|
||||||
|
|
||||||
|
# Don't put old configurations in the GRUB menu. The user has no
|
||||||
|
# way to select them anyway.
|
||||||
|
boot.loader.grub.configurationLimit = 0;
|
||||||
|
|
||||||
|
fileSystems."/".device = "/dev/disk/by-label/nixos";
|
||||||
|
|
||||||
|
# Allow root logins only using the SSH key that the user specified
|
||||||
|
# at instance creation time, ping client connections to avoid timeouts
|
||||||
|
services.openssh.enable = true;
|
||||||
|
services.openssh.permitRootLogin = "without-password";
|
||||||
|
services.openssh.extraConfig = ''
|
||||||
|
ClientAliveInterval 180
|
||||||
|
'';
|
||||||
|
|
||||||
|
# Force getting the hostname from Azure
|
||||||
|
networking.hostName = mkDefault "";
|
||||||
|
|
||||||
|
# Always include cryptsetup so that NixOps can use it.
|
||||||
|
environment.systemPackages = [ pkgs.cryptsetup ];
|
||||||
|
|
||||||
|
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"
|
||||||
|
|
||||||
|
'';
|
||||||
|
|
||||||
|
}
|
|
@ -5,8 +5,6 @@ let
|
||||||
diskSize = "4096";
|
diskSize = "4096";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [ ../profiles/headless.nix ];
|
|
||||||
|
|
||||||
system.build.azureImage =
|
system.build.azureImage =
|
||||||
pkgs.vmTools.runInLinuxVM (
|
pkgs.vmTools.runInLinuxVM (
|
||||||
pkgs.runCommand "azure-image"
|
pkgs.runCommand "azure-image"
|
||||||
|
@ -24,7 +22,6 @@ in
|
||||||
|
|
||||||
postVM =
|
postVM =
|
||||||
''
|
''
|
||||||
echo Converting
|
|
||||||
mkdir -p $out
|
mkdir -p $out
|
||||||
${pkgs.vmTools.qemu}/bin/qemu-img convert -f raw -O vpc $diskImage $out/disk.vhd
|
${pkgs.vmTools.qemu}/bin/qemu-img convert -f raw -O vpc $diskImage $out/disk.vhd
|
||||||
rm $diskImage
|
rm $diskImage
|
||||||
|
@ -93,34 +90,11 @@ in
|
||||||
''
|
''
|
||||||
);
|
);
|
||||||
|
|
||||||
fileSystems."/".device = "/dev/disk/by-label/nixos";
|
imports = [ ./azure-common.nix ];
|
||||||
|
|
||||||
# Azure metadata is available as a CD-ROM drive.
|
# Azure metadata is available as a CD-ROM drive.
|
||||||
fileSystems."/metadata".device = "/dev/sr0";
|
fileSystems."/metadata".device = "/dev/sr0";
|
||||||
|
|
||||||
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" ];
|
|
||||||
|
|
||||||
# Generate a GRUB menu.
|
|
||||||
boot.loader.grub.device = "/dev/sda";
|
|
||||||
boot.loader.grub.version = 2;
|
|
||||||
boot.loader.grub.timeout = 0;
|
|
||||||
|
|
||||||
# Don't put old configurations in the GRUB menu. The user has no
|
|
||||||
# way to select them anyway.
|
|
||||||
boot.loader.grub.configurationLimit = 0;
|
|
||||||
|
|
||||||
# Allow root logins only using the SSH key that the user specified
|
|
||||||
# at instance creation time.
|
|
||||||
services.openssh.enable = true;
|
|
||||||
services.openssh.permitRootLogin = "without-password";
|
|
||||||
|
|
||||||
# Force getting the hostname from Azure
|
|
||||||
networking.hostName = mkDefault "";
|
|
||||||
|
|
||||||
# Always include cryptsetup so that NixOps can use it.
|
|
||||||
environment.systemPackages = [ pkgs.cryptsetup ];
|
|
||||||
|
|
||||||
systemd.services.fetch-ssh-keys =
|
systemd.services.fetch-ssh-keys =
|
||||||
{ description = "Fetch host keys and authorized_keys for root user";
|
{ description = "Fetch host keys and authorized_keys for root user";
|
||||||
|
|
||||||
|
@ -157,8 +131,4 @@ in
|
||||||
serviceConfig.StandardOutput = "journal+console";
|
serviceConfig.StandardOutput = "journal+console";
|
||||||
};
|
};
|
||||||
|
|
||||||
networking.usePredictableInterfaceNames = false;
|
|
||||||
|
|
||||||
#users.extraUsers.root.openssh.authorizedKeys.keys = [ (builtins.readFile <ssh-pub-key>) ];
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue