summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/ci.yaml53
-rw-r--r--.github/workflows/codeql.yaml2
-rw-r--r--.github/workflows/eslint.yaml9
-rw-r--r--.github/workflows/treefmt.yaml30
-rw-r--r--flake.lock30
-rw-r--r--flake.nix101
-rw-r--r--src/env.ts6
-rw-r--r--src/index.ts7
-rw-r--r--treefmt.nix11
9 files changed, 96 insertions, 153 deletions
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
deleted file mode 100644
index b77ed84..0000000
--- a/.github/workflows/ci.yaml
+++ /dev/null
@@ -1,53 +0,0 @@
-name: CI
-
-on:
- pull_request:
- workflow_dispatch:
-
-jobs:
- build:
- name: Build
-
- runs-on: ubuntu-latest
-
- steps:
- - name: Checkout repository
- uses: actions/checkout@v4
-
- - name: Install Nix
- uses: DeterminateSystems/nix-installer-action@v13
-
- - name: Install Dependencies
- run: nix develop .#ci --command pnpm install --frozen-lockfile
-
- - name: Run build
- run: nix develop .#ci --command nrr build
-
- treefmt:
- name: Treefmt
-
- runs-on: ubuntu-latest
-
- steps:
- - name: Checkout repository
- uses: actions/checkout@v4
-
- - name: Install Nix
- uses: DeterminateSystems/nix-installer-action@v13
-
- - name: Run checks
- run: |
- nix develop .#ci --command treefmt --fail-on-change
-
- release-gate:
- name: CI Release gate
- needs: [build, treefmt]
-
- if: always()
-
- runs-on: ubuntu-latest
-
- steps:
- - name: Exit with error
- if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
- run: exit 1
diff --git a/.github/workflows/codeql.yaml b/.github/workflows/codeql.yaml
index 9d82771..ea9d2ce 100644
--- a/.github/workflows/codeql.yaml
+++ b/.github/workflows/codeql.yaml
@@ -6,7 +6,7 @@ on:
jobs:
codeql:
- name: Run CodeQL scan
+ name: Run scan
runs-on: ubuntu-latest
diff --git a/.github/workflows/eslint.yaml b/.github/workflows/eslint.yaml
index 0a6f7ce..56bae3e 100644
--- a/.github/workflows/eslint.yaml
+++ b/.github/workflows/eslint.yaml
@@ -1,13 +1,6 @@
name: ESLint
on:
- push:
- branches: [main]
- paths:
- - "**.ts"
- - "package.json"
- - "pnpm-lock.yaml"
- - "tsconfig.json"
pull_request:
jobs:
@@ -24,7 +17,7 @@ jobs:
uses: actions/checkout@v4
- name: Install Nix
- uses: DeterminateSystems/nix-installer-action@v13
+ uses: DeterminateSystems/nix-installer-action@v14
- name: Install Dependencies
run: nix develop .#ci --command pnpm install --frozen-lockfile
diff --git a/.github/workflows/treefmt.yaml b/.github/workflows/treefmt.yaml
new file mode 100644
index 0000000..1321488
--- /dev/null
+++ b/.github/workflows/treefmt.yaml
@@ -0,0 +1,30 @@
+name: Treefmt
+
+on:
+ pull_request:
+ paths:
+ - "**.lock"
+ - "**.nix"
+ - "**.ts"
+ - "package.json"
+ - "tsconfig.json"
+
+ - ".github/workflows/ci.yaml"
+ workflow_dispatch:
+
+jobs:
+ treefmt:
+ name: Run treefmt
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+
+ - name: Install Nix
+ uses: DeterminateSystems/nix-installer-action@v14
+
+ - name: Run treefmt
+ run: |
+ nix fmt -- --ci
diff --git a/flake.lock b/flake.lock
index 481948a..2104113 100644
--- a/flake.lock
+++ b/flake.lock
@@ -2,43 +2,23 @@
"nodes": {
"nixpkgs": {
"locked": {
- "lastModified": 1725534445,
- "narHash": "sha256-Yd0FK9SkWy+ZPuNqUgmVPXokxDgMJoGuNpMEtkfcf84=",
+ "lastModified": 1728538411,
+ "narHash": "sha256-f0SBJz1eZ2yOuKUr5CA9BHULGXVSn6miBuUWdTyhUhU=",
"owner": "NixOS",
"repo": "nixpkgs",
- "rev": "9bb1e7571aadf31ddb4af77fc64b2d59580f9a39",
+ "rev": "b69de56fac8c2b6f8fd27f2eca01dcda8e0a4221",
"type": "github"
},
"original": {
- "id": "nixpkgs",
+ "owner": "NixOS",
"ref": "nixpkgs-unstable",
- "type": "indirect"
- }
- },
- "parts": {
- "inputs": {
- "nixpkgs-lib": [
- "nixpkgs"
- ]
- },
- "locked": {
- "lastModified": 1725234343,
- "narHash": "sha256-+ebgonl3NbiKD2UD0x4BszCZQ6sTfL4xioaM49o5B3Y=",
- "owner": "hercules-ci",
- "repo": "flake-parts",
- "rev": "567b938d64d4b4112ee253b9274472dc3a346eb6",
- "type": "github"
- },
- "original": {
- "owner": "hercules-ci",
- "repo": "flake-parts",
+ "repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
- "parts": "parts",
"treefmt-nix": "treefmt-nix"
}
},
diff --git a/flake.nix b/flake.nix
index 94b8099..26d6bfd 100644
--- a/flake.nix
+++ b/flake.nix
@@ -1,11 +1,6 @@
{
inputs = {
- nixpkgs.url = "nixpkgs/nixpkgs-unstable";
-
- parts = {
- url = "github:hercules-ci/flake-parts";
- inputs.nixpkgs-lib.follows = "nixpkgs";
- };
+ nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
treefmt-nix = {
url = "github:numtide/treefmt-nix";
@@ -14,8 +9,13 @@
};
outputs =
- { parts, treefmt-nix, ... }@inputs:
- parts.lib.mkFlake { inherit inputs; } {
+ {
+ self,
+ nixpkgs,
+ treefmt-nix,
+ }:
+ let
+ inherit (nixpkgs) lib;
systems = [
"x86_64-linux"
"aarch64-linux"
@@ -23,63 +23,48 @@
"aarch64-darwin"
];
- imports = [ treefmt-nix.flakeModule ];
-
- perSystem =
- { self', pkgs, ... }:
- {
- devShells = {
- default = pkgs.mkShellNoCC {
- packages = with pkgs; [
- # node
- nodejs_20
- corepack_20
- wrangler
- nrr
- typescript-language-server
- vscode-langservers-extracted # for eslint server
+ forAllSystems = lib.genAttrs systems;
+ nixpkgsFor = forAllSystems (system: nixpkgs.legacyPackages.${system});
+ treefmtFor = forAllSystems (system: treefmt-nix.lib.evalModule nixpkgsFor.${system} ./treefmt.nix);
+ in
+ {
+ checks = forAllSystems (system: {
+ treefmt = treefmtFor.${system}.config.build.check self;
+ });
- # github actions
- actionlint
+ devShells = forAllSystems (
+ system:
+ let
+ pkgs = nixpkgsFor.${system};
- # nix
- self'.formatter
- nil
- statix
- ];
+ basePackages = [
+ pkgs.nodejs
+ pkgs.corepack
- env = {
- # https://github.com/NixOS/nixpkgs/pull/330808
- SSL_CERT_FILE = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
- };
- };
-
- ci = pkgs.mkShellNoCC {
- shellHook = ''
- corepack install
- '';
+ pkgs.nrr
+ pkgs.wrangler
+ ];
+ in
+ {
+ default = pkgs.mkShellNoCC {
+ packages = basePackages ++ [
+ pkgs.typescript-language-server
+ pkgs.vscode-langservers-extracted # for eslint server
- packages = with pkgs; [
- nodejs_20
- corepack_20
- nrr
+ # github actions
+ pkgs.actionlint
- self'.formatter
- ];
- };
+ # nix
+ self.formatter.${system}
+ pkgs.nil
+ pkgs.statix
+ ];
};
- treefmt = {
- projectRootFile = ".git/config";
+ ci = pkgs.mkShellNoCC { packages = basePackages; };
+ }
+ );
- programs = {
- actionlint.enable = true;
- deadnix.enable = true;
- nixfmt.enable = true;
- prettier.enable = true;
- statix.enable = true;
- };
- };
- };
+ formatter = forAllSystems (system: treefmtFor.${system}.config.build.wrapper);
};
}
diff --git a/src/env.ts b/src/env.ts
deleted file mode 100644
index 2ee3db7..0000000
--- a/src/env.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-export type Bindings = {
- REDIRECT_ROOT?: string;
- TEAWIE_API: KVNamespace;
-};
-
-export type Variables = Record<string, never>;
diff --git a/src/index.ts b/src/index.ts
index 82eaad9..5f4ba34 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -3,7 +3,6 @@ import { prettyJSON } from "hono/pretty-json";
import { swaggerUI } from "@hono/swagger-ui";
import { OpenAPIHono, createRoute } from "@hono/zod-openapi";
import { VERSION } from "./consts";
-import { Bindings, Variables } from "./env";
import {
ListTeawiesParams,
ListTeawiesResponse,
@@ -11,7 +10,11 @@ import {
} from "./schemas";
import { imageUrls } from "./teawie";
-const app = new OpenAPIHono<{ Bindings: Bindings; Variables: Variables }>();
+type Bindings = {
+ REDIRECT_ROOT?: string;
+ TEAWIE_API: KVNamespace;
+};
+const app = new OpenAPIHono<{ Bindings: Bindings }>();
app.use("*", logger());
app.use("*", prettyJSON());
diff --git a/treefmt.nix b/treefmt.nix
new file mode 100644
index 0000000..87636e7
--- /dev/null
+++ b/treefmt.nix
@@ -0,0 +1,11 @@
+{
+ projectRootFile = ".git/config";
+
+ programs = {
+ actionlint.enable = true;
+ deadnix.enable = true;
+ nixfmt.enable = true;
+ prettier.enable = true;
+ statix.enable = true;
+ };
+}