diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index 1cccfe71a..1859fef63 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -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
diff --git a/modules/lib/maintainers.nix b/modules/lib/maintainers.nix
index e0aaedb50..87815604b 100644
--- a/modules/lib/maintainers.nix
+++ b/modules/lib/maintainers.nix
@@ -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";
+ }];
+ };
}
diff --git a/modules/misc/news.nix b/modules/misc/news.nix
index 7d98272b0..5244b2a64 100644
--- a/modules/misc/news.nix
+++ b/modules/misc/news.nix
@@ -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'.
+ '';
+ }
+
];
};
}
diff --git a/modules/modules.nix b/modules/modules.nix
index 70593260c..b68eed0ac 100644
--- a/modules/modules.nix
+++ b/modules/modules.nix
@@ -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 { })
diff --git a/modules/programs/topgrade.nix b/modules/programs/topgrade.nix
new file mode 100644
index 000000000..878fdbb08
--- /dev/null
+++ b/modules/programs/topgrade.nix
@@ -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
+ ~/.config/topgrade.toml.
+
+ See 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;
+ };
+ };
+}
diff --git a/tests/default.nix b/tests/default.nix
index de0a2eb3d..fc833e29f 100644
--- a/tests/default.nix
+++ b/tests/default.nix
@@ -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
diff --git a/tests/modules/programs/topgrade/default.nix b/tests/modules/programs/topgrade/default.nix
new file mode 100644
index 000000000..46b0384a0
--- /dev/null
+++ b/tests/modules/programs/topgrade/default.nix
@@ -0,0 +1 @@
+{ topgrade-settings = ./settings.nix; }
diff --git a/tests/modules/programs/topgrade/settings-expected.toml b/tests/modules/programs/topgrade/settings-expected.toml
new file mode 100644
index 000000000..aeed3d14b
--- /dev/null
+++ b/tests/modules/programs/topgrade/settings-expected.toml
@@ -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"
diff --git a/tests/modules/programs/topgrade/settings.nix b/tests/modules/programs/topgrade/settings.nix
new file mode 100644
index 000000000..a7436b5ef
--- /dev/null
+++ b/tests/modules/programs/topgrade/settings.nix
@@ -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}
+ '';
+ };
+}