topgrade: add module (#1924)

This commit is contained in:
Harsh Shandilya 2021-04-29 05:26:58 +05:30 committed by GitHub
parent 55ef8d3a10
commit 137a584e22
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 130 additions and 0 deletions

3
.github/CODEOWNERS vendored
View file

@ -150,6 +150,9 @@
/modules/programs/texlive.nix @rycee
/modules/programs/topgrade.nix @msfjarvis
/tests/modules/programs/topgrade @msfjarvis
/modules/programs/waybar.nix @berbiche
/tests/modules/programs/waybar @berbiche

View file

@ -71,4 +71,14 @@
githubId = 46252070;
name = "Sara Johnsson";
};
msfjarvis = {
email = "me@msfjarvis.dev";
github = "msfjarvis";
githubId = "13348378";
name = "Harsh Shandilya";
keys = [{
longkeyid = "rsa4096/0xB7843F823355E9B9";
fingerprint = "8F87 050B 0F9C B841 1515 7399 B784 3F82 3355 E9B9";
}];
};
}

View file

@ -1921,6 +1921,14 @@ in
A new service is available: 'services.mpris-proxy'.
'';
}
{
time = "2021-04-28T12:00:00+00:00";
message = ''
A new module is available: 'programs.topgrade'.
'';
}
];
};
}

View file

@ -127,6 +127,7 @@ let
(loadModule ./programs/termite.nix { })
(loadModule ./programs/texlive.nix { })
(loadModule ./programs/tmux.nix { })
(loadModule ./programs/topgrade.nix { })
(loadModule ./programs/urxvt.nix { })
(loadModule ./programs/vim.nix { })
(loadModule ./programs/vscode.nix { })

View file

@ -0,0 +1,60 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.topgrade;
tomlFormat = pkgs.formats.toml { };
in {
meta.maintainers = [ hm.maintainers.msfjarvis ];
options.programs.topgrade = {
enable = mkEnableOption "topgrade";
package = mkOption {
type = types.package;
default = pkgs.topgrade;
defaultText = literalExample "pkgs.topgrade";
description = "The package to use for the topgrade binary.";
};
settings = mkOption {
type = tomlFormat.type;
default = { };
defaultText = literalExample "{ }";
example = literalExample ''
{
assume_yes = true;
disable = [
"flutter"
"node"
];
set_title = false;
cleanup = true;
commands = {
"Run garbage collection on Nix store" = "nix-collect-garbage";
};
}
'';
description = ''
Configuration written to
<filename>~/.config/topgrade.toml</filename>.
</para><para>
See <link xlink:href="https://github.com/r-darwish/topgrade/wiki/Step-list" /> for the full list
of options.
'';
};
};
config = mkIf cfg.enable {
home.packages = [ cfg.package ];
xdg.configFile."topgrade.toml" = mkIf (cfg.settings != { }) {
source = tomlFormat.generate "topgrade-config" cfg.settings;
};
};
}

View file

@ -76,6 +76,7 @@ import nmt {
./modules/programs/starship
./modules/programs/texlive
./modules/programs/tmux
./modules/programs/topgrade
./modules/programs/vscode
./modules/programs/zplug
./modules/programs/zsh

View file

@ -0,0 +1 @@
{ topgrade-settings = ./settings.nix; }

View file

@ -0,0 +1,8 @@
cleanup = true
disable = ["sdkman", "flutter", "node", "nix", "home_manager"]
remote_topgrade_path = "bin/topgrade"
remote_topgrades = ["backup", "ci"]
set_title = false
[commands]
"Purge unused APT packages" = "sudo apt autoremove"

View file

@ -0,0 +1,38 @@
{ config, lib, pkgs, ... }:
with lib;
{
config = {
programs.topgrade = {
enable = true;
settings = mkMerge [
{
disable = [ "sdkman" "flutter" "node" "nix" "home_manager" ];
remote_topgrades = [ "backup" "ci" ];
remote_topgrade_path = "bin/topgrade";
}
{
set_title = false;
cleanup = true;
commands = { "Purge unused APT packages" = "sudo apt autoremove"; };
}
];
};
nixpkgs.overlays = [
(self: super: { topgrade = pkgs.writeScriptBin "dummy-topgrade" ""; })
];
nmt.script = ''
assertFileContent \
home-files/.config/topgrade.toml \
${./settings-expected.toml}
'';
};
}