mirror of
https://github.com/kmein/niveum
synced 2026-03-21 12:21:08 +01:00
feat(moodle-dl): reintegrate module in niveum
This commit is contained in:
@@ -1,17 +1,11 @@
|
|||||||
{ config, pkgs, lib, ... }:
|
{ config, pkgs, lib, ... }:
|
||||||
let
|
let
|
||||||
nixpkgs-kmein = builtins.fetchGit {
|
moodle-dl-package = pkgs.moodle-dl.overrideAttrs (old: old // {
|
||||||
url = "https://github.com/kmein/nixpkgs";
|
|
||||||
ref = "refs/heads/feature/moodle-dl-module";
|
|
||||||
rev = "ea2e0387ee946e575f7851ec21debc9179d82ad0";
|
|
||||||
};
|
|
||||||
|
|
||||||
moodle-dl-package = (import nixpkgs-kmein {}).moodle-dl.overrideAttrs (old: old // {
|
|
||||||
patches = [ <niveum/packages/moodle-dl/telegram-format.patch> ];
|
patches = [ <niveum/packages/moodle-dl/telegram-format.patch> ];
|
||||||
});
|
});
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [ "${nixpkgs-kmein}/nixos/modules/services/networking/moodle-dl.nix" ];
|
imports = [ <niveum/modules/moodle-dl.nix> ];
|
||||||
|
|
||||||
services.moodle-dl = {
|
services.moodle-dl = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|||||||
@@ -1,17 +1,11 @@
|
|||||||
{ config, pkgs, lib, ... }:
|
{ config, pkgs, lib, ... }:
|
||||||
let
|
let
|
||||||
nixpkgs-kmein = builtins.fetchGit {
|
moodle-dl-package = pkgs.moodle-dl.overrideAttrs (old: old // {
|
||||||
url = "https://github.com/kmein/nixpkgs";
|
|
||||||
ref = "refs/heads/feature/moodle-dl-module";
|
|
||||||
rev = "11e035b133ea9fbf07bc1b6185990b095358ab4f";
|
|
||||||
};
|
|
||||||
|
|
||||||
moodle-dl-package = (import nixpkgs-kmein {}).moodle-dl.overrideAttrs (old: old // {
|
|
||||||
patches = [ <niveum/packages/moodle-dl/telegram-format.patch> ];
|
patches = [ <niveum/packages/moodle-dl/telegram-format.patch> ];
|
||||||
});
|
});
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [ "${nixpkgs-kmein}/nixos/modules/services/networking/moodle-dl.nix" ];
|
imports = [ <niveum/modules/moodle-dl.nix> ];
|
||||||
|
|
||||||
services.moodle-dl = {
|
services.moodle-dl = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|||||||
82
modules/moodle-dl.nix
Normal file
82
modules/moodle-dl.nix
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
{ 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;
|
||||||
|
stateDirectoryDefault = "/var/lib/moodle-dl";
|
||||||
|
in {
|
||||||
|
options = {
|
||||||
|
services.moodle-dl = {
|
||||||
|
enable = mkEnableOption "moodle-dl, a Moodle downloader";
|
||||||
|
|
||||||
|
settings = mkOption {
|
||||||
|
default = {};
|
||||||
|
type = json.type;
|
||||||
|
description = ''
|
||||||
|
Configuration for moodle-dl. For a full example, see
|
||||||
|
<link xlink:href="https://github.com/C0D3D3V/Moodle-Downloader-2/wiki/Config.json"/>.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
notifyOnly = mkOption {
|
||||||
|
default = false;
|
||||||
|
type = types.bool;
|
||||||
|
description = ''
|
||||||
|
Whether to notify about changes without downloading any files.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
startAt = mkOption {
|
||||||
|
type = with types; either str (listOf str);
|
||||||
|
description = "When to run moodle-dl. See systemd.time(7) for the format.";
|
||||||
|
};
|
||||||
|
|
||||||
|
directory = mkOption {
|
||||||
|
default = stateDirectoryDefault;
|
||||||
|
type = types.path;
|
||||||
|
description = ''
|
||||||
|
The path moodle-dl should download course files to. If left
|
||||||
|
as the default value this directory will automatically be created before
|
||||||
|
moodle-dl runs, otherwise the sysadmin is responsible for ensuring
|
||||||
|
the directory exists with appropriate ownership and permissions.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
package = mkOption {
|
||||||
|
default = pkgs.moodle-dl;
|
||||||
|
type = types.package;
|
||||||
|
description = "The moodle-dl package to use.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
|
||||||
|
users.users.moodle-dl = {
|
||||||
|
isSystemUser = true;
|
||||||
|
home = cfg.directory;
|
||||||
|
};
|
||||||
|
|
||||||
|
users.groups.moodle-dl = {};
|
||||||
|
|
||||||
|
systemd.services.moodle-dl = {
|
||||||
|
description = "A Moodle downloader that downloads course content";
|
||||||
|
wants = [ "network-online.target" ];
|
||||||
|
serviceConfig = mkMerge [
|
||||||
|
{
|
||||||
|
Type = "oneshot";
|
||||||
|
User = config.users.users.moodle-dl.name;
|
||||||
|
Group = config.users.groups.moodle-dl.name;
|
||||||
|
WorkingDirectory = cfg.directory;
|
||||||
|
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"; })
|
||||||
|
];
|
||||||
|
inherit (cfg) startAt;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
meta.maintainers = [ maintainers.kmein ];
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user