mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
nixos/virtualisation/linode-image: init (#155426)
This commit is contained in:
parent
88a2353643
commit
28e90d3709
5 changed files with 157 additions and 0 deletions
|
@ -5494,6 +5494,13 @@
|
||||||
githubId = 25618740;
|
githubId = 25618740;
|
||||||
name = "Vincent Cui";
|
name = "Vincent Cui";
|
||||||
};
|
};
|
||||||
|
houstdav000 = {
|
||||||
|
email = "houstdav000@gmail.com";
|
||||||
|
github = "houstdav000";
|
||||||
|
githubId = 17628961;
|
||||||
|
matrix = "@houstdav000:gh0st.ems.host";
|
||||||
|
name = "David Houston";
|
||||||
|
};
|
||||||
hoverbear = {
|
hoverbear = {
|
||||||
email = "operator+nix@hoverbear.org";
|
email = "operator+nix@hoverbear.org";
|
||||||
matrix = "@hoverbear:matrix.org";
|
matrix = "@hoverbear:matrix.org";
|
||||||
|
|
|
@ -142,6 +142,13 @@
|
||||||
OpenSSL now defaults to OpenSSL 3, updated from 1.1.1.
|
OpenSSL now defaults to OpenSSL 3, updated from 1.1.1.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
An image configuration and generator has been added for Linode
|
||||||
|
images, largely based on the present GCE configuration and
|
||||||
|
image.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
<literal>hardware.nvidia</literal> has a new option
|
<literal>hardware.nvidia</literal> has a new option
|
||||||
|
|
|
@ -57,6 +57,8 @@ In addition to numerous new and upgraded packages, this release has the followin
|
||||||
|
|
||||||
- OpenSSL now defaults to OpenSSL 3, updated from 1.1.1.
|
- OpenSSL now defaults to OpenSSL 3, updated from 1.1.1.
|
||||||
|
|
||||||
|
- An image configuration and generator has been added for Linode images, largely based on the present GCE configuration and image.
|
||||||
|
|
||||||
- `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.
|
- `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.
|
||||||
|
|
||||||
<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->
|
<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->
|
||||||
|
|
75
nixos/modules/virtualisation/linode-config.nix
Normal file
75
nixos/modules/virtualisation/linode-config.nix
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
with lib;
|
||||||
|
{
|
||||||
|
imports = [ ../profiles/qemu-guest.nix ];
|
||||||
|
|
||||||
|
services.openssh = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
permitRootLogin = "prohibit-password";
|
||||||
|
passwordAuthentication = mkDefault false;
|
||||||
|
};
|
||||||
|
|
||||||
|
networking = {
|
||||||
|
usePredictableInterfaceNames = false;
|
||||||
|
useDHCP = false;
|
||||||
|
interfaces.eth0 = {
|
||||||
|
useDHCP = true;
|
||||||
|
|
||||||
|
# Linode expects IPv6 privacy extensions to be disabled, so disable them
|
||||||
|
# See: https://www.linode.com/docs/guides/manual-network-configuration/#static-vs-dynamic-addressing
|
||||||
|
tempAddress = "disabled";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# Install diagnostic tools for Linode support
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
inetutils
|
||||||
|
mtr
|
||||||
|
sysstat
|
||||||
|
];
|
||||||
|
|
||||||
|
fileSystems."/" = {
|
||||||
|
fsType = "ext4";
|
||||||
|
device = "/dev/sda";
|
||||||
|
autoResize = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
swapDevices = mkDefault [{ device = "/dev/sdb"; }];
|
||||||
|
|
||||||
|
# Enable LISH and Linode Booting w/ GRUB
|
||||||
|
boot = {
|
||||||
|
# Add Required Kernel Modules
|
||||||
|
# NOTE: These are not documented in the install guide
|
||||||
|
initrd.availableKernelModules = [
|
||||||
|
"virtio_pci"
|
||||||
|
"virtio_scsi"
|
||||||
|
"ahci"
|
||||||
|
"sd_mod"
|
||||||
|
];
|
||||||
|
|
||||||
|
# Set Up LISH Serial Connection
|
||||||
|
kernelParams = [ "console=ttyS0,19200n8" ];
|
||||||
|
kernelModules = [ "virtio_net" ];
|
||||||
|
|
||||||
|
loader = {
|
||||||
|
# Increase Timeout to Allow LISH Connection
|
||||||
|
# NOTE: The image generator tries to set a timeout of 0, so we must force
|
||||||
|
timeout = lib.mkForce 10;
|
||||||
|
|
||||||
|
grub = {
|
||||||
|
enable = true;
|
||||||
|
version = 2;
|
||||||
|
forceInstall = true;
|
||||||
|
device = "nodev";
|
||||||
|
|
||||||
|
# Allow serial connection for GRUB to be able to use LISH
|
||||||
|
extraConfig = ''
|
||||||
|
serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1;
|
||||||
|
terminal_input serial;
|
||||||
|
terminal_output serial
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
66
nixos/modules/virtualisation/linode-image.nix
Normal file
66
nixos/modules/virtualisation/linode-image.nix
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
let
|
||||||
|
cfg = config.virtualisation.linodeImage;
|
||||||
|
defaultConfigFile = pkgs.writeText "configuration.nix" ''
|
||||||
|
_: {
|
||||||
|
imports = [
|
||||||
|
<nixpkgs/nixos/modules/virtualisation/linode-image.nix>
|
||||||
|
];
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
{
|
||||||
|
imports = [ ./linode-config.nix ];
|
||||||
|
|
||||||
|
options = {
|
||||||
|
virtualisation.linodeImage.diskSize = mkOption {
|
||||||
|
type = with types; either (enum (singleton "auto")) ints.positive;
|
||||||
|
default = "auto";
|
||||||
|
example = 1536;
|
||||||
|
description = ''
|
||||||
|
Size of disk image in MB.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
virtualisation.linodeImage.configFile = mkOption {
|
||||||
|
type = with types; nullOr str;
|
||||||
|
default = null;
|
||||||
|
description = ''
|
||||||
|
A path to a configuration file which will be placed at `/etc/nixos/configuration.nix`
|
||||||
|
and be used when switching to a new configuration.
|
||||||
|
If set to `null`, a default configuration is used, where the only import is
|
||||||
|
`<nixpkgs/nixos/modules/virtualisation/linode-image.nix>`
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
virtualisation.linodeImage.compressionLevel = mkOption {
|
||||||
|
type = types.ints.between 1 9;
|
||||||
|
default = 6;
|
||||||
|
description = ''
|
||||||
|
GZIP compression level of the resulting disk image (1-9).
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = {
|
||||||
|
system.build.linodeImage = import ../../lib/make-disk-image.nix {
|
||||||
|
name = "linode-image";
|
||||||
|
# NOTE: Linode specifically requires images to be `gzip`-ed prior to upload
|
||||||
|
# See: https://www.linode.com/docs/products/tools/images/guides/upload-an-image/#requirements-and-considerations
|
||||||
|
postVM = ''
|
||||||
|
${pkgs.gzip}/bin/gzip -${toString cfg.compressionLevel} -c -- $diskImage > \
|
||||||
|
$out/nixos-image-${config.system.nixos.label}-${pkgs.stdenv.hostPlatform.system}.img.gz
|
||||||
|
rm $diskImage
|
||||||
|
'';
|
||||||
|
format = "raw";
|
||||||
|
partitionTableType = "none";
|
||||||
|
configFile = if cfg.configFile == null then defaultConfigFile else cfg.configFile;
|
||||||
|
inherit (cfg) diskSize;
|
||||||
|
inherit config lib pkgs;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
meta.maintainers = with maintainers; [ houstdav000 ];
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue