Questions tagged [nixops]

NixOps is a tool for deploying sets of NixOS Linux machines, either to real hardware or to virtual machines

NixOps is a tool for deploying sets of NixOS Linux machines, either to real hardware or to virtual machines. It extends NixOS’s declarative approach to system configuration management to networks and adds provisioning. For example, here is a NixOps specification of a network consisting of two machines — one running Apache httpd, the other serving a file system via NFS:

{
  webserver =
    { deployment.targetEnv = "virtualbox";
      services.httpd.enable = true;
      services.httpd.documentRoot = "/data";
      fileSystems."/data" =
        { fsType = "nfs4";
          device = "fileserver:/"; };
    };

  fileserver =
    { deployment.targetEnv = "virtualbox";
      services.nfs.server.enable = true;
      services.nfs.server.exports = "...";
    };
}

The values of the webserver and fileserver attributes are regular NixOS system specifications, except for the deployment.* options, which tell NixOps how each machine should be instantiated (in this case, as VirtualBox virtual machines running on your desktop). You can then run:

$ nixops create -d simple network.nix $ nixops deploy -d simple

This will create the EC2 instances, and then build, upload and activate the NixOS configurations you specified. To change something to the configuration, you just edit the specification and run nixops deploy again.

NixOps makes it easy to abstract over target environments, allowing you to use the same “logical” specification for both testing and production deployments. For instance, to deploy to Amazon EC2, you would just change the deployment.* options to:

deployment.targetEnv = "ec2"; deployment.region = "eu-west-1"; NixOps currently supports provisioning the following resources:

Amazon EC2 instances. VirtualBox virtual machines. Hetzner machines. NixOS containers. Many Amazon resources, such as S3 buckets, EC2 key pairs, elastic IPs, and so on. Getting it If you already have Nix or NixOS installed, you can get NixOps by running:

$ nix-env -i nixops You can also get the latest development version; see the manual for details.

source

16 questions
85
votes
2 answers

When and how should default.nix, shell.nix and release.nix be used?

One of the first types of Nix expression one encounters when learning how to use the Nix package manager is default.nix; on the wonderful NixOS IRC channel I learned of the existence of shell.nix and release.nix as well. I got the impression that -…
Ixxie
  • 1,393
  • 1
  • 9
  • 17
7
votes
0 answers

nixops: how to use local ssh key when deploying on machine with existing nixos (targetEnv is none)?

I have machine with nixos (provisioned using terraform, config), I want to connect to it using deployment.targetHost = ipAddress and deployment.targetEnv = "none" But I can't configure nixops to use /secrets/stage_ssh_key ssh key This is not…
srghma
  • 4,770
  • 2
  • 38
  • 54
7
votes
1 answer

Deploying static files with NixOps

I've got a program which depends on the static and config directories being available on the server along with the binary. The default build phases for NixOps doesn't include these files, as far as I can tell it just compiles the binary and then…
Ben
  • 574
  • 3
  • 12
4
votes
1 answer

Deploying Scala to NixOps

I'm trying to deploy a VirtualBox with a Play 2 webservice in Scala under NixOS with NixOps. I have this machine : { backoffice = { deployment.targetEnv = "virtualbox"; deployment.virtualbox.memorySize = 1024; # MB }; } On this logical…
KaC
  • 613
  • 6
  • 14
3
votes
2 answers

NixOps: How to deploy to an existing NixOS VM?

I have almost the same problem as in this question, but it was never answered: nixops: how to use local ssh key when deploying on machine with existing nixos (targetEnv is none)? I'm not using Terraform though. Just NixOS + NixOps. So far,…
jefdaj
  • 2,025
  • 2
  • 21
  • 33
3
votes
1 answer

How to import nixos config and merge it with nixops deployment expression

I'm in the process of learning how to use Nix/NixOs/NixOps, and I'm having trouble refactoring a simple NixOps deployment. My starting point is this working vbox-all.nix file : { server = { config, pkgs, ... }: { #…
HectorJ
  • 5,814
  • 3
  • 34
  • 52
3
votes
1 answer

When will Travis-ci will support NixOS/NixOps?

Currently travis supports linux (ubuntu?) and mac. I'm currently exploring nix. I think it's a powerful way to declare the global state of your system. It's available at various level: nix: package nixos: machine nixops: deployment With the…
Guillaume Massé
  • 8,004
  • 8
  • 44
  • 57
2
votes
2 answers

What is the common way to install utility programs like file and ripgrep in NixOS

I want these programs to be installed in my user environment while not using nix-shell and nix-env (I was told to not use nix-env). I tried to use home-manager but I can't do program.file/ripgrep bc it's not an option. May I ask what is the common…
zoey1771
  • 79
  • 5
2
votes
1 answer

Override a service definition in Nix?

I'm writing a deployment definition in NixOps. As part of that definition, I need to modify an existing service definition that's provided by . I can't configure the service to do what I want. Because the service definition itself defines…
Isaac van Bakel
  • 1,772
  • 10
  • 22
2
votes
1 answer

Deploing a single bash script with nixops

I'm just starting to learn nix / nixos / nixops. I needed to install a simple bash script to remote host with nixops. And I can not realize how to do it. I have two files: just-deploy-bash-script.nix { resources.sshKeyPairs.ssh-key = {}; …
2
votes
1 answer

Is it possible (or advisable) to use NixOps to install NixOS to a USB flash drive?

I'd like to install NixOS to a flash drive, and have the operating system run entirely on the flash drive. Is it possible to install to a flash drive using NixOps? Or would I even need to? That is, would it be easier or better just to write a script…
Jonathan
  • 10,571
  • 13
  • 67
  • 103
2
votes
2 answers

Propagate nixpkgs checkout to NixOps machines

I'm maintaining my personal changes on nixpkgs, which I use both for system rebuilds (via NixOps) and for development on my workstation (mostly via nix-shell). The changes are commits rebased ontop of the nixos-17.09 channel and are stored on a…
erictapen
  • 578
  • 3
  • 13
1
vote
1 answer

Passing secrets to NixOps logical network specification

I am deploying a web application to AWS with NixOps. The application requires some environment variables to be set. I can achieve this with something similar to the following: { network.description = "Web server"; webserver = { config, pkgs,…
Jezen Thomas
  • 13,619
  • 6
  • 53
  • 91
1
vote
1 answer

NixOps - Configure Nginx proxy pass with Python Flask

I am new to Nix and trying to implement a service which passes Python Flask web services though Nginx proxy_pass. This is what I have tried so far. with import {}; let buildInputs = [ nginx …
lpsandaruwan
  • 790
  • 2
  • 11
  • 27
0
votes
1 answer

login shell without password on nixos/nixops

what i want i'm using nixops to deploy to VirtualBox and libvirtd (KVM) and on both environments i would like it if the shell did not have a login with username/password bust instead would already provide a logged in shell. for libvirt we have:…
qknight
  • 866
  • 10
  • 23
1
2