mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-01-31 04:58:01 +00:00
modules: reformat and refactor
This commit is contained in:
parent
fe94062d2e
commit
49018fb53e
@ -28,9 +28,7 @@ in {
|
||||
(lib.mkIf cfg.emacs.enable {
|
||||
# Doom Emacs dependencies.
|
||||
home.packages = with pkgs; [
|
||||
((emacsPackagesFor emacs).emacsWithPackages (epkgs: [
|
||||
epkgs.vterm
|
||||
]))
|
||||
((emacsPackagesFor emacs).emacsWithPackages (epkgs: [ epkgs.vterm ]))
|
||||
|
||||
# Required dependencies.
|
||||
ripgrep
|
||||
|
@ -9,13 +9,13 @@ let
|
||||
description = "List of links to archive.";
|
||||
example = lib.literalExpression ''
|
||||
[
|
||||
"https://guix.gnu.org/feeds/blog.atom"
|
||||
"https://nixos.org/blog/announcements-rss.xml"
|
||||
"https://guix.gnu.org/feeds/blog.atom"
|
||||
"https://nixos.org/blog/announcements-rss.xml"
|
||||
]
|
||||
'';
|
||||
};
|
||||
|
||||
extraOptions = lib.mkOption {
|
||||
extraArgs = lib.mkOption {
|
||||
type = with lib.types; listOf str;
|
||||
description = ''
|
||||
Additional arguments for adding links (i.e., <literal>archivebox add
|
||||
@ -69,7 +69,7 @@ in {
|
||||
"https://arxiv.org/rss/cs"
|
||||
"https://distill.pub/"
|
||||
];
|
||||
extraOptions = [ "--depth 1" ];
|
||||
extraArgs = [ "--depth 1" ];
|
||||
startAt = "daily";
|
||||
};
|
||||
}
|
||||
@ -91,34 +91,37 @@ in {
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
config = let
|
||||
pkgSet = [ pkgs.archivebox ] ++ (lib.optionals cfg.withDependencies
|
||||
(with pkgs; [ chromium nodejs_latest wget curl youtube-dl ]));
|
||||
in lib.mkIf cfg.enable {
|
||||
assertions = [
|
||||
(lib.hm.assertions.assertPlatform "services.archivebox" pkgs
|
||||
lib.platforms.linux)
|
||||
];
|
||||
|
||||
home.packages = [ pkgs.archivebox ] ++ (lib.optionals cfg.withDependencies
|
||||
(with pkgs; [ chromium nodejs_latest wget curl youtube-dl ]));
|
||||
home.packages = pkgSet;
|
||||
|
||||
systemd.user.services = lib.mkMerge [
|
||||
(lib.mapAttrs' (name: value:
|
||||
lib.nameValuePair "archivebox-add-${name}" {
|
||||
Unit = {
|
||||
Description = "Archivebox archive group '${name}' for ${cfg.archivePath}";
|
||||
Description =
|
||||
"Archivebox archive group '${name}' for ${cfg.archivePath}";
|
||||
After = "network.target";
|
||||
Documentation = [ "https://docs.archivebox.io/" ];
|
||||
};
|
||||
|
||||
Install.WantedBy = [ "default.target" ];
|
||||
|
||||
Service = let
|
||||
scriptName = "archivebox-job-${config.home.username}-${name}";
|
||||
script = pkgs.writeShellApplication {
|
||||
script = pkgs.writeShellApplication {
|
||||
name = scriptName;
|
||||
runtimeInputs = with pkgs; [ coreutils archivebox ];
|
||||
runtimeInputs = with pkgs;
|
||||
[ ripgrep coreutils ] ++ pkgSet
|
||||
++ [ config.programs.git.package ];
|
||||
text = ''
|
||||
echo "${lib.concatStringsSep "\n" value.links}" \
|
||||
| archivebox add ${lib.concatStringsSep " " value.extraOptions}
|
||||
| archivebox add ${lib.concatStringsSep " " value.extraArgs}
|
||||
'';
|
||||
};
|
||||
in {
|
||||
|
@ -105,7 +105,7 @@ in {
|
||||
Restart = "on-failure";
|
||||
ExecStart = "${pkgs.bleachbit}/bin/bleachbit --clean ${
|
||||
lib.concatStringsSep " " cleaners
|
||||
}";
|
||||
}";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -5,7 +5,8 @@ let
|
||||
|
||||
settingsFormat = pkgs.formats.json { };
|
||||
settingsFormatFile =
|
||||
settingsFormat.generate "gallery-dl-service-config-${config.home.username}" cfg.settings;
|
||||
settingsFormat.generate "gallery-dl-service-config-${config.home.username}"
|
||||
cfg.settings;
|
||||
|
||||
jobType = { name, config, options, ... }: {
|
||||
options = {
|
||||
|
@ -7,13 +7,16 @@ let
|
||||
# The configuration format of Mopidy. It seems to use configparser with
|
||||
# some quirky handling of its types. You can see how they're handled in
|
||||
# `mopidy/config/types.py` from the source code.
|
||||
toMopidyConf = with lib; generators.toINI {
|
||||
mkKeyValue = generators.mkKeyValueDefault {
|
||||
mkValueString = v:
|
||||
if isList v then "\n " + concatStringsSep "\n " v
|
||||
else generators.mkValueStringDefault {} v;
|
||||
} " = ";
|
||||
};
|
||||
toMopidyConf = with lib;
|
||||
generators.toINI {
|
||||
mkKeyValue = generators.mkKeyValueDefault {
|
||||
mkValueString = v:
|
||||
if isList v then
|
||||
"\n " + concatStringsSep "\n " v
|
||||
else
|
||||
generators.mkValueStringDefault { } v;
|
||||
} " = ";
|
||||
};
|
||||
|
||||
mopidyEnv = pkgs.buildEnv {
|
||||
name = "mopidy-with-extensions-${pkgs.mopidy.version}";
|
||||
@ -25,18 +28,19 @@ let
|
||||
'';
|
||||
};
|
||||
|
||||
mopidyConfFormat = {}: {
|
||||
mopidyConfFormat = { }: {
|
||||
type = with lib.types;
|
||||
let
|
||||
valueType = nullOr (oneOf [ bool int float str (listOf valueType) ]) // {
|
||||
description = "Mopidy config value";
|
||||
};
|
||||
valueType = nullOr (oneOf [ bool int float str (listOf valueType) ])
|
||||
// {
|
||||
description = "Mopidy config value";
|
||||
};
|
||||
in attrsOf (attrsOf valueType);
|
||||
|
||||
generate = name: value: pkgs.writeText name (toMopidyConf value);
|
||||
};
|
||||
|
||||
settingsFormat = mopidyConfFormat {};
|
||||
settingsFormat = mopidyConfFormat { };
|
||||
in {
|
||||
options.services.mopidy = {
|
||||
enable = lib.mkEnableOption "Mopidy music player daemon";
|
||||
@ -53,7 +57,7 @@ in {
|
||||
};
|
||||
|
||||
configuration = lib.mkOption {
|
||||
default = {};
|
||||
default = { };
|
||||
type = settingsFormat.type;
|
||||
description = ''
|
||||
The Mopidy configuration to be written in the appropriate file in the
|
||||
@ -94,7 +98,8 @@ in {
|
||||
];
|
||||
|
||||
xdg.configFile."mopidy/mopidy.conf".source =
|
||||
settingsFormat.generate "mopidy-conf-${config.home.username}" cfg.configuration;
|
||||
settingsFormat.generate "mopidy-conf-${config.home.username}"
|
||||
cfg.configuration;
|
||||
|
||||
systemd.user.services.mopidy = {
|
||||
Unit = {
|
||||
@ -103,9 +108,7 @@ in {
|
||||
Documentation = [ "https://mopidy.com/" ];
|
||||
};
|
||||
|
||||
Service = {
|
||||
ExecStart = "${mopidyEnv}/bin/mopidy";
|
||||
};
|
||||
Service = { ExecStart = "${mopidyEnv}/bin/mopidy"; };
|
||||
|
||||
Install.WantedBy = [ "default.target" ];
|
||||
};
|
||||
|
@ -80,6 +80,7 @@ in {
|
||||
Unit = {
|
||||
Description = "Plover stenography engine";
|
||||
Documentation = [ "https://github.com/openstenoproject/plover/wiki/" ];
|
||||
PartOf = "default.target";
|
||||
};
|
||||
|
||||
Service = {
|
||||
|
@ -95,7 +95,7 @@ in {
|
||||
configDir = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "${config.home.homeDirectory}/.recoll";
|
||||
example = "\${xdg.configHome.\"recoll\"}";
|
||||
example = ''''${xdg.configHome."recoll"}'';
|
||||
description = "The directory to contain Recoll configuration files.";
|
||||
};
|
||||
};
|
||||
|
@ -67,7 +67,10 @@ in {
|
||||
to be created at the time of running the service. Must be an absolute
|
||||
path.
|
||||
'';
|
||||
default = "${lib.replaceStrings ["$HOME"] [config.home.homeDirectory] config.xdg.userDirs.videos}/yt-dlp-service";
|
||||
default = "${
|
||||
lib.replaceStrings [ "$HOME" ] [ config.home.homeDirectory ]
|
||||
config.xdg.userDirs.videos
|
||||
}/yt-dlp-service";
|
||||
example = lib.literalExpression
|
||||
"\${config.xdg.userDirs.download}/archiving-service/videos";
|
||||
};
|
||||
@ -126,14 +129,19 @@ in {
|
||||
Service = {
|
||||
WorkingDirectory = cfg.archivePath;
|
||||
ExecStartPre = ''
|
||||
${pkgs.bash}/bin/bash -c "${pkgs.coreutils}/bin/mkdir -p ${lib.escapeShellArg cfg.archivePath}"
|
||||
${pkgs.bash}/bin/bash -c "${pkgs.coreutils}/bin/mkdir -p ${
|
||||
lib.escapeShellArg cfg.archivePath
|
||||
}"
|
||||
'';
|
||||
ExecStart = let
|
||||
scriptName = "yt-dlp-archive-service-${config.home.username}-${name}";
|
||||
scriptName =
|
||||
"yt-dlp-archive-service-${config.home.username}-${name}";
|
||||
archiveScript = pkgs.writeShellScriptBin scriptName ''
|
||||
${cfg.package}/bin/yt-dlp ${lib.concatStringsSep " " cfg.extraArgs} ${
|
||||
lib.concatStringsSep " " value.extraArgs
|
||||
} ${lib.escapeShellArgs value.urls}
|
||||
${cfg.package}/bin/yt-dlp ${
|
||||
lib.concatStringsSep " " cfg.extraArgs
|
||||
} ${lib.concatStringsSep " " value.extraArgs} ${
|
||||
lib.escapeShellArgs value.urls
|
||||
}
|
||||
'';
|
||||
in "${archiveScript}/bin/${scriptName}";
|
||||
};
|
||||
|
@ -19,8 +19,10 @@ let
|
||||
options = {
|
||||
settings = lib.mkOption {
|
||||
type = lib.types.attrs;
|
||||
description =
|
||||
"Configuration to be merged in <literal>users.users.<name></literal> from NixOS configuration.";
|
||||
description = ''
|
||||
Configuration to be merged in <literal>users.users.<name></literal>
|
||||
from NixOS configuration.
|
||||
'';
|
||||
default = { };
|
||||
example = {
|
||||
uid = 1234;
|
||||
@ -37,8 +39,11 @@ in {
|
||||
users = lib.mkOption {
|
||||
default = { };
|
||||
description = ''
|
||||
A set of users from the `./users/home-manager` directory to be included in the NixOS config.
|
||||
This will also create the appropriate user settings in <literal>users.users</literal> in the NixOS configuration.'';
|
||||
A set of users from the <filename>./users/home-manager</filename>
|
||||
directory to be included in the NixOS config. This will also create the
|
||||
appropriate user settings in <literal>users.users</literal> in the
|
||||
NixOS configuration.
|
||||
'';
|
||||
example = {
|
||||
foo-dogsquared.settings = {
|
||||
extraGroups = [ "wheel" "audio" "libvirtd" ];
|
||||
|
@ -140,12 +140,14 @@ in {
|
||||
path = [ cfg.package ] ++ (with pkgs; [ coreutils ffmpeg ]);
|
||||
script = ''
|
||||
mkdir -p ${lib.escapeShellArg cfg.archivePath} \
|
||||
&& gallery-dl ${
|
||||
lib.concatStringsSep " " cfg.extraArgs
|
||||
} ${lib.concatStringsSep " " value.extraArgs} ${
|
||||
&& gallery-dl ${lib.concatStringsSep " " cfg.extraArgs} ${
|
||||
lib.concatStringsSep " " value.extraArgs
|
||||
} ${
|
||||
lib.optionalString (cfg.settings != null)
|
||||
"--config ${settingsFormatFile}"
|
||||
} --directory ${lib.escapeShellArg cfg.archivePath} ${lib.escapeShellArgs value.urls}
|
||||
} --directory ${lib.escapeShellArg cfg.archivePath} ${
|
||||
lib.escapeShellArgs value.urls
|
||||
}
|
||||
'';
|
||||
startAt = value.startAt;
|
||||
}) cfg.jobs;
|
||||
|
Loading…
Reference in New Issue
Block a user