-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
87 lines (72 loc) · 2.82 KB
/
flake.nix
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
76
77
78
79
80
81
82
83
84
85
86
87
{
description = "eearomatics/iluvatar";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let pkgs = nixpkgs.legacyPackages.${system}; in
{
devShells = {
default = pkgs.mkShell {
packages = with pkgs; [
# General dev tools
biome
deno
git
go-task
# Secrets management
gnupg
sops
age
# NodeJS development
nodejs_18
yarn
prisma-engines # Prisma ORM
# Infrastructure-as-Code tools
opentofu
terragrunt
cf-terraforming
(pkgs.writeShellScriptBin
"cftofu"
"cf-terraforming --terraform-binary-path ${pkgs.opentofu}/bin/tofu --provider-registry-hostname $CLOUDFLARE_PROVIDER_REGISTRY_HOSTNAME -t $TF_VAR_cf_api_token $@"
)
(pkgs.writeShellScriptBin
"tofu-mv"
''
${pkgs.opentofu}/bin/tofu state mv $1.$2 $1.$3
find . -type f -iname '*.tf' -exec sed -i "s/$2/$3/g" {} \;
''
)
(pkgs.writeShellScriptBin
"cftofu-import"
"cftofu import $@ | sed 's/terraform/tofu/' | $SHELL"
)
];
env = {
PROJECT_NAME = "iluvatar";
CLOUDFLARE_PROVIDER_REGISTRY_HOSTNAME="registry.opentofu.org";
CLOUDFLARE_TERRAFORM_BINARY_PATH="${pkgs.opentofu}/bin/tofu";
TERRAGRUNT_TFPATH= "${pkgs.opentofu}/bin/tofu";
PRISMA_QUERY_ENGINE_LIBRARY = "${pkgs.prisma-engines}/lib/libquery_engine.node";
PRISMA_QUERY_ENGINE_BINARY = "${pkgs.prisma-engines}/bin/query-engine";
PRISMA_SCHEMA_ENGINE_BINARY = "${pkgs.prisma-engines}/bin/schema-engine";
};
shellHook = ''
echo $ Started devshell for $PROJECT_NAME
echo
echo Prisma has been configured from Nixpkgs
echo
echo Decrypting environment to shell
echo
local rd="$(${pkgs.git}/bin/git rev-parse --show-toplevel)"
if [ ! -f "$rd/.env.dec" ] || [ "$rd/.env.dec" -ot "$rd/.env" ]; then
${pkgs.sops}/bin/sops -d $rd/.env > $rd/.env.dec
fi
source $rd/.env.dec
gpg --keyserver hkp://keys.openpgp.org --refresh-keys [email protected]
'';
};
};
}
);
}