Build slides with Nix
This commit is contained in:
parent
e80aee1deb
commit
50662bffcc
10 changed files with 175 additions and 153 deletions
7
.gitignore
vendored
7
.gitignore
vendored
|
@ -1,11 +1,6 @@
|
||||||
# Nix.
|
# Nix.
|
||||||
/.direnv/
|
/.direnv/
|
||||||
|
/result
|
||||||
# rst2df.
|
|
||||||
/**/*.pdf
|
|
||||||
/**/*.rst.build_temp
|
|
||||||
/dist/*
|
|
||||||
!/dist/.keep
|
|
||||||
|
|
||||||
# pdfpc.
|
# pdfpc.
|
||||||
/**/*.pdfpc
|
/**/*.pdfpc
|
||||||
|
|
0
dist/.keep
vendored
0
dist/.keep
vendored
8
flake.lock
generated
8
flake.lock
generated
|
@ -2,16 +2,16 @@
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1725001927,
|
"lastModified": 1741010256,
|
||||||
"narHash": "sha256-eV+63gK0Mp7ygCR0Oy4yIYSNcum2VQwnZamHxYTNi+M=",
|
"narHash": "sha256-WZNlK/KX7Sni0RyqLSqLPbK8k08Kq7H7RijPJbq9KHM=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "6e99f2a27d600612004fbd2c3282d614bfee6421",
|
"rev": "ba487dbc9d04e0634c64e3b1f0d25839a0a68246",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"ref": "nixos-24.05",
|
"ref": "nixos-unstable",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
|
|
87
flake.nix
87
flake.nix
|
@ -1,25 +1,96 @@
|
||||||
{
|
{
|
||||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
|
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
|
||||||
outputs =
|
outputs =
|
||||||
{ nixpkgs, ... }:
|
{ nixpkgs, ... }:
|
||||||
let
|
let
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
pkgs = import nixpkgs { inherit system; };
|
||||||
|
|
||||||
inherit (pkgs) mkShell nixfmt-classic;
|
inherit (nixpkgs.lib) makeOverridable;
|
||||||
|
inherit (pkgs.stdenvNoCC) mkDerivation;
|
||||||
|
|
||||||
|
shared = mkDerivation {
|
||||||
|
name = "talks-shared";
|
||||||
|
src = ./src;
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
runHook preInstall
|
||||||
|
|
||||||
|
mkdir $out
|
||||||
|
cp -r fonts styles $out
|
||||||
|
|
||||||
|
runHook postInstall
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
commonBuildInputs = with pkgs; [
|
||||||
|
(python310.withPackages (p: with p; [ rst2pdf ]))
|
||||||
|
];
|
||||||
|
|
||||||
|
mkTalk = makeOverridable (
|
||||||
|
{ src }:
|
||||||
|
mkDerivation {
|
||||||
|
inherit shared src;
|
||||||
|
|
||||||
|
name = builtins.head (builtins.attrNames talks);
|
||||||
|
|
||||||
|
buildInputs = commonBuildInputs;
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
runHook preBuild
|
||||||
|
|
||||||
|
mkdir $out
|
||||||
|
|
||||||
|
rst2pdf slides.rst \
|
||||||
|
--break-level 1 \
|
||||||
|
--fit-background-mode scale \
|
||||||
|
--font-path "${toString shared}/fonts" \
|
||||||
|
--output "$out/slides.pdf" \
|
||||||
|
--stylesheets bw,"${toString shared}/styles/opdavies-light"
|
||||||
|
|
||||||
|
runHook postBuild
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
talks = {
|
||||||
|
build-configs = mkTalk {
|
||||||
|
src = ./src/building-build-configs;
|
||||||
|
};
|
||||||
|
|
||||||
|
sculpin = mkTalk {
|
||||||
|
src = ./src/building-static-websites-sculpin;
|
||||||
|
};
|
||||||
|
|
||||||
|
tailwind-css = mkTalk {
|
||||||
|
src = ./src/taking-flight-with-tailwind-css;
|
||||||
|
};
|
||||||
|
|
||||||
|
test-driven-drupal = mkTalk {
|
||||||
|
src = ./src/test-driven-drupal;
|
||||||
|
};
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
devShells.${system}.default = mkShell {
|
devShells.${system}.default =
|
||||||
packages = with pkgs; [
|
with pkgs;
|
||||||
|
mkShell {
|
||||||
|
packages =
|
||||||
|
with pkgs;
|
||||||
|
commonBuildInputs
|
||||||
|
++ [
|
||||||
ghostscript
|
ghostscript
|
||||||
|
just
|
||||||
pdfpc
|
pdfpc
|
||||||
python310Packages.rst2pdf
|
|
||||||
texliveMedium # includes pdfjam
|
texliveMedium # includes pdfjam
|
||||||
tree
|
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
formatter.${system} = nixfmt-classic;
|
packages.${system} = {
|
||||||
|
inherit shared;
|
||||||
|
} // talks;
|
||||||
|
|
||||||
|
formatter.${system} = pkgs.nixfmt-rfc-style;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
19
justfile
Normal file
19
justfile
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
alias b := build
|
||||||
|
|
||||||
|
_default:
|
||||||
|
just --list
|
||||||
|
|
||||||
|
check:
|
||||||
|
nix flake check
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -frv result
|
||||||
|
|
||||||
|
build:
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
talk=$(nix flake show --json | jq --raw-output '.packages["x86_64-linux"] | keys[]' | grep -v shared | fzf)
|
||||||
|
|
||||||
|
nix build \
|
||||||
|
--json \
|
||||||
|
--print-build-logs \
|
||||||
|
.#"$talk"
|
107
run
107
run
|
@ -1,107 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
set -o errexit
|
|
||||||
set -o nounset
|
|
||||||
set -o pipefail
|
|
||||||
|
|
||||||
PDF_FILENAME=slides.pdf
|
|
||||||
RST_FILENAME="${RST_FILENAME:-slides.rst}"
|
|
||||||
THUMBNAIL_FILENAME=thumbnail.jpg
|
|
||||||
|
|
||||||
function clean {
|
|
||||||
rm -fr dist/*
|
|
||||||
touch dist/.keep
|
|
||||||
|
|
||||||
find . \
|
|
||||||
-type f \( -name "${PDF_FILENAME}*" -o -name *.build_temp -o -name ${THUMBNAIL_FILENAME} \) \
|
|
||||||
-delete
|
|
||||||
}
|
|
||||||
|
|
||||||
function generate {
|
|
||||||
generate:pdf "${@}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function generate:pdf {
|
|
||||||
if [ "${1}" == "" ]; then
|
|
||||||
echo "Usage: ./${0##*/} ${FUNCNAME[0]} <talk-name>"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
DIRECTORY_NAME=$1
|
|
||||||
shift 1
|
|
||||||
pushd "src/${DIRECTORY_NAME}"
|
|
||||||
|
|
||||||
rst2pdf "${RST_FILENAME}" \
|
|
||||||
--break-level 1 \
|
|
||||||
-e preprocess \
|
|
||||||
--fit-background-mode scale \
|
|
||||||
--font-path ../fonts \
|
|
||||||
--output "../../dist/${DIRECTORY_NAME}.pdf" \
|
|
||||||
--stylesheets ../styles/opdavies-light,tango \
|
|
||||||
"${@}"
|
|
||||||
|
|
||||||
popd
|
|
||||||
|
|
||||||
tree dist
|
|
||||||
}
|
|
||||||
|
|
||||||
# Generate JPG thumbnails of each slide in a presentation.
|
|
||||||
function generate:thumbnail {
|
|
||||||
if [ "${1}" == "" ]; then
|
|
||||||
echo "Usage: ./${0##*/} ${FUNCNAME[0]} <talk-name>"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -d "src/${1}" ]; then
|
|
||||||
echo "${1} not found"
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
generate:pdf "${1}"
|
|
||||||
|
|
||||||
mkdir -p "dist/${1}"
|
|
||||||
|
|
||||||
gs \
|
|
||||||
-dBATCH \
|
|
||||||
-dDownScaleFactor=3 \
|
|
||||||
-dNOPAUSE \
|
|
||||||
-r600 \
|
|
||||||
-sDEVICE=jpeg \
|
|
||||||
-sOutputFile="dist/${1}/%d.jpg" \
|
|
||||||
"dist/${1}.pdf"
|
|
||||||
}
|
|
||||||
|
|
||||||
function help {
|
|
||||||
printf "%s <task> [args]\n\nTasks:\n" "${0}"
|
|
||||||
|
|
||||||
compgen -A function | grep -v "^_" | cat -n
|
|
||||||
|
|
||||||
printf "\nExtended help:\n Each task has comments for general usage\n"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Create a new talk.
|
|
||||||
function new {
|
|
||||||
if [ "${1}" == "" ]; then
|
|
||||||
echo "Usage: ./${0##*/} ${FUNCNAME[0]} <talk-name>"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -e "src/${1}" ]]; then
|
|
||||||
echo "Error: ${1} already exists."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -vp "src/${1}"
|
|
||||||
|
|
||||||
touch "src/${1}/slides.rst"
|
|
||||||
}
|
|
||||||
|
|
||||||
function present {
|
|
||||||
TALK_PATH=$1
|
|
||||||
shift 1
|
|
||||||
|
|
||||||
pdfpc "${@}" "dist/${TALK_PATH}.pdf"
|
|
||||||
}
|
|
||||||
|
|
||||||
TIMEFORMAT=$'\nTask completed in %3lR'
|
|
||||||
time "${@:-help}"
|
|
|
@ -1,7 +1,9 @@
|
||||||
..
|
..
|
||||||
This file used a mixture of `plain` and `php` languages for code blocks so that `hl_lines` display correctly.
|
This file used a mixture of `plain` and `php` languages for code blocks so that `hl_lines` display correctly.
|
||||||
|
|
||||||
.. page:: titlePage
|
.. raw:: pdf
|
||||||
|
|
||||||
|
PageBreak titlePage
|
||||||
|
|
||||||
.. class:: centredtitle
|
.. class:: centredtitle
|
||||||
|
|
||||||
|
@ -12,7 +14,9 @@ Building a blog module
|
||||||
TextAnnotation "Shortened and simplified example."
|
TextAnnotation "Shortened and simplified example."
|
||||||
TextAnnotation "I'd use Views for this in a real situation."
|
TextAnnotation "I'd use Views for this in a real situation."
|
||||||
|
|
||||||
.. page:: standardPage
|
.. raw:: pdf
|
||||||
|
|
||||||
|
PageBreak standardPage
|
||||||
|
|
||||||
Acceptance criteria
|
Acceptance criteria
|
||||||
===================
|
===================
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
.. page:: titlePage
|
.. raw:: pdf
|
||||||
|
|
||||||
|
PageBreak titlePage
|
||||||
|
|
||||||
.. class:: centredtitle
|
.. class:: centredtitle
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,21 @@
|
||||||
.. page:: titlePage
|
.. raw:: pdf
|
||||||
|
|
||||||
|
PageBreak titlePage
|
||||||
|
|
||||||
.. class:: centredtitle
|
.. class:: centredtitle
|
||||||
|
|
||||||
Example
|
Example
|
||||||
|
|
||||||
.. page:: imagePage
|
.. raw:: pdf
|
||||||
|
|
||||||
|
PageBreak imagePage
|
||||||
|
|
||||||
.. image:: images/broadbean-website.png
|
.. image:: images/broadbean-website.png
|
||||||
:width: 20cm
|
:width: 20cm
|
||||||
|
|
||||||
.. page:: standardPage
|
.. raw:: pdf
|
||||||
|
|
||||||
|
PageBreak standardPage
|
||||||
|
|
||||||
Specification
|
Specification
|
||||||
=============
|
=============
|
||||||
|
@ -27,7 +33,9 @@ Specification
|
||||||
TextAnnotation "Job applicants would visit the job on the Drupal site, click the application URL and go to another (CRM) system to apply."
|
TextAnnotation "Job applicants would visit the job on the Drupal site, click the application URL and go to another (CRM) system to apply."
|
||||||
TextAnnotation "Client wanted to be able to specify the Drupal path in advance."
|
TextAnnotation "Client wanted to be able to specify the Drupal path in advance."
|
||||||
|
|
||||||
.. page:: imagePage
|
.. raw:: pdf
|
||||||
|
|
||||||
|
PageBreak imagePage
|
||||||
|
|
||||||
|
|
|
|
||||||
|
|
|
|
||||||
|
@ -35,7 +43,9 @@ Specification
|
||||||
.. image:: images/broadbean-drupal-flow-2.png
|
.. image:: images/broadbean-drupal-flow-2.png
|
||||||
:width: 20cm
|
:width: 20cm
|
||||||
|
|
||||||
.. page:: standardPage
|
.. raw:: pdf
|
||||||
|
|
||||||
|
PageBreak standardPage
|
||||||
|
|
||||||
Implementation
|
Implementation
|
||||||
==============
|
==============
|
||||||
|
|
|
@ -15,7 +15,9 @@ Oliver Davies (@opdavies)
|
||||||
|
|
||||||
https://opdavi.es/drupal-london
|
https://opdavi.es/drupal-london
|
||||||
|
|
||||||
.. page:: titlePage
|
.. raw:: pdf
|
||||||
|
|
||||||
|
PageBreak titlePage
|
||||||
|
|
||||||
.. class:: centredtitle
|
.. class:: centredtitle
|
||||||
|
|
||||||
|
@ -27,7 +29,9 @@ Software Developer, Consultant, open-source maintainer
|
||||||
TextAnnotation "I contribute to and maintain open-source projects including Drupal core."
|
TextAnnotation "I contribute to and maintain open-source projects including Drupal core."
|
||||||
TextAnnotation "Different perspectives."
|
TextAnnotation "Different perspectives."
|
||||||
|
|
||||||
.. page:: imagePage
|
.. raw:: pdf
|
||||||
|
|
||||||
|
PageBreak imagePage
|
||||||
|
|
||||||
.. image:: images/timmillwood-ono.png
|
.. image:: images/timmillwood-ono.png
|
||||||
:width: 22cm
|
:width: 22cm
|
||||||
|
@ -36,7 +40,9 @@ Software Developer, Consultant, open-source maintainer
|
||||||
|
|
||||||
TextAnnotation "I saw this tweet by Tim Millwood and become the maintainer in 2012."
|
TextAnnotation "I saw this tweet by Tim Millwood and become the maintainer in 2012."
|
||||||
|
|
||||||
.. page:: imagePage
|
.. raw:: pdf
|
||||||
|
|
||||||
|
PageBreak imagePage
|
||||||
|
|
||||||
.. image:: images/override-node-options-1.png
|
.. image:: images/override-node-options-1.png
|
||||||
:width: 18cm
|
:width: 18cm
|
||||||
|
@ -70,7 +76,9 @@ Software Developer, Consultant, open-source maintainer
|
||||||
PageBreak
|
PageBreak
|
||||||
TextAnnotation "Had some existing tests, crucial to preventing regressions"
|
TextAnnotation "Had some existing tests, crucial to preventing regressions"
|
||||||
|
|
||||||
.. page:: standardPage
|
.. raw:: pdf
|
||||||
|
|
||||||
|
PageBreak standardPage
|
||||||
|
|
||||||
Why write tests?
|
Why write tests?
|
||||||
================
|
================
|
||||||
|
@ -117,7 +125,9 @@ Writing PHPUnit Tests for Drupal
|
||||||
TextAnnotation "PSR-4 autoloading."
|
TextAnnotation "PSR-4 autoloading."
|
||||||
TextAnnotation "Different to D7."
|
TextAnnotation "Different to D7."
|
||||||
|
|
||||||
.. page:: titlePage
|
.. raw:: pdf
|
||||||
|
|
||||||
|
PageBreak titlePage
|
||||||
|
|
||||||
.. class:: centredtitle
|
.. class:: centredtitle
|
||||||
|
|
||||||
|
@ -143,7 +153,9 @@ Given, When, Then
|
||||||
TextAnnotation "When I go to that page..."
|
TextAnnotation "When I go to that page..."
|
||||||
TextAnnotation "I should see 'About me' on the page."
|
TextAnnotation "I should see 'About me' on the page."
|
||||||
|
|
||||||
.. page:: standardPage
|
.. raw:: pdf
|
||||||
|
|
||||||
|
PageBreak standardPage
|
||||||
|
|
||||||
What to test?
|
What to test?
|
||||||
=============
|
=============
|
||||||
|
@ -160,14 +172,18 @@ What to test?
|
||||||
|
|
||||||
TextAnnotation "Examples of some things that I tested on previous projects."
|
TextAnnotation "Examples of some things that I tested on previous projects."
|
||||||
|
|
||||||
.. page:: imagePage
|
.. raw:: pdf
|
||||||
|
|
||||||
|
PageBreak imagePage
|
||||||
|
|
||||||
|
|
|
|
||||||
|
|
||||||
.. image:: images/matt-stauffer-tweet.png
|
.. image:: images/matt-stauffer-tweet.png
|
||||||
:width: 20cm
|
:width: 20cm
|
||||||
|
|
||||||
.. page:: standardPage
|
.. raw:: pdf
|
||||||
|
|
||||||
|
PageBreak standardPage
|
||||||
|
|
||||||
What does a test look like?
|
What does a test look like?
|
||||||
===========================
|
===========================
|
||||||
|
@ -296,13 +312,17 @@ Unit Tests
|
||||||
* Can become tightly coupled
|
* Can become tightly coupled
|
||||||
* Can be hard to refactor
|
* Can be hard to refactor
|
||||||
|
|
||||||
.. page:: titlePage
|
.. raw:: pdf
|
||||||
|
|
||||||
|
PageBreak titlePage
|
||||||
|
|
||||||
.. class:: centredtitle
|
.. class:: centredtitle
|
||||||
|
|
||||||
Running Tests
|
Running Tests
|
||||||
|
|
||||||
.. page:: standardPage
|
.. raw:: pdf
|
||||||
|
|
||||||
|
PageBreak standardPage
|
||||||
|
|
||||||
Core script
|
Core script
|
||||||
===========
|
===========
|
||||||
|
@ -416,13 +436,17 @@ Test Driven Development
|
||||||
TextAnnotation "Refactor if needed."
|
TextAnnotation "Refactor if needed."
|
||||||
TextAnnotation "Repeat."
|
TextAnnotation "Repeat."
|
||||||
|
|
||||||
.. page:: titlePage
|
.. raw:: pdf
|
||||||
|
|
||||||
|
PageBreak titlePage
|
||||||
|
|
||||||
.. class:: centredtitle
|
.. class:: centredtitle
|
||||||
|
|
||||||
Red, Green, Refactor
|
Red, Green, Refactor
|
||||||
|
|
||||||
.. page:: standardPage
|
.. raw:: pdf
|
||||||
|
|
||||||
|
PageBreak standardPage
|
||||||
|
|
||||||
Porting Modules From Drupal 7
|
Porting Modules From Drupal 7
|
||||||
=============================
|
=============================
|
||||||
|
@ -465,12 +489,16 @@ Run in 2-3 minutes in a CI pipeline with GitHub Actions.
|
||||||
.. .. include:: demo.rst
|
.. .. include:: demo.rst
|
||||||
.. include:: demo2.rst
|
.. include:: demo2.rst
|
||||||
|
|
||||||
.. page:: imagePage
|
.. raw:: pdf
|
||||||
|
|
||||||
|
PageBreak imagePage
|
||||||
|
|
||||||
.. image:: images/tawny-tweet-2.png
|
.. image:: images/tawny-tweet-2.png
|
||||||
:width: 18cm
|
:width: 18cm
|
||||||
|
|
||||||
.. page:: standardPage
|
.. raw:: pdf
|
||||||
|
|
||||||
|
PageBreak standardPage
|
||||||
|
|
||||||
Thanks!
|
Thanks!
|
||||||
=======
|
=======
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue