SymfonyCasts / sass-bundle

Delightful Sass Support for Symfony + AssetMapper
https://symfony.com/bundles/SassBundle/current/index.html
MIT License
37 stars 18 forks source link

Proposal to improve SASS binary handling #75

Closed drupol closed 1 month ago

drupol commented 1 month ago

Hello,

Today, I attempted to build a new instance of the Symfony demo on NixOS, and you can find the log here: https://gist.github.com/drupol/31f96f358e9d35e1095f0ba5dd92c056.

Downloading and attempting to run a binary on NixOS will almost never work. This is due to hard-coded paths in the executable. (source: https://wiki.nixos.org/wiki/Packaging/Binaries)

Why fixing this matters:

  1. To improve hermetic builds: by addressing this issue, we can enhance the isolation of builds for Symfony applications using this bundle. Since the builds should run in a fully isolated environment (no network access), we need a way to provide the SASS binary as a pre-requisite and avoid the build system downloading it.
  2. dependency clarity: this will also ensure we know exactly which dependencies the build system requires upfront, making the build process more predictable and maintainable.
  3. offline builds: making sure that "offline" builds of a Symfony app using this bundle will work

Proposed fix

To address this, I suggest modifying the behaviour of SassBuilder. Instead of downloading the SASS binary at build-time, it should first check if the binary is already available in the current system's path. If it finds the binary, it should use that, and only download the file if it is not found.

The current flow looks like this:

flowchart TD
    A[Find SASS Binary]
    A --> E[Download the file using the existing procedure]

I propose updating it to the following:

flowchart TD
    A[Find SASS Binary]
    A --> C{Is the SASS binary available in the system path?}
    C -->|Yes| D[Return the path to the binary]
    C -->|No| E[Download the file using the existing procedure]

This change would prevent unnecessary downloads and make the build process smoother on systems like NixOS and Guix.

Let me know what you think of the idea.