Skip to content

Instantly share code, notes, and snippets.

@WolfangAukang
Created September 28, 2022 17:42
Show Gist options
  • Save WolfangAukang/f54fdc8c04a9caa3e7d89bc7234ea3c2 to your computer and use it in GitHub Desktop.
Save WolfangAukang/f54fdc8c04a9caa3e7d89bc7234ea3c2 to your computer and use it in GitHub Desktop.
flake.nix for AWS SMTP script

This is a simple flake.nix for the SMTP key generator.

Steps: 1- Grab the Python script from here. Name it as main.py. 2- Set the secret key with SECRET_KEY=”insert_secret_key”. 3- Set the region with REGION=region-code-# (us-east-1, ca-central-1, etc…). 3- Run nix run .# -- $SECRET_KEY $REGION.

{
description = "SMTP Key Script";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, utils }:
utils.lib.eachDefaultSystem (system:
let
name = "smtp-generator";
pkgs = import nixpkgs {
inherit system;
};
inherit (pkgs) python3 mkShell writeShellScript;
inherit (utils) lib;
dependencies = [ python3 ];
in rec {
legacyPackages = pkgs system;
packages."${name}" = python3.pkgs.buildPythonPackage {
name = name;
src = ./.;
format = "other";
installPhase = ''
install -D -t $out/bin main.py
'';
};
defaultPackage = self.packages.${system}.${name};
apps."${name}" = lib.mkApp {
drv = packages.${name};
exePath = "/bin/main.py";
};
defaultApp = apps.${name};
devShell = mkShell {
buildInputs = dependencies;
};
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment