linux-apfs / apfsprogs

Experimental APFS tools for linux
GNU General Public License v2.0
99 stars 15 forks source link

Nixpkgs packaging #4

Closed Luflosi closed 3 years ago

Luflosi commented 3 years ago

FYI: I intend to package apfsprogs in Nixpkgs soon. This will allow easy installation on NixOS and any Linux distro with Nix installed. I just want to show you the code I intend to add to Nixpkgs so you can look over it and see if you can spot any obvious mistakes/improvements or ask any questions you may have.

{ lib
, stdenv
, fetchFromGitHub
}:

stdenv.mkDerivation rec {
  pname = "apfsprogs-unstable";
  version = "2021.05.07";

  src = fetchFromGitHub {
    owner = "linux-apfs";
    repo = "apfsprogs";
    rev = "d360211a30608a907e3ee8ad4468d606c40ec2d7";
    sha256 = "sha256-SeFs/GQfIEvnxERyww+mnynjR7E02DdtBA6JsknEM+Q=";
  };

  buildPhase = ''
    runHook preBuild
    make -C apfsck
    make -C mkapfs
    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall
    make -C apfsck install BINDIR="$out/bin" MANDIR="$out/share/man8"
    make -C mkapfs install BINDIR="$out/bin" MANDIR="$out/share/man8"
    runHook postInstall
  '';

  meta = with lib; {
    description = "Experimental APFS tools for linux";
    homepage = "https://github.com/linux-apfs/apfsprogs";
    license = licenses.gpl2Only;
    platforms = platforms.linux;
    maintainers = with maintainers; [ Luflosi ];
  };
}
eafer commented 3 years ago

FYI: I intend to package apfsprogs in Nixpkgs soon. This will allow easy installation on NixOS and any Linux distro with Nix installed.

Thanks! I'm not familiar with Nix myself, but I'll see if I can help:

make -C apfsck install BINDIR="$out/bin" MANDIR="$out/share/man8"
make -C mkapfs install BINDIR="$out/bin" MANDIR="$out/share/man8"

Are these the right installation directories? What would be the default value for $out? It doesn't look like the man pages can be sent to /usr/local/share/man/man8, which is probably what people expect.

Luflosi commented 3 years ago

Thanks for the quick reply. On NixOS the only file in /usr is /usr/bin/env. $out is a path like /nix/store/hnbmcyndwljhrb459dv2rppkc5wxjvxk-apfsprogs-unstable-2021.05.07. The long hash basically depends on the code I posted above and all the dependencies, in this case only the standard build environment with the compiler and a few other things. This allows binary reproducibility, multiple versions of the same package "installed" at the same time and all the other benefits of Nix. Of course there are a few downsides as well like no FHS compliance. Is the license info correct? I'm not 100% sure if it's GPL2 only or GPL2+.

eafer commented 3 years ago

On Wed, Jun 09, 2021 at 12:18:46PM -0700, Luflosi wrote:

On NixOS the only file in /usr is /usr/bin/env. $out is a path like /nix/store/hnbmcyndwljhrb459dv2rppkc5wxjvxk-apfsprogs-unstable-2021.05.07. The long hash basically depends on the code I posted above and all the dependencies, in this case only the standard build environment with the compiler and a few other things. This allows binary reproducibility, multiple versions of the same package "installed" at the same time and all the other benefits of Nix. Of course there are a few downsides as well like no FHS compliance.

Ah ok, that makes sense.

Is the license info correct? I'm not 100% sure if it's GPL2 only or GPL2+.

It's GPL2 only, to be safe. I sometimes copy code from the kernel module, so it's better to keep them both under the same license.

Luflosi commented 3 years ago

I got it merged: https://github.com/NixOS/nixpkgs/pull/126394. Thank you.

eafer commented 3 years ago

I got it merged: https://github.com/NixOS/nixpkgs/pull/126394. Thank you.

That's great, thanks.