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 let
lib' = pkgs.lib.extend (final: prev: lib' = pkgs.lib.extend (final: prev:
import ./lib { lib = prev; } // import ./lib/private.nix { lib = final; }); import ./lib { lib = prev; } // import ./lib/private.nix { lib = final; });
in { in
{
lib = import ./lib { lib = pkgs.lib; }; lib = import ./lib { lib = pkgs.lib; };
modules = lib'.importModules (lib'.filesToAttr ./modules/nixos); modules = lib'.importModules (lib'.filesToAttr ./modules/nixos);
overlays.foo-dogsquared-pkgs = final: prev: import ./pkgs { pkgs = prev; }; overlays.foo-dogsquared-pkgs = final: prev: import ./pkgs { pkgs = prev; };

View File

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

View File

@ -31,17 +31,19 @@ rec {
collect = file: type: { collect = file: type: {
name = lib.removeSuffix ".nix" file; name = lib.removeSuffix ".nix" file;
value = let path = dirPath + "/${file}"; value =
in if (type == "regular") let path = dirPath + "/${file}";
|| (type == "directory" && lib.pathExists (path + "/default.nix")) then in if (type == "regular")
path || (type == "directory" && lib.pathExists (path + "/default.nix")) then
else path
filesToAttr path; else
filesToAttr path;
}; };
files = lib.filterAttrs isModule (builtins.readDir dirPath); files = lib.filterAttrs isModule (builtins.readDir dirPath);
in lib.filterAttrs (name: value: value != { }) in
(lib.mapAttrs' collect files); lib.filterAttrs (name: value: value != { })
(lib.mapAttrs' collect files);
/* Collect all modules (results from `filesToAttr`) into a list. /* Collect all modules (results from `filesToAttr`) into a list.
@ -71,5 +73,5 @@ rec {
*/ */
countAttrs = pred: attrs: countAttrs = pred: attrs:
lib.count (attr: pred attr.name attr.value) lib.count (attr: pred attr.name attr.value)
(lib.mapAttrsToList lib.nameValuePair attrs); (lib.mapAttrsToList lib.nameValuePair attrs);
} }

View File

@ -14,12 +14,13 @@ rec {
# TODO: Effectively override the option. # TODO: Effectively override the option.
# We assume all users set with this module are normal users. # We assume all users set with this module are normal users.
absoluteOverrides = { isNormalUser = true; }; absoluteOverrides = { isNormalUser = true; };
in { in
{
home-manager.users."${user}" = { ... }: { home-manager.users."${user}" = { ... }: {
imports = [ (getUser "home-manager" user) ]; imports = [ (getUser "home-manager" user) ];
}; };
users.users."${user}" = defaultUserConfig // settings // absoluteOverrides; users.users."${user}" = defaultUserConfig // settings // absoluteOverrides;
}; };
getSecret = path: ../secrets/${path}; getSecret = path: ../secrets/${path};
@ -32,25 +33,28 @@ rec {
userList = lib.attrNames users'; userList = lib.attrNames users';
nonExistentUsers = lib.filter (name: !lib.elem name userList) 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}" "there are no users ${lib.concatMapStringsSep ", " (u: "'${u}'") nonExistentUsers} from ${type}"
(r: r) users'; (r: r)
users';
getUser = type: user: getUser = type: user:
lib.getAttr user (getUsers type [ user ]); lib.getAttr user (getUsers type [ user ]);
# Import modules with a set blocklist. # Import modules with a set blocklist.
importModules = attrs: let importModules = attrs:
blocklist = [ let
# The modules under this attribute are often incomplete and needing blocklist = [
# very specific requirements that is 99% going to be absent from the # The modules under this attribute are often incomplete and needing
# outside so we're not going to export it. # very specific requirements that is 99% going to be absent from the
"tasks" # outside so we're not going to export it.
"tasks"
# Profiles are often specific to this project so there's not much point # Profiles are often specific to this project so there's not much point
# in exporting these. # in exporting these.
"profiles" "profiles"
]; ];
in in
lib.filterAttrs (n: v: !lib.elem n blocklist) (lib.mapAttrsRecursive (_: path: import path) attrs); lib.filterAttrs (n: v: !lib.elem n blocklist) (lib.mapAttrsRecursive (_: path: import path) attrs);
} }

View File

