chore: reformat codebase

This commit is contained in:
Gabriel Arazas 2022-11-19 11:05:31 +08:00
parent 5ea8fcb0cf
commit 3a7816a901
26 changed files with 480 additions and 412 deletions

View File

@ -3,7 +3,8 @@
let
lib' = pkgs.lib.extend (final: prev:
import ./lib { lib = prev; } // import ./lib/private.nix { lib = final; });
in {
in
{
lib = import ./lib { lib = pkgs.lib; };
modules = lib'.importModules (lib'.filesToAttr ./modules/nixos);
overlays.foo-dogsquared-pkgs = final: prev: import ./pkgs { pkgs = prev; };

View File

@ -395,7 +395,8 @@
# Take note for automatically imported nodes, various options should be
# overridden in the deploy utility considering that most have only
# certain values and likely not work if run with the intended value.
deploy.nodes = (lib'.mapAttrs' (name: value:
deploy.nodes = (lib'.mapAttrs'
(name: value:
lib'.nameValuePair name {
hostname = name;
profiles.system = {
@ -403,7 +404,8 @@
user = "root";
path = inputs.deploy.lib.${defaultSystem}.activate.nixos value;
};
}) self.nixosConfigurations);
})
self.nixosConfigurations);
# How to make yourself slightly saner than before. So far the main checks
# are for deploy nodes.

View File

