Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: php <= 7.4 libtool sha256 #306

Merged
merged 1 commit into from
Nov 3, 2023
Merged

fix: php <= 7.4 libtool sha256 #306

merged 1 commit into from
Nov 3, 2023

Conversation

thelissimus
Copy link
Contributor

fixes #305

I tested it locally, everything was fine.

2023-11-03_14-31

@drupol
Copy link
Collaborator

drupol commented Nov 3, 2023

I couldn't test this myself since I do not own a Mac, but I trust you on this one.

@drupol drupol merged commit 3d8344f into fossar:master Nov 3, 2023
21 checks passed
@thelissimus
Copy link
Contributor Author

@drupol Thanks! However, I do not own a Mac too. The problem was that it did not even allow to build it on Linux, specifically in NixOS 23.11. Now it works, I was able to run my old project.

@drupol
Copy link
Collaborator

drupol commented Nov 3, 2023

Ho. That's weird because I can't reproduce the issue.

What's the command you were using to trigger the issue?

@thelissimus
Copy link
Contributor Author

nix develop --impure. Impure part is required by devenv.

@thelissimus
Copy link
Contributor Author

thelissimus commented Nov 3, 2023

I was able to reproduce it again with this flake.nix:

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    nixpkgsMySQL57.url = "github:NixOS/nixpkgs/611bf8f183e6360c2a215fa70dfd659943a9857f";
    flake-utils.url = "github:numtide/flake-utils";
    # phps.url = "github:thelissimus/nix-phps"; # my fork where I replaced the sha256
    phps.url = "github:fossar/nix-phps/58efd805e85ee2b0f332c3e4caaa19786de2f20e"; # this repo before merging my fork
    devenv.url = "github:cachix/devenv/v0.6.3";
  };
  outputs =
    { nixpkgs
    , nixpkgsMySQL57
    , flake-utils
    , devenv
    , phps
    , ...
    } @ inputs:
    flake-utils.lib.eachDefaultSystem (system:
    let
      pkgs = import nixpkgs { localSystem = { inherit system; }; };
      pkgsMySQL57 = import nixpkgsMySQL57 { localSystem = { inherit system; }; };
      pkgsPhp = phps.packages.${system};
      packages = [
        pkgsPhp.php73
        pkgsPhp.php73.packages.composer
        pkgsMySQL57.mysql57
      ];
    in
    {
      devShells.default = devenv.lib.mkShell {
        inherit inputs pkgs;
        modules = [{
          inherit packages;
          services.mysql = {
            enable = true;
          };
        }];
      };
    }
    );
}

Output of nix develop --impure:

• Updated input 'phps':
    'github:thelissimus/nix-phps/7d99bade16466892c631e3f59ba04d87f837f5a8' (2023-11-03)
  → 'github:fossar/nix-phps/58efd805e85ee2b0f332c3e4caaa19786de2f20e' (2023-10-29)
warning: Git tree '/home/gicw/code' is dirty
error: hash mismatch in fixed-output derivation '/nix/store/cbw81xmg63889yvk52zmnwicqlzk9gq0-d016434ad33284dfaceb8d233351d34356566d7d.patch.drv':
         specified: sha256-x0vEcoXNFeQi3re1TrK/Np9AH5dy3wf95xM08xCyGE0=
            got:    sha256-Th1ZhC8t84MACxosoYud1LGDd5DtYe36Ctk1Ocjcu1s=
error: 1 dependencies of derivation '/nix/store/yxa5yj0f5xiz0614h9bnrf01y5zswfzi-php-7.3.33.drv' failed to build
error: 1 dependencies of derivation '/nix/store/qqkwr3zph3achkkwl8zh7xfvb3gcpj82-php-with-extensions-7.3.33.drv' failed to build
error: 1 dependencies of derivation '/nix/store/9khycqnlnrdl929bbzmabnc3zmypqxc3-devenv-profile.drv' failed to build
error: 1 dependencies of derivation '/nix/store/byjk8rqlw8b396k8a4p1jgl89nr8gj1c-devenv-shell-env.drv' failed to build

I, initially, thought it was because that --impure of devenv broke something beyond fixing. Because of that I re-installed my whole OS (re-formatted disks even). But it was of no help, the issue persisted.

@thelissimus
Copy link
Contributor Author

I get the same error even when I don't use devenv with impure flag and instead use regular pkgs.mkShell:

      devShells.default = pkgs.mkShell {
        buildInputs = packages;
      };

@drupol
Copy link
Collaborator

drupol commented Nov 3, 2023

