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

mopidy, mail, telegram

This commit is contained in:
Kierán Meinhardt
2019-04-20 09:08:39 +02:00
parent 7d6dbc2809
commit 8e55e595c4
15 changed files with 232 additions and 125 deletions

View File

@@ -9,4 +9,8 @@
};
environment.systemPackages = [ pkgs.blueman ];
home-manager.users.me = {
services.blueman-applet.enable = true;
};
}

View File

@@ -7,6 +7,7 @@
"hdokiejnpimakedhajhdlcegeplioahd" # LastPass
"jldhpllghnbhlbpcmnajkpdmadaolakh" # Todoist
"dbepggeogbaibhgnhhndojpepiihcmeb" # Vimium
"fpnmgdkabkmnadcjpehmlllkndpkmiak" # Wayback Machine
];
};

View File

@@ -18,6 +18,8 @@
<configs/vscode.nix>
<configs/htop.nix>
<configs/dunst.nix>
# <configs/mopidy.nix>
<configs/mail.nix>
<configs/python.nix>
<configs/haskell.nix>
<configs/hu-berlin.nix>
@@ -77,7 +79,6 @@
nix-git = pkgs.callPackage <packages/nix-git.nix> {};
sncli = pkgs.python3Packages.callPackage <packages/sncli.nix> {};
spotify-cli-linux = pkgs.python3Packages.callPackage <packages/spotify-cli-linux.nix> {};
todoist = pkgs.unstable.callPackage <packages/todoist.nix> {};
wttr = pkgs.callPackage <packages/wttr.nix> {};
n = pkgs.callPackage <packages/n.nix> {};
@@ -317,6 +318,7 @@
qrencode
tmuxp
unstable.zola
unstable.hugo
wordnet
xsv
wttr

View File

@@ -1,4 +1,6 @@
{ pkgs, ... }:
{
virtualisation.docker.enable = true;
users.users.me.extraGroups = [ "docker" ];
environment.systemPackages = [ pkgs.docker pkgs.docker_compose ];
}

View File

@@ -25,11 +25,11 @@
stack2nix
cabal-install
hlint
haskellPackages.brittany
(haskellPackages.ghcWithHoogle (import <dot/haskells.nix>))
] ++ map haskell.lib.justStaticExecutables [
haskellPackages.ghcid
haskellPackages.hakyll
haskellPackages.brittany
haskellPackages.hfmt
haskellPackages.hasktags
haskellPackages.hindent

View File

@@ -7,7 +7,6 @@
server = {
enable = true;
user = config.users.users.me;
capabilities = [ "view" ];
};
};
}

View File

@@ -13,6 +13,11 @@ in with config.niveum; {
windowManager.i3.enable = true;
};
sound.mediaKeys = {
enable = true;
volumeStep = "5%";
};
home-manager.users.me.xsession.windowManager.i3 = {
enable = true;
config = rec {
@@ -157,9 +162,6 @@ in with config.niveum; {
"${modifier}+w" = "layout tabbed";
"${modifier}+x" = "exec --no-startup-id ${new-workspace}";
"${modifier}+y" = "exec ${applications.browser}";
"XF86AudioLowerVolume" = "exec --no-startup-id ${pkgs.pamixer}/bin/pamixer -d 5";
"XF86AudioMute" = "exec --no-startup-id ${pkgs.pamixer}/bin/pamixer -t";
"XF86AudioRaiseVolume" = "exec --no-startup-id ${pkgs.pamixer}/bin/pamixer -i 5";
};
};
};

39
configs/mail.nix Normal file
View File

@@ -0,0 +1,39 @@
{ config, pkgs, ... }:
{
environment.systemPackages = [
pkgs.notmuch
pkgs.offlineimap
pkgs.msmtp
pkgs.neomutt
];
home-manager.users.me = {
accounts.email.maildirBasePath = "${config.users.users.me.home}/mail";
accounts.email.accounts.hu-berlin = {
address = "meinhark@hu-berlin.de";
userName = "meinhark";
realName = config.niveum.user.fullName;
imap = {
host = "mailbox.cms.hu-berlin.de";
port = 993;
tls.enable = true;
};
smtp = {
host = "mailhost.cms.hu-berlin.de";
port = 25;
tls.enable = true;
};
msmtp.enable = true;
notmuch.enable = true;
offlineimap = {
enable = true;
postSyncHookCommand = "notmuch new";
};
primary = true;
};
programs.offlineimap = {
enable = true;
};
};
}

28
configs/mopidy.nix Normal file
View File

