From a668210d896250855408872e51ee42b2e38cc408 Mon Sep 17 00:00:00 2001 From: Dan Boitnott Date: Thu, 3 Oct 2024 11:11:49 -0500 Subject: [PATCH] add(1521) - Add nix flake, justfile, and direnv --- .gitignore | 2 ++ flake.lock | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 50 ++++++++++++++++++++++++++++++++++++++++++++ justfile | 24 +++++++++++++++++++++ 4 files changed, 137 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 justfile diff --git a/.gitignore b/.gitignore index 994c00d19..05584e4e1 100644 --- a/.gitignore +++ b/.gitignore @@ -143,3 +143,5 @@ tags # temp files temp/ +/.direnv/ +/.envrc diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000..a6ef2b286 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1726560853, + "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1727802920, + "narHash": "sha256-HP89HZOT0ReIbI7IJZJQoJgxvB2Tn28V6XS3MNKnfLs=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "27e30d177e57d912d614c88c622dcfdb2e6e6515", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 000000000..26dfe381a --- /dev/null +++ b/flake.nix @@ -0,0 +1,50 @@ +{ + description = "Sceptre development environment"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { + nixpkgs, + flake-utils, + ... + }: + flake-utils.lib.eachDefaultSystem (system: let + pkgs = import nixpkgs { + inherit system; + }; + in { + devShells.default = pkgs.mkShell { + # buildInputs = with pkgs; [ + # poetry + # ]; + packages = with pkgs; [ + nix-search-cli + pre-commit + just + watchexec + + # Make sure nix works within the shell + nixStatic + + # Python + poetry + python3 + + # Other packages needed for compiling python libs + readline + libffi + openssl + glibcLocalesUtf8 + ]; + + shellHook = '' + poetry env use $(which python3) + poetry install + . $(poetry env info -p)/bin/activate + ''; + }; + }); +} diff --git a/justfile b/justfile new file mode 100644 index 000000000..46e81c263 --- /dev/null +++ b/justfile @@ -0,0 +1,24 @@ +_default: + @just --list + +# Enable direnv +enable-direnv: + #!/usr/bin/env bash + set -euo pipefail + [ -f ".envrc" ] && echo ".envrc already exists" && exit + echo "use flake" >.envrc + +# Re-run recipe CMD whenever files change +watch CMD *ARGS: + watchexec -c -r -d 500ms --print-events -- just {{CMD}} {{ARGS}} +alias w := watch + +# Run tests via tox +test *ARGS: + poetry run tox {{ARGS}} +alias t := test + +# Run a single test +a-test TEST *ARGS: + poetry run pytest -ssv {{TEST}} {{ARGS}} +alias tt := a-test