mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-26 08:53:21 +00:00
nixos/services.headphones: remove with lib;
This commit is contained in:
parent
a40bb4329a
commit
0205ba83ab
@ -1,7 +1,4 @@
|
|||||||
{ config, lib, options, pkgs, ... }:
|
{ config, lib, options, pkgs, ... }:
|
||||||
|
|
||||||
with lib;
|
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
name = "headphones";
|
name = "headphones";
|
||||||
@ -17,39 +14,39 @@ in
|
|||||||
|
|
||||||
options = {
|
options = {
|
||||||
services.headphones = {
|
services.headphones = {
|
||||||
enable = mkOption {
|
enable = lib.mkOption {
|
||||||
type = types.bool;
|
type = lib.types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
description = "Whether to enable the headphones server.";
|
description = "Whether to enable the headphones server.";
|
||||||
};
|
};
|
||||||
dataDir = mkOption {
|
dataDir = lib.mkOption {
|
||||||
type = types.path;
|
type = lib.types.path;
|
||||||
default = "/var/lib/${name}";
|
default = "/var/lib/${name}";
|
||||||
description = "Path where to store data files.";
|
description = "Path where to store data files.";
|
||||||
};
|
};
|
||||||
configFile = mkOption {
|
configFile = lib.mkOption {
|
||||||
type = types.path;
|
type = lib.types.path;
|
||||||
default = "${cfg.dataDir}/config.ini";
|
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.";
|
description = "Path to config file.";
|
||||||
};
|
};
|
||||||
host = mkOption {
|
host = lib.mkOption {
|
||||||
type = types.str;
|
type = lib.types.str;
|
||||||
default = "localhost";
|
default = "localhost";
|
||||||
description = "Host to listen on.";
|
description = "Host to listen on.";
|
||||||
};
|
};
|
||||||
port = mkOption {
|
port = lib.mkOption {
|
||||||
type = types.ints.u16;
|
type = lib.types.ints.u16;
|
||||||
default = 8181;
|
default = 8181;
|
||||||
description = "Port to bind to.";
|
description = "Port to bind to.";
|
||||||
};
|
};
|
||||||
user = mkOption {
|
user = lib.mkOption {
|
||||||
type = types.str;
|
type = lib.types.str;
|
||||||
default = name;
|
default = name;
|
||||||
description = "User to run the service as";
|
description = "User to run the service as";
|
||||||
};
|
};
|
||||||
group = mkOption {
|
group = lib.mkOption {
|
||||||
type = types.str;
|
type = lib.types.str;
|
||||||
default = name;
|
default = name;
|
||||||
description = "Group to run the service as";
|
description = "Group to run the service as";
|
||||||
};
|
};
|
||||||
@ -59,9 +56,9 @@ in
|
|||||||
|
|
||||||
###### implementation
|
###### implementation
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
|
|
||||||
users.users = optionalAttrs (cfg.user == name) {
|
users.users = lib.optionalAttrs (cfg.user == name) {
|
||||||
${name} = {
|
${name} = {
|
||||||
uid = config.ids.uids.headphones;
|
uid = config.ids.uids.headphones;
|
||||||
group = cfg.group;
|
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;
|
${name}.gid = config.ids.gids.headphones;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user