factor-lang: Improve application deployment

Build staging images ahead of time for re-use during application
deployment.
This commit is contained in:
Michael Raitza
2026-10-21 11:53:21 +02:00
parent 275edd7c71
commit 91ba85554d
3 changed files with 35 additions and 0 deletions

View File

@@ -5,6 +5,7 @@
makeBinaryWrapper,
factor-lang,
factor-no-gui,
staging-images,
librsvg,
gdk-pixbuf,
}@initAttrs:
@@ -113,6 +114,9 @@ in
vocabBaseName=$(basename "$vocabName")
mkdir -p "$out/lib/factor" "$TMPDIR/.cache"
export XDG_CACHE_HOME="$TMPDIR/.cache"
mkdir "$XDG_CACHE_HOME/factor"
cp -r "${staging-images}"/lib/factor/staging.* "$XDG_CACHE_HOME/factor"
chmod -R u+w "$XDG_CACHE_HOME/factor"
# Deploy script writes the deploy path to to $PWD/deploy-path.txt
factor "${deployScript}" "./$vocabName" "$out/lib/factor"

View File

@@ -0,0 +1,29 @@
{
lib,
stdenv,
factor-unwrapped,
}:
stdenv.mkDerivation {
pname = "factor-staging-images";
inherit (factor-unwrapped) version meta;
dontUnpack = true;
preBuild = ''
# Factor uses XDG_CACHE_HOME for cache during compilation.
# We can't have that. So, set it to $TMPDIR/.cache
export XDG_CACHE_HOME=$TMPDIR/.cache
mkdir -p $XDG_CACHE_HOME
'';
buildPhase = ''
runHook preBuild
${factor-unwrapped}/lib/factor/factor -script -e='USING: kernel system tools.deploy.backend ; "compiler" "hello-world" [ deploy-config config>profile make-staging-image ] bi@'
runHook postBuild
'';
installPhase = ''
mkdir -p $out/lib/factor
cp -r $XDG_CACHE_HOME/factor/staging.* $out/lib/factor
'';
}

View File

@@ -32,6 +32,8 @@ let
enableDefaults = false;
};
staging-images = callPackage ../development/compilers/factor-lang/staging.nix { };
# Vocabularies
bresenham = callPackage ../development/factor-vocabs/bresenham { };