Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,23 @@ scoop install kagi
yay -S kagi-cli
```

### nix / nixos

run it without installing:

```bash
nix run github:Microck/kagi-cli -- search "rust async"
```

install it into your Nix profile:

```bash
nix profile install github:Microck/kagi-cli
```

for NixOS or home-manager, add the flake as an input and use its default
package or `overlays.default`.

### auth

run the guided setup:
Expand Down
21 changes: 21 additions & 0 deletions docs/guides/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The *kagi* CLI can be installed through several methods:
| Package Managers | System integration | Low | Automatic |
| GitHub Releases | Specific versions | Medium | Manual |
| Build from Source | Development, customization | High | Manual |
| Nix Flake | NixOS, Home Manager, reproducible installs | Medium | Manual |

## Quick Install (Recommended)

Expand Down Expand Up @@ -191,6 +192,26 @@ cargo install --path .

**Note on crates.io:** The package is not currently published to crates.io because both `kagi` and `kagi-cli` names are already taken. GitHub Releases remain the canonical distribution method.

### Nix / NixOS

The repository includes a flake for Nix users. It provides the CLI package, a runnable app, shell completions, and a development shell.

Run the CLI without installing it:

```bash
nix run github:Microck/kagi-cli -- search "rust async"
```

Install it into your Nix profile:

```bash
nix profile install github:Microck/kagi-cli
```

For NixOS or Home Manager, add `github:Microck/kagi-cli` as a flake input. Use `kagi.packages.${system}.default` for the package or `kagi.overlays.default` in your package set.

Authentication works the same as with other installation methods. Run `kagi auth` after installation or set the required Kagi environment variable.

## Manual Installation from GitHub Releases

For users who want full control over the installation process or need to install a specific version.
Expand Down
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 60 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
description = "terminal CLI for Kagi subscribers with JSON-first search output";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};

outputs =
{
self,
nixpkgs,
flake-utils,
}:
let
overlay = final: prev: {
kagi = final.callPackage ./nix/kagi.nix { };
};
in
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ overlay ];
};
in
{
packages = {
default = pkgs.kagi;
kagi = pkgs.kagi;
};

apps.default = {
type = "app";
program = "${pkgs.kagi}/bin/kagi";
meta.description = "Run the kagi CLI";
};

checks.kagi = pkgs.kagi;

devShells.default = pkgs.mkShell {
inputsFrom = [ pkgs.kagi ];
packages = with pkgs; [
cargo
rustc
clippy
rustfmt
rust-analyzer
];
RUST_SRC_PATH = "${pkgs.rustPlatform.rustLibSrc}";
};

formatter = pkgs.nixfmt;
}
)
// {
overlays.default = overlay;
};
}
39 changes: 39 additions & 0 deletions nix/kagi.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
lib,
rustPlatform,
installShellFiles,
stdenv,
}:

let
cargoToml = lib.importTOML ../Cargo.toml;
in
rustPlatform.buildRustPackage {
pname = cargoToml.package.name;
version = cargoToml.package.version;

src = lib.cleanSource ../.;
cargoLock.lockFile = ../Cargo.lock;

# reqwest uses rustls-tls, so the package does not need OpenSSL or pkg-config.
nativeBuildInputs = [ installShellFiles ];

# Skip tests when the build host cannot execute the target binary.
doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform;

postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
installShellCompletion --cmd kagi \
--bash <($out/bin/kagi --generate-completion bash) \
--zsh <($out/bin/kagi --generate-completion zsh) \
--fish <($out/bin/kagi --generate-completion fish)
'';

meta = {
description = cargoToml.package.description;
homepage = "https://github.com/Microck/kagi-cli";
changelog = "https://github.com/Microck/kagi-cli/blob/main/CHANGELOG.md";
license = lib.licenses.mit;
mainProgram = "kagi";
platforms = lib.platforms.unix;
};
}