From f53b777a7e6a618b482ed8b2fa6d39c8d4f7d003 Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Sat, 12 Dec 2020 16:12:38 +0100 Subject: [PATCH] Use krops for deployments --- lib/krops.nix | 31 +++++++++++++++++++++++++++++++ machines/nunotaba/krops.nix | 3 +++ machines/sayuri/krops.nix | 3 +++ nix/sources.json | 12 ++++++++++++ 4 files changed, 49 insertions(+) create mode 100644 lib/krops.nix create mode 100644 machines/nunotaba/krops.nix create mode 100644 machines/sayuri/krops.nix diff --git a/lib/krops.nix b/lib/krops.nix new file mode 100644 index 0000000..ff301c2 --- /dev/null +++ b/lib/krops.nix @@ -0,0 +1,31 @@ +{ hostname +, target ? null +, extraSources ? { } +}: +let + sources = import ../nix/sources.nix; + krops = sources.krops; + lib = import "${krops}/lib"; + pkgs = import "${krops}/pkgs" { }; + + source = lib.evalSource [ + ({ + nixpkgs.git = { + ref = sources.nixpkgs.rev; + url = https://github.com/NixOS/nixpkgs; + shallow = true; + }; + config.file = toString ../.; + nixos-config.symlink = "config/machines/${hostname}/configuration.nix"; + } // extraSources) + ]; +in +pkgs.krops.writeDeploy "deploy-${hostname}" { + source = source; + target = lib.mkTarget (if target == null then "root@${hostname}" else target) // { + extraOptions = [ + # force allocation of tty to allow aborting with ^C and to show build progress + "-t" + ]; + }; +} diff --git a/machines/nunotaba/krops.nix b/machines/nunotaba/krops.nix new file mode 100644 index 0000000..3e5a158 --- /dev/null +++ b/machines/nunotaba/krops.nix @@ -0,0 +1,3 @@ +import ../../lib/krops.nix { + hostname = "nunotaba"; +} diff --git a/machines/sayuri/krops.nix b/machines/sayuri/krops.nix new file mode 100644 index 0000000..f235161 --- /dev/null +++ b/machines/sayuri/krops.nix @@ -0,0 +1,3 @@ +import ../../lib/krops.nix { + hostname = "sayuri"; +} diff --git a/nix/sources.json b/nix/sources.json index 83d02be..aa22e7f 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -1,4 +1,16 @@ { + "krops": { + "branch": "master", + "description": "Mirror of https://cgit.krebsco.de/krops/about/ (PRs / issues accepted, as can be seen by not having them disabled)", + "homepage": "", + "owner": "krebs", + "repo": "krops", + "rev": "c207e1f71b85d7ed20f6bc8d91704ceec09ea5ef", + "sha256": "11rk7i7vy788sxhhngj9951z36y5y6l83szidjglw7czhff9rrbc", + "type": "tarball", + "url": "https://github.com/krebs/krops/archive/c207e1f71b85d7ed20f6bc8d91704ceec09ea5ef.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, "nixpkgs": { "branch": "nixos-20.09", "description": "Nix Packages collection",