diff options
| author | Franck Cuny <franck@fcuny.net> | 2025-09-08 08:06:04 -0700 |
|---|---|---|
| committer | Franck Cuny <franck@fcuny.net> | 2025-09-08 08:06:04 -0700 |
| commit | 3b47113c28c5180d4d5d710e3c1fe74f95aa7226 (patch) | |
| tree | c4839046153034017da079f4bd5ff64c32d984b1 /modules/hardware | |
| parent | move deployment bits to colmena declaration (diff) | |
| download | infra-3b47113c28c5180d4d5d710e3c1fe74f95aa7226.tar.gz | |
move droplet specific settings to its own module
Diffstat (limited to 'modules/hardware')
| -rw-r--r-- | modules/hardware/default.nix | 6 | ||||
| -rw-r--r-- | modules/hardware/do-droplet.nix | 70 |
2 files changed, 76 insertions, 0 deletions
diff --git a/modules/hardware/default.nix b/modules/hardware/default.nix new file mode 100644 index 0000000..f6ea0d9 --- /dev/null +++ b/modules/hardware/default.nix @@ -0,0 +1,6 @@ +{ ... }: +{ + imports = [ + ./do-droplet.nix + ]; +} diff --git a/modules/hardware/do-droplet.nix b/modules/hardware/do-droplet.nix new file mode 100644 index 0000000..50317d6 --- /dev/null +++ b/modules/hardware/do-droplet.nix @@ -0,0 +1,70 @@ +{ lib, config, ... }: +let + cfg = config.my.hardware.do-droplet; + inherit (lib) mkEnableOption mkIf; +in +{ + options.my.hardware.do-droplet = { + enable = mkEnableOption "DigitalOcean Droplet hardware defaults"; + }; + + config = mkIf cfg.enable { + boot.loader.grub.device = "/dev/vda"; + + # do not use DHCP, as DigitalOcean provisions IPs using cloud-init + networking.useDHCP = lib.mkForce false; + + # this one seems to always be broken + systemd.services.growpart.enable = false; + + # in order to get networking setup we need to enable it in cloud-init + # Disables all modules that do not work with NixOS + # Based on https://github.com/nix-community/nixos-anywhere-examples/blob/7f945ff0ae676c0eb77360b892add91328dd1f17/digitalocean.nix + services.cloud-init = { + enable = true; + network.enable = true; + settings = { + datasource_list = [ + "ConfigDrive" + "Digitalocean" + ]; + datasource.ConfigDrive = { }; + datasource.Digitalocean = { }; + # Based on https://github.com/canonical/cloud-init/blob/main/config/cloud.cfg.tmpl + cloud_init_modules = [ + "seed_random" + "bootcmd" + "write_files" + "growpart" + "resizefs" + "set_hostname" + "update_hostname" + "set_password" + ]; + cloud_config_modules = [ + "ssh-import-id" + "keyboard" + "runcmd" + "disable_ec2_metadata" + ]; + cloud_final_modules = [ + "write_files_deferred" + "puppet" + "chef" + "ansible" + "mcollective" + "salt_minion" + "reset_rmc" + "scripts_per_once" + "scripts_per_boot" + "scripts_user" + "ssh_authkey_fingerprints" + "keys_to_console" + "install_hotplug" + "phone_home" + "final_message" + ]; + }; + }; + }; +} |
