add flake.nix and other required files for nix build

This commit is contained in:
Tanish2002 2022-05-08 21:57:40 +05:30
parent 434184aa32
commit 857ea43694
6 changed files with 314 additions and 1 deletions

3
.gitignore vendored
View file

@ -10,6 +10,7 @@ CTestTestfile.cmake
_deps
build/
result/
/.vscode/
*.o
@ -17,4 +18,4 @@ build/
*-protocol.h
.ccls-cache
hyprctl/hyprctl
hyprctl/hyprctl

42
default.nix Normal file
View file

@ -0,0 +1,42 @@
{ lib, stdenv, fetchFromGitHub, src, version, pkg-config, cmake, ninja, libdrm
, libinput, libxcb, libxkbcommon, mesa, mount, pango, wayland, wayland-protocols
, wayland-scanner, wlroots, xcbutilwm, xwayland, xwaylandSupport ? true }:
stdenv.mkDerivation {
pname = "hyprland";
inherit src version;
nativeBuildInputs = [ cmake ninja pkg-config wayland ]
++ lib.optional xwaylandSupport xwayland;
buildInputs = [
libdrm
libinput
libxcb
libxkbcommon
mesa
pango
wayland-protocols
wayland-scanner
wlroots
xcbutilwm
];
dontBuild = true;
dontInstall = true;
patches = [ ./fix-makefile.diff ];
postPatch = ''
mkdir -p $out/bin
make install PREFIX=$out
'';
meta = with lib; {
homepage = "https://github.com/vaxerski/Hyprland";
description =
"A dynamic tiling Wayland compositor that doesn't sacrifice on its looks";
license = licenses.bsd3;
platforms = platforms.linux;
};
}

162
flake.lock Normal file
View file

