krebs.retiolum: define type of hosts

This commit is contained in:
tv 2015-07-24 12:41:41 +02:00
parent e082da2c23
commit faf5f6c172
6 changed files with 18 additions and 27 deletions

View File

@ -89,7 +89,6 @@ in
imports = [ ../../3modules/krebs/retiolum.nix ];
krebs.retiolum = {
enable = true;
hosts = ../../Zhosts;
connectTo = [
"fastpoke"
"pigstarter"

View File

@ -32,7 +32,6 @@ with lib;
imports = [ ../../3modules/krebs/retiolum.nix ];
krebs.retiolum = {
enable = true;
hosts = ../../Zhosts;
connectTo = [
"cd"
"fastpoke"

View File

@ -40,7 +40,6 @@ with lib;
imports = [ ../../3modules/krebs/retiolum.nix ];
krebs.retiolum = {
enable = true;
hosts = ../../Zhosts;
connectTo = [
"gum"
"pigstarter"

View File

@ -32,7 +32,6 @@ with lib;
imports = [ ../../3modules/krebs/retiolum.nix ];
krebs.retiolum = {
enable = true;
hosts = ../../Zhosts;
connectTo = [
"cd"
"mkdir"

View File

@ -148,7 +148,6 @@ in
imports = [ ../../3modules/krebs/retiolum.nix ];
krebs.retiolum = {
enable = true;
hosts = ../../Zhosts;
connectTo = [
"gum"
"pigstarter"

View File

@ -57,9 +57,9 @@ let
};
hosts = mkOption {
default = null;
type = with types; either package path;
default = ../../Zhosts;
description = ''
Hosts package or path to use.
If a path is given, then it will be used to generate an ad-hoc package.
'';
};
@ -127,24 +127,20 @@ let
};
tinc = cfg.tincPackage;
hostsType = builtins.typeOf cfg.hosts;
hosts =
if hostsType == "package" then
# use package as is
cfg.hosts
else if hostsType == "path" then
# use path to generate a package
pkgs.stdenv.mkDerivation {
hosts = getAttr (typeOf cfg.hosts) {
package = cfg.hosts;
path = pkgs.stdenv.mkDerivation {
name = "custom-retiolum-hosts";
src = cfg.hosts;
installPhase = ''
mkdir $out
find . -name .git -prune -o -type f -print0 | xargs -0 cp --target-directory $out
find . -name .git -prune -o -type f -print0 \
| xargs -0 cp --target-directory $out
'';
}
else
abort "The option `services.retiolum.hosts' must be set to a package or a path"
;
};
};
iproute = cfg.iproutePackage;
retiolumExtraHosts = import (pkgs.runCommand "retiolum-etc-hosts"
@ -222,5 +218,5 @@ let
chmod +x $out/tinc-up
'';
in
out
in out