From ef573234ac898749c69dc98471c5764b0926aab1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kier=C3=A1n=20Meinhardt?= Date: Mon, 17 Jun 2019 18:01:14 +0200 Subject: [PATCH] krops: restructure expressions --- deploy.nix | 76 +++++++++++++++++------------------------------------- 1 file changed, 24 insertions(+), 52 deletions(-) diff --git a/deploy.nix b/deploy.nix index 55d43db..ddfe7ce 100644 --- a/deploy.nix +++ b/deploy.nix @@ -1,8 +1,3 @@ -{ catullus-ssh ? "root@catullus.r:22022" -, scardanelli-ssh ? "root@scardanelli.r:22022" -, homeros-ssh ? "root@homeros.r:22022" -, wilde-ssh ? "root@192.168.178.31:22" -}: let krops = builtins.fetchGit { url = "https://cgit.krebsco.de/krops/"; @@ -12,7 +7,14 @@ let pkgs = import "${krops}/pkgs" {}; importJson = (import {}).lib.importJSON; - niveum = path: { + niveum = { + lib.file = toString ./lib; + packages.file = toString ./packages; + configs.file = toString ./configs; + dot.file = toString ./dot; + modules.file = toString ./modules; + nixos-config.symlink = "system/configuration.nix"; + nixpkgs.git = { url = https://github.com/NixOS/nixpkgs-channels; ref = (importJson ./nixpkgs.json).rev; @@ -21,19 +23,6 @@ let url = https://github.com/NixOS/nixpkgs-channels; ref = "nixos-unstable"; }; - system.file = toString path; - lib.file = toString ./lib; - packages.file = toString ./packages; - configs.file = toString ./configs; - dot.file = toString ./dot; - modules.file = toString ./modules; - - nixos-config.symlink = "system/configuration.nix"; - }; - - minimal = path: other: lib.evalSource [(niveum path // other)]; - - regular = path: name: minimal path { home-manager.git = { url = https://github.com/rycee/home-manager; ref = "2ccbf43"; @@ -42,41 +31,24 @@ let url = https://cgit.krebsco.de/stockholm; ref = "1340e3fb"; }; - secrets.pass = { - dir = toString ~/.password-store/niveum/systems; - inherit name; - }; - art.file = toString ./art; }; - systems.scardanelli = pkgs.krops.writeDeploy "deploy-scardanelli" { - source = regular ./systems/scardanelli "scardanelli"; - target = scardanelli-ssh; + regularSystem = path: name: extras: { + source = lib.evalSource [ + (niveum // extras // { + system.file = toString path; + secrets.pass = { + dir = toString ~/.password-store/systems; + inherit name; + }; + }) + ]; + target = "root@${name}:22022"; }; +in { + scardanelli = pkgs.krops.writeDeploy "deploy-scardanelli" (regularSystem systems/scardanelli "scardanelli" { art.file = toString ./art; }); + homeros = pkgs.krops.writeDeploy "deploy-homeros" (regularSystem systems/homeros "homeros" { art.file = toString ./art; }); + wilde = pkgs.krops.writeDeploy "deploy-wilde" (regularSystem systems/wilde "wilde" { art.file = toString ./art; }); - systems.homeros = pkgs.krops.writeDeploy "deploy-homeros" { - source = regular ./systems/homeros "homeros"; - target = homeros-ssh; - }; - - systems.wilde = pkgs.krops.writeDeploy "deploy-wilde" { - source = regular ./systems/wilde "wilde"; - target = wilde-ssh; - }; - - systems.catullus = pkgs.krops.writeDeploy "deploy-catullus" { - source = minimal ./systems/catullus { - secrets.pass = { - dir = toString ~/.password-store; - name = "catullus"; - }; - stockholm.git = { - url = https://cgit.krebsco.de/stockholm; - ref = "1340e3fb"; - }; - }; - target = catullus-ssh; - }; -in systems // { - all = pkgs.writeScript "deploy-all" (lib.concatStringsSep "\n" (lib.attrValues systems)); + catullus = pkgs.krops.writeDeploy "deploy-catullus" (regularSystem systems/catullus "catullus" {}); }