Skip to content

Instantly share code, notes, and snippets.

@betaboon
Last active October 24, 2017 09:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save betaboon/ba03b01f29347234efb3fe8add1bc620 to your computer and use it in GitHub Desktop.
Save betaboon/ba03b01f29347234efb3fe8add1bc620 to your computer and use it in GitHub Desktop.
{
network.description = "example";
vbox = {
deployment.targetEnv = "virtualbox";
deployment.virtualbox.memorySize = 512;
deployment.virtualbox.vcpu = 1;
deployment.virtualbox.headless = true;
};
example = { resources, ... }: {
deployment.targetEnv = "container";
deployment.container.host = resources.machines.vbox;
nixpkgs.overlays = [ (import <nixpkgs-overlays>) ];
};
}
self: super:
let
packageOverrides = self: super: with self; {
example = super.callPackage ./packages/python/example { };
};
in rec {
python2 = super.python2.override { inherit packageOverrides; };
python3 = super.python3.override { inherit packageOverrides; };
python2Packages = self.python2.pkgs;
python3Packages = self.python3.pkgs;
example = callPackage ./packages/applications/example {};
}
let
deploymentName = "example";
# create the nixops statefile in this directory
# this is done, so that it can be included in git
stateFilePath = builtins.toPath ./. + "/localstate.nixops";
# Use a specific revision of nixpkgs-channel
nixpkgsRevision = "c99239b";
pkgsSrc = builtins.fetchTarball { url =
"https://github.com/nixos/nixpkgs-channels" +
"/archive/${nixpkgsRevision}.tar.gz";
};
pkgs = (import pkgsSrc {
overlays = [ (import ./overlay.nix) ];
});
# TODO in production this should point to a git-commit of a seperate repo
overlaySrc = builtins.toPath ./. + "/overlay.nix";
nixPath = pkgs.lib.concatStringsSep ":" [
pkgs.path
"nixpkgs=${pkgs.path}"
"nixpkgs-overlays=${overlaySrc}"
"."
];
in
pkgs.stdenv.mkDerivation rec {
name = "nixops-env";
buildInputs = with pkgs; [ nixops ];
shellHook = ''
export NIX_PATH=${nixPath}
export NIXOPS_DEPLOYMENT=${deploymentName}
export NIXOPS_STATE=${stateFilePath}
'';
}
@betaboon
Copy link
Author

run with: $ nix-shell --run "nixops create && nixops deploy"

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