diff --git a/.github/workflows/nix-build.yaml b/.github/workflows/nix-build.yaml new file mode 100644 index 0000000..7b5bf20 --- /dev/null +++ b/.github/workflows/nix-build.yaml @@ -0,0 +1,21 @@ +name: Build xdph (Nix) + +on: [push, pull_request, workflow_dispatch] +jobs: + nix: + name: "Build" + runs-on: ubuntu-latest + steps: + - name: Clone repository + uses: actions/checkout@v3 + with: + submodules: recursive + - name: Install nix + uses: cachix/install-nix-action@v17 + with: + install_url: https://releases.nixos.org/nix/nix-2.10.3/install + extra_nix_config: | + auto-optimise-store = true + experimental-features = nix-command flakes + - name: Build xdg-desktop-portal-hyprland + run: nix build --print-build-logs diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..bb9feaa --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1669969257, + "narHash": "sha256-mOS13sK3v+kfgP+1Mh56ohiG8uVhLHAo7m/q9kqAehc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b72b8b94cf0c012b0252a9100a636cad69696666", + "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..7db442e --- /dev/null +++ b/flake.nix @@ -0,0 +1,35 @@ +{ + description = "xdg-desktop-portal-hyprland"; + + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + + outputs = { + self, + nixpkgs, + ... + }: let + inherit (nixpkgs) lib; + genSystems = lib.genAttrs [ + "aarch64-linux" + "x86_64-linux" + ]; + pkgsFor = nixpkgs.legacyPackages; + mkDate = longDate: (lib.concatStringsSep "-" [ + (builtins.substring 0 4 longDate) + (builtins.substring 4 2 longDate) + (builtins.substring 6 2 longDate) + ]); + in { + 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"); + }; + }; + + packages = genSystems (system: + (self.overlays.default null pkgsFor.${system}) + // {default = self.packages.${system}.xdg-desktop-portal-hyprland;}); + + formatter = genSystems (system: pkgsFor.${system}.alejandra); + }; +} diff --git a/nix/default.nix b/nix/default.nix new file mode 100644 index 0000000..c6b1f72 --- /dev/null +++ b/nix/default.nix @@ -0,0 +1,48 @@ +{ + lib, + stdenv, + fetchpatch, + makeWrapper, + meson, + ninja, + pkg-config, + wayland-protocols, + wayland-scanner, + grim, + inih, + libdrm, + mesa, + pipewire, + slurp, + systemd, + wayland, + src, + version ? "git", +}: +stdenv.mkDerivation { + pname = "xdg-desktop-portal-hyprland"; + inherit version; + + src = ../.; + + strictDeps = true; + depsBuildBuild = [pkg-config]; + nativeBuildInputs = [meson ninja pkg-config wayland-scanner makeWrapper]; + buildInputs = [inih libdrm mesa pipewire systemd wayland wayland-protocols]; + + mesonFlags = [ + "-Dsd-bus-provider=libsystemd" + ]; + + postInstall = '' + wrapProgram $out/libexec/xdg-desktop-portal-hyprland --prefix PATH ":" ${lib.makeBinPath [grim slurp]} + ''; + + meta = with lib; { + homepage = "https://github.com/emersion/xdg-desktop-portal-hyprland"; + description = "xdg-desktop-portal backend for Hyprland"; + maintainers = with maintainers; [fufexan]; + platforms = platforms.linux; + license = licenses.mit; + }; +}