From a9ce5b882f45d60ec584efaea0e22b1c5ca57fdb Mon Sep 17 00:00:00 2001 From: ryoppippi <1560508+ryoppippi@users.noreply.github.com> Date: Mon, 15 Dec 2025 16:28:50 +0000 Subject: [PATCH 1/3] fix(ci): move install to nix action --- .github/actions/setup-nix/action.yaml | 4 ++++ .github/workflows/ci.yaml | 3 --- .github/workflows/dry-publish.yaml | 3 --- .github/workflows/release.yaml | 3 --- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/.github/actions/setup-nix/action.yaml b/.github/actions/setup-nix/action.yaml index 3e2727d..6600015 100644 --- a/.github/actions/setup-nix/action.yaml +++ b/.github/actions/setup-nix/action.yaml @@ -13,3 +13,7 @@ runs: with: name: numtide authToken: '' + + - name: Load Nix development environment + shell: bash + run: nix develop --command true diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5f8a30c..54282d9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -25,9 +25,6 @@ jobs: - name: Setup Nix uses: ./.github/actions/setup-nix - - name: Initialise Nix environment - run: nix develop --command true - - name: Run Lint run: nix develop --command pnpm run lint diff --git a/.github/workflows/dry-publish.yaml b/.github/workflows/dry-publish.yaml index 7eec921..a8468b5 100644 --- a/.github/workflows/dry-publish.yaml +++ b/.github/workflows/dry-publish.yaml @@ -13,8 +13,5 @@ jobs: - name: Setup Nix uses: ./.github/actions/setup-nix - - name: Install dependencies - run: nix develop --command pnpm install --frozen-lockfile - - name: 🚀 Dry Run Publish Package run: nix develop --command pnpm dlx pkg-pr-new publish --pnpm diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index f0d2baa..02243e2 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -41,8 +41,5 @@ jobs: registry-url: 'https://registry.npmjs.org' node-version: lts/* - - name: 💫 Install dependencies - run: nix develop --command pnpm install --frozen-lockfile - - name: 🚀 Publish package run: nix develop --command pnpm publish --provenance --no-git-checks --access public From 9daab629bab2f8660fb9407a0f7132e7ced8ed4f Mon Sep 17 00:00:00 2001 From: ryoppippi <1560508+ryoppippi@users.noreply.github.com> Date: Mon, 15 Dec 2025 23:01:53 +0000 Subject: [PATCH 2/3] refactor(nix): migrate from flake-utils to flake-parts Replace flake-utils with flake-parts for a more modular and type-safe Nix flake configuration. flake-parts uses the NixOS module system pattern, providing better extensibility and composability. Key changes: - Replace flake-utils input with flake-parts - Use mkFlake with perSystem pattern instead of eachDefaultSystem - Explicitly declare supported systems (x86_64-linux, aarch64-linux, aarch64-darwin) - Remove x86_64-darwin from supported systems as it is no longer needed Benefits of flake-parts: - NixOS-style module system for flake configuration - Type-safe options with better error messages - Support for advanced features like partitions and flakeModules - More maintainable structure for complex flake configurations --- flake.lock | 46 +++++++++++++++++++++++----------------------- flake.nix | 21 ++++++++++++--------- 2 files changed, 35 insertions(+), 32 deletions(-) diff --git a/flake.lock b/flake.lock index 9227160..f932ff5 100644 --- a/flake.lock +++ b/flake.lock @@ -1,20 +1,20 @@ { "nodes": { - "flake-utils": { + "flake-parts": { "inputs": { - "systems": "systems" + "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "lastModified": 1765835352, + "narHash": "sha256-XswHlK/Qtjasvhd1nOa1e8MgZ8GS//jBoTqWtrS1Giw=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "a34fae9c08a15ad73f295041fec82323541400a9", "type": "github" }, "original": { - "owner": "numtide", - "repo": "flake-utils", + "owner": "hercules-ci", + "repo": "flake-parts", "type": "github" } }, @@ -34,26 +34,26 @@ "type": "github" } }, - "root": { - "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" - } - }, - "systems": { + "nixpkgs-lib": { "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "lastModified": 1765674936, + "narHash": "sha256-k00uTP4JNfmejrCLJOwdObYC9jHRrr/5M/a/8L2EIdo=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "2075416fcb47225d9b68ac469a5c4801a9c4dd85", "type": "github" }, "original": { - "owner": "nix-systems", - "repo": "default", + "owner": "nix-community", + "repo": "nixpkgs.lib", "type": "github" } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 3333f05..ef581a0 100644 --- a/flake.nix +++ b/flake.nix @@ -3,15 +3,18 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - flake-utils.url = "github:numtide/flake-utils"; + flake-parts.url = "github:hercules-ci/flake-parts"; }; - outputs = { self, nixpkgs, flake-utils }: - flake-utils.lib.eachDefaultSystem (system: - let - pkgs = nixpkgs.legacyPackages.${system}; - in - { + outputs = inputs@{ flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + systems = [ + "x86_64-linux" + "aarch64-linux" + "aarch64-darwin" + ]; + + perSystem = { pkgs, ... }: { devShells.default = pkgs.mkShell { buildInputs = with pkgs; [ pnpm_10 @@ -27,6 +30,6 @@ fi ''; }; - } - ); + }; + }; } From 2c9a8ff3d1e27a07fa0fed16a29ba75e57d81963 Mon Sep 17 00:00:00 2001 From: ryoppippi <1560508+ryoppippi@users.noreply.github.com> Date: Mon, 15 Dec 2025 23:05:13 +0000 Subject: [PATCH 3/3] feat(nix): add nixfmt-rfc-style to dev dependencies and lefthook Add nixfmt-rfc-style as a development dependency in the Nix flake and configure lefthook to automatically format .nix files on pre-commit. Uses `nix develop --command` to run nixfmt from the devShell context, ensuring consistent Nix code formatting across the project. --- flake.nix | 34 +++++++++++++++++++--------------- lefthook.yaml | 4 ++++ 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/flake.nix b/flake.nix index ef581a0..56ade39 100644 --- a/flake.nix +++ b/flake.nix @@ -6,7 +6,8 @@ flake-parts.url = "github:hercules-ci/flake-parts"; }; - outputs = inputs@{ flake-parts, ... }: + outputs = + inputs@{ flake-parts, ... }: flake-parts.lib.mkFlake { inherit inputs; } { systems = [ "x86_64-linux" @@ -14,22 +15,25 @@ "aarch64-darwin" ]; - perSystem = { pkgs, ... }: { - devShells.default = pkgs.mkShell { - buildInputs = with pkgs; [ - pnpm_10 - ]; + perSystem = + { pkgs, ... }: + { + devShells.default = pkgs.mkShell { + buildInputs = with pkgs; [ + pnpm_10 + nixfmt-rfc-style + ]; - shellHook = '' - echo "StackOne AI Node SDK development environment" + shellHook = '' + echo "StackOne AI Node SDK development environment" - # Install dependencies only if node_modules/.pnpm/lock.yaml is older than pnpm-lock.yaml - if [ ! -f node_modules/.pnpm/lock.yaml ] || [ pnpm-lock.yaml -nt node_modules/.pnpm/lock.yaml ]; then - echo "📦 Installing dependencies..." - pnpm install --frozen-lockfile - fi - ''; + # Install dependencies only if node_modules/.pnpm/lock.yaml is older than pnpm-lock.yaml + if [ ! -f node_modules/.pnpm/lock.yaml ] || [ pnpm-lock.yaml -nt node_modules/.pnpm/lock.yaml ]; then + echo "📦 Installing dependencies..." + pnpm install --frozen-lockfile + fi + ''; + }; }; - }; }; } diff --git a/lefthook.yaml b/lefthook.yaml index d982f1f..30a7558 100644 --- a/lefthook.yaml +++ b/lefthook.yaml @@ -9,6 +9,10 @@ pre-commit: glob: '*' run: pnpm oxfmt --no-error-on-unmatched-pattern {staged_files} stage_fixed: true + - name: nixfmt + glob: '*.nix' + run: nix develop --command nixfmt {staged_files} + stage_fixed: true pre-push: jobs: