Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
d9e0aa6
init with very basic flake.nix
chuckadams Oct 30, 2025
6847c2a
add more packages to the base flake
chuckadams Oct 31, 2025
3b77a8d
add .editorconfig to git
chuckadams Oct 31, 2025
50d60d2
add perl to /flake.nix
chuckadams Oct 31, 2025
a452b45
pin flake-utils to hash
chuckadams Oct 31, 2025
61d3be4
add legacy AS scripts
chuckadams Oct 31, 2025
438fea8
update prelude.bash with nounset and pipefail
chuckadams Oct 31, 2025
b44116f
update scripts cd to PLUGINS_DIR and THEMES_DIR
chuckadams Oct 31, 2025
4371ead
add auto svn cleanup to update-plugin-trunk
chuckadams Oct 31, 2025
dc6e6eb
pare down legacy scripts to archive-plugin
chuckadams Oct 31, 2025
0c8fe49
chmod +x bin/svn-changed-*
chuckadams Oct 31, 2025
4dda143
add some WIP docker image generation
chuckadams Nov 2, 2025
656eaa4
start of mkbuilder tool
chuckadams Nov 2, 2025
f355833
add prelude.d/reset.bash to set PATH only to /nix/* dirs
chuckadams Nov 2, 2025
54f6548
add missing git dependency
chuckadams Nov 2, 2025
24b6842
add liberal comments to docker section of flake.nix
chuckadams Nov 3, 2025
8e747f8
use /usr/bin/env in bash shebangs
chuckadams Nov 3, 2025
a41a915
zap unnecessary || die checks after cd
chuckadams Nov 3, 2025
d700939
add in-new-builder script
chuckadams Nov 3, 2025
ae23eb2
clear out ASPIREBUILD_* vars before executing in in-new-builder
chuckadams Nov 3, 2025
afbb1ce
symlink _common/lib to mkbuilder/lib
chuckadams Nov 3, 2025
7a711d9
renae mkbuilder -> builder
chuckadams Nov 3, 2025
ce1d831
rename in-new-builder -> with-new-builder
chuckadams Nov 3, 2025
92ea77f
use single ASPIREBUILD for root, clone to .aspirebuild subdir
chuckadams Nov 4, 2025
0a22a6e
use absolute path for __HERE
chuckadams Nov 4, 2025
ea76554
more flake fiddling
chuckadams Nov 4, 2025
bbe6da5
zap update-plugin-trunk
chuckadams Nov 4, 2025
710b5c1
update algorithm for finding/creating $ASPIRESYNC
chuckadams Nov 4, 2025
803de1c
add init-builder-flake but keep it manual for now
chuckadams Nov 4, 2025
ba51208
add default justfile
chuckadams Nov 4, 2025
d138375
use path:. for builder flake in justfile
chuckadams Nov 4, 2025
f1032d5
add php-init to justfile
chuckadams Nov 4, 2025
7e9d32b
switch to flake-parts
chuckadams Nov 10, 2025
a1c86b6
use flake-root to set ASPIREBUILD
chuckadams Nov 10, 2025
02eb274
init builders with template
chuckadams Nov 10, 2025
2b9144b
remove useless root justfile
chuckadams Nov 10, 2025
a223a95
add ffi extension to flake.nix
chuckadams Nov 12, 2025
fee146d
add intl extension to flake
chuckadams Nov 12, 2025
710f23e
build all needed extensions
chuckadams Nov 12, 2025
41176df
document The One Flake
chuckadams Nov 13, 2025
48f3d16
use dontInstall = true; add note about $ASPIREBUILD's impurity
chuckadams Nov 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{nix,yml,yaml}]
indent_size = 2
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# ignore all dotfiles and dotdirs by default, with exceptions below
.*
!.gitignore
!.editorconfig

builders/
node_modules/
tmp/
vendor/

*.log
*.tmp

# default output file for 'nix build'
result
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
# aspirebuild

## Requirements

* Nix, with flakes support. I _highly_ recommend the [Determinate Systems installer](https://docs.determinate.systems/)
* Recommended: `direnv` (should be available on apt/brew/dnf/pacman/etc)

## Quick Start

```
echo "use flake" > .envrc && direnv allow # if using direnv
nix develop
```
77 changes: 77 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

164 changes: 164 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
{
# This flake, which I'm now calling The One Flake, describes the entire AspireBuild monorepo including all its tools.
# The eventual goal is to make each tool its own flake, as well as each builder, with each tool and builder depending
# on the AspireBuild flake. However we're not there yet, so currently we manage everything through The One Flake.

description = "AspireBuild";

inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
flake-root.url = "github:srid/flake-root";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};

outputs =
inputs@{ self, flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [ inputs.flake-root.flakeModule ];

systems = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
"x86_64-darwin"
];

# most of the flake should go in here
perSystem =
{
config,
self',
inputs',
pkgs,
system,
lib,
...
}:
let
buildInputs = with pkgs; [
bashInteractive
coreutils
curl
git
gnutar
jq
just
lrzip
perl
php
php84Packages.composer
subversion
sqlite
systemfd
tzdata
watchexec
zip
zstd
];

extensions = with pkgs.php84Extensions; [
bcmath
curl
ffi
filter
gettext
gmp
intl
mbstring
pdo
pdo_sqlite
readline
sockets
sodium
sqlite3

# full list in /nix/store/nsybw5k5jcqwccbgslfq5psmqh3x3svs-php-with-extensions-8.4.14/lib/php.ini

# future consideration
#ctype
#dom
#fileinfo
#iconv
#mysqli
#mysqlnd
#openssl
#pcntl
#pdo_mysql
#pdo_pgsql
#pgsql
#posix
#session
#simplexml
#sockets
#tokenizer
#xmlreader
#xmlwriter
#zip
#zlib
];

zend-extensions = with pkgs.php84Extensions; [
opcache
xdebug
];

in
{
devShells.default = pkgs.mkShell {
inherit buildInputs;

inputsFrom = [ config.flake-root.devShell ]; # sets $FLAKE_ROOT

shellHook = ''
export ASPIREBUILD=$FLAKE_ROOT
export SELF_DIR=${self'.packages.default}
export PHP_INI_SCAN_DIR=:${self'.packages.default}
'';

# in case $FLAKE_ROOT isn't available, this should also work.
#
# export ASPIREBUILD=$(${lib.getExe config.flake-root.package})
#
# Note that the flake root is impure state, and thus should never be set in an attribute or in a file,
# so technically this makes our flake impure because of all of the dependencies on $ASPIREBUILD. But since
# $ASPIREBUILD in the package always points into the nix store for this flake, we can get away with it
# while still allowing local dev to point to the working copy.
};

packages.default = pkgs.stdenv.mkDerivation {
inherit buildInputs;

name = "aspirebuild";

src = ./.;

php-ini =
let
get-extension-name = name: builtins.elemAt (builtins.split "-" name) 2; # "php-intl-8.4.13" -> "intl"
ext-line = ext: "extension = ${ext}/lib/php/extensions/${get-extension-name ext.name}.so";
zend-ext-line = ext: "zend_extension = ${ext}/lib/php/extensions/${get-extension-name ext.name}.so";
in
(map ext-line extensions) ++ (map zend-ext-line zend-extensions);

buildPhase = ''
mkdir -p $out

cat << EOF > $out/php.ini
; PHP extensions for AspireBuild

${lib.concatStringsSep "\n" config.packages.default.php-ini}
EOF
'';

dontInstall = true;
};

# invoke with `nix fmt flake.nix`
formatter = pkgs.nixfmt-rfc-style;
};

flake = {
# system-agnostic flake attributes go here. we don't have any yet.
};
};
}
33 changes: 33 additions & 0 deletions tools/_common/lib/bash/prelude.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This file should be sourced, not run

set -o errexit
set -o nounset
set -o pipefail

# These are not exported, but will be visible in the tool's script if they need them
__ORIG_PWD=$PWD
__HERE=$(dirname "$0")
__HERE=$(realpath -s "$__HERE") # canonicalize only, don't resolve symlinks

function warn { echo "$@" >&2; }
function die { warn "$@"; exit 1; }

# This is set in flake.nix, so this will only be blank if not in a nix environment.
[[ -n $ASPIREBUILD ]] || die "ASPIREBUILD environment variable not set. Please set it to the absolute path of an AspireBuild git repo."

# We bail out early if our working directory contains spaces, rather than risk stepping on this mine later.
# We make reasonable efforts to quote bash arguments, but 'bash' and 'reasonable' do not belong in the same sentence.
[[ "$ASPIREBUILD" =~ [[:space:]] ]] && die "Refusing to deal with aspirebuild directory containing whitespace. Aborted."

cd "$ASPIREBUILD"

# Run all prelude files under the current tool's lib (usually symlinked to tools/_common/lib)
preludes=$(
shopt -s nullglob
echo "$__HERE"/../lib/bash/prelude.d/*.bash "$__HERE"/../local/lib/bash/prelude.d/*.bash
);

for file in $preludes; do
# shellcheck source=/dev/null
[[ -f $file ]] && source "$file"
done
10 changes: 10 additions & 0 deletions tools/_common/lib/bash/prelude.d/nix-only-path.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file should be sourced, not run
#
# Sets PATH to include only directories under /nix
#
# By no means does this script create a fully hermetic environment.
# It's meant to help make builds more reproducible, but does not guarantee it.

__ORIG_PATH=$PATH

PATH=$(awk -v RS=: -v ORS=: '$0 ~ /^\/nix\/.*/' <<<"$PATH")
28 changes: 28 additions & 0 deletions tools/builder/bin/init-builder
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

