applied nixfmt (new version)

This commit is contained in:
2024-09-22 14:45:24 -06:00
parent dd00fb4854
commit b514828594
89 changed files with 2091 additions and 1339 deletions

View File

@@ -1,59 +1,80 @@
{ config, lib, pkgs, ... }: {
{
config,
lib,
pkgs,
...
}:
{
options.my.scripts = lib.mkOption {
type = lib.types.attrsOf (lib.types.submodule {
options = {
enable = lib.mkEnableOption "Whether to enable this script";
install = lib.mkEnableOption "Whether to install the script package";
service = lib.mkEnableOption "Whether to enable the script service";
name = lib.mkOption {
type = lib.types.str;
description = "Name of the script.";
type = lib.types.attrsOf (
lib.types.submodule {
options = {
enable = lib.mkEnableOption "Whether to enable this script";
install = lib.mkEnableOption "Whether to install the script package";
service = lib.mkEnableOption "Whether to enable the script service";
name = lib.mkOption {
type = lib.types.str;
description = "Name of the script.";
};
timer = lib.mkOption {
type = lib.types.str;
default = "*:0";
description = "Systemd timer schedule.";
};
description = lib.mkOption {
type = lib.types.str;
description = "Description of the service.";
};
package = lib.mkOption {
type = lib.types.package;
description = "Package containing the executable script.";
};
};
timer = lib.mkOption {
type = lib.types.str;
default = "*:0";
description = "Systemd timer schedule.";
};
description = lib.mkOption {
type = lib.types.str;
description = "Description of the service.";
};
package = lib.mkOption {
type = lib.types.package;
description = "Package containing the executable script.";
};
};
});
}
);
default = { };
description = "Configuration for multiple scripts.";
};
config = lib.mkIf (lib.any (s: s.enable) (lib.attrValues config.my.scripts)) {
users.users.jawz.packages = lib.flatten (lib.mapAttrsToList (_name: script:
lib.optional (script.enable && script.install) script.package)
config.my.scripts);
users.users.jawz.packages = lib.flatten (
lib.mapAttrsToList (
_name: script: lib.optional (script.enable && script.install) script.package
) config.my.scripts
);
systemd.user.services = lib.mapAttrs' (name: script:
lib.nameValuePair "${script.name}"
(lib.mkIf (script.enable && script.service) {
restartIfChanged = true;
inherit (script) description;
wantedBy = [ "default.target" ];
path = [ pkgs.nix script.package ];
serviceConfig = {
Restart = "on-failure";
RestartSec = 30;
ExecStart = "${script.package}/bin/${script.name}";
};
})) config.my.scripts;
systemd.user.services = lib.mapAttrs' (
name: script:
lib.nameValuePair "${script.name}" (
lib.mkIf (script.enable && script.service) {
restartIfChanged = true;
inherit (script) description;
wantedBy = [ "default.target" ];
path = [
pkgs.nix
script.package
];
serviceConfig = {
Restart = "on-failure";
RestartSec = 30;
ExecStart = "${script.package}/bin/${script.name}";
};
}
)
) config.my.scripts;
systemd.user.timers = lib.mapAttrs' (name: script:
lib.nameValuePair "${script.name}"
(lib.mkIf (script.enable && script.service) {
enable = true;
inherit (script) description;
wantedBy = [ "timers.target" ];
timerConfig = { OnCalendar = script.timer; };
})) config.my.scripts;
systemd.user.timers = lib.mapAttrs' (
name: script:
lib.nameValuePair "${script.name}" (
lib.mkIf (script.enable && script.service) {
enable = true;
inherit (script) description;
wantedBy = [ "timers.target" ];
timerConfig = {
OnCalendar = script.timer;
};
}
)
) config.my.scripts;
};
}

View File

