about summary refs log tree commit diff
path: root/nixpkgs/pkgs/tools/system/s6-rc/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/tools/system/s6-rc/default.nix')
-rw-r--r--nixpkgs/pkgs/tools/system/s6-rc/default.nix23
1 files changed, 21 insertions, 2 deletions
diff --git a/nixpkgs/pkgs/tools/system/s6-rc/default.nix b/nixpkgs/pkgs/tools/system/s6-rc/default.nix
index 532575d16c88..31b9c14257af 100644
--- a/nixpkgs/pkgs/tools/system/s6-rc/default.nix
+++ b/nixpkgs/pkgs/tools/system/s6-rc/default.nix
@@ -1,4 +1,4 @@
-{ lib, skawarePackages }:
+{ lib, stdenv, skawarePackages, targetPackages }:
 
 with skawarePackages;
 
@@ -8,7 +8,7 @@ buildPackage {
   sha256 = "12bzc483jpd16xmhfsfrib84daj1k3kwy5s5nc18ap60apa1r39a";
 
   description = "A service manager for s6-based systems";
-  platforms = lib.platforms.linux;
+  platforms = lib.platforms.unix;
 
   outputs = [ "bin" "lib" "dev" "doc" "out" ];
 
@@ -30,6 +30,25 @@ buildPackage {
     "--with-dynlib=${s6.out}/lib"
   ];
 
+  # s6-rc-compile generates built-in service definitions containing
+  # absolute paths to execline, s6, and s6-rc programs.  If we're
+  # running s6-rc-compile as part of a Nix derivation, and we want to
+  # cross-compile that derivation, those paths will be wrong --
+  # they'll be for execline, s6, and s6-rc on the platform we're
+  # running s6-rc-compile on, not the platform we're targeting.
+  #
+  # We can detect this special case of s6-rc being used at build time
+  # in a derivation that's being cross-compiled, because that's the
+  # only time hostPlatform != targetPlatform.  When that happens we
+  # modify s6-rc-compile to use the configuration headers for the
+  # system we're cross-compiling for.
+  postConfigure = lib.optionalString (stdenv.hostPlatform != stdenv.targetPlatform) ''
+    substituteInPlace src/s6-rc/s6-rc-compile.c \
+        --replace '<execline/config.h>' '"${targetPackages.execline.dev}/include/execline/config.h"' \
+        --replace '<s6/config.h>' '"${targetPackages.s6.dev}/include/s6/config.h"' \
+        --replace '<s6-rc/config.h>' '"${targetPackages.s6-rc.dev}/include/s6-rc/config.h"'
+  '';
+
   postInstall = ''
     # remove all s6 executables from build directory
     rm $(find -name "s6-rc-*" -type f -mindepth 1 -maxdepth 1 -executable)