This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| manuals:vps:userdata [2025/03/14 20:39] – distributions aither | manuals:vps:userdata [2025/03/22 17:29] (current) – aither | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== User Data ====== | ====== User Data ====== | ||
| - | When creating or reinstalling a VPS, vpsAdmin can upload a script or configuration for [[https:// | + | When creating or reinstalling a VPS, vpsAdmin can upload a script or configuration for [[https:// |
| * [[# | * [[# | ||
| * [[# | * [[# | ||
| * [[# | * [[# | ||
| + | * [[# | ||
| + | * [[# | ||
| + | * [[# | ||
| Scripts and configurations can be stored in vpsAdmin, and you can select the configuration method when creating/ | Scripts and configurations can be stored in vpsAdmin, and you can select the configuration method when creating/ | ||
| For development and testing, you can deploy a stored configuration to a VPS at any time: | For development and testing, you can deploy a stored configuration to a VPS at any time: | ||
| - | **vpsAdmin** -> **VPS** -> **User data** -> Edit an entry from the list, then use the **Deploy to VPS** form. | + | **vpsAdmin** -> **VPS** -> **User data** -> Edit an entry from the list, then use the **Deploy to VPS** form. This action will only create the script/ |
| + | it. | ||
| ===== Configuration Formats ===== | ===== Configuration Formats ===== | ||
| Line 67: | Line 71: | ||
| The cloud-init output can be seen in the kernel log and is stored in ''/ | The cloud-init output can be seen in the kernel log and is stored in ''/ | ||
| + | |||
| + | ==== NixOS Configuration ==== | ||
| + | The provided configuration is saved to ''/ | ||
| + | |||
| + | Example configuration: | ||
| + | |||
| + | <code nix> | ||
| + | { config, pkgs, lib, ... }: | ||
| + | { | ||
| + | imports = [ | ||
| + | / | ||
| + | ]; | ||
| + | |||
| + | environment.systemPackages = with pkgs; [ | ||
| + | vim | ||
| + | ]; | ||
| + | |||
| + | services.openssh.enable = true; | ||
| + | services.openssh.settings.PermitRootLogin = " | ||
| + | # | ||
| + | # [ " | ||
| + | |||
| + | systemd.extraConfig = '' | ||
| + | DefaultTimeoutStartSec=900s | ||
| + | ''; | ||
| + | |||
| + | time.timeZone = " | ||
| + | |||
| + | system.stateVersion = " | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | The output of the '' | ||
| + | |||
| + | ==== NixOS Flake Configuration ==== | ||
| + | The configuration is saved to the file ''/ | ||
| + | |||
| + | Example configuration: | ||
| + | |||
| + | <code nix> | ||
| + | { | ||
| + | inputs = { | ||
| + | nixpkgs.url = github: | ||
| + | vpsadminos.url = github: | ||
| + | }; | ||
| + | | ||
| + | outputs = { self, nixpkgs, vpsadminos }: { | ||
| + | # The configuration must include a system named " | ||
| + | nixosConfigurations.vps = nixpkgs.lib.nixosSystem { | ||
| + | modules = [ | ||
| + | ({ config, pkgs, lib, ... }: | ||
| + | { | ||
| + | imports = [ | ||
| + | vpsadminos.nixosConfigurations.container | ||
| + | ]; | ||
| + | |||
| + | environment.systemPackages = with pkgs; [ | ||
| + | vim | ||
| + | ]; | ||
| + | |||
| + | services.openssh.enable = true; | ||
| + | services.openssh.settings.PermitRootLogin = " | ||
| + | # | ||
| + | # [ " | ||
| + | |||
| + | systemd.extraConfig = '' | ||
| + | DefaultTimeoutStartSec=900s | ||
| + | ''; | ||
| + | |||
| + | time.timeZone = " | ||
| + | |||
| + | nixpkgs.hostPlatform = lib.mkDefault " | ||
| + | |||
| + | system.stateVersion = " | ||
| + | }) | ||
| + | ]; | ||
| + | }; | ||
| + | }; | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | The output of the '' | ||
| + | |||
| + | ==== NixOS Flake URI ==== | ||
| + | Upon VPS startup, the command '' | ||
| + | |||
| + | Example configuration: | ||
| + | |||
| + | <code nix> | ||
| + | github: | ||
| + | </ | ||
| + | |||
| + | You can find this configuration at https:// | ||
| + | |||
| + | The output of the '' | ||
| ===== Usage with vpsfreectl ===== | ===== Usage with vpsfreectl ===== | ||