aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJörg Thalheim <joerg@thalheim.io>2020-02-17 17:40:50 +0000
committerJörg Thalheim <joerg@thalheim.io>2020-02-17 18:05:48 +0000
commitd51f353cb3ca667957e05699e4f250c9cd4d0882 (patch)
tree0a111953df144e407b13c59a5512e87391083931
parentf1b7112ac3cbe090e96f2c82c525b6db69b82034 (diff)
use writers from nixpkgs
This makes the evaluation of krops pure (no import from derivation) and makes it faster since the fetchGit result might be garbage collected.
-rw-r--r--pkgs/default.nix8
-rw-r--r--pkgs/krops/default.nix20
-rw-r--r--pkgs/populate/default.nix6
3 files changed, 11 insertions, 23 deletions
diff --git a/pkgs/default.nix b/pkgs/default.nix
index 682b6b4..76c7f11 100644
--- a/pkgs/default.nix
+++ b/pkgs/default.nix
@@ -1,15 +1,7 @@
{ overlays ? [], ... }@args:
-let
- nix-writers = builtins.fetchGit {
- url = https://cgit.krebsco.de/nix-writers/;
- rev = "c528cf970e292790b414b4c1c8c8e9d7e73b2a71";
- };
-in
-
import <nixpkgs> (args // {
overlays = [
(import ./overlay.nix)
- (import "${nix-writers}/pkgs")
] ++ overlays;
})
diff --git a/pkgs/krops/default.nix b/pkgs/krops/default.nix
index 16ef936..07c7395 100644
--- a/pkgs/krops/default.nix
+++ b/pkgs/krops/default.nix
@@ -2,7 +2,7 @@ let
lib = import ../../lib;
in
-{ exec, nix, openssh, populate, writeDash }: rec {
+{ nix, openssh, populate, writers }: rec {
build = target:
remoteCommand target (lib.concatStringsSep " " [
@@ -18,17 +18,14 @@ in
}";
remoteCommand = target: command:
- exec "build.${target.host}" rec {
- filename = "${openssh}/bin/ssh";
- argv = lib.flatten [
- filename
+ writers.writeDash "build.${target.host}" ''
+ exec ${openssh}/bin/ssh ${lib.escapeShellArgs (lib.flatten [
(lib.optionals (target.user != "") ["-l" target.user])
"-p" target.port
"-t"
target.host
- (if target.sudo then "sudo ${command}" else command)
- ];
- };
+ (if target.sudo then "sudo ${command}" else command)])}
+ '';
writeCommand = name: {
command ? (targetPath: "echo ${targetPath}"),
@@ -39,7 +36,7 @@ in
}: let
target' = lib.mkTarget target;
in
- writeDash name ''
+ writers.writeDash name ''
set -efu
${populate { inherit backup force source; target = target'; }}
${remoteCommand target' (command target'.path)}
@@ -60,7 +57,7 @@ in
else lib.mkTarget buildTarget;
target' = lib.mkTarget target;
in
- writeDash name ''
+ writers.writeDash name ''
set -efu
${lib.optionalString (buildTarget' != target')
(populate { inherit backup force source; target = buildTarget'; })}
@@ -88,7 +85,7 @@ in
target' = lib.mkTarget target;
in
assert lib.isLocalTarget target';
- writeDash name ''
+ writers.writeDash name ''
set -efu
${populate { inherit backup force source; target = target'; }} >&2
NIX_PATH=${lib.escapeShellArg target'.path} \
@@ -99,5 +96,4 @@ in
--show-trace \
'<nixpkgs/nixos>'
'';
-
}
diff --git a/pkgs/populate/default.nix b/pkgs/populate/default.nix
index acabc02..736376e 100644
--- a/pkgs/populate/default.nix
+++ b/pkgs/populate/default.nix
@@ -1,7 +1,7 @@
with import ../../lib;
with shell;
-{ coreutils, dash, findutils, git, jq, openssh, pass, rsync, writeDash }:
+{ coreutils, dash, findutils, git, jq, openssh, pass, rsync, writers }:
let
check = { force, target }: let
@@ -145,7 +145,7 @@ let
populate = target: name: source: let
source' = source.${source.type};
target' = target // { path = "${target.path}/${name}"; };
- in writeDash "populate.${target'.host}.${name}" ''
+ in writers.writeDash "populate.${target'.host}.${name}" ''
set -efu
${pop.${source.type} target' source'}
'';
@@ -196,7 +196,7 @@ let
in
{ backup ? false, force ? false, source, target }:
-writeDash "populate.${target.host}" ''
+writers.writeDash "populate.${target.host}" ''
set -efu
${check { inherit force target; }}
set -x