From d57c3177c103b3003f7004b8692af766f71d7b15 Mon Sep 17 00:00:00 2001 From: James Magahern Date: Sun, 16 Aug 2026 21:52:28 -0700 Subject: [PATCH] nix: add standalone project flake --- AGENTS.md | 3 +- README.md | 22 ++++++++++++-- flake.lock | 27 ++++++++++++++++++ flake.nix | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 133 insertions(+), 3 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/AGENTS.md b/AGENTS.md index b4a8364..69be509 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -16,6 +16,7 @@ sockets. - `src/model.rs`: client data, application grouping, address normalization, and focus history. - `src/desktop.rs`: XDG desktop-file metadata and icon lookup. +- `flake.nix`: standalone Nix package, app, checks, and development shell. - `../hyprland.conf`: source configuration integration. The live config may be deployed from another checkout; verify it before editing or reloading. @@ -53,6 +54,7 @@ cargo fmt --check cargo test cargo clippy --workspace --all-targets -- -D warnings cargo build --release +nix flake check ``` Install a tested build with: @@ -80,4 +82,3 @@ proportional runtime checks in a live Hyprland session. Preserve unrelated dirty changes in both configuration checkouts. Use `readlink -f ~/.config/hypr/hyprland.conf` before assuming the workspace copy is the active one. - diff --git a/README.md b/README.md index 3d19de6..d3fba44 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,23 @@ other workspaces. ## Build and install +### Nix + +The project flake owns the Rust and GTK build dependencies. Build or run the +locked package directly: + +```sh +nix build +nix run . -- show +``` + +Use `nix develop` for a shell containing Cargo, Clippy, rustfmt, and the native +GTK dependencies. Downstream flakes can install +`packages.${system}.default` and make this flake's `nixpkgs` input follow +their own. + +### Cargo + Run this from the directory containing this README: ```sh @@ -48,8 +65,9 @@ cargo clippy --workspace --all-targets -- -D warnings cargo install --path . --root ~/.local --force ``` -The binary is installed as `~/.local/bin/hypr-switcher`. The accompanying -`../hyprland.conf` starts the daemon and defines the bindings: +The binary is installed as `~/.local/bin/hypr-switcher`. A Nix profile usually +exposes it as `~/.nix-profile/bin/hypr-switcher`. Configure the applicable +absolute path, then start the daemon and define the bindings: ```ini $switcher = ~/.local/bin/hypr-switcher diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..3cfef49 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1786862985, + "narHash": "sha256-FBJRXmbGXiSUDvYEbfLYRkckayyZ6SK1UEqhCrIZ2Cs=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e5bdc4a41d4c072fe1e3787eaa0320a384741d44", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..b2ab933 --- /dev/null +++ b/flake.nix @@ -0,0 +1,84 @@ +{ + description = "macOS-style application switching and hiding for Hyprland"; + + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + + outputs = + { self, nixpkgs }: + let + supportedSystems = [ + "x86_64-linux" + "aarch64-linux" + ]; + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + pkgsFor = system: import nixpkgs { inherit system; }; + in + { + packages = forAllSystems ( + system: + let + pkgs = pkgsFor system; + in + rec { + hypr-switcher = pkgs.rustPlatform.buildRustPackage { + pname = "hypr-switcher"; + version = "0.1.0"; + src = pkgs.lib.cleanSource ./.; + + cargoLock.lockFile = ./Cargo.lock; + + nativeBuildInputs = with pkgs; [ + pkg-config + wrapGAppsHook4 + ]; + + buildInputs = with pkgs; [ + gtk4 + gtk4-layer-shell + ]; + + meta = { + description = "macOS-style application switcher for Hyprland"; + homepage = "https://code.buzzert.dev/buzzert/hypr-switcher"; + mainProgram = "hypr-switcher"; + platforms = pkgs.lib.platforms.linux; + }; + }; + + default = hypr-switcher; + } + ); + + apps = forAllSystems (system: { + hypr-switcher = { + type = "app"; + program = "${self.packages.${system}.hypr-switcher}/bin/hypr-switcher"; + }; + default = self.apps.${system}.hypr-switcher; + }); + + checks = forAllSystems (system: { + default = self.packages.${system}.hypr-switcher; + }); + + devShells = forAllSystems ( + system: + let + pkgs = pkgsFor system; + in + { + default = pkgs.mkShell { + inputsFrom = [ self.packages.${system}.hypr-switcher ]; + packages = with pkgs; [ + cargo + clippy + rustc + rustfmt + ]; + }; + } + ); + + formatter = forAllSystems (system: (pkgsFor system).nixfmt); + }; +}