From ca1138c08f25327392b7d69dbdbf41812d83d362 Mon Sep 17 00:00:00 2001 From: o-az Date: Thu, 7 Nov 2024 17:51:20 -0800 Subject: [PATCH] feat: use separate nixpkgs for js toolchains --- app/app.nix | 23 ++--- app/src/lib/graphql/queries/channels.ts | 3 +- biome.json | 5 +- ceremony/ceremony.nix | 17 ++-- docs/docs.nix | 19 ++-- flake.lock | 35 ++++--- flake.nix | 19 ++-- site/site.nix | 23 ++--- tools/biome/biome.nix | 119 ------------------------ treefmt.nix | 4 +- 10 files changed, 70 insertions(+), 197 deletions(-) delete mode 100644 tools/biome/biome.nix diff --git a/app/app.nix b/app/app.nix index aa6247a7b7..5dd68d34df 100644 --- a/app/app.nix +++ b/app/app.nix @@ -1,35 +1,32 @@ _: { perSystem = { - pkgs, - unstablePkgs, lib, + pkgs, + jsPkgs, ensureAtRepositoryRoot, ... }: let - pkgsDeps = with pkgs; [ - pkg-config + deps = with jsPkgs; [ python3 - ]; - nodeDeps = with unstablePkgs; [ + pkg-config nodePackages_latest.nodejs nodePackages_latest."patch-package" ]; - combinedDeps = pkgsDeps ++ nodeDeps; packageJSON = lib.importJSON ./package.json; in { packages = { - app = unstablePkgs.buildNpmPackage { + app = jsPkgs.buildNpmPackage { npmDepsHash = "sha256-yrqA4Qp7iiGvSo/Xk0G5adXdVqgK8nGYGdXtvLp7EPk="; src = ./.; sourceRoot = "app"; npmFlags = [ "--enable-pre-post-scripts" ]; pname = packageJSON.name; inherit (packageJSON) version; - nativeBuildInputs = combinedDeps; - buildInputs = combinedDeps; + nativeBuildInputs = deps; + buildInputs = deps; installPhase = '' mkdir -p $out cp -r ./build/* $out @@ -44,7 +41,7 @@ _: { type = "app"; program = pkgs.writeShellApplication { name = "app-dev-server"; - runtimeInputs = combinedDeps; + runtimeInputs = deps; text = '' ${ensureAtRepositoryRoot} cd app/ @@ -58,7 +55,7 @@ _: { type = "app"; program = pkgs.writeShellApplication { name = "app-dev-server"; - runtimeInputs = combinedDeps; + runtimeInputs = deps; text = '' ${ensureAtRepositoryRoot} cd app/ @@ -72,7 +69,7 @@ _: { type = "app"; program = pkgs.writeShellApplication { name = "deploy-app-ipfs"; - runtimeInputs = combinedDeps; + runtimeInputs = deps; text = '' ${ensureAtRepositoryRoot} cd app/ diff --git a/app/src/lib/graphql/queries/channels.ts b/app/src/lib/graphql/queries/channels.ts index 6f19e06d2c..35cc0347d0 100644 --- a/app/src/lib/graphql/queries/channels.ts +++ b/app/src/lib/graphql/queries/channels.ts @@ -1,6 +1,7 @@ import { graphql } from "gql.tada" -export const channelsQuery = graphql(/* GraphQL */ `query ChannelsQuery($limit: Int = 500) @cached(ttl: 30) { +export const channelsQuery = + graphql(/* GraphQL */ `query ChannelsQuery($limit: Int = 500) @cached(ttl: 30) { v1_channels( where: {source_chain: {enabled: {_eq: true}}, destination_chain: {enabled: {_eq: true}}}, order_by: [ diff --git a/biome.json b/biome.json index b607c1e725..124bed0a8f 100644 --- a/biome.json +++ b/biome.json @@ -1,5 +1,5 @@ { - "$schema": "https://biomejs.dev/schemas/1.9.3/schema.json", + "$schema": "https://biomejs.dev/schemas/1.9.4/schema.json", "vcs": { "enabled": true, "clientKind": "git", @@ -227,8 +227,7 @@ "noNestedTernary": "off", "noExportedImports": "off", "useImportRestrictions": "off", - "noDescendingSpecificity": "off", - "useExplicitFunctionReturnType": "off" + "noDescendingSpecificity": "off" }, "performance": { "all": true, diff --git a/ceremony/ceremony.nix b/ceremony/ceremony.nix index c5e6de7745..dd0f0de45c 100644 --- a/ceremony/ceremony.nix +++ b/ceremony/ceremony.nix @@ -1,32 +1,31 @@ _: { perSystem = { - pkgs, - unstablePkgs, lib, + pkgs, + jsPkgs, ensureAtRepositoryRoot, ... }: let - pkgsDeps = with pkgs; [ + deps = with jsPkgs; [ pkg-config python3 + nodePackages_latest.nodejs ]; - nodeDeps = with unstablePkgs; [ nodePackages_latest.nodejs ]; - combinedDeps = pkgsDeps ++ nodeDeps; packageJSON = lib.importJSON ./package.json; in { packages = { - ceremony = unstablePkgs.buildNpmPackage { + ceremony = jsPkgs.buildNpmPackage { npmDepsHash = "sha256-2s556is4PJaGmxQhIUPZLINh6J6ngeTf32bwDtl+v6Q="; src = ./.; sourceRoot = "ceremony"; npmFlags = [ "--legacy-peer-deps" ]; pname = packageJSON.name; inherit (packageJSON) version; - nativeBuildInputs = combinedDeps; - buildInputs = combinedDeps; + nativeBuildInputs = deps; + buildInputs = deps; installPhase = '' mkdir -p $out cp -r ./build/* $out @@ -44,7 +43,7 @@ _: { type = "app"; program = pkgs.writeShellApplication { name = "ceremony-dev-server"; - runtimeInputs = combinedDeps; + runtimeInputs = deps; text = '' ${ensureAtRepositoryRoot} cd ceremony/ diff --git a/docs/docs.nix b/docs/docs.nix index a024931388..8c60d6fa0a 100644 --- a/docs/docs.nix +++ b/docs/docs.nix @@ -4,23 +4,22 @@ _: { lib, pkgs, mkCi, - unstablePkgs, + jsPkgs, ensureAtRepositoryRoot, ... }: let - pkgsDeps = with pkgs; [ pkg-config ]; - nodeDeps = with unstablePkgs; [ + deps = with jsPkgs; [ vips + pkg-config nodePackages_latest.nodejs ]; - combinedDeps = pkgsDeps ++ nodeDeps; packageJSON = lib.importJSON ./package.json; in { packages = { docs = mkCi false ( - unstablePkgs.buildNpmPackage { + jsPkgs.buildNpmPackage { npmDepsHash = "sha256-v2rwxCCKmbtwxAynUryTigfg0V4cmARh6HgfKTwFQds="; src = ./.; srcs = [ @@ -30,8 +29,8 @@ _: { sourceRoot = "docs"; pname = packageJSON.name; inherit (packageJSON) version; - nativeBuildInputs = combinedDeps; - buildInputs = combinedDeps; + nativeBuildInputs = deps; + buildInputs = deps; installPhase = '' mkdir -p $out cp -r ./dist/* $out @@ -49,7 +48,7 @@ _: { type = "app"; program = pkgs.writeShellApplication { name = "docs-dev-server"; - runtimeInputs = combinedDeps; + runtimeInputs = deps; text = '' ${ensureAtRepositoryRoot} cd docs/ @@ -64,7 +63,7 @@ _: { type = "app"; program = pkgs.writeShellApplication { name = "docs-check"; - runtimeInputs = combinedDeps; + runtimeInputs = deps; text = '' ${ensureAtRepositoryRoot} biome check docs --error-on-warnings --write --unsafe @@ -84,7 +83,7 @@ _: { type = "app"; program = pkgs.writeShellApplication { name = "deploy-docs-ipfs"; - runtimeInputs = combinedDeps; + runtimeInputs = deps; text = '' ${ensureAtRepositoryRoot} cd docs/ diff --git a/flake.lock b/flake.lock index 11bbe189b0..08549b56bb 100644 --- a/flake.lock +++ b/flake.lock @@ -23,23 +23,6 @@ "type": "github" } }, - "biome": { - "flake": false, - "locked": { - "lastModified": 1727789707, - "narHash": "sha256-GZV8M/yUDMom6xvSvSfDRjcMGm+thiaTR3fggkBLmRE=", - "owner": "biomejs", - "repo": "biome", - "rev": "d5034515f48f9052fe4c47a60d43f05ed7986105", - "type": "github" - }, - "original": { - "owner": "biomejs", - "ref": "cli/v1.9.3", - "repo": "biome", - "type": "github" - } - }, "bls-eth-go": { "flake": false, "locked": { @@ -449,6 +432,22 @@ "type": "github" } }, + "nixpkgs-js": { + "locked": { + "lastModified": 1730785428, + "narHash": "sha256-Zwl8YgTVJTEum+L+0zVAWvXAGbWAuXHax3KzuejaDyo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "4aa36568d413aca0ea84a1684d2d46f55dbabad7", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs-lnav": { "locked": { "lastModified": 1713467351, @@ -585,7 +584,6 @@ "root": { "inputs": { "arion": "arion", - "biome": "biome", "bls-eth-go": "bls-eth-go", "blst": "blst", "cometbls": "cometbls", @@ -605,6 +603,7 @@ "nix-filter": "nix-filter", "nixpkgs": "nixpkgs", "nixpkgs-go": "nixpkgs-go", + "nixpkgs-js": "nixpkgs-js", "nixpkgs-lnav": "nixpkgs-lnav", "nixpkgs-solc": "nixpkgs-solc", "nixpkgs-unstable": "nixpkgs-unstable", diff --git a/flake.nix b/flake.nix index d7afa06529..b9ae27d828 100644 --- a/flake.nix +++ b/flake.nix @@ -12,6 +12,8 @@ nixpkgs-go.url = "github:NixOS/nixpkgs/nixos-unstable"; # Track a separate nixpkgs for unstable nixos nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable"; + # Track a separate nixpkgs for JS/TS toolchains + nixpkgs-js.url = "github:NixOS/nixpkgs/nixos-unstable"; # Remove when lnav is updated on upstream nixpkgs nixpkgs-lnav.url = "github:cor/nixpkgs/lnav-v0.12.2-beta"; process-compose.url = "github:F1bonacc1/process-compose"; @@ -94,11 +96,6 @@ url = "github:CosmWasm/wasmvm/v2.1.3"; flake = false; }; - biome = { - url = "github:biomejs/biome/cli/v1.9.3"; - flake = false; - }; - stargaze = { url = "git+https://github.com/public-awesome/stargaze?ref=main&submodules=1"; flake = false; @@ -247,7 +244,6 @@ ./tools/rust/rust.nix ./tools/rust/crane.nix ./tools/tera/tera.nix - ./tools/biome/biome.nix ./tools/docgen/docgen.nix ./tools/hasura-cli/hasura-cli.nix ./tools/todo-comment.nix @@ -272,7 +268,6 @@ rust, system, lib, - biome, ... }: let @@ -295,6 +290,7 @@ }; goPkgs = import inputs.nixpkgs-go { inherit system; }; + jsPkgs = import inputs.nixpkgs-js { inherit system; }; unstablePkgs = import inputs.nixpkgs-unstable { inherit system; }; in { @@ -306,6 +302,7 @@ get-flake uniondBundleVersions goPkgs + jsPkgs unstablePkgs mkCi ; @@ -496,10 +493,8 @@ self'.packages.tdc yq ]) - ++ (with unstablePkgs; [ - wasm-tools + ++ (with jsPkgs; [ bun # for running TypeScript files on the fly - postgresql emmet-language-server nodePackages.graphqurl nodePackages_latest.nodejs @@ -510,6 +505,8 @@ nodePackages_latest.vscode-langservers-extracted ]) ++ (with unstablePkgs; [ + wasm-tools + postgresql go_1_23 gopls go-tools @@ -554,8 +551,8 @@ pkgs unstablePkgs goPkgs + jsPkgs rust - biome ; }; }; diff --git a/site/site.nix b/site/site.nix index ca540dbdeb..c00d7abdd5 100644 --- a/site/site.nix +++ b/site/site.nix @@ -2,29 +2,30 @@ _: { perSystem = { pkgs, - unstablePkgs, lib, - ensureAtRepositoryRoot, mkCi, + jsPkgs, + ensureAtRepositoryRoot, ... }: let - pkgsDeps = with pkgs; [ pkg-config ]; - nodeDeps = with unstablePkgs; [ nodePackages_latest.nodejs ]; - combinedDeps = pkgsDeps ++ nodeDeps; + deps = with jsPkgs; [ + pkg-config + nodePackages_latest.nodejs + ]; packageJSON = lib.importJSON ./package.json; in { packages = { site = mkCi false ( - unstablePkgs.buildNpmPackage { + jsPkgs.buildNpmPackage { npmDepsHash = "sha256-Q9HbeXkrLI3aomqLxcpIAk+f72KWHOusQdQjRoz/tj4="; src = ./.; sourceRoot = "site"; pname = packageJSON.name; inherit (packageJSON) version; - nativeBuildInputs = combinedDeps; - buildInputs = combinedDeps; + nativeBuildInputs = deps; + buildInputs = deps; installPhase = '' mkdir -p $out cp -r ./.vercel/output/* $out @@ -42,7 +43,7 @@ _: { type = "app"; program = pkgs.writeShellApplication { name = "site-dev-server"; - runtimeInputs = combinedDeps; + runtimeInputs = deps; text = '' ${ensureAtRepositoryRoot} cd site/ @@ -57,7 +58,7 @@ _: { type = "app"; program = pkgs.writeShellApplication { name = "fmt-site"; - runtimeInputs = combinedDeps; + runtimeInputs = deps; text = '' ${ensureAtRepositoryRoot} cd site/ @@ -80,7 +81,7 @@ _: { type = "app"; program = pkgs.writeShellApplication { name = "site-check"; - runtimeInputs = combinedDeps; + runtimeInputs = deps; text = '' ${ensureAtRepositoryRoot} cd site/ diff --git a/tools/biome/biome.nix b/tools/biome/biome.nix deleted file mode 100644 index 7b52c2dfc0..0000000000 --- a/tools/biome/biome.nix +++ /dev/null @@ -1,119 +0,0 @@ -{ inputs, ... }: -{ - perSystem = - { - pkgs, - unstablePkgs, - crane, - dbg, - system, - rust, - mkCi, - nix-filter, - ... - }: - let - throwBadSystem = throw "libwasmvm cannot be built on system `${system}`"; - - CARGO_BUILD_TARGET = - if system == "aarch64-linux" then - "aarch64-unknown-linux-musl" - else if system == "x86_64-linux" then - "x86_64-unknown-linux-musl" - else if system == "aarch64-darwin" then - "aarch64-apple-darwin" - else if system == "x86_64-darwin" then - "x86_64-apple-darwin" - else - throwBadSystem; - - rustToolchain = rust.mkNightly { targets = [ CARGO_BUILD_TARGET ]; }; - - BIOME_VERSION = "1.9.3"; - - biome = (crane.lib.overrideToolchain rustToolchain).buildPackage { - inherit CARGO_BUILD_TARGET BIOME_VERSION; - - pname = "biome"; - version = BIOME_VERSION; - src = inputs.biome; - - nativeBuildInputs = [ pkgs.pkg-config ]; - - buildInputs = [ - pkgs.libgit2 - unstablePkgs.rust-jemalloc-sys - pkgs.zlib - ] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [ pkgs.darwin.apple_sdk.frameworks.Security ]; - - nativeCheckInputs = [ pkgs.git ]; - - cargoExtraArgs = "-p=biome_cli"; - - doCheck = false; - - meta.mainProgram = "biome"; - }; - in - { - _module.args.biome = biome; - checks.biome-lint = mkCi (system == "x86_64-linux") ( - pkgs.stdenv.mkDerivation { - name = "biome-lint"; - description = "Lint js,ts,jsx,tsx,d.ts,json,jsonc,astro,svelte,vue,css,graphql,html files"; - src = - with unstablePkgs.lib.fileset; - toSource { - root = ../../.; - fileset = - intersection - (difference ../../. (unions [ - ../../app/src/generated - ../../networks/genesis - ../../lib/ethereum-verifier/src/test - ])) - ( - fileFilter ( - file: - (file.name != "package-lock.json") - && (builtins.any file.hasExt [ - "js" - "ts" - "mts" - "cjs" - "mjs" - "jsx" - "tsx" - "vue" - "d.ts" - "css" - "astro" - "svelte" - "json" - "jsonc" - "css" - "graphql" - "html" - ]) - ) ../../. - ); - }; - buildInputs = [ biome ]; - doCheck = true; - checkPhase = '' - cd $src - - biome check . \ - --verbose \ - --error-on-warnings \ - --log-level="info" \ - --log-kind="pretty" \ - --diagnostic-level="info" - - echo "biome-lint: OK" - touch $out - ''; - } - ); - }; -} diff --git a/treefmt.nix b/treefmt.nix index 91e20e1fb1..3bf5a9d017 100644 --- a/treefmt.nix +++ b/treefmt.nix @@ -2,8 +2,8 @@ { pkgs, rust, - biome, goPkgs, + jsPkgs, unstablePkgs, movefmt, }: @@ -23,7 +23,7 @@ taplo.enable = true; biome = { enable = true; - package = biome; + package = jsPkgs.biome; }; yamlfmt = { enable = true;