@@ -1,90 +1,113 @@
{ pkgs, lib, config, ... }: {
{
pkgs,
lib,
config,
...
}:
{
imports = [ ./base.nix ];
options.my.units.download.enable = lib.mkEnableOption "enable";
config = let
download = with pkgs;
python3Packages.buildPythonApplication {
pname = "download";
version = "2.5";
src = ../../scripts/download/.;
build-system = with python3Packages; [ setuptools ];
dependencies = with python3Packages; [ pyyaml types-pyyaml yt-dlp ];
propagatedBuildInputs = [ gallery-dl ffmpeg ];
};
in {
home-manager.users.jawz = {
xdg.configFile."gallery-dl/config.json".source =
../../dotfiles/gallery-dl/config.json;
services.lorri.enable = true;
programs.bash = {
shellAliases = {
dl = "download -u jawz -i";
comic = ''dl "$(cat "$LC" | fzf --multi --exact -i)"'';
gallery = ''dl "$(cat "$LW" | fzf --multi --exact -i)"'';
config =
let
download =
with pkgs;
python3Packages.buildPythonApplication {
pname = "download";
version = "2.5";
src = ../../scripts/download/.;
build-system = with python3Packages; [ setuptools ];
dependencies = with python3Packages; [
pyyaml
types-pyyaml
yt-dlp
];
propagatedBuildInputs = [
gallery-dl
ffmpeg
];
};
initExtra = ''
list_root=$XDG_CONFIG_HOME/jawz/lists/jawz
export LW=$list_root/watch.txt
export LI=$list_root/instant.txt
export LC=$list_root/comic.txt
'';
};
};
systemd.user = lib.mkIf config.my.units.download.enable {
services = let
mkDownloadService = desc: execStartCmd: {
restartIfChanged = true;
description = "Downloads ${desc}";
wantedBy = [ "default.target" ];
path = [ pkgs.bash download ];
serviceConfig = {
TimeoutStartSec = 2000;
TimeoutStopSec = 2000;
Restart = "on-failure";
RestartSec = 30;
ExecStart = "${download}/bin/download ${execStartCmd}";
in
{
home-manager.users.jawz = {
xdg.configFile."gallery-dl/config.json".source = ../../dotfiles/gallery-dl/config.json;
services.lorri.enable = true;
programs.bash = {
shellAliases = {
dl = "download -u jawz -i";
comic = ''dl "$(cat "$LC" | fzf --multi --exact -i)"'';
gallery = ''dl "$(cat "$LW" | fzf --multi --exact -i)"'';
};
initExtra = ''
list_root=$XDG_CONFIG_HOME/jawz/lists/jawz
export LW=$list_root/watch.txt
export LI=$list_root/instant.txt
export LC=$list_root/comic.txt
'';
};
in {
tuhmayto = mkDownloadService "tuhmayto stuff" ''
-u jawz -i https://x.com/tuhmayto/media \
https://www.furaffinity.net/user/tuhmayto/'';
"download@" = mkDownloadService "post from multiple sources" "%I";
"instagram@" = mkDownloadService "post types from instagram"
"instagram -u jawz -t %I";
};
timers = let
downloadTimer = time: delay: {
enable = true;
description = "Downloads post types from different sites";
wantedBy = [ "timers.target" ];
timerConfig = {
OnCalendar = time;
RandomizedDelaySec = delay;
Persistent = true;
systemd.user = lib.mkIf config.my.units.download.enable {
services =
let
mkDownloadService = desc: execStartCmd: {
restartIfChanged = true;
description = "Downloads ${desc}";
wantedBy = [ "default.target" ];
path = [
pkgs.bash
download
];
serviceConfig = {
TimeoutStartSec = 2000;
TimeoutStopSec = 2000;
Restart = "on-failure";
RestartSec = 30;
ExecStart = "${download}/bin/download ${execStartCmd}";
};
};
in
{
tuhmayto = mkDownloadService "tuhmayto stuff" ''
-u jawz -i https://x.com/tuhmayto/media \
https://www.furaffinity.net/user/tuhmayto/'';
"download@" = mkDownloadService "post from multiple sources" "%I";
"instagram@" = mkDownloadService "post types from instagram" "instagram -u jawz -t %I";
};
};
in {
"instagram@stories" = downloadTimer "*-*-* 08:12:00" 120 // { };
"download@main" = downloadTimer "*-*-* 06,18:02:00" 30 // { };
"download@push" = downloadTimer "*:0/5" 30 // { };
"download@manga" = downloadTimer "Fri *-*-* 03:08:00" 30 // { };
# "download@kemono" = downloadTimer
# "*-*-1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31 18:06:00" 60 // { };
tuhmayto = {
enable = true;
description = "Downloads tuhmayto stuff";
wantedBy = [ "timers.target" ];
timerConfig = { OnCalendar = "*:0/10"; };
};
timers =
let
downloadTimer = time: delay: {
enable = true;
description = "Downloads post types from different sites";
wantedBy = [ "timers.target" ];
timerConfig = {
OnCalendar = time;
RandomizedDelaySec = delay;
Persistent = true;
};
};
in
{
"instagram@stories" = downloadTimer "*-*-* 08:12:00" 120 // { };
"download@main" = downloadTimer "*-*-* 06,18:02:00" 30 // { };
"download@push" = downloadTimer "*:0/5" 30 // { };
"download@manga" = downloadTimer "Fri *-*-* 03:08:00" 30 // { };
# "download@kemono" = downloadTimer
# "*-*-1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31 18:06:00" 60 // { };
tuhmayto = {
enable = true;
description = "Downloads tuhmayto stuff";
wantedBy = [ "timers.target" ];
timerConfig = {
OnCalendar = "*:0/10";
};
};
};
};
my.scripts.download = {
enable = lib.mkDefault false;
install = true;
service = false;
name = "download";
package = download;
};
};
my.scripts.download = {
enable = lib.mkDefault false;
install = true;
service = false;
name = "download";
package = download;
};
};
}

View File

@@ -1,11 +1,11 @@
{ pkgs, lib, ... }: {
{ pkgs, lib, ... }:
{
imports = [ ./base.nix ];
config.my.scripts.ffmpeg4discord = {
enable = lib.mkDefault false;
install = true;
service = false;
name = "ffmpeg4discord";
package = pkgs.writeScriptBin "ffmpeg4discord"
(builtins.readFile ../../scripts/ffmpeg4discord.py);
package = pkgs.writeScriptBin "ffmpeg4discord" (builtins.readFile ../../scripts/ffmpeg4discord.py);
};
}

View File

@@ -1,11 +1,11 @@
{ pkgs, lib, ... }: {
{ pkgs, lib, ... }:
{
imports = [ ./base.nix ];
config.my.scripts.ffmpreg = {
enable = lib.mkDefault false;
install = true;
service = false;
name = "ffmpreg";
package = pkgs.writeScriptBin "ffmpreg"
(builtins.readFile ../../scripts/ffmpreg.sh);
package = pkgs.writeScriptBin "ffmpreg" (builtins.readFile ../../scripts/ffmpreg.sh);
};
}

View File

@@ -1,11 +1,13 @@
{ pkgs, lib, ... }: {
{ pkgs, lib, ... }:
{
imports = [ ./base.nix ];
config.my.scripts.find-dup-episodes = {
enable = lib.mkDefault false;
install = true;
service = false;
name = "find-dup-episodes";
package = pkgs.writeScriptBin "find-dup-episodes"
(builtins.readFile ../../scripts/find-dup-episodes.sh);
package = pkgs.writeScriptBin "find-dup-episodes" (
builtins.readFile ../../scripts/find-dup-episodes.sh
);
};
}

View File

@@ -1,4 +1,5 @@
{ pkgs, lib, ... }: {
{ pkgs, lib, ... }:
{
imports = [ ./base.nix ];
config.my.scripts.manage-library = {
enable = lib.mkDefault false;
@@ -7,7 +8,6 @@
name = "manage-library";
timer = "00:30";
description = "scans the library directory and sorts files";
package = pkgs.writeScriptBin "manage-library"
(builtins.readFile ../../scripts/manage-library.sh);
package = pkgs.writeScriptBin "manage-library" (builtins.readFile ../../scripts/manage-library.sh);
};
}

View File

@@ -1,11 +1,11 @@
{ pkgs, lib, ... }: {
{ pkgs, lib, ... }:
{
imports = [ ./base.nix ];
config.my.scripts.pika-list = {
enable = lib.mkDefault false;
install = true;
service = false;
name = "pika-list";
package = pkgs.writeScriptBin "pika-list"
(builtins.readFile ../../scripts/pika-list.sh);
package = pkgs.writeScriptBin "pika-list" (builtins.readFile ../../scripts/pika-list.sh);
};
}

View File

@@ -1,11 +1,11 @@
{ pkgs, lib, ... }: {
{ pkgs, lib, ... }:
{
imports = [ ./base.nix ];
config.my.scripts.run = {
enable = lib.mkDefault false;
install = true;
service = false;
name = "run";
package =
pkgs.writeScriptBin "run" (builtins.readFile ../../scripts/run.sh);
package = pkgs.writeScriptBin "run" (builtins.readFile ../../scripts/run.sh);
};
}

View File

@@ -1,11 +1,11 @@
{ pkgs, lib, ... }: {
{ pkgs, lib, ... }:
{
imports = [ ./base.nix ];
config.my.scripts.split-dir = {
enable = lib.mkDefault false;
install = true;
service = false;
name = "split-dir";
package = pkgs.writeScriptBin "split-dir"
(builtins.readFile ../../scripts/split-dir.sh);
package = pkgs.writeScriptBin "split-dir" (builtins.readFile ../../scripts/split-dir.sh);
};
}

View File

@@ -1,47 +1,59 @@
{ pkgs, lib, config, ... }: {
{
pkgs,
lib,
config,
...
}:
{
imports = [ ./base.nix ];
options.my.units.stream-dl.enable = lib.mkEnableOption "enable";
config = let
stream-dl = pkgs.writeScriptBin "stream-dl"
(builtins.readFile ../../scripts/stream-dl.sh);
in {
systemd.user = lib.mkIf config.my.units.stream-dl.enable {
services."stream@" = {
description = "monitors a stream channel for online streams.";
restartIfChanged = true;
wantedBy = [ "default.target" ];
path = [ pkgs.nix stream-dl ];
serviceConfig = {
Restart = "on-failure";
RestartSec = 30;
ExecStart = "${stream-dl}/bin/stream-dl %I";
};
};
timers = let
streamTimer = {
enable = true;
config =
let
stream-dl = pkgs.writeScriptBin "stream-dl" (builtins.readFile ../../scripts/stream-dl.sh);
in
{
systemd.user = lib.mkIf config.my.units.stream-dl.enable {
services."stream@" = {
description = "monitors a stream channel for online streams.";
wantedBy = [ "timers.target" ];
timerConfig = {
OnBootSec = "5min";
OnUnitActiveSec = "65min";
RandomizedDelaySec = 30;
restartIfChanged = true;
wantedBy = [ "default.target" ];
path = [
pkgs.nix
stream-dl
];
serviceConfig = {
Restart = "on-failure";
RestartSec = 30;
ExecStart = "${stream-dl}/bin/stream-dl %I";
};
};
in {
"stream@johnneal911" = streamTimer // { };
"stream@uk2011boy" = streamTimer // { };
"stream@tommy9x6" = streamTimer // { };
"stream@brocollirob" = streamTimer // { };
"stream@tomayto\\x20picarto" = streamTimer // { };
timers =
let
streamTimer = {
enable = true;
description = "monitors a stream channel for online streams.";
wantedBy = [ "timers.target" ];
timerConfig = {
OnBootSec = "5min";
OnUnitActiveSec = "65min";
RandomizedDelaySec = 30;
};
};
in
{
"stream@johnneal911" = streamTimer // { };
"stream@uk2011boy" = streamTimer // { };
"stream@tommy9x6" = streamTimer // { };
"stream@brocollirob" = streamTimer // { };
"stream@tomayto\\x20picarto" = streamTimer // { };
};
};
my.scripts.stream-dl = {
enable = lib.mkDefault false;
install = true;
service = false;
name = "stream-dl";
package = stream-dl;
};
};
my.scripts.stream-dl = {
enable = lib.mkDefault false;
install = true;
service = false;
name = "stream-dl";
package = stream-dl;
};
};
}

View File

@@ -1,4 +1,5 @@
{ pkgs, lib, ... }: {
{ pkgs, lib, ... }:
{
imports = [ ./base.nix ];
config.my.scripts.tasks = {
enable = lib.mkDefault false;
@@ -7,7 +8,6 @@
name = "tasks";
timer = "*:0/10";
description = "Runs a bunch of organizing tasks on selected directories";
package =
pkgs.writeScriptBin "tasks" (builtins.readFile ../../scripts/tasks.sh);
package = pkgs.writeScriptBin "tasks" (builtins.readFile ../../scripts/tasks.sh);
};
}

View File

@@ -1,4 +1,10 @@
{ config, pkgs, lib, ... }: {
{
config,
pkgs,
lib,
...
}:
{
imports = [ ./base.nix ];
config = {
sops.secrets = {
@@ -25,17 +31,18 @@
name = "update-dns";
timer = "*:0/30";
description = "Updates the IP of all my domains";
package = let
update-dns = pkgs.writeScriptBin "update-dns"
(builtins.readFile ../../scripts/update-dns.sh);
in pkgs.writeScriptBin "update-dns" ''
#!/usr/bin/env nix-shell
#! nix-shell -i bash -p bash curl
set -a
source ${config.sops.secrets.dns.path}
set -a
${update-dns}/bin/update-dns
'';
package =
let
update-dns = pkgs.writeScriptBin "update-dns" (builtins.readFile ../../scripts/update-dns.sh);
in
pkgs.writeScriptBin "update-dns" ''
#!/usr/bin/env nix-shell
#! nix-shell -i bash -p bash curl
set -a
source ${config.sops.secrets.dns.path}
set -a
${update-dns}/bin/update-dns
'';
};
};
}