on master help sign in
Merge pull request #49 from tomberek/bundler

Allow bundle to handle an evaluated nix expression

commit0912342bf4b8a6e9f809c53b51018326b2d9d247 authorMatthew Bauer <mjbauer95@gmail.com> dateSat 29 Jun 2019, 18:58 (7 years ago) parentf7e25e6ee29621
2 files changed+23−19
appdir.nix+1−1 appimage-bundle.nix+22−18
appdir.nix+1−1
@@ -42,7 +42,7 @@ in
4242 cd $out/${name}.AppDir
4343
4444 mkdir -p nix/store
45− cp -Lr $storePaths nix/store
45+ cp -r $storePaths nix/store
4646
4747 ln -s .${target} usr
4848
appimage-bundle.nix+22−18
@@ -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,26 +17,18 @@ let
1517 };
1618 src = env;
1719 inherit exec;
18− buildInputs = [ drv nixpkgs.coreutils nixpkgs.gnutar nixpkgs.xz ];
19− usr_fonts = buildEnv {
20− name = "fonts";
21− paths = [noto-fonts];
22− };
20+ buildInputs = [ drv ];
2321 buildCommand = ''
24− source $stdenv/setup
25− mkdir -p $out/bin
26− cp -rL ${env}/* $out/
27− chmod +w -R $out/
22+ mkdir -p $out/share/icons/hicolor/256x256/apps
23+ mkdir -p $out/share/applications
2824
29− mkdir -p $out/share/fonts
30− cp ${usr_fonts}/share/fonts/* $out/share/fonts -R
25+ shopt -s extglob
26+ ln -s ${env}/!(share) $out/
27+ ln -s ${env}/share/* $out/share/
3128
32− mkdir -p $out/share/icons
33− mkdir -p $out/share/icons/hicolor/256x256/apps
3429 touch $out/share/icons/hicolor/256x256/apps/${drv.name}.png
3530 touch $out/share/icons/${drv.name}.png
3631
37− mkdir -p $out/share/applications
3832 cat <<EOF > $out/share/applications/${drv.name}.desktop
3933 [Desktop Entry]
4034 Type=Application
@@ -50,8 +44,18 @@ let
5044 };
5145
5246in
47+ let results =
48+ if (nixpkgs.lib.isDerivation package && !(nixpkgs.lib.isString package))
49+ then {
50+ name = package.name;
51+ target = appimage_src package "${exec}";
52+ extraTargets = [];
53+ }
54+ else {
55+ name = nixpkgs."${package}".name;
56+ target = appimage_src (nixpkgs."${package}") "${exec}";
57+ extraTargets = [];
58+ };
59+ in
5360 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;})
61+ (appimage (appdir results )).overrideAttrs (old: {name = results.name;})