wip
This commit is contained in:
parent
63bf55b978
commit
8b18e05fbc
25 changed files with 1042 additions and 1 deletions
71
working-without-workspace/sections/build-configs.rst
Normal file
71
working-without-workspace/sections/build-configs.rst
Normal file
|
@ -0,0 +1,71 @@
|
|||
.. raw:: pdf
|
||||
|
||||
PageBreak titlePage
|
||||
|
||||
.. class:: centredtitle
|
||||
|
||||
Generating configuration files
|
||||
|
||||
.. raw:: pdf
|
||||
|
||||
PageBreak standardPage
|
||||
|
||||
build-configs
|
||||
=============
|
||||
|
||||
Most of my projects have the same configuration files:
|
||||
|
||||
|
|
||||
|
||||
* ``Dockerfile``
|
||||
* ``docker-compose.yaml``
|
||||
* ``justfile``
|
||||
* ``phpstan.neon.dist``
|
||||
* ``phpunit.xml.dist``
|
||||
|
||||
.. raw:: pdf
|
||||
|
||||
TextAnnotation "Same files with either the same or similar values. What if, instead of copying and pasting these between projects, I could generate them from a canonical set of templates?"
|
||||
|
||||
build-configs
|
||||
=============
|
||||
|
||||
* Symfony/Silly CLI project
|
||||
* Twig for templating
|
||||
* Takes values from a `build.yaml` file
|
||||
* Generates the appropriate files with the correct configuration
|
||||
* Easier to set up a new project
|
||||
* Less maintenance overhead
|
||||
* Can quickly add a new feature and update every project
|
||||
|
||||
.. raw:: pdf
|
||||
|
||||
TextAnnotation "Opinionated template files"
|
||||
|
||||
build.yaml
|
||||
==========
|
||||
|
||||
.. code-block:: yaml
|
||||
:include: code/build.yaml
|
||||
:linenos:
|
||||
|
||||
Dockerfile.twig
|
||||
===============
|
||||
|
||||
.. code-block:: Dockerfile
|
||||
:include: code/Dockerfile.twig
|
||||
:linenos:
|
||||
|
||||
docker-compose.yaml.twig
|
||||
========================
|
||||
|
||||
.. code-block:: twig
|
||||
:include: code/docker-compose.yaml.twig
|
||||
:linenos:
|
||||
|
||||
justfile.twig
|
||||
=============
|
||||
|
||||
.. code-block:: twig
|
||||
:include: code/justfile.twig
|
||||
:linenos:
|
22
working-without-workspace/sections/flakes.rst
Normal file
22
working-without-workspace/sections/flakes.rst
Normal file
|
@ -0,0 +1,22 @@
|
|||
.. raw:: pdf
|
||||
|
||||
PageBreak standardPage
|
||||
|
||||
Nix Flakes
|
||||
==========
|
||||
|
||||
* Per project
|
||||
* Uses ``nixpkgs`` to create a development shell
|
||||
* Can create build artifacts (phar?)
|
||||
* Could replace Docker and Docker Compose
|
||||
|
||||
.. raw:: pdf
|
||||
|
||||
TextAnnotation "Creates a temporary shell with the requirements for that project."
|
||||
|
||||
flake.nix
|
||||
=========
|
||||
|
||||
.. code-block:: nix
|
||||
:include: code/flake.nix
|
||||
:linenos:
|
19
working-without-workspace/sections/git.rst
Normal file
19
working-without-workspace/sections/git.rst
Normal file
|
@ -0,0 +1,19 @@
|
|||
.. raw:: pdf
|
||||
|
||||
PageBreak standardPage
|
||||
|
||||
Git
|
||||
===
|
||||
|
||||
Customised to my preferences, managed by Home Manager:
|
||||
|
||||
.. code-block:: nix
|
||||
:include: code/git.nix
|
||||
:linenos:
|
||||
|
||||
.. raw:: pdf
|
||||
|
||||
PageBreak
|
||||
|
||||
.. code-block:: ini
|
||||
:include: code/gitconfig.ini
|
69
working-without-workspace/sections/just.rst
Normal file
69
working-without-workspace/sections/just.rst
Normal file
|
@ -0,0 +1,69 @@
|
|||
.. raw:: pdf
|
||||
|
||||
PageBreak titlePage
|
||||
|
||||
.. class:: centredtitle
|
||||
|
||||
just
|
||||
|
||||
.. raw:: pdf
|
||||
|
||||
TextAnnotation "Who's used a Makefile? I have, but wasn't using a lot of the build features it has. I was using it as a task runner."
|
||||
|
||||
.. raw:: pdf
|
||||
|
||||
PageBreak standardPage
|
||||
|
||||
justfile
|
||||
========
|
||||
|
||||
.. code-block:: make
|
||||
|
||||
default:
|
||||
@just --list
|
||||
|
||||
_exec +args:
|
||||
docker compose exec {{ args }}
|
||||
|
||||
# Run Composer
|
||||
composer *args:
|
||||
just _exec php composer {{ args }}
|
||||
|
||||
# Run Drush commands
|
||||
drush *args:
|
||||
just _exec php drush {{ args }}
|
||||
|
||||
# Install Drupal
|
||||
install *args:
|
||||
just drush site:install -y {{ args }}
|
||||
|
||||
# Run Artisan commands (Laravel)
|
||||
artisan *args:
|
||||
docker compose run \
|
||||
--entrypoint php \
|
||||
--rm \
|
||||
--tty \
|
||||
php artisan {{ args }}
|
||||
|
||||
.. raw:: pdf
|
||||
|
||||
PageBreak titlePage
|
||||
|
||||
.. class:: centredtitle
|
||||
|
||||
``just composer require
|
||||
drupal/override_node_options``
|
||||
|
||||
.. raw:: pdf
|
||||
|
||||
PageBreak
|
||||
|
||||
.. class:: centredtitle
|
||||
|
||||
``just drush cache-rebuild``
|
||||
|
||||
|
|
||||
|
||||
.. class:: centredtitle
|
||||
|
||||
``just install localgov``
|
14
working-without-workspace/sections/neovim.rst
Normal file
14
working-without-workspace/sections/neovim.rst
Normal file
|
@ -0,0 +1,14 @@
|
|||
.. raw:: pdf
|
||||
|
||||
PageBreak standardPage
|
||||
|
||||
neovim
|
||||
======
|
||||
|
||||
* Community-maintained fork of Vim
|
||||
* Configured with Lua
|
||||
* ``nvim-lspconfig`` for language server support
|
||||
* Intelephense and Phpactor for PHP
|
||||
* ``nvim-dap`` and ``nvim-dap-ui`` for step debugging
|
||||
* ``nvim-cmp`` for completion, LuaSnip for snippets
|
||||
* PHPCS, PHPStan diagnostics with ``null-ls.nvim``
|
138
working-without-workspace/sections/operating-system.rst
Normal file
138
working-without-workspace/sections/operating-system.rst
Normal file
|
@ -0,0 +1,138 @@
|
|||
.. raw:: pdf
|
||||
|
||||
PageBreak standardPage
|
||||
|
||||
Operating system
|
||||
================
|
||||
|
||||
**Personal**:
|
||||
|
||||
- Linux
|
||||
- NixOS
|
||||
- KDE Plasma
|
||||
|
||||
|
|
||||
|
||||
**Work**:
|
||||
|
||||
- Windows 10
|
||||
- WSL (Ubuntu)
|
||||
- Nix package manager
|
||||
|
||||
.. raw:: pdf
|
||||
|
||||
TextAnnotation "Started with Ubuntu for work, used Pop!_OS for personal laptops and now on NixOS."
|
||||
TextAnnotation "Used to use Apple/macOS and switched full-time to Linux a few years ago.used Homebrew for package management."
|
||||
TextAnnotation "Automated things with Ansible."
|
||||
TextAnnotation ""
|
||||
TextAnnotation "Use Windows for Office, Teams, etc. Development is done within the WSL/Linux environment."
|
||||
|
||||
Nix and NixOS
|
||||
=============
|
||||
|
||||
- Declarative
|
||||
- Reproducable
|
||||
- Nix Packages collection (``nixpkgs``) has over 80,000 packages
|
||||
- Easy to add to and edit, and contribute to
|
||||
|
||||
.. raw:: pdf
|
||||
|
||||
TextAnnotation "Nix builds packages in isolation from each other. This ensures that they are reproducible and don't have undeclared dependencies, so if a package works on one machine, it will also work on another."
|
||||
TextAnnotation "Nix makes it trivial to share development and build environments for your projects, regardless of what programming languages and tools you’re using. "
|
||||
TextAnnotation "80,000 packages including Vim and tmux plugins, PHP and node packages"
|
||||
TextAnnotation "Configuration file-driven. You declare the end state rather than the steps to get there."
|
||||
TextAnnotation "Replaced Ansible for me."
|
||||
|
||||
.. raw:: pdf
|
||||
|
||||
PageBreak titlePage
|
||||
|
||||
.. class:: centredtitle
|
||||
|
||||
``nix-env -iA php82``
|
||||
|
||||
.. raw:: pdf
|
||||
|
||||
PageBreak
|
||||
|
||||
.. class:: centredtitle
|
||||
|
||||
``nix-shell --packages php82``
|
||||
|
||||
.. raw:: pdf
|
||||
|
||||
PageBreak
|
||||
|
||||
.. class:: centredtitle
|
||||
|
||||
``nix-shell --packages php82
|
||||
--command "php -v"``
|
||||
|
||||
.. raw:: pdf
|
||||
|
||||
PageBreak standardPage
|
||||
|
||||
configuration.nix
|
||||
=================
|
||||
|
||||
.. code-block:: nix
|
||||
:include: code/configuration.nix
|
||||
:linenos:
|
||||
|
||||
|
||||
hardware-configuration.nix
|
||||
==========================
|
||||
|
||||
.. code-block:: nix
|
||||
:include: code/hardware-configuration.nix
|
||||
:linenos:
|
||||
|
||||
.. raw:: pdf
|
||||
|
||||
PageBreak titlePage
|
||||
|
||||
.. class:: centredtitle
|
||||
|
||||
``sudo nixos-rebuild build
|
||||
--flake .#nixedo``
|
||||
|
||||
.. raw:: pdf
|
||||
|
||||
PageBreak standardPage
|
||||
|
||||
dotfiles
|
||||
========
|
||||
|
||||
* System configuration files
|
||||
* Usually hidden, filenames start with a dot (``.zshrc``, ``.gitconfig``, ``.config/``)
|
||||
* Maintained on GitHub since July 2015
|
||||
* https://opdavi.es/dotfiles
|
||||
* Managed with Home Manager
|
||||
|
||||
.. raw:: pdf
|
||||
|
||||
TextAnnotation "Similar to hidden files within projects like .gitignore."
|
||||
TextAnnotation "Manages user configuration instead of system configuration."
|
||||
TextAnnotation ""
|
||||
TextAnnotation "Used with NixOS and the Nix package manager in WSL."
|
||||
|
||||
home-manager/home.nix
|
||||
=====================
|
||||
|
||||
.. code-block:: nix
|
||||
:include: code/home-manager.nix
|
||||
:linenos:
|
||||
|
||||
.. raw:: pdf
|
||||
|
||||
PageBreak titlePage
|
||||
|
||||
.. class:: centredtitle
|
||||
|
||||
``home-manager build
|
||||
-f home-manager/home.nix
|
||||
--flake .#wsl2``
|
||||
|
||||
.. raw:: pdf
|
||||
|
||||
PageBreak standardPage
|
12
working-without-workspace/sections/others.rst
Normal file
12
working-without-workspace/sections/others.rst
Normal file
|
@ -0,0 +1,12 @@
|
|||
.. raw:: pdf
|
||||
|
||||
PageBreak standardPage
|
||||
|
||||
Other mentions
|
||||
==============
|
||||
|
||||
* ``fzf``
|
||||
* ``grep`` and ``ripgrep``
|
||||
* ``find`` and ``xargs``
|
||||
* Pulumi and Terraform for infrastructure automation
|
||||
* Ansible and Ansistrano
|
80
working-without-workspace/sections/shell.rst
Normal file
80
working-without-workspace/sections/shell.rst
Normal file
|
@ -0,0 +1,80 @@
|
|||
.. raw:: pdf
|
||||
|
||||
PageBreak titlePage
|
||||
|
||||
.. class:: centredtitle
|
||||
|
||||
Z Shell
|
||||
|
||||
.. raw:: pdf
|
||||
|
||||
PageBreak standardPage
|
||||
|
||||
Why zsh?
|
||||
========
|
||||
|
||||
* Replacement for the ``bash`` shell
|
||||
* Default on macOS
|
||||
* Separate to "oh-my-zsh"
|
||||
* OMZSH plugins and themes can be installed using ``zplug``
|
||||
* Aliases
|
||||
* Globbing and expanding
|
||||
|
||||
Aliases
|
||||
=======
|
||||
|
||||
.. code-block:: bash
|
||||
:linenos:
|
||||
:include: code/aliases.sh
|
||||
|
||||
.. raw:: pdf
|
||||
|
||||
TextAnnotation "Can be used to override default behaviour or to add new commands and shortcuts."
|
||||
|
||||
Globbing and expanding
|
||||
======================
|
||||
|
||||
Changing a file prefix:
|
||||
|
||||
``mv index.{html,twig}``
|
||||
|
||||
``mv index.html index.twig``
|
||||
|
||||
|
|
||||
|
||||
Creating two files with different prefixes:
|
||||
|
||||
``touch my-component.{config.yml,twig}``
|
||||
|
||||
|
|
||||
|
||||
Creating a range of files:
|
||||
|
||||
``touch {1..10}.php``
|
||||
|
||||
Auto-expanding
|
||||
==============
|
||||
|
||||
.. code-block:: bash
|
||||
:linenos:
|
||||
|
||||
expand-alias-space() {
|
||||
[[ $LBUFFER =~ "\<(''${(j:|:)baliases})\$" ]]; insertBlank=$?
|
||||
if [[ ! $LBUFFER =~ "\<(''${(j:|:)ialiases})\$" ]]; then
|
||||
zle _expand_alias
|
||||
fi
|
||||
|
||||
zle self-insert
|
||||
|
||||
if [[ "$insertBlank" = "0" ]]; then
|
||||
zle backward-delete-char
|
||||
fi
|
||||
}
|
||||
|
||||
zle -N expand-alias-space
|
||||
|
||||
bindkey " " expand-alias-space
|
||||
|
||||
.. raw:: pdf
|
||||
|
||||
TextAnnotation "More like snippets than aliases."
|
12
working-without-workspace/sections/tmux.rst
Normal file
12
working-without-workspace/sections/tmux.rst
Normal file
|
@ -0,0 +1,12 @@
|
|||
.. raw:: pdf
|
||||
|
||||
PageBreak standardPage
|
||||
|
||||
tmux
|
||||
====
|
||||
|
||||
* "Terminal multiplexer"
|
||||
* Splits a terminal into different sessions and panes
|
||||
* One session per project
|
||||
* Editing in one pane, running commands in another
|
||||
* Long-running commands in a separate window
|
Loading…
Add table
Add a link
Reference in a new issue