Syncthing, HM and Nixos Module
This commit is contained in:
parent
bdb1ba2249
commit
863101b6f6
4 changed files with 152 additions and 2 deletions
63
hmModules/services/syncthing/service.nix
Normal file
63
hmModules/services/syncthing/service.nix
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
{ config, lib, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
options.syncthing = {
|
||||||
|
enable = lib.mkEnableOption "Enables Syncthing service";
|
||||||
|
|
||||||
|
devices = lib.mkOption {
|
||||||
|
type = lib.types.attrsOf (lib.types.submodule {
|
||||||
|
options = {
|
||||||
|
id = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
description = "Device ID";
|
||||||
|
};
|
||||||
|
addresses = lib.mkOption {
|
||||||
|
type = lib.types.listOf lib.types.str;
|
||||||
|
default = [ "dynamic" ];
|
||||||
|
description = "List of device addresses";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
|
default = {};
|
||||||
|
description = "Syncthing devices";
|
||||||
|
};
|
||||||
|
|
||||||
|
folders = lib.mkOption {
|
||||||
|
type = lib.types.attrsOf (lib.types.submodule {
|
||||||
|
options = {
|
||||||
|
path = lib.mkOption {
|
||||||
|
type = lib.types.path;
|
||||||
|
description = "Path to folder";
|
||||||
|
};
|
||||||
|
devices = lib.mkOption {
|
||||||
|
type = lib.types.listOf lib.types.str;
|
||||||
|
default = [];
|
||||||
|
description = "List of device names to share with";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
|
default = {};
|
||||||
|
description = "Syncthing folders";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf config.syncthing.enable {
|
||||||
|
services.syncthing = {
|
||||||
|
enable = true;
|
||||||
|
overrideDevices = true;
|
||||||
|
overrideFolders = true;
|
||||||
|
|
||||||
|
settings = {
|
||||||
|
devices = lib.mapAttrs (name: device: {
|
||||||
|
id = device.id;
|
||||||
|
addresses = device.addresses;
|
||||||
|
}) config.syncthing.devices;
|
||||||
|
|
||||||
|
folders = lib.mapAttrs (name: folder: {
|
||||||
|
path = folder.path;
|
||||||
|
devices = folder.devices;
|
||||||
|
}) config.syncthing.folders;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -3,8 +3,7 @@ let
|
||||||
email = "admin@woach.me";
|
email = "admin@woach.me";
|
||||||
in {
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
./hardware.nix
|
./hardware.nix ];
|
||||||
];
|
|
||||||
system.stateVersion = "24.11";
|
system.stateVersion = "24.11";
|
||||||
system.timezone = "America/Los_Angeles";
|
system.timezone = "America/Los_Angeles";
|
||||||
system.users.bigWheels = [ "pan" ];
|
system.users.bigWheels = [ "pan" ];
|
||||||
|
|
@ -66,6 +65,22 @@ in {
|
||||||
server.domain = "ginko.woach.me";
|
server.domain = "ginko.woach.me";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
syncthing = {
|
||||||
|
enable = true;
|
||||||
|
devices = {
|
||||||
|
"homura".id = "NEP24DB-DVXAHTZ-TCCNREQ-Q5TSC7K-ZXPWC4L-5ELGKQX-4I2P47O-2FT5QAU";
|
||||||
|
"onizuka".id = "5S6QMND-MHD2HYR-DR6KQD4-6AWJTRL-FQUCR7W-FD2KBT3-AF6RE6R-F47KBQC";
|
||||||
|
};
|
||||||
|
|
||||||
|
folders = {
|
||||||
|
"wiki" = {
|
||||||
|
path = "/var/lib/wiki";
|
||||||
|
devices = [ "homura" "onizuka" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
systemd.tmpfiles.rules = [ "d /var/lib/wiki 0755 syncthing syncthing -" ];
|
||||||
|
|
||||||
postgres.enable = true;
|
postgres.enable = true;
|
||||||
|
|
||||||
shell.enabledShells = [ "fish" ];
|
shell.enabledShells = [ "fish" ];
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,14 @@
|
||||||
ssh.enable = true;
|
ssh.enable = true;
|
||||||
librewolf.enable = true;
|
librewolf.enable = true;
|
||||||
librewolf.make_default = true;
|
librewolf.make_default = true;
|
||||||
|
syncthing = {
|
||||||
|
enable = true;
|
||||||
|
devices."juri".id = "HAUUSTK-W2YD6MV-DL2T2MV-XSHSFSC-IA6P6GY-B62IC27-YKHVQLX-374FRAO";
|
||||||
|
folders."wiki" = {
|
||||||
|
path = "${config.xdg.userDirs.documents}/neowiki";
|
||||||
|
devices = [ "juri" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
mpv.enable = true;
|
mpv.enable = true;
|
||||||
zathura.enable = true;
|
zathura.enable = true;
|
||||||
|
|
|
||||||
64
nixosModules/services/syncthing/service.nix
Normal file
64
nixosModules/services/syncthing/service.nix
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
{ config, lib, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
options.syncthing = {
|
||||||
|
enable = lib.mkEnableOption "Enables Syncthing service";
|
||||||
|
|
||||||
|
devices = lib.mkOption {
|
||||||
|
type = lib.types.attrsOf (lib.types.submodule {
|
||||||
|
options = {
|
||||||
|
id = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
description = "Device ID";
|
||||||
|
};
|
||||||
|
addresses = lib.mkOption {
|
||||||
|
type = lib.types.listOf lib.types.str;
|
||||||
|
default = [ "dynamic" ];
|
||||||
|
description = "List of device addresses";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
|
default = {};
|
||||||
|
description = "Syncthing devices";
|
||||||
|
};
|
||||||
|
|
||||||
|
folders = lib.mkOption {
|
||||||
|
type = lib.types.attrsOf (lib.types.submodule {
|
||||||
|
options = {
|
||||||
|
path = lib.mkOption {
|
||||||
|
type = lib.types.path;
|
||||||
|
description = "Path to folder";
|
||||||
|
};
|
||||||
|
devices = lib.mkOption {
|
||||||
|
type = lib.types.listOf lib.types.str;
|
||||||
|
default = [];
|
||||||
|
description = "List of device names to share with";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
|
default = {};
|
||||||
|
description = "Syncthing folders";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf config.syncthing.enable {
|
||||||
|
services.syncthing = {
|
||||||
|
enable = true;
|
||||||
|
openDefaultPorts = true;
|
||||||
|
overrideDevices = true;
|
||||||
|
overrideFolders = true;
|
||||||
|
|
||||||
|
settings = {
|
||||||
|
devices = lib.mapAttrs (name: device: {
|
||||||
|
id = device.id;
|
||||||
|
addresses = device.addresses;
|
||||||
|
}) config.syncthing.devices;
|
||||||
|
|
||||||
|
folders = lib.mapAttrs (name: folder: {
|
||||||
|
path = folder.path;
|
||||||
|
devices = folder.devices;
|
||||||
|
}) config.syncthing.folders;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue