From 205ef4d7f8adf8d831d053e87f0e0df98022476a Mon Sep 17 00:00:00 2001 From: Mihai Fufezan Date: Wed, 16 Aug 2023 22:28:45 +0300 Subject: [PATCH] add initial pluginBuilder --- all.nix | 44 +++++++++++++++++++++++++++++++++++ borders-plus-plus/default.nix | 11 +-------- csgo-vulkan-fix/default.nix | 11 +-------- flake.nix | 31 ++++++++++++------------ hyprbars/default.nix | 11 +-------- lib/builder.nix | 17 ++++++++++++++ lib/default.nix | 3 +++ 7 files changed, 83 insertions(+), 45 deletions(-) create mode 100644 all.nix create mode 100644 lib/builder.nix create mode 100644 lib/default.nix diff --git a/all.nix b/all.nix new file mode 100644 index 0000000..28184e9 --- /dev/null +++ b/all.nix @@ -0,0 +1,44 @@ +{ + builder, + lib, +}: +lib.mapAttrs (n: v: builder v) { + borders-plus-plus = { + pname = "borders-plus-plus"; + version = "0.1"; + src = ./.; + + meta = with lib; { + homepage = "https://github.com/hyprwm/hyprland-plugins"; + description = "Hyprland borders-plus-plus plugin"; + license = licenses.bsd3; + platforms = platforms.linux; + }; + }; + + csgo-vulkan-fix = { + pname = "csgo-vulkan-fix"; + version = "0.1"; + src = ./.; + + meta = with lib; { + homepage = "https://github.com/hyprwm/hyprland-plugins"; + description = "Hyprland CS:GO Vulkan fix"; + license = licenses.bsd3; + platforms = platforms.linux; + }; + }; + + hyprbars = { + pname = "hyprbars"; + version = "0.1"; + src = ./.; + + meta = with lib; { + homepage = "https://github.com/hyprwm/hyprland-plugins"; + description = "Hyprland window title plugin"; + license = licenses.bsd3; + platforms = platforms.linux; + }; + }; +} diff --git a/borders-plus-plus/default.nix b/borders-plus-plus/default.nix index 3f78dd6..ec8698e 100644 --- a/borders-plus-plus/default.nix +++ b/borders-plus-plus/default.nix @@ -1,17 +1,8 @@ -{ - lib, - stdenv, - hyprland, -}: -stdenv.mkDerivation { +lib: { pname = "borders-plus-plus"; version = "0.1"; src = ./.; - inherit (hyprland) nativeBuildInputs; - - buildInputs = [hyprland] ++ hyprland.buildInputs; - meta = with lib; { homepage = "https://github.com/hyprwm/hyprland-plugins"; description = "Hyprland borders-plus-plus plugin"; diff --git a/csgo-vulkan-fix/default.nix b/csgo-vulkan-fix/default.nix index 7671518..5162b06 100644 --- a/csgo-vulkan-fix/default.nix +++ b/csgo-vulkan-fix/default.nix @@ -1,17 +1,8 @@ -{ - lib, - stdenv, - hyprland, -}: -stdenv.mkDerivation { +lib: { pname = "csgo-vulkan-fix"; version = "0.1"; src = ./.; - inherit (hyprland) nativeBuildInputs; - - buildInputs = [hyprland] ++ hyprland.buildInputs; - meta = with lib; { homepage = "https://github.com/hyprwm/hyprland-plugins"; description = "Hyprland CS:GO Vulkan fix"; diff --git a/flake.nix b/flake.nix index 31205b2..c41ffe9 100644 --- a/flake.nix +++ b/flake.nix @@ -7,22 +7,23 @@ self, hyprland, }: let - inherit (hyprland.inputs) nixpkgs; - withPkgsFor = fn: nixpkgs.lib.genAttrs (builtins.attrNames hyprland.packages) (system: fn system nixpkgs.legacyPackages.${system}); + inherit (hyprland.inputs) nixpkgs systems; + inherit (nixpkgs) lib; + inherit (import ./lib) pluginBuilder; + withPkgsFor = fn: lib.genAttrs (import systems) (system: fn system nixpkgs.legacyPackages.${system}); in { - packages = withPkgsFor (system: pkgs: { - borders-plus-plus = pkgs.callPackage ./borders-plus-plus { - inherit (hyprland.packages.${system}) hyprland; - stdenv = pkgs.gcc13Stdenv; - }; - csgo-vulkan-fix = pkgs.callPackage ./csgo-vulkan-fix { - inherit (hyprland.packages.${system}) hyprland; - stdenv = pkgs.gcc13Stdenv; - }; - hyprbars = pkgs.callPackage ./hyprbars { - inherit (hyprland.packages.${system}) hyprland; - stdenv = pkgs.gcc13Stdenv; - }; + packages = withPkgsFor (system: pkgs: let + builder = pluginBuilder hyprland pkgs.gcc13Stdenv; + in { + borders-plus-plus = builder (import ./borders-plus-plus lib); + csgo-vulkan-fix = builder (import ./csgo-vulkan-fix lib); + hyprbars = builder (import ./hyprbars lib); + }); + + legacyPackages = withPkgsFor (system: pkgs: let + builder = pluginBuilder hyprland pkgs.stdenv; + in { + all = import ./all.nix {inherit builder lib;}; }); devShells = withPkgsFor (system: pkgs: { diff --git a/hyprbars/default.nix b/hyprbars/default.nix index 4ffb1d8..eaf5beb 100644 --- a/hyprbars/default.nix +++ b/hyprbars/default.nix @@ -1,17 +1,8 @@ -{ - lib, - stdenv, - hyprland, -}: -stdenv.mkDerivation { +lib: { pname = "hyprbars"; version = "0.1"; src = ./.; - inherit (hyprland) nativeBuildInputs; - - buildInputs = [hyprland] ++ hyprland.buildInputs; - meta = with lib; { homepage = "https://github.com/hyprwm/hyprland-plugins"; description = "Hyprland window title plugin"; diff --git a/lib/builder.nix b/lib/builder.nix new file mode 100644 index 0000000..ffbdfbb --- /dev/null +++ b/lib/builder.nix @@ -0,0 +1,17 @@ +hyprland: stdenv: { + pname, + version ? "dirty", + src, + buildInputs ? [], + meta ? {}, +}: let + hl = hyprland.packages.${stdenv.hostPlatform.system}.default; +in + stdenv.mkDerivation { + inherit pname version src; + + inherit (hl) nativeBuildInputs; + buildInputs = hl.buildInputs ++ [hl.dev] ++ buildInputs; + + inherit meta; + } diff --git a/lib/default.nix b/lib/default.nix new file mode 100644 index 0000000..23d9931 --- /dev/null +++ b/lib/default.nix @@ -0,0 +1,3 @@ +{ + pluginBuilder = import ./builder.nix; +}