diff --git a/Dockerfile b/Dockerfile index c191b58ff..0f1401787 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,6 +29,7 @@ RUN yarn build FROM base AS runner WORKDIR /app +# note: remember to make changes to the installPhase in flake.nix as well COPY --from=installer /app/apps/router/build build COPY scripts/replace-react-env.js scripts/replace-react-env.js COPY scripts/write-config-from-env.js scripts/write-config-from-env.js diff --git a/flake.lock b/flake.lock index d782ca84c..98b80fabe 100644 --- a/flake.lock +++ b/flake.lock @@ -119,17 +119,17 @@ "nixpkgs": "nixpkgs_4" }, "locked": { - "lastModified": 1727712199, - "narHash": "sha256-3Y95+vA64HaqodepPkwY159vIc6JES5oo9qPWLRF9es=", + "lastModified": 1727317398, + "narHash": "sha256-NUr1ZpYJozWIej46Oqlf/7feJ4kztYYvX3TEzQ5VoWo=", "owner": "fedimint", "repo": "fedimint", - "rev": "e8e3e6d84c223c3b90d7cf8d5fd5f346a7443e66", + "rev": "1813069d5d18a29f611a423990e8013a7331d2a2", "type": "github" }, "original": { "owner": "fedimint", + "ref": "refs/tags/v0.4.3", "repo": "fedimint", - "rev": "e8e3e6d84c223c3b90d7cf8d5fd5f346a7443e66", "type": "github" } }, diff --git a/flake.nix b/flake.nix index 9c279492b..d3fe3c576 100644 --- a/flake.nix +++ b/flake.nix @@ -1,11 +1,8 @@ { inputs = { flake-utils.url = "github:numtide/flake-utils"; - fedimint = { - # master on 09/30/2024 - url = - "github:fedimint/fedimint?rev=e8e3e6d84c223c3b90d7cf8d5fd5f346a7443e66"; - }; + fedimint.url = + "github:fedimint/fedimint?ref=refs/tags/v0.4.3"; }; outputs = { self, flake-utils, fedimint }: flake-utils.lib.eachDefaultSystem (system: @@ -17,11 +14,24 @@ }; fmLib = fedimint.lib.${system}; + + # When `yarn.lock` changes, follow these steps to update the `sha256` hash: + # 1. Remove the existing `sha256` hash.* + # 2. Rebuild the Nix derivation** by executing: + # nix build .#guardian-ui + # 3. Obtain the new `sha256` hash** from the build error message. + # 4. Update the `sha256` value** below with the newly copied hash. + # + # **Important:** + # Keeping the `sha256` hash in sync with `yarn.lock` is essential. An outdated or incorrect hash + # will cause the Nix package to become out-of-sync with Yarn dependencies, potentially leading + # to build failures or inconsistent behavior. yarnOfflineCache = pkgs.fetchYarnDeps { yarnLock = ./yarn.lock; - hash = "sha256-lJcqjTwC5C+4rvug6RYg8Ees4SzNTD+HazfACz1EaSQ="; + hash = "sha256-a1YeZYvxstAqDCgK2qrlylkKYhIX1Xo28tCKt46hxrE="; }; - in { + in + { devShells = fmLib.devShells // { default = fmLib.devShells.default.overrideAttrs (prev: { nativeBuildInputs = [ @@ -40,12 +50,13 @@ packages.guardian-ui = pkgs.stdenv.mkDerivation { pname = "guardian-ui"; - version = "0.3.0"; + version = "0.4.3"; src = ./.; nativeBuildInputs = with pkgs; [ nodejs yarn + cacert yarn2nix-moretea.fixup_yarn_lock ]; @@ -53,6 +64,14 @@ export HOME=$(mktemp -d) ''; + # NixOS is introducing `yarnBuildHook`, `yarnConfigHook`, and `yarnInstallHook`, + # which could simplify the current complex `buildPhase` that uses `fixup_yarn_lock` + # and the `installPhase`. + # 1. [JavaScript Frameworks Documentation](https://github.com/NixOS/nixpkgs/blob/ab4dc6ca78809a367aba6fb2813a15116560e2a9/doc/languages-frameworks/javascript.section.md) + # 2. [Nixpkgs Issue #324246](https://github.com/NixOS/nixpkgs/issues/324246) + # + # Additionally, avoid using `pkgs.mkYarnPackage` as it is slated for deprecation. + buildPhase = '' yarn config --offline set yarn-offline-mirror ${yarnOfflineCache} fixup_yarn_lock yarn.lock @@ -62,12 +81,16 @@ --ignore-engines --ignore-scripts patchShebangs . - yarn build:guardian-ui + yarn build ''; + # should be similar to the installer in the Dockerfile installPhase = '' - mkdir -p $out - cp -R apps/guardian-ui/build/* $out + mkdir -p $out/scripts + + cp -r apps/router/build/* $out/ + cp -r scripts/replace-react-env.js $out/scripts/replace-react-env.js + cp -r scripts/write-config-from-env.js $out/scripts/write-config-from-env.js ''; }; });