2021-03-28 15:27:46 +00:00
|
|
|
# SPDX-FileCopyrightText: 2020 Luke Granger-Brown <depot@lukegb.com>
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
|
|
{ depot, lib, pkgs, ... }:
|
|
|
|
let
|
2021-09-05 09:24:03 +00:00
|
|
|
cfg = let
|
|
|
|
macOS = system: {
|
|
|
|
stage = "build";
|
|
|
|
image = "nixos/nix:latest";
|
|
|
|
script = [
|
|
|
|
"nix run -f ./ third_party.nixpkgs.bash -c ./hack/populate_secrets.sh"
|
2023-01-18 00:20:27 +00:00
|
|
|
"nix build -v -f ./ci-root.nix --system ${system} --argstr system ${system} --substituters \"https://cache.nixos.org/ s3://lukegb-nix-cache?endpoint=storage.googleapis.com&trusted=1\""
|
2021-09-05 09:24:03 +00:00
|
|
|
"nix copy -v --to 's3://lukegb-nix-cache?endpoint=storage.googleapis.com' ./result"
|
|
|
|
];
|
2023-03-12 14:00:42 +00:00
|
|
|
timeout = "6h";
|
2021-09-05 09:24:03 +00:00
|
|
|
allow_failure = true;
|
|
|
|
tags = [ "macos" ];
|
|
|
|
};
|
2023-03-12 14:00:42 +00:00
|
|
|
linux-eval = {
|
2021-03-28 15:27:46 +00:00
|
|
|
stage = "build";
|
|
|
|
image = "nixos/nix:latest";
|
|
|
|
script = [
|
|
|
|
"nix run -f ./ third_party.nixpkgs.bash -c ./hack/populate_secrets.sh"
|
2023-03-12 14:00:42 +00:00
|
|
|
"nix-instantiate ./ci-root-linux.nix --option substituters \"https://cache.nixos.org/ s3://lukegb-nix-cache?endpoint=storage.googleapis.com&trusted=1\" > drv-name"
|
2023-03-12 14:28:16 +00:00
|
|
|
"cat drv-name"
|
2023-03-12 14:00:42 +00:00
|
|
|
"ln -s $(cat drv-name) ./result"
|
|
|
|
"nix run -f ./ go.nix.bcacheup -c bcacheup --cache_url vaultgs://lukegb-nix-cache --vault_addr unix:///run/tokend/sock --vault_token_source gcp/roleset/binary-cache-deployer/token ./result"
|
|
|
|
];
|
|
|
|
artifacts = {
|
|
|
|
paths = [ "drv-name" ];
|
|
|
|
expire_in = "30 days";
|
|
|
|
};
|
|
|
|
tags = [ "cacher" ];
|
|
|
|
};
|
|
|
|
linux-combined = {
|
|
|
|
stage = "build";
|
|
|
|
image = "nixos/nix:latest";
|
|
|
|
needs = [{ job = "nixCache-linux-eval"; artifacts = true; }];
|
|
|
|
script = [
|
2023-03-12 15:04:59 +00:00
|
|
|
"for n in 1 2 3 4 5; do echo attempt $n; nix-store --realise $(cat drv-name) --option substituters \"https://cache.nixos.org/ s3://lukegb-nix-cache?endpoint=storage.googleapis.com&trusted=1\" --indirect --add-root ./result && break; done"
|
2023-03-12 14:28:16 +00:00
|
|
|
"readlink -f ./result"
|
2023-02-25 23:47:36 +00:00
|
|
|
"nix run -f ./ go.nix.bcacheup -c bcacheup --cache_url vaultgs://lukegb-nix-cache --vault_addr unix:///run/tokend/sock --vault_token_source gcp/roleset/binary-cache-deployer/token ./result"
|
2023-03-12 14:00:42 +00:00
|
|
|
"cat ./result/combined-systems > systems.json"
|
2021-03-28 15:27:46 +00:00
|
|
|
];
|
2023-03-12 14:00:42 +00:00
|
|
|
timeout = "6h";
|
2021-03-28 15:27:46 +00:00
|
|
|
artifacts = {
|
2023-04-02 22:35:20 +00:00
|
|
|
paths = [ "systems.json" "hack/populate_secrets.sh" "hack/deploy.sh" ];
|
2021-03-28 15:27:46 +00:00
|
|
|
expire_in = "30 days";
|
|
|
|
};
|
|
|
|
tags = [ "cacher" ];
|
|
|
|
};
|
2023-01-17 22:03:14 +00:00
|
|
|
in {
|
|
|
|
stages = [ "build" "deploy-mach" "deploy-other" ];
|
2021-04-09 20:03:51 +00:00
|
|
|
|
2023-03-12 14:00:42 +00:00
|
|
|
nixCache-linux-eval = linux-eval;
|
|
|
|
nixCache-linux = linux-combined;
|
2023-01-17 22:03:14 +00:00
|
|
|
nixCache-x86_64-darwin = macOS "x86_64-darwin";
|
|
|
|
nixCache-aarch64-darwin = macOS "aarch64-darwin";
|
2022-04-05 21:04:32 +00:00
|
|
|
|
2023-02-10 21:01:45 +00:00
|
|
|
flipperzero-firmware = {
|
|
|
|
stage = "deploy-other";
|
2023-03-12 14:00:42 +00:00
|
|
|
needs = [{ job = "nixCache-linux"; artifacts = false; }];
|
2023-02-10 21:01:45 +00:00
|
|
|
tags = [ "cacher" ];
|
|
|
|
only.refs = [ "branch/default" ];
|
|
|
|
|
|
|
|
script = ''
|
|
|
|
export NIX_PATH=nixpkgs=$(readlink -f third_party/nixpkgs)
|
|
|
|
$(nix-build -A nix.pkgs.flipperzero-firmware.upload)/bin/upload-f0
|
|
|
|
'';
|
|
|
|
};
|
2022-04-05 21:04:32 +00:00
|
|
|
lukegbcom = {
|
2022-05-17 00:38:27 +00:00
|
|
|
stage = "deploy-other";
|
2023-03-12 14:00:42 +00:00
|
|
|
needs = [{ job = "nixCache-linux"; artifacts = false; }];
|
2022-04-05 21:04:32 +00:00
|
|
|
tags = [ "cacher" ];
|
|
|
|
only.refs = [ "branch/default" ];
|
|
|
|
|
2022-04-05 21:09:21 +00:00
|
|
|
script = ''
|
|
|
|
export NIX_PATH=nixpkgs=$(readlink -f third_party/nixpkgs)
|
|
|
|
cd web/lukegbcom
|
|
|
|
./deploy.sh
|
|
|
|
'';
|
2022-04-05 21:04:32 +00:00
|
|
|
};
|
2022-04-05 21:13:21 +00:00
|
|
|
} // (lib.mapAttrs deployStage deployMachs);
|
2021-03-28 15:27:46 +00:00
|
|
|
|
|
|
|
deployMachs = lib.filterAttrs (name: cfg: cfg.config.my.deploy.enable) depot.ops.nixos.systemConfigs;
|
2021-05-22 22:58:25 +00:00
|
|
|
deployStage = machName: mach: ({
|
2022-05-17 00:38:27 +00:00
|
|
|
stage = "deploy-mach";
|
2023-03-12 14:00:42 +00:00
|
|
|
needs = [{ job = "nixCache-linux"; artifacts = true; }];
|
2021-03-28 15:27:46 +00:00
|
|
|
tags = [ "deployer" ];
|
|
|
|
|
|
|
|
resource_group = machName;
|
|
|
|
script = ''./hack/deploy.sh "${machName}" "${mach.config.my.deploy.args}"'';
|
|
|
|
environment = {
|
|
|
|
name = machName;
|
|
|
|
};
|
2023-04-02 22:35:20 +00:00
|
|
|
variables = {
|
|
|
|
GIT_STRATEGY = "none";
|
|
|
|
};
|
2021-05-22 22:58:25 +00:00
|
|
|
allow_failure = true;
|
2022-03-20 10:26:56 +00:00
|
|
|
|
|
|
|
only.refs = [ "branch/default" ];
|
2021-05-22 22:58:25 +00:00
|
|
|
} // lib.optionalAttrs (!mach.config.my.deploy.enable) {
|
|
|
|
when = "manual";
|
|
|
|
});
|
2021-03-28 15:27:46 +00:00
|
|
|
|
|
|
|
format = pkgs.formats.yaml { };
|
|
|
|
configFile = format.generate ".gitlab-ci.yml" cfg;
|
|
|
|
in
|
|
|
|
configFile
|