Merge pull request #266455 from 06kellyjac/authelia_update_fixes

authelia: fix update script

authored by Mario Rodas and committed by GitHub 3da53eb0 596e6a54

+20 -29
-13
pkgs/servers/authelia/change-web-out-dir.patch
··· 1 - diff --git a/vite.config.ts b/vite.config.ts 2 - index 659ba3e1..1f0afa5c 100644 3 - --- a/vite.config.ts 4 - +++ b/vite.config.ts 5 - @@ -37,7 +37,7 @@ export default defineConfig(({ mode }) => { 6 - base: "./", 7 - build: { 8 - sourcemap, 9 - - outDir: "../internal/server/public_html", 10 - + outDir: "dist", 11 - emptyOutDir: true, 12 - assetsDir: "static", 13 - rollupOptions: {
+18 -12
pkgs/servers/authelia/update.sh
··· 10 10 instantiateClean() { 11 11 nix-instantiate --eval --strict -E "with import ./. {}; $1" | cut -d\" -f2 12 12 } 13 - fetchNewSha() { 13 + fetchNewHash() { 14 14 set +eo pipefail 15 - nix-build -A "$1" 2>&1 >/dev/null | grep "got:" | cut -d':' -f2 | sed 's| ||g' 15 + HASH="$(nix-build -A "$1" 2>&1 >/dev/null | grep "got:" | cut -d':' -f2 | sed 's| ||g')" 16 16 set -eo pipefail 17 + if [ -z "$HASH" ]; then 18 + echo "Could not generate hash" >&2 19 + exit 1 20 + else 21 + echo "$HASH" 22 + fi 17 23 } 18 24 replace() { 19 25 sed -i "s@$1@$2@g" "$3" ··· 49 55 OLD_SRC_HASH="$(instantiateClean authelia.src.outputHash)" 50 56 echo "Old src hash $OLD_SRC_HASH" 51 57 replace "$OLD_SRC_HASH" "$TMP_HASH" "$DRV_DIR/sources.nix" 52 - NEW_SRC_HASH="$(fetchNewSha authelia.src)" 58 + NEW_SRC_HASH="$(fetchNewHash authelia.src)" 53 59 echo "New src hash $NEW_SRC_HASH" 54 60 replace "$TMP_HASH" "$NEW_SRC_HASH" "$DRV_DIR/sources.nix" 55 61 ··· 61 67 } 62 68 trap clean_up EXIT 63 69 64 - # OLD_PWD=$PWD 65 - # cd $WEB_DIR 66 - # OUT=$(nix-build -E "with import $NIXPKGS_ROOT {}; authelia.src" --no-out-link) 67 - # cp -r $OUT/web/package.json . 68 - # npm install --package-lock-only --legacy-peer-deps --ignore-scripts 69 - # mv package-lock.json "$DRV_DIR/" 70 + OLD_PWD=$PWD 71 + cd $WEB_DIR 72 + OUT=$(nix-build -E "with import $NIXPKGS_ROOT {}; authelia.src" --no-out-link) 73 + cp -r $OUT/web/package.json . 74 + npm install --package-lock-only --legacy-peer-deps --ignore-scripts 75 + mv package-lock.json "$DRV_DIR/" 76 + cd $OLD_PWD 70 77 71 - # cd $OLD_PWD 72 78 OLD_NPM_DEPS_HASH="$(instantiateClean authelia.web.npmDepsHash)" 73 79 echo "Old npm deps hash $OLD_NPM_DEPS_HASH" 74 80 replace "$OLD_NPM_DEPS_HASH" "$TMP_HASH" "$DRV_DIR/sources.nix" 75 - NEW_NPM_DEPS_HASH="$(fetchNewSha authelia.web)" 81 + NEW_NPM_DEPS_HASH="$(fetchNewHash authelia.web)" 76 82 echo "New npm deps hash $NEW_NPM_DEPS_HASH" 77 83 replace "$TMP_HASH" "$NEW_NPM_DEPS_HASH" "$DRV_DIR/sources.nix" 78 84 clean_up ··· 80 86 OLD_GO_VENDOR_HASH="$(instantiateClean authelia.vendorHash)" 81 87 echo "Old go vendor hash $OLD_GO_VENDOR_HASH" 82 88 replace "$OLD_GO_VENDOR_HASH" "$TMP_HASH" "$DRV_DIR/sources.nix" 83 - NEW_GO_VENDOR_HASH="$(fetchNewSha authelia.goModules)" 89 + NEW_GO_VENDOR_HASH="$(fetchNewHash authelia.goModules)" 84 90 echo "New go vendor hash $NEW_GO_VENDOR_HASH" 85 91 replace "$TMP_HASH" "$NEW_GO_VENDOR_HASH" "$DRV_DIR/sources.nix"
+2 -4
pkgs/servers/authelia/web.nix
··· 9 9 10 10 sourceRoot = "${src.name}/web"; 11 11 12 - patches = [ 13 - ./change-web-out-dir.patch 14 - ]; 15 - 16 12 postPatch = '' 13 + substituteInPlace ./vite.config.ts \ 14 + --replace 'outDir: "../internal/server/public_html"' 'outDir: "dist"' 17 15 cp ${./package-lock.json} ./package-lock.json 18 16 ''; 19 17