parent
3a538e674d
commit
c7571611dc
@ -0,0 +1,70 @@ |
||||
{ config, pkgs, lib, ... }: |
||||
|
||||
with lib; |
||||
|
||||
let |
||||
cfg = config.services.cfdyndns; |
||||
in |
||||
{ |
||||
options = { |
||||
services.cfdyndns = { |
||||
enable = mkEnableOption "Cloudflare Dynamic DNS Client"; |
||||
|
||||
email = mkOption { |
||||
type = types.str; |
||||
description = '' |
||||
The email address to use to authenticate to CloudFlare. |
||||
''; |
||||
}; |
||||
|
||||
apikey = mkOption { |
||||
type = types.str; |
||||
description = '' |
||||
The API Key to use to authenticate to CloudFlare. |
||||
''; |
||||
}; |
||||
|
||||
records = mkOption { |
||||
default = []; |
||||
example = [ "host.tld" ]; |
||||
type = types.listOf types.str; |
||||
description = '' |
||||
The records to update in CloudFlare. |
||||
''; |
||||
}; |
||||
}; |
||||
}; |
||||
|
||||
config = mkIf cfg.enable { |
||||
systemd.services.cfdyndns = { |
||||
description = "CloudFlare Dynamic DNS Client"; |
||||
after = [ "network.target" ]; |
||||
wantedBy = [ "multi-user.target" ]; |
||||
startAt = "5 minutes"; |
||||
serviceConfig = { |
||||
Type = "simple"; |
||||
User = config.ids.uids.cfdyndns; |
||||
Group = config.ids.gids.cfdyndns; |
||||
ExecStart = "/bin/sh -c '${pkgs.cfdyndns}/bin/cfdyndns'"; |
||||
}; |
||||
environment = { |
||||
CLOUDFLARE_EMAIL="${cfg.email}"; |
||||
CLOUDFLARE_APIKEY="${cfg.apikey}"; |
||||
CLOUDFLARE_RECORDS="${concatStringsSep "," cfg.records}"; |
||||
}; |
||||
}; |
||||
|
||||
users.extraUsers = { |
||||
cfdyndns = { |
||||
group = "cfdyndns"; |
||||
uid = config.ids.uids.cfdyndns; |
||||
}; |
||||
}; |
||||
|
||||
users.extraGroups = { |
||||
cfdyndns = { |
||||
gid = config.ids.gids.cfdyndns; |
||||
}; |
||||
}; |
||||
}; |
||||
} |
@ -0,0 +1,30 @@ |
||||
{ stdenv, fetchFromGitHub, rustPlatform, makeWrapper, openssl }: |
||||
|
||||
with rustPlatform; |
||||
|
||||
buildRustPackage rec { |
||||
name = "cfdyndns-${version}"; |
||||
version = "0.0.1"; |
||||
src = fetchFromGitHub { |
||||
owner = "colemickens"; |
||||
repo = "cfdyndns"; |
||||
rev = "v${version}"; |
||||
sha256 = "1mcdjykrgh0jq6k6y664lai8sbgzk6j7k0r944f43vg63d1jql5b"; |
||||
}; |
||||
|
||||
depsSha256 = "0whs3fgmpb6g1mjajs3qs9g613x5dal4x6ghzzkpl73a9pgydkpn"; |
||||
|
||||
buildInputs = [ makeWrapper openssl ]; |
||||
|
||||
installPhase = '' |
||||
mkdir -p $out/bin |
||||
cp -p target/release/cfdyndns $out/bin/ |
||||
''; |
||||
|
||||
meta = with stdenv.lib; { |
||||
description = "CloudFlare Dynamic DNS Client"; |
||||
homepage = https://github.com/colemickens/cfdyndns; |
||||
license = stdenv.lib.licenses.mit; |
||||
maintainers = with maintainers; [ colemickens ]; |
||||
}; |
||||
} |
Loading…
Reference in new issue