Skip to content
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

Update generator #1

Merged
merged 1 commit into from
Feb 10, 2023
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
2 changes: 1 addition & 1 deletion .envrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
use nix
use flake
2 changes: 1 addition & 1 deletion .generator.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Changes here will be overwritten by Copier
_commit: 0.1.0
_commit: 0.2.0
_src_path: https://github.com/fastapi-mvc/copier-generator.git
copyright_date: 2022
generator: script
Expand Down
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@ Prerequisites:
* copier 6.2.0 or later

```shell
copier copy "https://github.com/fastapi-mvc/copier-script.git" /path/to/your/new/project
copier copy "https://github.com/fastapi-mvc/copier-script.git" /path/to/your/new/script
```

## Using Nix

Prerequisites:

* Nix 2.8.x or later installed [How to install Nix](https://nixos.org/download.html)

```shell
nix-shell shell.nix
copier copy "https://github.com/fastapi-mvc/copier-script.git" /path/to/your/new/project
nix develop
copier copy "https://github.com/fastapi-mvc/copier-script.git" /path/to/your/new/script
```

## Updating
Expand All @@ -29,13 +33,14 @@ To update your generator with the changes from the [upstream](https://github.com

```shell
./update.sh
# Or
nix run .#update
```

This action will not update/override your template and its configuration, but rather generators common files:

* Environment (`pyproject.toml` and `poetry.lock`)
* `README.md`
* Nix expression files
* `README.md`
* dotfiles
* `LICENSE`

Expand All @@ -49,5 +54,7 @@ List of excluded files/paths:
Lastly, you can pass extra copier CLI options should you choose:

```shell
./update.sh -x README.md
./update.sh -x README.md --vcs-ref=custom_branch
# Or
nix run .#update -- -x README.md --vcs-ref=custom_branch
```
9 changes: 0 additions & 9 deletions default.nix

This file was deleted.

121 changes: 121 additions & 0 deletions flake.lock

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

68 changes: 68 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
description = "Fastapi-mvc generator flake";
nixConfig.bash-prompt = ''\n\[\033[1;32m\][nix-develop:\w]\$\[\033[0m\] '';

inputs = {
flake-utils.url = "github:numtide/flake-utils";
fastapi-mvc.url = "github:fastapi-mvc/fastapi-mvc?ref=0.25.0";
nixpkgs.follows = "fastapi-mvc/nixpkgs";
};

outputs = { self, nixpkgs, flake-utils, fastapi-mvc }:
{
overlays.default = nixpkgs.lib.composeManyExtensions [
fastapi-mvc.overlays.default
];
} // (flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ self.overlays.default ];
};
in
rec {
apps = {
fastapi-mvc = flake-utils.lib.mkApp { drv = pkgs.fastapi-mvc; };
copier = {
type = "app";
program = toString (pkgs.writeScript "copier" ''
export PATH="${pkgs.lib.makeBinPath [
pkgs.fastapi-mvc.dependencyEnv
pkgs.git
pkgs.coreutils
]}"
copier $@
'');
};
update = {
type = "app";
program = toString (pkgs.writeScript "update" ''
export PATH="${pkgs.lib.makeBinPath [
pkgs.fastapi-mvc.dependencyEnv
pkgs.git
pkgs.coreutils
]}"
copier -x template/** -x copier.yml -x *.py -x CHANGELOG.md \
$@ \
-d generator=script \
-d nix=True \
-d license=MIT \
-d repo_url=https://github.com/fastapi-mvc/copier-script \
-d copyright_date=2022 \
-a .generator.yml \
update ./.
'');
};
};

devShells = {
default = pkgs.fastapi-mvc-dev.env.overrideAttrs (oldAttrs: {
buildInputs = [
pkgs.git
pkgs.coreutils
pkgs.poetry
];
});
};
}));
}
Loading