From 87eaaea091a71d0431ff07c3373b30cf02031121 Mon Sep 17 00:00:00 2001 From: Siddarth Kumar Date: Fri, 11 Jul 2025 13:38:53 +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 | 20 +++++++++++--------- flake.nix | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 9 deletions(-) create mode 100644 flake.nix diff --git a/Jenkinsfile b/Jenkinsfile index c3419e8..69e7357 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,5 @@ #!/usr/bin/env groovy -library 'status-jenkins-lib@v1.8.8' +library 'status-jenkins-lib@v1.9.24' pipeline { agent { label 'linux' } @@ -21,13 +21,13 @@ pipeline { stages { stage('Install') { steps { - sh 'yarn install' + nix.develop('yarn install') } } stage('Build') { steps { script { - sh 'yarn build' + nix.develop('yarn build') jenkins.genBuildMetaJSON('build/build.json') } } } @@ -35,12 +35,14 @@ pipeline { stage('Publish') { steps { sshagent(credentials: ['status-im-auto-ssh']) { - sh """ - ghp-import \ - -b ${deployBranch()} \ - -c ${deployDomain()} \ - -p build - """ + script { + nix.develop(""" + ghp-import \ + -b ${deployBranch()} \ + -c ${deployDomain()} \ + -p build + """, pure: false) + } } } } diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..fc98ecb --- /dev/null +++ b/flake.nix @@ -0,0 +1,33 @@ +{ + description = "Nix flake development shell."; + + inputs = { + nixpkgs.url = "nixpkgs/nixos-24.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; [ + yarn # 1.22.22 + nodejs_20 # v20.15.1 + ghp-import # 2.1.0 + ]; + }; + }); + }; +}