forked from the-distro/infra
add staging sync services
This commit is contained in:
parent
420e6915df
commit
b6375b8294
|
@ -47,12 +47,13 @@
|
||||||
};
|
};
|
||||||
bagel.nixpkgs.one-way-sync =
|
bagel.nixpkgs.one-way-sync =
|
||||||
let
|
let
|
||||||
mkNixpkgsJob = { timer, branchName, localRefspec ? null }: {
|
mkNixpkgsJob = { timer, fromRefspec, localRefspec ? fromRefspec }: {
|
||||||
name = "nixpkgs-${branchName}";
|
|
||||||
fromUri = "https://github.com/NixOS/nixpkgs";
|
fromUri = "https://github.com/NixOS/nixpkgs";
|
||||||
fromRefspec = branchName;
|
inherit fromRefspec localRefspec timer;
|
||||||
localRefspec = if localRefspec != null then localRefspec else branchName;
|
};
|
||||||
inherit timer;
|
mkLocalJob = { timer, fromRefspec, localRefspec }: {
|
||||||
|
fromUri = "https://cl.forkos.org/nixpkgs";
|
||||||
|
inherit fromRefspec localRefspec timer;
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
@ -61,48 +62,59 @@
|
||||||
pushUrl = "ssh://ows_bot@cl.forkos.org:29418/nixpkgs";
|
pushUrl = "ssh://ows_bot@cl.forkos.org:29418/nixpkgs";
|
||||||
deployKeyPath = config.age.secrets.ows-deploy-key.path;
|
deployKeyPath = config.age.secrets.ows-deploy-key.path;
|
||||||
|
|
||||||
branches."refs/heads/main" = mkNixpkgsJob {
|
# Sync main -> staging-next -> staging
|
||||||
|
branches."main-to-staging-next" = mkLocalJob {
|
||||||
timer = "hourly";
|
timer = "hourly";
|
||||||
branchName = "master";
|
fromRefspec = "main";
|
||||||
|
localRefspec = "staging-next";
|
||||||
|
};
|
||||||
|
branches."staging-next-to-staging" = mkLocalJob {
|
||||||
|
timer = "hourly";
|
||||||
|
fromRefspec = "staging-next";
|
||||||
|
localRefspec = "staging";
|
||||||
|
};
|
||||||
|
|
||||||
|
# Sync nixpkgs -> fork
|
||||||
|
branches."nixpkgs-master" = mkNixpkgsJob {
|
||||||
|
timer = "hourly";
|
||||||
|
fromRefspec = "master";
|
||||||
localRefspec = "main";
|
localRefspec = "main";
|
||||||
};
|
};
|
||||||
|
|
||||||
branches."refs/heads/staging" = mkNixpkgsJob {
|
branches."nixpkgs-staging" = mkNixpkgsJob {
|
||||||
timer = "hourly";
|
timer = "hourly";
|
||||||
branchName = "staging";
|
fromRefspec = "staging";
|
||||||
};
|
};
|
||||||
|
|
||||||
branches."refs/heads/release-24.05" = mkNixpkgsJob {
|
branches."nixpkgs-release-24.05" = mkNixpkgsJob {
|
||||||
timer = "hourly";
|
timer = "hourly";
|
||||||
branchName = "release-24.05";
|
fromRefspec = "release-24.05";
|
||||||
};
|
};
|
||||||
|
|
||||||
branches."refs/heads/staging-24.05" = mkNixpkgsJob {
|
branches."nixpkgs-staging-24.05" = mkNixpkgsJob {
|
||||||
timer = "hourly";
|
timer = "hourly";
|
||||||
branchName = "staging-24.05";
|
fromRefspec = "staging-24.05";
|
||||||
};
|
};
|
||||||
|
|
||||||
branches."refs/heads/release-23.11" = mkNixpkgsJob {
|
branches."nixpkgs-release-23.11" = mkNixpkgsJob {
|
||||||
timer = "hourly";
|
timer = "hourly";
|
||||||
branchName = "release-23.11";
|
fromRefspec = "release-23.11";
|
||||||
};
|
};
|
||||||
|
|
||||||
branches."refs/heads/staging-23.11" = mkNixpkgsJob {
|
branches."nixpkgs-staging-23.11" = mkNixpkgsJob {
|
||||||
timer = "hourly";
|
timer = "hourly";
|
||||||
branchName = "staging-23.11";
|
fromRefspec = "staging-23.11";
|
||||||
};
|
};
|
||||||
|
|
||||||
# Testing jobs for personal sandbox branches
|
# Testing jobs for personal sandbox branches
|
||||||
branches."refs/heads/sandbox/raito/raito-unstable-small" = {
|
branches."raito-unstable-sync" = {
|
||||||
name = "raito-unstable-sync";
|
|
||||||
fromUri = "https://github.com/NixOS/nixpkgs";
|
fromUri = "https://github.com/NixOS/nixpkgs";
|
||||||
fromRefspec = "nixos-unstable-small";
|
fromRefspec = "nixos-unstable-small";
|
||||||
localRefspec = "sandbox/raito/raito-unstable-small";
|
localRefspec = "sandbox/raito/raito-unstable-small";
|
||||||
timer = "*-*-* 12:00:00";
|
timer = "*-*-* 12:00:00";
|
||||||
};
|
};
|
||||||
|
|
||||||
branches."refs/heads/sandbox/raito/raito-nixos-24.05" = {
|
branches."raito-release-sync" = {
|
||||||
name = "raito-release-sync";
|
|
||||||
fromUri = "https://github.com/NixOS/nixpkgs";
|
fromUri = "https://github.com/NixOS/nixpkgs";
|
||||||
fromRefspec = "nixos-24.05";
|
fromRefspec = "nixos-24.05";
|
||||||
localRefspec = "sandbox/raito/raito-nixos-24.05";
|
localRefspec = "sandbox/raito/raito-nixos-24.05";
|
||||||
|
|
|
@ -3,7 +3,7 @@ let
|
||||||
cfg = config.bagel.nixpkgs.one-way-sync;
|
cfg = config.bagel.nixpkgs.one-way-sync;
|
||||||
inherit (lib) mkIf mkOption mkEnableOption types mapAttrs';
|
inherit (lib) mkIf mkOption mkEnableOption types mapAttrs';
|
||||||
|
|
||||||
mkSyncTimer = { name, timer, ... }: {
|
mkSyncTimer = name: { timer, ... }: {
|
||||||
wantedBy = [ "timers.target" ];
|
wantedBy = [ "timers.target" ];
|
||||||
|
|
||||||
timerConfig = {
|
timerConfig = {
|
||||||
|
@ -12,7 +12,7 @@ let
|
||||||
Unit = "ows-${name}.service";
|
Unit = "ows-${name}.service";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
mkSyncService = targetRef: { name, fromUri, fromRefspec, localRefspec, ... }: {
|
mkSyncService = name: { fromUri, fromRefspec, localRefspec, ... }: {
|
||||||
path = [ pkgs.gitFull pkgs.openssh pkgs.lix ];
|
path = [ pkgs.gitFull pkgs.openssh pkgs.lix ];
|
||||||
script = ''
|
script = ''
|
||||||
set -xe
|
set -xe
|
||||||
|
@ -25,7 +25,7 @@ let
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd /var/lib/onewaysync/nixpkgs
|
cd /var/lib/onewaysync/nixpkgs
|
||||||
echo "Syncing ${fromUri}:${fromRefspec} to /var/lib/onewaysync/nixpkgs:${targetRef}"
|
echo "Syncing ${fromUri}:${fromRefspec} to ${cfg.pushUrl}:refs/heads/${localRefspec}"
|
||||||
echo "Current ref: $EXPECTED_REF"
|
echo "Current ref: $EXPECTED_REF"
|
||||||
git worktree add -f "$RUNTIME_DIRECTORY"/${name} refs/remotes/origin/${localRefspec}
|
git worktree add -f "$RUNTIME_DIRECTORY"/${name} refs/remotes/origin/${localRefspec}
|
||||||
cd "$RUNTIME_DIRECTORY"/${name}
|
cd "$RUNTIME_DIRECTORY"/${name}
|
||||||
|
@ -43,7 +43,7 @@ let
|
||||||
# Do not allow auto-merging a staging iteration
|
# Do not allow auto-merging a staging iteration
|
||||||
test "$OLD_STDENV" = "$NEW_STDENV"
|
test "$OLD_STDENV" = "$NEW_STDENV"
|
||||||
'' + ''
|
'' + ''
|
||||||
GIT_SSH_COMMAND='ssh -i ${cfg.deployKeyPath}' git push ${cfg.pushUrl} HEAD:${targetRef}
|
GIT_SSH_COMMAND='ssh -i ${cfg.deployKeyPath}' git push ${cfg.pushUrl} HEAD:refs/heads/${localRefspec}
|
||||||
'';
|
'';
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
User = "git";
|
User = "git";
|
||||||
|
@ -120,12 +120,12 @@ in
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
systemd.timers = mapAttrs' (name: value: {
|
systemd.timers = mapAttrs' (name: value: {
|
||||||
name = "ows-${value.name}";
|
name = "ows-${name}";
|
||||||
value = mkSyncTimer value;
|
value = mkSyncTimer name value;
|
||||||
}) cfg.branches;
|
}) cfg.branches;
|
||||||
|
|
||||||
systemd.services = mapAttrs' (name: value: {
|
systemd.services = mapAttrs' (name: value: {
|
||||||
name = "ows-${value.name}";
|
name = "ows-${name}";
|
||||||
value = mkSyncService name value;
|
value = mkSyncService name value;
|
||||||
}) cfg.branches;
|
}) cfg.branches;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue