nix: init

This commit is contained in:
Ching Pei Yang 2024-10-09 16:46:01 +02:00
parent e8903702b3
commit d12d0ea8f8
No known key found for this signature in database
GPG Key ID: 062FBBCE1D0C5DD9
2 changed files with 65 additions and 0 deletions

37
flake.nix Normal file
View File

@ -0,0 +1,37 @@
{
inputs.hyprland.url = "github:hyprwm/Hyprland";
outputs = {
self,
hyprland,
}: let
inherit (hyprland.inputs) nixpkgs;
genPerSystem = fn: nixpkgs.lib.genAttrs (builtins.attrNames hyprland.packages) (system: fn system nixpkgs.legacyPackages.${system});
in {
packages = genPerSystem (system: pkgs: {
default = pkgs.callPackage ./plugin.nix {
inherit (hyprland.packages.${system}) hyprland;
};
});
devShells = genPerSystem (system: pkgs: {
default = pkgs.mkShell {
name = "hyprland-plugin-shell";
shellHook = ''
meson setup build --reconfigure
# clangd has different flags than gcc because... why not?
sed -e 's/c++23/c++2b/g' ./build/compile_commands.json > ./compile_commands.json
'';
# Note: gcc needs to be specified or else an older version might be used
# TODO: maybe using gcc13Stdenv.mkShell would fix this?
nativeBuildInputs = with pkgs; [gcc13 meson pkg-config ninja];
buildInputs = [hyprland.packages.${system}.hyprland];
inputsFrom = [
hyprland.packages.${system}.hyprland
self.packages.${system}.default
];
};
});
};
}

28
plugin.nix Normal file
View File

@ -0,0 +1,28 @@
{
lib,
gcc13Stdenv,
meson,
ninja,
pkg-config,
hyprland,
}: let
version = builtins.readFile ./VERSION;
in
gcc13Stdenv.mkDerivation {
pname = "example";
inherit version;
src = ./.;
nativeBuildInputs =
hyprland.nativeBuildInputs
++ [ninja meson pkg-config];
buildInputs = [hyprland] ++ hyprland.buildInputs;
meta = with lib; {
homepage = "https://example.com";
description = "Example hyprland plugin";
license = licenses.bsd3;
platforms = platforms.linux;
};
}