added stuff

This commit is contained in:
Charlie Root 2024-04-09 23:11:33 +02:00
commit 9d0ebdfbd0
907 changed files with 70990 additions and 0 deletions

View file

@ -0,0 +1 @@
{}

View file

@ -0,0 +1,101 @@
{
config,
lib,
pkgs,
...
}:
with builtins; let
cfg = config.programs.gtklock;
inherit (lib) types mkIf mkOption mkEnableOption mkPackageOptionMD literalExpression optionals optionalString;
inherit (lib.generators) toINI;
# the main config includes two very niche options: style (which takes a path) and modules, which takes a list of module paths
# concatted by ";"
# for type checking purposes, I prefer templating the main section of the config and let the user safely choose options
# extraConfig takes an attrset, and converts it to the correct INI format - it's mostly just strings and integers, so that's fine
baseConfig = ''
[main]
${optionalString (cfg.config.gtk-theme != "") "gtk-theme=${cfg.config.gtk-theme}"}
${optionalString (cfg.config.style != "") "style=${cfg.config.style}"}
${optionalString (cfg.config.modules != []) "modules=${concatStringsSep ";" cfg.config.modules}"}
'';
finalConfig = baseConfig + optionals (cfg.extraConfig != null) (toINI {} cfg.extraConfig);
in {
meta.maintainers = [maintainers.NotAShelf];
options.programs.gtklock = {
enable = mkEnableOption "GTK-based lockscreen for Wayland";
package = mkPackageOptionMD pkgs "gtklock" {};
config = {
gtk-theme = mkOption {
type = types.str;
default = "";
description = ''
GTK theme to use for gtklock.
'';
example = "Adwaita-dark";
};
style = mkOption {
type = with types; oneOf [str path];
default = "";
description = ''
The css file to be used for gtklock.
'';
example = literalExpression ''
pkgs.writeText "gtklock-style.css" '''
window {
background-size: cover;
background-repeat: no-repeat;
background-position: center;
}
'''
'';
};
modules = mkOption {
type = with types; listOf (either package str);
default = [];
description = ''
A list of gtklock modulesto use. Can either be packages, absolute paths, or strings.
'';
example = literalExpression ''
[
"${pkgs.gtklock-powerbar-module.outPath}/lib/gtklock/powerbar-module.so"
"${pkgs.gtklock-playerctl-module.outPath}/lib/gtklock/playerctl-module.so"
];
'';
};
};
extraConfig = mkOption {
type = with types; nullOr attrs;
default = {
countdown = {
countdown-position = "top-right";
justify = "right";
countdown = 20;
};
};
description = ''
Extra configuration to append to gtklock configuration file.
Mostly used for appending module configurations.
'';
example = literalExpression ''
countdown = {
countdown-position = "top-right";
justify = "right";
countdown = 20;
}
'';
};
};
config = mkIf cfg.enable {
home.packages = [cfg.package];
xdg.configFile."gtklock/config.ini".source = pkgs.writeText "gtklock-config.ini" finalConfig;
};
}

View file

@ -0,0 +1,76 @@
{
config,
pkgs,
lib,
...
}: let
inherit (lib) mkOption mkEnableOption types;
cfg = config.services.transience;
in {
meta.maintainers = [lib.maintainers.NotAShelf];
options.services.transience = {
enable = mkEnableOption "transience";
user = mkOption {
type = with types; nullOr string;
default = null;
description = "The user that the directories will be relative to";
};
days = mkOption {
type = types.int;
default = 30;
description = "Number of days after which files are deleted";
};
directories = mkOption {
type = with types; listOf path;
default = [];
description = ''
A list of directories that will be cleaned.
Must be relative to the user's home directory.
'';
};
};
config = {
assertions = [
{
assertion = cfg.enable -> cfg.user == null;
message = ''
You have enabled services.transience, but have not specified your user. You must specify a "main user"
for your system for Transience to work properly.
'';
}
{
assertion = cfg.directories == [];
message = ''
You have enabled services.transience, but have not specified any directories to clean up. Please specify
at least one folder. This option defaults to an empty list, but you must specify a list of directories for
Transience to work properly.
'';
}
];
systemd.user.services.transience = let
dirs =
map (
x:
config.home-manager.users.${cfg.user}.home.homeDirectory + "/" + x
)
cfg.directories;
in {
Install.wantedBy = ["default.target"];
Service.ExecStart = ''
${builtins.concatStringsSep "\n" (map (x: "find ${
lib.escapeShellArg x
} -mtime +${cfg.days} -exec rm -rv {} + -depth;")
dirs)}
'';
Unit.Description = "Clean up transient directories";
};
};
}

