From 90fcc7be84bad84a3906eccbb93dfd4ace29a448 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 24 Jan 2019 23:25:12 +0100 Subject: [PATCH] Rsync channel redirects to nixos.org --- default.nix | 2 +- mirror-nixos-branch.pl | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/default.nix b/default.nix index e9d1bc8..faecc41 100644 --- a/default.nix +++ b/default.nix @@ -27,7 +27,7 @@ stdenv.mkDerivation { -lsqlite3 cp ${./mirror-nixos-branch.pl} $out/bin/mirror-nixos-branch - wrapProgram $out/bin/mirror-nixos-branch --set PERL5LIB $PERL5LIB --prefix PATH : ${wget}/bin:${git}/bin:${nix}/bin:${gnutar}/bin:${xz}/bin:$out/bin + wrapProgram $out/bin/mirror-nixos-branch --set PERL5LIB $PERL5LIB --prefix PATH : ${wget}/bin:${git}/bin:${nix}/bin:${gnutar}/bin:${xz}/bin:${rsync}/bin:${openssh}/bin:$out/bin patchShebangs $out/bin ''; diff --git a/mirror-nixos-branch.pl b/mirror-nixos-branch.pl index 9c37fc6..d1986f4 100755 --- a/mirror-nixos-branch.pl +++ b/mirror-nixos-branch.pl @@ -25,8 +25,9 @@ my $channelDirRel = $channelName eq "nixpkgs-unstable" ? "nixpkgs" : "$1/$2"; # Configuration. -my $channelsDir = "/data/releases/channels"; -my $filesCache = "/data/releases/nixos-files.sqlite"; +my $TMPDIR = $ENV{'TMPDIR'} // "/tmp"; +my $channelsDir = "/home/hydra-mirror/channels"; +my $filesCache = "${TMPDIR}/nixos-files.sqlite"; my $bucketName = "nix-releases"; $ENV{'GIT_DIR'} = "/home/hydra-mirror/nixpkgs-channels"; @@ -72,16 +73,17 @@ my $rev = $evalInfo->{jobsetevalinputs}->{nixpkgs}->{revision} or die; print STDERR "release is ‘$releaseName’ (build $releaseId), eval is $evalId, prefix is $releasePrefix, Git commit is $rev\n"; # Guard against the channel going back in time. -my @releaseUrl = split(/\//, read_file("$channelsDir/$channelName", err_mode => 'quiet') // ""); -my $curRelease = pop @releaseUrl; +my @curReleaseUrl = split(/\//, read_file("$channelsDir/$channelName", err_mode => 'quiet') // ""); +my $curRelease = pop @curReleaseUrl; my $d = `NIX_PATH= nix-instantiate --eval -E "builtins.compareVersions (builtins.parseDrvName \\"$curRelease\\").version (builtins.parseDrvName \\"$releaseName\\").version"`; chomp $d; die "channel would go back in time from $curRelease to $releaseName, bailing out\n" if $d == 1; +exit if $d == 0; if ($bucket->head_key("$releasePrefix")) { print STDERR "release already exists\n"; } else { - my $tmpDir = "/data/releases/tmp/release-$channelName/$releaseName"; + my $tmpDir = "$TMPDIR/release-$channelName/$releaseName"; File::Path::make_path($tmpDir); write_file("$tmpDir/src-url", $evalUrl); @@ -226,3 +228,6 @@ system("git remote update origin >&2") == 0 or die; system("git push channels $rev:refs/heads/$channelName >&2") == 0 or die; flock($lockfile, LOCK_UN) or die "cannot release channels lock\n"; + +# Upload to nixos.org. +system("rsync -avx $channelsDir/ hydra-mirror\@nixos.org:/releases/channels/") == 0 or die;