Skip to content

Commit 58a8769

Browse files
authored
Merge pull request #2 from fastapi-mvc/update_generator
Update generator
2 parents 3c832dd + 0a3382c commit 58a8769

10 files changed

+207
-535
lines changed

.envrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
use nix
1+
use flake

.generator.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Changes here will be overwritten by Copier
2-
_commit: 3c38a44
2+
_commit: 0.2.0
33
_src_path: https://github.com/fastapi-mvc/copier-generator
44
copyright_date: 2022
55
generator: controller

README.md

+13-6
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,18 @@ Prerequisites:
1313
* copier 6.2.0 or later
1414

1515
```shell
16-
copier copy "https://github.com/fastapi-mvc/copier-controller.git" /path/to/your/new/project
16+
copier copy "https://github.com/fastapi-mvc/copier-controller.git" /path/to/your/new/controller
1717
```
1818

1919
## Using Nix
2020

21+
Prerequisites:
22+
23+
* Nix 2.8.x or later installed [How to install Nix](https://nixos.org/download.html)
24+
2125
```shell
22-
nix-shell shell.nix
23-
copier copy "https://github.com/fastapi-mvc/copier-controller.git" /path/to/your/new/project
26+
nix develop
27+
copier copy "https://github.com/fastapi-mvc/copier-controller.git" /path/to/your/new/controller
2428
```
2529

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

3034
```shell
3135
./update.sh
36+
# Or
37+
nix run .#update
3238
```
3339

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

36-
* Environment (`pyproject.toml` and `poetry.lock`)
37-
* `README.md`
3842
* Nix expression files
43+
* `README.md`
3944
* dotfiles
4045
* `LICENSE`
4146

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

5156
```shell
52-
./update.sh -x README.md
57+
./update.sh -x README.md --vcs-ref=custom_branch
58+
# Or
59+
nix run .#update -- -x README.md --vcs-ref=custom_branch
5360
```

default.nix

-9
This file was deleted.

flake.lock

+121
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
description = "Fastapi-mvc generator flake";
3+
nixConfig.bash-prompt = ''\n\[\033[1;32m\][nix-develop:\w]\$\[\033[0m\] '';
4+
5+
inputs = {
6+
flake-utils.url = "github:numtide/flake-utils";
7+
fastapi-mvc.url = "github:fastapi-mvc/fastapi-mvc?ref=0.25.0";
8+
nixpkgs.follows = "fastapi-mvc/nixpkgs";
9+
};
10+
11+
outputs = { self, nixpkgs, flake-utils, fastapi-mvc }:
12+
{
13+
overlays.default = nixpkgs.lib.composeManyExtensions [
14+
fastapi-mvc.overlays.default
15+
];
16+
} // (flake-utils.lib.eachDefaultSystem (system:
17+
let
18+
pkgs = import nixpkgs {
19+
inherit system;
20+
overlays = [ self.overlays.default ];
21+
};
22+
in
23+
rec {
24+
apps = {
25+
fastapi-mvc = flake-utils.lib.mkApp { drv = pkgs.fastapi-mvc; };
26+
copier = {
27+
type = "app";
28+
program = toString (pkgs.writeScript "copier" ''
29+
export PATH="${pkgs.lib.makeBinPath [
30+
pkgs.fastapi-mvc.dependencyEnv
31+
pkgs.git
32+
pkgs.coreutils
33+
]}"
34+
copier $@
35+
'');
36+
};
37+
update = {
38+
type = "app";
39+
program = toString (pkgs.writeScript "update" ''
40+
export PATH="${pkgs.lib.makeBinPath [
41+
pkgs.fastapi-mvc.dependencyEnv
42+
pkgs.git
43+
pkgs.coreutils
44+
]}"
45+
copier -x template/** -x copier.yml -x *.py -x CHANGELOG.md \
46+
$@ \
47+
-d generator=controller \
48+
-d nix=True \
49+
-d license=MIT \
50+
-d repo_url=https://github.com/fastapi-mvc/copier-controller \
51+
-d copyright_date=2022 \
52+
-a .generator.yml \
53+
update ./.
54+
'');
55+
};
56+
};
57+
58+
devShells = {
59+
default = pkgs.fastapi-mvc-dev.env.overrideAttrs (oldAttrs: {
60+
buildInputs = [
61+
pkgs.git
62+
pkgs.coreutils
63+
pkgs.poetry
64+
];
65+
});
66+
};
67+
}));
68+
}

0 commit comments

Comments
 (0)