1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 10:11:08 +01:00

feat: move ./modules to flake outputs

This commit is contained in:
2023-02-24 23:41:01 +01:00
parent c9af430f31
commit b1743f031c
18 changed files with 35 additions and 379 deletions

View File

@@ -1,34 +0,0 @@
{
pkgs,
lib,
config,
...
}:
with lib; let
cfg = config.niveum.dropbox;
in {
options.niveum.dropbox = {enable = mkEnableOption "Dropbox";};
config = mkIf cfg.enable {
environment.systemPackages = [pkgs.dropbox-cli];
networking.firewall = {
allowedTCPPorts = [17500];
allowedUDPPorts = [17500];
};
systemd.user.services.dropbox = {
description = "Dropbox synchronisation service";
wantedBy = ["graphical-session.target"];
serviceConfig = {
ExecStart = "${pkgs.dropbox.out}/bin/dropbox";
ExecReload = "${pkgs.coreutils.out}/bin/kill -HUP $MAINPID";
KillMode = "control-group"; # upstream recommends process
Restart = "on-failure";
PrivateTmp = true;
ProtectSystem = "full";
Nice = 10;
};
};
};
}

View File

@@ -1,86 +0,0 @@
{
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.niveum.hledger;
hledger-git = pkgs.writers.writeDashBin "hledger-git" ''
LEDGER_DIR="$(dirname $LEDGER_FILE)"
GIT="${pkgs.git}/bin/git -C ''${LEDGER_DIR}"
if [ "$1" = entry ]; then
${cfg.package}/bin/hledger balance -V > "$LEDGER_DIR/balance.txt"
$GIT add balance.txt
$GIT commit --all --message="$(date -Im)"
else
$GIT $*
fi
'';
hledger-edit = pkgs.writers.writeDashBin "hledger-edit" ''
LEDGER_DIR="$(dirname $LEDGER_FILE)"
$EDITOR ''${LEDGER_DIR}/current.journal
'';
in {
options.niveum.hledger = {
enable = mkEnableOption "hledger";
package = mkOption {
type = types.package;
default = pkgs.hledger;
};
ledgerFile = mkOption {
type = types.str;
default = null;
};
server = {
enable = mkEnableOption "hledger server";
port = mkOption {
type = types.port;
default = 5000;
};
host = mkOption {
type = types.str;
default = "127.0.0.1";
};
capabilities = mkOption {
type = types.listOf (types.enum ["view" "add" "manage"]);
default = ["view" "add"];
};
flags = mkOption {
type = types.listOf types.str;
default = [];
};
user = mkOption {type = types.attrs;};
package = mkOption {
type = types.package;
default = pkgs.hledger-web;
};
};
};
config = mkIf cfg.enable {
environment.systemPackages = [cfg.package hledger-git hledger-edit];
environment.variables.LEDGER_FILE =
mkIf (cfg.ledgerFile != null) cfg.ledgerFile;
systemd.services.hledger-web = mkIf cfg.server.enable {
description = "hledger server";
wantedBy = ["multi-user.target"];
serviceConfig = {
Restart = "always";
ExecStart = ''
${cfg.server.package}/bin/hledger-web \
--port=${toString cfg.server.port} \
--host=${cfg.server.host} \
--capabilities=${concatStringsSep "," cfg.server.capabilities} \
${concatStringsSep " " cfg.server.flags}
'';
User = cfg.server.user.name;
PrivateTemp = true;
RuntimeDirectory = "hledger-web";
WorkingDirectory = "%t/hledger-web";
};
};
};
}

View File

@@ -1,13 +0,0 @@
{
pkgs,
lib,
config,
...
}:
with lib; let
cfg = config.niveum.minecraft;
in {
options.niveum.minecraft = {enable = mkEnableOption "Minecraft";};
config = mkIf cfg.enable {environment.systemPackages = [pkgs.minecraft];};
}

View File

@@ -1,64 +0,0 @@
{
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.services.spotifyd;
toml = pkgs.formats.toml {};
spotifydConf =
if cfg.settings != {}
then toml.generate "spotify.conf" cfg.settings
else pkgs.writeText "spotifyd.conf" cfg.config;
in {
options = {
services.spotifyd = {
enable = mkEnableOption "spotifyd, a Spotify playing daemon";
config = mkOption {
default = "";
type = types.lines;
description = ''
(Deprecated) Configuration for Spotifyd. For syntax and directives, see
<link xlink:href="https://github.com/Spotifyd/spotifyd#Configuration"/>.
'';
};
settings = mkOption {
default = {};
type = toml.type;
description = ''
Configuration for Spotifyd. For syntax and directives, see
<link xlink:href="https://github.com/Spotifyd/spotifyd#Configuration"/>.
'';
};
};
};
config = mkIf cfg.enable {
assertions = [
{
assertion = (cfg.config == "" && cfg.settings != {}) || (cfg.config != "" && cfg.settings == {});
message = "Using the stringly typed .config attribute is discouraged. Use the TOML typed .settings attribute instead.";
}
];
systemd.services.spotifyd = {
wantedBy = ["multi-user.target"];
after = ["network-online.target" "sound.target"];
description = "spotifyd, a Spotify playing daemon";
environment.SHELL = "/bin/sh";
serviceConfig = {
ExecStart = "${pkgs.spotifyd}/bin/spotifyd --no-daemon --cache-path /var/cache/spotifyd --config-path ${spotifydConf}";
Restart = "always";
RestartSec = 12;
DynamicUser = true;
CacheDirectory = "spotifyd";
SupplementaryGroups = ["audio"];
};
};
};
meta.maintainers = [maintainers.anderslundstedt];
}

View File

@@ -1,103 +0,0 @@
{
config,
lib,
pkgs,
...
}:
with lib; let
tuna = pkgs.callPackage <tuna> {};
cfg = config.services.tuna;
in {
imports = [];
options.services.tuna = {
enable = mkEnableOption "Tuna, an MPD web UI for radio streams";
webPort = mkOption {
type = types.port;
default = 4200;
};
stations = mkOption {
default = [];
type = types.listOf (types.submodule {
options = {
id = mkOption {
type = types.int;
description = "A unique identifier of the station";
};
station = mkOption {
type = types.str;
description = "Name of the station that should be displayed";
};
desc = mkOption {
type = types.nullOr types.str;
description = "Short description of the station (optional)";
};
logo = mkOption {
type = types.str;
description = "URL to a logo of the station (any size)";
};
stream = mkOption {
type = types.str;
description = "URL to the stream of the radio station (in a format supported by MPD such as MP3, OGG, ...)";
};
};
});
};
stationsFile = mkOption {
type = types.path;
default = (pkgs.formats.json {}).generate "stations.json" cfg.stations;
};
package = mkOption {
type = types.package;
default = tuna;
};
mpd = {
host = mkOption {
type = types.str;
default = "localhost";
description = "The host where MPD is listening.";
example = "localhost";
};
port = mkOption {
type = types.port;
default = config.services.mpd.network.port;
description = "The port where MPD is listening.";
example = 6600;
};
};
};
config = mkIf cfg.enable {
users.users.tuna = {
isSystemUser = true;
group = "tuna";
};
users.groups.tuna = {};
# ref https://github.com/florianheinemann/MPD.FM/blob/9d037cf87597b26ae2f10ba9feea48946ad6cc68/service/MPD.FM.service
systemd.services.tuna = {
wantedBy = ["multi-user.target"];
after = ["mpd.service"];
script = "${cfg.package}/bin/tuna";
environment = {
NODE_ENV = "production";
MPD_HOST = cfg.mpd.host;
MPD_PORT = toString cfg.mpd.port;
PORT = toString cfg.webPort;
STATION_FILE = cfg.stationsFile;
};
serviceConfig = {
Restart = "always";
StandardOutput = "syslog";
StandardError = "syslog";
SyslogIdentifier = "tuna";
User = "tuna";
};
};
};
}