diff --git a/README.md b/README.md index 75fd0c8..1bd9686 100644 --- a/README.md +++ b/README.md @@ -41,5 +41,14 @@ Error: POST https://api.digitalocean.com/v2/droplets: 422 (request "116c778d-8e7 Oh. [Well that sucks](https://docs.digitalocean.com/products/custom-images/details/limits/). Digital Ocean can't do IPv6 on custom images. ## With cloud-init + +I tried creating a cloud-init function based on NixOS-infect. You can see the content in `digitalocean/infect-nixos.yaml`. I added it to the startup command via `doctl compute droplet create ... --user-data-file digitalocean/infect-nixos.yaml`. This may have a way of working, but I don't get a log and it doesn't get infected, so something fundamental isn't working. I abandoned it. + +## With nixos-anywhere. + +``` +$ nix run github:nix-community/nixos-anywhere -- --no-disko-deps --flake ./nixos-anywhere#digitalocean --target-host root@64.23.242.187 +``` + Cloud init data: curl http://169.254.169.254/metadata/v1.json diff --git a/digitalocean/create-droplet.sh b/digitalocean/create-droplet.sh index be9fccb..d3e1349 100644 --- a/digitalocean/create-droplet.sh +++ b/digitalocean/create-droplet.sh @@ -7,6 +7,5 @@ doctl compute droplet create \ --size s-1vcpu-1gb \ --ssh-keys 48777034,46710608 \ --tag-name nixos \ - --user-data-file digitalocean/infect-nixos.yaml \ --wait diff --git a/digitalocean/infect-nixos.yaml b/digitalocean/infect-nixos.yaml index ef0a599..05380fc 100644 --- a/digitalocean/infect-nixos.yaml +++ b/digitalocean/infect-nixos.yaml @@ -1,3 +1,11 @@ #cloud-config +write_files: +- path: /etc/nixos/host.nix + permissions: '0644' + content: | + {pkgs, ...}: + { + environment.systemPackages = with pkgs; [ neofetch neovim ]; + } runcmd: -– curl https://raw.githubusercontent.com/sheran/nixos-infect/master/nixos-infect | PROVIDER=digitalocean NIX_CHANNEL=nixos-23.05 bash 2>&1 | tee /tmp/infect.log + - curl https://raw.githubusercontent.com/elitak/nixos-infect/master/nixos-infect | NIXOS_IMPORT=./host.nix NIX_CHANNEL=nixos-25.05 bash 2>&1 | tee /var/log/infect.log diff --git a/nixos-anywhere/flake.lock b/nixos-anywhere/flake.lock new file mode 100644 index 0000000..5b1c56d --- /dev/null +++ b/nixos-anywhere/flake.lock @@ -0,0 +1,64 @@ +{ + "nodes": { + "disko": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1752113600, + "narHash": "sha256-7LYDxKxZgBQ8LZUuolAQ8UkIB+jb4A2UmiR+kzY9CLI=", + "owner": "nix-community", + "repo": "disko", + "rev": "79264292b7e3482e5702932949de9cbb69fedf6d", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "disko", + "type": "github" + } + }, + "nixos-facter-modules": { + "locked": { + "lastModified": 1750412875, + "narHash": "sha256-uP9Xxw5XcFwjX9lNoYRpybOnIIe1BHfZu5vJnnPg3Jc=", + "owner": "numtide", + "repo": "nixos-facter-modules", + "rev": "14df13c84552a7d1f33c1cd18336128fbc43f920", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "nixos-facter-modules", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1751949589, + "narHash": "sha256-mgFxAPLWw0Kq+C8P3dRrZrOYEQXOtKuYVlo9xvPntt8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "9b008d60392981ad674e04016d25619281550a9d", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "disko": "disko", + "nixos-facter-modules": "nixos-facter-modules", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +}