Improve build process and nix scripts

This commit is contained in:
outfoxxed 2024-03-05 03:13:50 -08:00
parent 3924816ba2
commit c880e0f009
No known key found for this signature in database
GPG key ID: 4C88A185FB89301E
5 changed files with 103 additions and 43 deletions

20
.gitignore vendored
View file

@ -1,4 +1,16 @@
build/ # build
compile_commands.json /result
.vscode/ /build/
*.log /compile_commands.json
# clangd
/.cache
# direnv
/.envrc
/.direnv/
# vscode
/.vscode/
/*.log

51
default.nix Normal file
View file

@ -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;
};
}

View file

@ -5,51 +5,32 @@
outputs = { self, hyprland, ... }: let outputs = { self, hyprland, ... }: let
inherit (hyprland.inputs) nixpkgs; 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 { in {
packages = hyprlandSystems (system: pkgs: let packages = hyprlandSystems (system: pkgs: rec {
hyprlandPackage = hyprland.packages.${system}.hyprland; hy3 = pkgs.callPackage ./default.nix {
in rec { hyprland = hyprland.packages.${system}.hyprland;
hy3 = hyprlandPackage.stdenv.mkDerivation { hlversion = props.version;
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;
};
}; };
default = hy3; default = hy3;
}); });
devShells = hyprlandSystems (system: pkgs: { devShells = hyprlandSystems (system: pkgs: {
default = pkgs.mkShell.override { default = import ./shell.nix {
stdenv = pkgs.gcc13Stdenv; inherit pkgs;
} { hlversion = props.version;
name = "hy3"; hyprland = hyprland.packages.${system}.hyprland-debug;
};
nativeBuildInputs = with pkgs; [ impure = import ./shell.nix {
clang-tools_17 pkgs = import <nixpkgs> {};
bear hlversion = props.version;
]; hyprland = (pkgs.appendOverlays [ hyprland.overlays.hyprland-packages ]).hyprland-debug;
inputsFrom = [ self.packages.${system}.hy3 ];
}; };
}); });
}; };

View file

@ -11,6 +11,6 @@ description = "i3 like tiling for hyprland"
authors = ["outfoxxed"] authors = ["outfoxxed"]
output = "build/libhy3.so" output = "build/libhy3.so"
build = [ build = [
"cmake -DCMAKE_BUILD_TYPE=Release -B build", "cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -B build",
"cmake --build build" "cmake --build build"
] ]

16
shell.nix Normal file
View file

@ -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
];
}