From 3be001b7479e4f27ee676f25d7f00dc9f158458f Mon Sep 17 00:00:00 2001 From: Mihai Fufezan Date: Sun, 4 Dec 2022 22:55:47 +0200 Subject: [PATCH] nix: add hyprland-protocols and streamline build --- flake.lock | 17 +++++++++++++++++ flake.nix | 12 ++++++++++-- meson.build | 2 +- nix/default.nix | 7 +++++++ nix/hyprland-share-picker.nix | 13 ++++++++++++- 5 files changed, 47 insertions(+), 4 deletions(-) diff --git a/flake.lock b/flake.lock index bb9feaa..05f5201 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,21 @@ { "nodes": { + "hyprland-protocols": { + "flake": false, + "locked": { + "lastModified": 1670185345, + "narHash": "sha256-hxWGqlPecqEsE6nOHDV29KFBKePbY2Ipeac6lrChMKY=", + "owner": "hyprwm", + "repo": "hyprland-protocols", + "rev": "4623a404c091e64743ba310199bb380ec52f1936", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprland-protocols", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1669969257, @@ -18,6 +34,7 @@ }, "root": { "inputs": { + "hyprland-protocols": "hyprland-protocols", "nixpkgs": "nixpkgs" } } diff --git a/flake.nix b/flake.nix index 7db442e..b622712 100644 --- a/flake.nix +++ b/flake.nix @@ -1,13 +1,20 @@ { description = "xdg-desktop-portal-hyprland"; - inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + + hyprland-protocols = { + url = "github:hyprwm/hyprland-protocols"; + flake = false; + }; + }; outputs = { self, nixpkgs, ... - }: let + } @ inputs: let inherit (nixpkgs) lib; genSystems = lib.genAttrs [ "aarch64-linux" @@ -23,6 +30,7 @@ overlays.default = _: prev: { xdg-desktop-portal-hyprland = prev.callPackage ./nix/default.nix { version = "0.pre" + "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty"); + inherit (inputs) hyprland-protocols; }; }; diff --git a/meson.build b/meson.build index 8a03317..25d80c8 100644 --- a/meson.build +++ b/meson.build @@ -100,7 +100,7 @@ executable( ], include_directories: [inc], install: true, - install_dir: 'libexecdir', + install_dir: get_option('libexecdir'), ) conf_data = configuration_data() diff --git a/nix/default.nix b/nix/default.nix index 85fafd4..6854515 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -9,6 +9,7 @@ wayland-protocols, wayland-scanner, grim, + hyprland-protocols, inih, libdrm, mesa, @@ -32,6 +33,12 @@ in nativeBuildInputs = [meson ninja pkg-config wayland-scanner makeWrapper]; buildInputs = [inih libdrm mesa pipewire systemd wayland wayland-protocols]; + preConfigure = '' + rmdir protocols/hyprland-protocols + + ln -s ${hyprland-protocols.outPath}/ protocols/hyprland-protocols + ''; + mesonFlags = [ "-Dsd-bus-provider=libsystemd" ]; diff --git a/nix/hyprland-share-picker.nix b/nix/hyprland-share-picker.nix index 606b7b7..c1da63f 100644 --- a/nix/hyprland-share-picker.nix +++ b/nix/hyprland-share-picker.nix @@ -3,7 +3,10 @@ lib, cmake, qtbase, + makeShellWrapper, wrapQtAppsHook, + grim, + slurp, version ? "git", ... }: @@ -12,6 +15,14 @@ stdenv.mkDerivation { inherit version; src = ../hyprland-share-picker; - nativeBuildInputs = [cmake wrapQtAppsHook]; + nativeBuildInputs = [cmake wrapQtAppsHook makeShellWrapper]; buildInputs = [qtbase]; + + dontWrapQtApps = true; + + postInstall = '' + wrapProgramShell $out/bin/hyprland-share-picker \ + "''${qtWrapperArgs[@]}" \ + --prefix PATH ":" ${lib.makeBinPath [grim slurp]} + ''; }