Nix flake: init

This commit is contained in:
Mihai Fufezan 2022-09-02 19:34:15 +03:00 committed by Mihai Fufezan
parent 1611dbc158
commit 5f7977c6a4
3 changed files with 155 additions and 0 deletions

27
flake.lock Normal file
View file

@ -0,0 +1,27 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1662019588,
"narHash": "sha256-oPEjHKGGVbBXqwwL+UjsveJzghWiWV0n9ogo1X6l4cw=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "2da64a81275b68fdad38af669afeda43d401e94b",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

39
flake.nix Normal file
View file

@ -0,0 +1,39 @@
{
description = "Hyprpicker - a wlroots-compatible Wayland color picker that does not suck";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
outputs = {
self,
nixpkgs,
...
}: let
inherit (nixpkgs) lib;
genSystems = lib.genAttrs [
# Add more systems if they are supported
"aarch64-linux"
"x86_64-linux"
];
pkgsFor = nixpkgs.legacyPackages;
mkDate = longDate: (lib.concatStringsSep "-" [
(__substring 0 4 longDate)
(__substring 4 2 longDate)
(__substring 6 2 longDate)
]);
in {
overlays.default = _: prev: rec {
hyprpicker = prev.callPackage ./nix/default.nix {
stdenv = prev.gcc12Stdenv;
version = "0.pre" + "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty");
inherit (prev.xorg) libXdmcp;
};
hyprpicker-debug = hyprpicker.override {debug = true;};
};
packages = genSystems (system:
(self.overlays.default null pkgsFor.${system})
// {default = self.packages.${system}.hyprpicker;});
formatter = genSystems (system: pkgsFor.${system}.alejandra);
};
}

89
nix/default.nix Normal file
View file

@ -0,0 +1,89 @@
{
lib,
stdenv,
pkg-config,
cmake,
ninja,
cairo,
fribidi,
libdatrie,
libjpeg,
libselinux,
libsepol,
libthai,
pango,
pcre,
utillinux,
wayland,
wayland-protocols,
wayland-scanner,
wlroots,
libXdmcp,
debug ? false,
version ? "git",
}:
stdenv.mkDerivation {
pname = "hyprpicker" + lib.optionalString debug "-debug";
inherit version;
src = ../.;
cmakeFlags = lib.optional debug "-DCMAKE_BUILD_TYPE=Debug";
nativeBuildInputs = [
cmake
ninja
pkg-config
];
buildInputs = [
cairo
fribidi
libdatrie
libjpeg
libselinux
libsepol
libthai
pango
pcre
wayland
wayland-protocols
wayland-scanner
wlroots
libXdmcp
utillinux
];
configurePhase = ''
runHook preConfigure
make protocols
runHook postConfigure
'';
buildPhase = ''
runHook preBuild
make release
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out/{bin,share/licenses}
install -Dm755 build/hyprpicker -t $out/bin
install -Dm644 LICENSE -t $out/share/licenses/hyprpicker
runHook postInstall
'';
meta = with lib; {
homepage = "https://github.com/hyprwm/hyprpicker";
description = "A wlroots-compatible Wayland color picker that does not suck";
license = licenses.bsd3;
platforms = platforms.linux;
};
}