on master help sign in
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

commitd18d34c2db9d43ed7fae187c6cd612e8a6433fdd authorTom Bereknyei <tom@dds.mil> dateTue 25 Jun 2019, 16:10 (7 years ago) parent943985a
1 file changed+22−9
appimage-bundle.nix+22−9
appimage-bundle.nix+22−9
@@ -1,5 +1,7 @@
11# use like this:
22# nix-build appimage-bundle.nix --argstr package hello --argstr exec hello
3+# nix-build appimage-bundle.nix --arg package 'with import <nixpkgs>{}; writers.writePython3Bin "helloThere.py" {} "print(1)\n"' --argstr exec helloThere.py
4+
35
46{nixpkgs ? import <nixpkgs>{},
57package,
@@ -15,18 +17,19 @@ let
1517 };
1618 src = env;
1719 inherit exec;
18− buildInputs = [ drv nixpkgs.coreutils nixpkgs.gnutar nixpkgs.xz ];
20+ buildInputs = [ drv ];
1921 usr_fonts = buildEnv {
2022 name = "fonts";
2123 paths = [noto-fonts];
2224 };
2325 buildCommand = ''
2426 source $stdenv/setup
25− mkdir -p $out/bin
26− cp -rL ${env}/* $out/
27− chmod +w -R $out/
28−
27+ mkdir $out
28+ shopt -s extglob
29+ ln -s ${env}/!(share) $out/
2930 mkdir -p $out/share/fonts
31+ ln -s ${env}/share/* $out/share/
32+
3033 cp ${usr_fonts}/share/fonts/* $out/share/fonts -R
3134
3235 mkdir -p $out/share/icons
@@ -50,8 +53,18 @@ let
5053 };
5154
5255in
56+ let results =
57+ if (nixpkgs.lib.isDerivation package && !(nixpkgs.lib.isString package))
58+ then {
59+ name = package.name;
60+ target = appimage_src package "${exec}";
61+ extraTargets = [];
62+ }
63+ else {
64+ name = nixpkgs."${package}".name;
65+ target = appimage_src (nixpkgs."${package}") "${exec}";
66+ extraTargets = [];
67+ };
68+ in
5369 with (import (./appimage-top.nix){nixpkgs' = nixpkgs.path;});
54− (appimage (appdir {
55− name = package;
56− target = appimage_src nixpkgs."${package}" "${exec}";
57− })).overrideAttrs (old: {name = package;})
70+ (appimage (appdir results )).overrideAttrs (old: {name = results.name;})