1
0
Fork 0
mirror of https://cgit.krebsco.de/krops synced 2024-11-26 21:19:47 +01:00

Merge pull request #17 from Mic92/no-writers

use writers from nixpkgs
This commit is contained in:
tv 2020-02-18 14:34:10 +01:00 committed by GitHub
commit 8161ec7367
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 23 deletions

View file

@ -1,15 +1,7 @@
{ overlays ? [], ... }@args: { overlays ? [], ... }@args:
let
nix-writers = builtins.fetchGit {
url = https://cgit.krebsco.de/nix-writers/;
rev = "c528cf970e292790b414b4c1c8c8e9d7e73b2a71";
};
in
import <nixpkgs> (args // { import <nixpkgs> (args // {
overlays = [ overlays = [
(import ./overlay.nix) (import ./overlay.nix)
(import "${nix-writers}/pkgs")
] ++ overlays; ] ++ overlays;
}) })

View file

@ -2,7 +2,7 @@ let
lib = import ../../lib; lib = import ../../lib;
in in
{ exec, nix, openssh, populate, writeDash }: rec { { nix, openssh, populate, writers }: rec {
build = target: build = target:
remoteCommand target (lib.concatStringsSep " " [ remoteCommand target (lib.concatStringsSep " " [
@ -18,17 +18,14 @@ in
}"; }";
remoteCommand = target: command: remoteCommand = target: command:
exec "build.${target.host}" rec { writers.writeDash "build.${target.host}" ''
filename = "${openssh}/bin/ssh"; exec ${openssh}/bin/ssh ${lib.escapeShellArgs (lib.flatten [
argv = lib.flatten [
filename
(lib.optionals (target.user != "") ["-l" target.user]) (lib.optionals (target.user != "") ["-l" target.user])
"-p" target.port "-p" target.port
"-t" "-t"
target.host target.host
(if target.sudo then "sudo ${command}" else command) (if target.sudo then "sudo ${command}" else command)])}
]; '';
};
writeCommand = name: { writeCommand = name: {
command ? (targetPath: "echo ${targetPath}"), command ? (targetPath: "echo ${targetPath}"),
@ -39,7 +36,7 @@ in
}: let }: let
target' = lib.mkTarget target; target' = lib.mkTarget target;
in in
writeDash name '' writers.writeDash name ''
set -efu set -efu
${populate { inherit backup force source; target = target'; }} ${populate { inherit backup force source; target = target'; }}
${remoteCommand target' (command target'.path)} ${remoteCommand target' (command target'.path)}
@ -60,7 +57,7 @@ in
else lib.mkTarget buildTarget; else lib.mkTarget buildTarget;
target' = lib.mkTarget target; target' = lib.mkTarget target;
in in
writeDash name '' writers.writeDash name ''
set -efu set -efu
${lib.optionalString (buildTarget' != target') ${lib.optionalString (buildTarget' != target')
(populate { inherit backup force source; target = buildTarget'; })} (populate { inherit backup force source; target = buildTarget'; })}
@ -88,7 +85,7 @@ in
target' = lib.mkTarget target; target' = lib.mkTarget target;
in in
assert lib.isLocalTarget target'; assert lib.isLocalTarget target';
writeDash name '' writers.writeDash name ''
set -efu set -efu
${populate { inherit backup force source; target = target'; }} >&2 ${populate { inherit backup force source; target = target'; }} >&2
NIX_PATH=${lib.escapeShellArg target'.path} \ NIX_PATH=${lib.escapeShellArg target'.path} \
@ -99,5 +96,4 @@ in
--show-trace \ --show-trace \
'<nixpkgs/nixos>' '<nixpkgs/nixos>'
''; '';
} }

View file

@ -1,7 +1,7 @@
with import ../../lib; with import ../../lib;
with shell; with shell;
{ coreutils, dash, findutils, git, jq, openssh, pass, rsync, writeDash }: { coreutils, dash, findutils, git, jq, openssh, pass, rsync, writers }:
let let
check = { force, target }: let check = { force, target }: let
@ -145,7 +145,7 @@ let
populate = target: name: source: let populate = target: name: source: let
source' = source.${source.type}; source' = source.${source.type};
target' = target // { path = "${target.path}/${name}"; }; target' = target // { path = "${target.path}/${name}"; };
in writeDash "populate.${target'.host}.${name}" '' in writers.writeDash "populate.${target'.host}.${name}" ''
set -efu set -efu
${pop.${source.type} target' source'} ${pop.${source.type} target' source'}
''; '';
@ -196,7 +196,7 @@ let
in in
{ backup ? false, force ? false, source, target }: { backup ? false, force ? false, source, target }:
writeDash "populate.${target.host}" '' writers.writeDash "populate.${target.host}" ''
set -efu set -efu
${check { inherit force target; }} ${check { inherit force target; }}
set -x set -x