nix/gitlab-ci: restructure to work better with multiple architectures

This commit is contained in:
Luke Granger-Brown 2023-01-17 22:03:14 +00:00
parent 0583eb2f07
commit 493d30ff44

View file

@ -16,15 +16,12 @@ let
allow_failure = true; allow_failure = true;
tags = [ "macos" ]; tags = [ "macos" ];
}; };
in { linux = system: {
stages = [ "build" "deploy-mach" "deploy-other" ];
nixCache = {
stage = "build"; stage = "build";
image = "nixos/nix:latest"; image = "nixos/nix:latest";
script = [ script = [
"nix run -f ./ third_party.nixpkgs.bash -c ./hack/populate_secrets.sh" "nix run -f ./ third_party.nixpkgs.bash -c ./hack/populate_secrets.sh"
"nix build -v -f ./ci-root.nix --substituters \"https://cache.nixos.org/ s3://lukegb-nix-cache?endpoint=storage.googleapis.com&trusted=1\"" "nix build -v -f ./ci-root.nix --argstr system ${system} --substituters \"https://cache.nixos.org/ s3://lukegb-nix-cache?endpoint=storage.googleapis.com&trusted=1\""
"GOOGLE_APPLICATION_CREDENTIALS=$HOME/sa.json nix run -f ./ go.nix.bcacheup -c bcacheup --cache_url gs://lukegb-nix-cache ./result" "GOOGLE_APPLICATION_CREDENTIALS=$HOME/sa.json nix run -f ./ go.nix.bcacheup -c bcacheup --cache_url gs://lukegb-nix-cache ./result"
"cat ./result/other-systemPathJSON > systems.json" "cat ./result/other-systemPathJSON > systems.json"
]; ];
@ -34,13 +31,17 @@ let
}; };
tags = [ "cacher" ]; tags = [ "cacher" ];
}; };
in {
stages = [ "build" "deploy-mach" "deploy-other" ];
nixCacheMacOSIntel = macOS "x86_64-darwin"; nixCache-x86_64-linux = linux "x86_64-linux";
nixCacheMacOSARM = macOS "aarch64-darwin"; nixCache-aarch64-linux = linux "aarch64-linux";
nixCache-x86_64-darwin = macOS "x86_64-darwin";
nixCache-aarch64-darwin = macOS "aarch64-darwin";
lukegbcom = { lukegbcom = {
stage = "deploy-other"; stage = "deploy-other";
needs = [{ job = "nixCache"; artifacts = false; }]; needs = [{ job = "nixCache-x86_64-linux"; artifacts = false; }];
tags = [ "cacher" ]; tags = [ "cacher" ];
only.refs = [ "branch/default" ]; only.refs = [ "branch/default" ];
@ -55,7 +56,7 @@ let
deployMachs = lib.filterAttrs (name: cfg: cfg.config.my.deploy.enable) depot.ops.nixos.systemConfigs; deployMachs = lib.filterAttrs (name: cfg: cfg.config.my.deploy.enable) depot.ops.nixos.systemConfigs;
deployStage = machName: mach: ({ deployStage = machName: mach: ({
stage = "deploy-mach"; stage = "deploy-mach";
needs = [{ job = "nixCache"; artifacts = true; }]; needs = [{ job = "nixCache-${mach.config.my.systemType}"; artifacts = true; }];
tags = [ "deployer" ]; tags = [ "deployer" ];
resource_group = machName; resource_group = machName;