Skip to content

Commit

Permalink
Merge pull request #1416 from nim65s/nix
Browse files Browse the repository at this point in the history
Initial nix packaging
  • Loading branch information
fspindle authored Jun 11, 2024
2 parents 73d8a6a + 69c444a commit 8283097
Show file tree
Hide file tree
Showing 7 changed files with 251 additions and 19 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: "Nix CI"

on: [pull_request, push]

jobs:
tests:
name: "Nix build on ${{ matrix.os }}"
runs-on: "${{ matrix.os }}-latest"
strategy:
matrix:
os: [ubuntu] # TODO: macos
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- uses: DeterminateSystems/flake-checker-action@main
- run: nix build
12 changes: 12 additions & 0 deletions .nixignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
*.nix
.clang-format
.git*
.nixignore
.vscode
appveyor.yml
ChangeLog.txt
ci
codecov.yml
CONTRIBUTING.md
INSTALL.txt
README.md
21 changes: 13 additions & 8 deletions cmake/VISPGenerateConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,19 @@
# output: path_to_parent, the relative path to go from path_to_child to parent
# example: if input =lib/x86_64-linux-gnu, then output=../..
macro(get_path_to_parent path_to_child path_to_parent)
set(${path_to_parent} "")
set(input_ "${path_to_child}")
while(input_)
if(input_)
set(${path_to_parent} "${${path_to_parent}}../")
endif()
get_filename_component(input_ "${input_}" PATH)
endwhile(input_)
if(IS_ABSOLUTE ${path_to_child})
file(RELATIVE_PATH _path_to_parent "${path_to_child}" "${CMAKE_INSTALL_PREFIX}")
string(REGEX REPLACE "/$" "" ${path_to_parent} "${_path_to_parent}")
else()
set(${path_to_parent} "")
set(input_ "${path_to_child}")
while(input_)
if(input_)
set(${path_to_parent} "${${path_to_parent}}../")
endif()
get_filename_component(input_ "${input_}" PATH)
endwhile(input_)
endif()
endmacro()

# Here we determine the relative path from ./${VISP_LIB_INSTALL_PATH} to its parent folder
Expand Down
45 changes: 34 additions & 11 deletions cmake/VISPGenerateConfigScript.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,16 @@ else() # DEFINED CMAKE_HELPER_SCRIPT
# Updates VISP_SCRIPT_PC_LIBS (for visp.pc used by pkg-config)
#----------------------------------------------------------------------
set(exec_prefix "\${prefix}")
set(includedir "\${prefix}/${VISP_INC_INSTALL_PATH}")
set(libdir "\${prefix}/${VISP_LIB_INSTALL_PATH}")
if(IS_ABSOLUTE ${VISP_INC_INSTALL_PATH})
set(includedir "${VISP_INC_INSTALL_PATH}")
else()
set(includedir "\${prefix}/${VISP_INC_INSTALL_PATH}")
endif()
if(IS_ABSOLUTE ${VISP_LIB_INSTALL_PATH})
set(libdir "${VISP_LIB_INSTALL_PATH}")
else()
set(libdir "\${prefix}/${VISP_LIB_INSTALL_PATH}")
endif()

