I'm currently trying to package some closed-source software into Nix derivations. The app is distributed as a large pile of .deb
files, and most of them contain libraries that the other parts of the app can use.
To simplify, assume that app.deb
contains the actual application, and lib.deb
contains a library that the app requires.
Currently I have:
# default.nix
let
nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-23.11";
pkgs = import nixpkgs {
config = { };
overlays = [ ];
};
in {
lib = pkgs.callPackage ./lib.nix { };
app = pkgs.callPackage ./app.nix { };
}
# lib.nix
{ lib, stdenv, autoPatchelfHook, dpkg, requireFile,
libcxx, libgcc, }:
stdenv.mkDerivation {
pname = "myapp-lib";
version = "1.0.0";
src = requireFile {
name = "lib.deb";
sha256 = "313e8686118ccba397de0bdfca101f1053b758227fd9d3510ea78644f2450bfe";
url = "https://softwarecorp.example/downloads";
};
nativeBuildInputs = [
dpkg
autoPatchelfHook
];
unpackPhase = "dpkg-deb -x $src .";
buildInputs = [ libcxx libgcc ];
installPhase = ''
cp -r lib $out/
'';
}
# app.nix
{ lib, stdenv, autoPatchelfHook, dpkg, requireFile,
libcxx, }:
stdenv.mkDerivation {
pname = "myapp-bin";
version = "1.0.0";
src = requireFile {
name = "app.deb";
sha256 = "f4abbdb3f83d982569c5cd30ce5ad63ec4e49011d165e17a2c59d9a613f163b9";
url = "https://softwarecorp.example/downloads";
};
nativeBuildInputs = [
dpkg
autoPatchelfHook
];
unpackPhase = "dpkg-deb -x $src .";
buildInputs = [ libcxx ];
installPhase = ''
cp -r bin $out/
'';
runtimeDependencies = [ myapp-lib ]; # <-- how to do this?
}
The lib
derivation builds on its own, and now I want to add the things it contains to the app
derivation.
I can't just add it to the regular list of package dependencies at the top of the file.
I'd also like to avoid submitting the package to nixpkgs at this time, because I'm not sure I'll be able to package the app fully, and I don't want to become its maintainer before I know it can be done.
Alternatively, are there any good patterns for packaging closed-source software like this that would avoid needing to make lots of derivations? From what I can tell, the libraries here all have the same version, and are never used anywhere else in the company's products, so building a single derivation could be acceptable here.