diff --git a/appdir.nix b/appdir.nix index 856eb40..1378ca9 100644 --- a/appdir.nix +++ b/appdir.nix @@ -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 diff --git a/appimage-bundle.nix b/appimage-bundle.nix index 1964de0..c42a5e7 100644 --- a/appimage-bundle.nix +++ b/appimage-bundle.nix @@ -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 {}; writers.writePython3Bin "helloThere.py" {} "print(1)\n"' --argstr exec helloThere.py + {nixpkgs ? import {}, 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 < $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;})