From 00e532c74e0f31eae9cbac563047f4c1c337deb5 Mon Sep 17 00:00:00 2001 From: Brynley Llewellyn-Roux Date: Tue, 6 Feb 2024 10:42:51 +1100 Subject: [PATCH] feat: switched over to using flakes --- .gitlab-ci.yml | 75 +++++++-------- README.md | 52 ++++++++--- default.nix | 38 -------- flake.lock | 61 +++++++++++++ flake.nix | 161 +++++++++++++++++++++++++++++++++ npmDepsHash | 1 + package.json | 1 + pkgs.nix | 4 - release.nix | 74 --------------- scripts/check-test-generate.sh | 4 +- scripts/npmDepsHash.js | 23 +++++ shell.nix | 44 --------- 12 files changed, 325 insertions(+), 213 deletions(-) delete mode 100644 default.nix create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 npmDepsHash delete mode 100644 pkgs.nix delete mode 100644 release.nix create mode 100755 scripts/npmDepsHash.js delete mode 100644 shell.nix diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8cc1930e..22453503 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -49,7 +49,7 @@ check:lint: needs: [] script: - > - nix-shell --arg ci true --run $' + nix develop .#ci --command bash -c $' npm run lint; npm run lint-shell; ' @@ -67,10 +67,7 @@ check:nix-dry: needs: [] script: - > - nix-shell --arg ci true --run $' - npmDepsHash="$(prefetch-npm-deps ./package-lock.json)"; - nix-build -v -v --dry-run ./release.nix --argstr npmDepsHash "$npmDepsHash"; - ' + nix build .#docker --dry-run rules: # Runs on feature and staging commits and ignores version commits - if: $CI_COMMIT_BRANCH =~ /^(?:feature.*|staging)$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/ @@ -85,7 +82,7 @@ check:test-generate: needs: [] script: - > - nix-shell --arg ci true --run $' + nix develop .#ci --command bash -c $' ./scripts/check-test-generate.sh > ./tmp/check-test.yml; ' artifacts: @@ -127,7 +124,7 @@ build:merge: # Required for `gh pr create` - git remote add upstream "$GH_PROJECT_URL" - > - nix-shell --arg ci true --run $' + nix develop .#ci --command bash -c $' gh pr create \ --head staging \ --base master \ @@ -152,7 +149,7 @@ build:dist: needs: [] script: - > - nix-shell --arg ci true --run $' + nix develop .#ci --command bash -c $' npm run build --verbose; ' artifacts: @@ -170,7 +167,7 @@ build:platforms-generate: needs: [] script: - > - nix-shell --arg ci true --run $' + nix develop .#ci --command bash -c $' ./scripts/build-platforms-generate.sh > ./tmp/build-platforms.yml; ' artifacts: @@ -213,7 +210,7 @@ build:prerelease: - echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ./.npmrc - echo 'Publishing library prerelease' - > - nix-shell --arg ci true --run $' + nix develop .#ci --command bash -c $' npm publish --tag prerelease --access public; ' after_script: @@ -233,26 +230,24 @@ integration:builds: script: - mkdir -p ./builds - > - nix-shell --arg ci true --run $' - npmDepsHash="$(prefetch-npm-deps ./package-lock.json)"; - build_application="$(nix-build \ - --max-jobs "$(nproc)" --cores "$(nproc)" \ - ./release.nix \ - --attr application \ - --argstr npmDepsHash "$npmDepsHash" \ + nix develop .#ci --command bash -c $' + build_application="$(nix build \ + --max-jobs "$(nproc)" \ + --cores "$(nproc)" \ + --print-out-paths \ + .#application \ )"; nix-store --export $( \ nix-store --query --requisites "$build_application" \ ) | gzip > ./builds/polykey-cli.closure.gz; - builds="$(nix-build \ - --max-jobs "$(nproc)" --cores "$(nproc)" \ - ./release.nix \ - --attr docker \ - --attr package.linux.x64.elf \ - --attr package.windows.x64.exe \ - --attr package.macos.x64.macho \ - --argstr npmDepsHash "$npmDepsHash" \ - --argstr commitHash "$CI_COMMIT_SHA")"; + builds="$(nix build \ + --max-jobs "$(nproc)" \ + --cores "$(nproc)" \ + --print-out-paths \ + .#docker \ + .#packages.x86_64-linux.polykey-cli \ + .#packages.x86_64-windows.polykey-cli \ + .#packages.x86_64-darwin.polykey-cli; cp -r $builds ./builds/; ' artifacts: @@ -283,7 +278,7 @@ integration:deployment: script: - echo 'Deploying container image to ECR' - > - nix-shell --arg ci true --run $' + nix develop .#ci --command bash -c $' aws ecr get-login-password \ | skopeo login \ --username AWS \ @@ -295,7 +290,7 @@ integration:deployment: ' - echo 'Waiting for Testnet Deployment' - > - nix-shell --arg ci true --run $' + nix develop .#ci --command bash -c $' ./scripts/wait-for-deploy.js testnet.polykey.com; ' after_script: @@ -343,7 +338,7 @@ integration:docker: - docker info - mkdir $PK_TEST_TMPDIR - > - nix-shell --arg ci true --run $' + nix develop .#ci --command bash -c $' image_and_tag="$(docker load --input ./builds/*docker* | cut -d\' \' -f3)"; docker tag "$image_and_tag" "polykey-cli:testtarget"; npm run test tests/integration/docker; @@ -433,7 +428,7 @@ integration:prerelease: script: - echo 'Publishing application prerelease' - > - nix-shell --arg ci true --run $' + nix develop .#ci --command bash -c $' if gh release view "$CI_COMMIT_TAG" --repo "$GH_PROJECT_PATH" >/dev/null; then \ gh release \ upload "$CI_COMMIT_TAG" \ @@ -461,7 +456,7 @@ integration:prerelease: ' - echo 'Prereleasing container image' - > - nix-shell --arg ci true --run $' + nix develop .#ci --command bash -c $' skopeo login \ --username "$CI_REGISTRY_USER" \ --password "$CI_REGISTRY_PASSWORD" \ @@ -505,7 +500,7 @@ integration:merge: GIT_DEPTH: 0 script: - > - nix-shell --arg ci true --run $' + nix develop .#ci --command bash -c $' printf "Pipeline Succeeded on ${CI_PIPELINE_ID} for ${CI_COMMIT_SHA}\n\n${CI_PIPELINE_URL}" \ | gh pr comment staging \ --body-file - \ @@ -545,7 +540,7 @@ release:deployment:branch: script: - echo 'Deploying container image to ECR' - > - nix-shell --arg ci true --run $' + nix develop .#ci --command bash -c $' aws ecr get-login-password \ | skopeo login \ --username AWS \ @@ -557,7 +552,7 @@ release:deployment:branch: ' - echo 'Waiting for Mainnet Deployment' - > - nix-shell --arg ci true --run $' + nix develop .#ci --command bash -c $' ./scripts/wait-for-deploy.js mainnet.polykey.com; ' after_script: @@ -587,7 +582,7 @@ release:deployment:tag: script: - echo 'Deploying container image to ECR' - > - nix-shell --arg ci true --run $' + nix develop .#ci --command bash -c $' aws ecr get-login-password \ | skopeo login \ --username AWS \ @@ -599,7 +594,7 @@ release:deployment:tag: ' - echo 'Waiting for Mainnet Deployment' - > - nix-shell --arg ci true --run $' + nix develop .#ci --command bash -c $' ./scripts/wait-for-deploy.js mainnet.polykey.com; ' after_script: @@ -625,7 +620,7 @@ release:docker: - docker info - mkdir $PK_TEST_TMPDIR - > - nix-shell --arg ci true --run $' + nix develop .#ci --command bash -c $' image_and_tag="$(docker load --input ./builds/*docker* | cut -d\' \' -f3)"; docker tag "$image_and_tag" "polykey-cli:testtarget"; npm run test tests/integration/docker; @@ -653,12 +648,12 @@ release:distribution: - echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ./.npmrc - echo 'Publishing library' - > - nix-shell --arg ci true --run $' + nix develop .#ci --command bash -c $' npm publish --access public; ' - echo 'Releasing application builds' - > - nix-shell --arg ci true --run $' + nix develop .#ci --command bash -c $' gh release \ create "$CI_COMMIT_TAG" \ builds/*.closure.gz \ @@ -673,7 +668,7 @@ release:distribution: ' - echo 'Releasing container image' - > - nix-shell --arg ci true --run $' + nix develop .#ci --command bash -c $' skopeo login \ --username "$CI_REGISTRY_USER" \ --password "$CI_REGISTRY_PASSWORD" \ diff --git a/README.md b/README.md index 2c3009c3..3d4cc702 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,27 @@ Have a security issue you want to let us know? You can contact us on our website Our main website is https://polykey.com +## Flakes + +Polykey-CLI uses flakes for its build process. By default Nix does not enable this feature. +To enable it by default, add the following to `~/.config/nix/nix.conf` or `/etc/nix/nix.conf`: + +``` +experimental-features = nix-command flakes +``` + +Or if you're on NixOS, you can add it to your flakes system configuration: + +``` +nix.settings.experimental-features = [ "nix-command" "flakes" ]; +``` + +Alternatively, to enable it temporarily append the following to any nix related commands: + +``` +--extra-experimental-features flakes +``` + ## Installation Note that JavaScript libraries are not packaged in Nix. Only JavaScript applications are. @@ -53,8 +74,7 @@ Note that JavaScript libraries are not packaged in Nix. Only JavaScript applicat Building the package: ```sh -npmDepsHash="$(prefetch-npm-deps ./package-lock.json)" -nix-build -E "(import ./pkgs.nix {}).callPackage ./default.nix { npmDepsHash = \"$npmDepsHash\"; }" +nix build .#polykey-cli ``` ### Nix/NixOS @@ -62,17 +82,27 @@ nix-build -E "(import ./pkgs.nix {}).callPackage ./default.nix { npmDepsHash = \ Building the releases: ```sh -nix-build ./release.nix --attr application --argstr npmDepsHash "$(prefetch-npm-deps ./package-lock.json)" -nix-build ./release.nix --attr docker --argstr npmDepsHash "$(prefetch-npm-deps ./package-lock.json)" -nix-build ./release.nix --attr package.linux.x64.elf --argstr npmDepsHash "$(prefetch-npm-deps ./package-lock.json)" -nix-build ./release.nix --attr package.windows.x64.exe --argstr npmDepsHash "$(prefetch-npm-deps ./package-lock.json)" -nix-build ./release.nix --attr package.macos.x64.macho --argstr npmDepsHash "$(prefetch-npm-deps ./package-lock.json)" +# Build the packages for your current platform +nix build .#polykey-cli + +# You can also specify the platform to build for +nix build .#application +nix build .#docker +nix build .#packages.x86_64-linux.polykey-cli +nix build .#packages.x86_64-windows.polykey-cli +nix build .#packages.x86_64-darwin.polykey-cli ``` Install into Nix user profile: ```sh -nix-env -f ./release.nix --install --attr application --argstr npmDepsHash "$(prefetch-npm-deps ./package-lock.json)" +nix profile install github:MatrixAI/Polykey-CLI +``` + +The program can be run directly without installing via `nix run` + +```sh +nix run . -- agent start ``` ### Docker @@ -80,14 +110,14 @@ nix-env -f ./release.nix --install --attr application --argstr npmDepsHash "$(pr Install into Docker: ```sh -loaded="$(docker load --input "$(nix-build ./release.nix --attr docker --argstr npmDepsHash "$(prefetch-npm-deps ./package-lock.json)")")" -image="$(cut -d' ' -f3 <<< "$loaded")" +nix build .#docker +image="$(docker load < result | cut -d' ' -f3)" docker run -it "$image" ``` ## Development -Run `nix-shell`, and once you're inside, you can use: +Run `nix develop`, and once you're inside, you can use: ```sh # install (or reinstall packages from package.json) diff --git a/default.nix b/default.nix deleted file mode 100644 index 0b654e19..00000000 --- a/default.nix +++ /dev/null @@ -1,38 +0,0 @@ -{ npmDepsHash ? "" -, commitHash ? null -, callPackage -, buildNpmPackage -}: - -let - utils = callPackage ./utils.nix {}; -in - if npmDepsHash == "" then - throw "You must provide an `npmDepsHash` using `prefetch-npm-deps` and pass it in as `--argstr npmDepsHash \"...\"`" - else - buildNpmPackage { - # Show full compilation flags - # NIX_DEBUG = 1; - inherit npmDepsHash; - pname = utils.packageName; - version = utils.packageVersion; - src = utils.src; - COMMIT_HASH = commitHash; - GIT_DIR = utils.dotGit; - # Filter out things kept by `src`, these were needed for building - # but not needed for subsequent usage of the store path - postInstall = '' - mv "$packageOut"/build/build.json "$out"/build.json; - rm -rf \ - "$packageOut"/build \ - "$packageOut"/src \ - "$packageOut"/.env.example \ - "$packageOut"/images \ - "$packageOut"/scripts \ - "$packageOut"/tsconfig.build.json \ - "$packageOut"/tsconfig.json \ - "$packageOut"/LICENSE \ - "$packageOut"/ADDITIONAL_TERMS \ - "$packageOut"/README.md; - ''; - } diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..e77edfb0 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1693183237, + "narHash": "sha256-c7OtyBkZ/vZE/WosBpRGRtkbWZjDHGJP7fg1FyB9Dsc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ea5234e7073d5f44728c499192544a84244bf35a", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ea5234e7073d5f44728c499192544a84244bf35a", + "type": "github" + } + }, + "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", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..d7524c2a --- /dev/null +++ b/flake.nix @@ -0,0 +1,161 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs?rev=ea5234e7073d5f44728c499192544a84244bf35a"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + let + # The system being used to build the outputs + buildSystem = "x86_64-linux"; + + # The target systems and their vercel/pkg mapping + systems = { + "x86_64-linux" = [ "linux" "x64" ]; + "x86_64-windows" = [ "win32" "x64" ]; + "x86_64-darwin" = [ "darwin" "x64" ]; + "aarch64-darwin" = [ "darwin" "arm64" ]; + }; + in + flake-utils.lib.eachSystem (builtins.attrNames systems) (targetSystem: + let + platform = builtins.elemAt systems.${targetSystem} 0; + arch = builtins.elemAt systems.${targetSystem} 1; + + pkgs = import nixpkgs { + system = buildSystem; + }; + + utils = pkgs.callPackage ./utils.nix {}; + + commitHash = toString (self.rev or self.dirtyRev); + npmDepsHash = builtins.readFile ./npmDepsHash; + + polykey-cli-app = pkgs.buildNpmPackage { + inherit npmDepsHash; + pname = utils.packageName; + meta = { + # Other meta attributes like description, homepage, license, etc. + mainProgram = "polykey"; + }; + version = utils.packageVersion; + src = utils.src; + COMMIT_HASH = commitHash; + GIT_DIR = if commitHash != null then null else utils.dotGit; + postInstall = '' + mv "$packageOut"/build/build.json "$out"/build.json; + rm -rf \ + "$packageOut"/build \ + "$packageOut"/src \ + "$packageOut"/.env.example \ + "$packageOut"/images \ + "$packageOut"/scripts \ + "$packageOut"/tsconfig.build.json \ + "$packageOut"/tsconfig.json \ + "$packageOut"/LICENSE \ + "$packageOut"/ADDITIONAL_TERMS \ + "$packageOut"/README.md; + ''; + }; + + polykey-cli-pkg = pkgs.buildNpmPackage { + inherit npmDepsHash; + name = "${utils.packageName}-${utils.packageVersion}-${platform}-${arch}"; + src = utils.src; + PKG_CACHE_PATH = utils.pkgCachePath; + PKG_IGNORE_TAG = 1; + COMMIT_HASH = commitHash; + GIT_DIR = if commitHash != null then null else utils.dotGit; + postBuild = '' + npm run pkg -- \ + --output=out \ + --bin=dist/polykey.js \ + --node-version=${utils.nodeVersion} \ + --platform=${platform} \ + --arch=${arch} + ''; + installPhase = '' + cp ${if platform == "win32" then "out.exe" else "out"} $out + ''; + dontFixup = true; + }; + + buildJSON = builtins.fromJSON (builtins.readFile "${polykey-cli-app}/build.json"); + + dockerImage = pkgs.dockerTools.buildImage { + name = polykey-cli-app.name; + copyToRoot = [ polykey-cli-app ]; + keepContentsDirlinks = true; + created = "now"; + extraCommands = '' + mkdir -m 1777 tmp + ''; + config = { + Entrypoint = [ "polykey" ]; + Labels = buildJSON.versionMetadata; + }; + }; + + shell = { ci ? false }: with pkgs; pkgs.mkShell { + nativeBuildInputs = [ + nodejs + prefetch-npm-deps + shellcheck + gitAndTools.gh + gitAndTools.git + awscli2 + skopeo + jq + ]; + PKG_CACHE_PATH = utils.pkgCachePath; + PKG_IGNORE_TAG = 1; + shellHook = '' + echo "Entering $(npm pkg get name)" + set -o allexport + . ./.env + set +o allexport + set -v + ${ + lib.optionalString ci + '' + set -o errexit + set -o nounset + set -o pipefail + shopt -s inherit_errexit + '' + } + mkdir --parents "$(pwd)/tmp" + + export PATH="$(pwd)/dist/bin:$(npm root)/.bin:$PATH" + + npm install --ignore-scripts + + set +v + ''; + }; + in + { + apps = { + default ={ + type = "app"; + program = "${self.packages.${targetSystem}.application}/bin/polykey"; + }; + polykey-cli = { + type = "app"; + program = "${self.packages.${targetSystem}.polykey-cli}"; + }; + }; + + packages = { + polykey-cli = polykey-cli-pkg; + application = polykey-cli-app; + docker = dockerImage; + }; + + devShells = { + default = shell { ci = false; }; + ci = shell { ci = true; }; + }; + } + ); +} diff --git a/npmDepsHash b/npmDepsHash new file mode 100644 index 00000000..cc78e9c6 --- /dev/null +++ b/npmDepsHash @@ -0,0 +1 @@ +sha256-qz2HhS6BAWJzFC4t5oiSK3Pz792aibAaieIiXIgcFHA= diff --git a/package.json b/package.json index 5b7e430e..74bbfc1c 100644 --- a/package.json +++ b/package.json @@ -82,6 +82,7 @@ "prepare": "node ./scripts/build.js", "build": "node ./scripts/build.js", "postversion": "npm install --package-lock-only --ignore-scripts --silent", + "dependencies": "node ./scripts/npmDepsHash.js", "ts-node": "ts-node", "test": "jest", "lint": "eslint '{src,tests,scripts,benches}/**/*.{js,mjs,ts,mts,jsx,tsx}'", diff --git a/pkgs.nix b/pkgs.nix deleted file mode 100644 index 2997ae2e..00000000 --- a/pkgs.nix +++ /dev/null @@ -1,4 +0,0 @@ -import ( - let rev = "ea5234e7073d5f44728c499192544a84244bf35a"; in - builtins.fetchTarball "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz" -) diff --git a/release.nix b/release.nix deleted file mode 100644 index 65fe67b2..00000000 --- a/release.nix +++ /dev/null @@ -1,74 +0,0 @@ -{ npmDepsHash ? "" -, commitHash ? null -, pkgs ? import ./pkgs.nix {} -}: - -with pkgs; -let - utils = callPackage ./utils.nix {}; - buildPkg = platform: arch: - if npmDepsHash == "" then - throw "You must provide an `npmDepsHash` using `prefetch-npm-deps` and pass it in as `--argstr npmDepsHash \"...\"`" - else - buildNpmPackage { - # Show full compilation flags - # NIX_DEBUG = 1; - inherit npmDepsHash; - name = "${utils.packageName}-${utils.packageVersion}-${platform}-${arch}"; - src = utils.src; - PKG_CACHE_PATH = utils.pkgCachePath; - PKG_IGNORE_TAG = 1; - GIT_DIR = utils.dotGit; - postBuild = '' - npm run pkg -- \ - --output=out \ - --bin=dist/polykey.js \ - --node-version=${utils.nodeVersion} \ - --platform=${platform} \ - --arch=${arch} - ''; - installPhase = '' - cp ${if platform == "win32" then "out.exe" else "out"} $out - ''; - dontFixup = true; - }; -in - rec { - application = callPackage ./default.nix { inherit npmDepsHash; inherit commitHash; }; - buildJSON = builtins.fromJSON (builtins.readFile "${application}/build.json"); - docker = dockerTools.buildImage { - name = application.name; - copyToRoot = [ application ]; - # This ensures symlinks to directories are preserved in the image - keepContentsDirlinks = true; - # This adds a correct timestamp, however breaks binary reproducibility - created = "now"; - extraCommands = '' - mkdir -m 1777 tmp - ''; - config = { - Entrypoint = [ "polykey" ]; - Labels = buildJSON.versionMetadata; - }; - }; - package = { - linux = { - x64 = { - elf = buildPkg "linux" "x64"; - }; - }; - windows = { - x64 = { - exe = buildPkg "win32" "x64"; - }; - }; - macos = { - x64 = { - macho = buildPkg "darwin" "x64"; - }; - arm64 = { - macho = buildPkg "darwin" "arm64"; - }; - }; - }; - } diff --git a/scripts/check-test-generate.sh b/scripts/check-test-generate.sh index c284320f..8915b854 100755 --- a/scripts/check-test-generate.sh +++ b/scripts/check-test-generate.sh @@ -70,7 +70,7 @@ check:test $test_dir: needs: [] script: - > - nix-shell --arg ci true --run $' + nix develop .#ci --command bash -c $' npm test -- --ci --coverage ${test_files[@]}; ' artifacts: @@ -94,7 +94,7 @@ check:test index: needs: [] script: - > - nix-shell --arg ci true --run $' + nix develop .#ci --command bash -c $' npm test -- --ci --coverage ${test_files[@]}; ' artifacts: diff --git a/scripts/npmDepsHash.js b/scripts/npmDepsHash.js new file mode 100755 index 00000000..2a547bdf --- /dev/null +++ b/scripts/npmDepsHash.js @@ -0,0 +1,23 @@ +#!/usr/bin/env node + +const fs = require('fs'); +const path = require('path'); +const childProcess = require('child_process'); + +async function main(_argv = process.argv) { + const projectRoot = path.join(__dirname, '..'); + try { + const output = childProcess.execSync( + 'prefetch-npm-deps ./package-lock.json', + ); + const hash = output.toString(); + await fs.promises.writeFile(path.join(projectRoot, 'npmDepsHash'), hash); + } catch (e) { + // eslint-disable-next-line no-console + console.error( + `Warning: prefetch failed with (${e.message}). if npmDepsHash was not updated`, + ); + } +} + +void main(); diff --git a/shell.nix b/shell.nix deleted file mode 100644 index 0a122b44..00000000 --- a/shell.nix +++ /dev/null @@ -1,44 +0,0 @@ -{ pkgs ? import ./pkgs.nix {}, ci ? false }: - -with pkgs; -let - utils = callPackage ./utils.nix {}; -in - mkShell { - nativeBuildInputs = [ - nodejs - prefetch-npm-deps - shellcheck - gitAndTools.gh - gitAndTools.git - awscli2 - skopeo - jq - ]; - PKG_CACHE_PATH = utils.pkgCachePath; - PKG_IGNORE_TAG = 1; - shellHook = '' - echo "Entering $(npm pkg get name)" - set -o allexport - . ./.env - set +o allexport - set -v - ${ - lib.optionalString ci - '' - set -o errexit - set -o nounset - set -o pipefail - shopt -s inherit_errexit - '' - } - mkdir --parents "$(pwd)/tmp" - - # Built executables and NPM executables - export PATH="$(pwd)/dist/bin:$(npm root)/.bin:$PATH" - - npm install --ignore-scripts - - set +v - ''; - }