Skip to content

Commit

Permalink
nix: Wrap FetchContent
Browse files Browse the repository at this point in the history
  • Loading branch information
vimpostor committed Nov 24, 2023
1 parent 9ba1517 commit dc47d42
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ latex/

.cache/
.gitattributes
/result
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
pkgs = nixpkgs.legacyPackages.${system};
stdenvs = [ { name = "gcc"; pkg = pkgs.gcc13Stdenv; } { name = "clang"; pkg = pkgs.llvmPackages_16.stdenv; } ];
defaultStdenv = (builtins.head stdenvs).name;
quartz = pkgs.fetchFromGitHub {
owner = "vimpostor";
repo = "quartz";
rev = builtins.head (builtins.match ".*FetchContent_Declare\\(.*GIT_TAG ([[:alnum:]\\.]+).*" (builtins.readFile ./CMakeLists.txt));
hash = "sha256-KSuwXPUMZKx8nm8XnXHvj07GQtJAAnfIkRM6vbYllT0=";
};
makeStdenvPkg = env: env.mkDerivation {
pname = "blobdrop";
version = builtins.head (builtins.match ".*project\\([[:alnum:]]+ VERSION ([0-9]+\.[0-9]+).*" (builtins.readFile ./CMakeLists.txt));
Expand All @@ -18,17 +24,19 @@

nativeBuildInputs = with pkgs; [
cmake
git
pkg-config
qt6.wrapQtAppsHook
];

buildInputs = with pkgs; [
qt6.qtbase
qt6.qtdeclarative
qt6.qtsvg
xorg.libxcb
xorg.xcbutilwm
];

cmakeFlags = [("-DFETCHCONTENT_SOURCE_DIR_QUARTZ=" + quartz)];
};
in {
packages = rec {
Expand All @@ -38,7 +46,7 @@
format = pkgs.runCommand "format" { src = ./.; nativeBuildInputs = [ pkgs.clang-tools pkgs.git ]; } "mkdir $out && cd $src && find . -type f -path './*\\.[hc]pp' -exec clang-format -style=file --dry-run --Werror {} \\;";
tests = (makeStdenvPkg pkgs.gcc13Stdenv).overrideAttrs (finalAttrs: previousAttrs: {
doCheck = true;
cmakeFlags = ["-DBUILD_TESTING=ON"];
cmakeFlags = previousAttrs.cmakeFlags ++ ["-DBUILD_TESTING=ON"];
QT_QPA_PLATFORM = "offscreen";
});
};
Expand Down

0 comments on commit dc47d42

Please sign in to comment.