feat: add flake.nix for pulumi

This commit is contained in:
Ryan Yin
2024-03-03 00:16:14 +08:00
parent f141b49dc3
commit d3ddf34267
3 changed files with 117 additions and 0 deletions

1
pulumi/k3s-prod-1/.envrc Normal file
View File

@@ -0,0 +1 @@
use flake

58
pulumi/k3s-prod-1/flake.lock generated Normal file
View File

@@ -0,0 +1,58 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1707956935,
"narHash": "sha256-ZL2TrjVsiFNKOYwYQozpbvQSwvtV/3Me7Zwhmdsfyu4=",
"path": "/nix/store/m9s94alic7s2r6v47p7lwfj58ibc076a-source",
"rev": "a4d4fe8c5002202493e87ec8dbc91335ff55552c",
"type": "path"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"utils": "utils"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1709126324,
"narHash": "sha256-q6EQdSeUZOG26WelxqkmR7kArjgWCdw5sfJVHPH/7j8=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "d465f4819400de7c8d874d50b982301f28a84605",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

View File

@@ -0,0 +1,58 @@
{
description = "Python venv development template";
inputs = {
utils.url = "github:numtide/flake-utils";
};
outputs = {
self,
nixpkgs,
utils,
...
}:
utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {inherit system;};
in {
devShells.default = pkgs.mkShell {
name = "pulumi-venv";
venvDir = "./venv";
buildInputs = with pkgs; [
# A Python interpreter including the 'venv' module is required to bootstrap
# the environment.
python3Packages.python
# This executes some shell code to initialize a venv in $venvDir before
# dropping into the shell
python3Packages.venvShellHook
# pulumi related packages
pulumi
pulumictl
tf2pulumi
crd2pulumi
pulumiPackages.pulumi-random
pulumiPackages.pulumi-command
pulumiPackages.pulumi-aws-native
pulumiPackages.pulumi-language-go
pulumiPackages.pulumi-language-python
pulumiPackages.pulumi-language-nodejs
];
# Run this command, only after creating the virtual environment
postVenvCreation = ''
unset SOURCE_DATE_EPOCH
pip install -r requirements.txt
'';
# Now we can execute any commands within the virtual environment.
# This is optional and can be left out to run pip manually.
postShellHook = ''
# allow pip to install wheels
unset SOURCE_DATE_EPOCH
# fix `libstdc++.so.6 => not found`
LD_LIBRARY_PATH="${pkgs.stdenv.cc.cc.lib}/lib"
'';
};
});
}