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.
|
|
|
|
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
|
|
|
|
|
2023-11-11 11:08:02 +01:00
|
|
|
depot.nix.readTree.drvTargets {
|
2023-11-11 11:43:53 +01:00
|
|
|
inherit clickhoseLocalFixedAWS;
|
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 \
|
2023-11-11 11:43:53 +01:00
|
|
|
--prefix PATH : ${pkgs.lib.makeBinPath [ clickhoseLocalFixedAWS ]}
|
2023-11-11 11:08:02 +01:00
|
|
|
'';
|
2023-11-11 11:12:26 +01:00
|
|
|
|
|
|
|
shell = pkgs.mkShell {
|
|
|
|
name = "archeology-shell";
|
2023-11-12 17:58:31 +01:00
|
|
|
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
|
|
|
|
'';
|
2023-11-11 11:12:26 +01:00
|
|
|
};
|
2023-11-11 11:08:02 +01:00
|
|
|
}
|