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

Appimage bundler

commitf7e25e668ffe02cd3a3f3c25884a9e12c42ece1a authorMatthew Bauer <mjbauer95@gmail.com> dateMon 24 Jun 2019, 01:16 (7 years ago) parente65faad943985a
2 files changed+60−3
appdir.nix+3−3 appimage-bundle.nix+57
appdir.nix+3−3
@@ -42,7 +42,7 @@ in
4242 cd $out/${name}.AppDir
4343
4444 mkdir -p nix/store
45− cp -r $storePaths nix/store
45+ cp -Lr $storePaths nix/store
4646
4747 ln -s .${target} usr
4848
@@ -63,12 +63,12 @@ in
6363
6464 # icons
6565 if [ -d ${target}/share/icons ]; then
66− icon=$(find ${target}/share/icons -name "${name}.png" | head -n1)
66+ icon=$(find ${target}/share/icons -name "${name}*.png" | head -n1)
6767 if ! [ -z "$icon" ]; then
6868 ln -s .$icon
6969 ln -s .$icon .DirIcon
7070 else
71− icon=$(find ${target}/share/icons -name "${name}.svg" | head -n1)
71+ icon=$(find ${target}/share/icons -name "${name}*.svg" | head -n1)
7272 if ! [ -z "$icon" ]; then
7373 ln -s .$icon
7474 ln -s .$icon .DirIcon
appimage-bundle.nixnew file+57
@@ -0,0 +1,57 @@
1+# use like this:
2+# nix-build appimage-bundle.nix --argstr package hello --argstr exec hello
3+
4+{nixpkgs ? import <nixpkgs>{},
5+package,
6+exec,
7+... }:
8+let
9+ appimage_src = drv : exec : with nixpkgs;
10+ self.stdenv.mkDerivation rec {
11+ name = drv.name + "-appdir";
12+ env = buildEnv {
13+ inherit name;
14+ paths = buildInputs;
15+ };
16+ src = env;
17+ inherit exec;
18+ buildInputs = [ drv nixpkgs.coreutils nixpkgs.gnutar nixpkgs.xz ];
19+ usr_fonts = buildEnv {
20+ name = "fonts";
21+ paths = [noto-fonts];
22+ };
23+ buildCommand = ''
24+ source $stdenv/setup
25+ mkdir -p $out/bin
26+ cp -rL ${env}/* $out/
27+ chmod +w -R $out/
28+
29+ mkdir -p $out/share/fonts
30+ cp ${usr_fonts}/share/fonts/* $out/share/fonts -R
31+
32+ mkdir -p $out/share/icons
33+ mkdir -p $out/share/icons/hicolor/256x256/apps
34+ touch $out/share/icons/hicolor/256x256/apps/${drv.name}.png
35+ touch $out/share/icons/${drv.name}.png
36+
37+ mkdir -p $out/share/applications
38+ cat <<EOF > $out/share/applications/${drv.name}.desktop
39+ [Desktop Entry]
40+ Type=Application
41+ Version=1.0
42+ Name=${drv.name}
43+ Path=${env}
44+ Icon=${drv.name}
45+ Exec=$exec
46+ Terminal=true
47+ EOF
48+ '';
49+ system = builtins.currentSystem;
50+ };
51+
52+in
53+ 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;})