What is the right way to install Symfony CLI?

Hi! I’m at the very beginning of my discover of NixOS (and Nix).

I tried to find the right way to install the Symfony CLI. This binary isn’t in the nixpkgs and maybe for a reason. The recommended way is a script but the binary is also release in a github repository (the source isn’t provided). I know the binary contain a self updater.

I believe it’s possible to specify the path to the binary to install. Is it the right way? If so, where can I find documentation on this?
Or do I have to plan to run the script in a particular way?

Thanks for your help!

Welcome… interesting project… however

https://github.com/symfony/cli/issues/415

makes for interesting reading… another one of these open source / closed source type projects.

nix likes source code. But binaries can be package with some extra effort.

You may need to use a fhs buildroot , or a combination of binary patching patchelf.

Success is highly dependant on the nature of the executable and if the libraries it need exist on within nix.

Grepping nixpkgs is alway where i start, to see if a similar project. Get a basic derivation going and usually someone will help with pointers to get it working.

The idea situation is to always start with the source, but it’s no always possible, and that is usually a layer 9 problem (politics).

take a look at this for inspiration with nixpkgs GitHub - NixOS/nixpkgs: Nix Packages collection & NixOS

pkgs/development/tools/ccloud-cli/default.nix

take a look at. buildFHSUserEnv too.

Maybe I started to understand something, but I’m not sure because all the things I tried didn’t work.

Inspired by the ccloud-cli example, I created a symfony-cli.nix (in the same folder as configuration.nix):

{ stdenv, autoPatchelfHook, fetchurl, lib }:

stdenv.mkDerivation rec {
  pname = "symfony-cli";
  version = "4.23.5";

  # To get the latest version:
  # wget https://get.symfony.com/cli/installer -O - | bash
  src = fetchurl {
    url = "https://github.com/symfony/cli/releases/download/v${version}/symfony_linux_amd64.gz";
    sha256 = "43aef5fd5d45f4602697cad016eff504cb68ec6ad1271c7b1e2a089e1eedd05a";
  };

  nativeBuildInputs = [ autoPatchelfHook ];

  installPhase = ''
    mkdir -p $out/bin
    cp $src $out/bin/symfony
    chmod +x $out/bin/symfony
  '';

  meta = with lib; {
    description = "Symfony CLI";
    homepage = "https://symfony.com/download";
    license = licenses.unfree;
    platforms = [ "x86_64-linux" ];
  };
}

But I don’t know what to do with that. What can I write now in my configuration.nix?

But I don’t know what to do with that. What can I write now in my configuration.nix?

environment.systemPackages = [ (pkgs.callPackage ./symphony-cli.nix {}) ];
2 Likes

Things are working. Many thanks to @nixinator and @peterhoeg :slightly_smiling_face:

You helped me a lot to understand how things works (well, in part at least). I’ll just post the blocks of code that works if it can help better someone else:

symfony-cli.nix:

{ stdenv, fetchurl, lib }:

stdenv.mkDerivation rec {
  pname = "symfony-cli";
  version = "4.23.5";

  src = fetchurl {
    url = "https://github.com/symfony/cli/releases/download/v${version}/symfony_linux_amd64";
    sha256 = "43aef5fd5d45f4602697cad016eff504cb68ec6ad1271c7b1e2a089e1eedd05a";
  };

  phases = [ "installPhase" ];

  installPhase = ''
    mkdir -p $out/bin
    cp $src $out/bin/symfony
    chmod +x $out/bin/symfony
  '';

  meta = with lib; {
    description = "Symfony CLI";
    homepage = "https://symfony.com/download";
    license = licenses.unfree;
    platforms = [ "x86_64-linux" ];
  };
}

In configuration.nix:

environment.systemPackages = with pkgs; [
  (callPackage ./symfony-cli.nix {})
];
1 Like

Hi,

Is there an official package for this?

Thanks!

I submitted a pull-request to have this package in NixOS: symfony-cli: init at 4.25.2 by drupol · Pull Request #126356 · NixOS/nixpkgs · GitHub

Nice! It will help me to see how to submit a new package like this.

I have some issues with the program on NixOS, especially on the use of the local certificate authority that can be created by the program.

1 Like