summaryrefslogtreecommitdiffstats
path: root/krebs
diff options
context:
space:
mode:
authorlassulus <lassulus@lassul.us>2017-09-19 22:56:19 +0200
committerlassulus <lassulus@lassul.us>2017-09-19 22:56:19 +0200
commit821e59baca98b5caba65c6e7c7e4d6671593a69e (patch)
tree499e78ef143bf20c7cb2ef4137d031085d25c6a9 /krebs
parentd30480f1457cf4ac4f67f5e02faec75765706e50 (diff)
parent94c57badae775cb863b76a6c6cb8c11012cd4f83 (diff)
Merge remote-tracking branch 'ni/master'
Diffstat (limited to 'krebs')
-rw-r--r--krebs/3modules/tv/default.nix46
-rw-r--r--krebs/5pkgs/simple/withGetopt.nix26
2 files changed, 19 insertions, 53 deletions
diff --git a/krebs/3modules/tv/default.nix b/krebs/3modules/tv/default.nix
index 79fa27bad..e80becfa7 100644
--- a/krebs/3modules/tv/default.nix
+++ b/krebs/3modules/tv/default.nix
@@ -32,52 +32,6 @@ with import <stockholm/lib>;
ssh.privkey.path = <secrets/ssh.id_rsa>;
ssh.pubkey = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDP9JS2Nyjx4Pn+/4MrFi1EvBBYVKkGm2Q4lhgaAiSuiGLol53OSsL2KIo01mbcSSBWow9QpQpn8KDoRnT2aMLDrdTFqL20ztDLOXmtrSsz3flgCjmW4f6uOaoZF0RNjAybd1coqwSJ7EINugwoqOsg1zzN2qeIGKYFvqFIKibYFAnQ8hcksmkvPdIO5O8CbdIiP9sZSrSDp0ZyLK2T0PML2jensVZOeqSPulQDFqLsbmavpVLkpDjdzzPRwbZWNB4++YeipbYNOkX4GR1EB4wMZ93IbBV7kpJtib2Zb2AnUf7UW37hxWBjILdstj9ClwNOQggn8kD9ub7YxBzH1dz0Xd8a0mPOAWIDJz9MypXgFRc3vdvPB/W1I4Se0CLbgOkORun9CkgijKr9oEY8JNt8HFd6viZcAaQxOyIm6PNHZTnHfdSc7bIBS2n3e3IZBv0fTd77knGLXg402aTuu2bm/kxsKivxsILXIaGbeXe4ceN3Fynr3FzSM2bUkzHb0mAHu1BQ9YaX0xzCwjVueA5nzGls7ODSFkXsiBfg2FvMN/sTLFca6tnwyqcnD6nujoiS5+BxjDWPgnZYqCaW3B/IkpTsRMsX6QrfhOFcsP8qlJ2Cp82orWoDK/D0vZ9pdzAc6PFGga0RofuJKY2yiq+SRZ7/e9E6VncIVCYZ1OfN0Q==";
};
- cd = {
- ci = true;
- cores = 2;
- extraZones = {
- # TODO generate krebsco.de zone from nets and don't use extraZones at all
- "krebsco.de" = ''
- cd 60 IN A ${config.krebs.hosts.cd.nets.internet.ip4.addr}
- '';
- };
- nets = {
- internet = {
- ip4.addr = "45.62.237.203";
- aliases = [
- "cd.i"
- "cd.krebsco.de"
- ];
- ssh.port = 11423;
- };
- retiolum = {
- via = config.krebs.hosts.cd.nets.internet;
- ip4.addr = "10.243.113.222";
- ip6.addr = "42:4522:25f8:36bb:8ccb:150:231a:2af3";
- aliases = [
- "cd.r"
- "cgit.cd.r"
- ];
- tinc.pubkey = ''
- -----BEGIN RSA PUBLIC KEY-----
- MIICCgKCAgEAvmCBVNKT/Su4v9nl/Nm3STPo5QxWPg7xEkzIs3Oh39BS8+r6/7UQ
- rebib7mczb+ebZd+Rg2yFoGrWO8cmM0VcLy5bYRMK7in8XroLEjWecNNM4TRfNR4
- e53+LhcPdkxo0A3/D+yiut+A2Mkqe+4VXDm/JhAiAYkZTn7jUtj00Atrc7CWW1gN
- sP3jIgv4+CGftdSYOB4dm699B7OD9XDLci2kOaFqFl4cjDYUok03G0AduUlRx10v
- CKbKOTIdm8C36A902/3ms+Hyzkruu+VagGIZuPSwqXHJPCu7Ju+jarKQstMmpQi0
- PubweWDL0o/Dfz2qT3DuL4xDecIvGE6kv3m41hHJYiK+2/azTSehyPFbsVbL7w0V
- LgKN3usnZNcpTsBWxRGT7nMFSnX2FLDu7d9OfCuaXYxHVFLZaNrpccOq8NF/7Hbk
- DDW81W7CvLyJDlp0WLnAawSOGTUTPoYv/2wAapJ89i8QGCueGvEc6o2EcnBVMFEW
- ejWTQzyD816f4RsplnrRqLVlIMbr9Q/n5TvlgjjhX7IMEfMy4+7qLGRQkNbFzgwK
- jxNG2fFSCjOEQitm0gAtx7QRIyvYr6c7/xiHz4AwxYzBmvQsL/OK57NO4+Krwgj5
- Vk8TQ2jGO7J4bB38zaxK+Lrtfl8i1AK1171JqFMhOc34JSJ7T4LWDMECAwEAAQ==
- -----END RSA PUBLIC KEY-----
- '';
- };
- };
- ssh.privkey.path = <secrets/ssh.id_ed25519>;
- ssh.pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOd/HqZIO9Trn3eycl23GZAz21HQCISaVNfNyaLSQvJ6";
- };
ju = {
external = true;
nets = {
diff --git a/krebs/5pkgs/simple/withGetopt.nix b/krebs/5pkgs/simple/withGetopt.nix
index fd59adcaf..196e6765a 100644
--- a/krebs/5pkgs/simple/withGetopt.nix
+++ b/krebs/5pkgs/simple/withGetopt.nix
@@ -13,6 +13,7 @@ opt-spec: cmd-spec: let
opts = mapAttrs (name: value: value // rec {
long = value.long or (replaceStrings ["_"] ["-"] name);
ref = value.ref or "\"\$${varname}\"";
+ short = value.short or null;
switch = value.switch or false;
varname = value.varname or (replaceStrings ["-"] ["_"] name);
}) opt-spec;
@@ -43,11 +44,17 @@ in writeDash wrapper-name ''
'') opts)}
args=$(${utillinux}/bin/getopt \
+ -l ${shell.escape
+ (concatMapStringsSep ","
+ (opt: opt.long + optionalString (!opt.switch) ":")
+ (filter (opt: opt.long != null)
+ (attrValues opts)))} \
-n "$wrapper_name" \
- -o "" \
- -l ${concatMapStringsSep ","
- (opt: opt.long + optionalString (!opt.switch) ":")
- (attrValues opts)} \
+ -o ${shell.escape
+ (concatMapStringsSep ""
+ (opt: opt.short + optionalString (!opt.switch) ":")
+ (filter (opt: opt.short != null)
+ (attrValues opts)))} \
-s sh \
-- "$@")
if \test $? != 0; then exit 1; fi
@@ -56,7 +63,10 @@ in writeDash wrapper-name ''
while :; do
case $1 in
${concatStringsSep "\n" (mapAttrsToList (name: opt: /* sh */ ''
- --${opt.long})
+ (${concatMapStringsSep "|" shell.escape (filter (x: x != "") [
+ (optionalString (opt.long != null) "--${opt.long}")
+ (optionalString (opt.short != null) "-${opt.short}")
+ ])})
${if opt.switch then /* sh */ ''
${opt.varname}=true
shift
@@ -65,7 +75,9 @@ in writeDash wrapper-name ''
shift 2
''}
;;
- '') opts)}
+ '') (filterAttrs
+ (_: opt: opt.long != null || opt.short != null)
+ opts))}
--)
shift
break
@@ -102,5 +114,5 @@ in writeDash wrapper-name ''
export ${opt.varname}
'') opts)}
- ${cmd-script}
+ ${cmd-script} "$@"
''