# prepend with ViSP own include dir
set(VISP_SCRIPT_PC_CFLAGS
Expand All @@ -356,18 +364,33 @@ else() # DEFINED CMAKE_HELPER_SCRIPT
vp_list_remove_separator(VISP_SCRIPT_PC_CFLAGS)

# prepend with ViSP own modules first
set(VISP_SCRIPT_PC_LIBS
"-L\${exec_prefix}/${VISP_LIB_INSTALL_PATH}"
"${_modules}"
)
if(IS_ABSOLUTE ${VISP_LIB_INSTALL_PATH})
set(VISP_SCRIPT_PC_LIBS
"-L${VISP_LIB_INSTALL_PATH}"
"${_modules}"
)
else()
set(VISP_SCRIPT_PC_LIBS
"-L\${exec_prefix}/${VISP_LIB_INSTALL_PATH}"
"${_modules}"
)
endif()
if(BUILD_SHARED_LIBS)
set(VISP_SCRIPT_PC_LIBS_PRIVATE "${_extra_opt}")
else()
set(VISP_SCRIPT_PC_LIBS_PRIVATE
"-L\${exec_prefix}/${VISP_3P_LIB_INSTALL_PATH}"
"${_3rdparty}"
"${_extra_opt}"
)
if(IS_ABSOLUTE ${VISP_3P_LIB_INSTALL_PATH})
set(VISP_SCRIPT_PC_LIBS_PRIVATE
"-L${VISP_3P_LIB_INSTALL_PATH}"
"${_3rdparty}"
"${_extra_opt}"
)
else()
set(VISP_SCRIPT_PC_LIBS_PRIVATE
"-L\${exec_prefix}/${VISP_3P_LIB_INSTALL_PATH}"
"${_3rdparty}"
"${_extra_opt}"
)
endif()
endif()

vp_list_remove_separator(VISP_SCRIPT_PC_LIBS)
Expand Down
93 changes: 93 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# TODO:
# visp> In file included from /nix/store/g6lpg2p890jn3hkv63jjkk2f7k66y6hk-ogre-14.2.5/include/OGRE/Ogre.h:52,
# visp> from /build/source/modules/ar/include/visp3/ar/vpAROgre.h:66:
# visp> /nix/store/g6lpg2p890jn3hkv63jjkk2f7k66y6hk-ogre-14.2.5/include/OGRE/OgreConfigFile.h:94:41: note: declared here
# visp> 94 | OGRE_DEPRECATED SectionIterator getSectionIterator(void);
# visp> | ^~~~~~~~~~~~~~~~~~
# visp> /build/source/modules/ar/src/ogre-simulator/vpAROgre.cpp:315:33: error: no matching function for call to 'Ogre::Root::showConfigDialog()'
# visp> 315 | if (!mRoot->showConfigDialog()) {
# visp> | ~~~~~~~~~~~~~~~~~~~~~~~^~
{
cmake,
coin3d,
doxygen,
eigen,
#fetchFromGitHub,
lapack,
lib,
libdc1394,
libdmtx,
libglvnd,
libjpeg, # this is libjpeg-turbo
libpng,
librealsense,
libxml2,
libX11,
nix-gitignore,
nlohmann_json,
#ogre,
openblas,
opencv,
pkg-config,
python3,
stdenv,
texliveSmall,
v4l-utils,
xorg,
zbar,
zlib,
}:

stdenv.mkDerivation (finalAttrs: {
pname = "visp";
version = "3.6.0";

/*
src = fetchFromGitHub {
owner = "lagadic";
repo = "visp";
rev = "v${finalAttrs.version}";
hash = "sha256-m5Tmr+cZab7eSjmbXb8HpJpFHb0UYFTyimY+CkfBIAo=";
};
*/
src = nix-gitignore.gitignoreSource [ ./.nixignore ] ./.;

nativeBuildInputs = [
cmake
doxygen
pkg-config
texliveSmall
];

doCheck = true;

buildInputs = [
coin3d
eigen
lapack
libdc1394
libdmtx
libglvnd
libjpeg
libpng
librealsense
libX11
libxml2
nlohmann_json
#ogre
openblas
opencv
(python3.withPackages (p: [ p.numpy ]))
v4l-utils
xorg.libpthreadstubs
zbar
zlib
];

meta = {
description = "Open Source Visual Servoing Platform";
homepage = "https://visp.inria.fr";
license = lib.licenses.gpl2Plus;
maintainers = [ lib.maintainers.nim65s ];
};
})
61 changes: 61 additions & 0 deletions flake.lock

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

21 changes: 21 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
description = "Open Source Visual Servoing Platform";

inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
};

outputs =
{ flake-utils, nixpkgs, ... }:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
visp = pkgs.callPackage ./default.nix { };
in
{
packages.default = visp;
}
);
}

0 comments on commit 8283097

Please sign in to comment.