Allow bundle to handle an evaluated nix expression

Example (note the --arg vs --argstr for the package argument):
nix-build appimage-bundle.nix --arg package 'with import <nixpkgs>{}; writers.writePython3Bin "helloThere.py" {} "print(1)\n"' --argstr exec helloThere.py
This commit is contained in:
Tom Bereknyei 2019-06-25 16:10:54 -04:00
parent 943985abb0
commit d18d34c2db

View File

@ -1,5 +1,7 @@
# use like this:
# nix-build appimage-bundle.nix --argstr package hello --argstr exec hello
# nix-build appimage-bundle.nix --arg package 'with import <nixpkgs>{}; writers.writePython3Bin "helloThere.py" {} "print(1)\n"' --argstr exec helloThere.py
{nixpkgs ? import <nixpkgs>{},
package,
@ -15,18 +17,19 @@ let
};
src = env;
inherit exec;
buildInputs = [ drv nixpkgs.coreutils nixpkgs.gnutar nixpkgs.xz ];
buildInputs = [ drv ];
usr_fonts = buildEnv {
name = "fonts";
paths = [noto-fonts];
};
buildCommand = ''
source $stdenv/setup
mkdir -p $out/bin
cp -rL ${env}/* $out/
chmod +w -R $out/
mkdir $out
shopt -s extglob
ln -s ${env}/!(share) $out/
mkdir -p $out/share/fonts
ln -s ${env}/share/* $out/share/
cp ${usr_fonts}/share/fonts/* $out/share/fonts -R
mkdir -p $out/share/icons
@ -50,8 +53,18 @@ let
};
in
let results =
if (nixpkgs.lib.isDerivation package && !(nixpkgs.lib.isString package))
then {
name = package.name;
target = appimage_src package "${exec}";
extraTargets = [];
}
else {
name = nixpkgs."${package}".name;
target = appimage_src (nixpkgs."${package}") "${exec}";
extraTargets = [];
};
in
with (import (./appimage-top.nix){nixpkgs' = nixpkgs.path;});
(appimage (appdir {
name = package;
target = appimage_src nixpkgs."${package}" "${exec}";
})).overrideAttrs (old: {name = package;})
(appimage (appdir results )).overrideAttrs (old: {name = results.name;})