Updates for unified.diff

This commit is contained in:
Oliver Davies 2025-09-25 18:00:00 +01:00
parent b2803aac2d
commit bfb67e4010

View file

@ -19,7 +19,7 @@ section {
}
h1 {
ont-size: 2rem;
font-size: 2rem;
}
</style>
@ -36,17 +36,48 @@ https://www.oliverdavies.uk
---
<style scoped>
section {
place-content: center;
}
h1 {
font-size: 2rem;
}
</style>
# Nix for ~~PHP Developers~~ everyone
<br>
<br>
Oliver Davies (opdavies)
https://www.oliverdavies.uk
<!--
PHP examples, but apply to other languages.
Replace PHP with your language of choice
-->
<!-- _paginate: false -->
---
# About Me
- PHP since 2007.
- Drupal since 2008.
- Full-time Linux since ~2015.
- Nix/NixOS since 2022.
- PHP since 2007
- Drupal since 2008
- Full-time Linux since ~2015
- Nix/NixOS since 2022
- Gave my first presentation at unified.diff in September 2012
<!--
PHP and Drupal Development. Linux-based infrastructure and systems administration. Automation.
Vagrant, Puppet, Ansible.
This is talk #107
-->
---
@ -153,6 +184,15 @@ Ecosystem of tools. Home Manager for user home configuration, nix-darwin for man
---
# What is Nix?
- Package manager
- Build tool
- Operating system
- Language
---
![](./nix-search.png)
<!--
@ -257,31 +297,32 @@ $ which php
$ php -v
PHP 8.3.6 (cli) (built: Jul 14 2025 18:30:55)
PHP 8.3.6
```
<!--
One version of PHP installed globally.
-->
---
# Running PHP with Nix
```shell
$ nix run nixpkgs#php \
--extra-experimental-features 'nix-command flakes' \
-- -v
$ nix run nixpkgs#php -- -v
PHP 8.4.11 (cli) (built: Jul 29 2025 15:30:21)
PHP 8.4.11
```
```shell
$ nix shell nixpkgs#php \
--extra-experimental-features 'nix-command flakes'
$ nix shell nixpkgs#php
$ which php
/nix/store/s4kv9bzqawhqcyjg9xm2hji3jap6d6kd-php-with-extensions-8.4.11/bin/php
$ php -v
PHP 8.4.11 (cli) (built: Jul 29 2025 15:30:21)
PHP 8.4.11
```
<!--
@ -294,6 +335,24 @@ Arbitrary commands and ephemeral shells.
---
# Running PHP with Nix
```
$ nix run nixpkgs#php83 -- -v
PHP 8.3.25
```
<br>
```
$ nix run nixpkgs#php82 -- -v
PHP 8.2.29
```
---
# Using a `shell.nix` file
```nix
@ -412,7 +471,7 @@ inputs = {
```
<!--
You can have multiple versions of Nix installed at once.
You can have multiple versions of Nix and applications installed at once.
Pin to a stable version of nixpkgs or a specific commit.
@ -585,6 +644,12 @@ h1 {
# Nix is like `nvm`<br> for everything
<!--
If there are multiple versions in nixpkgs, like PHP, you can pick the version you need.
If needed you can pin nixpkgs to a specific version for that project.
-->
---
# My ideal environment
@ -598,13 +663,13 @@ $ cd ~/my-project
$ php -v
PHP 8.4.10 (cli) (built: Jul 2 2025 02:22:42)
PHP 8.4.10
$ cd ~/another-project
$ php -v
PHP 8.3.24 (cli) (built: Jul 29 2025 15:48:33)
PHP 8.3.24
```
---
@ -717,6 +782,10 @@ php.buildComposerProject2 (finalAttrs: {
# ...
```
<!--
Existing builders for PHP, node, Go, etc, and functions to download source code from GitHub, GitLab or any remote URL.
-->
---
# Packaging PHP for Nix
@ -763,7 +832,6 @@ nix build
└── index.md
```
<!--
---
# Building Nix packages
@ -787,7 +855,24 @@ This derivation produced the following outputs:
Phpactor 2025.03.28.0
```
-->
---
# Not sure?
Want to try it, but you're not sure?
<br>
```shell
$ docker run --rm -it nixos/nix
```
<br>
```shell
$ podman run --rm -it nixos/nix
```
---
@ -798,6 +883,5 @@ Phpactor 2025.03.28.0
- https://wiki.nixos.org/wiki/PHP
- https://nixos.org/manual/nixpkgs/stable/#ssec-building-php-projects
- https://code.oliverdavies.uk/opdavies/lab
- https://code.oliverdavies.uk/opdavies/drupal-nix-flake-example
- https://code.oliverdavies.uk/opdavies/nix-config (laptop and home server)
- https://books.oliverdavies.uk/nix-for-php-developers (book, in progress)