From 4dda4feb2ca1c8dc5fdf0d27ba122dba8663b3c9 Mon Sep 17 00:00:00 2001 From: undefined Date: Mon, 29 Dec 2025 10:32:01 +0800 Subject: [PATCH] workspace: use direnv instead of corepack --- .envrc | 1 + .github/workflows/build.yml | 3 +- .gitignore | 1 + flake.lock | 40 ++++++++++++++++++++++-- flake.nix | 62 ++++++++++++++++++++++++------------- package.json | 3 +- 6 files changed, 81 insertions(+), 29 deletions(-) create mode 100644 .envrc diff --git a/.envrc b/.envrc new file mode 100644 index 000000000..3550a30f2 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7aa992178..d63b62184 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,8 +21,6 @@ jobs: with: submodules: recursive fetch-depth: 2 - - name: Setup Corepack - run: corepack enable - name: Set up Node uses: actions/setup-node@v4 with: @@ -49,6 +47,7 @@ jobs: run: | git config --global user.name undefined git config --global user.email i@undefined.moe + yarn set version stable yarn yarn dedupe env: diff --git a/.gitignore b/.gitignore index d3a937f56..3e8ffb9f4 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ benchmark.json globalConfig.json *.out .clinic/ +.direnv/ .yarn/cache .yarn/build-state.yml .yarn/unplugged diff --git a/flake.lock b/flake.lock index 42c04dd83..c2cc24a92 100644 --- a/flake.lock +++ b/flake.lock @@ -1,12 +1,30 @@ { "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1739446958, - "narHash": "sha256-+/bYK3DbPxMIvSL4zArkMX0LQvS7rzBKXnDXLfKyRVc=", + "lastModified": 1766902085, + "narHash": "sha256-coBu0ONtFzlwwVBzmjacUQwj3G+lybcZ1oeNSQkgC0M=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "2ff53fe64443980e139eaa286017f53f88336dd0", + "rev": "c0b0e0fddf73fd517c3471e546c0df87a42d53f4", "type": "github" }, "original": { @@ -18,8 +36,24 @@ }, "root": { "inputs": { + "flake-utils": "flake-utils", "nixpkgs": "nixpkgs" } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index da4a28850..42d1c3290 100644 --- a/flake.nix +++ b/flake.nix @@ -1,26 +1,44 @@ { description = "Hydro development environment"; - inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - }; + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + inputs.flake-utils.url = "github:numtide/flake-utils"; - outputs = { self, nixpkgs }: - let - system = "x86_64-linux"; - pkgs = nixpkgs.legacyPackages.${system}; - in { - packages.${system}.default = pkgs.hello; - devShells.${system}.default = pkgs.mkShell { - buildInputs = [ - pkgs.nodejs - pkgs.yarn-berry - pkgs.pm2 - pkgs.git - pkgs.gcc - pkgs.go-judge - pkgs.mongodb-ce - ]; - }; - }; -} \ No newline at end of file + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + composeConfig = { + version = "0.5"; + processes = { + hydro = { + command = "${pkgs.nodejs}/bin/node node_modules/.bin/hydrooj --debug --port=2333"; + is_interactive = true; + }; + go-judge = { + command = "${pkgs.go-judge}/bin/go-judge"; + }; + webpack = { + command = "${pkgs.yarn-berry}/bin/yarn build:ui:dev"; + }; + }; + }; + in + { + apps.default = { + type = "app"; + program = "${pkgs.writeShellScript "compose.sh" '' + ${pkgs.process-compose}/bin/process-compose -f ${pkgs.writeText "process-compose.yml" (builtins.toJSON composeConfig)} + ''}"; + }; + + devShells.default = pkgs.mkShell { + buildInputs = with pkgs; [ + nodejs + yarn-berry + gcc + go-judge + ]; + }; + }); +} diff --git a/package.json b/package.json index a78657f24..aaf3dd076 100644 --- a/package.json +++ b/package.json @@ -65,6 +65,5 @@ "resolutions": { "mongodb": "^7.0.0", "@types/express-serve-static-core": "patch:@types/express-serve-static-core@npm%3A4.19.6#~/.yarn/patches/@types-express-serve-static-core-npm-4.19.6-cc0017aaf4.patch" - }, - "packageManager": "yarn@4.10.3" + } }