feat: set up syncthing (with e-reader)
This commit is contained in:
24
flake.lock
generated
24
flake.lock
generated
@@ -53,11 +53,11 @@
|
|||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"dir": "pkgs/firefox-addons",
|
"dir": "pkgs/firefox-addons",
|
||||||
"lastModified": 1769745834,
|
"lastModified": 1770091431,
|
||||||
"narHash": "sha256-/7EzWXFrHiF2LiuQPFUD1jhICcRa30QVa/uQCPu1Q/g=",
|
"narHash": "sha256-9Sqq/hxq8ZDLRSzu+edn0OfWG+FAPWFpwMKaJobeLec=",
|
||||||
"owner": "rycee",
|
"owner": "rycee",
|
||||||
"repo": "nur-expressions",
|
"repo": "nur-expressions",
|
||||||
"rev": "ec30ecfdee4b0df2325c2672db21684e806f4b69",
|
"rev": "4f827ff035c6ddc58d04c45abe5b777d356b926a",
|
||||||
"type": "gitlab"
|
"type": "gitlab"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -145,11 +145,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1769776025,
|
"lastModified": 1769978395,
|
||||||
"narHash": "sha256-70a1kVC08AMTvPc7iqQsJbbD4Y1fukakMVudz4oY9SM=",
|
"narHash": "sha256-gj1yP3spUb1vGtaF5qPhshd2j0cg4xf51pklDsIm19Q=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "home-manager",
|
"repo": "home-manager",
|
||||||
"rev": "0fba737f8d5571d41467f3d99a878e11b8c0f0f0",
|
"rev": "984708c34d3495a518e6ab6b8633469bbca2f77a",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -321,11 +321,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1769461804,
|
"lastModified": 1770019141,
|
||||||
"narHash": "sha256-msG8SU5WsBUfVVa/9RPLaymvi5bI8edTavbIq3vRlhI=",
|
"narHash": "sha256-VKS4ZLNx4PNrABoB0L8KUpc1fE7CLpQXQs985tGfaCU=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "bfc1b8a4574108ceef22f02bafcf6611380c100d",
|
"rev": "cb369ef2efd432b3cdf8622b0ffc0a97a02f3137",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -612,11 +612,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1769469829,
|
"lastModified": 1769921679,
|
||||||
"narHash": "sha256-wFcr32ZqspCxk4+FvIxIL0AZktRs6DuF8oOsLt59YBU=",
|
"narHash": "sha256-twBMKGQvaztZQxFxbZnkg7y/50BW9yjtCBWwdjtOZew=",
|
||||||
"owner": "Mic92",
|
"owner": "Mic92",
|
||||||
"repo": "sops-nix",
|
"repo": "sops-nix",
|
||||||
"rev": "c5eebd4eb2e3372fe12a8d70a248a6ee9dd02eff",
|
"rev": "1e89149dcfc229e7e2ae24a8030f124a31e4f24f",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ in
|
|||||||
../../modules/ssh/hardened-openssh.nix
|
../../modules/ssh/hardened-openssh.nix
|
||||||
(import ../../modules/secrets { inherit lib inputs config; })
|
(import ../../modules/secrets { inherit lib inputs config; })
|
||||||
../../modules/docker
|
../../modules/docker
|
||||||
|
../../modules/syncthing
|
||||||
];
|
];
|
||||||
|
|
||||||
home-manager.users.${username} = import ../../home/hosts/andromache {
|
home-manager.users.${username} = import ../../home/hosts/andromache {
|
||||||
@@ -96,7 +97,6 @@ in
|
|||||||
inputs.colmena.packages.${pkgs.system}.colmena
|
inputs.colmena.packages.${pkgs.system}.colmena
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
services = {
|
services = {
|
||||||
xserver = {
|
xserver = {
|
||||||
videoDrivers = [ "nvidia" ];
|
videoDrivers = [ "nvidia" ];
|
||||||
@@ -106,30 +106,33 @@ in
|
|||||||
enable = true;
|
enable = true;
|
||||||
harden = true;
|
harden = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
syncthing = {
|
|
||||||
enable = true;
|
|
||||||
openDefaultPorts = true;
|
|
||||||
settings = {
|
|
||||||
devices = {
|
|
||||||
# "device1" = {
|
|
||||||
# id = "DEVICE-ID-GOES-HERE";
|
|
||||||
# };
|
|
||||||
};
|
|
||||||
folders = {
|
|
||||||
"/home/${username}/sync" = {
|
|
||||||
id = "sync";
|
|
||||||
devices = [ ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
locate = {
|
locate = {
|
||||||
enable = true;
|
enable = true;
|
||||||
package = pkgs.plocate;
|
package = pkgs.plocate;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
my.syncthing = {
|
||||||
|
enable = true;
|
||||||
|
deviceNames = [
|
||||||
|
"boox"
|
||||||
|
"astyanax"
|
||||||
|
];
|
||||||
|
folders = {
|
||||||
|
readings = {
|
||||||
|
path = "/home/h/doc/readings";
|
||||||
|
id = "readings";
|
||||||
|
devices = [
|
||||||
|
{
|
||||||
|
device = "boox";
|
||||||
|
type = "receiveonly";
|
||||||
|
}
|
||||||
|
"astyanax"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
networking = {
|
networking = {
|
||||||
# TODO: generate unique hostId on actual host with: head -c 8 /etc/machine-id
|
# TODO: generate unique hostId on actual host with: head -c 8 /etc/machine-id
|
||||||
hostId = "80eef97e";
|
hostId = "80eef97e";
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ in
|
|||||||
# ../../modules/vpn/wireguard.nix
|
# ../../modules/vpn/wireguard.nix
|
||||||
(import ../../modules/secrets { inherit lib inputs config; })
|
(import ../../modules/secrets { inherit lib inputs config; })
|
||||||
../../modules/docker
|
../../modules/docker
|
||||||
|
../../modules/syncthing
|
||||||
];
|
];
|
||||||
|
|
||||||
home-manager.users.${username} = import ../../home/hosts/astyanax {
|
home-manager.users.${username} = import ../../home/hosts/astyanax {
|
||||||
@@ -99,21 +100,30 @@ in
|
|||||||
enable = true;
|
enable = true;
|
||||||
harden = true;
|
harden = true;
|
||||||
};
|
};
|
||||||
syncthing = {
|
};
|
||||||
enable = true;
|
|
||||||
openDefaultPorts = true;
|
my.syncthing = {
|
||||||
folders = {
|
enable = true;
|
||||||
"/home/h/sync" = {
|
deviceNames = [
|
||||||
id = "sync";
|
"boox"
|
||||||
devices = [ ];
|
"andromache"
|
||||||
};
|
];
|
||||||
};
|
folders = {
|
||||||
devices = {
|
readings = {
|
||||||
# "device1" = {
|
path = "/home/h/doc/readings";
|
||||||
# id = "DEVICE-ID-GOES-HERE";
|
id = "readings";
|
||||||
# };
|
devices = [
|
||||||
|
{
|
||||||
|
device = "boox";
|
||||||
|
type = "receiveonly";
|
||||||
|
}
|
||||||
|
"andromache"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
services = {
|
||||||
locate = {
|
locate = {
|
||||||
enable = true;
|
enable = true;
|
||||||
package = pkgs.plocate;
|
package = pkgs.plocate;
|
||||||
|
|||||||
85
modules/syncthing/default.nix
Normal file
85
modules/syncthing/default.nix
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
{
|
||||||
|
lib,
|
||||||
|
config,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.my.syncthing;
|
||||||
|
allDevices = import ./devices.nix;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.my.syncthing = {
|
||||||
|
enable = mkEnableOption "Syncthing file synchronization";
|
||||||
|
username = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "h";
|
||||||
|
};
|
||||||
|
deviceNames = mkOption {
|
||||||
|
type = types.listOf types.str;
|
||||||
|
default = [ ];
|
||||||
|
};
|
||||||
|
folders = mkOption {
|
||||||
|
type = types.attrsOf (
|
||||||
|
types.submodule {
|
||||||
|
options = {
|
||||||
|
path = mkOption { type = types.path; };
|
||||||
|
id = mkOption { type = types.str; };
|
||||||
|
devices = mkOption {
|
||||||
|
type = types.listOf (
|
||||||
|
types.either types.str (
|
||||||
|
types.submodule {
|
||||||
|
options = {
|
||||||
|
device = mkOption { type = types.str; };
|
||||||
|
type = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "sendreceive";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
default = cfg.deviceNames;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
default = { };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
users.groups.${cfg.username} = { };
|
||||||
|
|
||||||
|
services.syncthing = {
|
||||||
|
enable = true;
|
||||||
|
user = cfg.username;
|
||||||
|
group = cfg.username;
|
||||||
|
configDir = "/home/${cfg.username}/.local/state/syncthing";
|
||||||
|
openDefaultPorts = true;
|
||||||
|
settings = {
|
||||||
|
options = {
|
||||||
|
localAnnounceEnabled = true;
|
||||||
|
globalAnnounceEnabled = true;
|
||||||
|
relaysEnabled = true;
|
||||||
|
urAccepted = -1;
|
||||||
|
};
|
||||||
|
devices = mapAttrs (name: id: { inherit id; }) (
|
||||||
|
filterAttrs (name: _: elem name cfg.deviceNames) allDevices
|
||||||
|
);
|
||||||
|
folders = mapAttrs (name: folder: {
|
||||||
|
inherit (folder) id path;
|
||||||
|
devices = map (
|
||||||
|
device:
|
||||||
|
if isString device then
|
||||||
|
allDevices.${device}
|
||||||
|
else
|
||||||
|
device // { deviceID = allDevices.${device.device}; }
|
||||||
|
) folder.devices;
|
||||||
|
}) cfg.folders;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
5
modules/syncthing/devices.nix
Normal file
5
modules/syncthing/devices.nix
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
boox = "7B5E6PT-HWRQ3WH-OLOSWAZ-T3WNHND-VKUREIJ-AD5I4EA-UJR4M5E-OR5COA7";
|
||||||
|
andromache = "QNVYMOC-GAPIIF7-PKYBN22-PPNAWOF-UJWNUFD-6DXRAJA-AZSMPOS-ULMZWAU";
|
||||||
|
astyanax = "CSSFKEO-2T5PAO5-HX43E4E-UKARH4I-6FVHP36-6YC5WXX-VNMHXD3-WY3QKA7";
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user