From b623ee2efaaa2f3f5d56ba990f858140d85faeba Mon Sep 17 00:00:00 2001 From: Siddarth Kumar Date: Wed, 30 Jul 2025 22:50:41 +0530 Subject: [PATCH] ci: add nix flake and use in CI Using system tooling can lead to weird behavior of available Node versions, for example this IPv6 resolution error: ``` [3/5] Fetching packages... error Error: connect EHOSTUNREACH 2606:4700::6810:1922:443 at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1495:16) ``` --- Jenkinsfile | 11 +++++++---- flake.lock | 26 ++++++++++++++++++++++++++ flake.nix | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/Jenkinsfile b/Jenkinsfile index 51a6321..e49623a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -22,7 +22,9 @@ pipeline { stages { stage('Install') { steps { - sh 'yarn install' + script { + nix.develop('yarn install') + } } } @@ -35,7 +37,7 @@ pipeline { variable: 'GITHUB_ACCESS_TOKEN' ), ]) { - sh 'yarn build' + nix.develop('yarn build') } jenkins.genBuildMetaJSON('build/build.json') } } @@ -44,12 +46,13 @@ pipeline { stage('Publish') { steps { sshagent(credentials: ['status-im-auto-ssh']) { - sh """ + nix.develop(""" ghp-import \ -b ${deployBranch()} \ -c ${deployDomain()} \ -p build - """ + """, + pure: false) } } } diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..4ee116e --- /dev/null +++ b/flake.lock @@ -0,0 +1,26 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1753749649, + "narHash": "sha256-+jkEZxs7bfOKfBIk430K+tK9IvXlwzqQQnppC2ZKFj4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "1f08a4df998e21f4e8be8fb6fbf61d11a1a5076a", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-25.05", + "type": "indirect" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..bd3e649 --- /dev/null +++ b/flake.nix @@ -0,0 +1,35 @@ +{ + description = "Nix flake development shell."; + + inputs = { + nixpkgs.url = "nixpkgs/nixos-25.05"; + }; + + outputs = + { self, nixpkgs }: + let + supportedSystems = [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + forEachSystem = nixpkgs.lib.genAttrs supportedSystems; + pkgsFor = forEachSystem (system: import nixpkgs { inherit system; }); + in + rec { + formatter = forEachSystem (system: pkgsFor.${system}.nixpkgs-fmt); + + devShells = forEachSystem (system: { + default = pkgsFor.${system}.mkShellNoCC { + packages = with pkgsFor.${system}.buildPackages; [ + git # 2.44.1 + openssh # 9.7p1 + yarn # 1.22.22 + nodejs_20 # v20.15.1 + ghp-import # 2.1.0 + ]; + }; + }); + }; +}