revert bd3861c580
revert Merge pull request 'Remove clanModules/*' (#4202) from remove-modules into main Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/4202 See: https://git.clan.lol/clan/clan-core/issues/4365 Not all modules are migrated. If they are not migrated, we need to write migration docs and please display the link to the migration docs
This commit is contained in:
5
clanModules/localsend/README.md
Normal file
5
clanModules/localsend/README.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
description = "Securely sharing files and messages over a local network without internet connectivity."
|
||||
categories = ["Utility"]
|
||||
features = [ "inventory", "deprecated" ]
|
||||
---
|
||||
3
clanModules/localsend/default.nix
Normal file
3
clanModules/localsend/default.nix
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
imports = [ ./roles/default.nix ];
|
||||
}
|
||||
22
clanModules/localsend/localsend-ensure-config/default.nix
Normal file
22
clanModules/localsend/localsend-ensure-config/default.nix
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
lib,
|
||||
writers,
|
||||
writeShellScriptBin,
|
||||
localsend,
|
||||
alias ? null,
|
||||
}:
|
||||
let
|
||||
localsend-ensure-config = writers.writePython3 "localsend-ensure-config" {
|
||||
flakeIgnore = [
|
||||
# We don't live in the dark ages anymore.
|
||||
# Languages like Python that are whitespace heavy will overrun
|
||||
# 79 characters..
|
||||
"E501"
|
||||
];
|
||||
} (builtins.readFile ./localsend-ensure-config.py);
|
||||
in
|
||||
writeShellScriptBin "localsend" ''
|
||||
set -xeu
|
||||
${localsend-ensure-config} ${lib.optionalString (alias != null) alias}
|
||||
${lib.getExe localsend}
|
||||
''
|
||||
@@ -0,0 +1,64 @@
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def load_json(file_path: Path) -> dict[str, any]:
|
||||
try:
|
||||
with file_path.open("r") as file:
|
||||
return json.load(file)
|
||||
except FileNotFoundError:
|
||||
return {}
|
||||
|
||||
|
||||
def save_json(file_path: Path, data: dict[str, any]) -> None:
|
||||
with file_path.open("w") as file:
|
||||
json.dump(data, file, indent=4)
|
||||
|
||||
|
||||
def update_json(file_path: Path, updates: dict[str, any]) -> None:
|
||||
data = load_json(file_path)
|
||||
data.update(updates)
|
||||
save_json(file_path, data)
|
||||
|
||||
|
||||
def config_location() -> str:
|
||||
config_file = "shared_preferences.json"
|
||||
config_directory = ".local/share/org.localsend.localsend_app"
|
||||
config_path = Path.home() / Path(config_directory) / Path(config_file)
|
||||
return config_path
|
||||
|
||||
|
||||
def ensure_config_directory() -> None:
|
||||
config_directory = Path(config_location()).parent
|
||||
config_directory.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
|
||||
def load_config() -> dict[str, any]:
|
||||
return load_json(config_location())
|
||||
|
||||
|
||||
def save_config(data: dict[str, any]) -> None:
|
||||
save_json(config_location(), data)
|
||||
|
||||
|
||||
def update_username(username: str, data: dict[str, any]) -> dict[str, any]:
|
||||
data["flutter.ls_alias"] = username
|
||||
return data
|
||||
|
||||
|
||||
def main(argv: list[str]) -> None:
|
||||
try:
|
||||
display_name = argv[1]
|
||||
except IndexError:
|
||||
# This is not an error, just don't update the name
|
||||
print("No display name provided.")
|
||||
sys.exit(0)
|
||||
|
||||
ensure_config_directory()
|
||||
updated_data = update_username(display_name, load_config())
|
||||
save_config(updated_data)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(sys.argv[:2])
|
||||
69
clanModules/localsend/roles/default.nix
Normal file
69
clanModules/localsend/roles/default.nix
Normal file
@@ -0,0 +1,69 @@
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.clan.localsend;
|
||||
in
|
||||
{
|
||||
# Integration can be improved, if the following issues get implemented:
|
||||
# - cli frontend: https://github.com/localsend/localsend/issues/11
|
||||
# - ipv6 support: https://github.com/localsend/localsend/issues/549
|
||||
options.clan.localsend = {
|
||||
|
||||
displayName = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
default = null;
|
||||
description = "The name that localsend will use to display your instance.";
|
||||
};
|
||||
|
||||
package = lib.mkPackageOption pkgs "localsend" { };
|
||||
|
||||
ipv4Addr = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
default = null;
|
||||
example = "192.168.56.2/24";
|
||||
description = "Optional IPv4 address for ZeroTier network.";
|
||||
};
|
||||
};
|
||||
|
||||
imports = [
|
||||
(lib.mkRemovedOptionModule [
|
||||
"clan"
|
||||
"localsend"
|
||||
"enable"
|
||||
] "Importing the module will already enable the service.")
|
||||
];
|
||||
config = {
|
||||
warnings = [
|
||||
"The clan.localsend module is deprecated and will be removed on 2025-07-15.
|
||||
Please migrate to user-maintained configuration or the new equivalent clan services
|
||||
(https://docs.clan.lol/reference/clanServices)."
|
||||
];
|
||||
|
||||
clan.core.state.localsend.folders = [
|
||||
"/var/localsend"
|
||||
];
|
||||
environment.systemPackages = [
|
||||
(pkgs.callPackage ./localsend-ensure-config {
|
||||
localsend = config.clan.localsend.package;
|
||||
alias = config.clan.localsend.displayName;
|
||||
})
|
||||
];
|
||||
|
||||
networking.firewall.interfaces."zt+".allowedTCPPorts = [ 53317 ];
|
||||
networking.firewall.interfaces."zt+".allowedUDPPorts = [ 53317 ];
|
||||
|
||||
#TODO: This is currently needed because there is no ipv6 multicasting support yet
|
||||
systemd.network.networks = lib.mkIf (cfg.ipv4Addr != null) {
|
||||
"09-zerotier" = {
|
||||
networkConfig = {
|
||||
Address = cfg.ipv4Addr;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user