Skip to content

Instantly share code, notes, and snippets.

@bobvanderlinden
Created October 4, 2017 20:25
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bobvanderlinden/e9ef4c338882f1ef31424e4743be15fc to your computer and use it in GitHub Desktop.
Save bobvanderlinden/e9ef4c338882f1ef31424e4743be15fc to your computer and use it in GitHub Desktop.
Example of reproducible deployments using nix-shell and nixops
{
server = {
deployment.targetHost = "target.host.com";
services.openssh.enable = true;
};
}
let
# Use a specific version of nixpkgs:
pkgsSrc = builtins.fetchTarball {
url = https://github.com/nixos/nixpkgs-channels/archive/19879836d10f64a10658d1e2a84fc54b090e2087.tar.gz;
sha256 = "f01e3a617e5b1d3c2ee8e525f3a48d1c4402d7c47f5cbf772c48ff57056481f4";
};
# Use a local version of nixpkgs:
# pkgsSrc = ./nixpkgs;
pkgs = (import pkgsSrc {});
in
pkgs.stdenv.mkDerivation rec {
name = "nixops-env";
buildInputs = with pkgs; [ awscli pkgs.nixops ];
shellHook = ''
[ -f ~/.aws/vars ] && . ~/.aws/vars
export NIX_PATH=${pkgs.path}:nixpkgs=${pkgs.path}:.
'';
}
@bobvanderlinden
Copy link
Author

This can run using:

nix-shell --run "nixops deploy"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment