Initial commit

This commit is contained in:
Oliver Davies 2025-08-13 10:20:37 +01:00
commit 917011db7e
5 changed files with 198 additions and 0 deletions

15
README.md Normal file
View file

@ -0,0 +1,15 @@
# Nix for PHP Developers
## Legal
Copyright © 2025 Oliver Davies. All rights reserved.
The code portions of this book are dedicated to the public domain under the terms of the **Creative Commons Zero (CC0 1.0 Universal)** license (https://creativecommons.org/publicdomain/zero/1.0).
This means you are free to copy, modify, distribute the _code portions only_, even for commercial purposes, without asking permission, and without saying where you got them. This is so there is no fear your creations are your own after learning to code using them.
The non-code prose and images are licensed under the more restrictive Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License (CC BY-NC-ND 4.0) (https://creativecommons.org/licenses/by-nc-nd/4.0).
This means that no non-code prose or image from the book may be reproduced, distributed, or transmitted in any form or by any means, without the prior written permission of the copyright holder. This includes remaking the same content in different formats such as PDF or EPUB since these fall under the definition of derived works. This restriction is primarily in place to ensure outdated copies are not redistributed given the frequent updates expected.
_"Nix for PHP Developers"_ is a legal trademark of Oliver Davies but can be used freely to refer to this book without limitation. To avoid potential confusion, intentionally using this trademark to refer to other projects - free or proprietary - is prohibited.

157
book/index.adoc Normal file
View file

@ -0,0 +1,157 @@
[separator=::]
= Nix for PHP Developers
:author: Oliver Davies (opdavies)
:copyright: 2025 {author}
:creator: {author}
:description: How to use Nix as a PHP Developer.
:doctype: book
:email: oliver@oliverdavies.uk
// :front-cover-image: image:cover.png[width=1024,height=1024]
:icons: font
:keywords: php software-development nix linux
:leveloffset: +1
:pygments-linenums-mode: table
:pygments-style: vs
:revdate: {date}
:revnumber: v0.0.1
:revremark: Under development
:sectlinks:
:sectnums!:
:source-highlighter: pygments
:toc-title: Table of Contents
:toc: left
:toclevels: 2
:xrefstyle: short
include::introduction/index.adoc[]
[installing_php]
== Other ways to install PHP
////
apt, yum, pacman, etc. System package managers.
Homebrew on macOS and Linux.
Docker, podman, DDEV (containers).
Valet/Herd?
Symfony CLI.
Is there an "official" way on php.net?
////
[different_versions]
== Different versions of PHP for different projects
////
Virtual machines.
Vagrant.
Containers.
Valet/Herd. Symfony CLI.
IAC - Ansible, etc.
nvm for PHP?
"virtual" environments, aka. ruby, python.
Why do you need a full operating system?
Why use something specific to a particular framework?
////
[what_nix]
== What is Nix?
[nix_language]
=== The language
[nix_package_manager]
=== The package manager
[nix_build_tool]
=== The build tool
[nixos]
=== The operating system (NixOS)
[nix_benefits]
== What are the benefits of using Nix?
////
Lightweight.
Simpler - no need for Makefiles or helper scripts.
More native feel.
One tool to work with everything.
Different languages and frameworks.
Agnostic package manager, works on different Linux distros as well as macOS.
Lots of available packages and operating system options.
Ecosystem of tools - e.g. Home Manager.
////
=== Reproducible software, not just repeatable
=== Imperative vs. declarative
[dev_shells]
== What are dev shells?
[direnv]
== dev shells and direnv
Using a local flake:
[source,bash]
----
use flake .
----
=== Remote dev shells
Using a remote flake:
You can use a `flake.nix` flake in any Git repository, not just the directory you're in.
It can be in a different local directory or a remote Git repository.
For example, you can add this to use the `php84` dev shell within my dev-shells repository:
[source,bash]
----
use flake "git+https://code.oliverdavies.uk/opdavies/dev-shells#php84"
----
This will install PHP 8.4, Composer and Phpactor without needing to create a bespoke `flake.nix`.
[NOTE]
====
If you're referencing a GitHub repository, you can use the shorter `github:username/repo` format instead of the full repository URL.
====
[what_flakes]
== What are Flakes?
[flake_templates]
=== Flake templates
////
flake-utils
flake-parts
////
[configuring_php]
== Configuring PHP with Nix
[managing_services]
== Managing services without NixOS
[building_derivations]
== Building derivations of PHP applications
[nix_composer]
== Nix vs. Composer
////
composer2nix
////
== Other usages for Nix
////
Homelab/Server
////
== Organising Nix configurations

View file

@ -0,0 +1,9 @@
= About Oliver
Oliver Davies is a self-taught Software Developer based in the UK.
He learned to code in 2007 by building a website for a local Tae Kwon-Do School.
After developing the initial version with HTML and CSS, he learned PHP and MySQL in 2008 before adopting Drupal as his content management system of choice.

View file

@ -0,0 +1,14 @@
[copyright]
= Copyright
Copyright © {copyright}. All rights reserved.
The code portions of this book are dedicated to the public domain under the terms of the **Creative Commons Zero (CC0 1.0 Universal)** license (https://creativecommons.org/publicdomain/zero/1.0).
This means you are free to copy, modify, distribute the _code portions only_, even for commercial purposes, without asking permission, and without saying where you got them. This is so there is no fear your creations are your own after learning to code using them.
The non-code prose and images are licensed under the more restrictive Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License (CC BY-NC-ND 4.0) (https://creativecommons.org/licenses/by-nc-nd/4.0).
This means that no non-code prose or image from the book may be reproduced, distributed, or transmitted in any form or by any means, without the prior written permission of the copyright holder. This includes remaking the same content in different formats such as PDF or EPUB since these fall under the definition of derived works. This restriction is primarily in place to ensure outdated copies are not redistributed given the frequent updates expected.
_"Nix for PHP Developers"_ is a legal trademark of {author} but can be used freely to refer to this book without limitation. To avoid potential confusion, intentionally using this trademark to refer to other projects - free or proprietary - is prohibited.

View file

@ -0,0 +1,3 @@
include::copyright.adoc[]
include::about-me.adoc[]