@ -31,7 +31,8 @@ rec {
collect = file: type: {
name = lib.removeSuffix ".nix" file;
value = let path = dirPath + "/${file}";
value =
let path = dirPath + "/${file}";
in if (type == "regular")
|| (type == "directory" && lib.pathExists (path + "/default.nix")) then
path
@ -40,7 +41,8 @@ rec {
};
files = lib.filterAttrs isModule (builtins.readDir dirPath);
in lib.filterAttrs (name: value: value != { })
in
lib.filterAttrs (name: value: value != { })
(lib.mapAttrs' collect files);
/* Collect all modules (results from `filesToAttr`) into a list.

View File

@ -14,7 +14,8 @@ rec {
# TODO: Effectively override the option.
# We assume all users set with this module are normal users.
absoluteOverrides = { isNormalUser = true; };
in {
in
{
home-manager.users."${user}" = { ... }: {
imports = [ (getUser "home-manager" user) ];
};
@ -32,15 +33,18 @@ rec {
userList = lib.attrNames users';
nonExistentUsers = lib.filter (name: !lib.elem name userList) users;
in lib.trivial.throwIfNot ((lib.length nonExistentUsers) == 0)
in
lib.trivial.throwIfNot ((lib.length nonExistentUsers) == 0)
"there are no users ${lib.concatMapStringsSep ", " (u: "'${u}'") nonExistentUsers} from ${type}"
(r: r) users';
(r: r)
users';
getUser = type: user:
lib.getAttr user (getUsers type [ user ]);
# Import modules with a set blocklist.
importModules = attrs: let
importModules = attrs:
let
blocklist = [
# The modules under this attribute are often incomplete and needing
# very specific requirements that is 99% going to be absent from the

View File

@ -15,9 +15,11 @@ let
# Some plugins may be packaged ala-busybox with multiple plugins coming from
# the same binary. Similar reasons as to why we don't want to rewrite
# symlinks with the main package.
plugins = lib.map (p: p.overrideAttrs (prev: {
plugins = lib.map
(p: p.overrideAttrs (prev: {
dontRewriteSymlinks = true;
})) cfg.plugins;
}))
cfg.plugins;
# Plugins and scripts are assumed to be packaged at
# `$out/share/pop-launcher`.

View File

@ -40,7 +40,8 @@ let
};
};
};
in {
in
{
options.services.archivebox = {
enable = lib.mkEnableOption "Archivebox service";
@ -92,10 +93,12 @@ in {
};
};
config = let
config =
let
pkgSet = [ pkgs.archivebox ] ++ (lib.optionals cfg.withDependencies
(with pkgs; [ chromium nodejs_latest wget curl youtube-dl ]));
in lib.mkIf cfg.enable {
in
lib.mkIf cfg.enable {
assertions = [
(lib.hm.assertions.assertPlatform "services.archivebox" pkgs
lib.platforms.linux)
@ -104,7 +107,8 @@ in {
home.packages = pkgSet;
systemd.user.services = lib.mkMerge [
(lib.mapAttrs' (name: value:
(lib.mapAttrs'
(name: value:
lib.nameValuePair (jobUnitName name) {
Unit = {
Description =
@ -113,7 +117,8 @@ in {
Documentation = [ "https://docs.archivebox.io/" ];
};
Service = let
Service =
let
scriptName = "archivebox-job-${config.home.username}-${name}";
script = pkgs.writeShellApplication {
name = scriptName;
@ -125,11 +130,13 @@ in {
| archivebox add ${lib.concatStringsSep " " value.extraArgs}
'';
};
in {
in
{
ExecStart = "${script}/bin/${scriptName}";
WorkingDirectory = cfg.archivePath;
};
}) cfg.jobs)
})
cfg.jobs)
(lib.mkIf cfg.webserver.enable {
archivebox-server = {
@ -152,7 +159,8 @@ in {
})
];
systemd.user.timers = lib.mapAttrs' (name: value:
systemd.user.timers = lib.mapAttrs'
(name: value:
lib.nameValuePair (jobUnitName name) {
Unit = {
Description = "Archivebox additions for ${cfg.archivePath}";
@ -167,6 +175,7 @@ in {
};
Install.WantedBy = [ "timers.target" ];
}) cfg.jobs;
})
cfg.jobs;
};
}

View File

@ -47,7 +47,8 @@ let
"thunderbird.passwords"
"thunderbird.sessionjson"
];
in {
in
{
options.services.bleachbit = {
enable = lib.mkEnableOption "automated cleanup with Bleachbit";
startAt = lib.mkOption {

View File

@ -82,7 +82,8 @@ let
};
};
};
in {
in
{
options.services.gallery-dl = {
enable = lib.mkEnableOption "archiving services with gallery-dl";
@ -163,7 +164,8 @@ in {
config = lib.mkIf cfg.enable {
home.packages = [ cfg.package ];
systemd.user.services = lib.mapAttrs' (name: value:
systemd.user.services = lib.mapAttrs'
(name: value:
lib.nameValuePair (jobUnitName name) {
Unit = {
Description = "gallery-dl archive job for group '${name}'";
@ -171,7 +173,8 @@ in {
Documentation = "man:gallery-dl(1)";
};
Service.ExecStart = let
Service.ExecStart =
let
scriptName = "gallery-dl-service-${config.home.username}-${name}";
jobSpecificSettingsFile =
settingsFormat.generate "gallery-dl-service-job-${name}-settings"
@ -187,10 +190,13 @@ in {
"--config ${jobSpecificSettingsFile}"
} --destination ${cfg.archivePath} ${lib.escapeShellArgs value.urls}
'';
in "${archiveScript}/bin/${scriptName}";
}) cfg.jobs;
in
"${archiveScript}/bin/${scriptName}";
})
cfg.jobs;
systemd.user.timers = lib.mapAttrs' (name: value:
systemd.user.timers = lib.mapAttrs'
(name: value:
lib.nameValuePair (jobUnitName name) {
Unit = {
Description = "gallery-dl archive job for group '${name}'";
@ -204,6 +210,7 @@ in {
};
Install.WantedBy = [ "timers.target" ];
}) cfg.jobs;
})
cfg.jobs;
};
}

View File

@ -5,7 +5,8 @@ let
toPloverINI = with lib;
generators.toINI {
mkKeyValue = generators.mkKeyValueDefault {
mkKeyValue = generators.mkKeyValueDefault
{
mkValueString = v:
if v == true then
"True"
@ -22,7 +23,8 @@ let
};
settingsFormat = ploverIniFormat { };
in {
in
{
options.services.plover = {
enable = lib.mkEnableOption "Plover stenography engine service";

View File

@ -63,7 +63,8 @@ let
};
};
};
in {
in
{
options.services.yt-dlp = {
enable = lib.mkEnableOption "archiving service with yt-dlp";
@ -135,7 +136,8 @@ in {
};
config = lib.mkIf cfg.enable {
systemd.user.services = lib.mapAttrs' (name: value:
systemd.user.services = lib.mapAttrs'
(name: value:
lib.nameValuePair (jobUnitName name) {
Unit = {
Description = "yt-dlp archive job for group '${name}'";
@ -149,7 +151,8 @@ in {
lib.escapeShellArg cfg.archivePath
}"
'';
ExecStart = let
ExecStart =
let
scriptName =
"yt-dlp-archive-service-${config.home.username}-${name}";
jobLevelArgs = lib.escapeShellArgs value.extraArgs;
@ -158,13 +161,16 @@ in {
${cfg.package}/bin/yt-dlp ${serviceLevelArgs} ${jobLevelArgs} \
${urls} --paths ${lib.escapeShellArg cfg.archivePath}
'';
in "${archiveScript}/bin/${scriptName}";
in
"${archiveScript}/bin/${scriptName}";
StandardOutput = "journal";
StandardError = "journal";
};
}) cfg.jobs;
})
cfg.jobs;
systemd.user.timers = lib.mapAttrs' (name: value:
systemd.user.timers = lib.mapAttrs'
(name: value:
lib.nameValuePair (jobUnitName name) {
Unit = {
Description = "yt-dlp archive job for group '${name}'";
@ -178,6 +184,7 @@ in {
};
Install.WantedBy = [ "timers.target" ];
}) cfg.jobs;
})
cfg.jobs;
};
}

View File

@ -2,7 +2,8 @@
let
cfg = config.profiles.filesystem;
in {
in
{
options.profiles.filesystem = {
archive.enable = lib.mkOption {
type = lib.types.bool;

View File

@ -217,7 +217,8 @@ in {
};
dates = "weekly";
flags = [
"--update-input" "nixpkgs"
"--update-input"
"nixpkgs"
"--commit-lock-file"
"--no-write-lock-file"
];

View File

@ -6,7 +6,8 @@ let
cardboardPackage = cfg.package.overrideAttrs (super: rec {
passthru.providedSessions = [ "cardboard" ];
});
in {
in
{
options.programs.cardboard-wm = {
enable =
lib.mkEnableOption "Cardboard, a scrollable tiling Wayland compositor";

View File

@ -4,7 +4,8 @@ let
cfg = config.programs.kiwmi;
package = cfg.package.override { extraOptions = cfg.extraOptions; };
in {
in
{
options.programs.kiwmi = {
enable = lib.mkEnableOption "Kiwmi, a fully programmable Wayland compositor";
package = lib.mkOption {

View File

@ -14,9 +14,11 @@ let
# Some plugins may be packaged busybox-style with multiple plugins in one
# binary.
plugins = lib.lists.map (p: p.overrideAttrs (prev: {
plugins = lib.lists.map
(p: p.overrideAttrs (prev: {
dontRewriteSymlinks = true;
})) cfg.plugins;
}))
cfg.plugins;
# Plugins and scripts are assumed to be packaged at
# `$out/share/pop-launcher`.

View File

@ -2,7 +2,8 @@
let
cfg = config.programs.wezterm;
in {
in
{
options.programs.wezterm = {
enable = lib.mkEnableOption "Wezterm terminal emulator";
package = lib.mkOption {

View File

@ -42,7 +42,8 @@ let
persistent = lib.mkEnableOption "service persistence for this job";
};
};
in {
in
{
options.services.archivebox = {
enable = lib.mkEnableOption "Archivebox service";
@ -96,12 +97,15 @@ in {
};
};
config = let
config =
let
pkgSet = [ pkgs.archivebox ] ++ (lib.optionals cfg.withDependencies
(with pkgs; [ chromium nodejs_latest wget curl youtube-dl ]));
in lib.mkIf cfg.enable {
in
lib.mkIf cfg.enable {
systemd.services = lib.mkMerge [
(lib.mapAttrs' (name: value:
(lib.mapAttrs'
(name: value:
lib.nameValuePair (jobUnitName name) {
description =
"Archivebox archive group '${name}' for ${cfg.archivePath}";
@ -131,7 +135,8 @@ in {
SystemCallErrorNumber = "EPERM";
WorkingDirectory = cfg.archivePath;
};
}) cfg.jobs)
})
cfg.jobs)
(lib.mkIf cfg.webserver.enable {
archivebox-server = {
@ -165,7 +170,8 @@ in {
})
];
systemd.timers = lib.mapAttrs' (name: value:
systemd.timers = lib.mapAttrs'
(name: value:
lib.nameValuePair (jobUnitName name) {
description =
"Archivebox archive group '${name}' for ${cfg.archivePath}";
@ -177,6 +183,7 @@ in {
RandomizedDelaySec = 120;
};
wantedBy = [ "timers.target" ];
}) cfg.jobs;
})
cfg.jobs;
};
}

View File

@ -80,7 +80,8 @@ let
};
};
};
in {
in
{
options.services.gallery-dl = {
enable = lib.mkEnableOption "archiving services with gallery-dl";
@ -157,7 +158,8 @@ in {
};
config = lib.mkIf cfg.enable {
systemd.services = lib.mapAttrs' (name: value:
systemd.services = lib.mapAttrs'
(name: value:
lib.nameValuePair (jobUnitName name) {
wantedBy = [ "multi-user.target" ];
description = "gallery-dl archive job for group '${name}'";
@ -177,11 +179,13 @@ in {
# `--config` option. This means that it will cascade resultings
# settings from `extraArgs` if there's any related option that is
# given like another `--config` for example.
script = let
script =
let
jobLevelSettingsFile =
settingsFormat.generate "gallery-dl-job-${name}-settings"
value.settings;
in ''
in
''
gallery-dl ${lib.escapeShellArgs cfg.extraArgs} ${
lib.optionalString (cfg.settings != null)
"--config ${settingsFormatFile}"
@ -207,14 +211,17 @@ in {
SystemCallFilter = "@system-service";
SystemCallErrorNumber = "EPERM";
};
}) cfg.jobs;
})
cfg.jobs;
systemd.timers = lib.mapAttrs' (name: value:
systemd.timers = lib.mapAttrs'
(name: value:
lib.nameValuePair (jobUnitName name) {
timerConfig = {
Persistent = value.persistent;
RandomizedDelaySec = "2min";
};
}) cfg.jobs;
})
cfg.jobs;
};
}

View File

@ -62,7 +62,8 @@ let
};
};
};
in {
in
{
options.services.yt-dlp = {
enable = lib.mkEnableOption "archiving service with yt-dlp";
@ -130,7 +131,9 @@ in {
# There's no need to go to the working directory since yt-dlp has the
# `--paths` flag.
config = lib.mkIf cfg.enable {
systemd.services = lib.mapAttrs' (name: value: let
systemd.services = lib.mapAttrs'
(name: value:
let
jobLevelArgs = lib.escapeShellArgs value.extraArgs;
in
lib.nameValuePair (jobUnitName name) {
@ -163,14 +166,17 @@ in {
SystemCallFilter = "@system-service";
SystemCallErrorNumber = "EPERM";
};
}) cfg.jobs;
})
cfg.jobs;
systemd.timers = lib.mapAttrs' (name: value:
systemd.timers = lib.mapAttrs'
(name: value:
lib.nameValuePair (jobUnitName name) {
timerConfig = {
Persistent = value.persistent;
RandomizedDelaySec = "2min";
};
}) cfg.jobs;
})
cfg.jobs;
};
}

View File

@ -2,7 +2,8 @@
let
cfg = config.workflows.workflows.knome;
in {
in
{
options.workflows.workflows.knome.enable = lib.mkEnableOption "KNOME, an attempt to bring as much GNOME to KDE Plasma";
config = lib.mkIf cfg.enable {

View File

@ -1,8 +1,10 @@
{ lib, callPackage, newScope, python3Packages, ... }:
lib.fix' (self: let
lib.fix' (self:
let
callPackage = newScope self;
in lib.recurseIntoAttrs {
in
lib.recurseIntoAttrs {
attrs-strict = callPackage ./attrs-strict.nix { inherit python3Packages; };
aiohttp-utils = callPackage ./aiohttp-utils.nix { inherit python3Packages; };

View File

@ -24,7 +24,8 @@ let
musicDir = config.xdg.userDirs.music;
playlistsDir = "${musicDir}/playlists";
in {
in
{
home.packages = with pkgs; [
songrec
vscodium-fhs