@@ -0,0 +1,28 @@
{ pkgs, ... }:
let secrets = import <dot/secrets.nix>;
in {
services.mopidy = {
enable = true;
extensionPackages = [
pkgs.mopidy-spotify
pkgs.mopidy-iris
pkgs.mopidy-gmusic
pkgs.mopidy-moped
pkgs.mopidy-soundcloud
pkgs.mopidy-youtube
];
configuration = ''
[mpd]
hostname = ::
[spotify]
username = ${secrets.spotify.username}
password = ${secrets.spotify.password}
client_id = ${secrets.spotify.clientId}
client_secret = ${secrets.spotify.clientSecret}
[soundcloud]
auth_token = ${secrets.soundcloud.authToken}
'';
};
}

View File

@@ -6,6 +6,8 @@
py.black
py.python-language-server
py.pyls-mypy
py.pyls-black
py.pyls-isort
py.flake8
])
)

View File

@@ -1,9 +1,11 @@
{ pkgs, ... }:
let secrets = import <dot/secrets.nix>;
let
secrets = import <dot/secrets.nix>;
todoist = pkgs.unstable.callPackage <packages/todoist.nix> {};
in {
environment.systemPackages = [
(pkgs.unstable.writers.writeDashBin "todoist" ''
${pkgs.todoist}/bin/todoist --color $@
${todoist}/bin/todoist --color $@
'')
];

View File

@@ -10,11 +10,24 @@ let
pkgs = import "${krops}/pkgs" {};
importJson = (import <nixpkgs> {}).lib.importJSON;
source = {path, other ? {}}: lib.evalSource [({
niveum = path: {
nixpkgs.git = {
url = https://github.com/NixOS/nixpkgs-channels;
ref = (importJson ./nixpkgs.json).rev;
};
system.file = toString path;
lib.file = toString ./lib;
packages.file = toString ./packages;
configs.file = toString ./configs;
dot.file = toString ./dot;
modules.file = toString ./modules;
nixos-config.symlink = "system/configuration.nix";
};
minimal = path: other: lib.evalSource [(niveum path // other)];
regular = path: minimal path (niveum path // {
nixos-unstable.git = {
url = https://github.com/NixOS/nixpkgs-channels;
ref = "nixos-unstable";
@@ -27,41 +40,23 @@ let
url = https://cgit.krebsco.de/stockholm;
ref = "7e1b197dab13d024ba491c96dc959306324943c0";
};
system.file = toString path;
lib.file = toString ./lib;
packages.file = toString ./packages;
systems.file = toString ./systems;
configs.file = toString ./configs;
dot.file = toString ./dot;
modules.file = toString ./modules;
nixos-config.symlink = "system/configuration.nix";
} // other)];
});
systems.scardanelli = pkgs.krops.writeDeploy "deploy-scardanelli" {
source = source {
path = ./systems/scardanelli;
other.art.file = ./art;
};
source = regular ./systems/scardanelli;
target = scardanelli-ssh;
};
systems.homeros = pkgs.krops.writeDeploy "deploy-homeros" {
source = source {
path = ./systems/homeros;
other.art.file = ./art;
};
source = regular ./systems/homeros;
target = homeros-ssh;
};
systems.catullus = pkgs.krops.writeDeploy "deploy-catullus" {
source = source {
path = ./systems/catullus;
other = {
secrets.pass = {
dir = toString ~/.password-store;
name = "catullus";
};
source = minimal ./systems/catullus {
secrets.pass = {
dir = toString ~/.password-store;
name = "catullus";
};
};
target = catullus-ssh;

41
modules/telegram-bot.nix Normal file
View File

@@ -0,0 +1,41 @@
{ lib, config, pkgs, ... }:
with lib;
let
cfg = config.niveum.telegramBots;
botService = name: bot: nameValuePair "telegram-bot-${name}" {
enable = bot.enable;
startAt = bot.time;
serviceConfig.Type = "oneshot";
wantedBy = [ "network-online.target" ];
script = ''
${pkgs.curl}/bin/curl -s -X POST "https://api.telegram.org/bot${bot.token}/sendMessage" \
-d chat_id="${bot.chatId}" \
-d text="$(${bot.command})" ${
if bot.parseMode == null then ""
else "-d parse_mode=${bot.parseMode}"
}
'';
};
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:-]+"; };
chatId = mkOption { type = types.strMatching "[0-9]+|@[A-Za-z0-9]+"; };
command = mkOption { type = types.str; };
parseMode = mkOption {
type = types.nullOr (types.enum ["HTML" "Markdown"]);
default = null;
};
};
});
default = {};
};
config = {
systemd.services = attrsets.mapAttrs' botService cfg;
};
}

View File

@@ -1,4 +1,4 @@
{ config, pkgs, ... }:
{ config, pkgs, lib, ... }:
let
sshKey = {
homeros = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDn13Y6CznabMvKJPIrr/dj1TX4boe8F98yc3FDElJeprQo2RXlDzjg/po9/lHTHaoC5yQUjlRg/AnI4vizYkn2sqJebAeSPahmpS+l0eFnjZgsqds2cCFqSPB6Qc5YEkGRhN4aq/ABz0jdFJLBYOYGxuuXowYxyNrqrItxDR7tF7upG+kVjYiDoP/qFm8C7zv6Zy8aoehNbzf8HlIJd0ITbMr/vUftNsQ8C84QmbZljReHmchPgE8GUfVLTlCORkhndbvNX3jXo+75y7JOIZZ6193FZHM4seg/VSDWYLJtpnhttD1w6qmiLrlimqbJB9ihoXq2eDmQ+4zo6hxQ6pFH6P0xQClJ0hxVWn6hEM3rkMwoMfbq4v54gKJsYxcGdnwjAX6d9DQv/QVjmVZffKWsGGoC7uz7bdmc0akVKi+GLSPOx8sJwXqvyvFStfqLaweVcuikUqQ72JLK7pZyliA7na6KuQ1PE3LTpfSr0lbBJ73xtS2rU1nF/Oe5zwA4LX5s/QeDVmS86D8acUrSCO62pBB3Yv8go0KR4mEvfxLiUWV6gR2uTeIPXvo4ouYFZqyABAGybjUATlGCXJaeHd/y/VWkpIB8ocqNESlRMCEe4TrYjw91AEmYBL6kWIeop3dyhovm3dTB3fQvC97kbL16wuXBrOcN4lEc+56ShhmvdQ== kieran.meinhardt@gmail.com";
@@ -9,8 +9,37 @@ in {
<system/hardware-configuration.nix>
<system/containers.nix>
<modules/retiolum.nix>
<modules/telegram-bot.nix>
{
sound.enable = true;
sound.extraConfig = ''
defaults.ctl.card 1
defaults.pcm.card 1
'';
hardware.pulseaudio = {
enable = true;
systemWide = true;
package = pkgs.pulseaudioFull;
};
users.users.root.extraGroups = [ "audio" ];
}
{
documentation.enable = false;
documentation.doc.enable = false;
documentation.man.enable = false;
documentation.info.enable = false;
fonts.fontconfig.enable = false;
}
];
nixpkgs.config.packageOverrides = pkgs: {
autorenkalender = pkgs.callPackage <packages/autorenkalender.nix> {};
literature-quote = pkgs.callPackage <packages/literature-quote.nix> {};
};
boot.loader.grub.enable = false;
boot.loader.generic-extlinux-compatible.enable = true;
@@ -26,26 +55,11 @@ in {
environment.variables.TERM = "linux";
environment.variables.HTOPRC = toString <dot/htoprc>;
documentation.enable = false;
documentation.doc.enable = false;
documentation.man.enable = false;
documentation.info.enable = false;
fonts.fontconfig.enable = false;
programs.tmux.enable = true;
environment.systemPackages = with pkgs; [
git
vim
htop
];
environment.systemPackages = with pkgs; [ git vim htop ];
users.mutableUsers = false;
services.syncthing = {
enable = true;
openDefaultPorts = true;
};
services.openssh.enable = true;
users.users.root.openssh.authorizedKeys.keys = [
sshKey.homeros

View File

@@ -4,81 +4,57 @@ let
telegram-betacode = pkgs.python3Packages.callPackage <packages/telegram-betacode.nix> {};
# telegram-horoscope = pkgs.python3Packages.callPackage <packages/telegram-horoscope.nix> {};
telegram-proverb = pkgs.python3Packages.callPackage <packages/telegram-proverb.nix> {};
autorenkalender = pkgs.callPackage <packages/autorenkalender.nix> {};
literature-quote = pkgs.callPackage <packages/literature-quote.nix> {};
in {
# containers.telegram-bots = {
# autoStart = true;
# config = {
systemd.services.quotebot = {
enable = true;
startAt = "08:00";
serviceConfig.Type = "oneshot";
wantedBy = [ "multi-user.target" ];
environment = {
TELEGRAM_AUTORENKALENDER_CHAT = "18980945";
TELEGRAM_AUTORENKALENDER_TOKEN = lib.strings.removeSuffix "\n" (builtins.readFile <secrets/telegram-kmein.token>);
};
script = ''
TELEGRAM_ENDPOINT="https://api.telegram.org/bot$TELEGRAM_AUTORENKALENDER_TOKEN"
${pkgs.curl}/bin/curl -s \
-X POST "$TELEGRAM_ENDPOINT/sendMessage" \
-d chat_id="$TELEGRAM_AUTORENKALENDER_CHAT" \
-d parse_mode=Markdown \
-d text="$(${literature-quote}/bin/literature-quote)"
'';
};
niveum.telegramBots.quotebot = {
enable = true;
time = "08:00";
token = lib.strings.removeSuffix "\n" (builtins.readFile <secrets/telegram-kmein.token>);
chatId = "18980945";
command = "${pkgs.literature-quote}/bin/literature-quote";
parseMode = "Markdown";
};
systemd.services.autorenbot = {
enable = true;
startAt = "07:00";
serviceConfig.Type = "oneshot";
wantedBy = [ "multi-user.target" ];
environment = {
TELEGRAM_AUTORENKALENDER_CHAT = "@autorenkalender";
TELEGRAM_AUTORENKALENDER_TOKEN = lib.strings.removeSuffix "\n" (builtins.readFile <secrets/telegram-kmein.token>);
};
script = ''
TELEGRAM_ENDPOINT="https://api.telegram.org/bot$TELEGRAM_AUTORENKALENDER_TOKEN"
${pkgs.curl}/bin/curl -s \
-X POST "$TELEGRAM_ENDPOINT/sendMessage" \
-d chat_id="$TELEGRAM_AUTORENKALENDER_CHAT" \
-d text="$(${autorenkalender}/bin/autorenkalender)"
'';
};
systemd.services.telegram-reverse = {
wantedBy = [ "multi-user.target" ];
description = "Telegram bot for reversing things";
environment.TELEGRAM_REVERSE_TOKEN = builtins.readFile <secrets/telegram-reverse.token>;
enable = true;
script = ''${telegram-reverse}/bin/telegram-reverse'';
serviceConfig.Restart = "always";
};
systemd.services.telegram-betacode = {
wantedBy = [ "multi-user.target" ];
description = "Telegram bot for converting Ancient Greek betacode into unicode";
environment.TELEGRAM_BETACODE_TOKEN = builtins.readFile <secrets/telegram-betacode.token>;
enable = true;
script = ''${telegram-betacode}/bin/telegram-betacode'';
serviceConfig.Restart = "always";
};
systemd.services.telegram-proverb = {
wantedBy = [ "multi-user.target" ];
description = "Telegram bot for generating inspiring but useless proverbs";
environment.TELEGRAM_PROVERB_TOKEN = builtins.readFile <secrets/telegram-proverb.token>;
enable = true;
script = ''${telegram-proverb}/bin/proverb_bot.py'';
serviceConfig.Restart = "always";
};
# systemd.services.telegram-horoscope = {
# wantedBy = [ "multi-user.target" ];
# description = "Telegram bot for generating horoscope charts";
# environment.TELEGRAM_HOROSCOPE_TOKEN = builtins.readFile <secrets/telegram-horoscope.token>;
# environment.GOOGLE_MAPS_API_KEY = builtins.readFile <secrets/google-maps.api-key>;
# enable = true;
# script = ''${telegram-horoscope}/bin/telegram-horoscope'';
# serviceConfig.Restart = "always";
# };
# };
niveum.telegramBots.autorenkalender = {
enable = true;
time = "07:00";
token = lib.strings.removeSuffix "\n" (builtins.readFile <secrets/telegram-kmein.token>);
chatId = "@autorenkalender";
command = "${pkgs.autorenkalender}/bin/autorenkalender";
};
systemd.services.telegram-reverse = {
wantedBy = [ "multi-user.target" ];
description = "Telegram bot for reversing things";
environment.TELEGRAM_REVERSE_TOKEN = builtins.readFile <secrets/telegram-reverse.token>;
enable = true;
script = ''${telegram-reverse}/bin/telegram-reverse'';
serviceConfig.Restart = "always";
};
systemd.services.telegram-betacode = {
wantedBy = [ "multi-user.target" ];
description = "Telegram bot for converting Ancient Greek betacode into unicode";
environment.TELEGRAM_BETACODE_TOKEN = builtins.readFile <secrets/telegram-betacode.token>;
enable = true;
script = ''${telegram-betacode}/bin/telegram-betacode'';
serviceConfig.Restart = "always";
};
systemd.services.telegram-proverb = {
wantedBy = [ "multi-user.target" ];
description = "Telegram bot for generating inspiring but useless proverbs";
environment.TELEGRAM_PROVERB_TOKEN = builtins.readFile <secrets/telegram-proverb.token>;
enable = true;
script = ''${telegram-proverb}/bin/proverb_bot.py'';
serviceConfig.Restart = "always";
};
# systemd.services.telegram-horoscope = {
# wantedBy = [ "multi-user.target" ];
# description = "Telegram bot for generating horoscope charts";
# environment.TELEGRAM_HOROSCOPE_TOKEN = builtins.readFile <secrets/telegram-horoscope.token>;
# environment.GOOGLE_MAPS_API_KEY = builtins.readFile <secrets/google-maps.api-key>;
# enable = true;
# script = ''${telegram-horoscope}/bin/telegram-horoscope'';
# serviceConfig.Restart = "always";
# };
}