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

chore: format with alejandra

This commit is contained in:
2022-03-10 21:52:12 +01:00
parent 13727abfd6
commit d37e90cb97
159 changed files with 4239 additions and 3405 deletions

View File

@@ -1,20 +1,25 @@
{ pkgs, lib, config, ... }:
with lib;
let cfg = config.niveum.dropbox;
{
pkgs,
lib,
config,
...
}:
with lib; let
cfg = config.niveum.dropbox;
in {
options.niveum.dropbox = { enable = mkEnableOption "Dropbox"; };
options.niveum.dropbox = {enable = mkEnableOption "Dropbox";};
config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.dropbox-cli ];
environment.systemPackages = [pkgs.dropbox-cli];
networking.firewall = {
allowedTCPPorts = [ 17500 ];
allowedUDPPorts = [ 17500 ];
allowedTCPPorts = [17500];
allowedUDPPorts = [17500];
};
systemd.user.services.dropbox = {
description = "Dropbox synchronisation service";
wantedBy = [ "graphical-session.target" ];
wantedBy = ["graphical-session.target"];
serviceConfig = {
ExecStart = "${pkgs.dropbox.out}/bin/dropbox";
ExecReload = "${pkgs.coreutils.out}/bin/kill -HUP $MAINPID";

View File

@@ -1,6 +1,10 @@
{ config, lib, pkgs, ... }:
with lib;
let
{
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.niveum.hledger;
hledger-git = pkgs.writers.writeDashBin "hledger-git" ''
LEDGER_DIR="$(dirname $LEDGER_FILE)"
@@ -39,14 +43,14 @@ in {
default = "127.0.0.1";
};
capabilities = mkOption {
type = types.listOf (types.enum [ "view" "add" "manage" ]);
default = [ "view" "add" ];
type = types.listOf (types.enum ["view" "add" "manage"]);
default = ["view" "add"];
};
flags = mkOption {
type = types.listOf types.str;
default = [ ];
default = [];
};
user = mkOption { type = types.attrs; };
user = mkOption {type = types.attrs;};
package = mkOption {
type = types.package;
default = pkgs.hledger-web;
@@ -55,22 +59,22 @@ in {
};
config = mkIf cfg.enable {
environment.systemPackages = [ cfg.package hledger-git hledger-edit ];
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" ];
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}
--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;

View File

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

View File

@@ -1,6 +1,10 @@
{ config, lib, pkgs, ... }:
with lib;
let
{
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.services.moodle-dl;
json = pkgs.formats.json {};
moodle-dl-json = json.generate "moodle-dl.json" cfg.settings;
@@ -52,7 +56,6 @@ in {
};
config = mkIf cfg.enable {
users.users.moodle-dl = {
isSystemUser = true;
home = cfg.directory;
@@ -63,7 +66,7 @@ in {
systemd.services.moodle-dl = {
description = "A Moodle downloader that downloads course content";
wants = [ "network-online.target" ];
wants = ["network-online.target"];
serviceConfig = mkMerge [
{
Type = "oneshot";
@@ -73,11 +76,11 @@ in {
ExecStart = "${cfg.package}/bin/moodle-dl ${lib.optionalString cfg.notifyOnly "--without-downloading-files"}";
ExecStartPre = "${pkgs.coreutils}/bin/ln -sfn ${toString moodle-dl-json} ${cfg.directory}/config.json";
}
(mkIf (cfg.directory == stateDirectoryDefault) { StateDirectory = "moodle-dl"; })
(mkIf (cfg.directory == stateDirectoryDefault) {StateDirectory = "moodle-dl";})
];
inherit (cfg) startAt;
};
};
meta.maintainers = [ maintainers.kmein ];
meta.maintainers = [maintainers.kmein];
}

View File

@@ -1,50 +1,69 @@
# https://github.com/jmackie/nixos-networkmanager-profiles/
{ lib, config, ... }:
with lib;
let
{
lib,
config,
...
}:
with lib; let
nm = config.networking.networkmanager;
mkProfile = profileAttrs:
if !(isAttrs profileAttrs) then
throw "error 1"
if !(isAttrs profileAttrs)
then throw "error 1"
else {
enable = true;
mode = "0400"; # readonly (user)
text = (foldlAttrs (accum:
{ name, value }: ''
text =
(foldlAttrs (accum: {
name,
value,
}: ''
${accum}
[${name}] ${mkProfileEntry value}'')
"# Generated by nixos-networkmanager-profiles" profileAttrs) + "\n";
"# Generated by nixos-networkmanager-profiles"
profileAttrs)
+ "\n";
};
mkProfileEntry = entryAttrs:
if !(isAttrs entryAttrs) then
throw "error 2"
if !(isAttrs entryAttrs)
then throw "error 2"
else
foldlAttrs (accum:
{ name, value }: ''
${accum}
${name}=${toString value}'') "" entryAttrs;
foldlAttrs (accum: {
name,
value,
}: ''
${accum}
${name}=${toString value}'') ""
entryAttrs;
foldlAttrs = op: nul: attrs:
foldl (accum: { fst, snd }: op accum (nameValuePair fst snd)) nul
foldl (accum: {
fst,
snd,
}:
op accum (nameValuePair fst snd))
nul
(lists.zipLists (attrNames attrs) (attrValues attrs));
attrLength = attrs: length (attrValues attrs);
in {
options.networking.networkmanager.profiles = mkOption {
type = types.attrs;
default = { };
default = {};
};
config = mkIf (attrLength nm.profiles > 0) {
environment.etc = (foldlAttrs (accum:
{ name, value }:
accum // {
environment.etc = foldlAttrs (accum: {
name,
value,
}:
accum
// {
"NetworkManager/system-connections/${name}.nmconnection" =
mkProfile value;
}) { } nm.profiles);
}) {}
nm.profiles;
};
}

View File

@@ -1,6 +1,10 @@
{ config, pkgs, lib, ... }:
with lib;
let
{
config,
pkgs,
lib,
...
}:
with lib; let
netname = "retiolum";
cfg = config.networking.retiolum;
in {
@@ -27,12 +31,11 @@ in {
};
config = {
services.tinc.networks.${netname} = {
name = cfg.nodename;
hosts = builtins.mapAttrs
(name: _: builtins.readFile "${<retiolum/hosts>}/${name}")
(builtins.readDir <retiolum/hosts>);
(name: _: builtins.readFile "${<retiolum/hosts>}/${name}")
(builtins.readDir <retiolum/hosts>);
rsaPrivateKeyFile = toString <system-secrets/retiolum.key>;
ed25519PrivateKeyFile = toString <system-secrets/retiolum.ed25519>;
extraConfig = ''
@@ -43,11 +46,11 @@ in {
networking.extraHosts = builtins.readFile (toString <retiolum/etc.hosts>);
environment.systemPackages = [ config.services.tinc.networks.${netname}.package ];
environment.systemPackages = [config.services.tinc.networks.${netname}.package];
networking.firewall = {
allowedTCPPorts = [ 655 ];
allowedUDPPorts = [ 655 ];
allowedTCPPorts = [655];
allowedUDPPorts = [655];
};
#services.netdata.portcheck.checks.tinc.port = 655;

View File

@@ -1,13 +1,17 @@
{ config, lib, pkgs, ... }:
with lib;
let
{
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
{
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";
@@ -41,8 +45,8 @@ in
];
systemd.services.spotifyd = {
wantedBy = [ "multi-user.target" ];
after = [ "network-online.target" "sound.target" ];
wantedBy = ["multi-user.target"];
after = ["network-online.target" "sound.target"];
description = "spotifyd, a Spotify playing daemon";
environment.SHELL = "/bin/sh";
serviceConfig = {
@@ -56,5 +60,5 @@ in
};
};
meta.maintainers = [ maintainers.anderslundstedt ];
meta.maintainers = [maintainers.anderslundstedt];
}

View File

@@ -1,10 +1,14 @@
{ config, lib, pkgs, ... }:
with lib;
{
config,
lib,
pkgs,
...
}:
with lib; {
options.niveum = {
wirelessInterface = mkOption { type = types.str; };
wirelessInterface = mkOption {type = types.str;};
batteryName = mkOption { type = types.str; };
batteryName = mkOption {type = types.str;};
promptColours = let
colours16 = types.enum [

View File

@@ -1,6 +1,10 @@
{ lib, config, pkgs, ... }:
with lib;
let
{
lib,
config,
pkgs,
...
}:
with lib; let
cfg = config.niveum.telegramBots;
botService = name: bot:
@@ -8,37 +12,38 @@ let
enable = bot.enable;
startAt = bot.time;
serviceConfig.Type = "oneshot";
wants = [ "network-online.target" ];
script = strings.concatStringsSep "\n" ([ "QUOTE=$(${bot.command})" "if [ -n \"$QUOTE\" ]; then" ]
++ map (chatId: ''
${pkgs.curl}/bin/curl -s -X POST "https://api.telegram.org/bot${bot.token}/sendMessage" \
-d chat_id="${chatId}" \
-d text="$QUOTE" ${
lib.strings.optionalString (bot.parseMode != null)
"-d parse_mode=${bot.parseMode}"
}
'') bot.chatIds
++ [ "fi" ]);
wants = ["network-online.target"];
script = strings.concatStringsSep "\n" (["QUOTE=$(${bot.command})" "if [ -n \"$QUOTE\" ]; then"]
++ map (chatId: ''
${pkgs.curl}/bin/curl -s -X POST "https://api.telegram.org/bot${bot.token}/sendMessage" \
-d chat_id="${chatId}" \
-d text="$QUOTE" ${
lib.strings.optionalString (bot.parseMode != null)
"-d parse_mode=${bot.parseMode}"
}
'')
bot.chatIds
++ ["fi"]);
};
in {
options.niveum.telegramBots = mkOption {
type = types.attrsOf (types.submodule {
options = {
enable = mkEnableOption "Telegram bot";
time = mkOption { type = types.str; };
token = mkOption { type = types.strMatching "[0-9A-Za-z:-]+"; };
time = mkOption {type = types.str;};
token = mkOption {type = types.strMatching "[0-9A-Za-z:-]+";};
chatIds = mkOption {
type = types.listOf (types.strMatching "-?[0-9]+|@[A-Za-z0-9]+");
};
command = mkOption { type = types.str; };
command = mkOption {type = types.str;};
parseMode = mkOption {
type = types.nullOr (types.enum [ "HTML" "Markdown" ]);
type = types.nullOr (types.enum ["HTML" "Markdown"]);
default = null;
};
};
});
default = { };
default = {};
};
config = { systemd.services = attrsets.mapAttrs' botService cfg; };
config = {systemd.services = attrsets.mapAttrs' botService cfg;};
}

View File

@@ -1,39 +1,49 @@
{ pkgs, lib, config, ... }:
with lib;
let
{
pkgs,
lib,
config,
...
}:
with lib; let
cfg = config.niveum.traadfri;
traadfri = pkgs.callPackage <traadfri> {
libcoap = pkgs.callPackage <niveum/packages/libcoap.nix> { tls = true; };
libcoap = pkgs.callPackage <niveum/packages/libcoap.nix> {tls = true;};
};
in {
options.niveum.traadfri = {
enable = mkEnableOption "Trådfri CLI";
user = mkOption { type = types.str; };
host = mkOption { type = types.str; };
key = mkOption { type = types.str; };
user = mkOption {type = types.str;};
host = mkOption {type = types.str;};
key = mkOption {type = types.str;};
rooms = mkOption {
type = types.attrsOf types.int;
default = { };
default = {};
};
bulbs = mkOption {
type = types.attrsOf types.int;
default = { };
default = {};
};
};
config = mkIf cfg.enable {
environment.systemPackages = [
(pkgs.writers.writeDashBin "traadfri" ''
TRAADFRI_USER="${cfg.user}" \
TRAADFRI_KEY="${cfg.key}" \
TRAADFRI_HUB="${cfg.host}" \
${traadfri}/bin/traadfri $@
'')
] ++ lib.mapAttrsToList (name: value: pkgs.writers.writeDashBin "traadfri-${name}" ''
exec traadfri --target Room ${toString value} "$@"
'') cfg.rooms
++ lib.mapAttrsToList (name: value: pkgs.writers.writeDashBin "traadfri-${name}" ''
exec traadfri --target Bulb ${toString value} "$@"
'') cfg.bulbs;
environment.systemPackages =
[
(pkgs.writers.writeDashBin "traadfri" ''
TRAADFRI_USER="${cfg.user}" \
TRAADFRI_KEY="${cfg.key}" \
TRAADFRI_HUB="${cfg.host}" \
${traadfri}/bin/traadfri $@
'')
]
++ lib.mapAttrsToList (name: value:
pkgs.writers.writeDashBin "traadfri-${name}" ''
exec traadfri --target Room ${toString value} "$@"
'')
cfg.rooms
++ lib.mapAttrsToList (name: value:
pkgs.writers.writeDashBin "traadfri-${name}" ''
exec traadfri --target Bulb ${toString value} "$@"
'')
cfg.bulbs;
};
}

View File

@@ -1,6 +1,10 @@
{ config, lib, pkgs, ... }:
with lib;
let
{
config,
lib,
pkgs,
...
}:
with lib; let
tuna = pkgs.callPackage <tuna> {};
cfg = config.services.tuna;
in {
@@ -77,8 +81,8 @@ in {
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" ];
wantedBy = ["multi-user.target"];
after = ["mpd.service"];
script = "${cfg.package}/bin/tuna";
environment = {
NODE_ENV = "production";