From d3ddf342679dba45e63666d2f21d10c79b59d5c1 Mon Sep 17 00:00:00 2001 From: Ryan Yin Date: Sun, 3 Mar 2024 00:16:14 +0800 Subject: [PATCH] feat: add flake.nix for pulumi --- pulumi/k3s-prod-1/.envrc | 1 + pulumi/k3s-prod-1/flake.lock | 58 ++++++++++++++++++++++++++++++++++++ pulumi/k3s-prod-1/flake.nix | 58 ++++++++++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+) create mode 100644 pulumi/k3s-prod-1/.envrc create mode 100644 pulumi/k3s-prod-1/flake.lock create mode 100644 pulumi/k3s-prod-1/flake.nix diff --git a/pulumi/k3s-prod-1/.envrc b/pulumi/k3s-prod-1/.envrc new file mode 100644 index 00000000..3550a30f --- /dev/null +++ b/pulumi/k3s-prod-1/.envrc @@ -0,0 +1 @@ +use flake diff --git a/pulumi/k3s-prod-1/flake.lock b/pulumi/k3s-prod-1/flake.lock new file mode 100644 index 00000000..59ebad50 --- /dev/null +++ b/pulumi/k3s-prod-1/flake.lock @@ -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 +} diff --git a/pulumi/k3s-prod-1/flake.nix b/pulumi/k3s-prod-1/flake.nix new file mode 100644 index 00000000..340842b2 --- /dev/null +++ b/pulumi/k3s-prod-1/flake.nix @@ -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" + ''; + }; + }); +}