@ -0,0 +1,162 @@
{
"nodes": {
"cachix": {
"locked": {
"lastModified": 1651865313,
"narHash": "sha256-fLnmcBaVpJukNIzXZETxtJKLSSTf4LnBCWa/DwyGJBU=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "ad667404474314806d8071eec4c8ec0db95c17e4",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-21.11",
"repo": "nixpkgs",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1650374568,
"narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "b4a34015c698c7793d592d66adbab377907a2be8",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1649676176,
"narHash": "sha256-OWKJratjt2RW151VUlJPRALb7OU2S5s+f0vLj4o1bHM=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "a4b154ebbdc88c8498a5c7b01589addc9e9cb678",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"lib-aggregate": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1652011770,
"narHash": "sha256-ZX+aDa9db1lNbLI44KK0EjTV2X6gyIqpcuN9RUCy9iI=",
"owner": "nix-community",
"repo": "lib-aggregate",
"rev": "89056ca8a9c74ea4440dc53bebcd9c74fc0e1f15",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "lib-aggregate",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1651927509,
"narHash": "sha256-fGVGUdEsriuAL1vkUh29FlOQmEkPRnSfRGImWYaVjos=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "2fdb6f2e08e7989b03a2a1aa8538d99e3eeea881",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1651970744,
"narHash": "sha256-3X/96C8I5alTCP0FHEx01/YOIvVmjkYoUPX/1Y4Bdsw=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "da23418cffc1763e30dba3383eac541afe3e4e70",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"nixpkgs-wayland": {
"inputs": {
"cachix": "cachix",
"flake-compat": "flake-compat",
"lib-aggregate": "lib-aggregate",
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1652015544,
"narHash": "sha256-YFjSavZSf6NZFRt2QB5mBccPYd8wrJGKHVH9p75vZtM=",
"owner": "nix-community",
"repo": "nixpkgs-wayland",
"rev": "2d9bc7f3261cc1c2a46d121f94ed483f35d194c2",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs-wayland",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1651726670,
"narHash": "sha256-dSGdzB49SEvdOJvrQWfQYkAefewXraHIV08Vz6iDXWQ=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "c777cdf5c564015d5f63b09cc93bef4178b19b01",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"nixpkgs-wayland": "nixpkgs-wayland",
"utils": "utils"
}
},
"utils": {
"locked": {
"lastModified": 1649676176,
"narHash": "sha256-OWKJratjt2RW151VUlJPRALb7OU2S5s+f0vLj4o1bHM=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "a4b154ebbdc88c8498a5c7b01589addc9e9cb678",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

30
flake.nix Normal file
View file

@ -0,0 +1,30 @@
# Based on fortuneteller2k's (https://github.com/fortuneteller2k/nixpkgs-f2k) package repo
{
description =
"Hyprland is a dynamic tiling Wayland compositor that doesn't sacrifice on its looks.";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
utils.url = "github:numtide/flake-utils";
nixpkgs-wayland.url = "github:nix-community/nixpkgs-wayland";
};
outputs = { self, nixpkgs, utils, nixpkgs-wayland }:
utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
version = "git";
in rec {
packages = {
hyprland = pkgs.callPackage ./nix-build {
inherit version;
src = self;
inherit (nixpkgs-wayland.packages.${system}) wlroots;
};
};
defaultPackage = packages.hyprland;
apps.hyprland = utils.lib.mkApp { drv = packages.hyprland; };
defaultApp = apps.hyprland;
apps.default =
utils.lib.mkApp { drv = self.packages."${system}".default; };
});
}

42
nix-build/default.nix Normal file
View file

@ -0,0 +1,42 @@
{ lib, stdenv, fetchFromGitHub, src, version, pkg-config, cmake, ninja, libdrm
, libinput, libxcb, libxkbcommon, mesa, mount, pango, wayland, wayland-protocols
, wayland-scanner, wlroots, xcbutilwm, xwayland, xwaylandSupport ? true }:
stdenv.mkDerivation {
pname = "hyprland";
inherit src version;
nativeBuildInputs = [ cmake ninja pkg-config wayland ]
++ lib.optional xwaylandSupport xwayland;
buildInputs = [
libdrm
libinput
libxcb
libxkbcommon
mesa
pango
wayland-protocols
wayland-scanner
wlroots
xcbutilwm
];
dontBuild = true;
dontInstall = true;
patches = [ ./fix-makefile.diff ];
postPatch = ''
mkdir -p $out/bin
make install PREFIX=$out
'';
meta = with lib; {
homepage = "https://github.com/vaxerski/Hyprland";
description =
"A dynamic tiling Wayland compositor that doesn't sacrifice on its looks";
license = licenses.bsd3;
platforms = platforms.linux;
};
}

View file

@ -0,0 +1,36 @@
diff --git a/Makefile b/Makefile
index bcf3a10..0a5b335 100644
--- a/Makefile
+++ b/Makefile
@@ -97,14 +97,14 @@ all:
install:
make all
- mkdir -p /usr/share/wayland-sessions
- cp ./example/hyprland.desktop /usr/share/wayland-sessions/
- cp ./build/Hyprland /usr/bin
- cp ./hyprctl/hyprctl /usr/bin
- mkdir -p /usr/share/hyprland
- cp ./assets/wall_2K.png /usr/share/hyprland
- cp ./assets/wall_4K.png /usr/share/hyprland
- cp ./assets/wall_8K.png /usr/share/hyprland
+ mkdir -p $(PREFIX)/share/wayland-sessions
+ cp ./example/hyprland.desktop $(PREFIX)/share/wayland-sessions/
+ cp ./build/Hyprland $(PREFIX)/bin
+ cp ./hyprctl/hyprctl $(PREFIX)/bin
+ mkdir -p $(PREFIX)/share/hyprland
+ cp ./assets/wall_2K.png $(PREFIX)/share/hyprland
+ cp ./assets/wall_4K.png $(PREFIX)/share/hyprland
+ cp ./assets/wall_8K.png $(PREFIX)/share/hyprland
uninstall:
rm -f /usr/share/wayland-sessions/hyprland.desktop
diff --git a/config.mk b/config.mk
index 91aca81..c40930e 100644
--- a/config.mk
+++ b/config.mk
@@ -1,4 +1,4 @@
-PREFIX = /usr/local
+PREFIX = @out@
CFLAGS ?= -g -Wall -Wextra -Werror -Wno-unused-parameter -Wno-sign-compare -Wno-unused-function -Wno-unused-variable -Wno-unused-result -Wdeclaration-after-statement
CFLAGS += -DXWAYLAND