Can't apply a patch

I’m trying to create this derivation [package request] Seahorse Nautilus extension · Issue #189671 · NixOS/nixpkgs · GitHub

but the patch I created doesn’t do anything
here is the derivation and the patch

{ meson, python3, gtk3, gnupg, cmake, pkg-config, gnome, libcryptui, gcr, libnotify, gpgme, ninja, stdenv, fetchgit, lib }:
stdenv.mkDerivation rec {
  name = "seahorse-nautilus";
  version = "master";

  src = fetchgit {
    url = "https://gitlab.gnome.org/GNOME/seahorse-nautilus.git";
    sha256 = "sha256-n5Q6ciE/3o0FYraweZWDY5suvwG+SXU1pU05VxA68Ls=";
  };

  nativeBuildInputs = [
    meson
    python3
    cmake
    pkg-config
    ninja
  ];

  buildInputs = [
    gtk3.dev
    gnupg
    gnome.nautilus.dev
    libcryptui
    gcr
    libnotify
    gpgme
  ];

  patches = [ ./gpg-version.patch ];

#  configurePhase = ''
#    cat $src/meson/gpg_check_version.py
#    meson build --prefix $out -D nautilus-ext-dir=$out/lib/nautilus/extensions-4
#  '';

  mesonFlags = [
    "-D nautilus-ext-dir=${placeholder "out"}/lib/nautilus/extensions-4"
  ];

#  buildPhase = ''
#    ninja -C build
#  '';

#  installPhase = ''
#    ninja -C build install
#  '';

  meta = with lib; {
    description = "An extension for Nautilus (also known as Files) which allows encryption and decryption of OpenPGP files using GnuPG.";
    homepage = "https://gitlab.gnome.org/GNOME/seahorse-nautilus";
    license = licenses.gpl2;
    platforms = platforms.linux;
    maintainers = teams.gnome.members;
  };
}
diff --git a/meson/gpg_check_version.py b/meson/gpg_check_version.py
index 4f1ccaf..0b752d5 100755
--- a/meson/gpg_check_version.py
+++ b/meson/gpg_check_version.py
@@ -13,6 +13,7 @@ def parse_version(gpg_output):
 # For GPG, this means that the major and minor version should be equal;
 # for GPGME, this means only the major version should be equal.
 def check_version(gpg_version, accepted_version, is_gpgme = False):
+    gpg_version = gpg_version.split('-')[0]
     gpg_major, gpg_minor, gpg_micro = [int(ver) for ver in gpg_version.split('.', 2)]
     acc_major, acc_minor, acc_micro = [int(ver) for ver in accepted_version.split('.', 2)]
     if is_gpgme:

What do you mean does not do anything?

If you get a “file not found” error, it likely means you need to patch the shebang by adding:

  nativeBuildInputs = [
    python3
  ];

  postPatch = ''
    patchShebangs \
      meson/gpg_check_version.py
  '';

try to run it yourself

What exactly do you want us to run?

nix-shell -p ‘with import {}; callPackage ./default.nix {}’

Building your inital code failed with an error (which is always nice to know before hand what the error is!):

meson.build:56:2: ERROR: Could not execute command "/build/seahorse-nautilus/meson/gpg_check_version.py /nix/store/gpsmzjn3g5kny90j2gg6n3a0my5j9cgv-gnupg-2.3.7/bin/gpg2 false 1.2.0 1.4.0 2.0.0 2.1.0 2.2.0 2.3.0".

So I cloned the nautilus repo and tried to run the command myself.

There I saw this:

$ meson/gpg_check_version.py /nix/store/gpsmzjn3g5kny90j2gg6n3a0my5j9cgv-gnupg-2.3.7/bin/gpg2 false 1.2.0 1.4.0 2.0.0 2.1.0 2.2.0 2.3.0
/usr/bin/env: ‘python3’: No such file or directory
$ head -1 meson/gpg_check_version.py
#!/usr/bin/env python3

So I would assume that Jans suggestion would work.

And guess what! It successfully produced a build output!

You already ran the code and have the error message so you might as well paste it here.

Requiring people helping you to create two new files, copy and paste their contents, run a command and then clean it up, just to get output you already have is not an efficient use of anyone’s time.

2 Likes

I didn’t mean to waste your time, I’m sorry about that.

Thanks @jtojnar and @NobbZ for helping.

Your solution @jtojnar helped alot

2 Likes