ralismark / nix-appimage

Convert a nixos derivation into a self-contained binary
MIT License
156 stars 20 forks source link

Make squashfsArgs configurable from derivation #15

Closed aim-nara closed 1 month ago

aim-nara commented 2 months ago

I've like to specify compression level and compression type from derivation

ralismark commented 2 months ago

Could you explain how drv.squashfsArgs would be set? I don't see how nix bundle can set them.

aim-nara commented 2 months ago

I've like to use it like:

packages.x86_64-linux.build = stdenv.mkDerivation {
  ...
  squashfsArgs = ["-comp" "zstd" "-Xcompression-level" "5"];
  ...
};

Or is there other better way to set it?

ralismark commented 1 month ago

For nix bundle, there's no way to set the squashfsArgs introduced by this PR.

If you're using building an AppImage from nix code, e.g. in another flake, use lib.mkAppImage, don't use bundlers.<system>.default.

Being able to set squashfsArgs from the derivation doesn't seem like a good idea, even if it is convenient.

aim-nara commented 1 month ago

I've got your point and seems more reasonable. I'm not a nix expert so I've tried on my env and got code like following work:

{
  inputs = {
    nixpkgs.url = ...;
    nix-appimage.url = "github:ralismark/nix-appimage";
  };
  outputs = { self, nixpkgs, nix-appimage }: 
    let
      pkgs = import nixpkgs { system = "x86_64-linux"; }
      mkAppImage = nix-appimage.lib.x86_64-linux.mkAppImage;
    in {
      packages.x86_64-linux.default = pkgs.stdenv.mkDerivation {
        ...
      }
      packages.x86_64-linux.appimage = mkAppImage {
        program = pkgs.lib.getExe self.packages.x86_64-linux.default;
        squashfsArgs = ["-comp" "zstd" "-Xcompression-level" "5" ...];
      };
    };
}

by running nix build ./.#appimage

Is there any other better example to refer?

aim-nara commented 1 month ago

Also by using lib.mkAppImage it's better since flake.nix will track specific nix-appimage with flake.lock which is more like "managed by nix"