mirror of
https://github.com/kmein/niveum
synced 2026-03-19 19:41:08 +01:00
feat: run moodle-dl on toum, sshfs from wilde
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
{ pkgs, lib, ... }:
|
{ config, pkgs, lib, ... }:
|
||||||
let
|
let
|
||||||
inherit (lib.strings) fileContents;
|
inherit (lib.strings) fileContents;
|
||||||
|
inherit (import <niveum/lib>) sshPort;
|
||||||
eduroam = {
|
eduroam = {
|
||||||
identity = fileContents <secrets/eduroam/identity>;
|
identity = fileContents <secrets/eduroam/identity>;
|
||||||
password = fileContents <secrets/eduroam/password>;
|
password = fileContents <secrets/eduroam/password>;
|
||||||
@@ -28,7 +29,33 @@ in {
|
|||||||
eduroam.auth = eduroamAuth;
|
eduroam.auth = eduroamAuth;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
fileSystems."/mnt/moodle" = {
|
||||||
|
device = "moodle@toum.r:/var/lib/moodle";
|
||||||
|
fsType = "fuse.sshfs";
|
||||||
|
options = [
|
||||||
|
"allow_other"
|
||||||
|
"default_permissions"
|
||||||
|
"gid=100"
|
||||||
|
"uid=1000"
|
||||||
|
"IdentityFile=/root/.ssh/id_rsa"
|
||||||
|
"Port=${toString sshPort}"
|
||||||
|
"idmap=user"
|
||||||
|
"noauto"
|
||||||
|
"nofail"
|
||||||
|
"reconnect"
|
||||||
|
"ro"
|
||||||
|
"x-systemd.automount"
|
||||||
|
"x-systemd.requires=network.target"
|
||||||
|
"x-systemd.idle-timeout=1min"
|
||||||
|
"x-systemd.device-timeout=1s"
|
||||||
|
"x-systemd.mount-timeout=1s"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
environment.systemPackages = [
|
environment.systemPackages = [
|
||||||
|
pkgs.sshfsFuse
|
||||||
|
|
||||||
(pkgs.writers.writeDashBin "hu-vpn" ''
|
(pkgs.writers.writeDashBin "hu-vpn" ''
|
||||||
${pkgs.openfortivpn}/bin/openfortivpn -p "${eduroam.password}" -c ${pkgs.writeText "hu-berlin.config" ''
|
${pkgs.openfortivpn}/bin/openfortivpn -p "${eduroam.password}" -c ${pkgs.writeText "hu-berlin.config" ''
|
||||||
host = forti-ssl.vpn.hu-berlin.de
|
host = forti-ssl.vpn.hu-berlin.de
|
||||||
|
|||||||
58
configs/moodle-dl.nix
Normal file
58
configs/moodle-dl.nix
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
{ config, pkgs, lib, ... }:
|
||||||
|
let
|
||||||
|
inherit (import <niveum/lib>) kieran;
|
||||||
|
|
||||||
|
moodle-dl = pkgs.callPackage <niveum/packages/moodle-dl> {};
|
||||||
|
|
||||||
|
moodle-dl-config = {
|
||||||
|
telegram = {
|
||||||
|
token = lib.strings.fileContents <system-secrets/telegram/moodle-dl.token>;
|
||||||
|
chat_id = "18980945";
|
||||||
|
send_error_msg = true;
|
||||||
|
};
|
||||||
|
token = lib.strings.fileContents <system-secrets/moodle.token>;
|
||||||
|
moodle_domain = "moodle.hu-berlin.de";
|
||||||
|
moodle_path = "/";
|
||||||
|
download_course_ids = [
|
||||||
|
99881 # Dialektologie
|
||||||
|
100183 # Onomastik
|
||||||
|
100353 # Sanskrit I
|
||||||
|
100692 # Sanskrit Tutorium
|
||||||
|
];
|
||||||
|
download_submissions = true;
|
||||||
|
download_descriptions = false;
|
||||||
|
download_links_in_descriptions = false;
|
||||||
|
download_databases = false;
|
||||||
|
download_forums = false;
|
||||||
|
download_linked_files = false;
|
||||||
|
download_also_with_cookie = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
moodle-dl-json = pkgs.writeText "moodle-dl.json" (builtins.toJSON moodle-dl-config);
|
||||||
|
in
|
||||||
|
{
|
||||||
|
users.extraUsers.moodle = {
|
||||||
|
isNormalUser = false;
|
||||||
|
home = "/var/lib/moodle";
|
||||||
|
createHome = true;
|
||||||
|
openssh.authorizedKeys.keys = [
|
||||||
|
# for sshfs mount
|
||||||
|
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDtIFmbspaBHaSkLEx43V0uaVd7l9NUFiwt2VOP++KzLjvRMLkyF2hg2HjmogTjUvTyoDs7RHwEH/cHZlJ5JQkM1jRqQpnYwGfkZEwYvmXAl6LY9+vQMP36gNPfXmKX3y3LelO7oD2uhUs0guTtg0tHUyN5/UY5u+VinyD6djxDkHaCUn3S7CS/odBcs/4flXT654wsvzgYicnSKH9R4W+7C0YsckZ/NoIkA4jnuwtWZYWrUkxd4/290buX6pAc5+zVVZqyy0sI4i8s6pO9RL5W7xvYt+w+U0u0dMxm5ckiRmLVKfIbMN4YtDxsZbZDajlQ1nDbOsEsrSXWz4H4cSNot7J820x1qh5SSxL4GSQlcT+6xCFk9kKyflxoS3oLoPLttx3rmOMkZKJWxF/IKLW47orxV6wkG5mHxdeR3cf6jX4j3nkwFVyC9R+WG4w2Z4vKONVE7uWGYU3y4OpR1e6MGHVShkNKqEvC/Kjcc/6v7I7AKRAuPZB0WEw36tA65/8= root@wilde"
|
||||||
|
];
|
||||||
|
useDefaultShell = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
system.activationScripts.moodle-dl-config = "ln -sfn ${toString moodle-dl-json} ${config.users.extraUsers.moodle.home}/config.json";
|
||||||
|
|
||||||
|
systemd.services.moodle-dl = {
|
||||||
|
enable = true;
|
||||||
|
startAt = "hourly";
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
User = config.users.extraUsers.moodle.name;
|
||||||
|
WorkingDirectory = config.users.extraUsers.moodle.home;
|
||||||
|
};
|
||||||
|
wants = [ "network-online.target" ];
|
||||||
|
script = "${moodle-dl}/bin/moodle-dl";
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,16 +1,12 @@
|
|||||||
{ pkgs, config, lib, ... }:
|
{ pkgs, config, lib, ... }:
|
||||||
let
|
let
|
||||||
inherit (import <niveum/lib>) sshPort;
|
inherit (import <niveum/lib>) sshPort kieran;
|
||||||
kmeinKeys = lib.strings.splitString "\n" (lib.strings.fileContents (pkgs.fetchurl {
|
|
||||||
url = "https://github.com/kmein.keys";
|
|
||||||
sha256 = "1b9gbpgihg7zc89ivsz0gs3najp0zg53rcknvzvkm0851fdzkryx";
|
|
||||||
}));
|
|
||||||
in {
|
in {
|
||||||
services.xserver.displayManager.sessionCommands = "${pkgs.openssh}/bin/ssh-add";
|
services.xserver.displayManager.sessionCommands = "${pkgs.openssh}/bin/ssh-add";
|
||||||
|
|
||||||
programs.ssh.startAgent = true;
|
programs.ssh.startAgent = true;
|
||||||
|
|
||||||
users.users.me.openssh.authorizedKeys.keys = kmeinKeys;
|
users.users.me.openssh.authorizedKeys.keys = kieran.sshKeys pkgs;
|
||||||
|
|
||||||
home-manager.users.me.programs.ssh = {
|
home-manager.users.me.programs.ssh = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
let
|
let
|
||||||
inherit (import <niveum/lib>) sshPort;
|
inherit (import <niveum/lib>) sshPort kieran;
|
||||||
kmeinKeys = lib.strings.splitString "\n" (lib.strings.fileContents (pkgs.fetchurl {
|
|
||||||
url = "https://github.com/kmein.keys";
|
|
||||||
sha256 = "1b9gbpgihg7zc89ivsz0gs3najp0zg53rcknvzvkm0851fdzkryx";
|
|
||||||
}));
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
users.motd = "Welcome to ${config.networking.hostName}!";
|
users.motd = "Welcome to ${config.networking.hostName}!";
|
||||||
@@ -16,5 +12,5 @@ in
|
|||||||
forwardX11 = true;
|
forwardX11 = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
users.users.root.openssh.authorizedKeys.keys = kmeinKeys;
|
users.users.root.openssh.authorizedKeys.keys = kieran.sshKeys pkgs;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,10 @@
|
|||||||
github = "kmein";
|
github = "kmein";
|
||||||
email = "kmein@posteo.de";
|
email = "kmein@posteo.de";
|
||||||
name = "Kierán Meinhardt";
|
name = "Kierán Meinhardt";
|
||||||
|
sshKeys = pkgs: pkgs.lib.strings.splitString "\n" (pkgs.lib.strings.fileContents (pkgs.fetchurl {
|
||||||
|
url = "https://github.com/kmein.keys";
|
||||||
|
sha256 = "1b9gbpgihg7zc89ivsz0gs3najp0zg53rcknvzvkm0851fdzkryx";
|
||||||
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
ignorePaths = [
|
ignorePaths = [
|
||||||
|
|||||||
32
packages/moodle-dl/default.nix
Normal file
32
packages/moodle-dl/default.nix
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
{ stdenv, lib, python3Packages }:
|
||||||
|
python3Packages.buildPythonApplication rec {
|
||||||
|
pname = "moodle-dl";
|
||||||
|
version = "2.1.1.1";
|
||||||
|
|
||||||
|
src = python3Packages.fetchPypi {
|
||||||
|
inherit pname version;
|
||||||
|
sha256 = "0nv2gm4x6mfsa0wywm4xbsx6nf6hx4kb63s4lczaxb9m4ybjd45h";
|
||||||
|
};
|
||||||
|
|
||||||
|
patches = [
|
||||||
|
./readchar-version.patch
|
||||||
|
];
|
||||||
|
|
||||||
|
propagatedBuildInputs = with python3Packages; [
|
||||||
|
sentry-sdk
|
||||||
|
colorama
|
||||||
|
readchar
|
||||||
|
youtube-dl
|
||||||
|
certifi
|
||||||
|
html2text
|
||||||
|
requests
|
||||||
|
];
|
||||||
|
|
||||||
|
meta = with stdenv.lib; {
|
||||||
|
homepage = "https://github.com/C0D3D3V/Moodle-Downloader-2";
|
||||||
|
maintainers = [ maintainers.kmein ];
|
||||||
|
description = "A Moodle downloader that downloads course content fast from Moodle";
|
||||||
|
license = licenses.gpl3;
|
||||||
|
platforms = platforms.all;
|
||||||
|
};
|
||||||
|
}
|
||||||
13
packages/moodle-dl/readchar-version.patch
Normal file
13
packages/moodle-dl/readchar-version.patch
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
diff --git a/setup.py b/setup.py
|
||||||
|
index 180139d..5582359 100644
|
||||||
|
--- a/setup.py
|
||||||
|
+++ b/setup.py
|
||||||
|
@@ -32,7 +32,7 @@ setup(
|
||||||
|
install_requires=[
|
||||||
|
'sentry_sdk>=0.13.5',
|
||||||
|
'colorama>=0.4.3',
|
||||||
|
- 'readchar>=2.0.1',
|
||||||
|
+ 'readchar>=2.0.0',
|
||||||
|
'youtube_dl>=2020.9.20',
|
||||||
|
'certifi>=2020.4.5.2',
|
||||||
|
'html2text>=2020.1.16',
|
||||||
@@ -1,18 +1,15 @@
|
|||||||
{ config, pkgs, lib, ... }:
|
{ config, pkgs, lib, ... }:
|
||||||
let
|
let
|
||||||
kmeinKeys = lib.strings.splitString "\n" (lib.strings.fileContents (pkgs.fetchurl {
|
inherit (import <niveum/lib>) kieran;
|
||||||
url = "https://github.com/kmein.keys";
|
|
||||||
sha256 = "1b9gbpgihg7zc89ivsz0gs3najp0zg53rcknvzvkm0851fdzkryx";
|
|
||||||
}));
|
|
||||||
in {
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
./hardware-configuration.nix
|
./hardware-configuration.nix
|
||||||
./hass
|
./hass
|
||||||
./telegram-bots
|
./telegram-bots
|
||||||
<niveum/configs/distrobump.nix>
|
<niveum/configs/distrobump.nix>
|
||||||
<niveum/configs/nextcloud.nix>
|
|
||||||
<niveum/configs/spacetime.nix>
|
<niveum/configs/spacetime.nix>
|
||||||
<niveum/configs/sshd.nix>
|
<niveum/configs/sshd.nix>
|
||||||
|
<niveum/configs/moodle-dl.nix>
|
||||||
<niveum/configs/save-space.nix>
|
<niveum/configs/save-space.nix>
|
||||||
<niveum/configs/wifi.nix>
|
<niveum/configs/wifi.nix>
|
||||||
<niveum/configs/tmux.nix>
|
<niveum/configs/tmux.nix>
|
||||||
@@ -72,7 +69,7 @@ in {
|
|||||||
hashedPassword =
|
hashedPassword =
|
||||||
"$6$w9hXyGFl/.IZBXk$5OiWzS1G.5hImhh1YQmZiCXYNAJhi3X6Y3uSLupJNYYXPLMsQpx2fwF4Xr2uYzGMV8Foqh8TgUavx1APD9rcb/";
|
"$6$w9hXyGFl/.IZBXk$5OiWzS1G.5hImhh1YQmZiCXYNAJhi3X6Y3uSLupJNYYXPLMsQpx2fwF4Xr2uYzGMV8Foqh8TgUavx1APD9rcb/";
|
||||||
shell = pkgs.bash;
|
shell = pkgs.bash;
|
||||||
openssh.authorizedKeys.keys = kmeinKeys;
|
openssh.authorizedKeys.keys = kieran.sshKeys pkgs;
|
||||||
};
|
};
|
||||||
|
|
||||||
security.sudo.enable = true;
|
security.sudo.enable = true;
|
||||||
|
|||||||
@@ -1,19 +1,14 @@
|
|||||||
{ config, pkgs, lib, ... }:
|
{ config, pkgs, lib, ... }:
|
||||||
let
|
{
|
||||||
kmeinKeys = lib.strings.splitString "\n" (lib.strings.fileContents (pkgs.fetchurl {
|
|
||||||
url = "https://github.com/kmein.keys";
|
|
||||||
sha256 = "1b9gbpgihg7zc89ivsz0gs3najp0zg53rcknvzvkm0851fdzkryx";
|
|
||||||
}));
|
|
||||||
in {
|
|
||||||
imports = [
|
imports = [
|
||||||
./hardware-configuration.nix
|
./hardware-configuration.nix
|
||||||
<niveum/configs/wifi.nix>
|
<niveum/configs/wifi.nix>
|
||||||
<niveum/configs/keyboard.nix>
|
<niveum/configs/keyboard.nix>
|
||||||
<niveum/modules/retiolum.nix>
|
<niveum/modules/retiolum.nix>
|
||||||
<niveum/modules/constants.nix>
|
|
||||||
<niveum/configs/spacetime.nix>
|
<niveum/configs/spacetime.nix>
|
||||||
<niveum/configs/mpd.nix>
|
<niveum/configs/mpd.nix>
|
||||||
<niveum/configs/sshd.nix>
|
<niveum/configs/sshd.nix>
|
||||||
|
<niveum/configs/version.nix>
|
||||||
<niveum/configs/spotifyd.nix>
|
<niveum/configs/spotifyd.nix>
|
||||||
{
|
{
|
||||||
sound.enable = true;
|
sound.enable = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user