From e948ab092cdca47d96053b13cffa4df8da3a9295 Mon Sep 17 00:00:00 2001 From: Samuel Grayson Date: Wed, 27 Mar 2024 00:33:54 -0500 Subject: [PATCH] Automate patching composer-env.nix --- pkgs/composer-env.nix | 2 +- pkgs/update.sh | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/pkgs/composer-env.nix b/pkgs/composer-env.nix index 2c646421a..99bf00e0b 100644 --- a/pkgs/composer-env.nix +++ b/pkgs/composer-env.nix @@ -190,7 +190,7 @@ let ${lib.optionalString (!noDev) (bundleDependencies devPackages)} cd .. - echo "APP_KEY=SomeRandomStringOf32CharsExactly" > .env + echo 'APP_KEY=SomeRandomStringOf32CharsExactly' > .env # Reconstruct autoload scripts # We use the optimize feature because Nix packages cannot change after they have been built diff --git a/pkgs/update.sh b/pkgs/update.sh index 0498af36e..601f4a558 100755 --- a/pkgs/update.sh +++ b/pkgs/update.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +set -x + # See http://mywiki.wooledge.org/BashFAQ/028 if [[ $BASH_SOURCE = */* ]]; then pushd -- "${BASH_SOURCE%/*}/" || exit @@ -36,11 +38,20 @@ composer2nix --name "firefly-iii" \ --composition=composition.nix rm composer.json composer.lock +# Understanding that this comment is a design detail of composer2nix, the code +# should be robust to the case where the comment is not present. +sed_str="s:# Reconstruct autoload scripts:echo 'APP_KEY=SomeRandomStringOf32CharsExactly' > .env\\n\\n # Reconstruct autoload scripts:" +if sed -i "${sed_str}" composer-env.nix; then + echo "Patched composer-env.nix successfully" +else + echo "Could not patch composer-env.nix. It is possible you will get an error related to APP_KEY." +fi + # Update the version number in flake.nix sed -i "s:firefly-iii/firefly-iii/v\?\([0-9]\+\.\?\)\{3\}:firefly-iii/firefly-iii/${latest_version}:" ../flake.nix nix fmt # Check if the update worked by attempting a build. -nix build .#firefly-iii +nix build .#firefly-iii --print-build-logs nix flake check exit $?