Merge pull request #49 from tomberek/bundler

Allow bundle to handle an evaluated nix expression
This commit is contained in:
Matthew Bauer 2019-06-29 18:58:26 -04:00 committed by GitHub
commit 0912342bf4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 20 deletions

View File

@ -42,7 +42,7 @@ in
cd $out/${name}.AppDir
mkdir -p nix/store
cp -Lr $storePaths nix/store
cp -r $storePaths nix/store
ln -s .${target} usr

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,26 +17,18 @@ let
};
src = env;
inherit exec;
buildInputs = [ drv nixpkgs.coreutils nixpkgs.gnutar nixpkgs.xz ];
usr_fonts = buildEnv {
name = "fonts";
paths = [noto-fonts];
};
buildInputs = [ drv ];
buildCommand = ''
source $stdenv/setup
mkdir -p $out/bin
cp -rL ${env}/* $out/
chmod +w -R $out/
mkdir -p $out/share/fonts
cp ${usr_fonts}/share/fonts/* $out/share/fonts -R
mkdir -p $out/share/icons
mkdir -p $out/share/icons/hicolor/256x256/apps
mkdir -p $out/share/applications
shopt -s extglob
ln -s ${env}/!(share) $out/
ln -s ${env}/share/* $out/share/
touch $out/share/icons/hicolor/256x256/apps/${drv.name}.png
touch $out/share/icons/${drv.name}.png
mkdir -p $out/share/applications
cat <<EOF > $out/share/applications/${drv.name}.desktop
[Desktop Entry]
Type=Application
@ -50,8 +44,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;})