corpix / terraform-provider-nixos

Terraform provider to deploy NixOS system configurations
https://corpix.dev/2022/08/terraforming-nixos-hosts.html
The Unlicense
17 stars 2 forks source link

Darwin platform #1

Open kolpav opened 2 years ago

kolpav commented 2 years ago

Could you please provide target for darwin platform there should be very little incompatibility when building I think.

I have tried to do it myself and make a PR but failed maybe when I am done with reading all the pills,nixpkgs resources I will be able to contribute somehow I would really like this project succeed it looks great and exactly what I would like to use 👍

$ terraform init -upgrade

Initializing the backend...

Initializing provider plugins...
- Finding corpix/nixos versions matching "0.0.8"...
╷
│ Error: Incompatible provider version
│
│ Provider registry.terraform.io/corpix/nixos v0.0.8 does not have a package available for your current platform, darwin_amd64.
│
│ Provider releases are separate from Terraform CLI releases, so not all providers are available for all platforms. Other versions of this provider may have different platforms
│ supported.
corpix commented 2 years ago

Hi @kolpav . I have added cross-compilation for darwin (amd64 & arm64) and linux (arm64) in version 0.0.9. Now provider should be available for Terraform on your platform.

But I think this is far from enough because there are probably a lot things to be done before anything could be deployed from OSX to NixOS host because of cross-compilation. I am sure there will be a lot of problems. Maybe I could address some of them on the Terraform provider level configuration wrapper. But I don't use OSX in my everyday life and can not test this changes. So, hopefully this could be done by somebody in future, I'll do my best to help

corpix commented 2 years ago

Forgot to mention: there is another way to deploy configuration to NixOS hosts from OSX, some of my teammates using this, you could run a Docker container with Nix like this:

docker run -it -v nix:/nix:rw -v $HOME/.ssh:/chroot/.ssh:rw -v $(pwd):/src -e HOME=/chroot -w /src --platform=linux/amd64 nixos/nix:2.9.0 

It will run container with Nix. Inside this container you could run nix-shell -p terraform which will provide a Terraform tool. This relies on the fact that Docker uses virtual machine on OSX.

kolpav commented 2 years ago

@corpix That was quick, thank you. installation passed I'll give it a go, hopefully I'll be able to get rid of ansible soon. Since you mentioned using docker as an workaround for potential compatibility issues, there is also https://github.com/lima-vm/lima (docker/-compose) and https://multipass.run for quick cli vms might be useful for your teammates or future readers.