Skip to content

Commit fde1778

Browse files
committed
Merge remote-tracking branch 'aster-void/setup-flake-check'
2 parents c0b23ea + 67e5505 commit fde1778

File tree

6 files changed

+73
-28
lines changed

6 files changed

+73
-28
lines changed

.github/workflows/check.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Nix Checks
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
check:
10+
name: Check
11+
runs-on: ubuntu-latest
12+
timeout-minutes: 10
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: cachix/install-nix-action@v30
16+
- run: nix flake check

flake.lock

Lines changed: 22 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,36 @@
11
{
22
inputs.pkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
33
inputs.flake-utils.url = "github:numtide/flake-utils";
4+
inputs.treefmt-nix.url = "github:numtide/treefmt-nix";
5+
inputs.treefmt-nix.inputs.nixpkgs.follows = "pkgs";
46
outputs =
5-
{ pkgs, flake-utils, ... }:
7+
{
8+
self,
9+
pkgs,
10+
flake-utils,
11+
treefmt-nix,
12+
}:
613
let
714
prisma-factory = import ./prisma.nix;
815
in
916
flake-utils.lib.eachDefaultSystem (
1017
system:
1118
let
1219
nixpkgs = import pkgs { inherit system; };
20+
treefmt = treefmt-nix.lib.evalModule nixpkgs {
21+
# nixfmt is nixfmt-rfc-style
22+
programs.nixfmt.enable = true;
23+
};
1324
in
1425
{
15-
packages = import ./tests.nix { inherit prisma-factory nixpkgs; };
26+
formatter = treefmt.config.build.wrapper;
27+
checks =
28+
(nixpkgs.callPackages ./tests.nix {
29+
inherit prisma-factory nixpkgs; # nixpkgs can be removed once it is renamed to pkgs
30+
})
31+
// {
32+
format = treefmt.config.build.check self;
33+
};
1634
devShells.default =
1735
let
1836
prisma = (

prisma.nix

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,7 @@ rec {
180180
"5" =
181181
pnpmLock:
182182
let
183-
version = builtins.elemAt (builtins.split ":" (
184-
builtins.elemAt (builtins.split ("@prisma/engines-version/") pnpmLock) 2
185-
)) 0;
183+
version = builtins.elemAt (builtins.split ":" (builtins.elemAt (builtins.split ("@prisma/engines-version/") pnpmLock) 2)) 0;
186184
in
187185
nixpkgs.lib.lists.last (nixpkgs.lib.strings.splitString "." version);
188186

@@ -191,9 +189,7 @@ rec {
191189
"6" =
192190
pnpmLock:
193191
let
194-
version = builtins.elemAt (builtins.split ":" (
195-
builtins.elemAt (builtins.split ("@prisma/engines-version@") pnpmLock) 2
196-
)) 0;
192+
version = builtins.elemAt (builtins.split ":" (builtins.elemAt (builtins.split ("@prisma/engines-version@") pnpmLock) 2)) 0;
197193
in
198194
nixpkgs.lib.lists.last (nixpkgs.lib.strings.splitString "." version);
199195

@@ -202,9 +198,7 @@ rec {
202198
"9" =
203199
pnpmLock:
204200
let
205-
version = builtins.elemAt (builtins.split "'" (
206-
builtins.elemAt (builtins.split ("@prisma/engines-version@") pnpmLock) 2
207-
)) 0;
201+
version = builtins.elemAt (builtins.split "'" (builtins.elemAt (builtins.split ("@prisma/engines-version@") pnpmLock) 2)) 0;
208202
in
209203
nixpkgs.lib.lists.last (nixpkgs.lib.strings.splitString "." version);
210204
};

readme.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,19 @@ With nix-prisma-utils it's the other way around. You can simply install prisma t
116116
}
117117
```
118118

119-
## Testing
119+
## Contributing
120120

121-
`nix run .#test-all`
121+
Before contributing, please make sure that your code is formatted correctly by running
122+
123+
```sh
124+
nix fmt
125+
```
126+
127+
All tests (including format check) can be run by
128+
129+
```sh
130+
nix flake check
131+
```
122132

123133
## License
124134

tests.nix

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -70,25 +70,11 @@ let
7070
bunx prisma generate
7171
'';
7272
};
73-
test-all = writeShellApplication {
74-
name = "test";
75-
runtimeInputs = [
76-
test-npm
77-
test-pnpm
78-
test-bun
79-
];
80-
text = ''
81-
test-npm
82-
test-pnpm
83-
test-bun
84-
'';
85-
};
8673
in
8774
{
8875
inherit
8976
test-npm
9077
test-pnpm
9178
test-bun
92-
test-all
9379
;
9480
}

0 commit comments

Comments
 (0)