-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "{nixos/modules,pkgs}/ddns: remove ddns (#93)"
This reverts commit e3f4686.
- Loading branch information
Showing
7 changed files
with
160 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
{ | ||
config, | ||
lib, | ||
pkgs, | ||
... | ||
}: | ||
let | ||
inherit (lib) | ||
filterAttrs | ||
mapAttrs' | ||
mkIf | ||
mkOption | ||
nameValuePair | ||
toUpper | ||
types | ||
; | ||
cfg = config.services.ddns; | ||
ddnsOptions = { | ||
options = { | ||
ipv4 = mkOption { | ||
type = with types; nullOr str; | ||
default = null; | ||
}; | ||
ipv6 = mkOption { | ||
type = with types; nullOr str; | ||
default = null; | ||
}; | ||
index4 = mkOption { | ||
type = with types; nullOr str; | ||
default = null; | ||
}; | ||
index6 = mkOption { | ||
type = with types; nullOr str; | ||
default = null; | ||
}; | ||
ttl = mkOption { | ||
type = with types; nullOr int; | ||
default = null; | ||
}; | ||
proxy = mkOption { | ||
type = with types; nullOr str; | ||
default = null; | ||
}; | ||
dns = mkOption { | ||
type = with types; nullOr str; | ||
default = null; | ||
}; | ||
package = mkOption { | ||
type = with types; package; | ||
default = pkgs.ddns; | ||
}; | ||
extraPath = mkOption { | ||
type = with types; listOf package; | ||
default = [ ]; | ||
}; | ||
environmentFile = mkOption { | ||
type = with types; listOf str; | ||
default = [ ]; | ||
}; | ||
onCalendar = mkOption { | ||
type = with types; nullOr str; | ||
default = null; | ||
}; | ||
}; | ||
}; | ||
mkService = name: ddns: { | ||
path = [ ddns.package ] ++ ddns.extraPath; | ||
environment = mapAttrs' (name: value: nameValuePair "DDNS_${toUpper name}" value) ( | ||
filterAttrs (n: v: (builtins.typeOf v) == "string" && n != "onCalendar") ddns | ||
); | ||
serviceConfig = { | ||
ExecStart = "${ddns.package}/bin/ddns"; | ||
EnvironmentFile = ddns.environmentFile; | ||
DynamicUser = true; | ||
}; | ||
}; | ||
mkTimer = | ||
name: ddns: | ||
mkIf (ddns.onCalendar != null) { | ||
wantedBy = [ "timers.target" ]; | ||
timerConfig = { | ||
OnCalendar = ddns.onCalendar; | ||
Persistent = true; | ||
}; | ||
}; | ||
in | ||
{ | ||
options.services.ddns = mkOption { | ||
default = { }; | ||
type = types.attrsOf (types.submodule ddnsOptions); | ||
}; | ||
config = lib.mkIf (cfg != { }) ( | ||
lib.mkMerge [ | ||
{ | ||
systemd.services = mapAttrs' (n: v: nameValuePair "ddns-${n}" (mkService n v)) cfg; | ||
systemd.timers = mapAttrs' (n: v: nameValuePair "ddns-${n}" (mkTimer n v)) cfg; | ||
} | ||
] | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
./clash | ||
./nix.nix | ||
./rathole.nix | ||
./ddns.nix | ||
./nix-ld.nix | ||
./gui.nix | ||
./user.nix | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ buildPythonApplication | ||
, fetchPypi | ||
}: | ||
buildPythonApplication | ||
rec { | ||
pname = "ddns"; | ||
version = "2.12.0"; | ||
name = "${pname}-${version}"; | ||
src = fetchPypi { | ||
inherit pname version; | ||
sha256 = "A41erAo7KOkgPpE+Izuof+MuUzOORPPraxFoj4/dtk0="; | ||
}; | ||
|
||
# Ungly hack for https://github.com/NewFuture/DDNS/blob/a1a8f8565c80d9702a49fcb45f18b32dfb4dba26/setup.py#L47 | ||
# setup a fack "travis" environment, pass package version to skip the check | ||
TRAVIS_TAG = version; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters