Skip to content

Commit

Permalink
Merge pull request #246 from Tom94/flake-deploy
Browse files Browse the repository at this point in the history
feat: allow deploying tev via nix flake
  • Loading branch information
Tom94 authored Dec 31, 2024
2 parents 32bdc95 + 79227dd commit 010708e
Showing 1 changed file with 67 additions and 22 deletions.
89 changes: 67 additions & 22 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
description = "Nix tev dev env";
description = "tev — The EXR Viewer";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
Expand All @@ -10,32 +10,77 @@
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
devShell = pkgs.mkShell {
buildInputs = with pkgs; [
gcc
gdb
cmake
pkg-config
binutils
zlib

xorg.libX11.dev
xorg.libXi.dev
xorg.libXrandr.dev
xorg.libXinerama.dev
xorg.libXcursor.dev
xorg.libXext.dev
xorg.libXfixes.dev
xorg.libXrender.dev
# Extract version from CMakeLists.txt
version = with builtins;
let
cmakeContents = readFile ./CMakeLists.txt;
versionMatch = match ".*VERSION[[:space:]]+([^[:space:]]+).*" cmakeContents;
in
if versionMatch == null then throw "Could not find version in CMakeLists.txt"
else head versionMatch;

# Common dependencies shared between dev shell and build
commonDeps = with pkgs;
if stdenv.isDarwin then [
darwin.apple_sdk.frameworks.Cocoa
darwin.apple_sdk.frameworks.OpenGL
] else [
xorg.libX11
xorg.libXcursor
xorg.libXinerama
xorg.libXrandr
xorg.libXi
libGL
zlib
];

shellHook = ''
export CMAKE_PREFIX_PATH="${pkgs.xorg.libX11.dev}:${pkgs.xorg.libXi.dev}:${pkgs.libGL}:''${CMAKE_PREFIX_PATH:-}"
'';
# Common build inputs shared between dev shell and build
commonBuildInputs = with pkgs; [
cmake
];

tev = pkgs.stdenv.mkDerivation {
pname = "tev";
inherit version;

src = ./.;

nativeBuildInputs = commonBuildInputs;
buildInputs = commonDeps;

cmakeFlags = [
"-DCMAKE_BUILD_TYPE=Release"
"-DTEV_DEPLOY=ON"
];

meta = with pkgs.lib; {
description = "High dynamic range (HDR) image comparison tool for graphics people";
homepage = "https://github.com/Tom94/tev";
license = licenses.bsd3;
platforms = platforms.unix;
maintainers = [ ];
};
};
in
{
packages = {
default = tev;
tev = tev;
};

devShell = pkgs.mkShell {
buildInputs = commonDeps ++ commonBuildInputs ++ (with pkgs;
if stdenv.isDarwin then [ ] else [
gcc
gdb
binutils
]
);
};

apps.default = flake-utils.lib.mkApp {
drv = tev;
};
}
);
Expand Down

0 comments on commit 010708e

Please sign in to comment.