-
Notifications
You must be signed in to change notification settings - Fork 1
/
Justfile
75 lines (64 loc) · 2.43 KB
/
Justfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
set shell := ["nu", "-c"]
set positional-arguments
AWS_REGION := 'eu-central-1'
downstreamPath := env_var_or_default("DOWNSTREAM_PATH","no-path-given")
templatePath := 'templates/cardano-parts-project'
# List all just recipes available
default:
@just --list
# Diff compare a downstream file against a cardano-parts template file
downstream-diff FILE *ARGS:
#!/usr/bin/env bash
set -euo pipefail
if ! [ -f "{{templatePath}}/{{FILE}}" ]; then
FILE="<(echo '')"
else
FILE="{{templatePath}}/{{FILE}}"
fi
if [ "{{downstreamPath}}" = "no-path-given" ]; then
echo "No downstream comparison path has been given. Please set the DOWNSTREAM_PATH environment variable and try again."
exit 1
else
DWN_FILE="{{downstreamPath}}/{{FILE}}"
DWN_NAME="$DWN_FILE"
fi
eval "icdiff -L \"{{templatePath}}/{{FILE}}\" -L \"$DWN_NAME\" {{ARGS}} $FILE $DWN_FILE"
# Patch a downstream file into a cardano-parts template file
downstream-patch FILE:
#!/usr/bin/env bash
set -euo pipefail
if git status --porcelain "{{templatePath}}/{{FILE}}" | grep -q "{{templatePath}}/{{FILE}}"; then
echo "Git file {{templatePath}}/{{FILE}} is dirty. Please revert or commit changes to clean state and try again."
exit 1
fi
if [ "{{downstreamPath}}" = "no-path-given" ]; then
echo "No downstream comparison path has been given. Please set the DOWNSTREAM_PATH environment variable and try again."
exit 1
else
DWN_FILE="{{downstreamPath}}/{{FILE}}"
fi
PATCH_FILE=$(eval "diff -Naru \"{{templatePath}}/{{FILE}}\" $DWN_FILE || true")
patch "{{templatePath}}/{{FILE}}" < <(echo "$PATCH_FILE")
git add -p "{{templatePath}}/{{FILE}}"
# Standard code lint
lint:
deadnix -f
statix check
# Show nix flake details
show-flake *ARGS:
nix flake show --allow-import-from-derivation {{ARGS}}
# Update the aws ec2 flakeModule spec
update-aws-ec2-spec AWS_PROFILE region="eu-central-1":
#!/usr/bin/env nu
# To describe instance types, any valid aws profile can be provided
# Default region for specs will be eu-central-1 which provides ~600 machine defns
let spec = (
do -c { aws ec2 --profile {{AWS_PROFILE}} --region {{region}} describe-instance-types }
| from json
| get InstanceTypes
| select InstanceType MemoryInfo VCpuInfo
| reject VCpuInfo.ValidCores? VCpuInfo.ValidThreadsPerCore?
| sort-by InstanceType
)
mkdir flakeModules/aws/
{InstanceTypes: $spec} | save --force flakeModules/aws/ec2-spec.json