@ -15,9 +15,11 @@ let
# Some plugins may be packaged ala-busybox with multiple plugins coming from # 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 # the same binary. Similar reasons as to why we don't want to rewrite
# symlinks with the main package. # symlinks with the main package.
plugins = lib.map (p: p.overrideAttrs (prev: { plugins = lib.map
dontRewriteSymlinks = true; (p: p.overrideAttrs (prev: {
})) cfg.plugins; dontRewriteSymlinks = true;
}))
cfg.plugins;
# Plugins and scripts are assumed to be packaged at # Plugins and scripts are assumed to be packaged at
# `$out/share/pop-launcher`. # `$out/share/pop-launcher`.
@ -57,7 +59,7 @@ in
List of packages containing Pop launcher plugins and scripts to be List of packages containing Pop launcher plugins and scripts to be
installed as system-wide plugins. installed as system-wide plugins.
''; '';
default = []; default = [ ];
defaultText = "[]"; defaultText = "[]";
example = lib.literalExpression '' example = lib.literalExpression ''
with pkgs; [ with pkgs; [

View File

@ -40,7 +40,8 @@ let
}; };
}; };
}; };
in { in
{
options.services.archivebox = { options.services.archivebox = {
enable = lib.mkEnableOption "Archivebox service"; enable = lib.mkEnableOption "Archivebox service";
@ -92,81 +93,89 @@ in {
}; };
}; };
config = let config =
pkgSet = [ pkgs.archivebox ] ++ (lib.optionals cfg.withDependencies let
(with pkgs; [ chromium nodejs_latest wget curl youtube-dl ])); pkgSet = [ pkgs.archivebox ] ++ (lib.optionals cfg.withDependencies
in lib.mkIf cfg.enable { (with pkgs; [ chromium nodejs_latest wget curl youtube-dl ]));
assertions = [ in
(lib.hm.assertions.assertPlatform "services.archivebox" pkgs lib.mkIf cfg.enable {
lib.platforms.linux) assertions = [
]; (lib.hm.assertions.assertPlatform "services.archivebox" pkgs
lib.platforms.linux)
];
home.packages = pkgSet; home.packages = pkgSet;
systemd.user.services = lib.mkMerge [ systemd.user.services = lib.mkMerge [
(lib.mapAttrs' (name: value: (lib.mapAttrs'
lib.nameValuePair (jobUnitName name) { (name: value:
Unit = { lib.nameValuePair (jobUnitName name) {
Description = Unit = {
"Archivebox archive group '${name}' for ${cfg.archivePath}"; Description =
After = "network.target"; "Archivebox archive group '${name}' for ${cfg.archivePath}";
Documentation = [ "https://docs.archivebox.io/" ]; After = "network.target";
}; Documentation = [ "https://docs.archivebox.io/" ];
};
Service = let Service =
scriptName = "archivebox-job-${config.home.username}-${name}"; let
script = pkgs.writeShellApplication { scriptName = "archivebox-job-${config.home.username}-${name}";
name = scriptName; script = pkgs.writeShellApplication {
runtimeInputs = with pkgs; name = scriptName;
[ ripgrep coreutils ] ++ pkgSet runtimeInputs = with pkgs;
++ [ config.programs.git.package ]; [ ripgrep coreutils ] ++ pkgSet
text = '' ++ [ config.programs.git.package ];
echo "${lib.concatStringsSep "\n" value.links}" \ text = ''
| archivebox add ${lib.concatStringsSep " " value.extraArgs} echo "${lib.concatStringsSep "\n" value.links}" \
''; | archivebox add ${lib.concatStringsSep " " value.extraArgs}
'';
};
in
{
ExecStart = "${script}/bin/${scriptName}";
WorkingDirectory = cfg.archivePath;
};
})
cfg.jobs)
(lib.mkIf cfg.webserver.enable {
archivebox-server = {
Unit = {
Description = "Archivebox server for ${cfg.archivePath}";
After = "network.target";
Documentation = [ "https://docs.archivebox.io/" ];
}; };
in {
ExecStart = "${script}/bin/${scriptName}";
WorkingDirectory = cfg.archivePath;
};
}) cfg.jobs)
(lib.mkIf cfg.webserver.enable { Install.WantedBy = [ "graphical-session.target" ];
archivebox-server = {
Unit = {
Description = "Archivebox server for ${cfg.archivePath}";
After = "network.target";
Documentation = [ "https://docs.archivebox.io/" ];
};
Install.WantedBy = [ "graphical-session.target" ]; Service = {
ExecStart = "${pkgs.archivebox}/bin/archivebox server localhost:${
Service = {
ExecStart = "${pkgs.archivebox}/bin/archivebox server localhost:${
toString cfg.webserver.port toString cfg.webserver.port
}"; }";
WorkingDirectory = cfg.archivePath; WorkingDirectory = cfg.archivePath;
Restart = "on-failure"; Restart = "on-failure";
};
}; };
}; })
}) ];
];
systemd.user.timers = lib.mapAttrs' (name: value: systemd.user.timers = lib.mapAttrs'
lib.nameValuePair (jobUnitName name) { (name: value:
Unit = { lib.nameValuePair (jobUnitName name) {
Description = "Archivebox additions for ${cfg.archivePath}"; Unit = {
After = "network.target"; Description = "Archivebox additions for ${cfg.archivePath}";
Documentation = [ "https://docs.archivebox.io/" ]; After = "network.target";
}; Documentation = [ "https://docs.archivebox.io/" ];
};
Timer = { Timer = {
Persistent = true; Persistent = true;
OnCalendar = value.startAt; OnCalendar = value.startAt;
RandomizedDelaySec = 120; RandomizedDelaySec = 120;
}; };
Install.WantedBy = [ "timers.target" ]; Install.WantedBy = [ "timers.target" ];
}) cfg.jobs; })
}; cfg.jobs;
};
} }

