2019-02-13 08:18:19 +03:00
|
|
|
{ stdenv, writeScript, glibc, coreutils, git, openssh
|
2020-03-06 16:52:05 +03:00
|
|
|
, nix-tools, cabal-install, nix-prefetch-git
|
|
|
|
, bash, curl, findutils, gawk }:
|
2019-02-11 06:37:10 +03:00
|
|
|
|
|
|
|
{ name, script }:
|
|
|
|
|
|
|
|
with stdenv.lib;
|
|
|
|
|
2019-02-13 08:18:19 +03:00
|
|
|
let
|
2019-04-02 05:18:04 +03:00
|
|
|
repoHTTPS = "https://github.com/input-output-hk/${name}.nix";
|
2019-02-13 08:18:19 +03:00
|
|
|
repoSSH = "git@github.com:input-output-hk/${name}.nix.git";
|
|
|
|
sshKey = "/run/keys/buildkite-${name}-ssh-private";
|
|
|
|
in
|
|
|
|
writeScript "update-${name}-nix.sh" ''
|
|
|
|
#!${stdenv.shell}
|
2019-02-11 06:37:10 +03:00
|
|
|
|
2019-02-13 08:18:19 +03:00
|
|
|
set -euo pipefail
|
2019-02-11 06:37:10 +03:00
|
|
|
|
2020-03-06 16:52:05 +03:00
|
|
|
export PATH="${makeBinPath ([ coreutils curl findutils gawk bash git openssh nix-tools cabal-install nix-prefetch-git ] ++ optional stdenv.isLinux glibc)}"
|
2019-02-11 06:37:10 +03:00
|
|
|
|
2019-02-13 08:18:19 +03:00
|
|
|
${script}
|
2019-02-11 06:37:10 +03:00
|
|
|
|
2019-03-22 04:48:30 +03:00
|
|
|
source ${./git.env}
|
|
|
|
|
2019-02-13 08:18:19 +03:00
|
|
|
echo "Committing changes..."
|
|
|
|
git add .
|
2019-03-22 04:48:30 +03:00
|
|
|
check_staged
|
|
|
|
git commit --message "Automatic update for $(date)"
|
2019-02-11 06:37:10 +03:00
|
|
|
|
2019-03-22 04:48:30 +03:00
|
|
|
use_ssh_key ${sshKey}
|
2019-02-11 06:37:10 +03:00
|
|
|
|
2019-02-13 08:18:19 +03:00
|
|
|
git push ${repoSSH}
|
2019-02-11 06:37:10 +03:00
|
|
|
|
2019-03-22 04:48:30 +03:00
|
|
|
rev=$(git rev-parse HEAD)
|
|
|
|
|
2019-02-13 08:18:19 +03:00
|
|
|
cd ..
|
|
|
|
|
|
|
|
nix-prefetch-git ${repoHTTPS} --rev "$rev" | tee ${name}-src.json
|
|
|
|
''
|