Skip to content

Commit

Permalink
nix: fix package and add devshell
Browse files Browse the repository at this point in the history
  • Loading branch information
outfoxxed authored and fufexan committed Oct 15, 2024
1 parent 00beba9 commit 707a315
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 20 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,10 @@
.vscode/
.cache/
build/
/result

# direnv
/.direnv
/.envrc

compile_commands.json
11 changes: 3 additions & 8 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,9 @@
});

devShells = eachSystem (system: {
default = pkgsFor.${system}.mkShell {
inputsFrom = [self.packages.${system}.hyprsysteminfo];

shellHook = ''
# Generate compile_commands.json
CMAKE_EXPORT_COMPILE_COMMANDS=1 cmake -S . -B ./build
ln -s build/compile_commands.json .
'';
default = import ./nix/shell.nix {
pkgs = pkgsFor.${system};
inherit (pkgsFor.${system}) hyprsysteminfo;
};
});
};
Expand Down
21 changes: 9 additions & 12 deletions nix/default.nix
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
{
lib,
nix-gitignore,
stdenv,

cmake,
kdePackages,
pciutils,
qt6,
pkg-config,
hyprutils,
pciutils,
kdePackages,
version ? "0",
}: let
inherit (lib.sources) cleanSource cleanSourceWith;
inherit (lib.strings) hasSuffix makeBinPath;
inherit (lib.strings) makeBinPath;
in
stdenv.mkDerivation {
pname = "hyprsysteminfo";
inherit version;

src = cleanSourceWith {
filter = name: _type: let
baseName = baseNameOf (toString name);
in
! (hasSuffix ".nix" baseName);
src = cleanSource ../.;
};
src = nix-gitignore.gitignoreSource [] ./..;

nativeBuildInputs = [
cmake
Expand All @@ -31,11 +26,13 @@ in
];

buildInputs = [
kdePackages.kirigami-addons
qt6.qtbase
qt6.qtdeclarative
qt6.qtsvg
qt6.qtwayland
hyprutils
kdePackages.qqc2-desktop-style
kdePackages.kirigami
];

preFixup = ''
Expand Down
28 changes: 28 additions & 0 deletions nix/shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
pkgs ? import <nixpkgs> {},
hyprsysteminfo ? pkgs.callPackage ./default.nix {},
...
}: pkgs.mkShell {
inputsFrom = [ hyprsysteminfo ];
nativeBuildInputs = [ pkgs.clang-tools pkgs.pciutils ];

shellHook = let
inherit (pkgs.lib.strings) concatMapStringsSep;
qtLibPath = f: concatMapStringsSep ":" f (with pkgs.qt6; [
qtbase
qtdeclarative
qtwayland
pkgs.kdePackages.qqc2-desktop-style
# see https://github.com/NixOS/nixpkgs/blob/e186dd1a34be7a76c6e2c038ab4b759faec32d5d/pkgs/kde/frameworks/kirigami/default.nix#L9-L11
pkgs.kdePackages.kirigami.unwrapped
]);
in ''
# Add Qt-related environment variables.
export QT_PLUGIN_PATH=${qtLibPath (p: "${p}/lib/qt-6/plugins")}
export QML2_IMPORT_PATH=${qtLibPath (p: "${p}/lib/qt-6/qml")}
# Generate compile_commands.json
CMAKE_EXPORT_COMPILE_COMMANDS=1 cmake -S . -B ./build
ln -s build/compile_commands.json .
'';
}

0 comments on commit 707a315

Please sign in to comment.