Skip to content

Commit

Permalink
add(1521) - Add nix flake, justfile, and direnv
Browse files Browse the repository at this point in the history
  • Loading branch information
dboitnot committed Oct 3, 2024
1 parent 12eb4d6 commit a668210
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,5 @@ tags

# temp files
temp/
/.direnv/
/.envrc
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 50 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -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
'';
};
});
}
24 changes: 24 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a668210

Please sign in to comment.