mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 12:29:19 -08:00
nf-update shell helper
This commit is contained in:
parent
eacf7a0a27
commit
09ff35bab5
1 changed files with 23 additions and 2 deletions
25
shell.nix
25
shell.nix
|
|
@ -2,6 +2,26 @@
|
||||||
meta = import ./default.nix;
|
meta = import ./default.nix;
|
||||||
config = meta;
|
config = meta;
|
||||||
inherit (meta) pkgs;
|
inherit (meta) pkgs;
|
||||||
|
fixedSources = removeAttrs config.sources [ "__functor" ];
|
||||||
|
nf-update = pkgs.writeShellScriptBin "nf-update" ''
|
||||||
|
TEMP=$(mktemp -d)
|
||||||
|
git init -q $TEMP
|
||||||
|
${pkgs.lib.concatStringsSep "\n" (pkgs.lib.mapAttrsToList (source: spec: let
|
||||||
|
update = "niv update ${source}";
|
||||||
|
fetch = "timeout 30 git -C $TEMP fetch -q --depth 1 ${spec.repo} ${spec.branch}:source-${source}";
|
||||||
|
revision = "$(git -C $TEMP show-ref -s source-${source})";
|
||||||
|
isGit = pkgs.lib.hasPrefix "https://" spec.repo or "";
|
||||||
|
git = ''
|
||||||
|
if ${fetch}; then
|
||||||
|
echo "${source}:${spec.branch} HEAD at ${revision}" >&2
|
||||||
|
${update} -r ${revision} || true
|
||||||
|
else
|
||||||
|
echo "failed to fetch latest revision from ${spec.repo}" >&2
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
auto = "${update} || true";
|
||||||
|
in if isGit then git else auto) fixedSources)}
|
||||||
|
'';
|
||||||
nf-actions = pkgs.writeShellScriptBin "nf-actions" ''
|
nf-actions = pkgs.writeShellScriptBin "nf-actions" ''
|
||||||
export START_DIR="$PWD"
|
export START_DIR="$PWD"
|
||||||
cd ${toString ./.}
|
cd ${toString ./.}
|
||||||
|
|
@ -20,7 +40,7 @@
|
||||||
done
|
done
|
||||||
cd $START_DIR
|
cd $START_DIR
|
||||||
'';
|
'';
|
||||||
nf-test = pkgs.writeShellScriptBin "nf-test" ''
|
nf-actions-test = pkgs.writeShellScriptBin "nf-actions-test" ''
|
||||||
export START_DIR="$PWD"
|
export START_DIR="$PWD"
|
||||||
cd ${toString ./.}
|
cd ${toString ./.}
|
||||||
export NF_CONFIG_ROOT=${toString ./.}/ci
|
export NF_CONFIG_ROOT=${toString ./.}/ci
|
||||||
|
|
@ -41,8 +61,9 @@
|
||||||
in pkgs.mkShell {
|
in pkgs.mkShell {
|
||||||
nativeBuildInputs = with pkgs; [
|
nativeBuildInputs = with pkgs; [
|
||||||
inetutils
|
inetutils
|
||||||
|
nf-update
|
||||||
nf-actions
|
nf-actions
|
||||||
nf-test
|
nf-actions-test
|
||||||
] ++ config.runners.lazy.nativeBuildInputs;
|
] ++ config.runners.lazy.nativeBuildInputs;
|
||||||
|
|
||||||
HISTFILE = toString (config.deploy.dataDir + "/.history");
|
HISTFILE = toString (config.deploy.dataDir + "/.history");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue