home: move neovim automation to modules
This commit is contained in:
@ -145,6 +145,7 @@
|
|||||||
shellAliases = ./home/modules/shellAliases.nix;
|
shellAliases = ./home/modules/shellAliases.nix;
|
||||||
colors = ./home/modules/colors.nix;
|
colors = ./home/modules/colors.nix;
|
||||||
gpg = ./home/modules/programs/gpg;
|
gpg = ./home/modules/programs/gpg;
|
||||||
|
neovim-auto-clean-swapfiles = ./home/modules/programs/neovim/auto-clean-swapfiles.nix;
|
||||||
};
|
};
|
||||||
|
|
||||||
homeConfigurations = {
|
homeConfigurations = {
|
||||||
|
@ -50,6 +50,7 @@ in {
|
|||||||
./modules/shellAliases.nix
|
./modules/shellAliases.nix
|
||||||
./modules/uidGid.nix
|
./modules/uidGid.nix
|
||||||
./modules/programs/gpg
|
./modules/programs/gpg
|
||||||
|
./modules/programs/neovim/auto-clean-swapfiles.nix
|
||||||
] ++ (optionals graphics [
|
] ++ (optionals graphics [
|
||||||
./config/gtk.nix
|
./config/gtk.nix
|
||||||
|
|
||||||
|
@ -1,9 +1,29 @@
|
|||||||
{ config, pkgs, lib, ... }:
|
{ config, pkgs, lib, ... }:
|
||||||
let
|
let
|
||||||
daysBeforeDeletion = 2;
|
daysBeforeDeletion = 2;
|
||||||
|
cfg = config.programs.neovim.auto-clean-swapfiles;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
config = {
|
options.programs.neovim.auto-clean-swapfiles = {
|
||||||
|
enable = lib.mkEnableOption "automatic cleanup of neovim swapfiles";
|
||||||
|
|
||||||
|
daysBeforeDeletion = lib.mkOption {
|
||||||
|
type = lib.types.ints.positive;
|
||||||
|
default = 2;
|
||||||
|
example = 7;
|
||||||
|
description = "How long many days old the swapfile should be before it gets cleaned up";
|
||||||
|
};
|
||||||
|
|
||||||
|
onCalendar = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "daily";
|
||||||
|
example = "weekly";
|
||||||
|
# TODO: link to systemd manpage for format.
|
||||||
|
description = "How often to run the cleanup.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
systemd.user.services.clean-neovim-swap-files = {
|
systemd.user.services.clean-neovim-swap-files = {
|
||||||
Unit = {
|
Unit = {
|
||||||
Description = "Clean old swap files for neovim";
|
Description = "Clean old swap files for neovim";
|
||||||
@ -19,7 +39,7 @@ in
|
|||||||
text = ''
|
text = ''
|
||||||
echo "Cleaning old swap files for neovim"
|
echo "Cleaning old swap files for neovim"
|
||||||
|
|
||||||
OLD_SWAPFILES=$(find "${config.xdg.stateHome}/nvim/swap" -type f -name '*.swp' -mtime +${toString daysBeforeDeletion})
|
OLD_SWAPFILES=$(find "${config.xdg.stateHome}/nvim/swap" -type f -name '*.swp' -mtime +${toString cfg.daysBeforeDeletion})
|
||||||
|
|
||||||
if [ -z "$OLD_SWAPFILES" ]; then
|
if [ -z "$OLD_SWAPFILES" ]; then
|
||||||
echo "No old swap files found"
|
echo "No old swap files found"
|
||||||
@ -44,7 +64,7 @@ in
|
|||||||
|
|
||||||
Timer = {
|
Timer = {
|
||||||
Unit = "clean-neovim-swap-files.service";
|
Unit = "clean-neovim-swap-files.service";
|
||||||
OnCalendar = "daily";
|
OnCalendar = cfg.onCalendar;
|
||||||
Persistent = true;
|
Persistent = true;
|
||||||
};
|
};
|
||||||
|
|
@ -1,12 +1,10 @@
|
|||||||
{ pkgs, lib, machineVars, ... }:
|
{ pkgs, lib, machineVars, ... }:
|
||||||
{
|
{
|
||||||
imports = [
|
|
||||||
./auto-clean-swapfiles.nix
|
|
||||||
];
|
|
||||||
|
|
||||||
programs.neovim = {
|
programs.neovim = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
|
auto-clean-swapfiles.enable = true;
|
||||||
|
|
||||||
viAlias = true;
|
viAlias = true;
|
||||||
vimAlias = true;
|
vimAlias = true;
|
||||||
vimdiffAlias = true;
|
vimdiffAlias = true;
|
||||||
|
Reference in New Issue
Block a user