GithubHelp home page GithubHelp logo

tweag / terraform-provider-nixos Goto Github PK

View Code? Open in Web Editor NEW
71.0 66.0 5.0 1.64 MB

Terraform provider for NixOS and NixOps

License: Mozilla Public License 2.0

HTML 10.41% Shell 23.47% Makefile 11.20% Go 54.91%

terraform-provider-nixos's Introduction

Terraform Provider NixOS

Archived: this project is not maintained anymore. You can use https://github.com/tweag/terraform-nixos instead.

NixOps has too many responsibilities and not a big enough community. The goal is to reduce NixOps' realm of control by moving all provisioning steps in to Terraform. This combines NixOp's deep support for NixOS with Terraform's nearly universal support for hardware and software providers.

Maintainers

This provider plugin is an experiment.

Requirements

  • Terraform 0.10.x
  • Go 1.8 (to build the provider plugin)

Building The Provider

Clone repository to: $GOPATH/src/github.com/tweag/terraform-provider-nixos

$ mkdir -p $GOPATH/src/github.com/tweag; cd $GOPATH/src/github.com/tweag
$ git clone [email protected]:tweag/terraform-provider-nixos

Enter the provider directory and build the provider

$ cd $GOPATH/src/github.com/tweag/terraform-provider-nixos
$ make build

Using the provider

provider "nixos" {
  root = "./nixos-machines/"
}

resource "nixos_node" "my-server" {
  node_name = "my-server-name"
  ip = "10.5.3.1"
  nix = <<NIX
    environment.systemPackages = with pkgs; [
      file
    ];
  NIX
}

This will create a file at ./nixos-machines/my-server.nix containing:

{
  terraform.ip = "10.5.3.1";
  terraform.name = "my-server-name";
  environment.systemPackages = with pkgs; [
    file
  ];
}

In your Nix configuration, add a file called terraform.nix containing:

{ config, lib, pkgs, ... }:
let
  inherit (lib) mkIf mkOption types;
  cfg = config.terraform;
in {
  options = {
    terraform = {
      name = mkOption {
        type = types.string;
      };

      ip = mkOption {
        type = types.string;
      };
    };
  };
}

and add it to the configuration.nix via:

{
  imports = [ ./terraform.nix ];
}

If you're using the provider with NixOps, you may want to add this to your configuration.nix:

{
  deployment.targetHost = terraform.ip;
}

Developing the Provider

If you wish to work on the provider, you'll first need Go installed on your machine (version 1.8+ is required). You'll also need to correctly setup a GOPATH, as well as adding $GOPATH/bin to your $PATH.

To compile the provider, run make build. This will build the provider and put the provider binary in the $GOPATH/bin directory.

$ make bin
...
$ $GOPATH/bin/terraform-provider-tweag
...

In order to test the provider, you can simply run make test.

$ make test

In order to run the full suite of Acceptance tests, run make testacc.

Note: Acceptance tests create real resources, and often cost money to run.

$ make testacc

License

Copyright (c) 2018 EURL Tweag.

All rights reserved.

terraform-provider-nixos is free software, and may be redistributed under the terms specified in the LICENSE file.

About

Tweag I/O

terraform-provider-nixos is maintained by Tweag I/O.

Have questions? Need help? Tweet at @tweagio.

terraform-provider-nixos's People

Contributors

grahamc avatar zimbatm avatar

Stargazers

Alex Mills avatar  avatar Jeff Carpenter avatar Kevin Alexander Scott Jellis avatar Bryan A. S. avatar Aditya Singh avatar Mike McGirr avatar Calum MacRae avatar Benoit de Chezelles avatar Jean-Baptiste Musso avatar Graeme Coupar avatar 38438 avatar Thibaut Marty avatar harapan avatar Thomas Honeyman avatar Vasiliy Yorkin avatar Collin Doering avatar  avatar Sidney Kochman avatar Robin Palotai avatar  avatar Trevor Riles avatar Hussein A. avatar Squirrel avatar Michael Kennedy avatar Dmitry Bushev avatar  avatar Arian van Putten avatar Karsten Gebbert avatar Leon Kyneur avatar Wael Nasreddine avatar Andrejs Agejevs avatar Serhii Khoma avatar hussein-aitlahcen avatar William Casarin avatar Tertius Stander avatar Eric Litak avatar Patrick C. avatar Valentin Reis avatar Michael Mercier avatar Michael Francis avatar Félix avatar Matthieu Coudron avatar Jos van Bakel avatar Stefan Junker avatar Piotr Limanowski avatar Sven Heyll avatar John Boehr avatar Vincent Demeester avatar Thor Erik avatar Michal Sitko avatar  avatar Steven Shaw avatar Francesco Gazzetta avatar Pi3r avatar Drew Hess avatar Jean-Baptiste G. avatar Yannis Koutras avatar Luka Blašković avatar Kamil Chmielewski avatar Vaibhav Sagar avatar Jörg Thalheim avatar Jörn Gersdorf avatar Robert Hensing avatar a13ph avatar Théophane Hufschmitt avatar Benjamin Staffin avatar Alexandre Nicastro avatar Brad Jones avatar Elliot Cameron avatar Domen Kožar avatar

Watchers

Torsten Schmits avatar  avatar Tobias Pflug avatar Mathieu Boespflug avatar Brad Jones avatar  avatar  avatar Ben Ford avatar Noon van der Silk avatar Alexander Vershilov avatar John Boehr avatar Michael B. Gale avatar Hans Höglund avatar Richard Bullington-McGuire avatar Yogesh Sajanikar avatar  avatar Robert Hensing avatar Gregg Reynolds avatar Clément Hurlin avatar Leonhard Markert avatar Manuel M T Chakravarty avatar Michael Mercier avatar James Cloos avatar Utku Demir avatar Jörn Gersdorf avatar José Luis Lafuente avatar Nicolas Frisby avatar Eelco Dolstra avatar Facundo Domínguez avatar sheaf avatar Arnaud Spiwack avatar Jan Pearce avatar Kamil Chmielewski avatar Mark Potter avatar Richard Eisenberg avatar Olivier Richard avatar  avatar lewo avatar Claudio Bley avatar Cheng Shao avatar Andréa Condoluci avatar Richard Bonichon avatar Coenen Benjamin avatar Matt Walker avatar Nicolas Jeannerod avatar Yves-Stan Le Cornec avatar Tianchan Dong avatar Logan Leland avatar Aleksander Gondek avatar Jeffrey Young avatar Mark Karpov avatar Benoit de Chezelles avatar Viktor Kleen avatar Erin van der Veen avatar  avatar Vince avatar Jack Hughes avatar Tom Westerhout avatar Tanya Bouman avatar  avatar Mathieu Montin avatar Tom Repetti avatar Deji Saliu avatar Avi Dessauer avatar Martin Allen avatar  avatar

terraform-provider-nixos's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.