Install Composer 1 to upgrade a project to Composer 2

I would have to jump back to Composer 1 to upgrade an existing Drupal project to Composer 2. However, for my NixOS version 21.11, it is no longer in the repository only in version 21.05. I can’t find anything via “nix-env -qaP composer” either. Can I somehow get the composer package from version 21.05 and install it. Because if I now also add the version 21.05 to the nix-channel, it still comes completely messed up?

Would be grateful for any help.

Greeting Bavra

If you want to add composer1 to your system you could adapt this configuration.nix:

{ config, pkgs, lib, ... }:
let
  nixos-21_05 = import (builtins.fetchTarball {
    name = "nixos-21_05-2022-01-15";
    url = "https://github.com/nixos/nixpkgs/archive/0fd9ee1aa36ce865ad273f4f07fdc093adeb5c00.tar.gz";
    sha256 = "1mr2qgv5r2nmf6s3gqpcjj76zpsca6r61grzmqngwm0xlh958smx";
  }) {};
in
{
  environment.systemPackages = with pkgs; [
    nixos-21_05.php.packages.composer1
  ];
}

If you just want to run composer1 from a nix-shell temporarily you could paste this shell.nix in a folder and then run nix-shell in that folder:

{ pkgs ? import <nixpkgs> {} }:
let
  nixos-21_05 = import (builtins.fetchTarball {
    name = "nixos-21_05-2022-01-15";
    url = "https://github.com/nixos/nixpkgs/archive/0fd9ee1aa36ce865ad273f4f07fdc093adeb5c00.tar.gz";
    sha256 = "1mr2qgv5r2nmf6s3gqpcjj76zpsca6r61grzmqngwm0xlh958smx";
  }) {};
in
  pkgs.mkShell {
    nativeBuildInputs = [
      nixos-21_05.php.packages.composer1
    ];
  }

I have tried this with the nix-shell. Works great. Thank you again.

1 Like