View file

@ -0,0 +1,50 @@
{
config,
lib,
pkgs,
...
}:
with builtins; let
inherit (lib) types mkIf mkOption mkEnableOption mkPackageOptionMD literalExpression;
cfg = config.programs.vifm;
in {
meta.maintainers = [maintainers.NotAShelf];
options.programs.vifm = {
enable = mkEnableOption "vifm, file manager with curses interface, which provides Vim-like environment for managing objects within file systems";
package = mkPackageOptionMD pkgs "vifm" {};
config = mkOption {
type = types.lines;
default = "";
description = "Vifm configuration to be written in vifmrc";
example = literalExpression ''
" vim:ft=vifm
set vicmd="nvim"
set runexec
'';
};
extraConfigFiles = mkOption {
type = with types; listOf str;
default = [];
example = ["~/.config/vifm/vifmrc.local"];
description = ''
Extra vifm configuration files to be sourced in vifmrc
Can be an absolute path, or a path relative to `$XDG_CONFIG_HOME/vifm`
'';
};
};
config = mkIf cfg.enable {
home.packages = [cfg.package];
xdg.configFile."vifm/vifmrc".source = pkgs.writeText "vifmrc" (
(lib.concatLines (lib.forEach cfg.extraConfigFiles (x: "source ${x}")))
+ cfg.config
);
};
}

View file

@ -0,0 +1,61 @@
{
config,
lib,
pkgs,
...
}:
with builtins; let
inherit (lib) types mkIf mkOption mkEnableOption mkPackageOptionMD literalExpression;
cfg = config.programs.xplr;
initialConfig = ''
version = '${cfg.package.version}'
'';
# we provide a default version line within the configuration file, which is obtained from the package's attributes
# merge the initial configFile, a mapped list of plugins and then the user defined configuration to obtain the final configuration
pluginPath =
if cfg.plugins != []
then ("package.path=\n" + (concatStringsSep " ..\n" (map (p: ''"${p}/init.lua;"'') cfg.plugins)) + " ..\npackage.path\n")
else "\n";
configFile = initialConfig + pluginPath + cfg.config;
in {
meta.maintainers = [maintainers.NotAShelf];
options.programs.xplr = {
enable = mkEnableOption "xplr, terminal UI based file explorer" // {default = true;};
package = mkPackageOptionMD pkgs "xplr" {};
plugins = mkOption {
type = with types; nullOr (listOf (either package str));
default = [];
defaultText = literalExpression "[]";
description = ''
Plugins to be added to your configuration file. Must be a package, an absolute plugin path, or string
to be recognized by xplr. Paths will be relative to $XDG_CONFIG_HOME/xplr/init.lua unless they are absolute.
'';
};
# TODO: rename, this is the main configuration
config = mkOption {
type = types.lines;
default = "";
description = ''
Extra xplr configuration.
'';
example = literalExpression ''
require("wl-clipboard").setup {
copy_command = "wl-copy -t text/uri-list",
paste_command = "wl-paste",
keep_selection = true,
}
'';
};
};
config = mkIf cfg.enable {
home.packages = [cfg.package];
xdg.configFile."xplr/init.lua".source = pkgs.writeText "init.lua" configFile;
};
}