Skip to content

Commit

Permalink
nix stdlib: add dns function
Browse files Browse the repository at this point in the history
and use that in cicero's CI
  • Loading branch information
dermetfan committed Jan 17, 2022
1 parent 4de4259 commit 1a0cc55
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
9 changes: 2 additions & 7 deletions actions/cicero/ci.nix
Expand Up @@ -16,6 +16,8 @@ std.behavior.onInputChange "start" name args
std.chain args [
actionLib.jobDefaults

(std.dns [ "1.1.1.1" ])

(std.escapeNames [ ] [ ])

{
Expand All @@ -32,8 +34,6 @@ std.behavior.onInputChange "start" name args

(std.wrapScript "bash" (next: ''
set -x
mkdir -p /etc
echo "nameserver 1.1.1.1" >> /etc/resolv.conf
${lib.escapeShellArgs next}
''))

Expand Down Expand Up @@ -79,9 +79,6 @@ std.behavior.onInputChange "start" name args

(std.script "bash" ''
set -ex
mkdir -p /etc
echo "nameserver 1.1.1.1" >> /etc/resolv.conf
exec cicero start
'')
];
Expand All @@ -101,8 +98,6 @@ std.behavior.onInputChange "start" name args

(std.wrapScript "bash" (next: ''
set -ex
mkdir -p /etc
echo "nameserver 1.1.1.1" >> /etc/resolv.conf
exec ${lib.escapeShellArgs next}
''))

Expand Down
10 changes: 9 additions & 1 deletion pkgs/cicero/evaluators/nix/lib.nix
Expand Up @@ -208,6 +208,14 @@ rec {
template = data-merge.append outer.template;
};

dns = nameservers:
wrapScript "bash" (next: ''
mkdir -p /etc
for nameserver in ${lib.escapeShellArg nameservers}; do
echo "nameserver $nameserver" >> /etc/resolv.conf
done
'');

nix = {
install = action: next:
data-merge.merge
Expand Down Expand Up @@ -357,7 +365,7 @@ rec {
};

inherit (actions) behavior;
inherit (tasks) script;
inherit (tasks) script dns;
inherit (chains) chain;
inherit (chains.jobs) escapeNames singleTask;
inherit (chains.tasks) wrapScript nix makes git github;
Expand Down

0 comments on commit 1a0cc55

Please sign in to comment.