Unverified Commit d6199f83 authored by Arne Keller's avatar Arne Keller Committed by GitHub
Browse files

doc/build-helpers: fix appimage example where postExtract is used (#402756)

parents a8d00590 855da9ad
Loading
Loading
Loading
Loading
+17 −7
Original line number Diff line number Diff line
@@ -110,12 +110,12 @@ appimageTools.wrapType2 {
  extraPkgs = pkgs: [ pkgs.at-spi2-core ];

  extraInstallCommands = ''
    mv $out/bin/${pname}-${version} $out/bin/${pname}
    mv $out/bin/irccloud-${version} $out/bin/irccloud
    install -m 444 -D ${appimageContents}/irccloud.desktop $out/share/applications/irccloud.desktop
    install -m 444 -D ${appimageContents}/usr/share/icons/hicolor/512x512/apps/irccloud.png \
      $out/share/icons/hicolor/512x512/apps/irccloud.png
    substituteInPlace $out/share/applications/irccloud.desktop \
      --replace-fail 'Exec=AppRun' 'Exec=${pname}'
      --replace-fail 'Exec=AppRun' 'Exec=irccloud'
  '';
}
```
@@ -125,11 +125,16 @@ appimageTools.wrapType2 {
The argument passed to `extract` can also contain a `postExtract` attribute, which allows you to execute additional commands after the files are extracted from the AppImage.
`postExtract` must be a string with commands to run.

:::{.warning}
When specifying `postExtract`, you should use `appimageTools.wrapAppImage` instead of `appimageTools.wrapType2`.
Otherwise `wrapType2` will extract the AppImage contents without respecting the `postExtract` instructions.
:::

:::{.example #ex-extracting-appimage-with-postextract}

# Extracting an AppImage to install extra files, using `postExtract`

This is a rewrite of [](#ex-extracting-appimage) to use `postExtract`.
This is a rewrite of [](#ex-extracting-appimage) to use `postExtract` and `wrapAppImage`.

```nix
{ appimageTools, fetchurl }:
@@ -145,21 +150,26 @@ let
  appimageContents = appimageTools.extract {
    inherit pname version src;
    postExtract = ''
      substituteInPlace $out/irccloud.desktop --replace-fail 'Exec=AppRun' 'Exec=${pname}'
      substituteInPlace $out/irccloud.desktop --replace-fail 'Exec=AppRun' 'Exec=irccloud'
    '';
  };
in
appimageTools.wrapType2 {
  inherit pname version src;
appimageTools.wrapAppImage {
  inherit pname version;

  src = appimageContents;

  extraPkgs = pkgs: [ pkgs.at-spi2-core ];

  extraInstallCommands = ''
    mv $out/bin/${pname}-${version} $out/bin/${pname}
    mv $out/bin/irccloud-${version} $out/bin/irccloud
    install -m 444 -D ${appimageContents}/irccloud.desktop $out/share/applications/irccloud.desktop
    install -m 444 -D ${appimageContents}/usr/share/icons/hicolor/512x512/apps/irccloud.png \
      $out/share/icons/hicolor/512x512/apps/irccloud.png
  '';

  # specify src archive for nix-update
  passthru.src = src;
}
```