lol

nixos/virtualisation/linode-image: init (#155426)

authored by

David Houston and committed by
GitHub
28e90d37 88a23536

+157
+7
maintainers/maintainer-list.nix
··· 5494 5494 githubId = 25618740; 5495 5495 name = "Vincent Cui"; 5496 5496 }; 5497 + houstdav000 = { 5498 + email = "houstdav000@gmail.com"; 5499 + github = "houstdav000"; 5500 + githubId = 17628961; 5501 + matrix = "@houstdav000:gh0st.ems.host"; 5502 + name = "David Houston"; 5503 + }; 5497 5504 hoverbear = { 5498 5505 email = "operator+nix@hoverbear.org"; 5499 5506 matrix = "@hoverbear:matrix.org";
+7
nixos/doc/manual/from_md/release-notes/rl-2211.section.xml
··· 144 144 </listitem> 145 145 <listitem> 146 146 <para> 147 + An image configuration and generator has been added for Linode 148 + images, largely based on the present GCE configuration and 149 + image. 150 + </para> 151 + </listitem> 152 + <listitem> 153 + <para> 147 154 <literal>hardware.nvidia</literal> has a new option 148 155 <literal>open</literal> that can be used to opt in the 149 156 opensource version of NVIDIA kernel driver. Note that the
+2
nixos/doc/manual/release-notes/rl-2211.section.md
··· 57 57 58 58 - OpenSSL now defaults to OpenSSL 3, updated from 1.1.1. 59 59 60 + - An image configuration and generator has been added for Linode images, largely based on the present GCE configuration and image. 61 + 60 62 - `hardware.nvidia` has a new option `open` that can be used to opt in the opensource version of NVIDIA kernel driver. Note that the driver's support for GeForce and Workstation GPUs is still alpha quality, see [NVIDIA Releases Open-Source GPU Kernel Modules](https://developer.nvidia.com/blog/nvidia-releases-open-source-gpu-kernel-modules/) for the official announcement. 61 63 62 64 <!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->
+75
nixos/modules/virtualisation/linode-config.nix
··· 1 + { config, lib, pkgs, ... }: 2 + with lib; 3 + { 4 + imports = [ ../profiles/qemu-guest.nix ]; 5 + 6 + services.openssh = { 7 + enable = true; 8 + 9 + permitRootLogin = "prohibit-password"; 10 + passwordAuthentication = mkDefault false; 11 + }; 12 + 13 + networking = { 14 + usePredictableInterfaceNames = false; 15 + useDHCP = false; 16 + interfaces.eth0 = { 17 + useDHCP = true; 18 + 19 + # Linode expects IPv6 privacy extensions to be disabled, so disable them 20 + # See: https://www.linode.com/docs/guides/manual-network-configuration/#static-vs-dynamic-addressing 21 + tempAddress = "disabled"; 22 + }; 23 + }; 24 + 25 + # Install diagnostic tools for Linode support 26 + environment.systemPackages = with pkgs; [ 27 + inetutils 28 + mtr 29 + sysstat 30 + ]; 31 + 32 + fileSystems."/" = { 33 + fsType = "ext4"; 34 + device = "/dev/sda"; 35 + autoResize = true; 36 + }; 37 + 38 + swapDevices = mkDefault [{ device = "/dev/sdb"; }]; 39 + 40 + # Enable LISH and Linode Booting w/ GRUB 41 + boot = { 42 + # Add Required Kernel Modules 43 + # NOTE: These are not documented in the install guide 44 + initrd.availableKernelModules = [ 45 + "virtio_pci" 46 + "virtio_scsi" 47 + "ahci" 48 + "sd_mod" 49 + ]; 50 + 51 + # Set Up LISH Serial Connection 52 + kernelParams = [ "console=ttyS0,19200n8" ]; 53 + kernelModules = [ "virtio_net" ]; 54 + 55 + loader = { 56 + # Increase Timeout to Allow LISH Connection 57 + # NOTE: The image generator tries to set a timeout of 0, so we must force 58 + timeout = lib.mkForce 10; 59 + 60 + grub = { 61 + enable = true; 62 + version = 2; 63 + forceInstall = true; 64 + device = "nodev"; 65 + 66 + # Allow serial connection for GRUB to be able to use LISH 67 + extraConfig = '' 68 + serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1; 69 + terminal_input serial; 70 + terminal_output serial 71 + ''; 72 + }; 73 + }; 74 + }; 75 + }
+66
nixos/modules/virtualisation/linode-image.nix
··· 1 + { config, lib, pkgs, ... }: 2 + 3 + with lib; 4 + let 5 + cfg = config.virtualisation.linodeImage; 6 + defaultConfigFile = pkgs.writeText "configuration.nix" '' 7 + _: { 8 + imports = [ 9 + <nixpkgs/nixos/modules/virtualisation/linode-image.nix> 10 + ]; 11 + } 12 + ''; 13 + in 14 + { 15 + imports = [ ./linode-config.nix ]; 16 + 17 + options = { 18 + virtualisation.linodeImage.diskSize = mkOption { 19 + type = with types; either (enum (singleton "auto")) ints.positive; 20 + default = "auto"; 21 + example = 1536; 22 + description = '' 23 + Size of disk image in MB. 24 + ''; 25 + }; 26 + 27 + virtualisation.linodeImage.configFile = mkOption { 28 + type = with types; nullOr str; 29 + default = null; 30 + description = '' 31 + A path to a configuration file which will be placed at `/etc/nixos/configuration.nix` 32 + and be used when switching to a new configuration. 33 + If set to `null`, a default configuration is used, where the only import is 34 + `<nixpkgs/nixos/modules/virtualisation/linode-image.nix>` 35 + ''; 36 + }; 37 + 38 + virtualisation.linodeImage.compressionLevel = mkOption { 39 + type = types.ints.between 1 9; 40 + default = 6; 41 + description = '' 42 + GZIP compression level of the resulting disk image (1-9). 43 + ''; 44 + }; 45 + }; 46 + 47 + config = { 48 + system.build.linodeImage = import ../../lib/make-disk-image.nix { 49 + name = "linode-image"; 50 + # NOTE: Linode specifically requires images to be `gzip`-ed prior to upload 51 + # See: https://www.linode.com/docs/products/tools/images/guides/upload-an-image/#requirements-and-considerations 52 + postVM = '' 53 + ${pkgs.gzip}/bin/gzip -${toString cfg.compressionLevel} -c -- $diskImage > \ 54 + $out/nixos-image-${config.system.nixos.label}-${pkgs.stdenv.hostPlatform.system}.img.gz 55 + rm $diskImage 56 + ''; 57 + format = "raw"; 58 + partitionTableType = "none"; 59 + configFile = if cfg.configFile == null then defaultConfigFile else cfg.configFile; 60 + inherit (cfg) diskSize; 61 + inherit config lib pkgs; 62 + }; 63 + }; 64 + 65 + meta.maintainers = with maintainers; [ houstdav000 ]; 66 + }