mirror of
https://github.com/lopsided98/nix-ros-overlay.git
synced 2025-06-10 17:54:49 +03:00
Refactor functions into lib attrset.
This commit is contained in:
parent
11f5493931
commit
d59aab21f6
6 changed files with 42 additions and 35 deletions
|
@ -1,10 +1,9 @@
|
|||
{ distro, python }:
|
||||
self: super:
|
||||
with self.lib;
|
||||
with import ./mk-overlay.nix { inherit (self) lib; };
|
||||
let
|
||||
|
||||
base = rosSelf: rosSuper: {
|
||||
lib = super.lib // import ./lib { inherit self rosSelf; };
|
||||
|
||||
callPackage = self.newScope rosSelf;
|
||||
|
||||
buildRosPackage = rosSelf.callPackage ./build-ros-package { };
|
||||
|
@ -20,38 +19,9 @@ let
|
|||
python = rosSelf.python;
|
||||
enablePython = true;
|
||||
};
|
||||
|
||||
patchVendorUrl = pkg: {
|
||||
url, sha256,
|
||||
originalUrl ? url,
|
||||
file ? "CMakeLists.txt"
|
||||
}: pkg.overrideAttrs ({
|
||||
postPatch ? "", ...
|
||||
}: {
|
||||
postPatch = ''
|
||||
substituteInPlace '${file}' \
|
||||
--replace '${originalUrl}' '${self.fetchurl { inherit url sha256; }}'
|
||||
'' + postPatch;
|
||||
});
|
||||
};
|
||||
|
||||
overrides = rosSelf: rosSuper: let
|
||||
patchBoostPython = let
|
||||
pythonVersion = rosSelf.python.sourceVersion;
|
||||
pythonLib = "python${pythonVersion.major}${pythonVersion.minor}";
|
||||
in ''
|
||||
sed -Ei CMakeLists.txt \
|
||||
-e 's/(Boost [^)]*)python[^ )]*([ )])/\1${pythonLib}\2/'
|
||||
'';
|
||||
|
||||
patchBoostSignals = pkg: pkg.overrideAttrs ({
|
||||
postPatch ? "", ...
|
||||
}: {
|
||||
postPatch = ''
|
||||
sed -i '/find_package(Boost [^)]*/s/signals//g' CMakeLists.txt
|
||||
'' + postPatch;
|
||||
});
|
||||
in {
|
||||
overrides = rosSelf: rosSuper: with rosSelf.lib; {
|
||||
# ROS package overrides/fixups
|
||||
|
||||
ament-cmake-core = rosSuper.ament-cmake-core.overrideAttrs ({
|
||||
|
@ -245,7 +215,7 @@ let
|
|||
sha256 = "1g45f71mk4gyca550177qf70v5cvavlsalmg7x8bi59j6z6f0mgz";
|
||||
};
|
||||
};
|
||||
in mkOverlay [
|
||||
in self.rosPackages.lib.mkOverlay [
|
||||
base
|
||||
(import (./. + "/${distro}/generated.nix"))
|
||||
overrides
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
self: super: {
|
||||
rosPackages = rec {
|
||||
lib = super.lib // import ./lib { inherit self; };
|
||||
|
||||
kinetic = import ./distro-overlay.nix {
|
||||
distro = "kinetic";
|
||||
python = self.python2;
|
||||
|
|
34
lib/default.nix
Normal file
34
lib/default.nix
Normal file
|
@ -0,0 +1,34 @@
|
|||
{ lib ? rosSelf.lib or self.lib
|
||||
, self ? null
|
||||
, rosSelf ? null }:
|
||||
with lib;
|
||||
{
|
||||
patchVendorUrl = pkg: {
|
||||
url, sha256,
|
||||
originalUrl ? url,
|
||||
file ? "CMakeLists.txt"
|
||||
}: pkg.overrideAttrs ({
|
||||
postPatch ? "", ...
|
||||
}: {
|
||||
postPatch = ''
|
||||
substituteInPlace '${file}' \
|
||||
--replace '${originalUrl}' '${self.fetchurl { inherit url sha256; }}'
|
||||
'' + postPatch;
|
||||
});
|
||||
|
||||
patchBoostPython = let
|
||||
pythonVersion = rosSelf.python.sourceVersion;
|
||||
pythonLib = "python${pythonVersion.major}${pythonVersion.minor}";
|
||||
in ''
|
||||
sed -Ei CMakeLists.txt \
|
||||
-e 's/(Boost [^)]*)python[^ )]*([ )])/\1${pythonLib}\2/'
|
||||
'';
|
||||
|
||||
patchBoostSignals = pkg: pkg.overrideAttrs ({
|
||||
postPatch ? "", ...
|
||||
}: {
|
||||
postPatch = ''
|
||||
sed -i '/find_package(Boost [^)]*/s/signals//g' CMakeLists.txt
|
||||
'' + postPatch;
|
||||
});
|
||||
} // (import ./mk-overlay.nix { inherit lib; })
|
|
@ -1,5 +1,5 @@
|
|||
self: super:
|
||||
with import ./mk-overlay.nix { inherit (super) lib; };
|
||||
with import ./lib/mk-overlay.nix { inherit (super) lib; };
|
||||
applyOverlays self super [
|
||||
(import ./base.nix)
|
||||
(import ./distros.nix)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{ nixpkgs ? <nixpkgs>, nix-ros-overlay ? ./., distro }:
|
||||
|
||||
removeAttrs (import nix-ros-overlay { inherit nixpkgs; }).rosPackages."${distro}" [
|
||||
"lib"
|
||||
"python"
|
||||
"python3"
|
||||
"python2"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue