mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-01-21 18:41:34 +01:00
Move modules in programs/services subfolders
This commit is contained in:
parent
2ff87c8404
commit
211ca98e92
38 changed files with 0 additions and 0 deletions
73
modules/system/services/syncthing/default.nix
Normal file
73
modules/system/services/syncthing/default.nix
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
{
|
||||
config,
|
||||
self,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.custom.services.syncthing;
|
||||
in
|
||||
{
|
||||
options.custom.services.syncthing = {
|
||||
enable = lib.mkEnableOption "";
|
||||
isServer = lib.mkEnableOption "";
|
||||
deviceId = lib.mkOption {
|
||||
type = lib.types.nonEmptyStr;
|
||||
default = "";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
services.syncthing = {
|
||||
enable = true;
|
||||
|
||||
user = lib.mkIf (!cfg.isServer) "seb";
|
||||
group = lib.mkIf (!cfg.isServer) "users";
|
||||
dataDir = lib.mkIf (!cfg.isServer) "/home/seb";
|
||||
|
||||
guiAddress = lib.mkIf cfg.isServer "0.0.0.0:8384";
|
||||
|
||||
settings = {
|
||||
# Get the devices and their ids from the configs of the other hosts
|
||||
devices =
|
||||
self.nixosConfigurations
|
||||
|> lib.filterAttrs (name: _: name != config.networking.hostName)
|
||||
|> lib.filterAttrs (_: value: value.config.custom.services.syncthing.enable)
|
||||
|> lib.mapAttrs (
|
||||
name: value: {
|
||||
id = value.config.custom.services.syncthing.deviceId;
|
||||
addresses = [ "tcp://${name}.${value.config.networking.domain}:22000" ];
|
||||
}
|
||||
);
|
||||
|
||||
folders =
|
||||
let
|
||||
genFolders =
|
||||
folders:
|
||||
lib.genAttrs folders (name: {
|
||||
path = "${config.services.syncthing.dataDir}/${name}";
|
||||
ignorePerms = false;
|
||||
devices = lib.attrNames config.services.syncthing.settings.devices;
|
||||
});
|
||||
in
|
||||
genFolders [
|
||||
"Documents"
|
||||
"Downloads"
|
||||
"Music"
|
||||
"Pictures"
|
||||
"Projects"
|
||||
"Videos"
|
||||
];
|
||||
|
||||
options = {
|
||||
globalAnnounceEnabled = false;
|
||||
localAnnounceEnabled = false;
|
||||
relaysEnabled = false;
|
||||
natEnabled = false;
|
||||
urAccepted = -1;
|
||||
autoUpgradeIntervalH = 0;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue