Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/codexlynx/nix-vagrant

A nix library for render, run and manage declarative HashiCorp Vagrant config files powered by nixago and CUE Lang.
https://github.com/codexlynx/nix-vagrant

cue cuelang hashicorp nix nix-flake nixago nixos vagrant vagrantfile

Last synced: 29 days ago
JSON representation

A nix library for render, run and manage declarative HashiCorp Vagrant config files powered by nixago and CUE Lang.

Awesome Lists containing this project

README

        

# nix-vagrant
> [!WARNING]
> This library is in an early, experimental stage and may lack complete functionality. It is intended for testing and feedback purposes only. Use at your own risk as stability is not guaranteed.

Vagrant
NixOS

A [nix](https://zero-to-nix.com/concepts/nix-language) library for render, run and manage declarative HashiCorp [Vagrant](https://www.vagrantup.com/) config files powered by nixago and [CUE Lang](https://cuelang.org/).
* Make Vagrantfiles from nix
* Manage vagrant machine lifecycle
* Batteries includes box runner

## Usage
### Make Vagrantfiles
```nix
vagrant.file.cumulus =
pkgs.writeShellScriptBin "result"
(nix-vagrant.lib."${system}".make "Vagrantfile" {
name = "machine1";
provider = "vmware_fusion";
box = "CumulusCommunity/cumulus-vx";
gui = false;
}).shellHook;
```

#### Commands
```commandline
$ nix run .#vagrant.x86_64-linux.file.cumulus
```

### Manual machine lifecycle control
```nix
vagrant.machine.windows = nix-vagrant.lib."${system}".machine {
package = pkgs.vagrant;

config = {
name = "windows1";
provider = "virtualbox";
box = "gusztavvargadr/windows-11";
gui = true;
};

init = {
launchScript = "powershell -noninteractive -executionpolicy unrestricted - < C:/";

script = ''
echo Hello from Windows!
'';
};
};
```
#### Commands
```commandline
$ nix run .#vagrant.x86_64-linux.machine.windows.up
$ nix run .#vagrant.x86_64-linux.machine.windows.ssh
$ nix run .#vagrant.x86_64-linux.machine.windows.destroy
$ nix run .#vagrant.x86_64-linux.machine.windows.ssh-config
$ nix run .#vagrant.x86_64-linux.machine.windows.provision
```

### Box runner
```nix
packages.start = nix-vagrant.lib."${system}".runner {
config = {
name = "windows1";
provider = "virtualbox";
box = "gusztavvargadr/windows-11";
gui = false;
};
};
```

#### Commands
```commandline
$ nix run .#start
```