fix: protect drv if it cannot be converted to a string

This commit is contained in:
Tom Bereknyei 2022-12-28 15:02:26 -05:00
parent aa68785e30
commit 3476034902

View File

@ -21,15 +21,17 @@
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
# Backwards compatibility helper for pre Nix2.6 bundler API
program = p: with builtins; with p; "${outPath}/bin/${
program = p: with builtins; with (protect p); "${outPath}/bin/${
if p?meta && p.meta?mainProgram then
meta.mainProgram
else (parseDrvName (unsafeDiscardStringContext p.name)).name
}";
protect = drv: if drv?outPath then drv else throw "provided installable is not a derivation and not coercible to an outPath";
in {
defaultBundler = builtins.listToAttrs (map (system: {
name = system;
value = drv: self.bundlers.${system}.toArx drv;
value = drv: self.bundlers.${system}.toArx (protect drv);
}) supportedSystems)
# Backwards compatibility helper for pre Nix2.6 bundler API
// {__functor = s: nix-bundle.bundlers.nix-bundle;};
@ -51,17 +53,17 @@
(nixpkgs.legacyPackages.${system}.dockerTools.buildLayeredImage {
name = drv.name or drv.pname or "image";
tag = "latest";
contents = [ drv ];
contents = if drv?outPath then drv else throw "provided installable is not a derivation and not coercible to an outPath";
});
toBuildDerivation = drv:
(import ./report/default.nix {
inherit drv;
drv = protect drv;
pkgs = nixpkgsFor.${system};}).buildtimeDerivations;
toReport = drv:
(import ./report/default.nix {
inherit drv;
drv = protect drv;
pkgs = nixpkgsFor.${system};}).runtimeReport;
identity = drv: drv;