2023-11-11 11:08:02 +01:00
|
|
|
{ depot, pkgs, ... }:
|
|
|
|
|
2023-11-11 11:43:53 +01:00
|
|
|
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.
|
2024-05-12 02:20:25 +02:00
|
|
|
clickhouseLocalFixedAWS = pkgs.runCommand "clickhouse-local-fixed"
|
2023-11-11 11:43:53 +01:00
|
|
|
{
|
|
|
|
nativeBuildInputs = [ pkgs.makeWrapper ];
|
|
|
|
} ''
|
|
|
|
mkdir -p $out/bin
|
|
|
|
makeWrapper ${pkgs.clickhouse}/bin/clickhouse-local $out/bin/clickhouse-local \
|
|
|
|
--append-flags "-C ${clickhouseConfigAWS}"
|
|
|
|
'';
|
|
|
|
in
|
|
|
|
|
2023-11-11 11:08:02 +01:00
|
|
|
depot.nix.readTree.drvTargets {
|
2024-05-12 02:20:25 +02:00
|
|
|
inherit clickhouseLocalFixedAWS;
|
2023-11-11 11:08:02 +01:00
|
|
|
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 \
|
2024-05-12 02:20:25 +02:00
|
|
|
--prefix PATH : ${pkgs.lib.makeBinPath [ clickhouseLocalFixedAWS ]}
|
2023-11-11 11:08:02 +01:00
|
|
|
'';
|
2023-11-11 11:12:26 +01:00
|
|
|
|
|
|
|
shell = pkgs.mkShell {
|
|
|
|
name = "archeology-shell";
|
2024-05-12 02:20:25 +02:00
|
|
|
packages = with pkgs; [ awscli2 clickhouseLocalFixedAWS rust-analyzer rustc rustfmt ];
|
2023-11-12 17:58:31 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
'';
|
2023-11-11 11:12:26 +01:00
|
|
|
};
|
2023-11-11 11:08:02 +01:00
|
|
|
}
|