# shellcheck disable=SC2086
source "$(dirname $0)"/../lib/bash/prelude.bash

[[ -n "$*" ]] || die "usage: $0 <cmdline ...>"

builder=$1
shift

cd $builder

# TODO: make this an option --template=foo (I'm not doing option parsing in bash)
template=${BUILDER_TEMPLATE:-default}

# A template containing a hash, e.g. .#foo is assumed to be a nix expression
if [[ $template =~ [#] ]]; then
nix flake init -t $template
exit 0
fi

[[ $template =~ ^/ ]] || template=$(realpath -s "$__HERE/../templates/$template")

[[ -d $template ]] || die "No such directory: $template "

[[ -f $template/_meta/install ]] || die "Template $template does not contain a _meta/install script"

$template/_meta/install "$template" "$builder"
15 changes: 15 additions & 0 deletions tools/builder/bin/make-builder
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

# shellcheck disable=SC2086
source "$(dirname $0)"/../lib/bash/prelude.bash

builders=${ASPIREBUILD_BUILDER_DIR:-$ASPIREBUILD/builders}
mkdir -p "$builders"

builder=${1:-$(mktemp -d $builders/builder.XXXXXXXXXX)}

[[ $builder =~ ^/ ]] || builder=$builders/$builder

$__HERE/init-builder $builder >/dev/null

echo $builder
12 changes: 12 additions & 0 deletions tools/builder/bin/with-temp-builder
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

here=$(dirname "$0")
source "$here/../lib/bash/prelude.bash"

[[ -n "$*" ]] || die "usage: $0 <cmdline ...>"

builder=$("$__HERE/make-builder")
[[ -z ${KEEP_BUILDER:-} ]] && trap "rm -rf $builder" EXIT

cd "$builder"
"$@"
1 change: 1 addition & 0 deletions tools/builder/lib
Loading