uuid: - value: 8c51f0d1-d7d3-4089-91bc-43b1f896f844 langcode: - value: en type: - target_id: daily_email target_type: node_type target_uuid: 8bde1f2f-eef9-4f2d-ae9c-96921f8193d7 revision_timestamp: - value: '2025-06-27T20:53:21+00:00' revision_uid: - target_type: user target_uuid: b8966985-d4b2-42a7-a319-2e94ccfbb849 revision_log: { } status: - value: true uid: - target_type: user target_uuid: b8966985-d4b2-42a7-a319-2e94ccfbb849 title: - value: 'Project-specific dependencies with Nix Flakes' created: - value: '2025-06-26T20:07:18+00:00' changed: - value: '2025-06-27T20:53:21+00:00' promote: - value: false sticky: - value: false default_langcode: - value: true revision_translation_affected: - value: true path: - alias: /daily/2025/06/26/project-specific-dependencies-nix-flakes langcode: en body: - value: |- Earlier this week, I wrote about [using Nix to manage different versions of PHP][1]. PHP 8.4, 8.3, 8.2 and 8.1 are all available in the current stable version of nixpkgs. You can only have one version installed globally, but you can have specific versions enabled for different projects. You can create a `shell.nix` file or a Nix Flake like [yesterday's example][0] in each project directory and add or override the version of PHP or any other packages as needed. Each directory can have its own set of installed packages and configuration, and this works for everything in nixpkgs. Because flakes can have multiple inputs, including multiple versions of nixpkgs, you can mix and match between stable, unstable or pinned versions in the same flake.nix and decide which to use for each project. This provides a lot of flexibility and offers a lot of customisation so you can configure each project exactly how you need. For some examples of flake.nix files I've used, see [my public repositories][2] on my Forgejo instance. [0]: /daily/2025/06/25/nix-and-older-versions-php [1]: /daily/2025/06/24/php-and-nix-shells [2]: https://code.oliverdavies.uk/opdavies format: markdown processed: |

Earlier this week, I wrote about using Nix to manage different versions of PHP.

PHP 8.4, 8.3, 8.2 and 8.1 are all available in the current stable version of nixpkgs.

You can only have one version installed globally, but you can have specific versions enabled for different projects.

You can create a shell.nix file or a Nix Flake like yesterday's example in each project directory and add or override the version of PHP or any other packages as needed.

Each directory can have its own set of installed packages and configuration, and this works for everything in nixpkgs.

Because flakes can have multiple inputs, including multiple versions of nixpkgs, you can mix and match between stable, unstable or pinned versions in the same flake.nix and decide which to use for each project.

This provides a lot of flexibility and offers a lot of customisation so you can configure each project exactly how you need.

For some examples of flake.nix files I've used, see my public repositories on my Forgejo instance.

summary: '' field_daily_email_cta: - target_type: node target_uuid: 9b4c39a3-702f-486c-a79b-4d7b96a4f3f6