diff --git a/.gitignore b/.gitignore index 36b6e89..5862322 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,16 @@ -build/ -compile_commands.json -.vscode/ -*.log +# build +/result +/build/ +/compile_commands.json + +# clangd +/.cache + +# direnv +/.envrc +/.direnv/ + +# vscode +/.vscode/ + +/*.log diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..1925ec5 --- /dev/null +++ b/default.nix @@ -0,0 +1,51 @@ +{ + hyprland, + + lib, + nix-gitignore, + keepDebugInfo, + stdenv ? (keepDebugInfo hyprland.stdenv), + + cmake, + ninja, + pkg-config, + pango, + cairo, + + debug ? false, + hlversion ? "git", + versionCheck ? true, +}: stdenv.mkDerivation { + pname = "hy3"; + version = "hl${hlversion}${lib.optionalString debug "-debug"}"; + src = nix-gitignore.gitignoreSource [] ./.; + + nativeBuildInputs = [ + cmake + ninja + pkg-config + ]; + + buildInputs = [ + hyprland.dev + pango + cairo + ] ++ hyprland.buildInputs; + + cmakeFlags = lib.optional (!versionCheck) "-DHY3_NO_VERSION_CHECK=ON"; + + cmakeBuildType = if debug + then "Debug" + else "RelWithDebInfo"; + + buildPhase = "ninjaBuildPhase"; + enableParallelBuilding = true; + dontStrip = true; + + meta = with lib; { + homepage = "https://github.com/outfoxxed/hy3"; + description = "Hyprland plugin for an i3 like manual tiling layout"; + license = licenses.gpl3; + platforms = platforms.linux; + }; +} diff --git a/flake.nix b/flake.nix index a250f37..a375308 100644 --- a/flake.nix +++ b/flake.nix @@ -5,51 +5,32 @@ outputs = { self, hyprland, ... }: let inherit (hyprland.inputs) nixpkgs; - hyprlandSystems = fn: nixpkgs.lib.genAttrs (builtins.attrNames hyprland.packages) (system: fn system nixpkgs.legacyPackages.${system}); + + hyprlandSystems = fn: nixpkgs.lib.genAttrs + (builtins.attrNames hyprland.packages) + (system: fn system nixpkgs.legacyPackages.${system}); + + props = builtins.fromJSON (builtins.readFile "${hyprland}/props.json"); in { - packages = hyprlandSystems (system: pkgs: let - hyprlandPackage = hyprland.packages.${system}.hyprland; - in rec { - hy3 = hyprlandPackage.stdenv.mkDerivation { - pname = "hy3"; - version = "0.1"; - src = ./.; - - nativeBuildInputs = with pkgs; [ cmake pkg-config ]; - - buildInputs = with pkgs; [ - hyprlandPackage.dev - pango - cairo - ] ++ hyprlandPackage.buildInputs; - - # no noticeable impact on performance and greatly assists debugging - cmakeBuildType = "Debug"; - dontStrip = true; - - meta = with pkgs.lib; { - homepage = "https://github.com/outfoxxed/hy3"; - description = "Hyprland plugin for an i3 / sway like manual tiling layout"; - license = licenses.gpl3; - platforms = platforms.linux; - }; + packages = hyprlandSystems (system: pkgs: rec { + hy3 = pkgs.callPackage ./default.nix { + hyprland = hyprland.packages.${system}.hyprland; + hlversion = props.version; }; - default = hy3; }); devShells = hyprlandSystems (system: pkgs: { - default = pkgs.mkShell.override { - stdenv = pkgs.gcc13Stdenv; - } { - name = "hy3"; + default = import ./shell.nix { + inherit pkgs; + hlversion = props.version; + hyprland = hyprland.packages.${system}.hyprland-debug; + }; - nativeBuildInputs = with pkgs; [ - clang-tools_17 - bear - ]; - - inputsFrom = [ self.packages.${system}.hy3 ]; + impure = import ./shell.nix { + pkgs = import {}; + hlversion = props.version; + hyprland = (pkgs.appendOverlays [ hyprland.overlays.hyprland-packages ]).hyprland-debug; }; }); }; diff --git a/hyprpm.toml b/hyprpm.toml index 012b379..b7178b2 100644 --- a/hyprpm.toml +++ b/hyprpm.toml @@ -11,6 +11,6 @@ description = "i3 like tiling for hyprland" authors = ["outfoxxed"] output = "build/libhy3.so" build = [ - "cmake -DCMAKE_BUILD_TYPE=Release -B build", + "cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -B build", "cmake --build build" ] diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..1cd716e --- /dev/null +++ b/shell.nix @@ -0,0 +1,16 @@ +{ + hyprland, + pkgs, + hlversion ? "git", + hy3 ? pkgs.callPackage ./default.nix { + inherit hyprland hlversion; + versionCheck = false; + }, +}: pkgs.mkShell { + inputsFrom = [ hy3 ]; + + nativeBuildInputs = with pkgs; [ + clang-tools_17 + bear + ]; +}