From d18d34c2db9d43ed7fae187c6cd612e8a6433fdd Mon Sep 17 00:00:00 2001 From: Tom Bereknyei Date: Tue, 25 Jun 2019 16:10:54 -0400 Subject: [PATCH 1/3] 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 {}; writers.writePython3Bin "helloThere.py" {} "print(1)\n"' --argstr exec helloThere.py --- appimage-bundle.nix | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/appimage-bundle.nix b/appimage-bundle.nix index 1964de0..e1e8c65 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,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;}) From 9323b9ca68b2ce493be6e0a8f3bfd9bbb70a9827 Mon Sep 17 00:00:00 2001 From: Tom Bereknyei Date: Wed, 26 Jun 2019 11:43:30 -0400 Subject: [PATCH 2/3] Remove symbolic link resolution, closure should contain all links --- appdir.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From ee29621831a3413d29fc84334fc11f957ea0050f Mon Sep 17 00:00:00 2001 From: Tom Bereknyei Date: Wed, 26 Jun 2019 17:32:46 -0400 Subject: [PATCH 3/3] Simplify appimage generation --- appimage-bundle.nix | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/appimage-bundle.nix b/appimage-bundle.nix index e1e8c65..c42a5e7 100644 --- a/appimage-bundle.nix +++ b/appimage-bundle.nix @@ -18,26 +18,17 @@ let src = env; inherit exec; buildInputs = [ drv ]; - usr_fonts = buildEnv { - name = "fonts"; - paths = [noto-fonts]; - }; buildCommand = '' - source $stdenv/setup - mkdir $out + mkdir -p $out/share/icons/hicolor/256x256/apps + mkdir -p $out/share/applications + 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 - mkdir -p $out/share/icons/hicolor/256x256/apps 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