nixos/services.headphones: remove with lib;

This commit is contained in:
Felix Buehler 2024-08-24 22:05:45 +02:00
parent a40bb4329a
commit 0205ba83ab

View File

@ -1,7 +1,4 @@
{ config, lib, options, pkgs, ... }:
with lib;
let
name = "headphones";
@ -17,39 +14,39 @@ in
options = {
services.headphones = {
enable = mkOption {
type = types.bool;
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Whether to enable the headphones server.";
};
dataDir = mkOption {
type = types.path;
dataDir = lib.mkOption {
type = lib.types.path;
default = "/var/lib/${name}";
description = "Path where to store data files.";
};
configFile = mkOption {
type = types.path;
configFile = lib.mkOption {
type = lib.types.path;
default = "${cfg.dataDir}/config.ini";
defaultText = literalExpression ''"''${config.${opt.dataDir}}/config.ini"'';
defaultText = lib.literalExpression ''"''${config.${opt.dataDir}}/config.ini"'';
description = "Path to config file.";
};
host = mkOption {
type = types.str;
host = lib.mkOption {
type = lib.types.str;
default = "localhost";
description = "Host to listen on.";
};
port = mkOption {
type = types.ints.u16;
port = lib.mkOption {
type = lib.types.ints.u16;
default = 8181;
description = "Port to bind to.";
};
user = mkOption {
type = types.str;
user = lib.mkOption {
type = lib.types.str;
default = name;
description = "User to run the service as";
};
group = mkOption {
type = types.str;
group = lib.mkOption {
type = lib.types.str;
default = name;
description = "Group to run the service as";
};
@ -59,9 +56,9 @@ in
###### implementation
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
users.users = optionalAttrs (cfg.user == name) {
users.users = lib.optionalAttrs (cfg.user == name) {
${name} = {
uid = config.ids.uids.headphones;
group = cfg.group;
@ -71,7 +68,7 @@ in
};
};
users.groups = optionalAttrs (cfg.group == name) {
users.groups = lib.optionalAttrs (cfg.group == name) {
${name}.gid = config.ids.gids.headphones;
};