tvl-depot/users/flokli/archeology/default.nix
Florian Klink c93086848f feat(users/flokli/archeology): add AWS config to shell
This allows using awscli inside a shell.

Clickhouse AWS SSO integration still seems broken unfortunately, even
with https://github.com/ClickHouse/ClickHouse/pull/54347 included in
our bump - it seems it's coming up with another token file path than the
AWS SDK:

> SSOCredentialsProvider: Unable to open token file on path: /home/flokli/.aws/sso/cache/da39a3ee5e6b4b0d3255bfef95601890afd80709.json

This is the sha1sum of the sso_start_url, not the sha1sum of the
session-name (nixos / f2f059b8b7298f1ad52636d67cef8b719aa83bf5).

Change-Id: Ia1bdec03c4f269a7415c42c90c1f4fd3d928f770
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10012
Reviewed-by: edef <edef@edef.eu>
Tested-by: BuildkiteCI
2023-11-12 22:43:26 +00:00

51 lines
1.5 KiB
Nix

{ depot, pkgs, ... }:
let
clickhouseConfigAWS = builtins.toFile "clickhouse-local.xml" ''
<clickhouse>
<s3>
<use_environment_credentials>true</use_environment_credentials>
</s3>
</clickhouse>
'';
# clickhouse has a very odd AWS config concept.
# Configure it to be a bit more sane.
clickhoseLocalFixedAWS = pkgs.runCommand "clickhouse-local-fixed"
{
nativeBuildInputs = [ pkgs.makeWrapper ];
} ''
mkdir -p $out/bin
makeWrapper ${pkgs.clickhouse}/bin/clickhouse-local $out/bin/clickhouse-local \
--append-flags "-C ${clickhouseConfigAWS}"
'';
in
depot.nix.readTree.drvTargets {
inherit clickhoseLocalFixedAWS;
parse-bucket-logs = pkgs.runCommand "archeology-parse-bucket-logs"
{
nativeBuildInputs = [ pkgs.makeWrapper ];
} ''
mkdir -p $out/bin
makeWrapper ${(pkgs.writers.writeRust "parse-bucket-logs-unwrapped" {} ./parse_bucket_logs.rs)} $out/bin/archeology-parse-bucket-logs \
--prefix PATH : ${pkgs.lib.makeBinPath [ clickhoseLocalFixedAWS ]}
'';
shell = pkgs.mkShell {
name = "archeology-shell";
packages = with pkgs; [ awscli2 clickhoseLocalFixedAWS rust-analyzer rustc rustfmt ];
AWS_PROFILE = "sso";
AWS_CONFIG_FILE = pkgs.writeText "aws-config" ''
[sso-session nixos]
sso_region = eu-north-1
sso_start_url = https://nixos.awsapps.com/start
sso_registration_scopes = sso:account:access
[profile "sso"]
sso_session = nixos
sso_account_id = 080433136561
sso_role_name = archeologist
'';
};
}