Add missing deps.

This commit is contained in:
Ben Wolsieffer 2019-03-21 00:23:14 -04:00
parent 096c49e618
commit 45675da968
15 changed files with 438 additions and 104 deletions

149
base.nix
View file

@ -1,107 +1,66 @@
{ lib, stdenv, pkgs, pythonPackages }:
with lib;
with pkgs;
with pythonPackages;
let
callPackage = newScope self;
callPythonPackage = newScope (pythonPackages // self);
self = rec {
buildRosPackage = { postFixup ? "", ... }@args: stdenv.mkDerivation args // {
postFixup = ''
wrapPythonPrograms
'' + postFixup;
};
self: super: with super.lib; let
catkin-pkg = pythonPackages.callPackage ./catkin-pkg { };
empy = pythonPackages.callPackage ./empy {};
rospkg = callPythonPackage ./rospkg {};
rosdistro = callPythonPackage ./rosdistro {};
rosdep = callPythonPackage ./rosdep {};
rosinstall-generator = callPythonPackage ./rosinstall-generator {};
vcstools = buildPythonPackage rec {
pname = "vcstools";
version = "0.1.40";
name = "${pname}-${version}";
src = fetchPypi {
inherit pname version;
sha256 = "1mfasip71ky1g968n1zlramgn3fjxk4c922d0x9cs0nwm2snln4m";
};
propagatedBuildInputs = [ pyyaml python-dateutil ];
# Tries to download files and lots of other issues
doCheck = false;
pythonOverridesFor = python: python.override (old: {
packageOverrides = pySelf: pySuper: {
catkin-pkg = pySelf.callPackage ./catkin-pkg { };
meta = {
description = "Python library for interacting with various VCS systems";
homepage = http://wiki.ros.org/vcstools;
};
empy = pySelf.callPackage ./empy { };
rosdep = pySelf.callPackage ./rosdep { };
rosdistro = pySelf.callPackage ./rosdistro { };
rosinstall = pySelf.callPackage ./rosinstall { };
rosinstall-generator = pySelf.callPackage ./rosinstall-generator { };
rospkg = pySelf.callPackage ./rospkg { };
};
});
in {
python27 = pythonOverridesFor super.python27;
python36 = pythonOverridesFor super.python36;
python37 = pythonOverridesFor super.python37;
vcstools = buildPythonPackage rec {
pname = "vcstools";
version = "0.1.40";
name = "${pname}-${version}";
src = fetchPypi {
inherit pname version;
sha256 = "1mfasip71ky1g968n1zlramgn3fjxk4c922d0x9cs0nwm2snln4m";
};
propagatedBuildInputs = [ pyyaml python-dateutil ];
# Tries to download files and lots of other issues
doCheck = false;
wstool = buildPythonPackage rec {
pname = "wstool";
version = "0.1.17";
name = "${pname}-${version}";
src = fetchPypi {
inherit pname version;
sha256 = "0dz2gn2qx919s1z5wa94nkvb01pnqp945mvj97108w7i1q8lz6y7";
};
propagatedBuildInputs = [ vcstools pyyaml ];
meta = {
description = "A tool for managing a workspace of multiple heterogenous SCM repositories";
homepage = http://wiki.ros.org/wstool;
};
meta = {
description = "Python library for interacting with various VCS systems";
homepage = http://wiki.ros.org/vcstools;
};
rosinstall = buildPythonPackage rec {
pname = "rosinstall";
version = "0.7.8";
name = "${pname}-${version}";
};
wstool = buildPythonPackage rec {
pname = "wstool";
version = "0.1.17";
name = "${pname}-${version}";
src = fetchPypi {
inherit pname version;
sha256 = "0h7d8ynv44c68sbfn28xw4k18k3ip6252x7r7bqw6b5cifzhia1b";
};
nativeBuildInputs = [ makeWrapper ];
propagatedBuildInputs = [ vcstools pyyaml rosdistro catkinPkg wstool rospkg ];
meta = {
description = "The installer for ROS";
homepage = http://wiki.ros.org/rosinstall;
};
src = fetchPypi {
inherit pname version;
sha256 = "0dz2gn2qx919s1z5wa94nkvb01pnqp945mvj97108w7i1q8lz6y7";
};
consoleBridge = stdenv.mkDerivation rec {
name = "console_bridge-0.3.2";
propagatedBuildInputs = [ vcstools pyyaml ];
src = fetchFromGitHub {
owner = "ros";
repo = "console_bridge";
rev = "0.4.0";
sha256 = "1sxwabx59znmx99mfskz4wh1fhkwjanqjj6dy33zim55c6x8qnxr";
};
nativeBuildInputs = [ cmake ];
meta = with lib; {
description = "A ROS-independent package for logging that seamlessly pipes into rosconsole/rosout for ROS-dependent packages";
homepage = https://github.com/ros/console_bridge;
license = licenses.bsd3;
};
meta = {
description = "A tool for managing a workspace of multiple heterogenous SCM repositories";
homepage = http://wiki.ros.org/wstool;
};
};
in self
console-bridge = self.callPackage ./console-bridge { };
}

98
build-env/default.nix Normal file
View file

@ -0,0 +1,98 @@
{ stdenv, runCommand, makeWrapper, catkin }:
{ packages ? []
, extraOutputsToInstall ? []
, postBuild ? ""
, ignoreCollisions ? false
# Wrap executables with the given argument.
, makeWrapperArgs ? [] }:
let
env = runCommand "ros-env" {
inherit packages;
nativeBuildInputs = [ makeWrapper ];
passthru.env = stdenv.mkDerivation {
name = "interactive-ros-env";
nativeBuildInputs = [ env ];
buildInputs = [ catkin ];
buildCommand = ''
echo >&2 ""
echo >&2 "*** ROS 'env' attributes are intended for interactive nix-shell sessions, not for building! ***"
echo >&2 ""
exit 1
'';
};
} ''
declare -A symlinks
declare -A pkgsAdded
isCatkinPackage() {
local pkg="$1"
[ -d "$pkg/share" ] && \
[ -n "$(find "$pkg/share" \
-maxdepth 2 -mindepth 2 \
-name package.xml -print -quit)" ]
}
isPythonPackage() {
[ -d "$1/${python.sitePackages}" ]
}
addPackageCommon() {
local pkg="$1"
shift
if [ -n "''${pkgsAdded[$pkg]}" ]; then return; fi
pkgsAdded[$pkg]=1
cd "$pkg"
local target
while IFS= read -r -d $'\0' file; do
target=$(realpath "$file")
symlinks[$file]="$pkg/$file"
done < <(find . \
-path ./nix-support -prune -o \
"$@" -type f -print0)
local prop="$pkg/nix-support/propagated-build-inputs"
if [ -e "$prop" ]; then
local new_pkg
for new_pkg in $(<"$prop"); do
addPackage $new_pkg
done
fi
}
addCatkinPackage() {
addPackageCommon "$1"
}
addPythonPackage() {
addPackageCommon "$1"
}
addPackage() {
local pkg="$1"
if isCatkinPackage "$pkg"; then
addCatkinPackage "$pkg"
elif isPythonPackage "$pkg"; then
addPythonPackage "$pkg"
fi
}
for p in ''${packages[@]}; do
addPackage "$p"
done
for link in "''${!symlinks[@]}"; do
mkdir -p "$(dirname "$out/$link")"
ln -s "''${symlinks[$link]}" "$out/$link"
done
${postBuild}
'';
in env

View file

@ -0,0 +1,20 @@
{ stdenv, python, cmake }:
{ postInstall ? ""
, postFixup ? ""
, buildInputs ? []
, nativeBuildInputs ? []
, propagatedNativeBuildInputs ? []
, ...
}@args: stdenv.mkDerivation (args // {
nativeBuildInputs = [ python.pkgs.wrapPython ] ++ nativeBuildInputs;
propagatedNativeBuildInputs = [ cmake ] ++ propagatedNativeBuildInputs;
postInstall = ''
pushd $out
rm -f *setup.*sh
rm -f _setup_util.py
rm -f env.sh
popd
'' + postInstall;
})

View file

@ -0,0 +1,11 @@
{ runCommand }:
distro:
runCommand "ros-setup-hook.sh" {
inherit distro;
} ''
cp ${./setup-hook.sh} setup-hook.sh
substituteAllInPlace setup-hook.sh
mv setup-hook.sh $out
''

View file

@ -0,0 +1,21 @@
isCatkinPackage() {
local pkg="$1"
[ -d "$pkg/share" ] && \
[ -n "$(find "$pkg/share" \
-maxdepth 2 -mindepth 2 \
-name package.xml -print -quit)" ]
}
_addRosPackagePath() {
if isCatkinPackage "$1"; then
addToSearchPath ROS_PACKAGE_PATH "$1"
fi
}
addEnvHooks "$hostOffset" _addRosPackagePath
_catkinPreConfigureHook() {
cmakeFlags+=" -DCATKIN_ENABLE_TESTING=${doCheck:-OFF}"
}
preConfigureHooks+=(_catkinPreConfigureHook)
export ROS_DISTRO="@distro@"

View file

@ -0,0 +1,20 @@
{ lib, stdenv, fetchFromGitHub, cmake }:
stdenv.mkDerivation rec {
pname = "console_bridge";
version = "0.4.3";
src = fetchFromGitHub {
owner = "ros";
repo = pname;
rev = version;
sha256 = "0vk2ji4q93w3fw4s6p0i9d3x2ppsmhxm3x7qrcl4jfr0pyj96n5x";
};
nativeBuildInputs = [ cmake ];
meta = with lib; {
description = "A ROS-independent package for logging that seamlessly pipes into rosconsole/rosout for ROS-dependent packages";
homepage = https://github.com/ros/console_bridge;
license = licenses.bsd3;
};
}

6
default.nix Normal file
View file

@ -0,0 +1,6 @@
{ overlays ? [] }@args: import <nixpkgs> {
overlays = [
(import ./base.nix)
(import ./melodic)
] ++ overlays;
} // args

View file

@ -5,10 +5,7 @@ self: super: let
buildRosPackage = rosSelf.callPackage ../build-ros-package { };
buildEnv = import ../build-env {
inherit (self) stdenv runCommand makeWrapper;
inherit (rosSelf) python;
};
buildEnv = rosSelf.callPackage ../build-env { };
python = self.python3;
pythonPackages = self.python3Packages;

View file

@ -0,0 +1,134 @@
From 062a441c889a870b01493485565554703987ee83 Mon Sep 17 00:00:00 2001
From: Ben Wolsieffer <benwolsieffer@gmail.com>
Date: Thu, 14 Mar 2019 17:30:55 -0400
Subject: [PATCH] Add support for Nix/NixOS
---
src/rosdep2/__init__.py | 3 +-
src/rosdep2/platforms/arch.py | 9 ++---
src/rosdep2/platforms/nix.py | 62 +++++++++++++++++++++++++++++++++++
3 files changed, 69 insertions(+), 5 deletions(-)
create mode 100644 src/rosdep2/platforms/nix.py
diff --git a/src/rosdep2/__init__.py b/src/rosdep2/__init__.py
index b7bbbfb..7d844f5 100644
--- a/src/rosdep2/__init__.py
+++ b/src/rosdep2/__init__.py
@@ -59,6 +59,7 @@ def create_default_installer_context(verbose=False):
from .platforms import cygwin
from .platforms import debian
from .platforms import gentoo
+ from .platforms import nix
from .platforms import opensuse
from .platforms import osx
from .platforms import pip
@@ -68,7 +69,7 @@ def create_default_installer_context(verbose=False):
from .platforms import slackware
from .platforms import source
- platform_mods = [arch, cygwin, debian, gentoo, opensuse, osx, redhat, slackware, freebsd]
+ platform_mods = [arch, cygwin, debian, gentoo, nix, opensuse, osx, redhat, slackware, freebsd]
installer_mods = [source, pip, gem] + platform_mods
context = InstallerContext()
diff --git a/src/rosdep2/platforms/arch.py b/src/rosdep2/platforms/arch.py
index c03e2f1..6aaf4f4 100644
--- a/src/rosdep2/platforms/arch.py
+++ b/src/rosdep2/platforms/arch.py
@@ -29,10 +29,11 @@
import subprocess
+from rospkg.os_detect import OS_ARCH
+
from ..installers import PackageManagerInstaller
from .source import SOURCE_INSTALLER
-ARCH_OS_NAME = 'arch'
PACMAN_INSTALLER = 'pacman'
@@ -41,9 +42,9 @@ def register_installers(context):
def register_platforms(context):
- context.add_os_installer_key(ARCH_OS_NAME, SOURCE_INSTALLER)
- context.add_os_installer_key(ARCH_OS_NAME, PACMAN_INSTALLER)
- context.set_default_os_installer_key(ARCH_OS_NAME, lambda self: PACMAN_INSTALLER)
+ context.add_os_installer_key(OS_ARCH, SOURCE_INSTALLER)
+ context.add_os_installer_key(OS_ARCH, PACMAN_INSTALLER)
+ context.set_default_os_installer_key(OS_ARCH, lambda self: PACMAN_INSTALLER)
def pacman_detect_single(p):
diff --git a/src/rosdep2/platforms/nix.py b/src/rosdep2/platforms/nix.py
new file mode 100644
index 0000000..c6c21b9
--- /dev/null
+++ b/src/rosdep2/platforms/nix.py
@@ -0,0 +1,62 @@
+# Copyright (c) 2009, Willow Garage, Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# * Neither the name of the Willow Garage, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+# Author Ben Wolsieffer/benwolsieffer@gmail.com
+import subprocess
+
+from rospkg.os_detect import OS_NIXOS
+
+from ..installers import PackageManagerInstaller
+
+NIX_INSTALLER = 'nix'
+
+
+def register_installers(context):
+ context.set_installer(NIX_INSTALLER, NixInstaller())
+
+
+def register_platforms(context):
+ context.add_os_installer_key(OS_NIXOS, NIX_INSTALLER)
+ context.set_default_os_installer_key(OS_NIXOS, lambda self: NIX_INSTALLER)
+
+
+def nix_detect(packages):
+ # Say that all packages are installed, because Nix handles installation
+ # automatically
+ return packages
+
+
+class NixInstaller(PackageManagerInstaller):
+
+ def __init__(self):
+ super(NixInstaller, self).__init__(nix_detect)
+
+ def get_install_command(self, resolved, interactive=True, reinstall=False, quiet=False):
+ raise NotImplementedError('Nix does not support installing packages through ROS')
+
+ def get_version_strings(self):
+ return subprocess.check_output(('nix', '--version'))
--
2.21.0

View file

@ -8,7 +8,9 @@ buildPythonPackage rec {
inherit pname version;
sha256 = "0y3hxyd84q7c0091cci3dnsg8pm9yw9i4fxgc09wzzgaiq8y3k40";
};
patches = [ ./0001-Add-support-for-Nix-NixOS.patch ];
# Tries to download files
doCheck = false;

View file

@ -1,4 +1,4 @@
{ buildPythonPackage, fetchPypi, rospkg, catkin-pkg, pyyaml }:
{ lib, buildPythonPackage, fetchPypi, rospkg, catkin-pkg, pyyaml }:
buildPythonPackage rec {
pname = "rosdistro";
@ -11,8 +11,9 @@ buildPythonPackage rec {
propagatedBuildInputs = [ rospkg catkin-pkg pyyaml ];
meta = {
meta = with lib; {
description = "A tool to work with rosdistro files";
homepage = http://wiki.ros.org/rosdistro;
license = licenses.bsd3;
};
}

View file

@ -1,4 +1,4 @@
{ buildPythonPackage, fetchPypi, catkin-pkg, rosdistro, rospkg, pyyaml }:
{ lib, buildPythonPackage, fetchPypi, catkin-pkg, rosdistro, rospkg, pyyaml }:
buildPythonPackage rec {
pname = "rosinstall_generator";
@ -11,8 +11,9 @@ buildPythonPackage rec {
propagatedBuildInputs = [ catkin-pkg rosdistro rospkg pyyaml ];
meta = {
meta = with lib; {
description = "A tool to generator rosinstall files";
homepage = http://wiki.ros.org/rosinstall_generator;
license = licenses.bsd3;
};
}

21
rosinstall/default.nix Normal file
View file

@ -0,0 +1,21 @@
{ lib, buildPythonPackage, fetchPypi, makeWrapper, vcstools, pyyaml, rosdistro
, catkin-pkg, wstool, rospkg }:
rosinstall = buildPythonPackage rec {
pname = "rosinstall";
version = "0.7.8";
src = fetchPypi {
inherit pname version;
sha256 = "0h7d8ynv44c68sbfn28xw4k18k3ip6252x7r7bqw6b5cifzhia1b";
};
nativeBuildInputs = [ makeWrapper ];
propagatedBuildInputs = [ vcstools pyyaml rosdistro catkin-pkg wstool rospkg ];
meta = with lib; {
description = "The installer for ROS";
homepage = http://wiki.ros.org/rosinstall;
license = licenses.bsd3;
};
};

View file

@ -0,0 +1,41 @@
From 2f9ca3ff1c81ef8d497cd867a2c2904d579cdc80 Mon Sep 17 00:00:00 2001
From: Ben Wolsieffer <benwolsieffer@gmail.com>
Date: Tue, 12 Mar 2019 11:53:25 -0400
Subject: [PATCH] os_detect: add support for NixOS
Also reorder the OS name declarations to match their usages.
---
src/rospkg/os_detect.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/rospkg/os_detect.py b/src/rospkg/os_detect.py
index 42b902e..482a566 100644
--- a/src/rospkg/os_detect.py
+++ b/src/rospkg/os_detect.py
@@ -687,13 +687,14 @@ OS_LINARO = 'linaro'
OS_MINT = 'mint'
OS_NEON = 'neon'
OS_OPENSUSE = 'opensuse'
-OS_TIZEN = 'tizen'
OS_OPENSUSE13 = 'opensuse'
+OS_TIZEN = 'tizen'
OS_OSX = 'osx'
OS_QNX = 'qnx'
OS_RHEL = 'rhel'
OS_SLACKWARE = 'slackware'
OS_UBUNTU = 'ubuntu'
+OS_NIXOS = 'nixos'
OS_WINDOWS = 'windows'
OsDetect.register_default(OS_ALPINE, FdoDetect("alpine"))
@@ -720,6 +721,7 @@ OsDetect.register_default(OS_QNX, QNX())
OsDetect.register_default(OS_RHEL, Rhel())
OsDetect.register_default(OS_SLACKWARE, Slackware())
OsDetect.register_default(OS_UBUNTU, LsbDetect("Ubuntu"))
+OsDetect.register_default(OS_NIXOS, FdoDetect("nixos"))
OsDetect.register_default(OS_WINDOWS, Windows())
--
2.21.0

View file

@ -10,6 +10,8 @@ buildPythonPackage rec {
};
propagatedBuildInputs = [ catkin-pkg pyyaml ];
patches = [ ./0001-os_detect-add-support-for-NixOS.patch ];
meta = {
description = "Library for retrieving information about ROS packages and stacks";