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:
parent
f21d916778
commit
6f656618eb
9 changed files with 182 additions and 0 deletions
9
modules/misc/news/2025/09/2025-09-15_18-14-27.nix
Normal file
9
modules/misc/news/2025/09/2025-09-15_18-14-27.nix
Normal 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.
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
113
modules/programs/nvchecker.nix
Normal file
113
modules/programs/nvchecker.nix
Normal 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
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
27
tests/modules/programs/nvchecker/basic-config.nix
Normal file
27
tests/modules/programs/nvchecker/basic-config.nix
Normal 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}"
|
||||||
|
'';
|
||||||
|
}
|
||||||
8
tests/modules/programs/nvchecker/basic-config.toml
Normal file
8
tests/modules/programs/nvchecker/basic-config.toml
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
[__config__]
|
||||||
|
keyfile = "keyfile.toml"
|
||||||
|
newver = "new_ver.json"
|
||||||
|
oldver = "old_ver.json"
|
||||||
|
|
||||||
|
[nvchecker]
|
||||||
|
github = "lilydjwg/nvchecker"
|
||||||
|
source = "github"
|
||||||
4
tests/modules/programs/nvchecker/default.nix
Normal file
4
tests/modules/programs/nvchecker/default.nix
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
nvchecker-basic-config = ./basic-config.nix;
|
||||||
|
nvchecker-empty-config = ./empty-config.nix;
|
||||||
|
}
|
||||||
16
tests/modules/programs/nvchecker/empty-config.nix
Normal file
16
tests/modules/programs/nvchecker/empty-config.nix
Normal 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}"
|
||||||
|
'';
|
||||||
|
}
|
||||||
3
tests/modules/programs/nvchecker/empty-config.toml
Normal file
3
tests/modules/programs/nvchecker/empty-config.toml
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
[__config__]
|
||||||
|
newver = "new_ver.json"
|
||||||
|
oldver = "old_ver.json"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue