mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 04:19:19 -08:00
ensure sources are cached locally before building
This commit is contained in:
parent
6a3b8ef8ca
commit
a8bfcdf17f
3 changed files with 28 additions and 5 deletions
10
ci/hosts.nix
10
ci/hosts.nix
|
|
@ -4,6 +4,16 @@
|
|||
ci.gh-actions.export = true;
|
||||
channels.nixfiles.path = ../.;
|
||||
|
||||
# ensure sources are fetched and available in the local store before evaluating host configs
|
||||
environment.bootstrap = {
|
||||
sourceCache = channels.cipkgs.runCommand "sources" {
|
||||
srcs = attrNames channels.nixfiles.sourceCache.local;
|
||||
} ''
|
||||
mkdir -p $out/share/sources
|
||||
ln -s $srcs $out/share/sources/
|
||||
'';
|
||||
};
|
||||
|
||||
jobs = let hostnames = [ "samhain" "yule" "athame" ];
|
||||
in mapAttrs' (k: nameValuePair "host-${k}") (genAttrs hostnames (host: {
|
||||
tasks.${host}.inputs = channels.nixfiles.hosts.${host}.config.system.build.toplevel;
|
||||
|
|
|
|||
|
|
@ -51,11 +51,14 @@ with lib; {
|
|||
done
|
||||
|
||||
if git status --porcelain | grep -qF nix/sources.json; then
|
||||
nix build --no-link -f . sourceCache.local
|
||||
if nix build -Lf . hosts.{athame,yule,samhain}.config.system.build.toplevel; then
|
||||
nix build -f ../. sourceCache
|
||||
if [[ -n $CACHIX_SIGNING_KEY ]]; then
|
||||
cachix push kittywitch $(nix eval '(toString (import ../.).sourceCache)')
|
||||
nix-build $(echo "-A hosts."{athame,yule,samhain}.config.system.build.toplevel) | cachix push kittywitch
|
||||
nix build --no-link -f . sourceCache.all
|
||||
cachix push kittywitch $(nix eval -f . sourceCache.allStr)
|
||||
|
||||
cachix push kittywitch result*/ &
|
||||
CACHIX_PUSH=$!
|
||||
fi
|
||||
if [[ -n $OPENSSH_PRIVATE_KEY ]]; then
|
||||
git add nix/sources.json
|
||||
|
|
@ -66,6 +69,8 @@ with lib; {
|
|||
GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" \
|
||||
git push gitea master
|
||||
fi
|
||||
|
||||
wait ''${CACHIX_PUSH-}
|
||||
fi
|
||||
else
|
||||
echo "no source changes" >&2
|
||||
|
|
|
|||
12
default.nix
12
default.nix
|
|
@ -19,8 +19,16 @@ rec {
|
|||
|
||||
runners = import ./runners.nix { inherit lib; inherit (deploy) target; };
|
||||
|
||||
getSources = sources: lib.attrValues (lib.removeAttrs sources [ "__functor" ]);
|
||||
sourceCache = map(value: if lib.isDerivation value.outPath then value.outPath else value) (getSources sources ++ getSources (import sources.nix-hexchen {}).sources);
|
||||
sourceCache = with lib; let
|
||||
getSources = sources: removeAttrs sources [ "__functor" "dorkfiles" ];
|
||||
source2drv = value: if isDerivation value.outPath then value.outPath else value;
|
||||
sources2drvs = sources: mapAttrs (_: source2drv) (getSources sources);
|
||||
in recurseIntoAttrs rec {
|
||||
local = sources2drvs sources;
|
||||
hexchen = sources2drvs (import sources.nix-hexchen {}).sources;
|
||||
all = attrValues local ++ attrValues hexchen;
|
||||
allStr = toString all;
|
||||
};
|
||||
|
||||
deploy = import ./lib/deploy.nix {
|
||||
inherit pkgs sources;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue