110 lines
4.2 KiB
YAML
110 lines
4.2 KiB
YAML
uuid:
|
|
- value: ec55d813-d412-4cfd-8ca1-1b3a7ac5ac3d
|
|
langcode:
|
|
- value: en
|
|
type:
|
|
- target_id: daily_email
|
|
target_type: node_type
|
|
target_uuid: 8bde1f2f-eef9-4f2d-ae9c-96921f8193d7
|
|
revision_timestamp:
|
|
- value: '2025-06-27T09:43:46+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: 'Nix and older versions of PHP'
|
|
created:
|
|
- value: '2025-06-25T09:33:51+00:00'
|
|
changed:
|
|
- value: '2025-06-27T09:43:46+00:00'
|
|
promote:
|
|
- value: false
|
|
sticky:
|
|
- value: false
|
|
default_langcode:
|
|
- value: true
|
|
revision_translation_affected:
|
|
- value: true
|
|
path:
|
|
- alias: /daily/2025/06/25/nix-and-older-versions-php
|
|
langcode: en
|
|
body:
|
|
- value: |-
|
|
Yesterday, I wrote about [using Nix to create shells for different versions of PHP][1].
|
|
|
|
The current stable version of Nix has PHP 8.4.8, 8.3.22, 8.2.28 and 8.1.32, but what if you need an older version?
|
|
|
|
If it has been in nixpkgs previously, it can still be accessed.
|
|
|
|
Nix allows you to create different channels to install different versions of the nixpkgs repository and access different sets of packages.
|
|
|
|
With flakes, different versions of nixpkgs can be used as inputs to add multiple releases, such as [stable and unstable][0], or older releases or even a specific Git commit.
|
|
|
|
For example, if I needed to use PHP 7.4 - which is not available in the current release - I could use this flake.nix file:
|
|
|
|
```nix
|
|
{
|
|
inputs = {
|
|
nixpkgs-php74.url = "github:nixos/nixpkgs/81b77fd3847a";
|
|
};
|
|
|
|
outputs = { nixpkgs-php74, ... }:
|
|
let
|
|
system = "x86_64-linux";
|
|
pkgs = import nixpkgs-php74 { inherit system; };
|
|
in {
|
|
devShells.${system}.default = pkgs.mkShell {
|
|
packages = [
|
|
pkgs.php74
|
|
];
|
|
};
|
|
};
|
|
}
|
|
```
|
|
|
|
Pinning nixpkgs to that commit hash gives me access to `php74`, which I can access using `nix develop`.
|
|
|
|
This approach works with any package in nixpkgs - not just PHP.
|
|
|
|
Or, if it wasn't available in an older version of nixpkgs, I can write a custom derivation and add it myself.
|
|
|
|
[0]: /daily/2025/05/25/why-i-prefer-rolling-linux-distribution
|
|
[1]: /daily/2025/06/24/php-and-nix-shells
|
|
format: markdown
|
|
processed: |
|
|
<p>Yesterday, I wrote about <a href="/daily/2025/06/24/php-and-nix-shells">using Nix to create shells for different versions of PHP</a>.</p>
|
|
<p>The current stable version of Nix has PHP 8.4.8, 8.3.22, 8.2.28 and 8.1.32, but what if you need an older version?</p>
|
|
<p>If it has been in nixpkgs previously, it can still be accessed.</p>
|
|
<p>Nix allows you to create different channels to install different versions of the nixpkgs repository and access different sets of packages.</p>
|
|
<p>With flakes, different versions of nixpkgs can be used as inputs to add multiple releases, such as <a href="/daily/2025/05/25/why-i-prefer-rolling-linux-distribution">stable and unstable</a>, or older releases or even a specific Git commit.</p>
|
|
<p>For example, if I needed to use PHP 7.4 - which is not available in the current release - I could use this flake.nix file:</p>
|
|
<pre><code>{
|
|
inputs = {
|
|
nixpkgs-php74.url = "github:nixos/nixpkgs/81b77fd3847a";
|
|
};
|
|
|
|
outputs = { nixpkgs-php74, ... }:
|
|
let
|
|
system = "x86_64-linux";
|
|
pkgs = import nixpkgs-php74 { inherit system; };
|
|
in {
|
|
devShells.${system}.default = pkgs.mkShell {
|
|
packages = [
|
|
pkgs.php74
|
|
];
|
|
};
|
|
};
|
|
}
|
|
</code></pre><p>Pinning nixpkgs to that commit hash gives me access to <code>php74</code>, which I can access using <code>nix develop</code>.</p>
|
|
<p>This approach works with any package in nixpkgs - not just PHP.</p>
|
|
<p>Or, if it wasn't available in an older version of nixpkgs, I can write a custom derivation and add it myself.</p>
|
|
summary: ''
|
|
field_daily_email_cta:
|
|
- target_type: node
|
|
target_uuid: 20cde1b4-efdc-46a4-a6a4-4fd2264f617e
|