You can now get a modern, plugged-in, nixops, directly in nixpkgs with nixpkgs.nixopsUnstable
thanks to work from other authors, therefore I am archiving this repo.
You can still fork it if you have some need not satisfied by upstream but I would recommend to file a ticket in the appropriate place.
This repo was always a short term solution, and it's day has come.
Essentially just a wrapper around nixops and some plugins. This flake aims to include any compatible plugins as they become available.
Clone this repository and you can run nixops from inside the project root. This flake exports a Nix App, so running nix run . -- <args>
is equivalent to running nixops <args>
.
You can refer to this flake as input for another flake, i.e. inside the development environment for some flake packaging a NixOps network.
{
description = "Your awesome flake";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
inputs.nixops-plugged.url = "github:lukebfox/nixops-plugged";
inputs.utils.url = "github:numtide/flake-utils";
outputs = { self, nixpkgs, nixops-plugged, utils, ... }: {
nixopsConfigurations.default = { ... }; # your network definition
} // utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs { inherit system; };
in {
devShell = pkgs.mkShell {
nativeBuildInputs = [ nixops-plugged.defaultPackage.${system} ];
};
});
}
While inside the development shell for your flake you will now have access to a fully(ish) featured nixops
.
λ nix develop
λ nixops list-plugins
If you only care about one plugin, this flake exports packages for this use case, i.e nixops-plugged.packages.nixops-aws
to get a nixops
with the nixops-aws
plugin.
If you want to mix and match from any supported plugins then use this function
devShell = pkgs.mkShell {
nativeBuildInputs = [
(nixops-plugged.lib.withPlugins (ps: [ps.nixops-aws ps.nixops-hetznercloud])
];
};
Plugins | Included |
---|---|
AWS | ✔️ |
DigitalOcean | ✔️ |
GCE | ✔️ |
Hetzner Cloud | ✔️ |
VBox | ✔️ |
Hetzner Robot | ❌ |
Proxmox | ❌ |
Virtd | ❌ |
Adding new plugins goes like this:
λ nix develop
λ vim pyproject.toml # add plugin to dependencies
λ vim flake.nix # add plugin to defaultPackage and/or packages
λ poetry lock
You can run nix run . -- list-plugins
to verify your changes.
The legacy commands nix-build
and nix-shell
should still work thanks to the compatability shim from flake-compat, although I don't use these so YMMV.