From c7571611dc5f69737d27449cfa8a9ef4af3de64d Mon Sep 17 00:00:00 2001 From: Cole Mickens Date: Sun, 17 Jan 2016 04:11:09 -0800 Subject: [PATCH] cfdyndns: init at 0.0.1 --- lib/maintainers.nix | 1 + nixos/modules/misc/ids.nix | 2 + nixos/modules/module-list.nix | 1 + nixos/modules/services/misc/cfdyndns.nix | 70 +++++++++++++++++++ .../networking/dyndns/cfdyndns/default.nix | 30 ++++++++ pkgs/top-level/all-packages.nix | 2 + 6 files changed, 106 insertions(+) create mode 100644 nixos/modules/services/misc/cfdyndns.nix create mode 100644 pkgs/applications/networking/dyndns/cfdyndns/default.nix diff --git a/lib/maintainers.nix b/lib/maintainers.nix index 808d78d499d..bf6cd29996d 100644 --- a/lib/maintainers.nix +++ b/lib/maintainers.nix @@ -69,6 +69,7 @@ coconnor = "Corey O'Connor "; codsl = "codsl "; codyopel = "Cody Opel "; + colemickens = "Cole Mickens "; copumpkin = "Dan Peebles "; coroa = "Jonas Hörsch "; couchemar = "Andrey Pavlov "; diff --git a/nixos/modules/misc/ids.nix b/nixos/modules/misc/ids.nix index 064b4cbc4b3..82ba9018c7c 100644 --- a/nixos/modules/misc/ids.nix +++ b/nixos/modules/misc/ids.nix @@ -248,6 +248,7 @@ matrix-synapse = 224; rspamd = 225; rmilter = 226; + cfdyndns = 227; # When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399! @@ -473,6 +474,7 @@ matrix-synapse = 224; rspamd = 225; rmilter = 226; + cfdyndns = 227; # When adding a gid, make sure it doesn't match an existing # uid. Users and groups with the same name should have equal diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 0011544988d..f6f674c253d 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -201,6 +201,7 @@ ./services/misc/bepasty.nix ./services/misc/canto-daemon.nix ./services/misc/calibre-server.nix + ./services/misc/cfdyndns.nix ./services/misc/cpuminer-cryptonight.nix ./services/misc/cgminer.nix ./services/misc/confd.nix diff --git a/nixos/modules/services/misc/cfdyndns.nix b/nixos/modules/services/misc/cfdyndns.nix new file mode 100644 index 00000000000..69a33d0b8c1 --- /dev/null +++ b/nixos/modules/services/misc/cfdyndns.nix @@ -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; + }; + }; + }; +} diff --git a/pkgs/applications/networking/dyndns/cfdyndns/default.nix b/pkgs/applications/networking/dyndns/cfdyndns/default.nix new file mode 100644 index 00000000000..43d257d7b0e --- /dev/null +++ b/pkgs/applications/networking/dyndns/cfdyndns/default.nix @@ -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 ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index d91d975689f..6aaa7e07f09 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -786,6 +786,8 @@ let ccnet = callPackage ../tools/networking/ccnet { }; + cfdyndns = callPackage ../applications/networking/dyndns/cfdyndns { }; + ckbcomp = callPackage ../tools/X11/ckbcomp { }; cli53 = callPackage ../tools/admin/cli53 { };