home: move nix-index automation to modules
This commit is contained in:
@@ -146,6 +146,7 @@
|
|||||||
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;
|
neovim-auto-clean-swapfiles = ./home/modules/programs/neovim/auto-clean-swapfiles.nix;
|
||||||
|
nix-index-auto-update-database = ./home/modules/programs/nix-index/auto-update-database.nix;
|
||||||
};
|
};
|
||||||
|
|
||||||
homeConfigurations = {
|
homeConfigurations = {
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ in {
|
|||||||
./modules/uidGid.nix
|
./modules/uidGid.nix
|
||||||
./modules/programs/gpg
|
./modules/programs/gpg
|
||||||
./modules/programs/neovim/auto-clean-swapfiles.nix
|
./modules/programs/neovim/auto-clean-swapfiles.nix
|
||||||
|
./modules/programs/nix-index/auto-update-database.nix
|
||||||
] ++ (optionals graphics [
|
] ++ (optionals graphics [
|
||||||
./config/gtk.nix
|
./config/gtk.nix
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,25 @@
|
|||||||
{ config, pkgs, lib, ... }:
|
{ config, pkgs, lib, ... }:
|
||||||
let
|
let
|
||||||
cfg = config.programs.nix-index;
|
cfg = config.programs.nix-index.autoUpdateDatabase;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.programs.nix-index.enableDatabaseFetcher = lib.mkEnableOption "timed unit that fetches an updated database of nixpkgs outputs";
|
options.programs.nix-index.autoUpdateDatabase = {
|
||||||
|
enable = lib.mkEnableOption "timed unit that fetches an updated database of nixpkgs outputs";
|
||||||
|
|
||||||
|
# TODO: let users specify forks and other sources
|
||||||
|
# url = "";
|
||||||
|
|
||||||
|
onCalendar = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "weekly";
|
||||||
|
example = "montly";
|
||||||
|
# TODO: link to systemd manpage for format.
|
||||||
|
description = "How often to update the database.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
systemd.user.timers.fetch-nix-index-database = lib.mkIf cfg.enableDatabaseFetcher {
|
systemd.user.timers.fetch-nix-index-database = lib.mkIf cfg.enable {
|
||||||
Unit = {
|
Unit = {
|
||||||
Description = "Fetch nix-index database";
|
Description = "Fetch nix-index database";
|
||||||
Documentation = [ "https://github.com/nix-community/nix-index-database" ];
|
Documentation = [ "https://github.com/nix-community/nix-index-database" ];
|
||||||
@@ -14,7 +27,7 @@ in
|
|||||||
|
|
||||||
Timer = {
|
Timer = {
|
||||||
Unit = "fetch-nix-index-database.service";
|
Unit = "fetch-nix-index-database.service";
|
||||||
OnCalendar = "weekly";
|
OnCalendar = cfg.onCalendar;
|
||||||
Persistent = true;
|
Persistent = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -23,7 +36,7 @@ in
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.user.services.fetch-nix-index-database = lib.mkIf cfg.enableDatabaseFetcher {
|
systemd.user.services.fetch-nix-index-database = lib.mkIf cfg.enable {
|
||||||
Unit = {
|
Unit = {
|
||||||
Description = "Fetch nix-index database";
|
Description = "Fetch nix-index database";
|
||||||
Documentation = [ "https://github.com/nix-community/nix-index-database" ];
|
Documentation = [ "https://github.com/nix-community/nix-index-database" ];
|
||||||
@@ -39,6 +52,8 @@ in
|
|||||||
wget
|
wget
|
||||||
];
|
];
|
||||||
|
|
||||||
|
# TODO: allow fetching with gh + github token
|
||||||
|
|
||||||
# Source: https://github.com/nix-community/nix-index-database?tab=readme-ov-file#ad-hoc-download
|
# Source: https://github.com/nix-community/nix-index-database?tab=readme-ov-file#ad-hoc-download
|
||||||
# Slightly modified to satisfy shellcheck
|
# Slightly modified to satisfy shellcheck
|
||||||
text = ''
|
text = ''
|
||||||
@@ -1,9 +1,7 @@
|
|||||||
{ ... }:
|
{ ... }:
|
||||||
{
|
{
|
||||||
imports = [ ./fetch-nix-index-database.nix ];
|
|
||||||
|
|
||||||
programs.nix-index = {
|
programs.nix-index = {
|
||||||
enable = true;
|
enable = true;
|
||||||
enableDatabaseFetcher = true;
|
autoUpdateDatabase.enable = true;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user