So basically, in your flake, you're using php73 from fossar/nix-phps. Therefore, when doing this command:

❯ nix shell github:fossar/nix-phps#php73
❯ php -v
PHP 7.3.33 (cli) (built: Nov 16 2021 11:18:41) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.33, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.33, Copyright (c) 1999-2018, by Zend Technologies
~ ❯  

I should also have the issue, but I have not.

I also took the liberty to rewrite your flake:

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    nixpkgsMySQL57.url = "github:NixOS/nixpkgs/611bf8f183e6360c2a215fa70dfd659943a9857f";
    # phps.url = "github:thelissimus/nix-phps"; # my fork where I replaced the sha256
    phps.url = "github:fossar/nix-phps/58efd805e85ee2b0f332c3e4caaa19786de2f20e"; # this repo before merging my fork
    devenv.url = "github:cachix/devenv/v0.6.3";
    systems.url = "github:nix-systems/default";
  };

  outputs = inputs @ { self, flake-parts, ... }: flake-parts.lib.mkFlake { inherit inputs; }
    {
      systems = import inputs.systems;

      perSystem = { config, self', inputs', pkgs, system, lib, ... }:
        let
          pkgsMySQL57 = import inputs.nixpkgsMySQL57 { inherit system; };
        in
        {
          _module.args.pkgs = import self.inputs.nixpkgs {
            inherit system;
            overlays = [
              inputs.phps.overlays.default
            ];
            config = {
              allowUnfree = true;
            };
          };

          devShells.default = inputs.devenv.lib.mkShell {
            inherit inputs pkgs;

            modules = [{
              packages = [
                pkgs.php73
                pkgs.php73.packages.composer
                pkgsMySQL57.mysql57
              ];

              services.mysql = {
                enable = true;
              };
            }];
          };
        };
    };
}

@thelissimus
Copy link
Contributor Author

thelissimus commented Nov 3, 2023

Thanks for your effort! But your new flake is producing the same error:

• Added input 'flake-parts':
    'github:hercules-ci/flake-parts/8c9fa2545007b49a5db5f650ae91f227672c3877' (2023-11-01)
• Added input 'flake-parts/nixpkgs-lib':
    'github:NixOS/nixpkgs/0cbe9f69c234a7700596e943bfae7ef27a31b735?dir=lib' (2023-10-29)
• Removed input 'flake-utils'
• Removed input 'flake-utils/systems'
• Updated input 'phps':
    'github:fossar/nix-phps/3d8344ff2de44bfc2d3fb143e0d7b96c96bd0577' (2023-11-03)
  → 'github:fossar/nix-phps/58efd805e85ee2b0f332c3e4caaa19786de2f20e' (2023-10-29)
• Added input 'systems':
    'github:nix-systems/default/da67096a3b9bf56a91d16901293e51ba5b49a27e' (2023-04-09)
warning: Git tree '/home/gicw/code' is dirty
error: hash mismatch in fixed-output derivation '/nix/store/cbw81xmg63889yvk52zmnwicqlzk9gq0-d016434ad33284dfaceb8d233351d34356566d7d.patch.drv':
         specified: sha256-x0vEcoXNFeQi3re1TrK/Np9AH5dy3wf95xM08xCyGE0=
            got:    sha256-Th1ZhC8t84MACxosoYud1LGDd5DtYe36Ctk1Ocjcu1s=
error: 1 dependencies of derivation '/nix/store/yxa5yj0f5xiz0614h9bnrf01y5zswfzi-php-7.3.33.drv' failed to build
error: 1 dependencies of derivation '/nix/store/qqkwr3zph3achkkwl8zh7xfvb3gcpj82-php-with-extensions-7.3.33.drv' failed to build
error: 1 dependencies of derivation '/nix/store/9khycqnlnrdl929bbzmabnc3zmypqxc3-devenv-profile.drv' failed to build
error: 1 dependencies of derivation '/nix/store/byjk8rqlw8b396k8a4p1jgl89nr8gj1c-devenv-shell-env.drv' failed to build

Also, it is now tested on MacOS Sonoma 14.1. My fork with new sha256 works:
photo_2023-11-03_18-18-35

It really is strange, considering I re-installed my whole operating system. I don't have any idea how the error still persists with the original sha256.

@thelissimus
Copy link
Contributor Author

I evaluated the flake on a whole another machine, where I never ran --impure even once. Still the same error with hash mismatch:

error: hash mismatch in fixed-output derivation '/nix/store/cbw81xmg63889yvk52zmnwicqlzk9gq0-d016434ad33284dfaceb8d233351d34356566d7d.patch.drv':
         specified: sha256-x0vEcoXNFeQi3re1TrK/Np9AH5dy3wf95xM08xCyGE0=
            got:    sha256-Th1ZhC8t84MACxosoYud1LGDd5DtYe36Ctk1Ocjcu1s=
error: 1 dependencies of derivation '/nix/store/yxa5yj0f5xiz0614h9bnrf01y5zswfzi-php-7.3.33.drv' failed to build
error: 1 dependencies of derivation '/nix/store/qqkwr3zph3achkkwl8zh7xfvb3gcpj82-php-with-extensions-7.3.33.drv' failed to build
error: 1 dependencies of derivation '/nix/store/lisicqg2arq8h7pxpqs2v1m5r0r5yf0h-nix-shell-env.drv' failed to build

@drupol
Copy link
Collaborator

drupol commented Nov 3, 2023

Which kind of machine, a mac ?

@jtojnar
Copy link
Member

jtojnar commented Nov 3, 2023

I am getting the same hash locally:

nix-repl> :b (pkgs.fetchpatch2 {
          url = "https://github.com/php/php-src/commit/d016434ad33284dfaceb8d233351d34356566d7d.patch";
          sha256 = "";
          includes = [
            "build/libtool.m4"
          ];
          })
warning: found empty hash, assuming 'sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA='
error: hash mismatch in fixed-output derivation '/nix/store/6q64kgyqnidkham4m3fsgs7rb32sb0iy-d016434ad33284dfaceb8d233351d34356566d7d.patch.drv':
         specified: sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
            got:    sha256-Th1ZhC8t84MACxosoYud1LGDd5DtYe36Ctk1Ocjcu1s=

Since I have the old derivation as well, I can just look at the outputs:

nix-repl> :b (pkgs.fetchpatch2 {
          url = "https://github.com/php/php-src/commit/d016434ad33284dfaceb8d233351d34356566d7d.patch";
          sha256 = "sha256-x0vEcoXNFeQi3re1TrK/Np9AH5dy3wf95xM08xCyGE0=";
          includes = [
            "build/libtool.m4"
          ];
          })

This derivation produced the following outputs:
  out -> /nix/store/ma5w6zj827xb862j6lkzl4c6hnin3xhy-d016434ad33284dfaceb8d233351d34356566d7d.patch

nix-repl> :b (pkgs.fetchpatch2 {
          url = "https://github.com/php/php-src/commit/d016434ad33284dfaceb8d233351d34356566d7d.patch";
          sha256 = "sha256-Th1ZhC8t84MACxosoYud1LGDd5DtYe36Ctk1Ocjcu1s=";
          includes = [
            "build/libtool.m4"
          ];
          })

This derivation produced the following outputs:
  out -> /nix/store/20v370iygvj45vw0k46dnr56fdalbvy7-d016434ad33284dfaceb8d233351d34356566d7d.patch

Looks like fetchpatch2 is not really stable with regards to git hash length:

$ diff -u /nix/store/ma5w6zj827xb862j6lkzl4c6hnin3xhy-d016434ad33284dfaceb8d233351d34356566d7d.patch /nix/store/20v370iygvj45vw0k46dnr56fdalbvy7-d016434ad33284dfaceb8d233351d34356566d7d.patch
--- /nix/store/ma5w6zj827xb862j6lkzl4c6hnin3xhy-d016434ad33284dfaceb8d233351d34356566d7d.patch	1970-01-01 01:00:01.000000000 +0100
+++ /nix/store/20v370iygvj45vw0k46dnr56fdalbvy7-d016434ad33284dfaceb8d233351d34356566d7d.patch	1970-01-01 01:00:01.000000000 +0100
@@ -1,5 +1,5 @@
 diff --git a/build/libtool.m4 b/build/libtool.m4
-index 099a8799352c..1faed63a8c60 100644
+index 099a8799352ce..1faed63a8c60a 100644
 --- a/build/libtool.m4
 +++ b/build/libtool.m4
 @@ -340,7 +340,7 @@

We should probably switch back to fetchpatch, which removes the Git specific headers.

@drupol
Copy link
Collaborator

drupol commented Nov 4, 2023

Thanks @jtojnar. I opened a new PR to use fetchpatch at #307

@thelissimus
Copy link
Contributor Author

thelissimus commented Nov 4, 2023

Which kind of machine, a mac ?

No, a Lenovo laptop running NixOS 23.05. Anyways, thank you all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong sha256 hash for php73 libtool patch
3 participants