1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00

nvchecker: add module

(cherry picked from commit 3cb08dd360)
Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
Michael Daniels 2025-09-15 18:11:04 -04:00 committed by Austin Horstman
parent f21d916778
commit 6f656618eb
9 changed files with 182 additions and 0 deletions

View file

@ -0,0 +1,9 @@
{
time = "2025-09-15T22:14:27+00:00";
condition = true;
message = ''
A new module is available: `programs.nvchecker`.
`nvchecker` checks if a new version of some software was released.
'';
}

View file

@ -213,6 +213,7 @@ let
./programs/notmuch.nix ./programs/notmuch.nix
./programs/numbat.nix ./programs/numbat.nix
./programs/nushell.nix ./programs/nushell.nix
./programs/nvchecker.nix
./programs/obs-studio.nix ./programs/obs-studio.nix
./programs/octant.nix ./programs/octant.nix
./programs/offlineimap.nix ./programs/offlineimap.nix

View file

@ -0,0 +1,113 @@
{
lib,
pkgs,
config,
...
}:
let
tomlFormat = pkgs.formats.toml { };
cfg = config.programs.nvchecker;
configDir =
if pkgs.stdenv.hostPlatform.isDarwin then
"${config.home.homeDirectory}/Library/Application Support/nvchecker"
else
"${config.xdg.configHome}/nvchecker";
in
{
meta.maintainers = [ lib.maintainers.mdaniels5757 ];
options.programs.nvchecker = {
enable = lib.mkEnableOption "nvchecker";
package = lib.mkPackageOption pkgs "nvchecker" { nullable = true; };
settings =
let
envDocs = ''
Environment variables and `~` are expanded,
and relative paths are relative to
{file}`''${config.home.homeDirectory}/Library/Application Support/nvchecker/nvchecker/` (on Darwin)
or {file}`''${config.xdg.configHome}/nvchecker/` (otherwise).
'';
in
lib.mkOption {
type = lib.types.submodule {
freeformType = tomlFormat.type;
options.__config__ = lib.mkOption {
type = lib.types.submodule {
freeformType = tomlFormat.type;
options = {
oldver = lib.mkOption {
# doesn't matter if absolute/relative or (not) in store
type = lib.types.pathWith { };
default = "old_ver.json";
description = ''
The file to store 'old' (i.e. installed) version information in.
${envDocs}
'';
};
newver = lib.mkOption {
# doesn't matter if absolute/relative or (not) in store
type = lib.types.pathWith { };
default = "new_ver.json";
description = ''
The file to store 'new' (i.e. available) versions in.
${envDocs}
'';
};
};
};
default = { };
defaultText = lib.literalExpression ''
{
oldver = "old_ver.json";
newver = "new_ver.json";
};
'';
description = ''
See <https://nvchecker.readthedocs.io/en/stable/usage.html#configuration-files>.
${envDocs}
'';
};
};
default = { };
defaultText = lib.literalExpression ''
__config__ = {
oldver = "old_ver.json";
newver = "new_ver.json";
};
'';
example = lib.literalExpression ''
{
__config__ = {
oldver = "my_custom_oldver.json";
newver = "~/seperately_placed_newver.json";
keyfile = "keyfile.toml";
};
nvchecker = {
source = "github";
github = "lilydjwg/nvchecker";
};
}
'';
description = ''
Configuration written to
{file}`$HOME/Library/Application Support/nvchecker/nvchecker.toml` (on Darwin) or
{file}`$XDG_CONFIG_HOME/nvchecker/nvchecker.toml` (otherwise).
See <https://nvchecker.readthedocs.io/en/stable/usage.html#configuration-files>
for the full list of options.
${envDocs}
'';
};
};
config = lib.mkIf cfg.enable {
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
home.file."${configDir}/nvchecker.toml".source = lib.mkIf (cfg.settings != { }) (
tomlFormat.generate "nvchecker.toml" cfg.settings
);
};
}

View file

@ -393,6 +393,7 @@ import nmtSrc {
./modules/programs/mpvpaper ./modules/programs/mpvpaper
./modules/programs/ncmpcpp-linux ./modules/programs/ncmpcpp-linux
./modules/programs/nh ./modules/programs/nh
./modules/programs/nvchecker
./modules/programs/onagre ./modules/programs/onagre
./modules/programs/onedrive ./modules/programs/onedrive
./modules/programs/pqiv ./modules/programs/pqiv

View file

@ -0,0 +1,27 @@
{ pkgs, ... }:
let
configDir =
if pkgs.stdenv.hostPlatform.isDarwin then
"Library/Application Support/nvchecker"
else
".config/nvchecker";
in
{
programs.nvchecker = {
enable = true;
settings = {
__config__ = {
keyfile = "keyfile.toml";
};
nvchecker = {
source = "github";
github = "lilydjwg/nvchecker";
};
};
};
nmt.script = ''
assertFileExists "home-files/${configDir}/nvchecker.toml"
assertFileContent "home-files/${configDir}/nvchecker.toml" "${./basic-config.toml}"
'';
}

View file

@ -0,0 +1,8 @@
[__config__]
keyfile = "keyfile.toml"
newver = "new_ver.json"
oldver = "old_ver.json"
[nvchecker]
github = "lilydjwg/nvchecker"
source = "github"

View file

@ -0,0 +1,4 @@
{
nvchecker-basic-config = ./basic-config.nix;
nvchecker-empty-config = ./empty-config.nix;
}

View file

@ -0,0 +1,16 @@
{ pkgs, ... }:
let
configDir =
if pkgs.stdenv.hostPlatform.isDarwin then
"Library/Application Support/nvchecker"
else
".config/nvchecker";
in
{
programs.nvchecker.enable = true;
nmt.script = ''
assertFileExists "home-files/${configDir}/nvchecker.toml"
assertFileContent "home-files/${configDir}/nvchecker.toml" "${./empty-config.toml}"
'';
}

View file

@ -0,0 +1,3 @@
[__config__]
newver = "new_ver.json"
oldver = "old_ver.json"