Skip to content

fix(docs): account for instantiation in dirs with active direnv state #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ jobs:
git config --local user.email "[email protected]"
git config --local user.name "Test User"
git commit --allow-empty -m "initial commit (empty)"

# This needs to use a global uv (astral-sh/setup-uv) before entering
# the devshell even though uv is included in the devshell
nix run github:NixOS/nixpkgs/nixos-unstable#uv -- lock
git add .

nix develop --accept-flake-config -c pytest
Expand Down Expand Up @@ -211,11 +215,10 @@ jobs:
git config --local user.email "[email protected]"
git config --local user.name "Test User"
git commit --allow-empty -m "initial commit (empty)"
git add .

# This needs to use a global uv (astral-sh/setup-uv) before entering
# the devshell even though uv is included in the devshell
nix run nixpkgs#uv -- lock
nix run github:NixOS/nixpkgs/nixos-unstable#uv -- lock
git add .

nix develop --accept-flake-config -c pytest
37 changes: 26 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,29 @@ tl;dr
<details><summary>instantiate a monorepo variant of the template</summary>

```sh
nix --accept-flake-config run github:juspay/omnix -- init github:sciexp/python-nix-template -o pnt-mono --non-interactive --params '{
"package-name-kebab-case": "pnt-mono",
"package-name-snake-case": "pnt_mono",
PROJECT_DIRECTORY=pnt-mono && \
PROJECT_SNAKE_CASE=$(echo "$PROJECT_DIRECTORY" | tr '-' '_') && \
PARAMS=$(cat <<EOF
{
"package-name-kebab-case": "$PROJECT_DIRECTORY",
"package-name-snake-case": "$PROJECT_SNAKE_CASE",
"monorepo-package": true,
"git-org": "pnt-mono",
"author": "Pnt Mono",
"author-email": "[email protected]",
"vscode": true,
"github-ci": true,
"nix-template": false
}' && \
cd pnt-mono && \
}
EOF
) && \
nix --accept-flake-config run github:juspay/omnix/1.0.3 -- init github:sciexp/python-nix-template/main -o "$PROJECT_DIRECTORY" --non-interactive --params "$PARAMS" && \
(command -v direnv >/dev/null 2>&1 && direnv revoke "./$PROJECT_DIRECTORY/" || true) && \
cd "$PROJECT_DIRECTORY" && \
git init && \
git commit --allow-empty -m "initial commit (empty)" && \
git add . && \
nix run github:NixOS/nixpkgs/nixos-unstable#uv -- lock && \
nix develop --accept-flake-config -c pytest
```

Expand All @@ -49,22 +57,29 @@ development dependencies or `nix develop --accept-flake-config` to enter (or add
<details><summary>instantiate a single-package variant of the template</summary>

```sh
nix --accept-flake-config run github:juspay/omnix -- init github:sciexp/python-nix-template/main -o pnt-new --non-interactive --params '{
"package-name-kebab-case": "pnt-new",
"package-name-snake-case": "pnt_new",
PROJECT_DIRECTORY=pnt-new && \
PROJECT_SNAKE_CASE=$(echo "$PROJECT_DIRECTORY" | tr '-' '_') && \
PARAMS=$(cat <<EOF
{
"package-name-kebab-case": "$PROJECT_DIRECTORY",
"package-name-snake-case": "$PROJECT_SNAKE_CASE",
"monorepo-package": false,
"git-org": "pnt-new",
"author": "Pnt New",
"author-email": "[email protected]",
"vscode": true,
"github-ci": true,
"nix-template": false
}' && \
cd pnt-new && \
}
EOF
) && \
nix --accept-flake-config run github:juspay/omnix/1.0.3 -- init github:sciexp/python-nix-template/main -o "$PROJECT_DIRECTORY" --non-interactive --params "$PARAMS" && \
(command -v direnv >/dev/null 2>&1 && direnv revoke "./$PROJECT_DIRECTORY/" || true) && \
cd "$PROJECT_DIRECTORY" && \
git init && \
git commit --allow-empty -m "initial commit (empty)" && \
nix run github:NixOS/nixpkgs/nixos-unstable#uv -- lock && \
git add . && \
nix run nixpkgs#uv -- lock && \
nix develop --accept-flake-config -c pytest
```

Expand Down
8 changes: 7 additions & 1 deletion nix/modules/template.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
welcomeText = ''
Welcome to the python-nix-template!

Don't forget to `cd` into your new project directory.
NOTE: If you're reusing a preexisting directory for PROJECT_DIRECTORY you
may need to run `direnv revoke $PROJECT_DIRECTORY` to unload the environment
before proceeding.

Otherwise, don't forget to `cd` into your new project directory.

If you do not have nix and direnv installed, check

Expand All @@ -21,6 +25,8 @@

In order to recognize the `flake.nix` and associated files, create a git
repository, stage the files, and run `direnv allow` to load the environment.
You might need to run `direnv revoke` first if you're reusing a directory
where you have previously run `direnv allow`.

You can copy and paste

Expand Down
Loading