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
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,18 @@ Available on the AUR as [`zlaunch-bin`](https://aur.archlinux.org/packages/zlaun
}
```

The package is available as `zlaunch.packages.${pkgs.system}.default`.
The package is available as `zlaunch.packages.${pkgs.system}.default`. A Home
Manager module is available as `zlaunch.homeManagerModules.default` (for
details see [Installation Instructions](https://zlaunch.zortax.de/docs/getting-started/installation)).

### Building from source

```bash
cargo build --release
```

If you have Nix installed, you can use `nix develop` for a preconfigured dev shell with all dependencies.
If you have Nix installed, you can use `nix develop` for a preconfigured dev
shell with all dependencies.

## Quick Start

Expand Down
169 changes: 141 additions & 28 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,54 @@
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
outputs = {
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system: let
pkgs = nixpkgs.legacyPackages.${system};
in
{
packages.default = pkgs.rustPlatform.buildRustPackage {
pname = "zlaunch";
version = "0.1.0";
src = ./.;

nativeBuildInputs = with pkgs; [
pkg-config
];
in {
packages.default = let
inherit ((pkgs.lib.importTOML ./Cargo.toml).package) name version description repository;
in
pkgs.rustPlatform.buildRustPackage {
pname = name;
inherit version;

buildInputs = with pkgs; [
openssl
libxkbcommon
libxcb
wayland
freetype
fontconfig
];
src = self;
cargoLock = {
lockFile = ./Cargo.lock;
allowBuiltinFetchGit = true;
};

cargoHash = "sha256-jTsq4Ed7REQ+dPgSXud2Frr27VqF99XFRO+v5+PjTeU=";
meta = with pkgs.lib; {
mainProgram = name;
inherit description;
homepage = repository;
license = licenses.mit;
platforms = platforms.linux;
};

postFixup = with pkgs; ''
patchelf --add-rpath ${vulkan-loader}/lib $out/bin/zlaunch
patchelf --add-rpath ${wayland}/lib $out/bin/zlaunch
'';
};
nativeBuildInputs = with pkgs; [
pkg-config
];

buildInputs = with pkgs; [
openssl
libxkbcommon
libxcb
wayland
freetype
fontconfig
];

postFixup = with pkgs; ''
patchelf --add-rpath ${vulkan-loader}/lib $out/bin/zlaunch
patchelf --add-rpath ${wayland}/lib $out/bin/zlaunch
'';
};

devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
Expand Down Expand Up @@ -67,5 +84,101 @@
};
};
}
);
)
// {
homeManagerModules.default = {
config,
lib,
pkgs,
...
}: let
cfg = config.services.zlaunch;
tomlFormat = pkgs.formats.toml {};
pkg = self.packages.${pkgs.stdenv.hostPlatform.system}.default;
in {
options.services.zlaunch = {
enable = lib.mkEnableOption "Enable zlaunch daemon";

settings = lib.mkOption {
type = tomlFormat.type;
default = {};
description = ''
Configuration written to "~/.config/zlaunch/config.toml".
See <https://github.com/zortax/zlaunch> for options, defined via TOML.
All settings are optional with sensible defaults.
'';
example = lib.literalExpression ''
{
theme = "one-dark";
launcher_size = [ 800.0 500.0 ];
enable_backdrop = true;
enable_transparency = true;
hyprland_auto_blur = true;

default_modes = ["combined" "emojis" "clipboard"];
combined_modules = ["calculator" "windows" "applications" "actions"];

fuzzy_match = {
show_best_match = true;
};

search_providers = [
{
name = "GitHub";
trigger = "!gh";
url = "https://github.com/search?q={query}";
}
];
}
'';
};

systemd = {
enable = lib.mkEnableOption "Enable a zlaunch systemd service";

autoStart = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Whether to automatically start the zlaunch service or not";
};

target = lib.mkOption {
type = lib.types.str;
default = "graphical-session.target";
example = "hyprland-session.target";
description = "Which systemd target will start the zlaunch service";
};
};
};

config = lib.mkIf cfg.enable {
home.packages = [
pkg
];

xdg.configFile."zlaunch/config.toml" = lib.mkIf (cfg.settings != {}) {
source = tomlFormat.generate "zlaunch-config" cfg.settings;
};

systemd.user.services.zlaunch = lib.mkIf cfg.systemd.enable {
Unit = {
Description = "Enable a zlaunch systemd service";
Documentation = ["https://github.com/zortax/zlaunch"];
After = [cfg.systemd.target];
PartOf = [cfg.systemd.target];
};
Service = {
Type = "simple";
ExecStart = "${lib.getExe' pkg "zlaunch"}";
Restart = "always";
RestartSec = 5;
KillMode = "process";
};
Install = lib.mkIf cfg.systemd.autoStart {
WantedBy = [cfg.systemd.target];
};
};
};
};
};
}