mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-23 23:43:30 +00:00
nixos/services.tinc: Fix whitespace
Fix indentation for previous commit
This commit is contained in:
parent
ca591e7008
commit
705392e011
@ -351,92 +351,92 @@ in
|
||||
|
||||
config = mkIf (cfg.networks != { }) (
|
||||
let
|
||||
etcConfig = foldr (a: b: a // b) { }
|
||||
(flip mapAttrsToList cfg.networks (network: data:
|
||||
flip mapAttrs' data.hosts (host: text: nameValuePair
|
||||
("tinc/${network}/hosts/${host}")
|
||||
({ mode = "0644"; user = "tinc.${network}"; inherit text; })
|
||||
) // {
|
||||
"tinc/${network}/tinc.conf" = {
|
||||
mode = "0444";
|
||||
text = ''
|
||||
${toTincConf ({ Interface = "tinc.${network}"; } // data.settings)}
|
||||
${data.extraConfig}
|
||||
'';
|
||||
};
|
||||
}
|
||||
));
|
||||
etcConfig = foldr (a: b: a // b) { }
|
||||
(flip mapAttrsToList cfg.networks (network: data:
|
||||
flip mapAttrs' data.hosts (host: text: nameValuePair
|
||||
("tinc/${network}/hosts/${host}")
|
||||
({ mode = "0644"; user = "tinc.${network}"; inherit text; })
|
||||
) // {
|
||||
"tinc/${network}/tinc.conf" = {
|
||||
mode = "0444";
|
||||
text = ''
|
||||
${toTincConf ({ Interface = "tinc.${network}"; } // data.settings)}
|
||||
${data.extraConfig}
|
||||
'';
|
||||
};
|
||||
}
|
||||
));
|
||||
in {
|
||||
environment.etc = etcConfig;
|
||||
environment.etc = etcConfig;
|
||||
|
||||
systemd.services = flip mapAttrs' cfg.networks (network: data: nameValuePair
|
||||
("tinc.${network}")
|
||||
(let version = getVersion data.package; in {
|
||||
description = "Tinc Daemon - ${network}";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
path = [ data.package ];
|
||||
reloadTriggers = mkIf (versionAtLeast version "1.1pre") [ (builtins.toJSON etcConfig) ];
|
||||
restartTriggers = mkIf (versionOlder version "1.1pre") [ (builtins.toJSON etcConfig) ];
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
Restart = "always";
|
||||
RestartSec = "3";
|
||||
ExecReload = mkIf (versionAtLeast version "1.1pre") "${data.package}/bin/tinc -n ${network} reload";
|
||||
ExecStart = "${data.package}/bin/tincd -D -U tinc.${network} -n ${network} ${optionalString (data.chroot) "-R"} --pidfile /run/tinc.${network}.pid -d ${toString data.debugLevel}";
|
||||
systemd.services = flip mapAttrs' cfg.networks (network: data: nameValuePair
|
||||
("tinc.${network}")
|
||||
(let version = getVersion data.package; in {
|
||||
description = "Tinc Daemon - ${network}";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
path = [ data.package ];
|
||||
reloadTriggers = mkIf (versionAtLeast version "1.1pre") [ (builtins.toJSON etcConfig) ];
|
||||
restartTriggers = mkIf (versionOlder version "1.1pre") [ (builtins.toJSON etcConfig) ];
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
Restart = "always";
|
||||
RestartSec = "3";
|
||||
ExecReload = mkIf (versionAtLeast version "1.1pre") "${data.package}/bin/tinc -n ${network} reload";
|
||||
ExecStart = "${data.package}/bin/tincd -D -U tinc.${network} -n ${network} ${optionalString (data.chroot) "-R"} --pidfile /run/tinc.${network}.pid -d ${toString data.debugLevel}";
|
||||
};
|
||||
preStart = ''
|
||||
mkdir -p /etc/tinc/${network}/hosts
|
||||
chown tinc.${network} /etc/tinc/${network}/hosts
|
||||
mkdir -p /etc/tinc/${network}/invitations
|
||||
chown tinc.${network} /etc/tinc/${network}/invitations
|
||||
|
||||
# Determine how we should generate our keys
|
||||
if type tinc >/dev/null 2>&1; then
|
||||
# Tinc 1.1+ uses the tinc helper application for key generation
|
||||
${if data.ed25519PrivateKeyFile != null then " # ed25519 Keyfile managed by nix" else ''
|
||||
# Prefer ED25519 keys (only in 1.1+)
|
||||
[ -f "/etc/tinc/${network}/ed25519_key.priv" ] || tinc -n ${network} generate-ed25519-keys
|
||||
''}
|
||||
${if data.rsaPrivateKeyFile != null then " # RSA Keyfile managed by nix" else ''
|
||||
[ -f "/etc/tinc/${network}/rsa_key.priv" ] || tinc -n ${network} generate-rsa-keys 4096
|
||||
''}
|
||||
# In case there isn't anything to do
|
||||
true
|
||||
else
|
||||
# Tinc 1.0 uses the tincd application
|
||||
[ -f "/etc/tinc/${network}/rsa_key.priv" ] || tincd -n ${network} -K 4096
|
||||
fi
|
||||
'';
|
||||
})
|
||||
);
|
||||
|
||||
environment.systemPackages = let
|
||||
cli-wrappers = pkgs.stdenv.mkDerivation {
|
||||
name = "tinc-cli-wrappers";
|
||||
nativeBuildInputs = [ pkgs.makeWrapper ];
|
||||
buildCommand = ''
|
||||
mkdir -p $out/bin
|
||||
${concatStringsSep "\n" (mapAttrsToList (network: data:
|
||||
optionalString (versionAtLeast data.package.version "1.1pre") ''
|
||||
makeWrapper ${data.package}/bin/tinc "$out/bin/tinc.${network}" \
|
||||
--add-flags "--pidfile=/run/tinc.${network}.pid" \
|
||||
--add-flags "--config=/etc/tinc/${network}"
|
||||
'') cfg.networks)}
|
||||
'';
|
||||
};
|
||||
preStart = ''
|
||||
mkdir -p /etc/tinc/${network}/hosts
|
||||
chown tinc.${network} /etc/tinc/${network}/hosts
|
||||
mkdir -p /etc/tinc/${network}/invitations
|
||||
chown tinc.${network} /etc/tinc/${network}/invitations
|
||||
in [ cli-wrappers ];
|
||||
|
||||
# Determine how we should generate our keys
|
||||
if type tinc >/dev/null 2>&1; then
|
||||
# Tinc 1.1+ uses the tinc helper application for key generation
|
||||
${if data.ed25519PrivateKeyFile != null then " # ed25519 Keyfile managed by nix" else ''
|
||||
# Prefer ED25519 keys (only in 1.1+)
|
||||
[ -f "/etc/tinc/${network}/ed25519_key.priv" ] || tinc -n ${network} generate-ed25519-keys
|
||||
''}
|
||||
${if data.rsaPrivateKeyFile != null then " # RSA Keyfile managed by nix" else ''
|
||||
[ -f "/etc/tinc/${network}/rsa_key.priv" ] || tinc -n ${network} generate-rsa-keys 4096
|
||||
''}
|
||||
# In case there isn't anything to do
|
||||
true
|
||||
else
|
||||
# Tinc 1.0 uses the tincd application
|
||||
[ -f "/etc/tinc/${network}/rsa_key.priv" ] || tincd -n ${network} -K 4096
|
||||
fi
|
||||
'';
|
||||
})
|
||||
);
|
||||
|
||||
environment.systemPackages = let
|
||||
cli-wrappers = pkgs.stdenv.mkDerivation {
|
||||
name = "tinc-cli-wrappers";
|
||||
nativeBuildInputs = [ pkgs.makeWrapper ];
|
||||
buildCommand = ''
|
||||
mkdir -p $out/bin
|
||||
${concatStringsSep "\n" (mapAttrsToList (network: data:
|
||||
optionalString (versionAtLeast data.package.version "1.1pre") ''
|
||||
makeWrapper ${data.package}/bin/tinc "$out/bin/tinc.${network}" \
|
||||
--add-flags "--pidfile=/run/tinc.${network}.pid" \
|
||||
--add-flags "--config=/etc/tinc/${network}"
|
||||
'') cfg.networks)}
|
||||
'';
|
||||
};
|
||||
in [ cli-wrappers ];
|
||||
|
||||
users.users = flip mapAttrs' cfg.networks (network: _:
|
||||
nameValuePair ("tinc.${network}") ({
|
||||
description = "Tinc daemon user for ${network}";
|
||||
isSystemUser = true;
|
||||
group = "tinc.${network}";
|
||||
})
|
||||
);
|
||||
users.groups = flip mapAttrs' cfg.networks (network: _:
|
||||
nameValuePair "tinc.${network}" {}
|
||||
);
|
||||
});
|
||||
users.users = flip mapAttrs' cfg.networks (network: _:
|
||||
nameValuePair ("tinc.${network}") ({
|
||||
description = "Tinc daemon user for ${network}";
|
||||
isSystemUser = true;
|
||||
group = "tinc.${network}";
|
||||
})
|
||||
);
|
||||
users.groups = flip mapAttrs' cfg.networks (network: _:
|
||||
nameValuePair "tinc.${network}" {}
|
||||
);
|
||||
});
|
||||
|
||||
meta.maintainers = with maintainers; [ minijackson mic92 ];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user