···22, stdenv
33, fetchurl
44, makeWrapper
55-, jre8 }: # TODO: Update this to the latest version of java upon the next release. This is currently not done because of https://github.com/toolbox4minecraft/amidst/issues/960
55+, jre }:
6677stdenv.mkDerivation rec {
88 pname = "amidst";
···15151616 dontUnpack = true;
17171818- nativeBuildInputs = [ jre8 makeWrapper ];
1818+ nativeBuildInputs = [ jre makeWrapper ];
19192020 installPhase = ''
2121 mkdir -p $out/{bin,lib/amidst}
2222 cp $src $out/lib/amidst/amidst.jar
2323- makeWrapper ${jre8}/bin/java $out/bin/amidst \
2323+ makeWrapper ${jre}/bin/java $out/bin/amidst \
2424 --add-flags "-jar $out/lib/amidst/amidst.jar"
2525 '';
2626
+5
pkgs/tools/misc/esphome/default.nix
···2121 sha256 = "0bz6gkrvn7mwmjsqrazgpy9r64m5jj462v0izgvdymkx8bjd8mpi";
2222 };
23232424+ patches = [
2525+ # fix missing write permissions on src files before modifing them
2626+ ./fix-src-permissions.patch
2727+ ];
2828+2429 postPatch = ''
2530 # remove all version pinning (E.g tornado==5.1.1 -> tornado)
2631 sed -i -e "s/==[0-9.]*//" requirements.txt
+46
pkgs/tools/misc/esphome/fix-src-permissions.patch
···11+From f72c5035944065941daaa236b60664657c777726 Mon Sep 17 00:00:00 2001
22+From: Martin Weinelt <hexa@darmstadt.ccc.de>
33+Date: Wed, 23 Jun 2021 04:50:35 +0200
44+Subject: [PATCH] Set u+w for copied src files before trying to overwrite them
55+MIME-Version: 1.0
66+Content-Type: text/plain; charset=UTF-8
77+Content-Transfer-Encoding: 8bit
88+99+We store esphome in the nix store, which results in its file permissions
1010+being 0444. Esphome, when compiling a firmware image, will copy these
1111+files from the nix store to a working directory. When updating between
1212+versions it will notice these files changed and try to copy the new
1313+version over, which would break, because the user had no write
1414+permissions on the files.
1515+1616+❯ esphome compile 01e4ac.yml
1717+INFO Reading configuration 01e4ac.yml...
1818+INFO Detected timezone 'CET' with UTC offset 1 and daylight saving time from 27 March 02:00:00 to 30 October 03:00:00
1919+INFO Generating C++ source...
2020+ERROR Error copying file /nix/store/lmzrgl1arqfd98jcss4rsmmy6dbffddn-esphome-1.19.2/lib/python3.8/site-packages/esphome/components/api/api_connection.cpp to 01e4ac/src/esphome/components/api/api_connection.cpp: [Errno 13] Permission denied: '01e4ac/src/esphome/components/api/api_connection.cpp'
2121+2222+To fix this we modify chmod to 0644 just before esphome tries a copy
2323+operation, which will fix permissions on existing working directories
2424+just in time.
2525+---
2626+ esphome/helpers.py | 4 ++++
2727+ 1 file changed, 4 insertions(+)
2828+2929+diff --git a/esphome/helpers.py b/esphome/helpers.py
3030+index ad7b8272..c456f4ff 100644
3131+--- a/esphome/helpers.py
3232++++ b/esphome/helpers.py
3333+@@ -228,6 +228,10 @@ def copy_file_if_changed(src: os.PathLike, dst: os.PathLike) -> None:
3434+ if file_compare(src, dst):
3535+ return
3636+ mkdir_p(os.path.dirname(dst))
3737++ try:
3838++ os.chmod(dst, 0o644)
3939++ except OSError:
4040++ pass
4141+ try:
4242+ shutil.copy(src, dst)
4343+ except OSError as err:
4444+--
4545+2.31.1
4646+