Add helper functions for multi-user toggle support
Introduced a new file `lib.nix` containing helper functions to streamline user package management and attributes for multi-user configurations. Updated various modules to utilize these functions, enhancing code maintainability and readability.
This commit is contained in:
@@ -16,32 +16,26 @@ in
|
||||
{
|
||||
options.my.services.syncthing.enable = lib.mkEnableOption "Syncthing file synchronization";
|
||||
config = lib.mkIf (config.my.services.syncthing.enable && config.my.secureHost) {
|
||||
sops.secrets = let
|
||||
# Syncthing runs as a single user service, so use the first user if a list is provided
|
||||
user = if lib.isString config.my.toggleUsers.services then config.my.toggleUsers.services else (lib.head config.my.toggleUsers.services);
|
||||
in {
|
||||
sops.secrets = {
|
||||
"syncthing_keys/${hostName}" = {
|
||||
sopsFile = ../../secrets/keys.yaml;
|
||||
owner = config.users.users.${user}.name;
|
||||
inherit (config.users.users.${user}) group;
|
||||
path = "/home/${user}/.config/syncthing/key.pem";
|
||||
owner = config.users.users.jawz.name;
|
||||
inherit (config.users.users.jawz) group;
|
||||
path = "/home/jawz/.config/syncthing/key.pem";
|
||||
};
|
||||
"syncthing_certs/${hostName}" = {
|
||||
sopsFile = ../../secrets/keys.yaml;
|
||||
owner = config.users.users.${user}.name;
|
||||
inherit (config.users.users.${user}) group;
|
||||
path = "/home/${user}/.config/syncthing/cert.pem";
|
||||
owner = config.users.users.jawz.name;
|
||||
inherit (config.users.users.jawz) group;
|
||||
path = "/home/jawz/.config/syncthing/cert.pem";
|
||||
};
|
||||
"syncthing_password" = {
|
||||
sopsFile = ../../secrets/keys.yaml;
|
||||
};
|
||||
};
|
||||
services.syncthing = let
|
||||
# Syncthing runs as a single user service, so use the first user if a list is provided
|
||||
user = if lib.isString config.my.toggleUsers.services then config.my.toggleUsers.services else (lib.head config.my.toggleUsers.services);
|
||||
in {
|
||||
services.syncthing = {
|
||||
enable = true;
|
||||
user = user;
|
||||
user = "jawz";
|
||||
group = "users";
|
||||
overrideDevices = true;
|
||||
overrideFolders = true;
|
||||
@@ -56,7 +50,7 @@ in
|
||||
globalAnnounceEnabled = false;
|
||||
};
|
||||
gui = {
|
||||
user = if lib.isString config.my.toggleUsers.services then config.my.toggleUsers.services else (lib.head config.my.toggleUsers.services);
|
||||
user = "jawz";
|
||||
password = config.sops.secrets.syncthing_password.path;
|
||||
};
|
||||
devices = {
|
||||
|
||||
Reference in New Issue
Block a user