mirror of
https://github.com/NixOS/bundlers.git
synced 2024-09-11 07:05:23 +03:00
Hacks to support both bundler APIs
This commit is contained in:
parent
13ac2bd539
commit
da6944052e
60
flake.nix
60
flake.nix
@ -1,3 +1,9 @@
|
||||
# First draft of this flake include a large amount of cruft to be compatible
|
||||
# with both pre and post Nix 2.6 APIs.
|
||||
#
|
||||
# The expected state is to support bundlers of the form:
|
||||
# bundlers.<system>.<name> = drv: some-drv;
|
||||
|
||||
{
|
||||
description = "Example bundlers";
|
||||
|
||||
@ -14,31 +20,43 @@
|
||||
# Nixpkgs instantiated for supported system types.
|
||||
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
|
||||
|
||||
# Backwards compatibility helper for previous bundler API
|
||||
program = p: with p; "${outPath}/bin/${
|
||||
if meta?mainProgram then
|
||||
# Backwards compatibility helper for pre Nix2.6 bundler API
|
||||
program = p: with builtins; with p; "${outPath}/bin/${
|
||||
if p?meta && p.meta?mainProgram then
|
||||
meta.mainProgram
|
||||
else
|
||||
(builtins.parseDrvName name).name
|
||||
else (parseDrvName (unsafeDiscardStringContext p.name)).name
|
||||
}";
|
||||
in {
|
||||
|
||||
# defaultBundler.x86_64-linux = forAllSystems (system: self.bundlers.${system}.toArx);
|
||||
defaultBundler.x86_64-linux = self.bundlers.x86_64-linux.toArx;
|
||||
# Backwards compatibility helper for pre Nix2.6 bundler API
|
||||
defaultBundler = {__functor = s: {...}@arg:
|
||||
(if arg?program && arg?system then
|
||||
nix-bundle.bundlers.nix-bundle arg
|
||||
else with builtins; listToAttrs (map (system: {
|
||||
name = system;
|
||||
value = drv: self.bundlers.${system}.toArx drv;
|
||||
}) supportedSystems));
|
||||
};
|
||||
|
||||
bundlers = forAllSystems (system: {
|
||||
toArx = drv: nix-bundle.bundlers.nix-bundle {inherit system; program=program drv;};
|
||||
bundlers = let n =
|
||||
(forAllSystems (system: {
|
||||
# Backwards compatibility helper for pre Nix2.6 bundler API
|
||||
toArx = drv: (nix-bundle.bundlers.nix-bundle ({
|
||||
program = if drv?program then drv.program else (program drv);
|
||||
inherit system;
|
||||
})) // (if drv?program then {} else {name=
|
||||
(builtins.parseDrvName drv.name).name;});
|
||||
|
||||
toRPM = drv: nix-utils.bundlers.rpm {inherit system; program=program drv;};
|
||||
|
||||
toDEB = drv: nix-utils.bundlers.deb {inherit system; program=program drv;};
|
||||
|
||||
toDockerImage = drv:
|
||||
nixpkgs.legacyPackages.${system}.dockerTools.buildLayeredImage {
|
||||
toDockerImage = {...}@drv:
|
||||
(nixpkgs.legacyPackages.${system}.dockerTools.buildLayeredImage {
|
||||
name = drv.name;
|
||||
tag = "latest";
|
||||
contents = [ drv ];
|
||||
};
|
||||
});
|
||||
|
||||
toBuildDerivation = drv:
|
||||
(import ./default.nix {
|
||||
@ -46,12 +64,26 @@
|
||||
pkgs = nixpkgsFor.${system};}).buildtimeDerivations;
|
||||
|
||||
toReport = drv:
|
||||
builtins.trace drv
|
||||
(import ./default.nix {
|
||||
inherit drv;
|
||||
pkgs = nixpkgsFor.${system};}).runtimeReport;
|
||||
|
||||
identity = drv: drv;
|
||||
});
|
||||
}
|
||||
));
|
||||
in with builtins;
|
||||
# Backwards compatibility helper for pre Nix2.6 bundler API
|
||||
listToAttrs (map
|
||||
(name: {
|
||||
inherit name;
|
||||
value = {system,program}@drv: self.bundlers.${system}.${name}
|
||||
(drv // {
|
||||
name = baseNameOf drv.program;
|
||||
outPath = dirOf (dirOf drv.program);
|
||||
});
|
||||
})
|
||||
(attrNames n.x86_64-linux))
|
||||
//
|
||||
n;
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user