diff --git a/.github/workflows/template.yaml b/.github/workflows/template.yaml index 1c55b92..720d22a 100644 --- a/.github/workflows/template.yaml +++ b/.github/workflows/template.yaml @@ -182,6 +182,10 @@ jobs: git config --local user.email "test@example.com" 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 @@ -211,11 +215,10 @@ jobs: git config --local user.email "test@example.com" 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 diff --git a/README.md b/README.md index 70c839d..5df1588 100644 --- a/README.md +++ b/README.md @@ -22,9 +22,12 @@ tl;dr
instantiate a monorepo variant of the template ```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 </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 ``` @@ -49,9 +57,12 @@ development dependencies or `nix develop --accept-flake-config` to enter (or add
instantiate a single-package variant of the template ```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 </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 ``` diff --git a/nix/modules/template.nix b/nix/modules/template.nix index 6eab2ff..ba33288 100644 --- a/nix/modules/template.nix +++ b/nix/modules/template.nix @@ -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 @@ -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