aboutsummaryrefslogtreecommitdiff
path: root/nixos/hosts
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2025-12-26 08:35:46 +0100
committerMartin Fischer <martin@push-f.com>2025-12-26 08:36:01 +0100
commit20e0a9ccf4df7f2c6c12d13ff17b515fc50d7ab5 (patch)
tree5dde26a8b0efdbc007af15c9828be5563322910c /nixos/hosts
parentfbc48c342145b566e24990e5250951cfd6f76b3b (diff)
refactor: define users in main modules
Diffstat (limited to 'nixos/hosts')
-rw-r--r--nixos/hosts/ev/default.nix24
-rw-r--r--nixos/hosts/ev/kodi.nix14
-rw-r--r--nixos/hosts/ev/qbittorrent.nix13
3 files changed, 38 insertions, 13 deletions
diff --git a/nixos/hosts/ev/default.nix b/nixos/hosts/ev/default.nix
index 1e4186f..1a50366 100644
--- a/nixos/hosts/ev/default.nix
+++ b/nixos/hosts/ev/default.nix
@@ -69,6 +69,11 @@ in
};
};
+ users.groups = {
+ kodi = {};
+ qbittorrent = {};
+ };
+
users.users = {
martin = {
isNormalUser = true;
@@ -77,6 +82,20 @@ in
"wheel"
];
};
+
+ kodi = {
+ isSystemUser = true;
+ group = "kodi";
+ home = "/home/kodi";
+ createHome = true;
+ };
+
+ qbittorrent = {
+ isSystemUser = true;
+ group = "qbittorrent";
+ home = "/var/lib/qbittorrent";
+ createHome = true;
+ };
};
# Services
@@ -95,6 +114,10 @@ in
port = ports.hosehawk;
};
+ kodi = {
+ user = "kodi";
+ };
+
miniflux = {
port = ports.miniflux;
};
@@ -105,6 +128,7 @@ in
};
qbittorrent = {
+ user = "qbittorrent";
webUiPort = ports.qbittorrent;
networkNamespace = "se";
};
diff --git a/nixos/hosts/ev/kodi.nix b/nixos/hosts/ev/kodi.nix
index 3862dfe..210ddcf 100644
--- a/nixos/hosts/ev/kodi.nix
+++ b/nixos/hosts/ev/kodi.nix
@@ -1,21 +1,27 @@
-{ config, pkgs, ... }:
+{ config, lib, pkgs, ... }:
let
+ cfg = config.kodi;
kodi-package = pkgs.kodi-wayland.withPackages (kodiPkgs: with kodiPkgs; [
joystick
]);
in
{
+ options.kodi = {
+ user = lib.mkOption {
+ type = lib.types.str;
+ };
+ };
+
config = {
- users.users.kodi = {
- isNormalUser = true;
+ users.users.${cfg.user} = {
extraGroups = ["audio"];
};
services = {
cage = {
enable = true;
- user = "kodi";
+ user = cfg.user;
program = "${kodi-package}/bin/kodi-standalone";
};
diff --git a/nixos/hosts/ev/qbittorrent.nix b/nixos/hosts/ev/qbittorrent.nix
index 697533b..a666f55 100644
--- a/nixos/hosts/ev/qbittorrent.nix
+++ b/nixos/hosts/ev/qbittorrent.nix
@@ -6,6 +6,9 @@ let
in
{
options.qbittorrent = {
+ user = lib.mkOption {
+ type = lib.types.str;
+ };
webUiPort = lib.mkOption {
type = lib.types.int;
};
@@ -17,14 +20,6 @@ in
config = {
environment.systemPackages = [pkgs.qbittorrent-nox];
- users.extraUsers.qbittorrent = {
- isSystemUser = true;
- group = "qbittorrent";
- home = "/var/lib/qbittorrent";
- createHome = true;
- };
- users.groups.qbittorrent = {};
-
systemd = {
packages = [pkgs.qbittorrent-nox];
services."qbittorrent" = helpers.joinWgNamespace cfg.networkNamespace {
@@ -32,7 +27,7 @@ in
path = [pkgs.qbittorrent-nox];
serviceConfig = {
ExecStart = "${pkgs.qbittorrent-nox}/bin/qbittorrent-nox --webui-port=${toString cfg.webUiPort}";
- User = "qbittorrent";
+ User = cfg.user;
};
wantedBy = ["multi-user.target"];
};