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:
@@ -3,6 +3,7 @@
|
||||
lib,
|
||||
config,
|
||||
niveumPackages,
|
||||
inputs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.strings) makeBinPath;
|
||||
@@ -10,16 +11,12 @@
|
||||
defaultApplications = (import ../lib).defaultApplications {inherit pkgs;};
|
||||
in {
|
||||
imports = [
|
||||
../modules/system-dependent.nix
|
||||
inputs.self.nixosModules.system-dependent
|
||||
inputs.self.nixosModules.traadfri
|
||||
inputs.self.nixosModules.power-action
|
||||
{
|
||||
boot.supportedFilesystems = ["ntfs"];
|
||||
}
|
||||
{
|
||||
nix.nixPath = [
|
||||
"/var/src"
|
||||
"nixpkgs-overlays=${toString ../overlays}"
|
||||
];
|
||||
}
|
||||
{
|
||||
nixpkgs = {
|
||||
config = {
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
imports = [../modules/hledger.nix];
|
||||
|
||||
environment.systemPackages = let
|
||||
timeLedger = "$HOME/projects/ledger/time.timeclock";
|
||||
ledgerDirectory = "$HOME/projects/ledger";
|
||||
timeLedger = "${ledgerDirectory}/time.timeclock";
|
||||
git = "${pkgs.git}/bin/git -C ${ledgerDirectory}";
|
||||
in [
|
||||
(pkgs.writers.writeDashBin "hora-edit" ''
|
||||
$EDITOR + "${timeLedger}" && ${pkgs.git}/bin/git -C "$(${pkgs.coreutils}/bin/dirname ${timeLedger})" commit --all --message "$(${pkgs.coreutils}/bin/date -Im)"
|
||||
@@ -21,16 +21,18 @@
|
||||
| sed 's/(fillidefilla:\(.*\))/\1/g' \
|
||||
| xsv select date,amount,total,account,description
|
||||
'')
|
||||
];
|
||||
|
||||
niveum.hledger = {
|
||||
enable = true;
|
||||
ledgerFile = "$HOME/projects/ledger/all.journal";
|
||||
server = {
|
||||
enable = false;
|
||||
user = config.users.users.me;
|
||||
package = pkgs.hledger-web;
|
||||
};
|
||||
package = pkgs.hledger;
|
||||
};
|
||||
(pkgs.writers.writeDashBin "hledger-git" ''
|
||||
if [ "$1" = entry ]; then
|
||||
${pkgs.hledger}/bin/hledger balance -V > "${ledgerDirectory}/balance.txt"
|
||||
${git} add balance.txt
|
||||
${git} commit --all --message="$(date -Im)"
|
||||
else
|
||||
${git} $*
|
||||
fi
|
||||
'')
|
||||
(pkgs.writers.writeDashBin "hledger-edit" ''
|
||||
$EDITOR ${ledgerDirectory}/current.journal
|
||||
'')
|
||||
];
|
||||
}
|
||||
|
||||
@@ -42,8 +42,6 @@
|
||||
};
|
||||
};
|
||||
in {
|
||||
imports = [../modules/networkmanager-declarative.nix];
|
||||
|
||||
programs.nm-applet.enable = true;
|
||||
|
||||
networking.networkmanager = {
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
}: let
|
||||
suspend = pkgs.writers.writeDash "suspend" "${pkgs.systemd}/bin/systemctl suspend";
|
||||
in {
|
||||
imports = [../modules/power-action.nix];
|
||||
|
||||
services.power-action = {
|
||||
enable = true;
|
||||
plans.suspend = {
|
||||
|
||||
@@ -19,7 +19,6 @@ in {
|
||||
./nachtischsatan.nix
|
||||
./tlg-wotd.nix
|
||||
./celan.nix
|
||||
../../modules/telegram-bot.nix
|
||||
];
|
||||
|
||||
systemd.tmpfiles.rules = map (path:
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
inherit (import ../lib) localAddresses;
|
||||
living-room-id = 131090;
|
||||
in {
|
||||
imports = [../modules/traadfri.nix];
|
||||
|
||||
environment.systemPackages = [
|
||||
(pkgs.writers.writeDashBin "traadfri-party" ''
|
||||
while true; do
|
||||
|
||||
15
flake.nix
15
flake.nix
@@ -46,6 +46,17 @@
|
||||
{
|
||||
apps = nixinate.nixinate.x86_64-linux self;
|
||||
|
||||
nixosModules = {
|
||||
htgen = import modules/htgen.nix;
|
||||
moodle-dl = import modules/moodle-dl.nix;
|
||||
networkmanager-declarative = import modules/networkmanager-declarative.nix;
|
||||
passport = import modules/passport.nix;
|
||||
power-action = import modules/power-action.nix;
|
||||
system-dependent = import modules/system-dependent.nix;
|
||||
telegram-bot = import modules/telegram-bot.nix;
|
||||
traadfri = import modules/traadfri.nix;
|
||||
};
|
||||
|
||||
nixosConfigurations = {
|
||||
ful = nixpkgs.lib.nixosSystem rec {
|
||||
system = "aarch64-linux";
|
||||
@@ -85,6 +96,7 @@
|
||||
};
|
||||
}
|
||||
systems/zaatar/configuration.nix
|
||||
inputs.self.nixosModules.moodle-dl
|
||||
agenix.nixosModules.default
|
||||
retiolum.nixosModules.retiolum
|
||||
];
|
||||
@@ -107,6 +119,9 @@
|
||||
};
|
||||
}
|
||||
systems/makanek/configuration.nix
|
||||
inputs.self.nixosModules.telegram-bot
|
||||
inputs.self.nixosModules.htgen
|
||||
inputs.self.nixosModules.passport
|
||||
agenix.nixosModules.default
|
||||
retiolum.nixosModules.retiolum
|
||||
nur.nixosModules.nur
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -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";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -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];};
|
||||
}
|
||||
@@ -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];
|
||||
}
|
||||
103
modules/tuna.nix
103
modules/tuna.nix
@@ -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";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
self: super:
|
||||
with super.lib; let
|
||||
eval = import <nixpkgs/nixos/lib/eval-config.nix>;
|
||||
paths = (eval {modules = [(import <nixos-config>)];}).config.nixpkgs.overlays;
|
||||
in
|
||||
foldl' (flip extends) (_: super) paths self
|
||||
@@ -29,7 +29,6 @@ in {
|
||||
../../configs/spacetime.nix
|
||||
../../configs/sshd.nix
|
||||
../../configs/telegram-bots
|
||||
../../modules/passport.nix
|
||||
];
|
||||
|
||||
services.restic.backups.niveum = {
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
moodle-dl-package = pkgs.moodle-dl.overrideAttrs (old:
|
||||
old
|
||||
// {
|
||||
patches = [<niveum/packages/moodle-dl/telegram-format.patch>];
|
||||
});
|
||||
in {
|
||||
imports = [<niveum/modules/moodle-dl.nix>];
|
||||
|
||||
niveum.passport.services = [
|
||||
{
|
||||
title = "MoodleDL";
|
||||
description = "notifies about changes on Moodle.";
|
||||
}
|
||||
];
|
||||
|
||||
services.moodle-dl = {
|
||||
enable = true;
|
||||
startAt = "hourly";
|
||||
package = moodle-dl-package;
|
||||
notifyOnly = true;
|
||||
settings = {
|
||||
telegram = {
|
||||
token = lib.strings.fileContents <system-secrets/telegram/moodle-dl.token>;
|
||||
chat_id = "311425510";
|
||||
send_error_msg = false;
|
||||
};
|
||||
token = lib.strings.fileContents <system-secrets/moodle-dl/faye.token>;
|
||||
moodle_domain = "moodle.hu-berlin.de";
|
||||
moodle_path = "/";
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -15,8 +15,6 @@
|
||||
sha256 = "1n2m53kjg2vj9dbr70b9jrsbqwdfrcb48l4wswn21549fi24g6dx";
|
||||
};
|
||||
in {
|
||||
imports = [../../modules/htgen.nix];
|
||||
|
||||
services.htgen.tarot = {
|
||||
port = tarotPort;
|
||||
script = ''. ${pkgs.writers.writeDash "tarot" ''
|
||||
|
||||
@@ -50,8 +50,6 @@ in {
|
||||
];
|
||||
};
|
||||
|
||||
nix.nixPath = ["/var/src"];
|
||||
|
||||
services.logind = {
|
||||
lidSwitch = "ignore";
|
||||
lidSwitchDocked = "ignore";
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
patches = [../../packages/moodle-dl/telegram-format.patch];
|
||||
});
|
||||
in {
|
||||
imports = [../../modules/moodle-dl.nix];
|
||||
|
||||
age.secrets = {
|
||||
moodle-dl-tokens = {
|
||||
file = ../../secrets/zaatar-moodle-dl-tokens.json.age;
|
||||
|
||||
Reference in New Issue
Block a user