summaryrefslogtreecommitdiffstats
path: root/krebs
diff options
context:
space:
mode:
Diffstat (limited to 'krebs')
-rw-r--r--krebs/3modules/monit.nix4
-rw-r--r--krebs/3modules/repo-sync.nix114
-rw-r--r--krebs/3modules/tv/default.nix2
-rw-r--r--krebs/5pkgs/writers.nix28
4 files changed, 101 insertions, 47 deletions
diff --git a/krebs/3modules/monit.nix b/krebs/3modules/monit.nix
index 4d4066ae4..cc4a1b208 100644
--- a/krebs/3modules/monit.nix
+++ b/krebs/3modules/monit.nix
@@ -49,10 +49,10 @@ let
type = with types; attrsOf (submodule {
options = {
test = mkOption {
- type = path;
+ type = either path str;
};
alarm = mkOption {
- type = path;
+ type = either path str;
};
interval = mkOption {
type = str;
diff --git a/krebs/3modules/repo-sync.nix b/krebs/3modules/repo-sync.nix
index 7705635f0..0211b31ba 100644
--- a/krebs/3modules/repo-sync.nix
+++ b/krebs/3modules/repo-sync.nix
@@ -12,7 +12,34 @@ let
api = {
enable = mkEnableOption "repo-sync";
repos = mkOption {
- type = with types;attrsOf (attrsOf (attrsOf (attrsOf str)));
+ type = types.attrsOf (types.submodule {
+ options = {
+ branches = mkOption {
+ type = types.attrsOf (types.submodule ({ config, ... }: {
+ options = {
+ origin = mkOption {
+ type = types.git-source;
+ };
+ mirror = mkOption {
+ type = types.git-source;
+ };
+ };
+ config = {
+ origin.ref = mkDefault "heads/master";
+ mirror.ref = mkDefault "heads/${config._module.args.name}";
+ };
+ }));
+ };
+ latest = mkOption {
+ type = types.nullOr types.git-source;
+ default = null;
+ };
+ timerConfig = mkOption {
+ type = types.attrsOf types.str;
+ default = cfg.timerConfig;
+ };
+ };
+ });
example = literalExample ''
# see `repo-sync --help`
# `ref` provides sane defaults and can be omitted
@@ -23,53 +50,53 @@ let
# each attrset defines a group of repos for syncing
{ nxpkgs = {
- makefu = {
- origin = {
- url = http://github.com/makefu/nixpkgs;
- ref = "heads/dev" ;
+ branches = {
+ makefu = {
+ origin = {
+ url = http://github.com/makefu/nixpkgs;
+ ref = "heads/dev" ;
+ };
+ mirror = {
+ url = "git@internal:nixpkgs-mirror" ;
+ ref = "heads/github-mirror-dev" ;
+ };
};
- mirror = {
- url = "git@internal:nixpkgs-mirror" ;
- ref = "heads/github-mirror-dev" ;
+ lass = {
+ origin = {
+ url = http://github.com/lass/nixpkgs;
+ };
+ mirror = {
+ url = "git@internal:nixpkgs-mirror" ;
+ };
};
};
- lass = {
- origin = {
- url = http://github.com/lass/nixpkgs;
- };
- mirror = {
- url = "git@internal:nixpkgs-mirror" ;
- };
- };
- "@latest" = {
- mirror = {
- url = "git@internal:nixpkgs-mirror";
- ref = "heads/master";
- };
+ latest = {
+ url = "git@internal:nixpkgs-mirror";
+ ref = "heads/master";
};
};
stockholm = {
- lass = {
- origin = {
- url = http://cgit.prism.r/stockholm;
+ branches = {
+ lass = {
+ origin = {
+ url = http://cgit.prism.r/stockholm;
+ };
+ mirror = {
+ url = "git@internal:stockholm-mirror" ;
+ };
};
- mirror = {
- url = "git@internal:stockholm-mirror" ;
+ makefu = {
+ origin = {
+ url = http://gum.krebsco.de/stockholm;
+ };
+ mirror = {
+ url = "git@internal:stockholm-mirror" ;
+ };
};
};
- makefu = {
- origin = {
- url = http://gum.krebsco.de/stockholm;
- };
- mirror = {
- url = "git@internal:stockholm-mirror" ;
- };
- };
- "@latest" = {
- mirror = {
- url = "git@internal:stockholm-mirror";
- ref = "heads/master";
- };
+ latest = {
+ url = "git@internal:stockholm-mirror";
+ ref = "heads/master";
};
};
};
@@ -127,15 +154,16 @@ let
nameValuePair "repo-sync-${name}" {
description = "repo-sync timer";
wantedBy = [ "timers.target" ];
-
- timerConfig = cfg.timerConfig;
+ timerConfig = repo.timerConfig;
}
) cfg.repos;
systemd.services = mapAttrs' (name: repo:
let
- repo-sync-config = pkgs.writeText "repo-sync-config-${name}.json"
- (builtins.toJSON repo);
+ repo-sync-config = pkgs.writeJSON "repo-sync-config-${name}.json"
+ (repo.branches // optionalAttrs (repo.latest != null) {
+ "@latest".mirror = repo.latest;
+ });
in nameValuePair "repo-sync-${name}" {
description = "repo-sync";
after = [ "network.target" "secret.service" ];
diff --git a/krebs/3modules/tv/default.nix b/krebs/3modules/tv/default.nix
index 1220143a7..d44c322aa 100644
--- a/krebs/3modules/tv/default.nix
+++ b/krebs/3modules/tv/default.nix
@@ -85,7 +85,7 @@ with import <stockholm/lib>;
};
nets = {
internet = {
- ip4.addr = "64.137.177.226";
+ ip4.addr = "45.62.237.203";
aliases = [
"cd.i"
"cd.krebsco.de"
diff --git a/krebs/5pkgs/writers.nix b/krebs/5pkgs/writers.nix
index 65ee14485..d14090323 100644
--- a/krebs/5pkgs/writers.nix
+++ b/krebs/5pkgs/writers.nix
@@ -2,6 +2,32 @@
with import <stockholm/lib>;
{
nixpkgs.config.packageOverrides = _: {
+
+ # Combine a list of derivations using symlinks. Paths in later derivations
+ # take precedence over earlier ones.
+ #
+ # Example: create wrapper but retain all other files (man pages etc.)
+ #
+ # {
+ # nixpkgs.config.packageOverrides = super: {
+ # hello = pkgs.concat "hello" [
+ # super.hello
+ # (pkgs.writeDashBin "hello" ''
+ # echo OMG
+ # echo exec ${super.hello}/bin/hello "$@"
+ # '')
+ # ];
+ # };
+ # }
+ #
+ concat = name: xs: pkgs.runCommand name {} ''
+ mkdir $out
+ ${flip concatMapStrings xs (x: ''
+ cp --remove-destination -vrs ${x}/* $out
+ find $out -type d -exec chmod -v u+rwx {} +
+ '')}
+ '';
+
execve = name: { filename, argv ? null, envp ? {}, destination ? "" }: let
in pkgs.writeC name { inherit destination; } /* c */ ''
#include <unistd.h>
@@ -96,7 +122,7 @@ with import <stockholm/lib>;
assert types.package.check link;
{
install = /* sh */ ''
- ${optionalString (dirOf path != "/") /* sh */ ''
+ ${optionalString (path != "") /* sh */ ''
${pkgs.coreutils}/bin/mkdir -p $out${dirOf path}
''}
${pkgs.coreutils}/bin/ln -s ${link} $out${path}