diff --git a/nixos/doc/manual/release-notes/rl-2411.section.md b/nixos/doc/manual/release-notes/rl-2411.section.md index 1060e444a53f07..feb22e7a5cc762 100644 --- a/nixos/doc/manual/release-notes/rl-2411.section.md +++ b/nixos/doc/manual/release-notes/rl-2411.section.md @@ -115,6 +115,8 @@ - [Eintopf](https://eintopf.info), a community event and calendar web application. Available as [services.eintopf](options.html#opt-services.eintopf.enable). +- [`pay-respects`](https://codeberg.org/iff/pay-respects), a terminal command correction program, alternative to `thefuck`, written in Rust. Available as [programs.pay-respects](options.html#opt-programs.pay-respects). + - [Radicle](https://radicle.xyz), an open source, peer-to-peer code collaboration stack built on Git. Available as [services.radicle](#opt-services.radicle.enable). - [ddns-updater](https://github.com/qdm12/ddns-updater), a service with a WebUI to update DNS records periodically for many providers. Available as [services.ddns-updater](#opt-services.ddns-updater.enable). diff --git a/nixos/modules/programs/pay-respects.nix b/nixos/modules/programs/pay-respects.nix new file mode 100644 index 00000000000000..a3fdcf5b88485b --- /dev/null +++ b/nixos/modules/programs/pay-respects.nix @@ -0,0 +1,56 @@ +{ + config, + pkgs, + lib, + ... +}: +let + inherit (lib) + getExe + maintainers + mkEnableOption + mkIf + mkOption + types + ; + inherit (types) str; + cfg = config.programs.pay-respects; + + initScript = + shell: + if (shell != "fish") then + '' + eval $(${getExe pkgs.pay-respects} ${shell} --alias ${cfg.alias}) + '' + else + '' + ${getExe pkgs.pay-respects} ${shell} --alias ${cfg.alias} | source + ''; +in +{ + options = { + programs.pay-respects = { + enable = mkEnableOption "pay-respects, an app which corrects your previous console command"; + + alias = mkOption { + default = "f"; + type = str; + description = '' + `pay-respects` needs an alias to be configured. + The default value is `f`, but you can use anything else as well. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + environment.systemPackages = [ pkgs.pay-respects ]; + + programs = { + bash.interactiveShellInit = initScript "bash"; + fish.interactiveShellInit = mkIf config.programs.fish.enable initScript "fish"; + zsh.interactiveShellInit = mkIf config.programs.zsh.enable initScript "zsh"; + }; + }; + meta.maintainers = with maintainers; [ sigmasquadron ]; +} diff --git a/pkgs/by-name/pa/pay-respects/package.nix b/pkgs/by-name/pa/pay-respects/package.nix new file mode 100644 index 00000000000000..50b0f6398a2a23 --- /dev/null +++ b/pkgs/by-name/pa/pay-respects/package.nix @@ -0,0 +1,27 @@ +{ + lib, + fetchFromGitea, + rustPlatform, +}: +rustPlatform.buildRustPackage rec { + pname = "pay-respects"; + version = "0.4.18"; + + src = fetchFromGitea { + domain = "codeberg.org"; + owner = "iff"; + repo = "pay-respects"; + rev = "v${version}"; + hash = "sha256-8YQgNOqZAMhn93rk0fw1SV02XhI/Wt9D5Rzo64cCs7s="; + }; + + cargoHash = "sha256-xLAJLwzX923E7Pzfwdw38moLOlY0Q4xK8himbKHQ7O8="; + + meta = { + description = "Terminal command correction, alternative to `thefuck`, written in Rust"; + homepage = "https://codeberg.org/iff/pay-respects"; + license = lib.licenses.agpl3Plus; + maintainers = with lib.maintainers; [ sigmasquadron ]; + mainProgram = "pay-respects"; + }; +}