Skip to content
Open
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
59 changes: 47 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ A wayland native krunner-like runner, made with customizability in mind.
<img width="950" height="702" alt="image" src="https://github.com/user-attachments/assets/0a53b435-58f5-4a7c-90f7-b3f39266f2f4" />

> [!NOTE]
> If you use Nvidia and Anyrun refuses to close for you, you need to set `GSK_RENDERER=ngl` for Anyrun.
> As in, running it with `GSK_RENDERER=ngl anyrun`. This is a [known issue](https://forums.developer.nvidia.com/t/580-65-06-gtk-4-apps-hang-when-attempting-to-exit-close/341308/6)
> If you use Nvidia and Anyrun refuses to close for you, you need to set
> `GSK_RENDERER=ngl` for Anyrun. As in, running it with
> `GSK_RENDERER=ngl anyrun`. This is a
> [known issue](https://forums.developer.nvidia.com/t/580-65-06-gtk-4-apps-hang-when-attempting-to-exit-close/341308/6)
> and is quite driver version dependent.

## Features
Expand All @@ -30,8 +32,8 @@ A wayland native krunner-like runner, made with customizability in mind.

### Dependencies

Anyrun mainly depends various GTK4 libraries, and rust of course for building the
project. Rust you can get with [rustup](https://rustup.rs). The rest are
Anyrun mainly depends various GTK4 libraries, and rust of course for building
the project. Rust you can get with [rustup](https://rustup.rs). The rest are
statically linked in the binary. Here are the libraries you need to have to
build & run it:

Expand All @@ -48,11 +50,13 @@ build & run it:

### Nix

An Anyrun package that contains all the official plugins is available in [nixpkgs](https://search.nixos.org/packages?channel=unstable&show=anyrun&from=0&size=50&sort=relevance&type=packages&query=anyrun).
An Anyrun package that contains all the official plugins is available in
[nixpkgs](https://search.nixos.org/packages?channel=unstable&show=anyrun&from=0&size=50&sort=relevance&type=packages&query=anyrun).

#### Home-Manager module

The preferred way to use Home-Manager with Anyrun is by using the upstream module.
The preferred way to use Home-Manager with Anyrun is by using the upstream
module.

You may use it in your system like this:

Expand Down Expand Up @@ -145,8 +149,39 @@ nix.settings = {

> [!WARNING]
> While using the Anyrun flake, overriding the `nixpkgs` input for Anyrun will
> cause cache misses, i.e., you will have to build from source every time. To use
> the cache, do _not_ override the Nixpkgs input.
> cause cache misses, i.e., you will have to build from source every time. To
> use the cache, do _not_ override the Nixpkgs input.

### Hjem module

We also provide a Hjem module, which comes with the exact same API as the
Home-Manager one. You may import it in your configuration like so:

```nix
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
hjem.url = "github:feel-co/hjem";
anyrun.url = "github:anyrun-org/anyrun";
};
outputs = {self, ...}@inputs: {
nixosConfigurations.hostname = inputs.nixpkgs.lib.nixosSystem {
modules = [
({
hjem.extraModules = [
inputs.anyrun.hjemModules.default
];
})
{
programs.anyrun = {
# ...
};
}
];
};
}
}
```

### Manual installation

Expand Down Expand Up @@ -224,8 +259,8 @@ use them.

## Styling

Anyrun supports [GTK4 CSS](https://docs.gtk.org/gtk4/css-properties.html) styling.
The style classes and widgets that use them are as follows:
Anyrun supports [GTK4 CSS](https://docs.gtk.org/gtk4/css-properties.html)
styling. The style classes and widgets that use them are as follows:

- No class, unique widget:
- `GtkText`: The main entry box
Expand All @@ -248,8 +283,8 @@ The style classes and widgets that use them are as follows:
- `.description`
- `GtkLabel`: The description (if present)

Refer to the [default style](anyrun/res/style.css) for an example, and use `GTK_DEBUG=interactive anyrun`
to edit styles live.
Refer to the [default style](anyrun/res/style.css) for an example, and use
`GTK_DEBUG=interactive anyrun` to edit styles live.

## Arguments

Expand Down
161 changes: 79 additions & 82 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,105 +14,102 @@
};
};

outputs =
{
self,
flake-parts,
systems,
...
}@inputs:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [ flake-parts.flakeModules.easyOverlay ];
outputs = {
self,
flake-parts,
systems,
...
} @ inputs:
flake-parts.lib.mkFlake {inherit inputs;} {
imports = [flake-parts.flakeModules.easyOverlay];
systems = import systems;

perSystem =
{
self',
config,
pkgs,
...
}:
let
inherit (pkgs) callPackage;
in
{
packages =
let
lockFile = ./Cargo.lock;
perSystem = {
self',
config,
pkgs,
...
}: let
inherit (pkgs) callPackage;
in {
packages = let
lockFile = ./Cargo.lock;

# Since all plugin derivations are called with the exact same arguments
# it is possible to streamline calling packages with a single function
# that takes name as an argument, and handles default inherits.
mkPlugin =
name:
callPackage ./nix/packages/plugin.nix {
inherit inputs lockFile;
inherit name;
};
in
{
default = self'.packages.anyrun;

# By default the anyrun package is built without any plugins
# as per the `dontBuildPlugins` arg.
anyrun = callPackage ./nix/packages/anyrun.nix { inherit inputs lockFile; };
anyrun-with-all-plugins = callPackage ./nix/packages/anyrun.nix {
inherit inputs lockFile;
dontBuildPlugins = false;
};
# Since all plugin derivations are called with the exact same arguments
# it is possible to streamline calling packages with a single function
# that takes name as an argument, and handles default inherits.
mkPlugin = name:
callPackage ./nix/packages/plugin.nix {
inherit inputs lockFile;
inherit name;
};
in {
default = self'.packages.anyrun;

# Expose each plugin as a separate package. This uses the mkPlugin function
# to call the same derivation with same default inherits and the name of the
# plugin every time.
applications = mkPlugin "applications";
dictionary = mkPlugin "dictionary";
kidex = mkPlugin "kidex";
nix-run = mkPlugin "nix-run";
randr = mkPlugin "randr";
rink = mkPlugin "rink";
shell = mkPlugin "shell";
stdin = mkPlugin "stdin";
symbols = mkPlugin "symbols";
translate = mkPlugin "translate";
websearch = mkPlugin "websearch";
niri-focus = mkPlugin "niri-focus";
# By default the anyrun package is built without any plugins
# as per the `dontBuildPlugins` arg.
anyrun = callPackage ./nix/packages/anyrun.nix {inherit inputs lockFile;};
anyrun-with-all-plugins = callPackage ./nix/packages/anyrun.nix {
inherit inputs lockFile;
dontBuildPlugins = false;
};

anyrun-provider = inputs.anyrun-provider.packages.${pkgs.system}.default;
};
# Expose each plugin as a separate package. This uses the mkPlugin function
# to call the same derivation with same default inherits and the name of the
# plugin every time.
applications = mkPlugin "applications";
dictionary = mkPlugin "dictionary";
kidex = mkPlugin "kidex";
nix-run = mkPlugin "nix-run";
randr = mkPlugin "randr";
rink = mkPlugin "rink";
shell = mkPlugin "shell";
stdin = mkPlugin "stdin";
symbols = mkPlugin "symbols";
translate = mkPlugin "translate";
websearch = mkPlugin "websearch";
niri-focus = mkPlugin "niri-focus";

# Set up an overlay from packages exposed by this flake
overlayAttrs = config.packages;
anyrun-provider = inputs.anyrun-provider.packages.${pkgs.system}.default;
};

devShells = {
default = pkgs.mkShell {
inputsFrom = builtins.attrValues self'.packages;
packages = with pkgs; [
rustc
gcc
cargo
clippy
rustfmt
];
};
# Set up an overlay from packages exposed by this flake
overlayAttrs = config.packages;

nix = pkgs.mkShellNoCC {
packages = with pkgs; [
alejandra # formatter
statix # linter
deadnix # dead-code finder
];
};
devShells = {
default = pkgs.mkShell {
inputsFrom = builtins.attrValues self'.packages;
packages = with pkgs; [
rustc
gcc
cargo
clippy
rustfmt
];
};

# provide the formatter for nix fmt
formatter = pkgs.alejandra;
nix = pkgs.mkShellNoCC {
packages = with pkgs; [
alejandra # formatter
statix # linter
deadnix # dead-code finder
];
};
};

# provide the formatter for nix fmt
formatter = pkgs.alejandra;
};

flake = {
homeManagerModules = {
anyrun = import ./nix/modules/home-manager.nix self;
default = self.homeManagerModules.anyrun;
};
hjemModules = {
anyrun = import ./nix/modules/hjem.nix self;
default = self.hjemModules.anyrun;
};
};
};
}
82 changes: 82 additions & 0 deletions nix/lib.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
lib: let
inherit
(builtins)
map
toString
substring
stringLength
;
inherit
(lib.strings)
concatMapStringsSep
toLower
toUpper
replaceStrings
optionalString
;

assertNumeric = numeric: {
assertion =
!(
(numeric ? absolute && numeric.absolute != null) && (numeric ? fraction && numeric.fraction != null)
);
message = "Invalid numeric definition, you can only specify one of absolute or fraction.";
};

stringifyNumeric = numeric:
if (numeric ? absolute && numeric.absolute != null)
then "Absolute(${toString numeric.absolute})"
else "Fraction(${toString numeric.fraction})";

capitalize = string: toUpper (substring 0 1 string) + toLower (substring 1 ((stringLength string) - 1) string);

parsedPlugins = plugins: anyrunPackage:
if plugins == null
then []
else
map (
entry:
if lib.types.package.check entry
then "${entry}/lib/lib${replaceStrings ["-"] ["_"] entry.pname}.so"
else let
path = "${anyrunPackage}/lib/${entry}";
in
if builtins.pathExists path
then path
else let
path = "${anyrunPackage}/lib/lib${replaceStrings ["-"] ["_"] entry}.so";
in
if builtins.pathExists path
then path
else if lib.strings.hasPrefix "/" entry
then entry
else throw "Anyrun: Plugin ${entry} does not exist"
)
plugins;

keybinds = keybinds:
if keybinds == null
then ""
else ''
keybinds: [
${
concatMapStringsSep "\n" (x: ''
Keybind(
${optionalString x.ctrl "ctrl: true,"}
${optionalString x.alt "alt: true,"}
key: "${x.key}",
action: ${capitalize x.action},
),
'')
keybinds
}],
'';
keyboardMode = mode:
{
"exclusive" = "Exclusive";
"on-demand" = "OnDemand";
}
.${
mode
};
in {inherit assertNumeric stringifyNumeric capitalize parsedPlugins keybinds keyboardMode;}
Loading