View File

@ -47,7 +47,8 @@ let
"thunderbird.passwords" "thunderbird.passwords"
"thunderbird.sessionjson" "thunderbird.sessionjson"
]; ];
in { in
{
options.services.bleachbit = { options.services.bleachbit = {
enable = lib.mkEnableOption "automated cleanup with Bleachbit"; enable = lib.mkEnableOption "automated cleanup with Bleachbit";
startAt = lib.mkOption { startAt = lib.mkOption {
@ -81,7 +82,7 @@ in {
cleaners = lib.mkOption { cleaners = lib.mkOption {
type = with lib.types; listOf str; type = with lib.types; listOf str;
description = "List of cleaners to be used when cleaning."; description = "List of cleaners to be used when cleaning.";
default = []; default = [ ];
example = lib.literalExpression '' example = lib.literalExpression ''
[ [
"bash.history" "bash.history"
@ -111,7 +112,7 @@ in {
}; };
Service.ExecStart = '' Service.ExecStart = ''
${cfg.package}/bin/bleachbit --clean ${lib.escapeShellArgs cleaners} ${cfg.package}/bin/bleachbit --clean ${lib.escapeShellArgs cleaners}
''; '';
}; };

View File

@ -8,7 +8,7 @@ let
settingsFormat = pkgs.formats.json { }; settingsFormat = pkgs.formats.json { };
settingsFormatFile = settingsFormatFile =
settingsFormat.generate "gallery-dl-service-config-${config.home.username}" settingsFormat.generate "gallery-dl-service-config-${config.home.username}"
cfg.settings; cfg.settings;
jobType = { name, config, options, ... }: { jobType = { name, config, options, ... }: {
options = { options = {
@ -82,7 +82,8 @@ let
}; };
}; };
}; };
in { in
{
options.services.gallery-dl = { options.services.gallery-dl = {
enable = lib.mkEnableOption "archiving services with gallery-dl"; enable = lib.mkEnableOption "archiving services with gallery-dl";
@ -163,47 +164,53 @@ in {
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
home.packages = [ cfg.package ]; home.packages = [ cfg.package ];
systemd.user.services = lib.mapAttrs' (name: value: systemd.user.services = lib.mapAttrs'
lib.nameValuePair (jobUnitName name) { (name: value:
Unit = { lib.nameValuePair (jobUnitName name) {
Description = "gallery-dl archive job for group '${name}'"; Unit = {
After = [ "default.target" ]; Description = "gallery-dl archive job for group '${name}'";
Documentation = "man:gallery-dl(1)"; After = [ "default.target" ];
}; Documentation = "man:gallery-dl(1)";
};
Service.ExecStart = let Service.ExecStart =
scriptName = "gallery-dl-service-${config.home.username}-${name}"; let
jobSpecificSettingsFile = scriptName = "gallery-dl-service-${config.home.username}-${name}";
settingsFormat.generate "gallery-dl-service-job-${name}-settings" jobSpecificSettingsFile =
value.settings; settingsFormat.generate "gallery-dl-service-job-${name}-settings"
archiveScript = pkgs.writeShellScriptBin scriptName '' value.settings;
${cfg.package}/bin/gallery-dl ${ archiveScript = pkgs.writeShellScriptBin scriptName ''
lib.escapeShellArgs cfg.extraArgs ${cfg.package}/bin/gallery-dl ${
} ${ lib.escapeShellArgs cfg.extraArgs
lib.optionalString (cfg.settings != null) } ${
"--config ${settingsFormatFile}" lib.optionalString (cfg.settings != null)
} ${lib.escapeShellArgs value.extraArgs} ${ "--config ${settingsFormatFile}"
lib.optionalString (value.settings != null) } ${lib.escapeShellArgs value.extraArgs} ${
"--config ${jobSpecificSettingsFile}" lib.optionalString (value.settings != null)
} --destination ${cfg.archivePath} ${lib.escapeShellArgs value.urls} "--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'
lib.nameValuePair (jobUnitName name) { (name: value:
Unit = { lib.nameValuePair (jobUnitName name) {
Description = "gallery-dl archive job for group '${name}'"; Unit = {
Documentation = "man:gallery-dl(1)"; Description = "gallery-dl archive job for group '${name}'";
}; Documentation = "man:gallery-dl(1)";
};
Timer = { Timer = {
OnCalendar = value.startAt; OnCalendar = value.startAt;
Persistent = value.persistent; Persistent = value.persistent;
RandomizedDelaySec = "2min"; RandomizedDelaySec = "2min";
}; };
Install.WantedBy = [ "timers.target" ]; Install.WantedBy = [ "timers.target" ];
}) cfg.jobs; })
cfg.jobs;
}; };
} }

View File

@ -5,24 +5,26 @@ let
toPloverINI = with lib; toPloverINI = with lib;
generators.toINI { generators.toINI {
mkKeyValue = generators.mkKeyValueDefault { mkKeyValue = generators.mkKeyValueDefault
mkValueString = v: {
if v == true then mkValueString = v:
"True" if v == true then
else if v == false then "True"
"False" else if v == false then
else "False"
generators.mkValueStringDefault { } v; else
} " = "; generators.mkValueStringDefault { } v;
} " = ";
}; };
ploverIniFormat = { }: { ploverIniFormat = {}: {
type = (pkgs.formats.ini { }).type; type = (pkgs.formats.ini { }).type;
generate = name: value: pkgs.writeText name (toPloverINI value); generate = name: value: pkgs.writeText name (toPloverINI value);
}; };
settingsFormat = ploverIniFormat { }; settingsFormat = ploverIniFormat { };
in { in
{
options.services.plover = { options.services.plover = {
enable = lib.mkEnableOption "Plover stenography engine service"; enable = lib.mkEnableOption "Plover stenography engine service";
@ -74,7 +76,7 @@ in {
xdg.configFile."plover/plover.cfg".source = xdg.configFile."plover/plover.cfg".source =
settingsFormat.generate "plover-config-${config.home.username}" settingsFormat.generate "plover-config-${config.home.username}"
cfg.settings; cfg.settings;
systemd.user.services.plover = { systemd.user.services.plover = {
Unit = { Unit = {

View File

@ -63,7 +63,8 @@ let
}; };
}; };
}; };
in { in
{
options.services.yt-dlp = { options.services.yt-dlp = {
enable = lib.mkEnableOption "archiving service with yt-dlp"; enable = lib.mkEnableOption "archiving service with yt-dlp";
@ -135,49 +136,55 @@ in {
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
systemd.user.services = lib.mapAttrs' (name: value: systemd.user.services = lib.mapAttrs'
lib.nameValuePair (jobUnitName name) { (name: value:
Unit = { lib.nameValuePair (jobUnitName name) {
Description = "yt-dlp archive job for group '${name}'"; Unit = {
After = [ "default.target" ]; Description = "yt-dlp archive job for group '${name}'";
Documentation = "man:yt-dlp(1)"; After = [ "default.target" ];
}; Documentation = "man:yt-dlp(1)";
};
Service = { Service = {
ExecStartPre = '' ExecStartPre = ''
${pkgs.bash}/bin/bash -c "${pkgs.coreutils}/bin/mkdir -p ${ ${pkgs.bash}/bin/bash -c "${pkgs.coreutils}/bin/mkdir -p ${
lib.escapeShellArg cfg.archivePath lib.escapeShellArg cfg.archivePath
}" }"
'';
ExecStart = let
scriptName =
"yt-dlp-archive-service-${config.home.username}-${name}";
jobLevelArgs = lib.escapeShellArgs value.extraArgs;
urls = lib.escapeShellArgs urls;
archiveScript = pkgs.writeShellScriptBin scriptName ''
${cfg.package}/bin/yt-dlp ${serviceLevelArgs} ${jobLevelArgs} \
${urls} --paths ${lib.escapeShellArg cfg.archivePath}
''; '';
in "${archiveScript}/bin/${scriptName}"; ExecStart =
StandardOutput = "journal"; let
StandardError = "journal"; scriptName =
}; "yt-dlp-archive-service-${config.home.username}-${name}";
}) cfg.jobs; jobLevelArgs = lib.escapeShellArgs value.extraArgs;
urls = lib.escapeShellArgs urls;
archiveScript = pkgs.writeShellScriptBin scriptName ''
${cfg.package}/bin/yt-dlp ${serviceLevelArgs} ${jobLevelArgs} \
${urls} --paths ${lib.escapeShellArg cfg.archivePath}
'';
in
"${archiveScript}/bin/${scriptName}";
StandardOutput = "journal";
StandardError = "journal";
};
})
cfg.jobs;
systemd.user.timers = lib.mapAttrs' (name: value: systemd.user.timers = lib.mapAttrs'
lib.nameValuePair (jobUnitName name) { (name: value:
Unit = { lib.nameValuePair (jobUnitName name) {
Description = "yt-dlp archive job for group '${name}'"; Unit = {
Documentation = "man:yt-dlp(1)"; Description = "yt-dlp archive job for group '${name}'";
}; Documentation = "man:yt-dlp(1)";
};
Timer = { Timer = {
OnCalendar = value.startAt; OnCalendar = value.startAt;
RandomizedDelaySec = "2min"; RandomizedDelaySec = "2min";
Persistent = value.persistent; Persistent = value.persistent;
}; };
Install.WantedBy = [ "timers.target" ]; Install.WantedBy = [ "timers.target" ];
}) cfg.jobs; })
cfg.jobs;
}; };
} }

View File

@ -47,7 +47,7 @@ in {
# Also, this config is based from this tip. # Also, this config is based from this tip.
# https://lists.reproducible-builds.org/pipermail/diffoscope/2016-April/000193.html # https://lists.reproducible-builds.org/pipermail/diffoscope/2016-April/000193.html
config.difftool."diffoscope".cmd = '' config.difftool."diffoscope".cmd = ''
"if [ $LOCAL = /dev/null ]; then diffoscope --new-file $REMOTE; else diffoscope $LOCAL $REMOTE; fi" "if [ $LOCAL = /dev/null ]; then diffoscope --new-file $REMOTE; else diffoscope $LOCAL $REMOTE; fi"
''; '';
config.difftool."diffoscope-html".cmd = '' config.difftool."diffoscope-html".cmd = ''
@ -87,15 +87,15 @@ in {
moreutils # Less is more but more utilities, the merrier. moreutils # Less is more but more utilities, the merrier.
valgrind # Making sure your applications don't pee as much. valgrind # Making sure your applications don't pee as much.
] ]
# Finally, a local environment for testing out GitHub workflows without # Finally, a local environment for testing out GitHub workflows without
# embarassing yourself pushing a bunch of commits. # embarassing yourself pushing a bunch of commits.
++ (lib.optional config.virtualisation.docker.enable pkgs.act) ++ (lib.optional config.virtualisation.docker.enable pkgs.act)
# Enable all of the gud things. # Enable all of the gud things.
++ (lib.optionals config.programs.git.enable [ ++ (lib.optionals config.programs.git.enable [
github-cli # Client for GitHub. github-cli # Client for GitHub.
hut # And one for Sourcehut. hut # And one for Sourcehut.
]); ]);
systemd.user.services.nix-upgrade-profile = { systemd.user.services.nix-upgrade-profile = {
description = '' description = ''

View File

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

View File

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

View File

@ -6,7 +6,8 @@ let
cardboardPackage = cfg.package.overrideAttrs (super: rec { cardboardPackage = cfg.package.overrideAttrs (super: rec {
passthru.providedSessions = [ "cardboard" ]; passthru.providedSessions = [ "cardboard" ];
}); });
in { in
{
options.programs.cardboard-wm = { options.programs.cardboard-wm = {
enable = enable =
lib.mkEnableOption "Cardboard, a scrollable tiling Wayland compositor"; lib.mkEnableOption "Cardboard, a scrollable tiling Wayland compositor";
@ -23,13 +24,13 @@ in {
extraOptions = lib.mkOption { extraOptions = lib.mkOption {
type = with lib.types; listOf str; type = with lib.types; listOf str;
default = []; default = [ ];
description = "Command-line arguments to be passed to Cardboard."; description = "Command-line arguments to be passed to Cardboard.";
}; };
extraPackages = lib.mkOption { extraPackages = lib.mkOption {
type = with lib.types; listOf package; type = with lib.types; listOf package;
default = []; default = [ ];
description = '' description = ''
Extra packages to be installed with this program. Extra packages to be installed with this program.
''; '';

View File

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

View File

@ -14,9 +14,11 @@ let
# Some plugins may be packaged busybox-style with multiple plugins in one # Some plugins may be packaged busybox-style with multiple plugins in one
# binary. # binary.
plugins = lib.lists.map (p: p.overrideAttrs (prev: { plugins = lib.lists.map
dontRewriteSymlinks = true; (p: p.overrideAttrs (prev: {
})) cfg.plugins; dontRewriteSymlinks = true;
}))
cfg.plugins;
# Plugins and scripts are assumed to be packaged at # Plugins and scripts are assumed to be packaged at
# `$out/share/pop-launcher`. # `$out/share/pop-launcher`.
@ -58,7 +60,7 @@ in
List of packages containing Pop launcher plugins and scripts to be List of packages containing Pop launcher plugins and scripts to be
installed as system-wide plugins. installed as system-wide plugins.
''; '';
default = []; default = [ ];
defaultText = "[]"; defaultText = "[]";
example = lib.literalExpression '' example = lib.literalExpression ''
with pkgs; [ with pkgs; [

View File

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

View File

@ -42,7 +42,8 @@ let
persistent = lib.mkEnableOption "service persistence for this job"; persistent = lib.mkEnableOption "service persistence for this job";
}; };
}; };
in { in
{
options.services.archivebox = { options.services.archivebox = {
enable = lib.mkEnableOption "Archivebox service"; enable = lib.mkEnableOption "Archivebox service";
@ -96,87 +97,93 @@ in {
}; };
}; };
config = let config =
pkgSet = [ pkgs.archivebox ] ++ (lib.optionals cfg.withDependencies let
(with pkgs; [ chromium nodejs_latest wget curl youtube-dl ])); pkgSet = [ pkgs.archivebox ] ++ (lib.optionals cfg.withDependencies
in lib.mkIf cfg.enable { (with pkgs; [ chromium nodejs_latest wget curl youtube-dl ]));
systemd.services = lib.mkMerge [ in
(lib.mapAttrs' (name: value: lib.mkIf cfg.enable {
lib.nameValuePair (jobUnitName name) { systemd.services = lib.mkMerge [
description = (lib.mapAttrs'
"Archivebox archive group '${name}' for ${cfg.archivePath}"; (name: value:
after = [ "network.target" ]; lib.nameValuePair (jobUnitName name) {
documentation = [ "https://docs.archivebox.io/" ]; description =
path = with pkgs; "Archivebox archive group '${name}' for ${cfg.archivePath}";
[ ripgrep coreutils ] ++ pkgSet ++ [ config.programs.git.package ]; after = [ "network.target" ];
preStart = '' documentation = [ "https://docs.archivebox.io/" ];
mkdir -p ${lib.escapeShellArg cfg.archivePath} path = with pkgs;
''; [ ripgrep coreutils ] ++ pkgSet ++ [ config.programs.git.package ];
script = '' preStart = ''
echo "${lib.concatStringsSep "\n" value.urls}" \ mkdir -p ${lib.escapeShellArg cfg.archivePath}
| archivebox add ${lib.concatStringsSep " " value.extraArgs} '';
''; script = ''
serviceConfig = { echo "${lib.concatStringsSep "\n" value.urls}" \
LockPersonality = true; | archivebox add ${lib.concatStringsSep " " value.extraArgs}
NoNewPrivileges = true; '';
PrivateTmp = true; serviceConfig = {
PrivateUsers = true; LockPersonality = true;
PrivateDevices = true; NoNewPrivileges = true;
ProtectControlGroups = true; PrivateTmp = true;
ProtectClock = true; PrivateUsers = true;
ProtectKernelLogs = true; PrivateDevices = true;
ProtectKernelModules = true; ProtectControlGroups = true;
ProtectKernelTunables = true; ProtectClock = true;
SystemCallFilter = "@system-service"; ProtectKernelLogs = true;
SystemCallErrorNumber = "EPERM"; ProtectKernelModules = true;
WorkingDirectory = cfg.archivePath; ProtectKernelTunables = true;
}; SystemCallFilter = "@system-service";
}) cfg.jobs) SystemCallErrorNumber = "EPERM";
WorkingDirectory = cfg.archivePath;
};
})
cfg.jobs)
(lib.mkIf cfg.webserver.enable { (lib.mkIf cfg.webserver.enable {
archivebox-server = { archivebox-server = {
description = "Archivebox server for ${cfg.archivePath}"; description = "Archivebox server for ${cfg.archivePath}";
after = [ "network.target" ]; after = [ "network.target" ];
documentation = [ "https://docs.archivebox.io/" ]; documentation = [ "https://docs.archivebox.io/" ];
wantedBy = [ "graphical-session.target" ]; wantedBy = [ "graphical-session.target" ];
preStart = '' preStart = ''
mkdir -p ${lib.escapeShellArg cfg.archivePath} mkdir -p ${lib.escapeShellArg cfg.archivePath}
''; '';
serviceConfig = { serviceConfig = {
ExecStart = "${pkgs.archivebox}/bin/archivebox server localhost:${ ExecStart = "${pkgs.archivebox}/bin/archivebox server localhost:${
toString cfg.webserver.port toString cfg.webserver.port
}"; }";
Restart = "on-failure"; Restart = "on-failure";
LockPersonality = true; LockPersonality = true;
NoNewPrivileges = true; NoNewPrivileges = true;
PrivateTmp = true; PrivateTmp = true;
PrivateUsers = true; PrivateUsers = true;
PrivateDevices = true; PrivateDevices = true;
ProtectControlGroups = true; ProtectControlGroups = true;
ProtectClock = true; ProtectClock = true;
ProtectKernelLogs = true; ProtectKernelLogs = true;
ProtectKernelModules = true; ProtectKernelModules = true;
ProtectKernelTunables = true; ProtectKernelTunables = true;
SystemCallFilter = "@system-service"; SystemCallFilter = "@system-service";
SystemCallErrorNumber = "EPERM"; SystemCallErrorNumber = "EPERM";
WorkingDirectory = cfg.archivePath; WorkingDirectory = cfg.archivePath;
};
}; };
}; })
}) ];
];
systemd.timers = lib.mapAttrs' (name: value: systemd.timers = lib.mapAttrs'
lib.nameValuePair (jobUnitName name) { (name: value:
description = lib.nameValuePair (jobUnitName name) {
"Archivebox archive group '${name}' for ${cfg.archivePath}"; description =
after = [ "network.target" ]; "Archivebox archive group '${name}' for ${cfg.archivePath}";
documentation = [ "https://docs.archivebox.io/" ]; after = [ "network.target" ];
timerConfig = { documentation = [ "https://docs.archivebox.io/" ];
Persistent = value.persistent; timerConfig = {
OnCalendar = value.startAt; Persistent = value.persistent;
RandomizedDelaySec = 120; OnCalendar = value.startAt;
}; RandomizedDelaySec = 120;
wantedBy = [ "timers.target" ]; };
}) cfg.jobs; wantedBy = [ "timers.target" ];
}; })
cfg.jobs;
};
} }

View File

@ -80,7 +80,8 @@ let
}; };
}; };
}; };
in { in
{
options.services.gallery-dl = { options.services.gallery-dl = {
enable = lib.mkEnableOption "archiving services with gallery-dl"; enable = lib.mkEnableOption "archiving services with gallery-dl";
@ -157,64 +158,70 @@ in {
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
systemd.services = lib.mapAttrs' (name: value: systemd.services = lib.mapAttrs'
lib.nameValuePair (jobUnitName name) { (name: value:
wantedBy = [ "multi-user.target" ]; lib.nameValuePair (jobUnitName name) {
description = "gallery-dl archive job for group '${name}'"; wantedBy = [ "multi-user.target" ];
documentation = [ "man:gallery-dl(1)" ]; description = "gallery-dl archive job for group '${name}'";
enable = true; documentation = [ "man:gallery-dl(1)" ];
path = with pkgs; [ brotli coreutils ffmpeg cfg.package ]; enable = true;
preStart = '' path = with pkgs; [ brotli coreutils ffmpeg cfg.package ];
mkdir -p ${lib.escapeShellArg cfg.archivePath} preStart = ''
''; mkdir -p ${lib.escapeShellArg cfg.archivePath}
'';
# Order matters here. We're letting service-level arguments and # Order matters here. We're letting service-level arguments and
# settings to be overridden with job-specific things as much as # settings to be overridden with job-specific things as much as
# possible especially with the settings. # possible especially with the settings.
# #
# Regarding to settings (`settings`) and extra arguments # Regarding to settings (`settings`) and extra arguments
# (`extraArgs`), the settings is the last applied argument with # (`extraArgs`), the settings is the last applied argument with
# `--config` option. This means that it will cascade resultings # `--config` option. This means that it will cascade resultings
# settings from `extraArgs` if there's any related option that is # settings from `extraArgs` if there's any related option that is
# given like another `--config` for example. # given like another `--config` for example.
script = let script =
jobLevelSettingsFile = let
settingsFormat.generate "gallery-dl-job-${name}-settings" jobLevelSettingsFile =
value.settings; settingsFormat.generate "gallery-dl-job-${name}-settings"
in '' value.settings;
gallery-dl ${lib.escapeShellArgs cfg.extraArgs} ${ in
lib.optionalString (cfg.settings != null) ''
"--config ${settingsFormatFile}" gallery-dl ${lib.escapeShellArgs cfg.extraArgs} ${
} ${lib.escapeShellArgs value.extraArgs} ${ lib.optionalString (cfg.settings != null)
lib.optionalString (value.settings != null) "--config ${settingsFormatFile}"
"--config ${jobLevelSettingsFile}" } ${lib.escapeShellArgs value.extraArgs} ${
} --destination ${lib.escapeShellArg cfg.archivePath} ${ lib.optionalString (value.settings != null)
lib.escapeShellArgs value.urls "--config ${jobLevelSettingsFile}"
} } --destination ${lib.escapeShellArg cfg.archivePath} ${
''; lib.escapeShellArgs value.urls
startAt = value.startAt; }
serviceConfig = { '';
LockPersonality = true; startAt = value.startAt;
NoNewPrivileges = true; serviceConfig = {
PrivateTmp = true; LockPersonality = true;
PrivateUsers = true; NoNewPrivileges = true;
PrivateDevices = true; PrivateTmp = true;
ProtectControlGroups = true; PrivateUsers = true;
ProtectClock = true; PrivateDevices = true;
ProtectKernelLogs = true; ProtectControlGroups = true;
ProtectKernelModules = true; ProtectClock = true;
ProtectKernelTunables = true; ProtectKernelLogs = true;
SystemCallFilter = "@system-service"; ProtectKernelModules = true;
SystemCallErrorNumber = "EPERM"; ProtectKernelTunables = true;
}; SystemCallFilter = "@system-service";
}) cfg.jobs; SystemCallErrorNumber = "EPERM";
};
})
cfg.jobs;
systemd.timers = lib.mapAttrs' (name: value: systemd.timers = lib.mapAttrs'
lib.nameValuePair (jobUnitName name) { (name: value:
timerConfig = { lib.nameValuePair (jobUnitName name) {
Persistent = value.persistent; timerConfig = {
RandomizedDelaySec = "2min"; Persistent = value.persistent;
}; RandomizedDelaySec = "2min";
}) cfg.jobs; };
})
cfg.jobs;
}; };
} }

View File

@ -62,7 +62,8 @@ let
}; };
}; };
}; };
in { in
{
options.services.yt-dlp = { options.services.yt-dlp = {
enable = lib.mkEnableOption "archiving service with yt-dlp"; enable = lib.mkEnableOption "archiving service with yt-dlp";
@ -130,47 +131,52 @@ in {
# There's no need to go to the working directory since yt-dlp has the # There's no need to go to the working directory since yt-dlp has the
# `--paths` flag. # `--paths` flag.
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
systemd.services = lib.mapAttrs' (name: value: let systemd.services = lib.mapAttrs'
jobLevelArgs = lib.escapeShellArgs value.extraArgs; (name: value:
in let
lib.nameValuePair (jobUnitName name) { jobLevelArgs = lib.escapeShellArgs value.extraArgs;
wantedBy = [ "multi-user.target" ]; in
description = "yt-dlp archive job for group '${name}'"; lib.nameValuePair (jobUnitName name) {
documentation = [ "man:yt-dlp(1)" ]; wantedBy = [ "multi-user.target" ];
enable = true; description = "yt-dlp archive job for group '${name}'";
path = [ cfg.package pkgs.coreutils ]; documentation = [ "man:yt-dlp(1)" ];
preStart = '' enable = true;
mkdir -p ${lib.escapeShellArg cfg.archivePath} path = [ cfg.package pkgs.coreutils ];
''; preStart = ''
script = '' mkdir -p ${lib.escapeShellArg cfg.archivePath}
yt-dlp ${serviceLevelArgs} ${jobLevelArgs} \ '';
${lib.escapeShellArgs value.urls} --paths ${lib.escapeShellArg cfg.archivePath} script = ''
''; yt-dlp ${serviceLevelArgs} ${jobLevelArgs} \
startAt = value.startAt; ${lib.escapeShellArgs value.urls} --paths ${lib.escapeShellArg cfg.archivePath}
serviceConfig = { '';
LockPersonality = true; startAt = value.startAt;
NoNewPrivileges = true; serviceConfig = {
PrivateTmp = true; LockPersonality = true;
PrivateUsers = true; NoNewPrivileges = true;
PrivateDevices = true; PrivateTmp = true;
ProtectControlGroups = true; PrivateUsers = true;
ProtectClock = true; PrivateDevices = true;
ProtectKernelLogs = true; ProtectControlGroups = true;
ProtectKernelModules = true; ProtectClock = true;
ProtectKernelTunables = true; ProtectKernelLogs = true;
StandardOutput = "journal"; ProtectKernelModules = true;
StandardError = "journal"; ProtectKernelTunables = true;
SystemCallFilter = "@system-service"; StandardOutput = "journal";
SystemCallErrorNumber = "EPERM"; StandardError = "journal";
}; SystemCallFilter = "@system-service";
}) cfg.jobs; SystemCallErrorNumber = "EPERM";
};
})
cfg.jobs;
systemd.timers = lib.mapAttrs' (name: value: systemd.timers = lib.mapAttrs'
lib.nameValuePair (jobUnitName name) { (name: value:
timerConfig = { lib.nameValuePair (jobUnitName name) {
Persistent = value.persistent; timerConfig = {
RandomizedDelaySec = "2min"; Persistent = value.persistent;
}; RandomizedDelaySec = "2min";
}) cfg.jobs; };
})
cfg.jobs;
}; };
} }

View File

@ -13,7 +13,7 @@ let
}; };
# We're combining all of the custom dconf database into a package to be installed. # We're combining all of the custom dconf database into a package to be installed.
dconfConfig = pkgs.runCommand "install-a-happy-gnome-dconf-keyfiles" {} '' dconfConfig = pkgs.runCommand "install-a-happy-gnome-dconf-keyfiles" { } ''
install -Dm644 ${./config/dconf}/*.conf -t $out/etc/dconf/db/${name}-conf.d install -Dm644 ${./config/dconf}/*.conf -t $out/etc/dconf/db/${name}-conf.d
install -Dm644 ${enabledExtensions} $out/etc/dconf/db/${name}-conf.d/90-enabled-extensions.conf install -Dm644 ${enabledExtensions} $out/etc/dconf/db/${name}-conf.d/90-enabled-extensions.conf
''; '';
@ -132,8 +132,8 @@ in
profiles.user = pkgs.writeTextFile { profiles.user = pkgs.writeTextFile {
name = "a-happy-gnome"; name = "a-happy-gnome";
text = '' text = ''
user-db:user user-db:user
system-db:${name}-conf system-db:${name}-conf
''; '';
}; };
}; };

View File

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

View File

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

View File

@ -73,11 +73,11 @@ stdenv.mkDerivation rec {
valgrind valgrind
sndio sndio
] ++ lib.optional pulseaudioSupport libpulseaudio ] ++ lib.optional pulseaudioSupport libpulseaudio
++ lib.optional jackSupport jack2 ++ lib.optional esoundSupport espeak ++ lib.optional jackSupport jack2 ++ lib.optional esoundSupport espeak
++ lib.optionals (stdenv.isLinux && waylandSupport) [ ++ lib.optionals (stdenv.isLinux && waylandSupport) [
wayland wayland
libxkbcommon libxkbcommon
]; ];
# TODO: Replace SOKOL-built version with SDL. # TODO: Replace SOKOL-built version with SDL.
cmakeFlags = [ "-DBUILD_PRO=ON" ]; cmakeFlags = [ "-DBUILD_PRO=ON" ];

View File

@ -27,6 +27,6 @@
}) // { }) // {
overlays.default = final: prev: import ./pkgs { pkgs = prev; }; overlays.default = final: prev: import ./pkgs { pkgs = prev; };
nixosModules = {}; nixosModules = { };
}; };
} }

View File

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