From 42b9a56256e026557f25a47fc586e261b9744ba3 Mon Sep 17 00:00:00 2001 From: Fernando Ayats Date: Wed, 29 Mar 2023 09:57:23 +0200 Subject: [PATCH] nixify --- .gitignore | 4 +- flake.lock | 112 +++++++++++++++++++++++++++++++++++++++++++ flake.nix | 18 +++++++ hyprbars/default.nix | 39 +++++++++++++++ 4 files changed, 172 insertions(+), 1 deletion(-) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 hyprbars/default.nix diff --git a/.gitignore b/.gitignore index 2cbc7ae..2a7cc14 100644 --- a/.gitignore +++ b/.gitignore @@ -31,4 +31,6 @@ *.out *.app -.vscode/ \ No newline at end of file +.vscode/ +# Nix +*result* diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..df7e5e4 --- /dev/null +++ b/flake.lock @@ -0,0 +1,112 @@ +{ + "nodes": { + "hyprland": { + "inputs": { + "hyprland-protocols": "hyprland-protocols", + "nixpkgs": "nixpkgs", + "wlroots": "wlroots", + "xdph": "xdph" + }, + "locked": { + "lastModified": 1680031067, + "narHash": "sha256-kwywAAnHTx3IohvHDbhgsQjrHdN6ewE/vX+E/9oWmFc=", + "owner": "hyprwm", + "repo": "Hyprland", + "rev": "d6241a3086c4abfd21e91e23c83c97c3f80123d4", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "Hyprland", + "type": "github" + } + }, + "hyprland-protocols": { + "inputs": { + "nixpkgs": [ + "hyprland", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1671839510, + "narHash": "sha256-+PY1qqJfmZzzROgcIY4I7AkCwpnC+qBIYk2eFoA9RWc=", + "owner": "hyprwm", + "repo": "hyprland-protocols", + "rev": "b8f55e02a328c47ed373133c52483bbfa20a1b75", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprland-protocols", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1679172431, + "narHash": "sha256-XEh5gIt5otaUbEAPUY5DILUTyWe1goAyeqQtmwaFPyI=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "1603d11595a232205f03d46e635d919d1e1ec5b9", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "hyprland": "hyprland" + } + }, + "wlroots": { + "flake": false, + "locked": { + "host": "gitlab.freedesktop.org", + "lastModified": 1679340088, + "narHash": "sha256-/1KiYoBivDj8HC/eVK2Tr2WYkVdKJxq2Lb0tQs0qqJo=", + "owner": "wlroots", + "repo": "wlroots", + "rev": "1d64e12391a638201c679e71d4e22bb45e5faa8e", + "type": "gitlab" + }, + "original": { + "host": "gitlab.freedesktop.org", + "owner": "wlroots", + "repo": "wlroots", + "type": "gitlab" + } + }, + "xdph": { + "inputs": { + "hyprland-protocols": [ + "hyprland", + "hyprland-protocols" + ], + "nixpkgs": [ + "hyprland", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1673116118, + "narHash": "sha256-eR0yDSkR2XYMesfdRWJs25kAdXET2mbNNHu5t+KUcKA=", + "owner": "hyprwm", + "repo": "xdg-desktop-portal-hyprland", + "rev": "d479c846531fd0e1d2357c9588b8310a2b859ef2", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "xdg-desktop-portal-hyprland", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..6168563 --- /dev/null +++ b/flake.nix @@ -0,0 +1,18 @@ +{ + inputs.hyprland.url = "github:hyprwm/Hyprland"; + + outputs = { + self, + hyprland, + }: let + inherit (hyprland.inputs) nixpkgs; + withPkgsFor = fn: nixpkgs.lib.genAttrs (builtins.attrNames hyprland.packages) (system: fn system nixpkgs.legacyPackages.${system}); + in { + packages = withPkgsFor (system: pkgs: { + hyprbars = pkgs.callPackage ./hyprbars { + inherit (hyprland.packages.${system}) hyprland; + wlroots = hyprland.packages.${system}.wlroots-hyprland; + }; + }); + }; +} diff --git a/hyprbars/default.nix b/hyprbars/default.nix new file mode 100644 index 0000000..d4913df --- /dev/null +++ b/hyprbars/default.nix @@ -0,0 +1,39 @@ +{ + stdenv, + hyprland, + pkg-config, + pixman, + libdrm, + wlroots, +}: +stdenv.mkDerivation { + name = "hyprbars"; + src = ./.; + preConfigure = "rm Makefile"; + + nativeBuildInputs = [ + pkg-config + ]; + + buildInputs = [ + pixman + libdrm + wlroots + ]; + + buildPhase = '' + trap "set +x" err + set -xeu + + $CXX --no-gnu-unique -shared \ + -std=c++23 \ + $(pkg-config --cflags pixman-1) \ + $(pkg-config --cflags libdrm) \ + $(pkg-config --cflags wlroots) \ + -I${hyprland.src}/ \ + main.cpp barDeco.cpp \ + -o $out + + set +x + ''; +}