diff --git a/.eslintrc.json b/.eslintrc.json index 3e73697..6499d3b 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -33,7 +33,7 @@ "@typescript-eslint/array-type": "error", "@typescript-eslint/await-thenable": "error", "@typescript-eslint/ban-ts-comment": "error", - "camelcase": "off", + "camelcase": "error", "@typescript-eslint/consistent-type-assertions": "error", "@typescript-eslint/explicit-function-return-type": [ "error", diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d2d4860..07b3ffa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,10 +14,20 @@ jobs: - uses: actions/checkout@v4 - uses: DeterminateSystems/nix-installer-action@main - uses: DeterminateSystems/magic-nix-cache-action@main - - run: nix develop --command pnpm install - - run: nix develop --command pnpm run all - - run: git status --porcelain=v1 - - run: test $(git status --porcelain=v1 2>/dev/null | wc -l) -eq 0 + - name: pnpm install + run: nix develop --command pnpm install + - name: prettier format + run: nix develop --command pnpm run check-fmt + - name: ESLint + run: nix develop --command pnpm run lint + - name: tsup build + run: nix develop --command pnpm run build + - name: ncc package + run: nix develop --command pnpm run package + - name: Git status + run: git status --porcelain=v1 + - name: Ensure no staged changes + run: git diff --exit-code run-test-suite: name: Run test suite strategy: diff --git a/dist/index.js b/dist/index.js index 7a67781..2533b6a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -77962,672 +77962,6 @@ exports["default"] = _default; /***/ }), -/***/ 711: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -var __webpack_unused_export__; - - -__webpack_unused_export__ = ({ - value: true -}); -Object.defineProperty(exports, "zR", ({ - enumerable: true, - get: function () { - return _nil.default; - } -})); -Object.defineProperty(exports, "Qc", ({ - enumerable: true, - get: function () { - return _parse.default; - } -})); -Object.defineProperty(exports, "Pz", ({ - enumerable: true, - get: function () { - return _stringify.default; - } -})); -Object.defineProperty(exports, "v1", ({ - enumerable: true, - get: function () { - return _v.default; - } -})); -Object.defineProperty(exports, "v3", ({ - enumerable: true, - get: function () { - return _v2.default; - } -})); -Object.defineProperty(exports, "v4", ({ - enumerable: true, - get: function () { - return _v3.default; - } -})); -Object.defineProperty(exports, "v5", ({ - enumerable: true, - get: function () { - return _v4.default; - } -})); -Object.defineProperty(exports, "Gu", ({ - enumerable: true, - get: function () { - return _validate.default; - } -})); -Object.defineProperty(exports, "i8", ({ - enumerable: true, - get: function () { - return _version.default; - } -})); - -var _v = _interopRequireDefault(__nccwpck_require__(2426)); - -var _v2 = _interopRequireDefault(__nccwpck_require__(5198)); - -var _v3 = _interopRequireDefault(__nccwpck_require__(8452)); - -var _v4 = _interopRequireDefault(__nccwpck_require__(7279)); - -var _nil = _interopRequireDefault(__nccwpck_require__(6904)); - -var _version = _interopRequireDefault(__nccwpck_require__(7018)); - -var _validate = _interopRequireDefault(__nccwpck_require__(3497)); - -var _stringify = _interopRequireDefault(__nccwpck_require__(1682)); - -var _parse = _interopRequireDefault(__nccwpck_require__(8721)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -/***/ }), - -/***/ 9434: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; - -var _crypto = _interopRequireDefault(__nccwpck_require__(6113)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function md5(bytes) { - if (Array.isArray(bytes)) { - bytes = Buffer.from(bytes); - } else if (typeof bytes === 'string') { - bytes = Buffer.from(bytes, 'utf8'); - } - - return _crypto.default.createHash('md5').update(bytes).digest(); -} - -var _default = md5; -exports["default"] = _default; - -/***/ }), - -/***/ 6626: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; - -var _crypto = _interopRequireDefault(__nccwpck_require__(6113)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var _default = { - randomUUID: _crypto.default.randomUUID -}; -exports["default"] = _default; - -/***/ }), - -/***/ 6904: -/***/ ((__unused_webpack_module, exports) => { - - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; -var _default = '00000000-0000-0000-0000-000000000000'; -exports["default"] = _default; - -/***/ }), - -/***/ 8721: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; - -var _validate = _interopRequireDefault(__nccwpck_require__(3497)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function parse(uuid) { - if (!(0, _validate.default)(uuid)) { - throw TypeError('Invalid UUID'); - } - - let v; - const arr = new Uint8Array(16); // Parse ########-....-....-....-............ - - arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24; - arr[1] = v >>> 16 & 0xff; - arr[2] = v >>> 8 & 0xff; - arr[3] = v & 0xff; // Parse ........-####-....-....-............ - - arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8; - arr[5] = v & 0xff; // Parse ........-....-####-....-............ - - arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8; - arr[7] = v & 0xff; // Parse ........-....-....-####-............ - - arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8; - arr[9] = v & 0xff; // Parse ........-....-....-....-############ - // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes) - - arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff; - arr[11] = v / 0x100000000 & 0xff; - arr[12] = v >>> 24 & 0xff; - arr[13] = v >>> 16 & 0xff; - arr[14] = v >>> 8 & 0xff; - arr[15] = v & 0xff; - return arr; -} - -var _default = parse; -exports["default"] = _default; - -/***/ }), - -/***/ 7096: -/***/ ((__unused_webpack_module, exports) => { - - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; -var _default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i; -exports["default"] = _default; - -/***/ }), - -/***/ 1996: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = rng; - -var _crypto = _interopRequireDefault(__nccwpck_require__(6113)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -const rnds8Pool = new Uint8Array(256); // # of random values to pre-allocate - -let poolPtr = rnds8Pool.length; - -function rng() { - if (poolPtr > rnds8Pool.length - 16) { - _crypto.default.randomFillSync(rnds8Pool); - - poolPtr = 0; - } - - return rnds8Pool.slice(poolPtr, poolPtr += 16); -} - -/***/ }), - -/***/ 5259: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; - -var _crypto = _interopRequireDefault(__nccwpck_require__(6113)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function sha1(bytes) { - if (Array.isArray(bytes)) { - bytes = Buffer.from(bytes); - } else if (typeof bytes === 'string') { - bytes = Buffer.from(bytes, 'utf8'); - } - - return _crypto.default.createHash('sha1').update(bytes).digest(); -} - -var _default = sha1; -exports["default"] = _default; - -/***/ }), - -/***/ 1682: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; -exports.unsafeStringify = unsafeStringify; - -var _validate = _interopRequireDefault(__nccwpck_require__(3497)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -/** - * Convert array of 16 byte values to UUID string format of the form: - * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX - */ -const byteToHex = []; - -for (let i = 0; i < 256; ++i) { - byteToHex.push((i + 0x100).toString(16).slice(1)); -} - -function unsafeStringify(arr, offset = 0) { - // Note: Be careful editing this code! It's been tuned for performance - // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434 - return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]; -} - -function stringify(arr, offset = 0) { - const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one - // of the following: - // - One or more input array values don't map to a hex octet (leading to - // "undefined" in the uuid) - // - Invalid input values for the RFC `version` or `variant` fields - - if (!(0, _validate.default)(uuid)) { - throw TypeError('Stringified UUID is invalid'); - } - - return uuid; -} - -var _default = stringify; -exports["default"] = _default; - -/***/ }), - -/***/ 2426: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; - -var _rng = _interopRequireDefault(__nccwpck_require__(1996)); - -var _stringify = __nccwpck_require__(1682); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -// **`v1()` - Generate time-based UUID** -// -// Inspired by https://github.com/LiosK/UUID.js -// and http://docs.python.org/library/uuid.html -let _nodeId; - -let _clockseq; // Previous uuid creation time - - -let _lastMSecs = 0; -let _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details - -function v1(options, buf, offset) { - let i = buf && offset || 0; - const b = buf || new Array(16); - options = options || {}; - let node = options.node || _nodeId; - let clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not - // specified. We do this lazily to minimize issues related to insufficient - // system entropy. See #189 - - if (node == null || clockseq == null) { - const seedBytes = options.random || (options.rng || _rng.default)(); - - if (node == null) { - // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1) - node = _nodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]]; - } - - if (clockseq == null) { - // Per 4.2.2, randomize (14 bit) clockseq - clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff; - } - } // UUID timestamps are 100 nano-second units since the Gregorian epoch, - // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so - // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs' - // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00. - - - let msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock - // cycle to simulate higher resolution clock - - let nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs) - - const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression - - if (dt < 0 && options.clockseq === undefined) { - clockseq = clockseq + 1 & 0x3fff; - } // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new - // time interval - - - if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) { - nsecs = 0; - } // Per 4.2.1.2 Throw error if too many uuids are requested - - - if (nsecs >= 10000) { - throw new Error("uuid.v1(): Can't create more than 10M uuids/sec"); - } - - _lastMSecs = msecs; - _lastNSecs = nsecs; - _clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch - - msecs += 12219292800000; // `time_low` - - const tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000; - b[i++] = tl >>> 24 & 0xff; - b[i++] = tl >>> 16 & 0xff; - b[i++] = tl >>> 8 & 0xff; - b[i++] = tl & 0xff; // `time_mid` - - const tmh = msecs / 0x100000000 * 10000 & 0xfffffff; - b[i++] = tmh >>> 8 & 0xff; - b[i++] = tmh & 0xff; // `time_high_and_version` - - b[i++] = tmh >>> 24 & 0xf | 0x10; // include version - - b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant) - - b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low` - - b[i++] = clockseq & 0xff; // `node` - - for (let n = 0; n < 6; ++n) { - b[i + n] = node[n]; - } - - return buf || (0, _stringify.unsafeStringify)(b); -} - -var _default = v1; -exports["default"] = _default; - -/***/ }), - -/***/ 5198: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; - -var _v = _interopRequireDefault(__nccwpck_require__(5192)); - -var _md = _interopRequireDefault(__nccwpck_require__(9434)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -const v3 = (0, _v.default)('v3', 0x30, _md.default); -var _default = v3; -exports["default"] = _default; - -/***/ }), - -/***/ 5192: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports.URL = exports.DNS = void 0; -exports["default"] = v35; - -var _stringify = __nccwpck_require__(1682); - -var _parse = _interopRequireDefault(__nccwpck_require__(8721)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function stringToBytes(str) { - str = unescape(encodeURIComponent(str)); // UTF8 escape - - const bytes = []; - - for (let i = 0; i < str.length; ++i) { - bytes.push(str.charCodeAt(i)); - } - - return bytes; -} - -const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'; -exports.DNS = DNS; -const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8'; -exports.URL = URL; - -function v35(name, version, hashfunc) { - function generateUUID(value, namespace, buf, offset) { - var _namespace; - - if (typeof value === 'string') { - value = stringToBytes(value); - } - - if (typeof namespace === 'string') { - namespace = (0, _parse.default)(namespace); - } - - if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) { - throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)'); - } // Compute hash of namespace and value, Per 4.3 - // Future: Use spread syntax when supported on all platforms, e.g. `bytes = - // hashfunc([...namespace, ... value])` - - - let bytes = new Uint8Array(16 + value.length); - bytes.set(namespace); - bytes.set(value, namespace.length); - bytes = hashfunc(bytes); - bytes[6] = bytes[6] & 0x0f | version; - bytes[8] = bytes[8] & 0x3f | 0x80; - - if (buf) { - offset = offset || 0; - - for (let i = 0; i < 16; ++i) { - buf[offset + i] = bytes[i]; - } - - return buf; - } - - return (0, _stringify.unsafeStringify)(bytes); - } // Function#name is not settable on some platforms (#270) - - - try { - generateUUID.name = name; // eslint-disable-next-line no-empty - } catch (err) {} // For CommonJS default export support - - - generateUUID.DNS = DNS; - generateUUID.URL = URL; - return generateUUID; -} - -/***/ }), - -/***/ 8452: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; - -var _native = _interopRequireDefault(__nccwpck_require__(6626)); - -var _rng = _interopRequireDefault(__nccwpck_require__(1996)); - -var _stringify = __nccwpck_require__(1682); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function v4(options, buf, offset) { - if (_native.default.randomUUID && !buf && !options) { - return _native.default.randomUUID(); - } - - options = options || {}; - - const rnds = options.random || (options.rng || _rng.default)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` - - - rnds[6] = rnds[6] & 0x0f | 0x40; - rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided - - if (buf) { - offset = offset || 0; - - for (let i = 0; i < 16; ++i) { - buf[offset + i] = rnds[i]; - } - - return buf; - } - - return (0, _stringify.unsafeStringify)(rnds); -} - -var _default = v4; -exports["default"] = _default; - -/***/ }), - -/***/ 7279: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; - -var _v = _interopRequireDefault(__nccwpck_require__(5192)); - -var _sha = _interopRequireDefault(__nccwpck_require__(5259)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -const v5 = (0, _v.default)('v5', 0x50, _sha.default); -var _default = v5; -exports["default"] = _default; - -/***/ }), - -/***/ 3497: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; - -var _regex = _interopRequireDefault(__nccwpck_require__(7096)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function validate(uuid) { - return typeof uuid === 'string' && _regex.default.test(uuid); -} - -var _default = validate; -exports["default"] = _default; - -/***/ }), - -/***/ 7018: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - - - -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; - -var _validate = _interopRequireDefault(__nccwpck_require__(3497)); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -function version(uuid) { - if (!(0, _validate.default)(uuid)) { - throw TypeError('Invalid UUID'); - } - - return parseInt(uuid.slice(14, 15), 16); -} - -var _default = version; -exports["default"] = _default; - -/***/ }), - /***/ 369: /***/ ((module) => { @@ -90085,167 +89419,15 @@ function firstString() { // EXTERNAL MODULE: external "path" var external_path_ = __nccwpck_require__(1017); +// EXTERNAL MODULE: external "node:util" +var external_node_util_ = __nccwpck_require__(7261); +// EXTERNAL MODULE: external "os" +var external_os_ = __nccwpck_require__(2037); ;// CONCATENATED MODULE: external "node:crypto" const external_node_crypto_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:crypto"); -;// CONCATENATED MODULE: ./node_modules/.pnpm/github.com+DeterminateSystems+detsys-ts@3a315cdffd83d4b229d4fb16548d22a3756baf28_lprtsns3vmnabnzqpk64lag6gi/node_modules/detsys-ts/dist/correlation.js - - -function identify(projectName) { - const ident = { - correlation_source: "github-actions", - repository: hashEnvironmentVariables("GHR", [ - "GITHUB_SERVER_URL", - "GITHUB_REPOSITORY_OWNER", - "GITHUB_REPOSITORY_OWNER_ID", - "GITHUB_REPOSITORY", - "GITHUB_REPOSITORY_ID", - ]), - workflow: hashEnvironmentVariables("GHW", [ - "GITHUB_SERVER_URL", - "GITHUB_REPOSITORY_OWNER", - "GITHUB_REPOSITORY_OWNER_ID", - "GITHUB_REPOSITORY", - "GITHUB_REPOSITORY_ID", - "GITHUB_WORKFLOW", - ]), - job: hashEnvironmentVariables("GHWJ", [ - "GITHUB_SERVER_URL", - "GITHUB_REPOSITORY_OWNER", - "GITHUB_REPOSITORY_OWNER_ID", - "GITHUB_REPOSITORY", - "GITHUB_REPOSITORY_ID", - "GITHUB_WORKFLOW", - "GITHUB_JOB", - ]), - run: hashEnvironmentVariables("GHWJR", [ - "GITHUB_SERVER_URL", - "GITHUB_REPOSITORY_OWNER", - "GITHUB_REPOSITORY_OWNER_ID", - "GITHUB_REPOSITORY", - "GITHUB_REPOSITORY_ID", - "GITHUB_WORKFLOW", - "GITHUB_JOB", - "GITHUB_RUN_ID", - ]), - run_differentiator: hashEnvironmentVariables("GHWJA", [ - "GITHUB_SERVER_URL", - "GITHUB_REPOSITORY_OWNER", - "GITHUB_REPOSITORY_OWNER_ID", - "GITHUB_REPOSITORY", - "GITHUB_REPOSITORY_ID", - "GITHUB_WORKFLOW", - "GITHUB_JOB", - "GITHUB_RUN_ID", - "GITHUB_RUN_NUMBER", - "GITHUB_RUN_ATTEMPT", - ]), - groups: { - ci: "github-actions", - project: projectName, - github_organization: hashEnvironmentVariables("GHO", [ - "GITHUB_SERVER_URL", - "GITHUB_REPOSITORY_OWNER", - "GITHUB_REPOSITORY_OWNER_ID", - ]), - }, - }; - core.debug("Correlation data:"); - core.debug(JSON.stringify(ident, null, 2)); - return ident; -} -function hashEnvironmentVariables(prefix, variables) { - const hash = (0,external_node_crypto_namespaceObject.createHash)("sha256"); - for (const varName of variables) { - const value = process.env[varName]; - if (value === undefined) { - core.debug(`Environment variable not set: ${varName} -- can't generate the requested identity`); - return undefined; - } - else { - hash.update(value); - hash.update("\0"); - } - } - return `${prefix}-${hash.digest("hex")}`; -} - -;// CONCATENATED MODULE: ./node_modules/.pnpm/github.com+DeterminateSystems+detsys-ts@3a315cdffd83d4b229d4fb16548d22a3756baf28_lprtsns3vmnabnzqpk64lag6gi/node_modules/detsys-ts/dist/package.json -const package_namespaceObject = {"i8":"1.0.0"}; -;// CONCATENATED MODULE: ./node_modules/.pnpm/github.com+DeterminateSystems+detsys-ts@3a315cdffd83d4b229d4fb16548d22a3756baf28_lprtsns3vmnabnzqpk64lag6gi/node_modules/detsys-ts/dist/platform.js - -function getArchOs() { - const envArch = process.env.RUNNER_ARCH; - const envOs = process.env.RUNNER_OS; - if (envArch && envOs) { - return `${envArch}-${envOs}`; - } - else { - core.error(`Can't identify the platform: RUNNER_ARCH or RUNNER_OS undefined (${envArch}-${envOs})`); - throw new Error("RUNNER_ARCH and/or RUNNER_OS is not defined"); - } -} -function getNixPlatform(archOs) { - const archOsMap = new Map([ - ["X64-macOS", "x86_64-darwin"], - ["ARM64-macOS", "aarch64-darwin"], - ["X64-Linux", "x86_64-linux"], - ["ARM64-Linux", "aarch64-linux"], - ]); - const mappedTo = archOsMap.get(archOs); - if (mappedTo) { - return mappedTo; - } - else { - core.error(`ArchOs (${archOs}) doesn't map to a supported Nix platform.`); - throw new Error(`Cannot convert ArchOs (${archOs}) to a supported Nix platform.`); - } -} - -;// CONCATENATED MODULE: ./node_modules/.pnpm/github.com+DeterminateSystems+detsys-ts@3a315cdffd83d4b229d4fb16548d22a3756baf28_lprtsns3vmnabnzqpk64lag6gi/node_modules/detsys-ts/dist/sourcedef.js - -function constructSourceParameters(legacyPrefix) { - const noisilyGetInput = (suffix) => { - const preferredInput = inputStringOrUndef(`source-${suffix}`); - if (!legacyPrefix) { - return preferredInput; - } - // Remaining is for handling cases where the legacy prefix - // should be examined. - const legacyInput = inputStringOrUndef(`${legacyPrefix}-${suffix}`); - if (preferredInput && legacyInput) { - core.warning(`The supported option source-${suffix} and the legacy option ${legacyPrefix}-${suffix} are both set. Preferring source-${suffix}. Please stop setting ${legacyPrefix}-${suffix}.`); - return preferredInput; - } - else if (legacyInput) { - core.warning(`The legacy option ${legacyPrefix}-${suffix} is set. Please migrate to source-${suffix}.`); - return legacyInput; - } - else { - return preferredInput; - } - }; - return { - path: noisilyGetInput("path"), - url: noisilyGetInput("url"), - tag: noisilyGetInput("tag"), - pr: noisilyGetInput("pr"), - branch: noisilyGetInput("branch"), - revision: noisilyGetInput("revision"), - }; -} -function inputStringOrUndef(name) { - const value = core.getInput(name); - if (value === "") { - return undefined; - } - else { - return value; - } -} - // EXTERNAL MODULE: ./node_modules/.pnpm/@actions+cache@3.2.4/node_modules/@actions/cache/lib/cache.js var cache = __nccwpck_require__(6878); -;// CONCATENATED MODULE: ./node_modules/.pnpm/@sindresorhus+is@6.2.0/node_modules/@sindresorhus/is/dist/index.js +;// CONCATENATED MODULE: ./node_modules/.pnpm/@sindresorhus+is@6.3.0/node_modules/@sindresorhus/is/dist/index.js const typedArrayTypeNames = [ 'Int8Array', 'Uint8Array', @@ -91097,458 +90279,458 @@ function assertAny(predicate, ...values) { throw new TypeError(typeErrorMessageMultipleValues(expectedTypes, values)); } } -function assertArray(value, assertion) { +function assertArray(value, assertion, message) { if (!isArray(value)) { - throw new TypeError(typeErrorMessage('Array', value)); + throw new TypeError(message ?? typeErrorMessage('Array', value)); } if (assertion) { // eslint-disable-next-line unicorn/no-array-for-each, unicorn/no-array-callback-reference value.forEach(assertion); } } -function assertArrayBuffer(value) { +function assertArrayBuffer(value, message) { if (!isArrayBuffer(value)) { - throw new TypeError(typeErrorMessage('ArrayBuffer', value)); + throw new TypeError(message ?? typeErrorMessage('ArrayBuffer', value)); } } -function assertArrayLike(value) { +function assertArrayLike(value, message) { if (!isArrayLike(value)) { - throw new TypeError(typeErrorMessage('array-like', value)); + throw new TypeError(message ?? typeErrorMessage('array-like', value)); } } // eslint-disable-next-line @typescript-eslint/ban-types -function assertAsyncFunction(value) { +function assertAsyncFunction(value, message) { if (!isAsyncFunction(value)) { - throw new TypeError(typeErrorMessage('AsyncFunction', value)); + throw new TypeError(message ?? typeErrorMessage('AsyncFunction', value)); } } -function assertAsyncGenerator(value) { +function assertAsyncGenerator(value, message) { if (!isAsyncGenerator(value)) { - throw new TypeError(typeErrorMessage('AsyncGenerator', value)); + throw new TypeError(message ?? typeErrorMessage('AsyncGenerator', value)); } } -function assertAsyncGeneratorFunction(value) { +function assertAsyncGeneratorFunction(value, message) { if (!isAsyncGeneratorFunction(value)) { - throw new TypeError(typeErrorMessage('AsyncGeneratorFunction', value)); + throw new TypeError(message ?? typeErrorMessage('AsyncGeneratorFunction', value)); } } -function assertAsyncIterable(value) { +function assertAsyncIterable(value, message) { if (!isAsyncIterable(value)) { - throw new TypeError(typeErrorMessage('AsyncIterable', value)); + throw new TypeError(message ?? typeErrorMessage('AsyncIterable', value)); } } -function assertBigint(value) { +function assertBigint(value, message) { if (!isBigint(value)) { - throw new TypeError(typeErrorMessage('bigint', value)); + throw new TypeError(message ?? typeErrorMessage('bigint', value)); } } -function assertBigInt64Array(value) { +function assertBigInt64Array(value, message) { if (!isBigInt64Array(value)) { - throw new TypeError(typeErrorMessage('BigInt64Array', value)); + throw new TypeError(message ?? typeErrorMessage('BigInt64Array', value)); } } -function assertBigUint64Array(value) { +function assertBigUint64Array(value, message) { if (!isBigUint64Array(value)) { - throw new TypeError(typeErrorMessage('BigUint64Array', value)); + throw new TypeError(message ?? typeErrorMessage('BigUint64Array', value)); } } -function assertBlob(value) { +function assertBlob(value, message) { if (!isBlob(value)) { - throw new TypeError(typeErrorMessage('Blob', value)); + throw new TypeError(message ?? typeErrorMessage('Blob', value)); } } -function assertBoolean(value) { +function assertBoolean(value, message) { if (!isBoolean(value)) { - throw new TypeError(typeErrorMessage('boolean', value)); + throw new TypeError(message ?? typeErrorMessage('boolean', value)); } } // eslint-disable-next-line @typescript-eslint/ban-types -function assertBoundFunction(value) { +function assertBoundFunction(value, message) { if (!isBoundFunction(value)) { - throw new TypeError(typeErrorMessage('Function', value)); + throw new TypeError(message ?? typeErrorMessage('Function', value)); } } -function assertBuffer(value) { +function assertBuffer(value, message) { if (!isBuffer(value)) { - throw new TypeError(typeErrorMessage('Buffer', value)); + throw new TypeError(message ?? typeErrorMessage('Buffer', value)); } } -function assertClass(value) { +function assertClass(value, message) { if (!isClass(value)) { - throw new TypeError(typeErrorMessage('Class', value)); + throw new TypeError(message ?? typeErrorMessage('Class', value)); } } -function assertDataView(value) { +function assertDataView(value, message) { if (!isDataView(value)) { - throw new TypeError(typeErrorMessage('DataView', value)); + throw new TypeError(message ?? typeErrorMessage('DataView', value)); } } -function assertDate(value) { +function assertDate(value, message) { if (!isDate(value)) { - throw new TypeError(typeErrorMessage('Date', value)); + throw new TypeError(message ?? typeErrorMessage('Date', value)); } } -function assertDirectInstanceOf(instance, class_) { +function assertDirectInstanceOf(instance, class_, message) { if (!isDirectInstanceOf(instance, class_)) { - throw new TypeError(typeErrorMessage('T', instance)); + throw new TypeError(message ?? typeErrorMessage('T', instance)); } } -function assertEmptyArray(value) { +function assertEmptyArray(value, message) { if (!isEmptyArray(value)) { - throw new TypeError(typeErrorMessage('empty array', value)); + throw new TypeError(message ?? typeErrorMessage('empty array', value)); } } -function assertEmptyMap(value) { +function assertEmptyMap(value, message) { if (!isEmptyMap(value)) { - throw new TypeError(typeErrorMessage('empty map', value)); + throw new TypeError(message ?? typeErrorMessage('empty map', value)); } } -function assertEmptyObject(value) { +function assertEmptyObject(value, message) { if (!isEmptyObject(value)) { - throw new TypeError(typeErrorMessage('empty object', value)); + throw new TypeError(message ?? typeErrorMessage('empty object', value)); } } -function assertEmptySet(value) { +function assertEmptySet(value, message) { if (!isEmptySet(value)) { - throw new TypeError(typeErrorMessage('empty set', value)); + throw new TypeError(message ?? typeErrorMessage('empty set', value)); } } -function assertEmptyString(value) { +function assertEmptyString(value, message) { if (!isEmptyString(value)) { - throw new TypeError(typeErrorMessage('empty string', value)); + throw new TypeError(message ?? typeErrorMessage('empty string', value)); } } -function assertEmptyStringOrWhitespace(value) { +function assertEmptyStringOrWhitespace(value, message) { if (!isEmptyStringOrWhitespace(value)) { - throw new TypeError(typeErrorMessage('empty string or whitespace', value)); + throw new TypeError(message ?? typeErrorMessage('empty string or whitespace', value)); } } -function assertEnumCase(value, targetEnum) { +function assertEnumCase(value, targetEnum, message) { if (!isEnumCase(value, targetEnum)) { - throw new TypeError(typeErrorMessage('EnumCase', value)); + throw new TypeError(message ?? typeErrorMessage('EnumCase', value)); } } -function assertError(value) { +function assertError(value, message) { if (!isError(value)) { - throw new TypeError(typeErrorMessage('Error', value)); + throw new TypeError(message ?? typeErrorMessage('Error', value)); } } -function assertEvenInteger(value) { +function assertEvenInteger(value, message) { if (!isEvenInteger(value)) { - throw new TypeError(typeErrorMessage('even integer', value)); + throw new TypeError(message ?? typeErrorMessage('even integer', value)); } } -function assertFalsy(value) { +function assertFalsy(value, message) { if (!isFalsy(value)) { - throw new TypeError(typeErrorMessage('falsy', value)); + throw new TypeError(message ?? typeErrorMessage('falsy', value)); } } -function assertFloat32Array(value) { +function assertFloat32Array(value, message) { if (!isFloat32Array(value)) { - throw new TypeError(typeErrorMessage('Float32Array', value)); + throw new TypeError(message ?? typeErrorMessage('Float32Array', value)); } } -function assertFloat64Array(value) { +function assertFloat64Array(value, message) { if (!isFloat64Array(value)) { - throw new TypeError(typeErrorMessage('Float64Array', value)); + throw new TypeError(message ?? typeErrorMessage('Float64Array', value)); } } -function assertFormData(value) { +function assertFormData(value, message) { if (!isFormData(value)) { - throw new TypeError(typeErrorMessage('FormData', value)); + throw new TypeError(message ?? typeErrorMessage('FormData', value)); } } // eslint-disable-next-line @typescript-eslint/ban-types -function assertFunction(value) { +function assertFunction(value, message) { if (!isFunction(value)) { - throw new TypeError(typeErrorMessage('Function', value)); + throw new TypeError(message ?? typeErrorMessage('Function', value)); } } -function assertGenerator(value) { +function assertGenerator(value, message) { if (!isGenerator(value)) { - throw new TypeError(typeErrorMessage('Generator', value)); + throw new TypeError(message ?? typeErrorMessage('Generator', value)); } } -function assertGeneratorFunction(value) { +function assertGeneratorFunction(value, message) { if (!isGeneratorFunction(value)) { - throw new TypeError(typeErrorMessage('GeneratorFunction', value)); + throw new TypeError(message ?? typeErrorMessage('GeneratorFunction', value)); } } -function assertHtmlElement(value) { +function assertHtmlElement(value, message) { if (!isHtmlElement(value)) { - throw new TypeError(typeErrorMessage('HTMLElement', value)); + throw new TypeError(message ?? typeErrorMessage('HTMLElement', value)); } } -function assertInfinite(value) { +function assertInfinite(value, message) { if (!isInfinite(value)) { - throw new TypeError(typeErrorMessage('infinite number', value)); + throw new TypeError(message ?? typeErrorMessage('infinite number', value)); } } -function assertInRange(value, range) { +function assertInRange(value, range, message) { if (!isInRange(value, range)) { - throw new TypeError(typeErrorMessage('in range', value)); + throw new TypeError(message ?? typeErrorMessage('in range', value)); } } -function assertInt16Array(value) { +function assertInt16Array(value, message) { if (!isInt16Array(value)) { - throw new TypeError(typeErrorMessage('Int16Array', value)); + throw new TypeError(message ?? typeErrorMessage('Int16Array', value)); } } -function assertInt32Array(value) { +function assertInt32Array(value, message) { if (!isInt32Array(value)) { - throw new TypeError(typeErrorMessage('Int32Array', value)); + throw new TypeError(message ?? typeErrorMessage('Int32Array', value)); } } -function assertInt8Array(value) { +function assertInt8Array(value, message) { if (!isInt8Array(value)) { - throw new TypeError(typeErrorMessage('Int8Array', value)); + throw new TypeError(message ?? typeErrorMessage('Int8Array', value)); } } -function assertInteger(value) { +function assertInteger(value, message) { if (!isInteger(value)) { - throw new TypeError(typeErrorMessage('integer', value)); + throw new TypeError(message ?? typeErrorMessage('integer', value)); } } -function assertIterable(value) { +function assertIterable(value, message) { if (!isIterable(value)) { - throw new TypeError(typeErrorMessage('Iterable', value)); + throw new TypeError(message ?? typeErrorMessage('Iterable', value)); } } -function assertMap(value) { +function assertMap(value, message) { if (!isMap(value)) { - throw new TypeError(typeErrorMessage('Map', value)); + throw new TypeError(message ?? typeErrorMessage('Map', value)); } } -function assertNan(value) { +function assertNan(value, message) { if (!isNan(value)) { - throw new TypeError(typeErrorMessage('NaN', value)); + throw new TypeError(message ?? typeErrorMessage('NaN', value)); } } -function assertNativePromise(value) { +function assertNativePromise(value, message) { if (!isNativePromise(value)) { - throw new TypeError(typeErrorMessage('native Promise', value)); + throw new TypeError(message ?? typeErrorMessage('native Promise', value)); } } -function assertNegativeNumber(value) { +function assertNegativeNumber(value, message) { if (!isNegativeNumber(value)) { - throw new TypeError(typeErrorMessage('negative number', value)); + throw new TypeError(message ?? typeErrorMessage('negative number', value)); } } -function assertNodeStream(value) { +function assertNodeStream(value, message) { if (!isNodeStream(value)) { - throw new TypeError(typeErrorMessage('Node.js Stream', value)); + throw new TypeError(message ?? typeErrorMessage('Node.js Stream', value)); } } -function assertNonEmptyArray(value) { +function assertNonEmptyArray(value, message) { if (!isNonEmptyArray(value)) { - throw new TypeError(typeErrorMessage('non-empty array', value)); + throw new TypeError(message ?? typeErrorMessage('non-empty array', value)); } } -function assertNonEmptyMap(value) { +function assertNonEmptyMap(value, message) { if (!isNonEmptyMap(value)) { - throw new TypeError(typeErrorMessage('non-empty map', value)); + throw new TypeError(message ?? typeErrorMessage('non-empty map', value)); } } -function assertNonEmptyObject(value) { +function assertNonEmptyObject(value, message) { if (!isNonEmptyObject(value)) { - throw new TypeError(typeErrorMessage('non-empty object', value)); + throw new TypeError(message ?? typeErrorMessage('non-empty object', value)); } } -function assertNonEmptySet(value) { +function assertNonEmptySet(value, message) { if (!isNonEmptySet(value)) { - throw new TypeError(typeErrorMessage('non-empty set', value)); + throw new TypeError(message ?? typeErrorMessage('non-empty set', value)); } } -function assertNonEmptyString(value) { +function assertNonEmptyString(value, message) { if (!isNonEmptyString(value)) { - throw new TypeError(typeErrorMessage('non-empty string', value)); + throw new TypeError(message ?? typeErrorMessage('non-empty string', value)); } } -function assertNonEmptyStringAndNotWhitespace(value) { +function assertNonEmptyStringAndNotWhitespace(value, message) { if (!isNonEmptyStringAndNotWhitespace(value)) { - throw new TypeError(typeErrorMessage('non-empty string and not whitespace', value)); + throw new TypeError(message ?? typeErrorMessage('non-empty string and not whitespace', value)); } } // eslint-disable-next-line @typescript-eslint/ban-types -function assertNull(value) { +function assertNull(value, message) { if (!isNull(value)) { - throw new TypeError(typeErrorMessage('null', value)); + throw new TypeError(message ?? typeErrorMessage('null', value)); } } // eslint-disable-next-line @typescript-eslint/ban-types -function assertNullOrUndefined(value) { +function assertNullOrUndefined(value, message) { if (!isNullOrUndefined(value)) { - throw new TypeError(typeErrorMessage('null or undefined', value)); + throw new TypeError(message ?? typeErrorMessage('null or undefined', value)); } } -function assertNumber(value) { +function assertNumber(value, message) { if (!isNumber(value)) { - throw new TypeError(typeErrorMessage('number', value)); + throw new TypeError(message ?? typeErrorMessage('number', value)); } } -function assertNumericString(value) { +function assertNumericString(value, message) { if (!isNumericString(value)) { - throw new TypeError(typeErrorMessage('string with a number', value)); + throw new TypeError(message ?? typeErrorMessage('string with a number', value)); } } // eslint-disable-next-line @typescript-eslint/ban-types -function assertObject(value) { +function assertObject(value, message) { if (!isObject(value)) { - throw new TypeError(typeErrorMessage('Object', value)); + throw new TypeError(message ?? typeErrorMessage('Object', value)); } } -function assertObservable(value) { +function assertObservable(value, message) { if (!isObservable(value)) { - throw new TypeError(typeErrorMessage('Observable', value)); + throw new TypeError(message ?? typeErrorMessage('Observable', value)); } } -function assertOddInteger(value) { +function assertOddInteger(value, message) { if (!isOddInteger(value)) { - throw new TypeError(typeErrorMessage('odd integer', value)); + throw new TypeError(message ?? typeErrorMessage('odd integer', value)); } } -function assertPlainObject(value) { +function assertPlainObject(value, message) { if (!isPlainObject(value)) { - throw new TypeError(typeErrorMessage('plain object', value)); + throw new TypeError(message ?? typeErrorMessage('plain object', value)); } } -function assertPositiveNumber(value) { +function assertPositiveNumber(value, message) { if (!isPositiveNumber(value)) { - throw new TypeError(typeErrorMessage('positive number', value)); + throw new TypeError(message ?? typeErrorMessage('positive number', value)); } } -function assertPrimitive(value) { +function assertPrimitive(value, message) { if (!isPrimitive(value)) { - throw new TypeError(typeErrorMessage('primitive', value)); + throw new TypeError(message ?? typeErrorMessage('primitive', value)); } } -function assertPromise(value) { +function assertPromise(value, message) { if (!isPromise(value)) { - throw new TypeError(typeErrorMessage('Promise', value)); + throw new TypeError(message ?? typeErrorMessage('Promise', value)); } } -function assertPropertyKey(value) { +function assertPropertyKey(value, message) { if (!isPropertyKey(value)) { - throw new TypeError(typeErrorMessage('PropertyKey', value)); + throw new TypeError(message ?? typeErrorMessage('PropertyKey', value)); } } -function assertRegExp(value) { +function assertRegExp(value, message) { if (!isRegExp(value)) { - throw new TypeError(typeErrorMessage('RegExp', value)); + throw new TypeError(message ?? typeErrorMessage('RegExp', value)); } } -function assertSafeInteger(value) { +function assertSafeInteger(value, message) { if (!isSafeInteger(value)) { - throw new TypeError(typeErrorMessage('integer', value)); + throw new TypeError(message ?? typeErrorMessage('integer', value)); } } -function assertSet(value) { +function assertSet(value, message) { if (!isSet(value)) { - throw new TypeError(typeErrorMessage('Set', value)); + throw new TypeError(message ?? typeErrorMessage('Set', value)); } } -function assertSharedArrayBuffer(value) { +function assertSharedArrayBuffer(value, message) { if (!isSharedArrayBuffer(value)) { - throw new TypeError(typeErrorMessage('SharedArrayBuffer', value)); + throw new TypeError(message ?? typeErrorMessage('SharedArrayBuffer', value)); } } -function assertString(value) { +function assertString(value, message) { if (!isString(value)) { - throw new TypeError(typeErrorMessage('string', value)); + throw new TypeError(message ?? typeErrorMessage('string', value)); } } -function assertSymbol(value) { +function assertSymbol(value, message) { if (!isSymbol(value)) { - throw new TypeError(typeErrorMessage('symbol', value)); + throw new TypeError(message ?? typeErrorMessage('symbol', value)); } } -function assertTruthy(value) { +function assertTruthy(value, message) { if (!isTruthy(value)) { - throw new TypeError(typeErrorMessage('truthy', value)); + throw new TypeError(message ?? typeErrorMessage('truthy', value)); } } -function assertTupleLike(value, guards) { +function assertTupleLike(value, guards, message) { if (!isTupleLike(value, guards)) { - throw new TypeError(typeErrorMessage('tuple-like', value)); + throw new TypeError(message ?? typeErrorMessage('tuple-like', value)); } } -function assertTypedArray(value) { +function assertTypedArray(value, message) { if (!isTypedArray(value)) { - throw new TypeError(typeErrorMessage('TypedArray', value)); + throw new TypeError(message ?? typeErrorMessage('TypedArray', value)); } } -function assertUint16Array(value) { +function assertUint16Array(value, message) { if (!isUint16Array(value)) { - throw new TypeError(typeErrorMessage('Uint16Array', value)); + throw new TypeError(message ?? typeErrorMessage('Uint16Array', value)); } } -function assertUint32Array(value) { +function assertUint32Array(value, message) { if (!isUint32Array(value)) { - throw new TypeError(typeErrorMessage('Uint32Array', value)); + throw new TypeError(message ?? typeErrorMessage('Uint32Array', value)); } } -function assertUint8Array(value) { +function assertUint8Array(value, message) { if (!isUint8Array(value)) { - throw new TypeError(typeErrorMessage('Uint8Array', value)); + throw new TypeError(message ?? typeErrorMessage('Uint8Array', value)); } } -function assertUint8ClampedArray(value) { +function assertUint8ClampedArray(value, message) { if (!isUint8ClampedArray(value)) { - throw new TypeError(typeErrorMessage('Uint8ClampedArray', value)); + throw new TypeError(message ?? typeErrorMessage('Uint8ClampedArray', value)); } } -function assertUndefined(value) { +function assertUndefined(value, message) { if (!isUndefined(value)) { - throw new TypeError(typeErrorMessage('undefined', value)); + throw new TypeError(message ?? typeErrorMessage('undefined', value)); } } -function assertUrlInstance(value) { +function assertUrlInstance(value, message) { if (!isUrlInstance(value)) { - throw new TypeError(typeErrorMessage('URL', value)); + throw new TypeError(message ?? typeErrorMessage('URL', value)); } } // eslint-disable-next-line unicorn/prevent-abbreviations -function assertUrlSearchParams(value) { +function assertUrlSearchParams(value, message) { if (!isUrlSearchParams(value)) { - throw new TypeError(typeErrorMessage('URLSearchParams', value)); + throw new TypeError(message ?? typeErrorMessage('URLSearchParams', value)); } } -function assertUrlString(value) { +function assertUrlString(value, message) { if (!isUrlString(value)) { - throw new TypeError(typeErrorMessage('string with a URL', value)); + throw new TypeError(message ?? typeErrorMessage('string with a URL', value)); } } -function assertValidDate(value) { +function assertValidDate(value, message) { if (!isValidDate(value)) { - throw new TypeError(typeErrorMessage('valid Date', value)); + throw new TypeError(message ?? typeErrorMessage('valid Date', value)); } } -function assertValidLength(value) { +function assertValidLength(value, message) { if (!isValidLength(value)) { - throw new TypeError(typeErrorMessage('valid length', value)); + throw new TypeError(message ?? typeErrorMessage('valid length', value)); } } // eslint-disable-next-line @typescript-eslint/ban-types -function assertWeakMap(value) { +function assertWeakMap(value, message) { if (!isWeakMap(value)) { - throw new TypeError(typeErrorMessage('WeakMap', value)); + throw new TypeError(message ?? typeErrorMessage('WeakMap', value)); } } // eslint-disable-next-line @typescript-eslint/ban-types -function assertWeakRef(value) { +function assertWeakRef(value, message) { if (!isWeakRef(value)) { - throw new TypeError(typeErrorMessage('WeakRef', value)); + throw new TypeError(message ?? typeErrorMessage('WeakRef', value)); } } // eslint-disable-next-line @typescript-eslint/ban-types -function assertWeakSet(value) { +function assertWeakSet(value, message) { if (!isWeakSet(value)) { - throw new TypeError(typeErrorMessage('WeakSet', value)); + throw new TypeError(message ?? typeErrorMessage('WeakSet', value)); } } -function assertWhitespaceString(value) { +function assertWhitespaceString(value, message) { if (!isWhitespaceString(value)) { - throw new TypeError(typeErrorMessage('whitespace string', value)); + throw new TypeError(message ?? typeErrorMessage('whitespace string', value)); } } /* harmony default export */ const dist = (is); @@ -93321,8 +92503,6 @@ getContentLength_fn = function() { }; -// EXTERNAL MODULE: external "node:util" -var external_node_util_ = __nccwpck_require__(7261); ;// CONCATENATED MODULE: ./node_modules/.pnpm/got@14.2.1/node_modules/got/dist/source/core/utils/is-form-data.js function is_form_data_isFormData(body) { @@ -97198,392 +96378,886 @@ const got = source_create(defaults); ;// CONCATENATED MODULE: external "node:stream/promises" const external_node_stream_promises_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:stream/promises"); -// EXTERNAL MODULE: ./node_modules/.pnpm/uuid@9.0.1/node_modules/uuid/dist/index.js -var uuid_dist = __nccwpck_require__(711); -;// CONCATENATED MODULE: ./node_modules/.pnpm/uuid@9.0.1/node_modules/uuid/wrapper.mjs +;// CONCATENATED MODULE: ./node_modules/.pnpm/github.com+DeterminateSystems+detsys-ts@cd38b227c4d6faca10aed591b1f8863ef7b93dce_nckxvs7jbq6qb4vr5xhgyxcrgy/node_modules/detsys-ts/dist/index.js +var __defProp = Object.defineProperty; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; -const v1 = uuid_dist.v1; -const v3 = uuid_dist.v3; -const v4 = uuid_dist.v4; -const v5 = uuid_dist.v5; -const NIL = uuid_dist/* NIL */.zR; -const version = uuid_dist/* version */.i8; -const validate = uuid_dist/* validate */.Gu; -const stringify = uuid_dist/* stringify */.Pz; -const parse = uuid_dist/* parse */.Qc; +// package.json +var version = "1.0.0"; -;// CONCATENATED MODULE: ./node_modules/.pnpm/github.com+DeterminateSystems+detsys-ts@3a315cdffd83d4b229d4fb16548d22a3756baf28_lprtsns3vmnabnzqpk64lag6gi/node_modules/detsys-ts/dist/main.js - -// eslint-disable-next-line import/extensions +// src/linux-release-info.ts - - - - - - - - - - -const DEFAULT_IDS_HOST = "https://install.determinate.systems"; -const IDS_HOST = process.env["IDS_HOST"] ?? DEFAULT_IDS_HOST; -const EVENT_EXCEPTION = "exception"; -const EVENT_ARTIFACT_CACHE_HIT = "artifact_cache_hit"; -const EVENT_ARTIFACT_CACHE_MISS = "artifact_cache_miss"; -const FACT_ENDED_WITH_EXCEPTION = "ended_with_exception"; -const FACT_FINAL_EXCEPTION = "final_exception"; -class IdsToolbox { - constructor(actionOptions) { - this.actionOptions = makeOptionsConfident(actionOptions); - this.hookMain = undefined; - this.hookPost = undefined; - this.events = []; - this.client = got_dist_source.extend({ - retry: { - limit: 3, - methods: ["GET", "HEAD"], - }, - hooks: { - beforeRetry: [ - (error, retryCount) => { - core.info(`Retrying after error ${error.code}, retry #: ${retryCount}`); - }, - ], - }, - }); - this.facts = { - $lib: "idslib", - $lib_version: package_namespaceObject.i8, - project: this.actionOptions.name, - ids_project: this.actionOptions.idsProjectName, - }; - const params = [ - ["github_action_ref", "GITHUB_ACTION_REF"], - ["github_action_repository", "GITHUB_ACTION_REPOSITORY"], - ["github_event_name", "GITHUB_EVENT_NAME"], - ["$os", "RUNNER_OS"], - ["arch", "RUNNER_ARCH"], - ]; - for (const [target, env] of params) { - const value = process.env[env]; - if (value) { - this.facts[target] = value; - } - } - this.identity = identify(this.actionOptions.name); - this.archOs = getArchOs(); - this.nixSystem = getNixPlatform(this.archOs); - this.facts.arch_os = this.archOs; - this.facts.nix_system = this.nixSystem; - { - const phase = core.getState("idstoolbox_execution_phase"); - if (phase === "") { - core.saveState("idstoolbox_execution_phase", "post"); - this.executionPhase = "main"; - } - else { - this.executionPhase = "post"; - } - this.facts.execution_phase = this.executionPhase; - } - if (this.actionOptions.fetchStyle === "gh-env-style") { - this.architectureFetchSuffix = this.archOs; - } - else if (this.actionOptions.fetchStyle === "nix-style") { - this.architectureFetchSuffix = this.nixSystem; - } - else if (this.actionOptions.fetchStyle === "universal") { - this.architectureFetchSuffix = "universal"; - } - else { - throw new Error(`fetchStyle ${this.actionOptions.fetchStyle} is not a valid style`); - } - this.sourceParameters = constructSourceParameters(this.actionOptions.legacySourcePrefix); - this.recordEvent(`begin_${this.executionPhase}`); - } - onMain(callback) { - this.hookMain = callback; - } - onPost(callback) { - this.hookPost = callback; - } - execute() { - // eslint-disable-next-line github/no-then - this.executeAsync().catch((error) => { - // eslint-disable-next-line no-console - console.log(error); - process.exitCode = 1; - }); - } - async executeAsync() { - try { - process.env.DETSYS_CORRELATION = JSON.stringify(this.getCorrelationHashes()); - if (this.executionPhase === "main" && this.hookMain) { - await this.hookMain(); - } - else if (this.executionPhase === "post" && this.hookPost) { - await this.hookPost(); - } - this.addFact(FACT_ENDED_WITH_EXCEPTION, false); - } - catch (error) { - this.addFact(FACT_ENDED_WITH_EXCEPTION, true); - const reportable = error instanceof Error || typeof error == "string" - ? error.toString() - : JSON.stringify(error); - this.addFact(FACT_FINAL_EXCEPTION, reportable); - if (this.executionPhase === "post") { - core.warning(reportable); - } - else { - core.setFailed(reportable); - } - this.recordEvent(EVENT_EXCEPTION); - } - finally { - await this.complete(); - } - } - addFact(key, value) { - this.facts[key] = value; - } - getDiagnosticsUrl() { - return this.actionOptions.diagnosticsUrl; - } - getUniqueId() { - return (this.identity.run_differentiator || - process.env.RUNNER_TRACKING_ID || - (0,external_node_crypto_namespaceObject.randomUUID)()); - } - getCorrelationHashes() { - return this.identity; - } - recordEvent(eventName, context = {}) { - this.events.push({ - event_name: `${this.actionOptions.eventPrefix}${eventName}`, - context, - correlation: this.identity, - facts: this.facts, - timestamp: new Date(), - }); - } - async fetch() { - core.info(`Fetching from ${this.getUrl()}`); - const correlatedUrl = this.getUrl(); - correlatedUrl.searchParams.set("ci", "github"); - correlatedUrl.searchParams.set("correlation", JSON.stringify(this.identity)); - const versionCheckup = await this.client.head(correlatedUrl); - if (versionCheckup.headers.etag) { - const v = versionCheckup.headers.etag; - core.debug(`Checking the tool cache for ${this.getUrl()} at ${v}`); - const cached = await this.getCachedVersion(v); - if (cached) { - this.facts["artifact_fetched_from_cache"] = true; - core.debug(`Tool cache hit.`); - return cached; - } - } - this.facts["artifact_fetched_from_cache"] = false; - core.debug(`No match from the cache, re-fetching from the redirect: ${versionCheckup.url}`); - const destFile = this.getTemporaryName(); - const fetchStream = this.client.stream(versionCheckup.url); - await (0,external_node_stream_promises_namespaceObject.pipeline)(fetchStream, (0,external_node_fs_namespaceObject.createWriteStream)(destFile, { - encoding: "binary", - mode: 0o755, - })); - if (fetchStream.response?.headers.etag) { - const v = fetchStream.response.headers.etag; - try { - await this.saveCachedVersion(v, destFile); - } - catch (e) { - core.debug(`Error caching the artifact: ${e}`); - } - } - return destFile; - } - async fetchExecutable() { - const binaryPath = await this.fetch(); - await (0,promises_namespaceObject.chmod)(binaryPath, promises_namespaceObject.constants.S_IXUSR | promises_namespaceObject.constants.S_IXGRP); - return binaryPath; - } - async complete() { - this.recordEvent(`complete_${this.executionPhase}`); - await this.submitEvents(); - } - getUrl() { - const p = this.sourceParameters; - if (p.url) { - return new URL(p.url); - } - const fetchUrl = new URL(IDS_HOST); - fetchUrl.pathname += this.actionOptions.idsProjectName; - if (p.tag) { - fetchUrl.pathname += `/tag/${p.tag}`; - } - else if (p.pr) { - fetchUrl.pathname += `/pr/${p.pr}`; - } - else if (p.branch) { - fetchUrl.pathname += `/branch/${p.branch}`; - } - else if (p.revision) { - fetchUrl.pathname += `/rev/${p.revision}`; - } - else { - fetchUrl.pathname += `/stable`; - } - fetchUrl.pathname += `/${this.architectureFetchSuffix}`; - return fetchUrl; - } - cacheKey(version) { - const cleanedVersion = version.replace(/[^a-zA-Z0-9-+.]/g, ""); - return `determinatesystem-${this.actionOptions.name}-${this.architectureFetchSuffix}-${cleanedVersion}`; - } - async getCachedVersion(version) { - const startCwd = process.cwd(); - try { - const tempDir = this.getTemporaryName(); - await (0,promises_namespaceObject.mkdir)(tempDir); - process.chdir(tempDir); - // extremely evil shit right here: - process.env.GITHUB_WORKSPACE_BACKUP = process.env.GITHUB_WORKSPACE; - delete process.env.GITHUB_WORKSPACE; - if (await cache.restoreCache([this.actionOptions.name], this.cacheKey(version), [], undefined, true)) { - this.recordEvent(EVENT_ARTIFACT_CACHE_HIT); - return `${tempDir}/${this.actionOptions.name}`; - } - this.recordEvent(EVENT_ARTIFACT_CACHE_MISS); - return undefined; - } - finally { - process.env.GITHUB_WORKSPACE = process.env.GITHUB_WORKSPACE_BACKUP; - delete process.env.GITHUB_WORKSPACE_BACKUP; - process.chdir(startCwd); - } - } - async saveCachedVersion(version, toolPath) { - const startCwd = process.cwd(); - try { - const tempDir = this.getTemporaryName(); - await (0,promises_namespaceObject.mkdir)(tempDir); - process.chdir(tempDir); - await (0,promises_namespaceObject.copyFile)(toolPath, `${tempDir}/${this.actionOptions.name}`); - // extremely evil shit right here: - process.env.GITHUB_WORKSPACE_BACKUP = process.env.GITHUB_WORKSPACE; - delete process.env.GITHUB_WORKSPACE; - await cache.saveCache([this.actionOptions.name], this.cacheKey(version), undefined, true); - this.recordEvent(EVENT_ARTIFACT_CACHE_HIT); - } - finally { - process.env.GITHUB_WORKSPACE = process.env.GITHUB_WORKSPACE_BACKUP; - delete process.env.GITHUB_WORKSPACE_BACKUP; - process.chdir(startCwd); - } - } - async submitEvents() { - if (!this.actionOptions.diagnosticsUrl) { - core.debug("Diagnostics are disabled. Not sending the following events:"); - core.debug(JSON.stringify(this.events, undefined, 2)); - return; - } - const batch = { - type: "eventlog", - sent_at: new Date(), - events: this.events, - }; - try { - await this.client.post(this.actionOptions.diagnosticsUrl, { - json: batch, - }); - } - catch (error) { - core.debug(`Error submitting diagnostics event: ${error}`); - } - this.events = []; - } - getTemporaryName() { - const _tmpdir = process.env["RUNNER_TEMP"] || (0,external_node_os_.tmpdir)(); - return external_node_path_namespaceObject.join(_tmpdir, `${this.actionOptions.name}-${v4()}`); +var readFileAsync = (0,external_node_util_.promisify)(external_node_fs_namespaceObject.readFile); +var linuxReleaseInfoOptionsDefaults = { + mode: "async", + customFile: null, + debug: false +}; +function releaseInfo(infoOptions) { + const options = { ...linuxReleaseInfoOptionsDefaults, ...infoOptions }; + const searchOsReleaseFileList = osReleaseFileList( + options.customFile + ); + if (external_node_os_.type() !== "Linux") { + if (options.mode === "sync") { + return getOsInfo(); + } else { + return Promise.resolve(getOsInfo()); } + } + if (options.mode === "sync") { + return readSyncOsreleaseFile(searchOsReleaseFileList, options); + } else { + return Promise.resolve( + readAsyncOsReleaseFile(searchOsReleaseFileList, options) + ); + } } -function makeOptionsConfident(actionOptions) { - const idsProjectName = actionOptions.idsProjectName ?? actionOptions.name; - const finalOpts = { - name: actionOptions.name, - idsProjectName, - eventPrefix: actionOptions.eventPrefix || "action:", - fetchStyle: actionOptions.fetchStyle, - legacySourcePrefix: actionOptions.legacySourcePrefix, - diagnosticsUrl: determineDiagnosticsUrl(idsProjectName, actionOptions.diagnosticsUrl), +function formatFileData(sourceData, srcParseData) { + const lines = srcParseData.split("\n"); + for (const line of lines) { + const lineData = line.split("="); + if (lineData.length === 2) { + lineData[1] = lineData[1].replace(/["'\r]/gi, ""); + Object.defineProperty(sourceData, lineData[0].toLowerCase(), { + value: lineData[1], + writable: true, + enumerable: true, + configurable: true + }); + } + } + return sourceData; +} +function osReleaseFileList(customFile) { + const DEFAULT_OS_RELEASE_FILES = ["/etc/os-release", "/usr/lib/os-release"]; + if (!customFile) { + return DEFAULT_OS_RELEASE_FILES; + } else { + return Array(customFile); + } +} +function getOsInfo() { + return { + type: external_node_os_.type(), + platform: external_node_os_.platform(), + hostname: external_node_os_.hostname(), + arch: external_node_os_.arch(), + release: external_node_os_.release() + }; +} +async function readAsyncOsReleaseFile(fileList, options) { + let fileData = null; + for (const osReleaseFile of fileList) { + try { + if (options.debug) { + console.log(`Trying to read '${osReleaseFile}'...`); + } + fileData = await readFileAsync(osReleaseFile, "binary"); + if (options.debug) { + console.log(`Read data: +${fileData}`); + } + break; + } catch (error2) { + if (options.debug) { + console.error(error2); + } + } + } + if (fileData === null) { + throw new Error("Cannot read os-release file!"); + } + return formatFileData(getOsInfo(), fileData); +} +function readSyncOsreleaseFile(releaseFileList, options) { + let fileData = null; + for (const osReleaseFile of releaseFileList) { + try { + if (options.debug) { + console.log(`Trying to read '${osReleaseFile}'...`); + } + fileData = external_node_fs_namespaceObject.readFileSync(osReleaseFile, "binary"); + if (options.debug) { + console.log(`Read data: +${fileData}`); + } + break; + } catch (error2) { + if (options.debug) { + console.error(error2); + } + } + } + if (fileData === null) { + throw new Error("Cannot read os-release file!"); + } + return formatFileData(getOsInfo(), fileData); +} + +// src/actions-core-platform.ts + + + +var getWindowsInfo = async () => { + const { stdout: version2 } = await exec.getExecOutput( + 'powershell -command "(Get-CimInstance -ClassName Win32_OperatingSystem).Version"', + void 0, + { + silent: true + } + ); + const { stdout: name } = await exec.getExecOutput( + 'powershell -command "(Get-CimInstance -ClassName Win32_OperatingSystem).Caption"', + void 0, + { + silent: true + } + ); + return { + name: name.trim(), + version: version2.trim() + }; +}; +var getMacOsInfo = async () => { + const { stdout } = await exec.getExecOutput("sw_vers", void 0, { + silent: true + }); + const version2 = stdout.match(/ProductVersion:\s*(.+)/)?.[1] ?? ""; + const name = stdout.match(/ProductName:\s*(.+)/)?.[1] ?? ""; + return { + name, + version: version2 + }; +}; +var getLinuxInfo = async () => { + let data = {}; + try { + data = releaseInfo({ mode: "sync" }); + core.debug(`Identified release info: ${JSON.stringify(data)}`); + } catch (e) { + core.debug(`Error collecting release info: ${e}`); + } + return { + name: getPropertyViaWithDefault( + data, + ["id", "name", "pretty_name", "id_like"], + "unknown" + ), + version: getPropertyViaWithDefault( + data, + ["version_id", "version", "version_codename"], + "unknown" + ) + }; +}; +function getPropertyViaWithDefault(data, names, defaultValue) { + for (const name of names) { + const ret = getPropertyWithDefault(data, name, defaultValue); + if (ret !== defaultValue) { + return ret; + } + } + return defaultValue; +} +function getPropertyWithDefault(data, name, defaultValue) { + if (!data.hasOwnProperty(name)) { + return defaultValue; + } + const value = data[name]; + if (typeof value !== typeof defaultValue) { + return defaultValue; + } + return value; +} +var platform2 = external_os_.platform(); +var arch2 = external_os_.arch(); +var isWindows = platform2 === "win32"; +var isMacOS = platform2 === "darwin"; +var isLinux = platform2 === "linux"; +async function getDetails() { + return { + ...await (isWindows ? getWindowsInfo() : isMacOS ? getMacOsInfo() : getLinuxInfo()), + platform: platform2, + arch: arch2, + isWindows, + isMacOS, + isLinux + }; +} + +// src/correlation.ts + + +var OPTIONAL_VARIABLES = ["INVOCATION_ID"]; +function identify(projectName) { + const ident = { + correlation_source: "github-actions", + repository: hashEnvironmentVariables("GHR", [ + "GITHUB_SERVER_URL", + "GITHUB_REPOSITORY_OWNER", + "GITHUB_REPOSITORY_OWNER_ID", + "GITHUB_REPOSITORY", + "GITHUB_REPOSITORY_ID" + ]), + workflow: hashEnvironmentVariables("GHW", [ + "GITHUB_SERVER_URL", + "GITHUB_REPOSITORY_OWNER", + "GITHUB_REPOSITORY_OWNER_ID", + "GITHUB_REPOSITORY", + "GITHUB_REPOSITORY_ID", + "GITHUB_WORKFLOW" + ]), + job: hashEnvironmentVariables("GHWJ", [ + "GITHUB_SERVER_URL", + "GITHUB_REPOSITORY_OWNER", + "GITHUB_REPOSITORY_OWNER_ID", + "GITHUB_REPOSITORY", + "GITHUB_REPOSITORY_ID", + "GITHUB_WORKFLOW", + "GITHUB_JOB" + ]), + run: hashEnvironmentVariables("GHWJR", [ + "GITHUB_SERVER_URL", + "GITHUB_REPOSITORY_OWNER", + "GITHUB_REPOSITORY_OWNER_ID", + "GITHUB_REPOSITORY", + "GITHUB_REPOSITORY_ID", + "GITHUB_WORKFLOW", + "GITHUB_JOB", + "GITHUB_RUN_ID" + ]), + run_differentiator: hashEnvironmentVariables("GHWJA", [ + "GITHUB_SERVER_URL", + "GITHUB_REPOSITORY_OWNER", + "GITHUB_REPOSITORY_OWNER_ID", + "GITHUB_REPOSITORY", + "GITHUB_REPOSITORY_ID", + "GITHUB_WORKFLOW", + "GITHUB_JOB", + "GITHUB_RUN_ID", + "GITHUB_RUN_NUMBER", + "GITHUB_RUN_ATTEMPT", + "INVOCATION_ID" + ]), + groups: { + ci: "github-actions", + project: projectName, + github_organization: hashEnvironmentVariables("GHO", [ + "GITHUB_SERVER_URL", + "GITHUB_REPOSITORY_OWNER", + "GITHUB_REPOSITORY_OWNER_ID" + ]) + } + }; + core.debug("Correlation data:"); + core.debug(JSON.stringify(ident, null, 2)); + return ident; +} +function hashEnvironmentVariables(prefix, variables) { + const hash = (0,external_node_crypto_namespaceObject.createHash)("sha256"); + for (const varName of variables) { + let value = process.env[varName]; + if (value === void 0) { + if (OPTIONAL_VARIABLES.includes(varName)) { + core.debug( + `Optional environment variable not set: ${varName} -- substituting with the variable name` + ); + value = varName; + } else { + core.debug( + `Environment variable not set: ${varName} -- can't generate the requested identity` + ); + return void 0; + } + } + hash.update(value); + hash.update("\0"); + } + return `${prefix}-${hash.digest("hex")}`; +} + +// src/platform.ts +var platform_exports = {}; +__export(platform_exports, { + getArchOs: () => getArchOs, + getNixPlatform: () => getNixPlatform +}); + +function getArchOs() { + const envArch = process.env.RUNNER_ARCH; + const envOs = process.env.RUNNER_OS; + if (envArch && envOs) { + return `${envArch}-${envOs}`; + } else { + core.error( + `Can't identify the platform: RUNNER_ARCH or RUNNER_OS undefined (${envArch}-${envOs})` + ); + throw new Error("RUNNER_ARCH and/or RUNNER_OS is not defined"); + } +} +function getNixPlatform(archOs) { + const archOsMap = /* @__PURE__ */ new Map([ + ["X64-macOS", "x86_64-darwin"], + ["ARM64-macOS", "aarch64-darwin"], + ["X64-Linux", "x86_64-linux"], + ["ARM64-Linux", "aarch64-linux"] + ]); + const mappedTo = archOsMap.get(archOs); + if (mappedTo) { + return mappedTo; + } else { + core.error( + `ArchOs (${archOs}) doesn't map to a supported Nix platform.` + ); + throw new Error( + `Cannot convert ArchOs (${archOs}) to a supported Nix platform.` + ); + } +} + +// src/inputs.ts +var inputs_exports = {}; +__export(inputs_exports, { + getBool: () => getBool, + getCommaSeparatedArrayOfStrings: () => getCommaSeparatedArrayOfStrings, + getMultilineStringOrNull: () => getMultilineStringOrNull, + getNumberOrNull: () => getNumberOrNull, + getString: () => getString, + getStringOrNull: () => getStringOrNull, + getStringOrUndefined: () => getStringOrUndefined +}); + +var getBool = (name) => { + return core.getBooleanInput(name); +}; +var getCommaSeparatedArrayOfStrings = (name, stripWhitespace) => { + const strip = stripWhitespace ?? false; + const original = getString(name); + return (strip ? original.replace(/\s+/g, "") : original).split(","); +}; +var getMultilineStringOrNull = (name) => { + const value = core.getMultilineInput(name); + if (value.length === 0) { + return null; + } else { + return value; + } +}; +var getNumberOrNull = (name) => { + const value = core.getInput(name); + if (value === "") { + return null; + } else { + return Number(value); + } +}; +var getString = (name) => { + return core.getInput(name); +}; +var getStringOrNull = (name) => { + const value = core.getInput(name); + if (value === "") { + return null; + } else { + return value; + } +}; +var getStringOrUndefined = (name) => { + const value = core.getInput(name); + if (value === "") { + return void 0; + } else { + return value; + } +}; + +// src/sourcedef.ts + +function constructSourceParameters(legacyPrefix) { + const noisilyGetInput = (suffix) => { + const preferredInput = getStringOrUndefined(`source-${suffix}`); + if (!legacyPrefix) { + return preferredInput; + } + const legacyInput = getStringOrUndefined(`${legacyPrefix}-${suffix}`); + if (preferredInput && legacyInput) { + core.warning( + `The supported option source-${suffix} and the legacy option ${legacyPrefix}-${suffix} are both set. Preferring source-${suffix}. Please stop setting ${legacyPrefix}-${suffix}.` + ); + return preferredInput; + } else if (legacyInput) { + core.warning( + `The legacy option ${legacyPrefix}-${suffix} is set. Please migrate to source-${suffix}.` + ); + return legacyInput; + } else { + return preferredInput; + } + }; + return { + path: noisilyGetInput("path"), + url: noisilyGetInput("url"), + tag: noisilyGetInput("tag"), + pr: noisilyGetInput("pr"), + branch: noisilyGetInput("branch"), + revision: noisilyGetInput("revision") + }; +} + +// src/index.ts + + + + + + + + + +var DEFAULT_IDS_HOST = "https://install.determinate.systems"; +var IDS_HOST = process.env["IDS_HOST"] ?? DEFAULT_IDS_HOST; +var EVENT_EXCEPTION = "exception"; +var EVENT_ARTIFACT_CACHE_HIT = "artifact_cache_hit"; +var EVENT_ARTIFACT_CACHE_MISS = "artifact_cache_miss"; +var FACT_ENDED_WITH_EXCEPTION = "ended_with_exception"; +var FACT_FINAL_EXCEPTION = "final_exception"; +var IdsToolbox = class { + constructor(actionOptions) { + this.actionOptions = makeOptionsConfident(actionOptions); + this.hookMain = void 0; + this.hookPost = void 0; + this.events = []; + this.client = got_dist_source.extend({ + retry: { + limit: 3, + methods: ["GET", "HEAD"] + }, + hooks: { + beforeRetry: [ + (error2, retryCount) => { + core.info( + `Retrying after error ${error2.code}, retry #: ${retryCount}` + ); + } + ] + } + }); + this.facts = { + $lib: "idslib", + $lib_version: version, + project: this.actionOptions.name, + ids_project: this.actionOptions.idsProjectName }; - core.debug("idslib options:"); - core.debug(JSON.stringify(finalOpts, undefined, 2)); - return finalOpts; -} -function determineDiagnosticsUrl(idsProjectName, urlOption) { - if (urlOption === null) { - // Disable diagnostict events - return undefined; + const params = [ + ["github_action_ref", "GITHUB_ACTION_REF"], + ["github_action_repository", "GITHUB_ACTION_REPOSITORY"], + ["github_event_name", "GITHUB_EVENT_NAME"], + ["$os", "RUNNER_OS"], + ["arch", "RUNNER_ARCH"] + ]; + for (const [target, env] of params) { + const value = process.env[env]; + if (value) { + this.facts[target] = value; + } } - if (urlOption !== undefined) { - // Caller specified a specific diagnostics URL - return urlOption; + this.identity = identify(this.actionOptions.name); + this.archOs = getArchOs(); + this.nixSystem = getNixPlatform(this.archOs); + this.facts.arch_os = this.archOs; + this.facts.nix_system = this.nixSystem; + { + getDetails().then((details) => { + if (details.name !== "unknown") { + this.addFact("$os", details.name); + } + if (details.version !== "unknown") { + this.addFact("$os_version", details.version); + } + }).catch((e) => { + core.debug(`Failure getting platform details: ${e}`); + }); } { - // Attempt to use the action input's diagnostic-endpoint option. - // Note: we don't use actionsCore.getInput('diagnostic-endpoint') on purpose: - // getInput silently converts absent data to an empty string. - const providedDiagnosticEndpoint = process.env["INPUT_DIAGNOSTIC-ENDPOINT"]; - if (providedDiagnosticEndpoint === "") { - // User probably explicitly turned it off - return undefined; - } - if (providedDiagnosticEndpoint !== undefined) { - try { - return mungeDiagnosticEndpoint(new URL(providedDiagnosticEndpoint)); - } - catch (e) { - core.info(`User-provided diagnostic endpoint ignored: not a valid URL: ${e}`); - } - } + const phase = core.getState("idstoolbox_execution_phase"); + if (phase === "") { + core.saveState("idstoolbox_execution_phase", "post"); + this.executionPhase = "main"; + } else { + this.executionPhase = "post"; + } + this.facts.execution_phase = this.executionPhase; } + if (this.actionOptions.fetchStyle === "gh-env-style") { + this.architectureFetchSuffix = this.archOs; + } else if (this.actionOptions.fetchStyle === "nix-style") { + this.architectureFetchSuffix = this.nixSystem; + } else if (this.actionOptions.fetchStyle === "universal") { + this.architectureFetchSuffix = "universal"; + } else { + throw new Error( + `fetchStyle ${this.actionOptions.fetchStyle} is not a valid style` + ); + } + this.sourceParameters = constructSourceParameters( + this.actionOptions.legacySourcePrefix + ); + this.recordEvent(`begin_${this.executionPhase}`); + } + onMain(callback) { + this.hookMain = callback; + } + onPost(callback) { + this.hookPost = callback; + } + execute() { + this.executeAsync().catch((error2) => { + console.log(error2); + process.exitCode = 1; + }); + } + async executeAsync() { try { - const diagnosticUrl = new URL(IDS_HOST); - diagnosticUrl.pathname += idsProjectName; - diagnosticUrl.pathname += "/diagnostics"; - return diagnosticUrl; + process.env.DETSYS_CORRELATION = JSON.stringify( + this.getCorrelationHashes() + ); + if (!await this.preflightRequireNix()) { + this.recordEvent("preflight-require-nix-denied"); + return; + } + if (this.executionPhase === "main" && this.hookMain) { + await this.hookMain(); + } else if (this.executionPhase === "post" && this.hookPost) { + await this.hookPost(); + } + this.addFact(FACT_ENDED_WITH_EXCEPTION, false); + } catch (error2) { + this.addFact(FACT_ENDED_WITH_EXCEPTION, true); + const reportable = error2 instanceof Error || typeof error2 == "string" ? error2.toString() : JSON.stringify(error2); + this.addFact(FACT_FINAL_EXCEPTION, reportable); + if (this.executionPhase === "post") { + core.warning(reportable); + } else { + core.setFailed(reportable); + } + this.recordEvent(EVENT_EXCEPTION); + } finally { + await this.complete(); } - catch (e) { - core.info(`Generated diagnostic endpoint ignored: not a valid URL: ${e}`); + } + addFact(key, value) { + this.facts[key] = value; + } + getDiagnosticsUrl() { + return this.actionOptions.diagnosticsUrl; + } + getUniqueId() { + return this.identity.run_differentiator || process.env.RUNNER_TRACKING_ID || (0,external_node_crypto_namespaceObject.randomUUID)(); + } + getCorrelationHashes() { + return this.identity; + } + recordEvent(eventName, context = {}) { + this.events.push({ + event_name: `${this.actionOptions.eventPrefix}${eventName}`, + context, + correlation: this.identity, + facts: this.facts, + timestamp: /* @__PURE__ */ new Date(), + uuid: (0,external_node_crypto_namespaceObject.randomUUID)() + }); + } + async fetch() { + core.startGroup( + `Downloading ${this.actionOptions.name} for ${this.architectureFetchSuffix}` + ); + try { + core.info(`Fetching from ${this.getUrl()}`); + const correlatedUrl = this.getUrl(); + correlatedUrl.searchParams.set("ci", "github"); + correlatedUrl.searchParams.set( + "correlation", + JSON.stringify(this.identity) + ); + const versionCheckup = await this.client.head(correlatedUrl); + if (versionCheckup.headers.etag) { + const v = versionCheckup.headers.etag; + core.debug( + `Checking the tool cache for ${this.getUrl()} at ${v}` + ); + const cached = await this.getCachedVersion(v); + if (cached) { + this.facts["artifact_fetched_from_cache"] = true; + core.debug(`Tool cache hit.`); + return cached; + } + } + this.facts["artifact_fetched_from_cache"] = false; + core.debug( + `No match from the cache, re-fetching from the redirect: ${versionCheckup.url}` + ); + const destFile = this.getTemporaryName(); + const fetchStream = this.client.stream(versionCheckup.url); + await (0,external_node_stream_promises_namespaceObject.pipeline)( + fetchStream, + (0,external_node_fs_namespaceObject.createWriteStream)(destFile, { + encoding: "binary", + mode: 493 + }) + ); + if (fetchStream.response?.headers.etag) { + const v = fetchStream.response.headers.etag; + try { + await this.saveCachedVersion(v, destFile); + } catch (e) { + core.debug(`Error caching the artifact: ${e}`); + } + } + return destFile; + } finally { + core.endGroup(); } - return undefined; + } + async fetchExecutable() { + const binaryPath = await this.fetch(); + await (0,promises_namespaceObject.chmod)(binaryPath, promises_namespaceObject.constants.S_IXUSR | promises_namespaceObject.constants.S_IXGRP); + return binaryPath; + } + async complete() { + this.recordEvent(`complete_${this.executionPhase}`); + await this.submitEvents(); + } + getUrl() { + const p = this.sourceParameters; + if (p.url) { + return new URL(p.url); + } + const fetchUrl = new URL(IDS_HOST); + fetchUrl.pathname += this.actionOptions.idsProjectName; + if (p.tag) { + fetchUrl.pathname += `/tag/${p.tag}`; + } else if (p.pr) { + fetchUrl.pathname += `/pr/${p.pr}`; + } else if (p.branch) { + fetchUrl.pathname += `/branch/${p.branch}`; + } else if (p.revision) { + fetchUrl.pathname += `/rev/${p.revision}`; + } else { + fetchUrl.pathname += `/stable`; + } + fetchUrl.pathname += `/${this.architectureFetchSuffix}`; + return fetchUrl; + } + cacheKey(version2) { + const cleanedVersion = version2.replace(/[^a-zA-Z0-9-+.]/g, ""); + return `determinatesystem-${this.actionOptions.name}-${this.architectureFetchSuffix}-${cleanedVersion}`; + } + async getCachedVersion(version2) { + const startCwd = process.cwd(); + try { + const tempDir = this.getTemporaryName(); + await (0,promises_namespaceObject.mkdir)(tempDir); + process.chdir(tempDir); + process.env.GITHUB_WORKSPACE_BACKUP = process.env.GITHUB_WORKSPACE; + delete process.env.GITHUB_WORKSPACE; + if (await cache.restoreCache( + [this.actionOptions.name], + this.cacheKey(version2), + [], + void 0, + true + )) { + this.recordEvent(EVENT_ARTIFACT_CACHE_HIT); + return `${tempDir}/${this.actionOptions.name}`; + } + this.recordEvent(EVENT_ARTIFACT_CACHE_MISS); + return void 0; + } finally { + process.env.GITHUB_WORKSPACE = process.env.GITHUB_WORKSPACE_BACKUP; + delete process.env.GITHUB_WORKSPACE_BACKUP; + process.chdir(startCwd); + } + } + async saveCachedVersion(version2, toolPath) { + const startCwd = process.cwd(); + try { + const tempDir = this.getTemporaryName(); + await (0,promises_namespaceObject.mkdir)(tempDir); + process.chdir(tempDir); + await (0,promises_namespaceObject.copyFile)(toolPath, `${tempDir}/${this.actionOptions.name}`); + process.env.GITHUB_WORKSPACE_BACKUP = process.env.GITHUB_WORKSPACE; + delete process.env.GITHUB_WORKSPACE; + await cache.saveCache( + [this.actionOptions.name], + this.cacheKey(version2), + void 0, + true + ); + this.recordEvent(EVENT_ARTIFACT_CACHE_HIT); + } finally { + process.env.GITHUB_WORKSPACE = process.env.GITHUB_WORKSPACE_BACKUP; + delete process.env.GITHUB_WORKSPACE_BACKUP; + process.chdir(startCwd); + } + } + async preflightRequireNix() { + let nixLocation; + const pathParts = (process.env["PATH"] || "").split(":"); + for (const location of pathParts) { + const candidateNix = external_node_path_namespaceObject.join(location, "nix"); + try { + await promises_namespaceObject.access(candidateNix, promises_namespaceObject.constants.X_OK); + core.debug(`Found Nix at ${candidateNix}`); + nixLocation = candidateNix; + } catch { + core.debug(`Nix not at ${candidateNix}`); + } + } + this.addFact("nix_location", nixLocation || ""); + if (this.actionOptions.requireNix === "ignore") { + return true; + } + const currentNotFoundState = core.getState( + "idstoolbox_nix_not_found" + ); + if (currentNotFoundState === "not-found") { + return false; + } + if (nixLocation !== void 0) { + return true; + } + core.saveState("idstoolbox_nix_not_found", "not-found"); + switch (this.actionOptions.requireNix) { + case "fail": + core.setFailed( + "This action can only be used when Nix is installed. Add `- uses: DeterminateSystems/nix-installer-action@main` earlier in your workflow." + ); + break; + case "warn": + core.warning( + "This action is in no-op mode because Nix is not installed. Add `- uses: DeterminateSystems/nix-installer-action@main` earlier in your workflow." + ); + break; + } + return false; + } + async submitEvents() { + if (!this.actionOptions.diagnosticsUrl) { + core.debug( + "Diagnostics are disabled. Not sending the following events:" + ); + core.debug(JSON.stringify(this.events, void 0, 2)); + return; + } + const batch = { + type: "eventlog", + sent_at: /* @__PURE__ */ new Date(), + events: this.events + }; + try { + await this.client.post(this.actionOptions.diagnosticsUrl, { + json: batch + }); + } catch (error2) { + core.debug(`Error submitting diagnostics event: ${error2}`); + } + this.events = []; + } + getTemporaryName() { + const _tmpdir = process.env["RUNNER_TEMP"] || (0,external_node_os_.tmpdir)(); + return external_node_path_namespaceObject.join(_tmpdir, `${this.actionOptions.name}-${(0,external_node_crypto_namespaceObject.randomUUID)()}`); + } +}; +function makeOptionsConfident(actionOptions) { + const idsProjectName = actionOptions.idsProjectName ?? actionOptions.name; + const finalOpts = { + name: actionOptions.name, + idsProjectName, + eventPrefix: actionOptions.eventPrefix || "action:", + fetchStyle: actionOptions.fetchStyle, + legacySourcePrefix: actionOptions.legacySourcePrefix, + requireNix: actionOptions.requireNix, + diagnosticsUrl: determineDiagnosticsUrl( + idsProjectName, + actionOptions.diagnosticsUrl + ) + }; + core.debug("idslib options:"); + core.debug(JSON.stringify(finalOpts, void 0, 2)); + return finalOpts; +} +function determineDiagnosticsUrl(idsProjectName, urlOption) { + if (urlOption === null) { + return void 0; + } + if (urlOption !== void 0) { + return urlOption; + } + { + const providedDiagnosticEndpoint = process.env["INPUT_DIAGNOSTIC-ENDPOINT"]; + if (providedDiagnosticEndpoint === "") { + return void 0; + } + if (providedDiagnosticEndpoint !== void 0) { + try { + return mungeDiagnosticEndpoint(new URL(providedDiagnosticEndpoint)); + } catch (e) { + core.info( + `User-provided diagnostic endpoint ignored: not a valid URL: ${e}` + ); + } + } + } + try { + const diagnosticUrl = new URL(IDS_HOST); + diagnosticUrl.pathname += idsProjectName; + diagnosticUrl.pathname += "/diagnostics"; + return diagnosticUrl; + } catch (e) { + core.info( + `Generated diagnostic endpoint ignored: not a valid URL: ${e}` + ); + } + return void 0; } function mungeDiagnosticEndpoint(inputUrl) { - if (DEFAULT_IDS_HOST === IDS_HOST) { - return inputUrl; - } - try { - const defaultIdsHost = new URL(DEFAULT_IDS_HOST); - const currentIdsHost = new URL(IDS_HOST); - if (inputUrl.origin !== defaultIdsHost.origin) { - return inputUrl; - } - inputUrl.protocol = currentIdsHost.protocol; - inputUrl.host = currentIdsHost.host; - inputUrl.username = currentIdsHost.username; - inputUrl.password = currentIdsHost.password; - return inputUrl; - } - catch (e) { - core.info(`Default or overridden IDS host isn't a valid URL: ${e}`); - } + if (DEFAULT_IDS_HOST === IDS_HOST) { return inputUrl; + } + try { + const defaultIdsHost = new URL(DEFAULT_IDS_HOST); + const currentIdsHost = new URL(IDS_HOST); + if (inputUrl.origin !== defaultIdsHost.origin) { + return inputUrl; + } + inputUrl.protocol = currentIdsHost.protocol; + inputUrl.host = currentIdsHost.host; + inputUrl.username = currentIdsHost.username; + inputUrl.password = currentIdsHost.password; + return inputUrl; + } catch (e) { + core.info(`Default or overridden IDS host isn't a valid URL: ${e}`); + } + return inputUrl; } +/*! + * linux-release-info + * Get Linux release info (distribution name, version, arch, release, etc.) + * from '/etc/os-release' or '/usr/lib/os-release' files and from native os + * module. On Windows and Darwin platforms it only returns common node os module + * info (platform, hostname, release, and arch) + * + * Licensed under MIT + * Copyright (c) 2018-2020 [Samuel Carreira] + */ +//# sourceMappingURL=index.js.map ;// CONCATENATED MODULE: ./dist/main.js @@ -97596,52 +97270,73 @@ function mungeDiagnosticEndpoint(inputUrl) { +// Nix installation events +const EVENT_INSTALL_NIX_FAILURE = "install_nix_failure"; +const EVENT_INSTALL_NIX_START = "install_nix_start"; +const EVENT_INSTALL_NIX_SUCCESS = "install_nix_start"; +const EVENT_SETUP_KVM = "setup_kvm"; +const EVENT_UNINSTALL_NIX = "uninstall"; +// Docker events +const EVENT_CLEAN_UP_DOCKER_SHIM = "clean_up_docker_shim"; +const EVENT_START_DOCKER_SHIM = "start_docker_shim"; +// FlakeHub events +const EVENT_LOGIN_TO_FLAKEHUB = "login_to_flakehub"; +// Other events +const EVENT_CONCLUDE_WORKFLOW = "conclude_workflow"; +// Facts +const FACT_HAS_DOCKER = "has_docker"; +const FACT_HAS_SYSTEMD = "has_systemd"; +const FACT_IN_GITHUB_ACTIONS = "in_act"; +const FACT_IN_NAMESPACE_SO = "in_namespace_so"; +const FACT_NIX_INSTALLER_PLANNER = "nix_installer_planner"; class NixInstallerAction { constructor() { this.idslib = new IdsToolbox({ name: "nix-installer", fetchStyle: "nix-style", legacySourcePrefix: "nix-installer", + requireNix: "ignore", }); - this.platform = get_nix_platform(); - this.nix_package_url = action_input_string_or_null("nix-package-url"); - this.backtrace = action_input_string_or_null("backtrace"); - this.extra_args = action_input_string_or_null("extra-args"); - this.extra_conf = action_input_multiline_string_or_null("extra-conf"); - this.flakehub = action_input_bool("flakehub"); - this.kvm = action_input_bool("kvm"); - this.force_docker_shim = action_input_bool("force-docker-shim"); - this.github_token = action_input_string_or_null("github-token"); - this.github_server_url = action_input_string_or_null("github-server-url"); - this.init = action_input_string_or_null("init"); - this.local_root = action_input_string_or_null("local-root"); - this.log_directives = action_input_string_or_null("log-directives"); - this.logger = action_input_string_or_null("logger"); - this.ssl_cert_file = action_input_string_or_null("ssl-cert-file"); - this.proxy = action_input_string_or_null("proxy"); - this.mac_case_sensitive = action_input_string_or_null("mac-case-sensitive"); - this.mac_encrypt = action_input_string_or_null("mac-encrypt"); - this.mac_root_disk = action_input_string_or_null("mac-root-disk"); - this.mac_volume_label = action_input_string_or_null("mac-volume-label"); - this.modify_profile = action_input_bool("modify-profile"); - this.nix_build_group_id = action_input_number_or_null("nix-build-group-id"); - this.nix_build_group_name = action_input_string_or_null("nix-build-group-name"); - this.nix_build_user_base = action_input_number_or_null("nix_build-user-base"); - this.nix_build_user_count = action_input_number_or_null("nix-build-user-count"); - this.nix_build_user_prefix = action_input_string_or_null("nix-build-user-prefix"); - this.planner = action_input_string_or_null("planner"); - this.reinstall = action_input_bool("reinstall"); - this.start_daemon = action_input_bool("start-daemon"); - this.trust_runner_user = action_input_bool("trust-runner-user"); + this.platform = platform_exports.getNixPlatform(platform_exports.getArchOs()); + this.nixPackageUrl = inputs_exports.getStringOrNull("nix-package-url"); + this.backtrace = inputs_exports.getStringOrNull("backtrace"); + this.extraArgs = inputs_exports.getStringOrNull("extra-args"); + this.extraConf = inputs_exports.getMultilineStringOrNull("extra-conf"); + this.flakehub = inputs_exports.getBool("flakehub"); + this.kvm = inputs_exports.getBool("kvm"); + this.forceDockerShim = inputs_exports.getBool("force-docker-shim"); + this.githubToken = inputs_exports.getStringOrNull("github-token"); + this.githubServerUrl = inputs_exports.getStringOrNull("github-server-url"); + this.init = inputs_exports.getStringOrNull("init"); + this.localRoot = inputs_exports.getStringOrNull("local-root"); + this.logDirectives = inputs_exports.getStringOrNull("log-directives"); + this.logger = inputs_exports.getStringOrNull("logger"); + this.sslCertFile = inputs_exports.getStringOrNull("ssl-cert-file"); + this.proxy = inputs_exports.getStringOrNull("proxy"); + this.macCaseSensitive = inputs_exports.getStringOrNull("mac-case-sensitive"); + this.macEncrypt = inputs_exports.getStringOrNull("mac-encrypt"); + this.macRootDisk = inputs_exports.getStringOrNull("mac-root-disk"); + this.macVolumeLabel = inputs_exports.getStringOrNull("mac-volume-label"); + this.modifyProfile = inputs_exports.getBool("modify-profile"); + this.nixBuildGroupId = inputs_exports.getNumberOrNull("nix-build-group-id"); + this.nixBuildGroupName = inputs_exports.getStringOrNull("nix-build-group-name"); + this.nixBuildUserBase = inputs_exports.getNumberOrNull("nix-build-user-base"); + this.nixBuildUserCount = inputs_exports.getNumberOrNull("nix-build-user-count"); + this.nixBuildUserPrefix = inputs_exports.getStringOrNull("nix-build-user-prefix"); + this.planner = inputs_exports.getStringOrNull("planner"); + this.reinstall = inputs_exports.getBool("reinstall"); + this.startDaemon = inputs_exports.getBool("start-daemon"); + this.trustRunnerUser = inputs_exports.getBool("trust-runner-user"); } async detectAndForceDockerShim() { + const runnerOs = process.env["RUNNER_OS"]; // Detect if we're in a GHA runner which is Linux, doesn't have Systemd, and does have Docker. // This is a common case in self-hosted runners, providers like [Namespace](https://namespace.so/), // and especially GitHub Enterprise Server. - if (process.env.RUNNER_OS !== "Linux") { - if (this.force_docker_shim) { + if (runnerOs !== "Linux") { + if (this.forceDockerShim) { core.warning("Ignoring force-docker-shim which is set to true, as it is only supported on Linux."); - this.force_docker_shim = false; + this.forceDockerShim = false; } return; } @@ -97649,20 +97344,20 @@ class NixInstallerAction { throwIfNoEntry: false, }); if (systemdCheck?.isDirectory()) { - if (this.force_docker_shim) { + if (this.forceDockerShim) { core.warning("Systemd is detected, but ignoring it since force-docker-shim is enabled."); } else { - this.idslib.addFact("has_systemd", true); + this.idslib.addFact(FACT_HAS_SYSTEMD, true); return; } } - this.idslib.addFact("has_systemd", false); + this.idslib.addFact(FACT_HAS_SYSTEMD, false); core.debug("Linux detected without systemd, testing for Docker with `docker info` as an alternative daemon supervisor."); - this.idslib.addFact("has_docker", false); // Set to false here, and only in the success case do we set it to true - let exit_code; + this.idslib.addFact(FACT_HAS_DOCKER, false); // Set to false here, and only in the success case do we set it to true + let exitCode; try { - exit_code = await exec.exec("docker", ["info"], { + exitCode = await exec.exec("docker", ["info"], { silent: true, listeners: { stdout: (data) => { @@ -97680,20 +97375,20 @@ class NixInstallerAction { }, }); } - catch (e) { + catch { core.debug("Docker not detected, not enabling docker shim."); return; } - if (exit_code !== 0) { - if (this.force_docker_shim) { + if (exitCode !== 0) { + if (this.forceDockerShim) { core.warning("docker info check failed, but trying anyway since force-docker-shim is enabled."); } else { return; } } - this.idslib.addFact("has_docker", true); - if (!this.force_docker_shim && + this.idslib.addFact(FACT_HAS_DOCKER, true); + if (!this.forceDockerShim && (await this.detectDockerWithMountedDockerSocket())) { core.debug("Detected a Docker container with a Docker socket mounted, not enabling docker shim."); return; @@ -97707,7 +97402,7 @@ class NixInstallerAction { core.info(`Changing planner from '${this.planner}' to 'linux'`); this.planner = "linux"; } - this.force_docker_shim = true; + this.forceDockerShim = true; core.endGroup(); } // Detect if we are running under `act` or some other system which is not using docker-in-docker, @@ -97715,13 +97410,13 @@ class NixInstallerAction { // In the case of the socket mount solution, the shim will cause issues since the given mount paths will // equate to mount paths on the host, not mount paths to the docker container in question. async detectDockerWithMountedDockerSocket() { - let cgroups_buffer; + let cgroupsBuffer; try { // If we are inside a docker container, the last line of `/proc/self/cgroup` should be // 0::/docker/$SOME_ID // // If we are not, the line will likely be `0::/` - cgroups_buffer = await (0,promises_namespaceObject.readFile)("/proc/self/cgroup", { + cgroupsBuffer = await (0,promises_namespaceObject.readFile)("/proc/self/cgroup", { encoding: "utf-8", }); } @@ -97729,48 +97424,48 @@ class NixInstallerAction { core.debug(`Did not detect \`/proc/self/cgroup\` existence, bailing on docker container ID detection:\n${e}`); return false; } - const cgroups = cgroups_buffer.trim().split("\n"); - const last_cgroup = cgroups[cgroups.length - 1]; - const last_cgroup_parts = last_cgroup.split(":"); - const last_cgroup_path = last_cgroup_parts[last_cgroup_parts.length - 1]; - if (!last_cgroup_path.includes("/docker/")) { + const cgroups = cgroupsBuffer.trim().split("\n"); + const lastCgroup = cgroups[cgroups.length - 1]; + const lastCgroupParts = lastCgroup.split(":"); + const lastCgroupPath = lastCgroupParts[lastCgroupParts.length - 1]; + if (!lastCgroupPath.includes("/docker/")) { core.debug("Did not detect a container ID, bailing on docker.sock detection"); return false; } // We are in a docker container, now to determine if this container is visible from // the `docker` command, and if so, if there is a `docker.socket` mounted. - const last_cgroup_path_parts = last_cgroup_path.split("/"); - const container_id = last_cgroup_path_parts[last_cgroup_path_parts.length - 1]; + const lastCgroupPathParts = lastCgroupPath.split("/"); + const containerId = lastCgroupPathParts[lastCgroupPathParts.length - 1]; // If we cannot `docker inspect` this discovered container ID, we'll fall through to the `catch` below. - let stdout_buffer = ""; - let stderr_buffer = ""; - let exit_code; + let stdoutBuffer = ""; + let stderrBuffer = ""; + let exitCode; try { - exit_code = await exec.exec("docker", ["inspect", container_id], { + exitCode = await exec.exec("docker", ["inspect", containerId], { silent: true, listeners: { stdout: (data) => { - stdout_buffer += data.toString("utf-8"); + stdoutBuffer += data.toString("utf-8"); }, stderr: (data) => { - stderr_buffer += data.toString("utf-8"); + stderrBuffer += data.toString("utf-8"); }, }, }); } catch (e) { - core.debug(`Could not execute \`docker inspect ${container_id}\`, bailing on docker container inspection:\n${e}`); + core.debug(`Could not execute \`docker inspect ${containerId}\`, bailing on docker container inspection:\n${e}`); return false; } - if (exit_code !== 0) { - core.debug(`Unable to inspect detected docker container with id \`${container_id}\`, bailing on container inspection (exit ${exit_code}):\n${stderr_buffer}`); + if (exitCode !== 0) { + core.debug(`Unable to inspect detected docker container with id \`${containerId}\`, bailing on container inspection (exit ${exitCode}):\n${stderrBuffer}`); return false; } - const output = JSON.parse(stdout_buffer); + const output = JSON.parse(stdoutBuffer); // `docker inspect $ID` prints an array containing objects. // In our use case, we should only see 1 item in the array. if (output.length !== 1) { - core.debug(`Got \`docker inspect ${container_id}\` output which was not one item (was ${output.length}), bailing on docker.sock detection.`); + core.debug(`Got \`docker inspect ${containerId}\` output which was not one item (was ${output.length}), bailing on docker.sock detection.`); return false; } const item = output[0]; @@ -97779,203 +97474,203 @@ class NixInstallerAction { // We are looking for a `Destination` ending with `docker.sock`. const mounts = item["Mounts"]; if (typeof mounts !== "object") { - core.debug(`Got non-object in \`Mounts\` field of \`docker inspect ${container_id}\` output, bailing on docker.sock detection.`); + core.debug(`Got non-object in \`Mounts\` field of \`docker inspect ${containerId}\` output, bailing on docker.sock detection.`); return false; } - let found_docker_sock_mount = false; + let foundDockerSockMount = false; for (const mount of mounts) { const destination = mount["Destination"]; if (typeof destination === "string") { if (destination.endsWith("docker.sock")) { - found_docker_sock_mount = true; + foundDockerSockMount = true; break; } } } - return found_docker_sock_mount; + return foundDockerSockMount; } async executionEnvironment() { - const execution_env = {}; - execution_env.NIX_INSTALLER_NO_CONFIRM = "true"; - execution_env.NIX_INSTALLER_DIAGNOSTIC_ATTRIBUTION = JSON.stringify(this.idslib.getCorrelationHashes()); + const executionEnv = {}; + const runnerOs = process.env["RUNNER_OS"]; + executionEnv.NIX_INSTALLER_NO_CONFIRM = "true"; + executionEnv.NIX_INSTALLER_DIAGNOSTIC_ATTRIBUTION = JSON.stringify(this.idslib.getCorrelationHashes()); if (this.backtrace !== null) { - execution_env.RUST_BACKTRACE = this.backtrace; + executionEnv.RUST_BACKTRACE = this.backtrace; } - if (this.modify_profile !== null) { - if (this.modify_profile) { - execution_env.NIX_INSTALLER_MODIFY_PROFILE = "true"; + if (this.modifyProfile !== null) { + if (this.modifyProfile) { + executionEnv.NIX_INSTALLER_MODIFY_PROFILE = "true"; } else { - execution_env.NIX_INSTALLER_MODIFY_PROFILE = "false"; + executionEnv.NIX_INSTALLER_MODIFY_PROFILE = "false"; } } - if (this.nix_build_group_id !== null) { - execution_env.NIX_INSTALLER_NIX_BUILD_GROUP_ID = `${this.nix_build_group_id}`; + if (this.nixBuildGroupId !== null) { + executionEnv.NIX_INSTALLER_NIX_BUILD_GROUP_ID = `${this.nixBuildGroupId}`; } - if (this.nix_build_group_name !== null) { - execution_env.NIX_INSTALLER_NIX_BUILD_GROUP_NAME = - this.nix_build_group_name; + if (this.nixBuildGroupName !== null) { + executionEnv.NIX_INSTALLER_NIX_BUILD_GROUP_NAME = this.nixBuildGroupName; } - if (this.nix_build_user_prefix !== null) { - execution_env.NIX_INSTALLER_NIX_BUILD_USER_PREFIX = - this.nix_build_user_prefix; + if (this.nixBuildUserPrefix !== null) { + executionEnv.NIX_INSTALLER_NIX_BUILD_USER_PREFIX = + this.nixBuildUserPrefix; } - if (this.nix_build_user_count !== null) { - execution_env.NIX_INSTALLER_NIX_BUILD_USER_COUNT = `${this.nix_build_user_count}`; + if (this.nixBuildUserCount !== null) { + executionEnv.NIX_INSTALLER_NIX_BUILD_USER_COUNT = `${this.nixBuildUserCount}`; } - if (this.nix_build_user_base !== null) { - execution_env.NIX_INSTALLER_NIX_BUILD_USER_ID_BASE = `${this.nix_build_user_count}`; + if (this.nixBuildUserBase !== null) { + executionEnv.NIX_INSTALLER_NIX_BUILD_USER_ID_BASE = `${this.nixBuildUserCount}`; } - if (this.nix_package_url !== null) { - execution_env.NIX_INSTALLER_NIX_PACKAGE_URL = `${this.nix_package_url}`; + if (this.nixPackageUrl !== null) { + executionEnv.NIX_INSTALLER_NIX_PACKAGE_URL = `${this.nixPackageUrl}`; } if (this.proxy !== null) { - execution_env.NIX_INSTALLER_PROXY = this.proxy; + executionEnv.NIX_INSTALLER_PROXY = this.proxy; } - if (this.ssl_cert_file !== null) { - execution_env.NIX_INSTALLER_SSL_CERT_FILE = this.ssl_cert_file; + if (this.sslCertFile !== null) { + executionEnv.NIX_INSTALLER_SSL_CERT_FILE = this.sslCertFile; } - execution_env.NIX_INSTALLER_DIAGNOSTIC_ENDPOINT = - this.idslib.getDiagnosticsUrl()?.toString() || ""; + executionEnv.NIX_INSTALLER_DIAGNOSTIC_ENDPOINT = + this.idslib.getDiagnosticsUrl()?.toString() ?? ""; // TODO: Error if the user uses these on not-MacOS - if (this.mac_encrypt !== null) { - if (process.env.RUNNER_OS !== "macOS") { + if (this.macEncrypt !== null) { + if (runnerOs !== "macOS") { throw new Error("`mac-encrypt` while `$RUNNER_OS` was not `macOS`"); } - execution_env.NIX_INSTALLER_ENCRYPT = this.mac_encrypt; + executionEnv.NIX_INSTALLER_ENCRYPT = this.macEncrypt; } - if (this.mac_case_sensitive !== null) { - if (process.env.RUNNER_OS !== "macOS") { + if (this.macCaseSensitive !== null) { + if (runnerOs !== "macOS") { throw new Error("`mac-case-sensitive` while `$RUNNER_OS` was not `macOS`"); } - execution_env.NIX_INSTALLER_CASE_SENSITIVE = this.mac_case_sensitive; + executionEnv.NIX_INSTALLER_CASE_SENSITIVE = this.macCaseSensitive; } - if (this.mac_volume_label !== null) { - if (process.env.RUNNER_OS !== "macOS") { + if (this.macVolumeLabel !== null) { + if (runnerOs !== "macOS") { throw new Error("`mac-volume-label` while `$RUNNER_OS` was not `macOS`"); } - execution_env.NIX_INSTALLER_VOLUME_LABEL = this.mac_volume_label; + executionEnv.NIX_INSTALLER_VOLUME_LABEL = this.macVolumeLabel; } - if (this.mac_root_disk !== null) { - if (process.env.RUNNER_OS !== "macOS") { + if (this.macRootDisk !== null) { + if (runnerOs !== "macOS") { throw new Error("`mac-root-disk` while `$RUNNER_OS` was not `macOS`"); } - execution_env.NIX_INSTALLER_ROOT_DISK = this.mac_root_disk; + executionEnv.NIX_INSTALLER_ROOT_DISK = this.macRootDisk; } if (this.logger !== null) { - execution_env.NIX_INSTALLER_LOGGER = this.logger; + executionEnv.NIX_INSTALLER_LOGGER = this.logger; } - if (this.log_directives !== null) { - execution_env.NIX_INSTALLER_LOG_DIRECTIVES = this.log_directives; + if (this.logDirectives !== null) { + executionEnv.NIX_INSTALLER_LOG_DIRECTIVES = this.logDirectives; } // TODO: Error if the user uses these on MacOS if (this.init !== null) { - if (process.env.RUNNER_OS === "macOS") { + if (runnerOs === "macOS") { throw new Error("`init` is not a valid option when `$RUNNER_OS` is `macOS`"); } - execution_env.NIX_INSTALLER_INIT = this.init; + executionEnv.NIX_INSTALLER_INIT = this.init; } - if (this.start_daemon !== null) { - if (this.start_daemon) { - execution_env.NIX_INSTALLER_START_DAEMON = "true"; + if (this.startDaemon !== null) { + if (this.startDaemon) { + executionEnv.NIX_INSTALLER_START_DAEMON = "true"; } else { - execution_env.NIX_INSTALLER_START_DAEMON = "false"; + executionEnv.NIX_INSTALLER_START_DAEMON = "false"; } } - let extra_conf = ""; - if (this.github_server_url !== null && this.github_token !== null) { - const server_url = this.github_server_url.replace("https://", ""); - extra_conf += `access-tokens = ${server_url}=${this.github_token}`; - extra_conf += "\n"; + let extraConf = ""; + if (this.githubServerUrl !== null && this.githubToken !== null) { + const serverUrl = this.githubServerUrl.replace("https://", ""); + extraConf += `access-tokens = ${serverUrl}=${this.githubToken}`; + extraConf += "\n"; } - if (this.trust_runner_user !== null) { + if (this.trustRunnerUser !== null) { const user = (0,external_node_os_.userInfo)().username; if (user) { - extra_conf += `trusted-users = root ${user}`; + extraConf += `trusted-users = root ${user}`; } else { - extra_conf += `trusted-users = root`; + extraConf += `trusted-users = root`; } - extra_conf += "\n"; + extraConf += "\n"; } if (this.flakehub) { try { - const flakehub_netrc_file = await this.flakehub_login(); - extra_conf += `netrc-file = ${flakehub_netrc_file}`; - extra_conf += "\n"; + const flakeHubNetrcFile = await this.flakehubLogin(); + extraConf += `netrc-file = ${flakeHubNetrcFile}`; + extraConf += "\n"; } catch (e) { - core.warning(`Failed to setup FlakeHub: ${e}`); + core.warning(`Failed to set up FlakeHub: ${e}`); } } - if (this.extra_conf !== null && this.extra_conf.length !== 0) { - extra_conf += this.extra_conf.join("\n"); - extra_conf += "\n"; + if (this.extraConf !== null && this.extraConf.length !== 0) { + extraConf += this.extraConf.join("\n"); + extraConf += "\n"; } - execution_env.NIX_INSTALLER_EXTRA_CONF = extra_conf; - if (process.env.ACT && !process.env.NOT_ACT) { - this.idslib.addFact("in_act", true); + executionEnv.NIX_INSTALLER_EXTRA_CONF = extraConf; + if (process.env["ACT"] && !process.env["NOT_ACT"]) { + this.idslib.addFact(FACT_IN_GITHUB_ACTIONS, true); core.info("Detected `$ACT` environment, assuming this is a https://github.com/nektos/act created container, set `NOT_ACT=true` to override this. This will change the setting of the `init` to be compatible with `act`"); - execution_env.NIX_INSTALLER_INIT = "none"; + executionEnv.NIX_INSTALLER_INIT = "none"; } - if (process.env.NSC_VM_ID && !process.env.NOT_NAMESPACE) { - this.idslib.addFact("in_namespace_so", true); + if (process.env["NSC_VM_ID"] && !process.env["NOT_NAMESPACE"]) { + this.idslib.addFact(FACT_IN_NAMESPACE_SO, true); core.info("Detected Namespace runner, assuming this is a https://namespace.so created container, set `NOT_NAMESPACE=true` to override this. This will change the setting of the `init` to be compatible with Namespace"); - execution_env.NIX_INSTALLER_INIT = "none"; + executionEnv.NIX_INSTALLER_INIT = "none"; } - return execution_env; + return executionEnv; } - async execute_install(binary_path) { - const execution_env = await this.executionEnvironment(); - core.debug(`Execution environment: ${JSON.stringify(execution_env, null, 4)}`); + async executeInstall(binaryPath) { + const executionEnv = await this.executionEnvironment(); + core.debug(`Execution environment: ${JSON.stringify(executionEnv, null, 4)}`); const args = ["install"]; if (this.planner) { - this.idslib.addFact("nix_installer_planner", this.planner); + this.idslib.addFact(FACT_NIX_INSTALLER_PLANNER, this.planner); args.push(this.planner); } else { - this.idslib.addFact("nix_installer_planner", get_default_planner()); - args.push(get_default_planner()); + this.idslib.addFact(FACT_NIX_INSTALLER_PLANNER, getDefaultPlanner()); + args.push(getDefaultPlanner()); } - if (this.extra_args) { - const extra_args = parseArgsStringToArgv(this.extra_args); - args.concat(extra_args); + if (this.extraArgs) { + const extraArgs = parseArgsStringToArgv(this.extraArgs); + args.concat(extraArgs); } - this.idslib.recordEvent("install_nix_start"); - const exit_code = await exec.exec(binary_path, args, { + this.idslib.recordEvent(EVENT_INSTALL_NIX_START); + const exitCode = await exec.exec(binaryPath, args, { env: { - ...execution_env, + ...executionEnv, ...process.env, // To get $PATH, etc }, }); - if (exit_code !== 0) { - this.idslib.recordEvent("install_nix_failure", { - exit_code, + if (exitCode !== 0) { + this.idslib.recordEvent(EVENT_INSTALL_NIX_FAILURE, { + exitCode, }); - throw new Error(`Non-zero exit code of \`${exit_code}\` detected`); + throw new Error(`Non-zero exit code of \`${exitCode}\` detected`); } - this.idslib.recordEvent("install_nix_success"); - return exit_code; + this.idslib.recordEvent(EVENT_INSTALL_NIX_SUCCESS); + return exitCode; } async install() { - const existing_install = await this.detect_existing(); - if (existing_install) { + const existingInstall = await this.detectExisting(); + if (existingInstall) { if (this.reinstall) { // We need to uninstall, then reinstall core.info("Nix was already installed, `reinstall` is set, uninstalling for a reinstall"); - await this.execute_uninstall(); + await this.executeUninstall(); } else { // We're already installed, and not reinstalling, just set GITHUB_PATH and finish early - await this.set_github_path(); + await this.setGithubPath(); core.info("Nix was already installed, using existing install"); return; } } if (this.kvm) { core.startGroup("Configuring KVM"); - if (await this.setup_kvm()) { + if (await this.setupKvm()) { core.endGroup(); core.info("\u001b[32m Accelerated KVM is enabled \u001b[33m⚡️"); core.exportVariable("DETERMINATE_NIX_KVM", "1"); @@ -97988,13 +97683,13 @@ class NixInstallerAction { } // Normal just doing of the install core.startGroup("Installing Nix"); - const binary_path = await this.fetch_binary(); - await this.execute_install(binary_path); + const binaryPath = await this.fetchBinary(); + await this.executeInstall(binaryPath); core.endGroup(); - if (this.force_docker_shim) { + if (this.forceDockerShim) { await this.spawnDockerShim(); } - await this.set_github_path(); + await this.setGithubPath(); } async spawnDockerShim() { core.startGroup("Configuring the Docker shim as the Nix Daemon's process supervisor"); @@ -98002,11 +97697,12 @@ class NixInstallerAction { X64: __nccwpck_require__.ab + "amd64.tar.gz", ARM64: __nccwpck_require__.ab + "arm64.tar.gz", }; + const runnerArch = process.env["RUNNER_ARCH"]; let arch; - if (process.env.RUNNER_ARCH === "X64") { + if (runnerArch === "X64") { arch = "X64"; } - else if (process.env.RUNNER_ARCH === "ARM64") { + else if (runnerArch === "ARM64") { arch = "ARM64"; } else { @@ -98014,7 +97710,7 @@ class NixInstallerAction { } core.debug("Loading image: determinate-nix-shim:latest..."); { - const exit_code = await exec.exec("docker", ["image", "load", "--input", images[arch]], { + const exitCode = await exec.exec("docker", ["image", "load", "--input", images[arch]], { silent: true, listeners: { stdout: (data) => { @@ -98031,14 +97727,14 @@ class NixInstallerAction { }, }, }); - if (exit_code !== 0) { - throw new Error(`Failed to build the shim image, exit code: \`${exit_code}\``); + if (exitCode !== 0) { + throw new Error(`Failed to build the shim image, exit code: \`${exitCode}\``); } } { core.debug("Starting the Nix daemon through Docker..."); - this.idslib.recordEvent("start_docker_shim"); - const exit_code = await exec.exec("docker", [ + this.idslib.recordEvent(EVENT_START_DOCKER_SHIM); + const exitCode = await exec.exec("docker", [ "--log-level=debug", "run", "--detach", @@ -98084,20 +97780,20 @@ class NixInstallerAction { }, }, }); - if (exit_code !== 0) { - throw new Error(`Failed to start the Nix daemon through Docker, exit code: \`${exit_code}\``); + if (exitCode !== 0) { + throw new Error(`Failed to start the Nix daemon through Docker, exit code: \`${exitCode}\``); } } core.endGroup(); return; } async cleanupDockerShim() { - const container_id = core.getState("docker_shim_container_id"); - if (container_id !== "") { + const containerId = core.getState("docker_shim_container_id"); + if (containerId !== "") { core.startGroup("Cleaning up the Nix daemon's Docker shim"); let cleaned = false; try { - await exec.exec("docker", ["rm", "--force", container_id]); + await exec.exec("docker", ["rm", "--force", containerId]); cleaned = true; } catch { @@ -98106,7 +97802,7 @@ class NixInstallerAction { if (!cleaned) { core.info("trying to pkill the container's shim process"); try { - await exec.exec("pkill", [container_id]); + await exec.exec("pkill", [containerId]); cleaned = true; } catch { @@ -98114,7 +97810,7 @@ class NixInstallerAction { } } if (cleaned) { - this.idslib.recordEvent("clean_up_docker_shim"); + this.idslib.recordEvent(EVENT_CLEAN_UP_DOCKER_SHIM); } else { core.warning("Giving up on cleaning up the nix daemon container"); @@ -98122,52 +97818,52 @@ class NixInstallerAction { core.endGroup(); } } - async set_github_path() { + async setGithubPath() { // Interim versions of the `nix-installer` crate may have already manipulated `$GITHUB_PATH`, as root even! Accessing that will be an error. try { - const nix_var_nix_profile_path = "/nix/var/nix/profiles/default/bin"; - const home_nix_profile_path = `${process.env.HOME}/.nix-profile/bin`; - core.addPath(nix_var_nix_profile_path); - core.addPath(home_nix_profile_path); - core.info(`Added \`${nix_var_nix_profile_path}\` and \`${home_nix_profile_path}\` to \`$GITHUB_PATH\``); + const nixVarNixProfilePath = "/nix/var/nix/profiles/default/bin"; + const homeNixProfilePath = `${process.env["HOME"]}/.nix-profile/bin`; + core.addPath(nixVarNixProfilePath); + core.addPath(homeNixProfilePath); + core.info(`Added \`${nixVarNixProfilePath}\` and \`${homeNixProfilePath}\` to \`$GITHUB_PATH\``); } - catch (error) { + catch { core.info("Skipping setting $GITHUB_PATH in action, the `nix-installer` crate seems to have done this already. From `nix-installer` version 0.11.0 and up, this step is done in the action. Prior to 0.11.0, this was only done in the `nix-installer` binary."); } } - async flakehub_login() { - this.idslib.recordEvent("login_to_flakehub"); - const netrc_path = `${process.env["RUNNER_TEMP"]}/determinate-nix-installer-netrc`; + async flakehubLogin() { + this.idslib.recordEvent(EVENT_LOGIN_TO_FLAKEHUB); + const netrcPath = `${process.env["RUNNER_TEMP"]}/determinate-nix-installer-netrc`; const jwt = await core.getIDToken("api.flakehub.com"); - await (0,promises_namespaceObject.writeFile)(netrc_path, [ + await (0,promises_namespaceObject.writeFile)(netrcPath, [ `machine api.flakehub.com login flakehub password ${jwt}`, `machine flakehub.com login flakehub password ${jwt}`, ].join("\n")); core.info("Logging in to FlakeHub."); // the join followed by a match on ^... looks silly, but extra_config // could contain multi-line values - if (this.extra_conf?.join("\n").match(/^netrc-file/m)) { + if (this.extraConf?.join("\n").match(/^netrc-file/m)) { core.warning("Logging in to FlakeHub conflicts with the Nix option `netrc-file`."); } - return netrc_path; + return netrcPath; } - async execute_uninstall() { - this.idslib.recordEvent("uninstall"); - const exit_code = await exec.exec(`/nix/nix-installer`, ["uninstall"], { + async executeUninstall() { + this.idslib.recordEvent(EVENT_UNINSTALL_NIX); + const exitCode = await exec.exec(`/nix/nix-installer`, ["uninstall"], { env: { NIX_INSTALLER_NO_CONFIRM: "true", ...process.env, // To get $PATH, etc }, }); - if (exit_code !== 0) { - throw new Error(`Non-zero exit code of \`${exit_code}\` detected`); + if (exitCode !== 0) { + throw new Error(`Non-zero exit code of \`${exitCode}\` detected`); } - return exit_code; + return exitCode; } - async detect_existing() { - const receipt_path = "/nix/receipt.json"; + async detectExisting() { + const receiptPath = "/nix/receipt.json"; try { - await (0,promises_namespaceObject.access)(receipt_path); + await (0,promises_namespaceObject.access)(receiptPath); // There is a /nix/receipt.json return true; } @@ -98176,16 +97872,16 @@ class NixInstallerAction { return false; } } - async setup_kvm() { - this.idslib.recordEvent("setup_kvm"); - const current_user = (0,external_node_os_.userInfo)(); - const is_root = current_user.uid === 0; - const maybe_sudo = is_root ? "" : "sudo"; - const kvm_rules = "/etc/udev/rules.d/99-determinate-nix-installer-kvm.rules"; + async setupKvm() { + this.idslib.recordEvent(EVENT_SETUP_KVM); + const currentUser = (0,external_node_os_.userInfo)(); + const isRoot = currentUser.uid === 0; + const maybeSudo = isRoot ? "" : "sudo"; + const kvmRules = "/etc/udev/rules.d/99-determinate-nix-installer-kvm.rules"; try { - const write_file_exit_code = await exec.exec("sh", [ + const writeFileExitCode = await exec.exec("sh", [ "-c", - `echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | ${maybe_sudo} tee ${kvm_rules} > /dev/null`, + `echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | ${maybeSudo} tee ${kvmRules} > /dev/null`, ], { silent: true, listeners: { @@ -98203,15 +97899,15 @@ class NixInstallerAction { }, }, }); - if (write_file_exit_code !== 0) { - throw new Error(`Non-zero exit code of \`${write_file_exit_code}\` detected while writing '${kvm_rules}'`); + if (writeFileExitCode !== 0) { + throw new Error(`Non-zero exit code of \`${writeFileExitCode}\` detected while writing '${kvmRules}'`); } - const debug_root_run_throw = async (action, command, args) => { - if (!is_root) { + const debugRootRunThrow = async (action, command, args) => { + if (!isRoot) { args = [command, ...args]; command = "sudo"; } - const reload_exit_code = await exec.exec(command, args, { + const reloadExitCode = await exec.exec(command, args, { silent: true, listeners: { stdout: (data) => { @@ -98228,59 +97924,60 @@ class NixInstallerAction { }, }, }); - if (reload_exit_code !== 0) { - throw new Error(`Non-zero exit code of \`${reload_exit_code}\` detected while ${action}.`); + if (reloadExitCode !== 0) { + throw new Error(`Non-zero exit code of \`${reloadExitCode}\` detected while ${action}.`); } }; - await debug_root_run_throw("reloading udev rules", "udevadm", [ + await debugRootRunThrow("reloading udev rules", "udevadm", [ "control", "--reload-rules", ]); - await debug_root_run_throw("triggering udev against kvm", "udevadm", [ + await debugRootRunThrow("triggering udev against kvm", "udevadm", [ "trigger", "--name-match=kvm", ]); return true; } - catch (error) { - if (is_root) { - await exec.exec("rm", ["-f", kvm_rules]); + catch { + if (isRoot) { + await exec.exec("rm", ["-f", kvmRules]); } else { - await exec.exec("sudo", ["rm", "-f", kvm_rules]); + await exec.exec("sudo", ["rm", "-f", kvmRules]); } return false; } } - async fetch_binary() { - if (!this.local_root) { + async fetchBinary() { + if (!this.localRoot) { return await this.idslib.fetchExecutable(); } else { - const local_path = (0,external_node_path_namespaceObject.join)(this.local_root, `nix-installer-${this.platform}`); - core.info(`Using binary ${local_path}`); - return local_path; + const localPath = (0,external_node_path_namespaceObject.join)(this.localRoot, `nix-installer-${this.platform}`); + core.info(`Using binary ${localPath}`); + return localPath; } } - async report_overall() { + async reportOverall() { try { - this.idslib.recordEvent("conclude_workflow", { - conclusion: await this.get_workflow_conclusion(), + this.idslib.recordEvent(EVENT_CONCLUDE_WORKFLOW, { + conclusion: await this.getWorkflowConclusion(), }); } - catch (error) { - core.debug(`Error submitting post-run diagnostics report: ${error}`); + catch (e) { + core.debug(`Error submitting post-run diagnostics report: ${e}`); } } - async get_workflow_conclusion() { - if (this.github_token == null) { + async getWorkflowConclusion() { + if (this.githubToken == null) { return undefined; } try { - const octokit = github.getOctokit(this.github_token); + const octokit = github.getOctokit(this.githubToken); const jobs = await octokit.paginate(octokit.rest.actions.listJobsForWorkflowRun, { owner: github.context.repo.owner, repo: github.context.repo.repo, + /* eslint-disable camelcase */ run_id: github.context.runId, }); core.debug(`awaited jobs: ${jobs}`); @@ -98290,7 +97987,7 @@ class NixInstallerAction { if (job === undefined) { return "no-jobs"; } - const outcomes = (job.steps || []).map((j) => j.conclusion || "unknown"); + const outcomes = (job.steps ?? []).map((j) => j.conclusion ?? "unknown"); // Possible values: success, failure, cancelled, or skipped // from: https://docs.github.com/en/actions/learn-github-actions/contexts if (outcomes.includes("failure")) { @@ -98304,73 +98001,24 @@ class NixInstallerAction { // Assume success if no jobs failed or were canceled return "success"; } - catch (error) { - core.debug(`Error determining final disposition: ${error}`); + catch (e) { + core.debug(`Error determining final disposition: ${e}`); return "unavailable"; } } } -function get_nix_platform() { - const env_os = process.env.RUNNER_OS; - const env_arch = process.env.RUNNER_ARCH; - if (env_os === "macOS" && env_arch === "X64") { - return "x86_64-darwin"; - } - else if (env_os === "macOS" && env_arch === "ARM64") { - return "aarch64-darwin"; - } - else if (env_os === "Linux" && env_arch === "X64") { - return "x86_64-linux"; - } - else if (env_os === "Linux" && env_arch === "ARM64") { - return "aarch64-linux"; - } - else { - throw new Error(`Unsupported \`RUNNER_OS\` (currently \`${env_os}\`) and \`RUNNER_ARCH\` (currently \`${env_arch}\`) combination`); - } -} -function get_default_planner() { - const env_os = process.env.RUNNER_OS; - if (env_os === "macOS") { +function getDefaultPlanner() { + const envOs = process.env["RUNNER_OS"]; + if (envOs === "macOS") { return "macos"; } - else if (env_os === "Linux") { + else if (envOs === "Linux") { return "linux"; } else { - throw new Error(`Unsupported \`RUNNER_OS\` (currently \`${env_os}\`)`); + throw new Error(`Unsupported \`RUNNER_OS\` (currently \`${envOs}\`)`); } } -function action_input_string_or_null(name) { - const value = core.getInput(name); - if (value === "") { - return null; - } - else { - return value; - } -} -function action_input_multiline_string_or_null(name) { - const value = core.getMultilineInput(name); - if (value.length === 0) { - return null; - } - else { - return value; - } -} -function action_input_number_or_null(name) { - const value = core.getInput(name); - if (value === "") { - return null; - } - else { - return Number(value); - } -} -function action_input_bool(name) { - return core.getBooleanInput(name); -} function main() { const installer = new NixInstallerAction(); installer.idslib.onMain(async () => { @@ -98379,7 +98027,7 @@ function main() { }); installer.idslib.onPost(async () => { await installer.cleanupDockerShim(); - await installer.report_overall(); + await installer.reportOverall(); }); installer.idslib.execute(); } diff --git a/dist/main.js b/dist/main.js index 0b3f26e..7aa866b 100644 --- a/dist/main.js +++ b/dist/main.js @@ -1,60 +1,81 @@ -import * as actions_core from "@actions/core"; +import * as actionsCore from "@actions/core"; import * as github from "@actions/github"; -import * as actions_exec from "@actions/exec"; +import * as actionsExec from "@actions/exec"; import { access, writeFile, readFile } from "node:fs/promises"; import { join } from "node:path"; import fs from "node:fs"; import { userInfo } from "node:os"; import stringArgv from "string-argv"; import * as path from "path"; -import { IdsToolbox } from "detsys-ts"; +import { IdsToolbox, inputs, platform } from "detsys-ts"; import { randomUUID } from "node:crypto"; +// Nix installation events +const EVENT_INSTALL_NIX_FAILURE = "install_nix_failure"; +const EVENT_INSTALL_NIX_START = "install_nix_start"; +const EVENT_INSTALL_NIX_SUCCESS = "install_nix_start"; +const EVENT_SETUP_KVM = "setup_kvm"; +const EVENT_UNINSTALL_NIX = "uninstall"; +// Docker events +const EVENT_CLEAN_UP_DOCKER_SHIM = "clean_up_docker_shim"; +const EVENT_START_DOCKER_SHIM = "start_docker_shim"; +// FlakeHub events +const EVENT_LOGIN_TO_FLAKEHUB = "login_to_flakehub"; +// Other events +const EVENT_CONCLUDE_WORKFLOW = "conclude_workflow"; +// Facts +const FACT_HAS_DOCKER = "has_docker"; +const FACT_HAS_SYSTEMD = "has_systemd"; +const FACT_IN_GITHUB_ACTIONS = "in_act"; +const FACT_IN_NAMESPACE_SO = "in_namespace_so"; +const FACT_NIX_INSTALLER_PLANNER = "nix_installer_planner"; class NixInstallerAction { constructor() { this.idslib = new IdsToolbox({ name: "nix-installer", fetchStyle: "nix-style", legacySourcePrefix: "nix-installer", + requireNix: "ignore", }); - this.platform = get_nix_platform(); - this.nix_package_url = action_input_string_or_null("nix-package-url"); - this.backtrace = action_input_string_or_null("backtrace"); - this.extra_args = action_input_string_or_null("extra-args"); - this.extra_conf = action_input_multiline_string_or_null("extra-conf"); - this.flakehub = action_input_bool("flakehub"); - this.kvm = action_input_bool("kvm"); - this.force_docker_shim = action_input_bool("force-docker-shim"); - this.github_token = action_input_string_or_null("github-token"); - this.github_server_url = action_input_string_or_null("github-server-url"); - this.init = action_input_string_or_null("init"); - this.local_root = action_input_string_or_null("local-root"); - this.log_directives = action_input_string_or_null("log-directives"); - this.logger = action_input_string_or_null("logger"); - this.ssl_cert_file = action_input_string_or_null("ssl-cert-file"); - this.proxy = action_input_string_or_null("proxy"); - this.mac_case_sensitive = action_input_string_or_null("mac-case-sensitive"); - this.mac_encrypt = action_input_string_or_null("mac-encrypt"); - this.mac_root_disk = action_input_string_or_null("mac-root-disk"); - this.mac_volume_label = action_input_string_or_null("mac-volume-label"); - this.modify_profile = action_input_bool("modify-profile"); - this.nix_build_group_id = action_input_number_or_null("nix-build-group-id"); - this.nix_build_group_name = action_input_string_or_null("nix-build-group-name"); - this.nix_build_user_base = action_input_number_or_null("nix_build-user-base"); - this.nix_build_user_count = action_input_number_or_null("nix-build-user-count"); - this.nix_build_user_prefix = action_input_string_or_null("nix-build-user-prefix"); - this.planner = action_input_string_or_null("planner"); - this.reinstall = action_input_bool("reinstall"); - this.start_daemon = action_input_bool("start-daemon"); - this.trust_runner_user = action_input_bool("trust-runner-user"); + this.platform = platform.getNixPlatform(platform.getArchOs()); + this.nixPackageUrl = inputs.getStringOrNull("nix-package-url"); + this.backtrace = inputs.getStringOrNull("backtrace"); + this.extraArgs = inputs.getStringOrNull("extra-args"); + this.extraConf = inputs.getMultilineStringOrNull("extra-conf"); + this.flakehub = inputs.getBool("flakehub"); + this.kvm = inputs.getBool("kvm"); + this.forceDockerShim = inputs.getBool("force-docker-shim"); + this.githubToken = inputs.getStringOrNull("github-token"); + this.githubServerUrl = inputs.getStringOrNull("github-server-url"); + this.init = inputs.getStringOrNull("init"); + this.localRoot = inputs.getStringOrNull("local-root"); + this.logDirectives = inputs.getStringOrNull("log-directives"); + this.logger = inputs.getStringOrNull("logger"); + this.sslCertFile = inputs.getStringOrNull("ssl-cert-file"); + this.proxy = inputs.getStringOrNull("proxy"); + this.macCaseSensitive = inputs.getStringOrNull("mac-case-sensitive"); + this.macEncrypt = inputs.getStringOrNull("mac-encrypt"); + this.macRootDisk = inputs.getStringOrNull("mac-root-disk"); + this.macVolumeLabel = inputs.getStringOrNull("mac-volume-label"); + this.modifyProfile = inputs.getBool("modify-profile"); + this.nixBuildGroupId = inputs.getNumberOrNull("nix-build-group-id"); + this.nixBuildGroupName = inputs.getStringOrNull("nix-build-group-name"); + this.nixBuildUserBase = inputs.getNumberOrNull("nix-build-user-base"); + this.nixBuildUserCount = inputs.getNumberOrNull("nix-build-user-count"); + this.nixBuildUserPrefix = inputs.getStringOrNull("nix-build-user-prefix"); + this.planner = inputs.getStringOrNull("planner"); + this.reinstall = inputs.getBool("reinstall"); + this.startDaemon = inputs.getBool("start-daemon"); + this.trustRunnerUser = inputs.getBool("trust-runner-user"); } async detectAndForceDockerShim() { + const runnerOs = process.env["RUNNER_OS"]; // Detect if we're in a GHA runner which is Linux, doesn't have Systemd, and does have Docker. // This is a common case in self-hosted runners, providers like [Namespace](https://namespace.so/), // and especially GitHub Enterprise Server. - if (process.env.RUNNER_OS !== "Linux") { - if (this.force_docker_shim) { - actions_core.warning("Ignoring force-docker-shim which is set to true, as it is only supported on Linux."); - this.force_docker_shim = false; + if (runnerOs !== "Linux") { + if (this.forceDockerShim) { + actionsCore.warning("Ignoring force-docker-shim which is set to true, as it is only supported on Linux."); + this.forceDockerShim = false; } return; } @@ -62,128 +83,128 @@ class NixInstallerAction { throwIfNoEntry: false, }); if (systemdCheck?.isDirectory()) { - if (this.force_docker_shim) { - actions_core.warning("Systemd is detected, but ignoring it since force-docker-shim is enabled."); + if (this.forceDockerShim) { + actionsCore.warning("Systemd is detected, but ignoring it since force-docker-shim is enabled."); } else { - this.idslib.addFact("has_systemd", true); + this.idslib.addFact(FACT_HAS_SYSTEMD, true); return; } } - this.idslib.addFact("has_systemd", false); - actions_core.debug("Linux detected without systemd, testing for Docker with `docker info` as an alternative daemon supervisor."); - this.idslib.addFact("has_docker", false); // Set to false here, and only in the success case do we set it to true - let exit_code; + this.idslib.addFact(FACT_HAS_SYSTEMD, false); + actionsCore.debug("Linux detected without systemd, testing for Docker with `docker info` as an alternative daemon supervisor."); + this.idslib.addFact(FACT_HAS_DOCKER, false); // Set to false here, and only in the success case do we set it to true + let exitCode; try { - exit_code = await actions_exec.exec("docker", ["info"], { + exitCode = await actionsExec.exec("docker", ["info"], { silent: true, listeners: { stdout: (data) => { const trimmed = data.toString("utf-8").trimEnd(); if (trimmed.length >= 0) { - actions_core.debug(trimmed); + actionsCore.debug(trimmed); } }, stderr: (data) => { const trimmed = data.toString("utf-8").trimEnd(); if (trimmed.length >= 0) { - actions_core.debug(trimmed); + actionsCore.debug(trimmed); } }, }, }); } - catch (e) { - actions_core.debug("Docker not detected, not enabling docker shim."); + catch { + actionsCore.debug("Docker not detected, not enabling docker shim."); return; } - if (exit_code !== 0) { - if (this.force_docker_shim) { - actions_core.warning("docker info check failed, but trying anyway since force-docker-shim is enabled."); + if (exitCode !== 0) { + if (this.forceDockerShim) { + actionsCore.warning("docker info check failed, but trying anyway since force-docker-shim is enabled."); } else { return; } } - this.idslib.addFact("has_docker", true); - if (!this.force_docker_shim && + this.idslib.addFact(FACT_HAS_DOCKER, true); + if (!this.forceDockerShim && (await this.detectDockerWithMountedDockerSocket())) { - actions_core.debug("Detected a Docker container with a Docker socket mounted, not enabling docker shim."); + actionsCore.debug("Detected a Docker container with a Docker socket mounted, not enabling docker shim."); return; } - actions_core.startGroup("Enabling the Docker shim for running Nix on Linux in CI without Systemd."); + actionsCore.startGroup("Enabling the Docker shim for running Nix on Linux in CI without Systemd."); if (this.init !== "none") { - actions_core.info(`Changing init from '${this.init}' to 'none'`); + actionsCore.info(`Changing init from '${this.init}' to 'none'`); this.init = "none"; } if (this.planner !== "linux") { - actions_core.info(`Changing planner from '${this.planner}' to 'linux'`); + actionsCore.info(`Changing planner from '${this.planner}' to 'linux'`); this.planner = "linux"; } - this.force_docker_shim = true; - actions_core.endGroup(); + this.forceDockerShim = true; + actionsCore.endGroup(); } // Detect if we are running under `act` or some other system which is not using docker-in-docker, // and instead using a mounted docker socket. // In the case of the socket mount solution, the shim will cause issues since the given mount paths will // equate to mount paths on the host, not mount paths to the docker container in question. async detectDockerWithMountedDockerSocket() { - let cgroups_buffer; + let cgroupsBuffer; try { // If we are inside a docker container, the last line of `/proc/self/cgroup` should be // 0::/docker/$SOME_ID // // If we are not, the line will likely be `0::/` - cgroups_buffer = await readFile("/proc/self/cgroup", { + cgroupsBuffer = await readFile("/proc/self/cgroup", { encoding: "utf-8", }); } catch (e) { - actions_core.debug(`Did not detect \`/proc/self/cgroup\` existence, bailing on docker container ID detection:\n${e}`); + actionsCore.debug(`Did not detect \`/proc/self/cgroup\` existence, bailing on docker container ID detection:\n${e}`); return false; } - const cgroups = cgroups_buffer.trim().split("\n"); - const last_cgroup = cgroups[cgroups.length - 1]; - const last_cgroup_parts = last_cgroup.split(":"); - const last_cgroup_path = last_cgroup_parts[last_cgroup_parts.length - 1]; - if (!last_cgroup_path.includes("/docker/")) { - actions_core.debug("Did not detect a container ID, bailing on docker.sock detection"); + const cgroups = cgroupsBuffer.trim().split("\n"); + const lastCgroup = cgroups[cgroups.length - 1]; + const lastCgroupParts = lastCgroup.split(":"); + const lastCgroupPath = lastCgroupParts[lastCgroupParts.length - 1]; + if (!lastCgroupPath.includes("/docker/")) { + actionsCore.debug("Did not detect a container ID, bailing on docker.sock detection"); return false; } // We are in a docker container, now to determine if this container is visible from // the `docker` command, and if so, if there is a `docker.socket` mounted. - const last_cgroup_path_parts = last_cgroup_path.split("/"); - const container_id = last_cgroup_path_parts[last_cgroup_path_parts.length - 1]; + const lastCgroupPathParts = lastCgroupPath.split("/"); + const containerId = lastCgroupPathParts[lastCgroupPathParts.length - 1]; // If we cannot `docker inspect` this discovered container ID, we'll fall through to the `catch` below. - let stdout_buffer = ""; - let stderr_buffer = ""; - let exit_code; + let stdoutBuffer = ""; + let stderrBuffer = ""; + let exitCode; try { - exit_code = await actions_exec.exec("docker", ["inspect", container_id], { + exitCode = await actionsExec.exec("docker", ["inspect", containerId], { silent: true, listeners: { stdout: (data) => { - stdout_buffer += data.toString("utf-8"); + stdoutBuffer += data.toString("utf-8"); }, stderr: (data) => { - stderr_buffer += data.toString("utf-8"); + stderrBuffer += data.toString("utf-8"); }, }, }); } catch (e) { - actions_core.debug(`Could not execute \`docker inspect ${container_id}\`, bailing on docker container inspection:\n${e}`); + actionsCore.debug(`Could not execute \`docker inspect ${containerId}\`, bailing on docker container inspection:\n${e}`); return false; } - if (exit_code !== 0) { - actions_core.debug(`Unable to inspect detected docker container with id \`${container_id}\`, bailing on container inspection (exit ${exit_code}):\n${stderr_buffer}`); + if (exitCode !== 0) { + actionsCore.debug(`Unable to inspect detected docker container with id \`${containerId}\`, bailing on container inspection (exit ${exitCode}):\n${stderrBuffer}`); return false; } - const output = JSON.parse(stdout_buffer); + const output = JSON.parse(stdoutBuffer); // `docker inspect $ID` prints an array containing objects. // In our use case, we should only see 1 item in the array. if (output.length !== 1) { - actions_core.debug(`Got \`docker inspect ${container_id}\` output which was not one item (was ${output.length}), bailing on docker.sock detection.`); + actionsCore.debug(`Got \`docker inspect ${containerId}\` output which was not one item (was ${output.length}), bailing on docker.sock detection.`); return false; } const item = output[0]; @@ -192,266 +213,267 @@ class NixInstallerAction { // We are looking for a `Destination` ending with `docker.sock`. const mounts = item["Mounts"]; if (typeof mounts !== "object") { - actions_core.debug(`Got non-object in \`Mounts\` field of \`docker inspect ${container_id}\` output, bailing on docker.sock detection.`); + actionsCore.debug(`Got non-object in \`Mounts\` field of \`docker inspect ${containerId}\` output, bailing on docker.sock detection.`); return false; } - let found_docker_sock_mount = false; + let foundDockerSockMount = false; for (const mount of mounts) { const destination = mount["Destination"]; if (typeof destination === "string") { if (destination.endsWith("docker.sock")) { - found_docker_sock_mount = true; + foundDockerSockMount = true; break; } } } - return found_docker_sock_mount; + return foundDockerSockMount; } async executionEnvironment() { - const execution_env = {}; - execution_env.NIX_INSTALLER_NO_CONFIRM = "true"; - execution_env.NIX_INSTALLER_DIAGNOSTIC_ATTRIBUTION = JSON.stringify(this.idslib.getCorrelationHashes()); + const executionEnv = {}; + const runnerOs = process.env["RUNNER_OS"]; + executionEnv.NIX_INSTALLER_NO_CONFIRM = "true"; + executionEnv.NIX_INSTALLER_DIAGNOSTIC_ATTRIBUTION = JSON.stringify(this.idslib.getCorrelationHashes()); if (this.backtrace !== null) { - execution_env.RUST_BACKTRACE = this.backtrace; + executionEnv.RUST_BACKTRACE = this.backtrace; } - if (this.modify_profile !== null) { - if (this.modify_profile) { - execution_env.NIX_INSTALLER_MODIFY_PROFILE = "true"; + if (this.modifyProfile !== null) { + if (this.modifyProfile) { + executionEnv.NIX_INSTALLER_MODIFY_PROFILE = "true"; } else { - execution_env.NIX_INSTALLER_MODIFY_PROFILE = "false"; + executionEnv.NIX_INSTALLER_MODIFY_PROFILE = "false"; } } - if (this.nix_build_group_id !== null) { - execution_env.NIX_INSTALLER_NIX_BUILD_GROUP_ID = `${this.nix_build_group_id}`; + if (this.nixBuildGroupId !== null) { + executionEnv.NIX_INSTALLER_NIX_BUILD_GROUP_ID = `${this.nixBuildGroupId}`; } - if (this.nix_build_group_name !== null) { - execution_env.NIX_INSTALLER_NIX_BUILD_GROUP_NAME = - this.nix_build_group_name; + if (this.nixBuildGroupName !== null) { + executionEnv.NIX_INSTALLER_NIX_BUILD_GROUP_NAME = this.nixBuildGroupName; } - if (this.nix_build_user_prefix !== null) { - execution_env.NIX_INSTALLER_NIX_BUILD_USER_PREFIX = - this.nix_build_user_prefix; + if (this.nixBuildUserPrefix !== null) { + executionEnv.NIX_INSTALLER_NIX_BUILD_USER_PREFIX = + this.nixBuildUserPrefix; } - if (this.nix_build_user_count !== null) { - execution_env.NIX_INSTALLER_NIX_BUILD_USER_COUNT = `${this.nix_build_user_count}`; + if (this.nixBuildUserCount !== null) { + executionEnv.NIX_INSTALLER_NIX_BUILD_USER_COUNT = `${this.nixBuildUserCount}`; } - if (this.nix_build_user_base !== null) { - execution_env.NIX_INSTALLER_NIX_BUILD_USER_ID_BASE = `${this.nix_build_user_count}`; + if (this.nixBuildUserBase !== null) { + executionEnv.NIX_INSTALLER_NIX_BUILD_USER_ID_BASE = `${this.nixBuildUserCount}`; } - if (this.nix_package_url !== null) { - execution_env.NIX_INSTALLER_NIX_PACKAGE_URL = `${this.nix_package_url}`; + if (this.nixPackageUrl !== null) { + executionEnv.NIX_INSTALLER_NIX_PACKAGE_URL = `${this.nixPackageUrl}`; } if (this.proxy !== null) { - execution_env.NIX_INSTALLER_PROXY = this.proxy; + executionEnv.NIX_INSTALLER_PROXY = this.proxy; } - if (this.ssl_cert_file !== null) { - execution_env.NIX_INSTALLER_SSL_CERT_FILE = this.ssl_cert_file; + if (this.sslCertFile !== null) { + executionEnv.NIX_INSTALLER_SSL_CERT_FILE = this.sslCertFile; } - execution_env.NIX_INSTALLER_DIAGNOSTIC_ENDPOINT = - this.idslib.getDiagnosticsUrl()?.toString() || ""; + executionEnv.NIX_INSTALLER_DIAGNOSTIC_ENDPOINT = + this.idslib.getDiagnosticsUrl()?.toString() ?? ""; // TODO: Error if the user uses these on not-MacOS - if (this.mac_encrypt !== null) { - if (process.env.RUNNER_OS !== "macOS") { + if (this.macEncrypt !== null) { + if (runnerOs !== "macOS") { throw new Error("`mac-encrypt` while `$RUNNER_OS` was not `macOS`"); } - execution_env.NIX_INSTALLER_ENCRYPT = this.mac_encrypt; + executionEnv.NIX_INSTALLER_ENCRYPT = this.macEncrypt; } - if (this.mac_case_sensitive !== null) { - if (process.env.RUNNER_OS !== "macOS") { + if (this.macCaseSensitive !== null) { + if (runnerOs !== "macOS") { throw new Error("`mac-case-sensitive` while `$RUNNER_OS` was not `macOS`"); } - execution_env.NIX_INSTALLER_CASE_SENSITIVE = this.mac_case_sensitive; + executionEnv.NIX_INSTALLER_CASE_SENSITIVE = this.macCaseSensitive; } - if (this.mac_volume_label !== null) { - if (process.env.RUNNER_OS !== "macOS") { + if (this.macVolumeLabel !== null) { + if (runnerOs !== "macOS") { throw new Error("`mac-volume-label` while `$RUNNER_OS` was not `macOS`"); } - execution_env.NIX_INSTALLER_VOLUME_LABEL = this.mac_volume_label; + executionEnv.NIX_INSTALLER_VOLUME_LABEL = this.macVolumeLabel; } - if (this.mac_root_disk !== null) { - if (process.env.RUNNER_OS !== "macOS") { + if (this.macRootDisk !== null) { + if (runnerOs !== "macOS") { throw new Error("`mac-root-disk` while `$RUNNER_OS` was not `macOS`"); } - execution_env.NIX_INSTALLER_ROOT_DISK = this.mac_root_disk; + executionEnv.NIX_INSTALLER_ROOT_DISK = this.macRootDisk; } if (this.logger !== null) { - execution_env.NIX_INSTALLER_LOGGER = this.logger; + executionEnv.NIX_INSTALLER_LOGGER = this.logger; } - if (this.log_directives !== null) { - execution_env.NIX_INSTALLER_LOG_DIRECTIVES = this.log_directives; + if (this.logDirectives !== null) { + executionEnv.NIX_INSTALLER_LOG_DIRECTIVES = this.logDirectives; } // TODO: Error if the user uses these on MacOS if (this.init !== null) { - if (process.env.RUNNER_OS === "macOS") { + if (runnerOs === "macOS") { throw new Error("`init` is not a valid option when `$RUNNER_OS` is `macOS`"); } - execution_env.NIX_INSTALLER_INIT = this.init; + executionEnv.NIX_INSTALLER_INIT = this.init; } - if (this.start_daemon !== null) { - if (this.start_daemon) { - execution_env.NIX_INSTALLER_START_DAEMON = "true"; + if (this.startDaemon !== null) { + if (this.startDaemon) { + executionEnv.NIX_INSTALLER_START_DAEMON = "true"; } else { - execution_env.NIX_INSTALLER_START_DAEMON = "false"; + executionEnv.NIX_INSTALLER_START_DAEMON = "false"; } } - let extra_conf = ""; - if (this.github_server_url !== null && this.github_token !== null) { - const server_url = this.github_server_url.replace("https://", ""); - extra_conf += `access-tokens = ${server_url}=${this.github_token}`; - extra_conf += "\n"; + let extraConf = ""; + if (this.githubServerUrl !== null && this.githubToken !== null) { + const serverUrl = this.githubServerUrl.replace("https://", ""); + extraConf += `access-tokens = ${serverUrl}=${this.githubToken}`; + extraConf += "\n"; } - if (this.trust_runner_user !== null) { + if (this.trustRunnerUser !== null) { const user = userInfo().username; if (user) { - extra_conf += `trusted-users = root ${user}`; + extraConf += `trusted-users = root ${user}`; } else { - extra_conf += `trusted-users = root`; + extraConf += `trusted-users = root`; } - extra_conf += "\n"; + extraConf += "\n"; } if (this.flakehub) { try { - const flakehub_netrc_file = await this.flakehub_login(); - extra_conf += `netrc-file = ${flakehub_netrc_file}`; - extra_conf += "\n"; + const flakeHubNetrcFile = await this.flakehubLogin(); + extraConf += `netrc-file = ${flakeHubNetrcFile}`; + extraConf += "\n"; } catch (e) { - actions_core.warning(`Failed to setup FlakeHub: ${e}`); + actionsCore.warning(`Failed to set up FlakeHub: ${e}`); } } - if (this.extra_conf !== null && this.extra_conf.length !== 0) { - extra_conf += this.extra_conf.join("\n"); - extra_conf += "\n"; + if (this.extraConf !== null && this.extraConf.length !== 0) { + extraConf += this.extraConf.join("\n"); + extraConf += "\n"; } - execution_env.NIX_INSTALLER_EXTRA_CONF = extra_conf; - if (process.env.ACT && !process.env.NOT_ACT) { - this.idslib.addFact("in_act", true); - actions_core.info("Detected `$ACT` environment, assuming this is a https://github.com/nektos/act created container, set `NOT_ACT=true` to override this. This will change the setting of the `init` to be compatible with `act`"); - execution_env.NIX_INSTALLER_INIT = "none"; + executionEnv.NIX_INSTALLER_EXTRA_CONF = extraConf; + if (process.env["ACT"] && !process.env["NOT_ACT"]) { + this.idslib.addFact(FACT_IN_GITHUB_ACTIONS, true); + actionsCore.info("Detected `$ACT` environment, assuming this is a https://github.com/nektos/act created container, set `NOT_ACT=true` to override this. This will change the setting of the `init` to be compatible with `act`"); + executionEnv.NIX_INSTALLER_INIT = "none"; } - if (process.env.NSC_VM_ID && !process.env.NOT_NAMESPACE) { - this.idslib.addFact("in_namespace_so", true); - actions_core.info("Detected Namespace runner, assuming this is a https://namespace.so created container, set `NOT_NAMESPACE=true` to override this. This will change the setting of the `init` to be compatible with Namespace"); - execution_env.NIX_INSTALLER_INIT = "none"; + if (process.env["NSC_VM_ID"] && !process.env["NOT_NAMESPACE"]) { + this.idslib.addFact(FACT_IN_NAMESPACE_SO, true); + actionsCore.info("Detected Namespace runner, assuming this is a https://namespace.so created container, set `NOT_NAMESPACE=true` to override this. This will change the setting of the `init` to be compatible with Namespace"); + executionEnv.NIX_INSTALLER_INIT = "none"; } - return execution_env; + return executionEnv; } - async execute_install(binary_path) { - const execution_env = await this.executionEnvironment(); - actions_core.debug(`Execution environment: ${JSON.stringify(execution_env, null, 4)}`); + async executeInstall(binaryPath) { + const executionEnv = await this.executionEnvironment(); + actionsCore.debug(`Execution environment: ${JSON.stringify(executionEnv, null, 4)}`); const args = ["install"]; if (this.planner) { - this.idslib.addFact("nix_installer_planner", this.planner); + this.idslib.addFact(FACT_NIX_INSTALLER_PLANNER, this.planner); args.push(this.planner); } else { - this.idslib.addFact("nix_installer_planner", get_default_planner()); - args.push(get_default_planner()); + this.idslib.addFact(FACT_NIX_INSTALLER_PLANNER, getDefaultPlanner()); + args.push(getDefaultPlanner()); } - if (this.extra_args) { - const extra_args = stringArgv(this.extra_args); - args.concat(extra_args); + if (this.extraArgs) { + const extraArgs = stringArgv(this.extraArgs); + args.concat(extraArgs); } - this.idslib.recordEvent("install_nix_start"); - const exit_code = await actions_exec.exec(binary_path, args, { + this.idslib.recordEvent(EVENT_INSTALL_NIX_START); + const exitCode = await actionsExec.exec(binaryPath, args, { env: { - ...execution_env, + ...executionEnv, ...process.env, // To get $PATH, etc }, }); - if (exit_code !== 0) { - this.idslib.recordEvent("install_nix_failure", { - exit_code, + if (exitCode !== 0) { + this.idslib.recordEvent(EVENT_INSTALL_NIX_FAILURE, { + exitCode, }); - throw new Error(`Non-zero exit code of \`${exit_code}\` detected`); + throw new Error(`Non-zero exit code of \`${exitCode}\` detected`); } - this.idslib.recordEvent("install_nix_success"); - return exit_code; + this.idslib.recordEvent(EVENT_INSTALL_NIX_SUCCESS); + return exitCode; } async install() { - const existing_install = await this.detect_existing(); - if (existing_install) { + const existingInstall = await this.detectExisting(); + if (existingInstall) { if (this.reinstall) { // We need to uninstall, then reinstall - actions_core.info("Nix was already installed, `reinstall` is set, uninstalling for a reinstall"); - await this.execute_uninstall(); + actionsCore.info("Nix was already installed, `reinstall` is set, uninstalling for a reinstall"); + await this.executeUninstall(); } else { // We're already installed, and not reinstalling, just set GITHUB_PATH and finish early - await this.set_github_path(); - actions_core.info("Nix was already installed, using existing install"); + await this.setGithubPath(); + actionsCore.info("Nix was already installed, using existing install"); return; } } if (this.kvm) { - actions_core.startGroup("Configuring KVM"); - if (await this.setup_kvm()) { - actions_core.endGroup(); - actions_core.info("\u001b[32m Accelerated KVM is enabled \u001b[33m⚡️"); - actions_core.exportVariable("DETERMINATE_NIX_KVM", "1"); + actionsCore.startGroup("Configuring KVM"); + if (await this.setupKvm()) { + actionsCore.endGroup(); + actionsCore.info("\u001b[32m Accelerated KVM is enabled \u001b[33m⚡️"); + actionsCore.exportVariable("DETERMINATE_NIX_KVM", "1"); } else { - actions_core.endGroup(); - actions_core.info("KVM is not available."); - actions_core.exportVariable("DETERMINATE_NIX_KVM", "0"); + actionsCore.endGroup(); + actionsCore.info("KVM is not available."); + actionsCore.exportVariable("DETERMINATE_NIX_KVM", "0"); } } // Normal just doing of the install - actions_core.startGroup("Installing Nix"); - const binary_path = await this.fetch_binary(); - await this.execute_install(binary_path); - actions_core.endGroup(); - if (this.force_docker_shim) { + actionsCore.startGroup("Installing Nix"); + const binaryPath = await this.fetchBinary(); + await this.executeInstall(binaryPath); + actionsCore.endGroup(); + if (this.forceDockerShim) { await this.spawnDockerShim(); } - await this.set_github_path(); + await this.setGithubPath(); } async spawnDockerShim() { - actions_core.startGroup("Configuring the Docker shim as the Nix Daemon's process supervisor"); + actionsCore.startGroup("Configuring the Docker shim as the Nix Daemon's process supervisor"); const images = { X64: path.join(__dirname, "/../docker-shim/amd64.tar.gz"), ARM64: path.join(__dirname, "/../docker-shim/arm64.tar.gz"), }; + const runnerArch = process.env["RUNNER_ARCH"]; let arch; - if (process.env.RUNNER_ARCH === "X64") { + if (runnerArch === "X64") { arch = "X64"; } - else if (process.env.RUNNER_ARCH === "ARM64") { + else if (runnerArch === "ARM64") { arch = "ARM64"; } else { throw Error("Architecture not supported in Docker shim mode."); } - actions_core.debug("Loading image: determinate-nix-shim:latest..."); + actionsCore.debug("Loading image: determinate-nix-shim:latest..."); { - const exit_code = await actions_exec.exec("docker", ["image", "load", "--input", images[arch]], { + const exitCode = await actionsExec.exec("docker", ["image", "load", "--input", images[arch]], { silent: true, listeners: { stdout: (data) => { const trimmed = data.toString("utf-8").trimEnd(); if (trimmed.length >= 0) { - actions_core.debug(trimmed); + actionsCore.debug(trimmed); } }, stderr: (data) => { const trimmed = data.toString("utf-8").trimEnd(); if (trimmed.length >= 0) { - actions_core.debug(trimmed); + actionsCore.debug(trimmed); } }, }, }); - if (exit_code !== 0) { - throw new Error(`Failed to build the shim image, exit code: \`${exit_code}\``); + if (exitCode !== 0) { + throw new Error(`Failed to build the shim image, exit code: \`${exitCode}\``); } } { - actions_core.debug("Starting the Nix daemon through Docker..."); - this.idslib.recordEvent("start_docker_shim"); - const exit_code = await actions_exec.exec("docker", [ + actionsCore.debug("Starting the Nix daemon through Docker..."); + this.idslib.recordEvent(EVENT_START_DOCKER_SHIM); + const exitCode = await actionsExec.exec("docker", [ "--log-level=debug", "run", "--detach", @@ -481,106 +503,106 @@ class NixInstallerAction { silent: true, listeners: { stdline: (data) => { - actions_core.saveState("docker_shim_container_id", data.trimEnd()); + actionsCore.saveState("docker_shim_container_id", data.trimEnd()); }, stdout: (data) => { const trimmed = data.toString("utf-8").trimEnd(); if (trimmed.length >= 0) { - actions_core.debug(trimmed); + actionsCore.debug(trimmed); } }, stderr: (data) => { const trimmed = data.toString("utf-8").trimEnd(); if (trimmed.length >= 0) { - actions_core.debug(trimmed); + actionsCore.debug(trimmed); } }, }, }); - if (exit_code !== 0) { - throw new Error(`Failed to start the Nix daemon through Docker, exit code: \`${exit_code}\``); + if (exitCode !== 0) { + throw new Error(`Failed to start the Nix daemon through Docker, exit code: \`${exitCode}\``); } } - actions_core.endGroup(); + actionsCore.endGroup(); return; } async cleanupDockerShim() { - const container_id = actions_core.getState("docker_shim_container_id"); - if (container_id !== "") { - actions_core.startGroup("Cleaning up the Nix daemon's Docker shim"); + const containerId = actionsCore.getState("docker_shim_container_id"); + if (containerId !== "") { + actionsCore.startGroup("Cleaning up the Nix daemon's Docker shim"); let cleaned = false; try { - await actions_exec.exec("docker", ["rm", "--force", container_id]); + await actionsExec.exec("docker", ["rm", "--force", containerId]); cleaned = true; } catch { - actions_core.warning("failed to cleanup nix daemon container"); + actionsCore.warning("failed to cleanup nix daemon container"); } if (!cleaned) { - actions_core.info("trying to pkill the container's shim process"); + actionsCore.info("trying to pkill the container's shim process"); try { - await actions_exec.exec("pkill", [container_id]); + await actionsExec.exec("pkill", [containerId]); cleaned = true; } catch { - actions_core.warning("failed to forcibly kill the container's shim process"); + actionsCore.warning("failed to forcibly kill the container's shim process"); } } if (cleaned) { - this.idslib.recordEvent("clean_up_docker_shim"); + this.idslib.recordEvent(EVENT_CLEAN_UP_DOCKER_SHIM); } else { - actions_core.warning("Giving up on cleaning up the nix daemon container"); + actionsCore.warning("Giving up on cleaning up the nix daemon container"); } - actions_core.endGroup(); + actionsCore.endGroup(); } } - async set_github_path() { + async setGithubPath() { // Interim versions of the `nix-installer` crate may have already manipulated `$GITHUB_PATH`, as root even! Accessing that will be an error. try { - const nix_var_nix_profile_path = "/nix/var/nix/profiles/default/bin"; - const home_nix_profile_path = `${process.env.HOME}/.nix-profile/bin`; - actions_core.addPath(nix_var_nix_profile_path); - actions_core.addPath(home_nix_profile_path); - actions_core.info(`Added \`${nix_var_nix_profile_path}\` and \`${home_nix_profile_path}\` to \`$GITHUB_PATH\``); + const nixVarNixProfilePath = "/nix/var/nix/profiles/default/bin"; + const homeNixProfilePath = `${process.env["HOME"]}/.nix-profile/bin`; + actionsCore.addPath(nixVarNixProfilePath); + actionsCore.addPath(homeNixProfilePath); + actionsCore.info(`Added \`${nixVarNixProfilePath}\` and \`${homeNixProfilePath}\` to \`$GITHUB_PATH\``); } - catch (error) { - actions_core.info("Skipping setting $GITHUB_PATH in action, the `nix-installer` crate seems to have done this already. From `nix-installer` version 0.11.0 and up, this step is done in the action. Prior to 0.11.0, this was only done in the `nix-installer` binary."); + catch { + actionsCore.info("Skipping setting $GITHUB_PATH in action, the `nix-installer` crate seems to have done this already. From `nix-installer` version 0.11.0 and up, this step is done in the action. Prior to 0.11.0, this was only done in the `nix-installer` binary."); } } - async flakehub_login() { - this.idslib.recordEvent("login_to_flakehub"); - const netrc_path = `${process.env["RUNNER_TEMP"]}/determinate-nix-installer-netrc`; - const jwt = await actions_core.getIDToken("api.flakehub.com"); - await writeFile(netrc_path, [ + async flakehubLogin() { + this.idslib.recordEvent(EVENT_LOGIN_TO_FLAKEHUB); + const netrcPath = `${process.env["RUNNER_TEMP"]}/determinate-nix-installer-netrc`; + const jwt = await actionsCore.getIDToken("api.flakehub.com"); + await writeFile(netrcPath, [ `machine api.flakehub.com login flakehub password ${jwt}`, `machine flakehub.com login flakehub password ${jwt}`, ].join("\n")); - actions_core.info("Logging in to FlakeHub."); + actionsCore.info("Logging in to FlakeHub."); // the join followed by a match on ^... looks silly, but extra_config // could contain multi-line values - if (this.extra_conf?.join("\n").match(/^netrc-file/m)) { - actions_core.warning("Logging in to FlakeHub conflicts with the Nix option `netrc-file`."); + if (this.extraConf?.join("\n").match(/^netrc-file/m)) { + actionsCore.warning("Logging in to FlakeHub conflicts with the Nix option `netrc-file`."); } - return netrc_path; + return netrcPath; } - async execute_uninstall() { - this.idslib.recordEvent("uninstall"); - const exit_code = await actions_exec.exec(`/nix/nix-installer`, ["uninstall"], { + async executeUninstall() { + this.idslib.recordEvent(EVENT_UNINSTALL_NIX); + const exitCode = await actionsExec.exec(`/nix/nix-installer`, ["uninstall"], { env: { NIX_INSTALLER_NO_CONFIRM: "true", ...process.env, // To get $PATH, etc }, }); - if (exit_code !== 0) { - throw new Error(`Non-zero exit code of \`${exit_code}\` detected`); + if (exitCode !== 0) { + throw new Error(`Non-zero exit code of \`${exitCode}\` detected`); } - return exit_code; + return exitCode; } - async detect_existing() { - const receipt_path = "/nix/receipt.json"; + async detectExisting() { + const receiptPath = "/nix/receipt.json"; try { - await access(receipt_path); + await access(receiptPath); // There is a /nix/receipt.json return true; } @@ -589,121 +611,122 @@ class NixInstallerAction { return false; } } - async setup_kvm() { - this.idslib.recordEvent("setup_kvm"); - const current_user = userInfo(); - const is_root = current_user.uid === 0; - const maybe_sudo = is_root ? "" : "sudo"; - const kvm_rules = "/etc/udev/rules.d/99-determinate-nix-installer-kvm.rules"; + async setupKvm() { + this.idslib.recordEvent(EVENT_SETUP_KVM); + const currentUser = userInfo(); + const isRoot = currentUser.uid === 0; + const maybeSudo = isRoot ? "" : "sudo"; + const kvmRules = "/etc/udev/rules.d/99-determinate-nix-installer-kvm.rules"; try { - const write_file_exit_code = await actions_exec.exec("sh", [ + const writeFileExitCode = await actionsExec.exec("sh", [ "-c", - `echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | ${maybe_sudo} tee ${kvm_rules} > /dev/null`, + `echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | ${maybeSudo} tee ${kvmRules} > /dev/null`, ], { silent: true, listeners: { stdout: (data) => { const trimmed = data.toString("utf-8").trimEnd(); if (trimmed.length >= 0) { - actions_core.debug(trimmed); + actionsCore.debug(trimmed); } }, stderr: (data) => { const trimmed = data.toString("utf-8").trimEnd(); if (trimmed.length >= 0) { - actions_core.debug(trimmed); + actionsCore.debug(trimmed); } }, }, }); - if (write_file_exit_code !== 0) { - throw new Error(`Non-zero exit code of \`${write_file_exit_code}\` detected while writing '${kvm_rules}'`); + if (writeFileExitCode !== 0) { + throw new Error(`Non-zero exit code of \`${writeFileExitCode}\` detected while writing '${kvmRules}'`); } - const debug_root_run_throw = async (action, command, args) => { - if (!is_root) { + const debugRootRunThrow = async (action, command, args) => { + if (!isRoot) { args = [command, ...args]; command = "sudo"; } - const reload_exit_code = await actions_exec.exec(command, args, { + const reloadExitCode = await actionsExec.exec(command, args, { silent: true, listeners: { stdout: (data) => { const trimmed = data.toString("utf-8").trimEnd(); if (trimmed.length >= 0) { - actions_core.debug(trimmed); + actionsCore.debug(trimmed); } }, stderr: (data) => { const trimmed = data.toString("utf-8").trimEnd(); if (trimmed.length >= 0) { - actions_core.debug(trimmed); + actionsCore.debug(trimmed); } }, }, }); - if (reload_exit_code !== 0) { - throw new Error(`Non-zero exit code of \`${reload_exit_code}\` detected while ${action}.`); + if (reloadExitCode !== 0) { + throw new Error(`Non-zero exit code of \`${reloadExitCode}\` detected while ${action}.`); } }; - await debug_root_run_throw("reloading udev rules", "udevadm", [ + await debugRootRunThrow("reloading udev rules", "udevadm", [ "control", "--reload-rules", ]); - await debug_root_run_throw("triggering udev against kvm", "udevadm", [ + await debugRootRunThrow("triggering udev against kvm", "udevadm", [ "trigger", "--name-match=kvm", ]); return true; } - catch (error) { - if (is_root) { - await actions_exec.exec("rm", ["-f", kvm_rules]); + catch { + if (isRoot) { + await actionsExec.exec("rm", ["-f", kvmRules]); } else { - await actions_exec.exec("sudo", ["rm", "-f", kvm_rules]); + await actionsExec.exec("sudo", ["rm", "-f", kvmRules]); } return false; } } - async fetch_binary() { - if (!this.local_root) { + async fetchBinary() { + if (!this.localRoot) { return await this.idslib.fetchExecutable(); } else { - const local_path = join(this.local_root, `nix-installer-${this.platform}`); - actions_core.info(`Using binary ${local_path}`); - return local_path; + const localPath = join(this.localRoot, `nix-installer-${this.platform}`); + actionsCore.info(`Using binary ${localPath}`); + return localPath; } } - async report_overall() { + async reportOverall() { try { - this.idslib.recordEvent("conclude_workflow", { - conclusion: await this.get_workflow_conclusion(), + this.idslib.recordEvent(EVENT_CONCLUDE_WORKFLOW, { + conclusion: await this.getWorkflowConclusion(), }); } - catch (error) { - actions_core.debug(`Error submitting post-run diagnostics report: ${error}`); + catch (e) { + actionsCore.debug(`Error submitting post-run diagnostics report: ${e}`); } } - async get_workflow_conclusion() { - if (this.github_token == null) { + async getWorkflowConclusion() { + if (this.githubToken == null) { return undefined; } try { - const octokit = github.getOctokit(this.github_token); + const octokit = github.getOctokit(this.githubToken); const jobs = await octokit.paginate(octokit.rest.actions.listJobsForWorkflowRun, { owner: github.context.repo.owner, repo: github.context.repo.repo, + /* eslint-disable camelcase */ run_id: github.context.runId, }); - actions_core.debug(`awaited jobs: ${jobs}`); + actionsCore.debug(`awaited jobs: ${jobs}`); const job = jobs .filter((candidate) => candidate.name === github.context.job) .at(0); if (job === undefined) { return "no-jobs"; } - const outcomes = (job.steps || []).map((j) => j.conclusion || "unknown"); + const outcomes = (job.steps ?? []).map((j) => j.conclusion ?? "unknown"); // Possible values: success, failure, cancelled, or skipped // from: https://docs.github.com/en/actions/learn-github-actions/contexts if (outcomes.includes("failure")) { @@ -717,73 +740,24 @@ class NixInstallerAction { // Assume success if no jobs failed or were canceled return "success"; } - catch (error) { - actions_core.debug(`Error determining final disposition: ${error}`); + catch (e) { + actionsCore.debug(`Error determining final disposition: ${e}`); return "unavailable"; } } } -function get_nix_platform() { - const env_os = process.env.RUNNER_OS; - const env_arch = process.env.RUNNER_ARCH; - if (env_os === "macOS" && env_arch === "X64") { - return "x86_64-darwin"; - } - else if (env_os === "macOS" && env_arch === "ARM64") { - return "aarch64-darwin"; - } - else if (env_os === "Linux" && env_arch === "X64") { - return "x86_64-linux"; - } - else if (env_os === "Linux" && env_arch === "ARM64") { - return "aarch64-linux"; - } - else { - throw new Error(`Unsupported \`RUNNER_OS\` (currently \`${env_os}\`) and \`RUNNER_ARCH\` (currently \`${env_arch}\`) combination`); - } -} -function get_default_planner() { - const env_os = process.env.RUNNER_OS; - if (env_os === "macOS") { +function getDefaultPlanner() { + const envOs = process.env["RUNNER_OS"]; + if (envOs === "macOS") { return "macos"; } - else if (env_os === "Linux") { + else if (envOs === "Linux") { return "linux"; } else { - throw new Error(`Unsupported \`RUNNER_OS\` (currently \`${env_os}\`)`); + throw new Error(`Unsupported \`RUNNER_OS\` (currently \`${envOs}\`)`); } } -function action_input_string_or_null(name) { - const value = actions_core.getInput(name); - if (value === "") { - return null; - } - else { - return value; - } -} -function action_input_multiline_string_or_null(name) { - const value = actions_core.getMultilineInput(name); - if (value.length === 0) { - return null; - } - else { - return value; - } -} -function action_input_number_or_null(name) { - const value = actions_core.getInput(name); - if (value === "") { - return null; - } - else { - return Number(value); - } -} -function action_input_bool(name) { - return actions_core.getBooleanInput(name); -} function main() { const installer = new NixInstallerAction(); installer.idslib.onMain(async () => { @@ -792,7 +766,7 @@ function main() { }); installer.idslib.onPost(async () => { await installer.cleanupDockerShim(); - await installer.report_overall(); + await installer.reportOverall(); }); installer.idslib.execute(); } diff --git a/package.json b/package.json index 2578412..46ed045 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,14 @@ { "name": "nix-installer-action", "version": "1.0.0", - "description": "You can use [`nix-installer`](https://github.com/DeterminateSystems/nix-installer) as a Github action:", + "description": "You can use [`nix-installer`](https://github.com/DeterminateSystems/nix-installer) as a Github Action:", "main": "./dist/main.js", "types": "./dist/main.d.ts", "type": "module", "scripts": { "build": "tsc", "format": "prettier --write .", + "check-fmt": "prettier --check .", "lint": "eslint src/**/*.ts", "package": "ncc build", "all": "pnpm run format && pnpm run lint && pnpm run build && pnpm run package" @@ -27,16 +28,14 @@ "@actions/core": "^1.10.1", "@actions/exec": "^1.1.1", "@actions/github": "^5.1.1", - "@actions/tool-cache": "^2.0.1", "detsys-ts": "github:DeterminateSystems/detsys-ts", - "fetch-retry": "^5.0.6", "string-argv": "^0.3.2" }, "devDependencies": { "@trivago/prettier-plugin-sort-imports": "^4.3.0", - "@types/node": "^20.12.7", + "@types/node": "^20.12.8", "@types/uuid": "^9.0.8", - "@typescript-eslint/eslint-plugin": "^7.6.0", + "@typescript-eslint/eslint-plugin": "^7.8.0", "@vercel/ncc": "^0.38.1", "eslint": "^8.57.0", "eslint-import-resolver-typescript": "^3.6.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 11ed2d4..43ade7e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,15 +14,9 @@ dependencies: "@actions/github": specifier: ^5.1.1 version: 5.1.1 - "@actions/tool-cache": - specifier: ^2.0.1 - version: 2.0.1 detsys-ts: specifier: github:DeterminateSystems/detsys-ts - version: github.com/DeterminateSystems/detsys-ts/3a315cdffd83d4b229d4fb16548d22a3756baf28 - fetch-retry: - specifier: ^5.0.6 - version: 5.0.6 + version: github.com/DeterminateSystems/detsys-ts/cd38b227c4d6faca10aed591b1f8863ef7b93dce string-argv: specifier: ^0.3.2 version: 0.3.2 @@ -32,14 +26,14 @@ devDependencies: specifier: ^4.3.0 version: 4.3.0(prettier@3.2.5) "@types/node": - specifier: ^20.12.7 - version: 20.12.7 + specifier: ^20.12.8 + version: 20.12.8 "@types/uuid": specifier: ^9.0.8 version: 9.0.8 "@typescript-eslint/eslint-plugin": - specifier: ^7.6.0 - version: 7.6.0(@typescript-eslint/parser@7.6.0)(eslint@8.57.0)(typescript@5.4.5) + specifier: ^7.8.0 + version: 7.8.0(@typescript-eslint/parser@7.8.0)(eslint@8.57.0)(typescript@5.4.5) "@vercel/ncc": specifier: ^0.38.1 version: 0.38.1 @@ -48,13 +42,13 @@ devDependencies: version: 8.57.0 eslint-import-resolver-typescript: specifier: ^3.6.1 - version: 3.6.1(@typescript-eslint/parser@7.6.0)(eslint-plugin-import@2.29.1)(eslint@8.57.0) + version: 3.6.1(@typescript-eslint/parser@7.8.0)(eslint-plugin-import@2.29.1)(eslint@8.57.0) eslint-plugin-github: specifier: ^4.10.2 version: 4.10.2(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0)(typescript@5.4.5) eslint-plugin-import: specifier: ^2.29.1 - version: 2.29.1(@typescript-eslint/parser@7.6.0)(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0) + version: 2.29.1(@typescript-eslint/parser@7.8.0)(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0) eslint-plugin-prettier: specifier: ^5.1.3 version: 5.1.3(eslint-config-prettier@9.1.0)(eslint@8.57.0)(prettier@3.2.5) @@ -69,14 +63,6 @@ devDependencies: version: 5.4.5 packages: - /@aashutoshrathi/word-wrap@1.2.6: - resolution: - { - integrity: sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==, - } - engines: { node: ">=0.10.0" } - dev: true - /@actions/cache@3.2.4: resolution: { @@ -157,20 +143,6 @@ packages: } dev: false - /@actions/tool-cache@2.0.1: - resolution: - { - integrity: sha512-iPU+mNwrbA8jodY8eyo/0S/QqCKDajiR8OxWTnSk/SnYg0sj8Hp4QcUEVC1YFpHWXtrfbQrE13Jz4k4HXJQKcA==, - } - dependencies: - "@actions/core": 1.10.1 - "@actions/exec": 1.1.1 - "@actions/http-client": 2.2.1 - "@actions/io": 1.1.3 - semver: 6.3.1 - uuid: 3.4.0 - dev: false - /@azure/abort-controller@1.1.0: resolution: { @@ -327,7 +299,7 @@ packages: } engines: { node: ">=6.9.0" } dependencies: - "@babel/highlight": 7.24.2 + "@babel/highlight": 7.24.5 picocolors: 1.0.0 dev: true @@ -343,14 +315,14 @@ packages: source-map: 0.5.7 dev: true - /@babel/generator@7.24.4: + /@babel/generator@7.24.5: resolution: { - integrity: sha512-Xd6+v6SnjWVx/nus+y0l1sxMOTOMBkyL4+BIdbALyatQnAe/SRVjANeDPSCYaX+i1iJmuGSKf3Z+E+V/va1Hvw==, + integrity: sha512-x32i4hEXvr+iI0NEoEfDKzlemF8AmtOP8CcrRaEcpzysWuoEb1KknpcvMsHKPONoKZiDuItklgWhB18xEhr9PA==, } engines: { node: ">=6.9.0" } dependencies: - "@babel/types": 7.24.0 + "@babel/types": 7.24.5 "@jridgewell/gen-mapping": 0.3.5 "@jridgewell/trace-mapping": 0.3.25 jsesc: 2.5.2 @@ -372,7 +344,7 @@ packages: engines: { node: ">=6.9.0" } dependencies: "@babel/template": 7.24.0 - "@babel/types": 7.24.0 + "@babel/types": 7.24.5 dev: true /@babel/helper-hoist-variables@7.22.5: @@ -382,17 +354,17 @@ packages: } engines: { node: ">=6.9.0" } dependencies: - "@babel/types": 7.24.0 + "@babel/types": 7.24.5 dev: true - /@babel/helper-split-export-declaration@7.22.6: + /@babel/helper-split-export-declaration@7.24.5: resolution: { - integrity: sha512-AsUnxuLhRYsisFiaJwvp1QF+I3KjD5FOxut14q/GzovUe6orHLesW2C7d754kRm53h5gqrz6sFl6sxc4BVtE/g==, + integrity: sha512-5CHncttXohrHk8GWOFCcCl4oRD9fKosWlIRgWm4ql9VYioKm52Mk2xsmoohvm7f3JoiLSM5ZgJuRaf5QZZYd3Q==, } engines: { node: ">=6.9.0" } dependencies: - "@babel/types": 7.24.0 + "@babel/types": 7.24.5 dev: true /@babel/helper-string-parser@7.24.1: @@ -403,31 +375,31 @@ packages: engines: { node: ">=6.9.0" } dev: true - /@babel/helper-validator-identifier@7.22.20: + /@babel/helper-validator-identifier@7.24.5: resolution: { - integrity: sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==, + integrity: sha512-3q93SSKX2TWCG30M2G2kwaKeTYgEUp5Snjuj8qm729SObL6nbtUldAi37qbxkD5gg3xnBio+f9nqpSepGZMvxA==, } engines: { node: ">=6.9.0" } dev: true - /@babel/highlight@7.24.2: + /@babel/highlight@7.24.5: resolution: { - integrity: sha512-Yac1ao4flkTxTteCDZLEvdxg2fZfz1v8M4QpaGypq/WPDqg3ijHYbDfs+LG5hvzSoqaSZ9/Z9lKSP3CjZjv+pA==, + integrity: sha512-8lLmua6AVh/8SLJRRVD6V8p73Hir9w5mJrhE+IPpILG31KKlI9iz5zmBYKcWPS59qSfgP9RaSBQSHHE81WKuEw==, } engines: { node: ">=6.9.0" } dependencies: - "@babel/helper-validator-identifier": 7.22.20 + "@babel/helper-validator-identifier": 7.24.5 chalk: 2.4.2 js-tokens: 4.0.0 picocolors: 1.0.0 dev: true - /@babel/parser@7.24.4: + /@babel/parser@7.24.5: resolution: { - integrity: sha512-zTvEBcghmeBma9QIGunWevvBAp4/Qu9Bdq+2k0Ot4fVMD6v3dsC9WOcRSKk7tRRyBM/53yKMJko9xOatGQAwSg==, + integrity: sha512-EOv5IK8arwh3LI47dz1b0tKUb/1uhHAnHJOrjgtQMIpu1uXd9mlFrJg9IUgGUgZ41Ch0K8REPTYpO7B76b4vJg==, } engines: { node: ">=6.0.0" } hasBin: true @@ -435,10 +407,10 @@ packages: "@babel/types": 7.17.0 dev: true - /@babel/runtime@7.24.4: + /@babel/runtime@7.24.5: resolution: { - integrity: sha512-dkxf7+hn8mFBwKjs9bvBlArzLVxVbS8usaPUDd5p2a9JCL9tB8OaOVN1isD4+Xyk4ns89/xeOmbQvgdK7IIVdA==, + integrity: sha512-Nms86NXrsaeU9vbBJKni6gXiEXZ4CVpYVzEjDH9Sb8vmZ3UljyA1GSOJl/6LGPO8EHLuSF9H+IxNXHPX8QHJ4g==, } engines: { node: ">=6.9.0" } dependencies: @@ -453,8 +425,8 @@ packages: engines: { node: ">=6.9.0" } dependencies: "@babel/code-frame": 7.24.2 - "@babel/parser": 7.24.4 - "@babel/types": 7.24.0 + "@babel/parser": 7.24.5 + "@babel/types": 7.24.5 dev: true /@babel/traverse@7.23.2: @@ -465,13 +437,13 @@ packages: engines: { node: ">=6.9.0" } dependencies: "@babel/code-frame": 7.24.2 - "@babel/generator": 7.24.4 + "@babel/generator": 7.24.5 "@babel/helper-environment-visitor": 7.22.20 "@babel/helper-function-name": 7.23.0 "@babel/helper-hoist-variables": 7.22.5 - "@babel/helper-split-export-declaration": 7.22.6 - "@babel/parser": 7.24.4 - "@babel/types": 7.24.0 + "@babel/helper-split-export-declaration": 7.24.5 + "@babel/parser": 7.24.5 + "@babel/types": 7.24.5 debug: 4.3.4 globals: 11.12.0 transitivePeerDependencies: @@ -485,19 +457,19 @@ packages: } engines: { node: ">=6.9.0" } dependencies: - "@babel/helper-validator-identifier": 7.22.20 + "@babel/helper-validator-identifier": 7.24.5 to-fast-properties: 2.0.0 dev: true - /@babel/types@7.24.0: + /@babel/types@7.24.5: resolution: { - integrity: sha512-+j7a5c253RfKh8iABBhywc8NSfP5LURe7Uh4qpsh6jc+aLJguvmIUBdjSdEMQv2bENrCR5MfRdjGo7vzS/ob7w==, + integrity: sha512-6mQNsaLeXTw0nxYUYu+NSa4Hx4BlF1x1x8/PMFbiR+GBSr+2DkECc69b8hgy2frEodNcvPffeH8YfWd3LI6jhQ==, } engines: { node: ">=6.9.0" } dependencies: "@babel/helper-string-parser": 7.24.1 - "@babel/helper-validator-identifier": 7.22.20 + "@babel/helper-validator-identifier": 7.24.5 to-fast-properties: 2.0.0 dev: true @@ -1104,10 +1076,10 @@ packages: engines: { node: ^12.20.0 || ^14.18.0 || >=16.0.0 } dev: true - /@rollup/rollup-android-arm-eabi@4.14.1: + /@rollup/rollup-android-arm-eabi@4.17.2: resolution: { - integrity: sha512-fH8/o8nSUek8ceQnT7K4EQbSiV7jgkHq81m9lWZFIXjJ7lJzpWXbQFpT/Zh6OZYnpFykvzC3fbEvEAFZu03dPA==, + integrity: sha512-NM0jFxY8bB8QLkoKxIQeObCaDlJKewVlIEkuyYKm5An1tdVZ966w2+MPQ2l8LBZLjR+SgyV+nRkTIunzOYBMLQ==, } cpu: [arm] os: [android] @@ -1115,10 +1087,10 @@ packages: dev: true optional: true - /@rollup/rollup-android-arm64@4.14.1: + /@rollup/rollup-android-arm64@4.17.2: resolution: { - integrity: sha512-Y/9OHLjzkunF+KGEoJr3heiD5X9OLa8sbT1lm0NYeKyaM3oMhhQFvPB0bNZYJwlq93j8Z6wSxh9+cyKQaxS7PQ==, + integrity: sha512-yeX/Usk7daNIVwkq2uGoq2BYJKZY1JfyLTaHO/jaiSwi/lsf8fTFoQW/n6IdAsx5tx+iotu2zCJwz8MxI6D/Bw==, } cpu: [arm64] os: [android] @@ -1126,10 +1098,10 @@ packages: dev: true optional: true - /@rollup/rollup-darwin-arm64@4.14.1: + /@rollup/rollup-darwin-arm64@4.17.2: resolution: { - integrity: sha512-+kecg3FY84WadgcuSVm6llrABOdQAEbNdnpi5X3UwWiFVhZIZvKgGrF7kmLguvxHNQy+UuRV66cLVl3S+Rkt+Q==, + integrity: sha512-kcMLpE6uCwls023+kknm71ug7MZOrtXo+y5p/tsg6jltpDtgQY1Eq5sGfHcQfb+lfuKwhBmEURDga9N0ol4YPw==, } cpu: [arm64] os: [darwin] @@ -1137,10 +1109,10 @@ packages: dev: true optional: true - /@rollup/rollup-darwin-x64@4.14.1: + /@rollup/rollup-darwin-x64@4.17.2: resolution: { - integrity: sha512-2pYRzEjVqq2TB/UNv47BV/8vQiXkFGVmPFwJb+1E0IFFZbIX8/jo1olxqqMbo6xCXf8kabANhp5bzCij2tFLUA==, + integrity: sha512-AtKwD0VEx0zWkL0ZjixEkp5tbNLzX+FCqGG1SvOu993HnSz4qDI6S4kGzubrEJAljpVkhRSlg5bzpV//E6ysTQ==, } cpu: [x64] os: [darwin] @@ -1148,10 +1120,10 @@ packages: dev: true optional: true - /@rollup/rollup-linux-arm-gnueabihf@4.14.1: + /@rollup/rollup-linux-arm-gnueabihf@4.17.2: resolution: { - integrity: sha512-mS6wQ6Do6/wmrF9aTFVpIJ3/IDXhg1EZcQFYHZLHqw6AzMBjTHWnCG35HxSqUNphh0EHqSM6wRTT8HsL1C0x5g==, + integrity: sha512-3reX2fUHqN7sffBNqmEyMQVj/CKhIHZd4y631duy0hZqI8Qoqf6lTtmAKvJFYa6bhU95B1D0WgzHkmTg33In0A==, } cpu: [arm] os: [linux] @@ -1159,10 +1131,21 @@ packages: dev: true optional: true - /@rollup/rollup-linux-arm64-gnu@4.14.1: + /@rollup/rollup-linux-arm-musleabihf@4.17.2: resolution: { - integrity: sha512-p9rGKYkHdFMzhckOTFubfxgyIO1vw//7IIjBBRVzyZebWlzRLeNhqxuSaZ7kCEKVkm/kuC9fVRW9HkC/zNRG2w==, + integrity: sha512-uSqpsp91mheRgw96xtyAGP9FW5ChctTFEoXP0r5FAzj/3ZRv3Uxjtc7taRQSaQM/q85KEKjKsZuiZM3GyUivRg==, + } + cpu: [arm] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@rollup/rollup-linux-arm64-gnu@4.17.2: + resolution: + { + integrity: sha512-EMMPHkiCRtE8Wdk3Qhtciq6BndLtstqZIroHiiGzB3C5LDJmIZcSzVtLRbwuXuUft1Cnv+9fxuDtDxz3k3EW2A==, } cpu: [arm64] os: [linux] @@ -1170,10 +1153,10 @@ packages: dev: true optional: true - /@rollup/rollup-linux-arm64-musl@4.14.1: + /@rollup/rollup-linux-arm64-musl@4.17.2: resolution: { - integrity: sha512-nDY6Yz5xS/Y4M2i9JLQd3Rofh5OR8Bn8qe3Mv/qCVpHFlwtZSBYSPaU4mrGazWkXrdQ98GB//H0BirGR/SKFSw==, + integrity: sha512-NMPylUUZ1i0z/xJUIx6VUhISZDRT+uTWpBcjdv0/zkp7b/bQDF+NfnfdzuTiB1G6HTodgoFa93hp0O1xl+/UbA==, } cpu: [arm64] os: [linux] @@ -1181,21 +1164,21 @@ packages: dev: true optional: true - /@rollup/rollup-linux-powerpc64le-gnu@4.14.1: + /@rollup/rollup-linux-powerpc64le-gnu@4.17.2: resolution: { - integrity: sha512-im7HE4VBL+aDswvcmfx88Mp1soqL9OBsdDBU8NqDEYtkri0qV0THhQsvZtZeNNlLeCUQ16PZyv7cqutjDF35qw==, + integrity: sha512-T19My13y8uYXPw/L/k0JYaX1fJKFT/PWdXiHr8mTbXWxjVF1t+8Xl31DgBBvEKclw+1b00Chg0hxE2O7bTG7GQ==, } - cpu: [ppc64le] + cpu: [ppc64] os: [linux] requiresBuild: true dev: true optional: true - /@rollup/rollup-linux-riscv64-gnu@4.14.1: + /@rollup/rollup-linux-riscv64-gnu@4.17.2: resolution: { - integrity: sha512-RWdiHuAxWmzPJgaHJdpvUUlDz8sdQz4P2uv367T2JocdDa98iRw2UjIJ4QxSyt077mXZT2X6pKfT2iYtVEvOFw==, + integrity: sha512-BOaNfthf3X3fOWAB+IJ9kxTgPmMqPPH5f5k2DcCsRrBIbWnaJCgX2ll77dV1TdSy9SaXTR5iDXRL8n7AnoP5cg==, } cpu: [riscv64] os: [linux] @@ -1203,10 +1186,10 @@ packages: dev: true optional: true - /@rollup/rollup-linux-s390x-gnu@4.14.1: + /@rollup/rollup-linux-s390x-gnu@4.17.2: resolution: { - integrity: sha512-VMgaGQ5zRX6ZqV/fas65/sUGc9cPmsntq2FiGmayW9KMNfWVG/j0BAqImvU4KTeOOgYSf1F+k6at1UfNONuNjA==, + integrity: sha512-W0UP/x7bnn3xN2eYMql2T/+wpASLE5SjObXILTMPUBDB/Fg/FxC+gX4nvCfPBCbNhz51C+HcqQp2qQ4u25ok6g==, } cpu: [s390x] os: [linux] @@ -1214,10 +1197,10 @@ packages: dev: true optional: true - /@rollup/rollup-linux-x64-gnu@4.14.1: + /@rollup/rollup-linux-x64-gnu@4.17.2: resolution: { - integrity: sha512-9Q7DGjZN+hTdJomaQ3Iub4m6VPu1r94bmK2z3UeWP3dGUecRC54tmVu9vKHTm1bOt3ASoYtEz6JSRLFzrysKlA==, + integrity: sha512-Hy7pLwByUOuyaFC6mAr7m+oMC+V7qyifzs/nW2OJfC8H4hbCzOX07Ov0VFk/zP3kBsELWNFi7rJtgbKYsav9QQ==, } cpu: [x64] os: [linux] @@ -1225,10 +1208,10 @@ packages: dev: true optional: true - /@rollup/rollup-linux-x64-musl@4.14.1: + /@rollup/rollup-linux-x64-musl@4.17.2: resolution: { - integrity: sha512-JNEG/Ti55413SsreTguSx0LOVKX902OfXIKVg+TCXO6Gjans/k9O6ww9q3oLGjNDaTLxM+IHFMeXy/0RXL5R/g==, + integrity: sha512-h1+yTWeYbRdAyJ/jMiVw0l6fOOm/0D1vNLui9iPuqgRGnXA0u21gAqOyB5iHjlM9MMfNOm9RHCQ7zLIzT0x11Q==, } cpu: [x64] os: [linux] @@ -1236,10 +1219,10 @@ packages: dev: true optional: true - /@rollup/rollup-win32-arm64-msvc@4.14.1: + /@rollup/rollup-win32-arm64-msvc@4.17.2: resolution: { - integrity: sha512-ryS22I9y0mumlLNwDFYZRDFLwWh3aKaC72CWjFcFvxK0U6v/mOkM5Up1bTbCRAhv3kEIwW2ajROegCIQViUCeA==, + integrity: sha512-tmdtXMfKAjy5+IQsVtDiCfqbynAQE/TQRpWdVataHmhMb9DCoJxp9vLcCBjEQWMiUYxO1QprH/HbY9ragCEFLA==, } cpu: [arm64] os: [win32] @@ -1247,10 +1230,10 @@ packages: dev: true optional: true - /@rollup/rollup-win32-ia32-msvc@4.14.1: + /@rollup/rollup-win32-ia32-msvc@4.17.2: resolution: { - integrity: sha512-TdloItiGk+T0mTxKx7Hp279xy30LspMso+GzQvV2maYePMAWdmrzqSNZhUpPj3CGw12aGj57I026PgLCTu8CGg==, + integrity: sha512-7II/QCSTAHuE5vdZaQEwJq2ZACkBpQDOmQsE6D6XUbnBHW8IAhm4eTufL6msLJorzrHDFv3CF8oCA/hSIRuZeQ==, } cpu: [ia32] os: [win32] @@ -1258,10 +1241,10 @@ packages: dev: true optional: true - /@rollup/rollup-win32-x64-msvc@4.14.1: + /@rollup/rollup-win32-x64-msvc@4.17.2: resolution: { - integrity: sha512-wQGI+LY/Py20zdUPq+XCem7JcPOyzIJBm3dli+56DJsQOHbnXZFEwgmnC6el1TPAfC8lBT3m+z69RmLykNUbew==, + integrity: sha512-TGGO7v7qOq4CYmSBVEYpI1Y5xDuCEnbVC5Vth8mOsW0gDSzxNrVERPc790IGHsrT2dQSimgMr9Ub3Y1Jci5/8w==, } cpu: [x64] os: [win32] @@ -1269,10 +1252,10 @@ packages: dev: true optional: true - /@sindresorhus/is@6.2.0: + /@sindresorhus/is@6.3.0: resolution: { - integrity: sha512-yM/IGPkVnYGblhDosFBwq0ZGdnVSBkNV4onUtipGMOjZd4kB6GAu3ys91aftSbyMHh6A2GPdt+KDI5NoWP63MQ==, + integrity: sha512-bOSPck7aIJjASXIg1qvXSIjXhVBpIEKdl2Wxg4pVqoTRPL8wWExKBrnGIh6CEnhkFQHfc36k7APhO3uXV4g5xg==, } engines: { node: ">=16" } dev: false @@ -1300,7 +1283,7 @@ packages: optional: true dependencies: "@babel/generator": 7.17.7 - "@babel/parser": 7.24.4 + "@babel/parser": 7.24.5 "@babel/traverse": 7.23.2 "@babel/types": 7.17.0 javascript-natural-sort: 0.7.1 @@ -1344,14 +1327,14 @@ packages: integrity: sha512-24xFj9R5+rfQJLRyM56qh+wnVSYhyXC2tkoBndtY0U+vubqNsYXGjufB2nn8Q6gt0LrARwL6UBtMCSVCwl4B1g==, } dependencies: - "@types/node": 20.12.7 + "@types/node": 20.12.8 form-data: 4.0.0 dev: false - /@types/node@20.12.7: + /@types/node@20.12.8: resolution: { - integrity: sha512-wq0cICSkRLVaf3UGLMGItu/PtdY7oaXaI/RVU+xliKVOtRna3PRY57ZDfztpDL0n11vfymMUnXv8QwYCO7L1wg==, + integrity: sha512-NU0rJLJnshZWdE/097cdCBbyW1h4hEg0xpovcoAQYHl8dnEyp/NAOiE45pvc+Bd1Dt+2r94v2eGFpQJ4R7g+2w==, } dependencies: undici-types: 5.26.5 @@ -1369,7 +1352,7 @@ packages: integrity: sha512-sOUTGn6h1SfQ+gbgqC364jLFBw2lnFqkgF3q0WovEHRLMrVD1sd5aufqi/aJObLekJO+Aq5z646U4Oxy6shXMA==, } dependencies: - "@types/node": 20.12.7 + "@types/node": 20.12.8 dev: false /@types/uuid@9.0.8: @@ -1379,10 +1362,10 @@ packages: } dev: true - /@typescript-eslint/eslint-plugin@7.6.0(@typescript-eslint/parser@7.6.0)(eslint@8.57.0)(typescript@5.4.5): + /@typescript-eslint/eslint-plugin@7.8.0(@typescript-eslint/parser@7.8.0)(eslint@8.57.0)(typescript@5.4.5): resolution: { - integrity: sha512-gKmTNwZnblUdnTIJu3e9kmeRRzV2j1a/LUO27KNNAnIC5zjy1aSvXSRp4rVNlmAoHlQ7HzX42NbKpcSr4jF80A==, + integrity: sha512-gFTT+ezJmkwutUPmB0skOj3GZJtlEGnlssems4AjkVweUPGj7jRwwqg0Hhg7++kPGJqKtTYx+R05Ftww372aIg==, } engines: { node: ^18.18.0 || >=20.0.0 } peerDependencies: @@ -1394,11 +1377,11 @@ packages: optional: true dependencies: "@eslint-community/regexpp": 4.10.0 - "@typescript-eslint/parser": 7.6.0(eslint@8.57.0)(typescript@5.4.5) - "@typescript-eslint/scope-manager": 7.6.0 - "@typescript-eslint/type-utils": 7.6.0(eslint@8.57.0)(typescript@5.4.5) - "@typescript-eslint/utils": 7.6.0(eslint@8.57.0)(typescript@5.4.5) - "@typescript-eslint/visitor-keys": 7.6.0 + "@typescript-eslint/parser": 7.8.0(eslint@8.57.0)(typescript@5.4.5) + "@typescript-eslint/scope-manager": 7.8.0 + "@typescript-eslint/type-utils": 7.8.0(eslint@8.57.0)(typescript@5.4.5) + "@typescript-eslint/utils": 7.8.0(eslint@8.57.0)(typescript@5.4.5) + "@typescript-eslint/visitor-keys": 7.8.0 debug: 4.3.4 eslint: 8.57.0 graphemer: 1.4.0 @@ -1411,10 +1394,10 @@ packages: - supports-color dev: true - /@typescript-eslint/parser@7.6.0(eslint@8.57.0)(typescript@5.4.5): + /@typescript-eslint/parser@7.8.0(eslint@8.57.0)(typescript@5.4.5): resolution: { - integrity: sha512-usPMPHcwX3ZoPWnBnhhorc14NJw9J4HpSXQX4urF2TPKG0au0XhJoZyX62fmvdHONUkmyUe74Hzm1//XA+BoYg==, + integrity: sha512-KgKQly1pv0l4ltcftP59uQZCi4HUYswCLbTqVZEJu7uLX8CTLyswqMLqLN+2QFz4jCptqWVV4SB7vdxcH2+0kQ==, } engines: { node: ^18.18.0 || >=20.0.0 } peerDependencies: @@ -1424,10 +1407,10 @@ packages: typescript: optional: true dependencies: - "@typescript-eslint/scope-manager": 7.6.0 - "@typescript-eslint/types": 7.6.0 - "@typescript-eslint/typescript-estree": 7.6.0(typescript@5.4.5) - "@typescript-eslint/visitor-keys": 7.6.0 + "@typescript-eslint/scope-manager": 7.8.0 + "@typescript-eslint/types": 7.8.0 + "@typescript-eslint/typescript-estree": 7.8.0(typescript@5.4.5) + "@typescript-eslint/visitor-keys": 7.8.0 debug: 4.3.4 eslint: 8.57.0 typescript: 5.4.5 @@ -1435,21 +1418,21 @@ packages: - supports-color dev: true - /@typescript-eslint/scope-manager@7.6.0: + /@typescript-eslint/scope-manager@7.8.0: resolution: { - integrity: sha512-ngttyfExA5PsHSx0rdFgnADMYQi+Zkeiv4/ZxGYUWd0nLs63Ha0ksmp8VMxAIC0wtCFxMos7Lt3PszJssG/E6w==, + integrity: sha512-viEmZ1LmwsGcnr85gIq+FCYI7nO90DVbE37/ll51hjv9aG+YZMb4WDE2fyWpUR4O/UrhGRpYXK/XajcGTk2B8g==, } engines: { node: ^18.18.0 || >=20.0.0 } dependencies: - "@typescript-eslint/types": 7.6.0 - "@typescript-eslint/visitor-keys": 7.6.0 + "@typescript-eslint/types": 7.8.0 + "@typescript-eslint/visitor-keys": 7.8.0 dev: true - /@typescript-eslint/type-utils@7.6.0(eslint@8.57.0)(typescript@5.4.5): + /@typescript-eslint/type-utils@7.8.0(eslint@8.57.0)(typescript@5.4.5): resolution: { - integrity: sha512-NxAfqAPNLG6LTmy7uZgpK8KcuiS2NZD/HlThPXQRGwz6u7MDBWRVliEEl1Gj6U7++kVJTpehkhZzCJLMK66Scw==, + integrity: sha512-H70R3AefQDQpz9mGv13Uhi121FNMh+WEaRqcXTX09YEDky21km4dV1ZXJIp8QjXc4ZaVkXVdohvWDzbnbHDS+A==, } engines: { node: ^18.18.0 || >=20.0.0 } peerDependencies: @@ -1459,8 +1442,8 @@ packages: typescript: optional: true dependencies: - "@typescript-eslint/typescript-estree": 7.6.0(typescript@5.4.5) - "@typescript-eslint/utils": 7.6.0(eslint@8.57.0)(typescript@5.4.5) + "@typescript-eslint/typescript-estree": 7.8.0(typescript@5.4.5) + "@typescript-eslint/utils": 7.8.0(eslint@8.57.0)(typescript@5.4.5) debug: 4.3.4 eslint: 8.57.0 ts-api-utils: 1.3.0(typescript@5.4.5) @@ -1469,18 +1452,18 @@ packages: - supports-color dev: true - /@typescript-eslint/types@7.6.0: + /@typescript-eslint/types@7.8.0: resolution: { - integrity: sha512-h02rYQn8J+MureCvHVVzhl69/GAfQGPQZmOMjG1KfCl7o3HtMSlPaPUAPu6lLctXI5ySRGIYk94clD/AUMCUgQ==, + integrity: sha512-wf0peJ+ZGlcH+2ZS23aJbOv+ztjeeP8uQ9GgwMJGVLx/Nj9CJt17GWgWWoSmoRVKAX2X+7fzEnAjxdvK2gqCLw==, } engines: { node: ^18.18.0 || >=20.0.0 } dev: true - /@typescript-eslint/typescript-estree@7.6.0(typescript@5.4.5): + /@typescript-eslint/typescript-estree@7.8.0(typescript@5.4.5): resolution: { - integrity: sha512-+7Y/GP9VuYibecrCQWSKgl3GvUM5cILRttpWtnAu8GNL9j11e4tbuGZmZjJ8ejnKYyBRb2ddGQ3rEFCq3QjMJw==, + integrity: sha512-5pfUCOwK5yjPaJQNy44prjCwtr981dO8Qo9J9PwYXZ0MosgAbfEMB008dJ5sNo3+/BN6ytBPuSvXUg9SAqB0dg==, } engines: { node: ^18.18.0 || >=20.0.0 } peerDependencies: @@ -1489,8 +1472,8 @@ packages: typescript: optional: true dependencies: - "@typescript-eslint/types": 7.6.0 - "@typescript-eslint/visitor-keys": 7.6.0 + "@typescript-eslint/types": 7.8.0 + "@typescript-eslint/visitor-keys": 7.8.0 debug: 4.3.4 globby: 11.1.0 is-glob: 4.0.3 @@ -1502,10 +1485,10 @@ packages: - supports-color dev: true - /@typescript-eslint/utils@7.6.0(eslint@8.57.0)(typescript@5.4.5): + /@typescript-eslint/utils@7.8.0(eslint@8.57.0)(typescript@5.4.5): resolution: { - integrity: sha512-x54gaSsRRI+Nwz59TXpCsr6harB98qjXYzsRxGqvA5Ue3kQH+FxS7FYU81g/omn22ML2pZJkisy6Q+ElK8pBCA==, + integrity: sha512-L0yFqOCflVqXxiZyXrDr80lnahQfSOfc9ELAAZ75sqicqp2i36kEZZGuUymHNFoYOqxRT05up760b4iGsl02nQ==, } engines: { node: ^18.18.0 || >=20.0.0 } peerDependencies: @@ -1514,9 +1497,9 @@ packages: "@eslint-community/eslint-utils": 4.4.0(eslint@8.57.0) "@types/json-schema": 7.0.15 "@types/semver": 7.5.8 - "@typescript-eslint/scope-manager": 7.6.0 - "@typescript-eslint/types": 7.6.0 - "@typescript-eslint/typescript-estree": 7.6.0(typescript@5.4.5) + "@typescript-eslint/scope-manager": 7.8.0 + "@typescript-eslint/types": 7.8.0 + "@typescript-eslint/typescript-estree": 7.8.0(typescript@5.4.5) eslint: 8.57.0 semver: 7.6.0 transitivePeerDependencies: @@ -1524,14 +1507,14 @@ packages: - typescript dev: true - /@typescript-eslint/visitor-keys@7.6.0: + /@typescript-eslint/visitor-keys@7.8.0: resolution: { - integrity: sha512-4eLB7t+LlNUmXzfOu1VAIAdkjbu5xNSerURS9X/S5TUKWFRpXRQZbmtPqgKmYx8bj3J0irtQXSiWAOY82v+cgw==, + integrity: sha512-q4/gibTNBQNA0lGyYQCmWRS5D15n8rXh4QjK3KV+MBPlTYHpfBUT3D3PaPR/HeNiI9W6R7FvlkcGhNyAoP+caA==, } engines: { node: ^18.18.0 || >=20.0.0 } dependencies: - "@typescript-eslint/types": 7.6.0 + "@typescript-eslint/types": 7.8.0 eslint-visitor-keys: 3.4.3 dev: true @@ -1860,16 +1843,16 @@ packages: engines: { node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7 } hasBin: true dependencies: - caniuse-lite: 1.0.30001608 - electron-to-chromium: 1.4.733 + caniuse-lite: 1.0.30001615 + electron-to-chromium: 1.4.754 node-releases: 2.0.14 - update-browserslist-db: 1.0.13(browserslist@4.23.0) + update-browserslist-db: 1.0.14(browserslist@4.23.0) dev: true - /bundle-require@4.0.2(esbuild@0.19.12): + /bundle-require@4.1.0(esbuild@0.19.12): resolution: { - integrity: sha512-jwzPOChofl67PSTW2SGubV9HBQAhhR2i6nskiOThauo9dzwDUgOWQScFVaJkjEfYX+UXiD+LEx8EblQMc2wIag==, + integrity: sha512-FeArRFM+ziGkRViKRnSTbHZc35dgmR9yNog05Kn0+ItI59pOAISGvnnIwW1WgFZQW59IxD9QpJnUPkdIPfZuXg==, } engines: { node: ^12.20.0 || ^14.13.1 || >=16.0.0 } peerDependencies: @@ -1933,10 +1916,10 @@ packages: engines: { node: ">=6" } dev: true - /caniuse-lite@1.0.30001608: + /caniuse-lite@1.0.30001615: resolution: { - integrity: sha512-cjUJTQkk9fQlJR2s4HMuPMvTiRggl0rAVMtthQuyOlDWuqHXqN8azLq+pi8B2TjwKJ32diHjUqRIKeFX4z1FoA==, + integrity: sha512-1IpazM5G3r38meiae0bHRnPhz+CBQ3ZLqbQMtrg+AsTPKAXgW38JNsXkyZ+v8waCsDmPq87lmfun5Q2AGysNEQ==, } dev: true @@ -2231,10 +2214,10 @@ packages: } dev: true - /electron-to-chromium@1.4.733: + /electron-to-chromium@1.4.754: resolution: { - integrity: sha512-gUI9nhI2iBGF0OaYYLKOaOtliFMl+Bt1rY7VmEjwxOxqoYLub/D9xmduPEhbw2imE6gYkJKhIE5it+KE2ulVxQ==, + integrity: sha512-7Kr5jUdns5rL/M9wFFmMZAgFDuL2YOnanFH4OI4iFzUqyh3XOL7nAGbSlSMZdzKMIyyTpNSbqZsWG9odwLeKvA==, } dev: true @@ -2285,7 +2268,7 @@ packages: function.prototype.name: 1.1.6 get-intrinsic: 1.2.4 get-symbol-description: 1.0.2 - globalthis: 1.0.3 + globalthis: 1.0.4 gopd: 1.0.1 has-property-descriptors: 1.0.2 has-proto: 1.0.3 @@ -2336,10 +2319,10 @@ packages: engines: { node: ">= 0.4" } dev: true - /es-iterator-helpers@1.0.18: + /es-iterator-helpers@1.0.19: resolution: { - integrity: sha512-scxAJaewsahbqTYrGKJihhViaM6DDZDDoucfvzNbK0pOren1g/daDQ3IAhzn+1G14rBG7w+i5N+qul60++zlKA==, + integrity: sha512-zoMwbCcH5hwUkKJkT8kDIBZSz9I6mVG//+lDCinLCGov4+r7NIy0ld8o03M0cJxl2spVf6ESYVS6/gpIfq1FFw==, } engines: { node: ">= 0.4" } dependencies: @@ -2350,7 +2333,7 @@ packages: es-set-tostringtag: 2.0.3 function-bind: 1.1.2 get-intrinsic: 1.2.4 - globalthis: 1.0.3 + globalthis: 1.0.4 has-property-descriptors: 1.0.2 has-proto: 1.0.3 has-symbols: 1.0.3 @@ -2485,7 +2468,7 @@ packages: - supports-color dev: true - /eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.6.0)(eslint-plugin-import@2.29.1)(eslint@8.57.0): + /eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.8.0)(eslint-plugin-import@2.29.1)(eslint@8.57.0): resolution: { integrity: sha512-xgdptdoi5W3niYeuQxKmzVDTATvLYqhpwmykwsh7f6HIOStGWEIL9iqZgQDF9u9OEzrRwR8no5q2VT+bjAujTg==, @@ -2498,8 +2481,8 @@ packages: debug: 4.3.4 enhanced-resolve: 5.16.0 eslint: 8.57.0 - eslint-module-utils: 2.8.1(@typescript-eslint/parser@7.6.0)(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0) - eslint-plugin-import: 2.29.1(@typescript-eslint/parser@7.6.0)(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0) + eslint-module-utils: 2.8.1(@typescript-eslint/parser@7.8.0)(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0) + eslint-plugin-import: 2.29.1(@typescript-eslint/parser@7.8.0)(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0) fast-glob: 3.3.2 get-tsconfig: 4.7.3 is-core-module: 2.13.1 @@ -2511,7 +2494,7 @@ packages: - supports-color dev: true - /eslint-module-utils@2.8.1(@typescript-eslint/parser@7.6.0)(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0): + /eslint-module-utils@2.8.1(@typescript-eslint/parser@7.8.0)(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0): resolution: { integrity: sha512-rXDXR3h7cs7dy9RNpUlQf80nX31XWJEyGq1tRMo+6GsO5VmTe4UTwtmonAD4ZkAsrfMVDA2wlGJ3790Ys+D49Q==, @@ -2535,11 +2518,11 @@ packages: eslint-import-resolver-webpack: optional: true dependencies: - "@typescript-eslint/parser": 7.6.0(eslint@8.57.0)(typescript@5.4.5) + "@typescript-eslint/parser": 7.8.0(eslint@8.57.0)(typescript@5.4.5) debug: 3.2.7 eslint: 8.57.0 eslint-import-resolver-node: 0.3.9 - eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/parser@7.6.0)(eslint-plugin-import@2.29.1)(eslint@8.57.0) + eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/parser@7.8.0)(eslint-plugin-import@2.29.1)(eslint@8.57.0) transitivePeerDependencies: - supports-color dev: true @@ -2595,8 +2578,8 @@ packages: eslint: ^8.0.1 dependencies: "@github/browserslist-config": 1.0.0 - "@typescript-eslint/eslint-plugin": 7.6.0(@typescript-eslint/parser@7.6.0)(eslint@8.57.0)(typescript@5.4.5) - "@typescript-eslint/parser": 7.6.0(eslint@8.57.0)(typescript@5.4.5) + "@typescript-eslint/eslint-plugin": 7.8.0(@typescript-eslint/parser@7.8.0)(eslint@8.57.0)(typescript@5.4.5) + "@typescript-eslint/parser": 7.8.0(eslint@8.57.0)(typescript@5.4.5) aria-query: 5.3.0 eslint: 8.57.0 eslint-config-prettier: 9.1.0(eslint@8.57.0) @@ -2604,7 +2587,7 @@ packages: eslint-plugin-eslint-comments: 3.2.0(eslint@8.57.0) eslint-plugin-filenames: 1.3.2(eslint@8.57.0) eslint-plugin-i18n-text: 1.0.1(eslint@8.57.0) - eslint-plugin-import: 2.29.1(@typescript-eslint/parser@7.6.0)(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0) + eslint-plugin-import: 2.29.1(@typescript-eslint/parser@7.8.0)(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0) eslint-plugin-jsx-a11y: 6.8.0(eslint@8.57.0) eslint-plugin-no-only-tests: 3.1.0 eslint-plugin-prettier: 5.1.3(eslint-config-prettier@9.1.0)(eslint@8.57.0)(prettier@3.2.5) @@ -2631,7 +2614,7 @@ packages: eslint: 8.57.0 dev: true - /eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.6.0)(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0): + /eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.8.0)(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0): resolution: { integrity: sha512-BbPC0cuExzhiMo4Ff1BTVwHpjjv28C5R+btTOGaCRC7UEz801up0JadwkeSk5Ued6TG34uaczuVuH6qyy5YUxw==, @@ -2644,7 +2627,7 @@ packages: "@typescript-eslint/parser": optional: true dependencies: - "@typescript-eslint/parser": 7.6.0(eslint@8.57.0)(typescript@5.4.5) + "@typescript-eslint/parser": 7.8.0(eslint@8.57.0)(typescript@5.4.5) array-includes: 3.1.8 array.prototype.findlastindex: 1.2.5 array.prototype.flat: 1.3.2 @@ -2653,7 +2636,7 @@ packages: doctrine: 2.1.0 eslint: 8.57.0 eslint-import-resolver-node: 0.3.9 - eslint-module-utils: 2.8.1(@typescript-eslint/parser@7.6.0)(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0) + eslint-module-utils: 2.8.1(@typescript-eslint/parser@7.8.0)(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0) hasown: 2.0.2 is-core-module: 2.13.1 is-glob: 4.0.3 @@ -2678,7 +2661,7 @@ packages: peerDependencies: eslint: ^3 || ^4 || ^5 || ^6 || ^7 || ^8 dependencies: - "@babel/runtime": 7.24.4 + "@babel/runtime": 7.24.5 aria-query: 5.3.0 array-includes: 3.1.8 array.prototype.flatmap: 1.3.2 @@ -2687,7 +2670,7 @@ packages: axobject-query: 3.2.1 damerau-levenshtein: 1.0.8 emoji-regex: 9.2.2 - es-iterator-helpers: 1.0.18 + es-iterator-helpers: 1.0.19 eslint: 8.57.0 hasown: 2.0.2 jsx-ast-utils: 3.3.5 @@ -2799,7 +2782,7 @@ packages: lodash.merge: 4.6.2 minimatch: 3.1.2 natural-compare: 1.4.0 - optionator: 0.9.3 + optionator: 0.9.4 strip-ansi: 6.0.1 text-table: 0.2.0 transitivePeerDependencies: @@ -2939,13 +2922,6 @@ packages: reusify: 1.0.4 dev: true - /fetch-retry@5.0.6: - resolution: - { - integrity: sha512-3yurQZ2hD9VISAhJJP9bpYFNQrHHBXE2JxxjY5aLEcDi46RmAzJE2OC9FAde0yis5ElW0jTTzs0zfg/Cca4XqQ==, - } - dev: false - /file-entry-cache@6.0.1: resolution: { @@ -3210,14 +3186,15 @@ packages: type-fest: 0.20.2 dev: true - /globalthis@1.0.3: + /globalthis@1.0.4: resolution: { - integrity: sha512-sFdI5LyBiNTHjRd7cGPWapiHWMOXKyuBNX/cWJ3NfzrZQVa8GI/8cofCl74AOVqq9W5kNmguTIzJ/1s2gyI9wA==, + integrity: sha512-DpLKbNU4WylpxJykQujfCcwYWiV/Jhm50Goo0wrVILAv5jOr9d+H+UR3PhSCD2rCCEIg0uc+G+muBTwD54JhDQ==, } engines: { node: ">= 0.4" } dependencies: define-properties: 1.2.1 + gopd: 1.0.1 dev: true /globby@11.1.0: @@ -3251,7 +3228,7 @@ packages: } engines: { node: ">=20" } dependencies: - "@sindresorhus/is": 6.2.0 + "@sindresorhus/is": 6.3.0 "@szmarczak/http-timer": 5.0.1 cacheable-lookup: 7.0.0 cacheable-request: 10.2.14 @@ -3955,10 +3932,10 @@ packages: engines: { node: ^12.20.0 || ^14.13.1 || >=16.0.0 } dev: false - /lru-cache@10.2.0: + /lru-cache@10.2.2: resolution: { - integrity: sha512-2bIM8x+VAf6JT4bKAljS1qUWgMsqZRPGJS6FSahIMPVvctcNhyVp7AJu7quxOW9jwkryBReKZY5tY5JYv2n/7Q==, + integrity: sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ==, } engines: { node: 14 || >=16.14 } dev: true @@ -4257,19 +4234,19 @@ packages: mimic-fn: 2.1.0 dev: true - /optionator@0.9.3: + /optionator@0.9.4: resolution: { - integrity: sha512-JjCoypp+jKn1ttEFExxhetCKeJt9zhAgAve5FXHixTvFDW/5aEktX9bufBKLRRMdU7bNtpLfcGu94B3cdEJgjg==, + integrity: sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==, } engines: { node: ">= 0.8.0" } dependencies: - "@aashutoshrathi/word-wrap": 1.2.6 deep-is: 0.1.4 fast-levenshtein: 2.0.6 levn: 0.4.1 prelude-ls: 1.2.1 type-check: 0.4.0 + word-wrap: 1.2.5 dev: true /p-cancelable@4.0.1: @@ -4348,7 +4325,7 @@ packages: } engines: { node: ">=16 || 14 >=14.17" } dependencies: - lru-cache: 10.2.0 + lru-cache: 10.2.2 minipass: 7.0.4 dev: true @@ -4407,7 +4384,7 @@ packages: optional: true dependencies: lilconfig: 3.1.1 - yaml: 2.4.1 + yaml: 2.4.2 dev: true /prelude-ls@1.2.1: @@ -4490,7 +4467,7 @@ packages: es-abstract: 1.23.3 es-errors: 1.3.0 get-intrinsic: 1.2.4 - globalthis: 1.0.3 + globalthis: 1.0.4 which-builtin-type: 1.1.3 dev: true @@ -4584,31 +4561,32 @@ packages: glob: 7.2.3 dev: true - /rollup@4.14.1: + /rollup@4.17.2: resolution: { - integrity: sha512-4LnHSdd3QK2pa1J6dFbfm1HN0D7vSK/ZuZTsdyUAlA6Rr1yTouUTL13HaDOGJVgby461AhrNGBS7sCGXXtT+SA==, + integrity: sha512-/9ClTJPByC0U4zNLowV1tMBe8yMEAxewtR3cUNX5BoEpGH3dQEWpJLr6CLp0fPdYRF/fzVOgvDb1zXuakwF5kQ==, } engines: { node: ">=18.0.0", npm: ">=8.0.0" } hasBin: true dependencies: "@types/estree": 1.0.5 optionalDependencies: - "@rollup/rollup-android-arm-eabi": 4.14.1 - "@rollup/rollup-android-arm64": 4.14.1 - "@rollup/rollup-darwin-arm64": 4.14.1 - "@rollup/rollup-darwin-x64": 4.14.1 - "@rollup/rollup-linux-arm-gnueabihf": 4.14.1 - "@rollup/rollup-linux-arm64-gnu": 4.14.1 - "@rollup/rollup-linux-arm64-musl": 4.14.1 - "@rollup/rollup-linux-powerpc64le-gnu": 4.14.1 - "@rollup/rollup-linux-riscv64-gnu": 4.14.1 - "@rollup/rollup-linux-s390x-gnu": 4.14.1 - "@rollup/rollup-linux-x64-gnu": 4.14.1 - "@rollup/rollup-linux-x64-musl": 4.14.1 - "@rollup/rollup-win32-arm64-msvc": 4.14.1 - "@rollup/rollup-win32-ia32-msvc": 4.14.1 - "@rollup/rollup-win32-x64-msvc": 4.14.1 + "@rollup/rollup-android-arm-eabi": 4.17.2 + "@rollup/rollup-android-arm64": 4.17.2 + "@rollup/rollup-darwin-arm64": 4.17.2 + "@rollup/rollup-darwin-x64": 4.17.2 + "@rollup/rollup-linux-arm-gnueabihf": 4.17.2 + "@rollup/rollup-linux-arm-musleabihf": 4.17.2 + "@rollup/rollup-linux-arm64-gnu": 4.17.2 + "@rollup/rollup-linux-arm64-musl": 4.17.2 + "@rollup/rollup-linux-powerpc64le-gnu": 4.17.2 + "@rollup/rollup-linux-riscv64-gnu": 4.17.2 + "@rollup/rollup-linux-s390x-gnu": 4.17.2 + "@rollup/rollup-linux-x64-gnu": 4.17.2 + "@rollup/rollup-linux-x64-musl": 4.17.2 + "@rollup/rollup-win32-arm64-msvc": 4.17.2 + "@rollup/rollup-win32-ia32-msvc": 4.17.2 + "@rollup/rollup-win32-x64-msvc": 4.17.2 fsevents: 2.3.3 dev: true @@ -5088,7 +5066,7 @@ packages: typescript: optional: true dependencies: - bundle-require: 4.0.2(esbuild@0.19.12) + bundle-require: 4.1.0(esbuild@0.19.12) cac: 6.7.14 chokidar: 3.6.0 debug: 4.3.4 @@ -5098,7 +5076,7 @@ packages: joycon: 3.1.1 postcss-load-config: 4.0.2 resolve-from: 5.0.0 - rollup: 4.14.1 + rollup: 4.17.2 source-map: 0.8.0-beta.0 sucrase: 3.35.0 tree-kill: 1.2.2 @@ -5234,10 +5212,10 @@ packages: } dev: false - /update-browserslist-db@1.0.13(browserslist@4.23.0): + /update-browserslist-db@1.0.14(browserslist@4.23.0): resolution: { - integrity: sha512-xebP81SNcPuNpPP3uzeW1NYXxI3rxyJzF3pD6sH4jE7o/IX+WtSpwnVU+qIsDPyk0d3hmFQ7mjqc6AtV604hbg==, + integrity: sha512-JixKH8GR2pWYshIPUg/NujK3JO7JiqEEUiNArE86NQyrgUuZeTlZQN3xuS/yiV5Kb48ev9K6RqNkaJjXsdg7Jw==, } hasBin: true peerDependencies: @@ -5274,14 +5252,6 @@ packages: hasBin: true dev: false - /uuid@9.0.1: - resolution: - { - integrity: sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==, - } - hasBin: true - dev: false - /webidl-conversions@3.0.1: resolution: { @@ -5389,6 +5359,14 @@ packages: isexe: 2.0.0 dev: true + /word-wrap@1.2.5: + resolution: + { + integrity: sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==, + } + engines: { node: ">=0.10.0" } + dev: true + /wrap-ansi@7.0.0: resolution: { @@ -5445,10 +5423,10 @@ packages: } dev: true - /yaml@2.4.1: + /yaml@2.4.2: resolution: { - integrity: sha512-pIXzoImaqmfOrL7teGUBt/T7ZDnyeGBWyXQBvOVhLkWLN37GXv8NMLK406UY6dS51JfcQHsmcW5cJ441bHg6Lg==, + integrity: sha512-B3VqDZ+JAg1nZpaEmWtTXUlBneoGx6CPM9b0TENK6aoSu5t73dItudwdgmi6tHlIZZId4dZ9skcAQ2UbcyAeVA==, } engines: { node: ">= 14" } hasBin: true @@ -5462,10 +5440,10 @@ packages: engines: { node: ">=10" } dev: true - github.com/DeterminateSystems/detsys-ts/3a315cdffd83d4b229d4fb16548d22a3756baf28: + github.com/DeterminateSystems/detsys-ts/cd38b227c4d6faca10aed591b1f8863ef7b93dce: resolution: { - tarball: https://codeload.github.com/DeterminateSystems/detsys-ts/tar.gz/3a315cdffd83d4b229d4fb16548d22a3756baf28, + tarball: https://codeload.github.com/DeterminateSystems/detsys-ts/tar.gz/cd38b227c4d6faca10aed591b1f8863ef7b93dce, } name: detsys-ts version: 1.0.0 @@ -5473,11 +5451,7 @@ packages: "@actions/cache": 3.2.4 "@actions/core": 1.10.1 "@actions/exec": 1.1.1 - "@actions/github": 5.1.1 - fetch-retry: 5.0.6 got: 14.2.1 - string-argv: 0.3.2 - uuid: 9.0.1 transitivePeerDependencies: - encoding dev: false diff --git a/src/main.ts b/src/main.ts index 20ce6d3..5b8a326 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,105 +1,124 @@ -import * as actions_core from "@actions/core"; +import * as actionsCore from "@actions/core"; import * as github from "@actions/github"; -import * as actions_exec from "@actions/exec"; +import * as actionsExec from "@actions/exec"; import { access, writeFile, readFile } from "node:fs/promises"; import { join } from "node:path"; import fs from "node:fs"; import { userInfo } from "node:os"; import stringArgv from "string-argv"; import * as path from "path"; -import { IdsToolbox } from "detsys-ts"; +import { IdsToolbox, inputs, platform } from "detsys-ts"; import { randomUUID } from "node:crypto"; +// Nix installation events +const EVENT_INSTALL_NIX_FAILURE = "install_nix_failure"; +const EVENT_INSTALL_NIX_START = "install_nix_start"; +const EVENT_INSTALL_NIX_SUCCESS = "install_nix_start"; +const EVENT_SETUP_KVM = "setup_kvm"; +const EVENT_UNINSTALL_NIX = "uninstall"; + +// Docker events +const EVENT_CLEAN_UP_DOCKER_SHIM = "clean_up_docker_shim"; +const EVENT_START_DOCKER_SHIM = "start_docker_shim"; + +// FlakeHub events +const EVENT_LOGIN_TO_FLAKEHUB = "login_to_flakehub"; + +// Other events +const EVENT_CONCLUDE_WORKFLOW = "conclude_workflow"; + +// Facts +const FACT_HAS_DOCKER = "has_docker"; +const FACT_HAS_SYSTEMD = "has_systemd"; +const FACT_IN_GITHUB_ACTIONS = "in_act"; +const FACT_IN_NAMESPACE_SO = "in_namespace_so"; +const FACT_NIX_INSTALLER_PLANNER = "nix_installer_planner"; + class NixInstallerAction { idslib: IdsToolbox; platform: string; - nix_package_url: string | null; + nixPackageUrl: string | null; backtrace: string | null; - extra_args: string | null; - extra_conf: string[] | null; + extraArgs: string | null; + extraConf: string[] | null; flakehub: boolean; kvm: boolean; - github_server_url: string | null; - github_token: string | null; - force_docker_shim: boolean | null; + githubServerUrl: string | null; + githubToken: string | null; + forceDockerShim: boolean | null; init: string | null; - local_root: string | null; - log_directives: string | null; + localRoot: string | null; + logDirectives: string | null; logger: string | null; - ssl_cert_file: string | null; + sslCertFile: string | null; proxy: string | null; - mac_case_sensitive: string | null; - mac_encrypt: string | null; - mac_root_disk: string | null; - mac_volume_label: string | null; - modify_profile: boolean; - nix_build_group_id: number | null; - nix_build_group_name: string | null; - nix_build_user_base: number | null; - nix_build_user_count: number | null; - nix_build_user_prefix: string | null; + macCaseSensitive: string | null; + macEncrypt: string | null; + macRootDisk: string | null; + macVolumeLabel: string | null; + modifyProfile: boolean; + nixBuildGroupId: number | null; + nixBuildGroupName: string | null; + nixBuildUserBase: number | null; + nixBuildUserCount: number | null; + nixBuildUserPrefix: string | null; planner: string | null; reinstall: boolean; - start_daemon: boolean; - trust_runner_user: boolean | null; + startDaemon: boolean; + trustRunnerUser: boolean | null; constructor() { this.idslib = new IdsToolbox({ name: "nix-installer", fetchStyle: "nix-style", legacySourcePrefix: "nix-installer", + requireNix: "ignore", }); - this.platform = get_nix_platform(); - this.nix_package_url = action_input_string_or_null("nix-package-url"); - this.backtrace = action_input_string_or_null("backtrace"); - this.extra_args = action_input_string_or_null("extra-args"); - this.extra_conf = action_input_multiline_string_or_null("extra-conf"); - this.flakehub = action_input_bool("flakehub"); - this.kvm = action_input_bool("kvm"); - this.force_docker_shim = action_input_bool("force-docker-shim"); - this.github_token = action_input_string_or_null("github-token"); - this.github_server_url = action_input_string_or_null("github-server-url"); - this.init = action_input_string_or_null("init"); - this.local_root = action_input_string_or_null("local-root"); - this.log_directives = action_input_string_or_null("log-directives"); - this.logger = action_input_string_or_null("logger"); - this.ssl_cert_file = action_input_string_or_null("ssl-cert-file"); - this.proxy = action_input_string_or_null("proxy"); - this.mac_case_sensitive = action_input_string_or_null("mac-case-sensitive"); - this.mac_encrypt = action_input_string_or_null("mac-encrypt"); - this.mac_root_disk = action_input_string_or_null("mac-root-disk"); - this.mac_volume_label = action_input_string_or_null("mac-volume-label"); - this.modify_profile = action_input_bool("modify-profile"); - this.nix_build_group_id = action_input_number_or_null("nix-build-group-id"); - this.nix_build_group_name = action_input_string_or_null( - "nix-build-group-name", - ); - this.nix_build_user_base = action_input_number_or_null( - "nix_build-user-base", - ); - this.nix_build_user_count = action_input_number_or_null( - "nix-build-user-count", - ); - this.nix_build_user_prefix = action_input_string_or_null( - "nix-build-user-prefix", - ); - this.planner = action_input_string_or_null("planner"); - this.reinstall = action_input_bool("reinstall"); - this.start_daemon = action_input_bool("start-daemon"); - this.trust_runner_user = action_input_bool("trust-runner-user"); + this.platform = platform.getNixPlatform(platform.getArchOs()); + this.nixPackageUrl = inputs.getStringOrNull("nix-package-url"); + this.backtrace = inputs.getStringOrNull("backtrace"); + this.extraArgs = inputs.getStringOrNull("extra-args"); + this.extraConf = inputs.getMultilineStringOrNull("extra-conf"); + this.flakehub = inputs.getBool("flakehub"); + this.kvm = inputs.getBool("kvm"); + this.forceDockerShim = inputs.getBool("force-docker-shim"); + this.githubToken = inputs.getStringOrNull("github-token"); + this.githubServerUrl = inputs.getStringOrNull("github-server-url"); + this.init = inputs.getStringOrNull("init"); + this.localRoot = inputs.getStringOrNull("local-root"); + this.logDirectives = inputs.getStringOrNull("log-directives"); + this.logger = inputs.getStringOrNull("logger"); + this.sslCertFile = inputs.getStringOrNull("ssl-cert-file"); + this.proxy = inputs.getStringOrNull("proxy"); + this.macCaseSensitive = inputs.getStringOrNull("mac-case-sensitive"); + this.macEncrypt = inputs.getStringOrNull("mac-encrypt"); + this.macRootDisk = inputs.getStringOrNull("mac-root-disk"); + this.macVolumeLabel = inputs.getStringOrNull("mac-volume-label"); + this.modifyProfile = inputs.getBool("modify-profile"); + this.nixBuildGroupId = inputs.getNumberOrNull("nix-build-group-id"); + this.nixBuildGroupName = inputs.getStringOrNull("nix-build-group-name"); + this.nixBuildUserBase = inputs.getNumberOrNull("nix-build-user-base"); + this.nixBuildUserCount = inputs.getNumberOrNull("nix-build-user-count"); + this.nixBuildUserPrefix = inputs.getStringOrNull("nix-build-user-prefix"); + this.planner = inputs.getStringOrNull("planner"); + this.reinstall = inputs.getBool("reinstall"); + this.startDaemon = inputs.getBool("start-daemon"); + this.trustRunnerUser = inputs.getBool("trust-runner-user"); } async detectAndForceDockerShim(): Promise { + const runnerOs = process.env["RUNNER_OS"]; + // Detect if we're in a GHA runner which is Linux, doesn't have Systemd, and does have Docker. // This is a common case in self-hosted runners, providers like [Namespace](https://namespace.so/), // and especially GitHub Enterprise Server. - if (process.env.RUNNER_OS !== "Linux") { - if (this.force_docker_shim) { - actions_core.warning( + if (runnerOs !== "Linux") { + if (this.forceDockerShim) { + actionsCore.warning( "Ignoring force-docker-shim which is set to true, as it is only supported on Linux.", ); - this.force_docker_shim = false; + this.forceDockerShim = false; } return; } @@ -108,83 +127,83 @@ class NixInstallerAction { throwIfNoEntry: false, }); if (systemdCheck?.isDirectory()) { - if (this.force_docker_shim) { - actions_core.warning( + if (this.forceDockerShim) { + actionsCore.warning( "Systemd is detected, but ignoring it since force-docker-shim is enabled.", ); } else { - this.idslib.addFact("has_systemd", true); + this.idslib.addFact(FACT_HAS_SYSTEMD, true); return; } } - this.idslib.addFact("has_systemd", false); + this.idslib.addFact(FACT_HAS_SYSTEMD, false); - actions_core.debug( + actionsCore.debug( "Linux detected without systemd, testing for Docker with `docker info` as an alternative daemon supervisor.", ); - this.idslib.addFact("has_docker", false); // Set to false here, and only in the success case do we set it to true - let exit_code; + this.idslib.addFact(FACT_HAS_DOCKER, false); // Set to false here, and only in the success case do we set it to true + let exitCode; try { - exit_code = await actions_exec.exec("docker", ["info"], { + exitCode = await actionsExec.exec("docker", ["info"], { silent: true, listeners: { stdout: (data: Buffer) => { const trimmed = data.toString("utf-8").trimEnd(); if (trimmed.length >= 0) { - actions_core.debug(trimmed); + actionsCore.debug(trimmed); } }, stderr: (data: Buffer) => { const trimmed = data.toString("utf-8").trimEnd(); if (trimmed.length >= 0) { - actions_core.debug(trimmed); + actionsCore.debug(trimmed); } }, }, }); - } catch (e) { - actions_core.debug("Docker not detected, not enabling docker shim."); + } catch { + actionsCore.debug("Docker not detected, not enabling docker shim."); return; } - if (exit_code !== 0) { - if (this.force_docker_shim) { - actions_core.warning( + if (exitCode !== 0) { + if (this.forceDockerShim) { + actionsCore.warning( "docker info check failed, but trying anyway since force-docker-shim is enabled.", ); } else { return; } } - this.idslib.addFact("has_docker", true); + this.idslib.addFact(FACT_HAS_DOCKER, true); if ( - !this.force_docker_shim && + !this.forceDockerShim && (await this.detectDockerWithMountedDockerSocket()) ) { - actions_core.debug( + actionsCore.debug( "Detected a Docker container with a Docker socket mounted, not enabling docker shim.", ); return; } - actions_core.startGroup( + actionsCore.startGroup( "Enabling the Docker shim for running Nix on Linux in CI without Systemd.", ); if (this.init !== "none") { - actions_core.info(`Changing init from '${this.init}' to 'none'`); + actionsCore.info(`Changing init from '${this.init}' to 'none'`); this.init = "none"; } if (this.planner !== "linux") { - actions_core.info(`Changing planner from '${this.planner}' to 'linux'`); + actionsCore.info(`Changing planner from '${this.planner}' to 'linux'`); this.planner = "linux"; } - this.force_docker_shim = true; + this.forceDockerShim = true; - actions_core.endGroup(); + actionsCore.endGroup(); } // Detect if we are running under `act` or some other system which is not using docker-in-docker, @@ -192,74 +211,73 @@ class NixInstallerAction { // In the case of the socket mount solution, the shim will cause issues since the given mount paths will // equate to mount paths on the host, not mount paths to the docker container in question. async detectDockerWithMountedDockerSocket(): Promise { - let cgroups_buffer; + let cgroupsBuffer; try { // If we are inside a docker container, the last line of `/proc/self/cgroup` should be // 0::/docker/$SOME_ID // // If we are not, the line will likely be `0::/` - cgroups_buffer = await readFile("/proc/self/cgroup", { + cgroupsBuffer = await readFile("/proc/self/cgroup", { encoding: "utf-8", }); } catch (e) { - actions_core.debug( + actionsCore.debug( `Did not detect \`/proc/self/cgroup\` existence, bailing on docker container ID detection:\n${e}`, ); return false; } - const cgroups = cgroups_buffer.trim().split("\n"); - const last_cgroup = cgroups[cgroups.length - 1]; - const last_cgroup_parts = last_cgroup.split(":"); - const last_cgroup_path = last_cgroup_parts[last_cgroup_parts.length - 1]; - if (!last_cgroup_path.includes("/docker/")) { - actions_core.debug( + const cgroups = cgroupsBuffer.trim().split("\n"); + const lastCgroup = cgroups[cgroups.length - 1]; + const lastCgroupParts = lastCgroup.split(":"); + const lastCgroupPath = lastCgroupParts[lastCgroupParts.length - 1]; + if (!lastCgroupPath.includes("/docker/")) { + actionsCore.debug( "Did not detect a container ID, bailing on docker.sock detection", ); return false; } // We are in a docker container, now to determine if this container is visible from // the `docker` command, and if so, if there is a `docker.socket` mounted. - const last_cgroup_path_parts = last_cgroup_path.split("/"); - const container_id = - last_cgroup_path_parts[last_cgroup_path_parts.length - 1]; + const lastCgroupPathParts = lastCgroupPath.split("/"); + const containerId = lastCgroupPathParts[lastCgroupPathParts.length - 1]; // If we cannot `docker inspect` this discovered container ID, we'll fall through to the `catch` below. - let stdout_buffer = ""; - let stderr_buffer = ""; - let exit_code; + let stdoutBuffer = ""; + let stderrBuffer = ""; + let exitCode; try { - exit_code = await actions_exec.exec("docker", ["inspect", container_id], { + exitCode = await actionsExec.exec("docker", ["inspect", containerId], { silent: true, listeners: { stdout: (data: Buffer) => { - stdout_buffer += data.toString("utf-8"); + stdoutBuffer += data.toString("utf-8"); }, stderr: (data: Buffer) => { - stderr_buffer += data.toString("utf-8"); + stderrBuffer += data.toString("utf-8"); }, }, }); } catch (e) { - actions_core.debug( - `Could not execute \`docker inspect ${container_id}\`, bailing on docker container inspection:\n${e}`, + actionsCore.debug( + `Could not execute \`docker inspect ${containerId}\`, bailing on docker container inspection:\n${e}`, ); return false; } - if (exit_code !== 0) { - actions_core.debug( - `Unable to inspect detected docker container with id \`${container_id}\`, bailing on container inspection (exit ${exit_code}):\n${stderr_buffer}`, + if (exitCode !== 0) { + actionsCore.debug( + `Unable to inspect detected docker container with id \`${containerId}\`, bailing on container inspection (exit ${exitCode}):\n${stderrBuffer}`, ); return false; } - const output = JSON.parse(stdout_buffer); + const output = JSON.parse(stdoutBuffer); // `docker inspect $ID` prints an array containing objects. // In our use case, we should only see 1 item in the array. if (output.length !== 1) { - actions_core.debug( - `Got \`docker inspect ${container_id}\` output which was not one item (was ${output.length}), bailing on docker.sock detection.`, + actionsCore.debug( + `Got \`docker inspect ${containerId}\` output which was not one item (was ${output.length}), bailing on docker.sock detection.`, ); return false; } @@ -269,276 +287,274 @@ class NixInstallerAction { // We are looking for a `Destination` ending with `docker.sock`. const mounts = item["Mounts"]; if (typeof mounts !== "object") { - actions_core.debug( - `Got non-object in \`Mounts\` field of \`docker inspect ${container_id}\` output, bailing on docker.sock detection.`, + actionsCore.debug( + `Got non-object in \`Mounts\` field of \`docker inspect ${containerId}\` output, bailing on docker.sock detection.`, ); return false; } - let found_docker_sock_mount = false; + let foundDockerSockMount = false; for (const mount of mounts) { const destination = mount["Destination"]; if (typeof destination === "string") { if (destination.endsWith("docker.sock")) { - found_docker_sock_mount = true; + foundDockerSockMount = true; break; } } } - return found_docker_sock_mount; + return foundDockerSockMount; } private async executionEnvironment(): Promise { - const execution_env: ExecuteEnvironment = {}; + const executionEnv: ExecuteEnvironment = {}; + const runnerOs = process.env["RUNNER_OS"]; - execution_env.NIX_INSTALLER_NO_CONFIRM = "true"; - execution_env.NIX_INSTALLER_DIAGNOSTIC_ATTRIBUTION = JSON.stringify( + executionEnv.NIX_INSTALLER_NO_CONFIRM = "true"; + executionEnv.NIX_INSTALLER_DIAGNOSTIC_ATTRIBUTION = JSON.stringify( this.idslib.getCorrelationHashes(), ); if (this.backtrace !== null) { - execution_env.RUST_BACKTRACE = this.backtrace; + executionEnv.RUST_BACKTRACE = this.backtrace; } - if (this.modify_profile !== null) { - if (this.modify_profile) { - execution_env.NIX_INSTALLER_MODIFY_PROFILE = "true"; + if (this.modifyProfile !== null) { + if (this.modifyProfile) { + executionEnv.NIX_INSTALLER_MODIFY_PROFILE = "true"; } else { - execution_env.NIX_INSTALLER_MODIFY_PROFILE = "false"; + executionEnv.NIX_INSTALLER_MODIFY_PROFILE = "false"; } } - if (this.nix_build_group_id !== null) { - execution_env.NIX_INSTALLER_NIX_BUILD_GROUP_ID = `${this.nix_build_group_id}`; + if (this.nixBuildGroupId !== null) { + executionEnv.NIX_INSTALLER_NIX_BUILD_GROUP_ID = `${this.nixBuildGroupId}`; } - if (this.nix_build_group_name !== null) { - execution_env.NIX_INSTALLER_NIX_BUILD_GROUP_NAME = - this.nix_build_group_name; + if (this.nixBuildGroupName !== null) { + executionEnv.NIX_INSTALLER_NIX_BUILD_GROUP_NAME = this.nixBuildGroupName; } - if (this.nix_build_user_prefix !== null) { - execution_env.NIX_INSTALLER_NIX_BUILD_USER_PREFIX = - this.nix_build_user_prefix; + if (this.nixBuildUserPrefix !== null) { + executionEnv.NIX_INSTALLER_NIX_BUILD_USER_PREFIX = + this.nixBuildUserPrefix; } - if (this.nix_build_user_count !== null) { - execution_env.NIX_INSTALLER_NIX_BUILD_USER_COUNT = `${this.nix_build_user_count}`; + if (this.nixBuildUserCount !== null) { + executionEnv.NIX_INSTALLER_NIX_BUILD_USER_COUNT = `${this.nixBuildUserCount}`; } - if (this.nix_build_user_base !== null) { - execution_env.NIX_INSTALLER_NIX_BUILD_USER_ID_BASE = `${this.nix_build_user_count}`; + if (this.nixBuildUserBase !== null) { + executionEnv.NIX_INSTALLER_NIX_BUILD_USER_ID_BASE = `${this.nixBuildUserCount}`; } - if (this.nix_package_url !== null) { - execution_env.NIX_INSTALLER_NIX_PACKAGE_URL = `${this.nix_package_url}`; + if (this.nixPackageUrl !== null) { + executionEnv.NIX_INSTALLER_NIX_PACKAGE_URL = `${this.nixPackageUrl}`; } if (this.proxy !== null) { - execution_env.NIX_INSTALLER_PROXY = this.proxy; + executionEnv.NIX_INSTALLER_PROXY = this.proxy; } - if (this.ssl_cert_file !== null) { - execution_env.NIX_INSTALLER_SSL_CERT_FILE = this.ssl_cert_file; + if (this.sslCertFile !== null) { + executionEnv.NIX_INSTALLER_SSL_CERT_FILE = this.sslCertFile; } - execution_env.NIX_INSTALLER_DIAGNOSTIC_ENDPOINT = - this.idslib.getDiagnosticsUrl()?.toString() || ""; + executionEnv.NIX_INSTALLER_DIAGNOSTIC_ENDPOINT = + this.idslib.getDiagnosticsUrl()?.toString() ?? ""; // TODO: Error if the user uses these on not-MacOS - if (this.mac_encrypt !== null) { - if (process.env.RUNNER_OS !== "macOS") { + if (this.macEncrypt !== null) { + if (runnerOs !== "macOS") { throw new Error("`mac-encrypt` while `$RUNNER_OS` was not `macOS`"); } - execution_env.NIX_INSTALLER_ENCRYPT = this.mac_encrypt; + executionEnv.NIX_INSTALLER_ENCRYPT = this.macEncrypt; } - if (this.mac_case_sensitive !== null) { - if (process.env.RUNNER_OS !== "macOS") { + if (this.macCaseSensitive !== null) { + if (runnerOs !== "macOS") { throw new Error( "`mac-case-sensitive` while `$RUNNER_OS` was not `macOS`", ); } - execution_env.NIX_INSTALLER_CASE_SENSITIVE = this.mac_case_sensitive; + executionEnv.NIX_INSTALLER_CASE_SENSITIVE = this.macCaseSensitive; } - if (this.mac_volume_label !== null) { - if (process.env.RUNNER_OS !== "macOS") { + if (this.macVolumeLabel !== null) { + if (runnerOs !== "macOS") { throw new Error( "`mac-volume-label` while `$RUNNER_OS` was not `macOS`", ); } - execution_env.NIX_INSTALLER_VOLUME_LABEL = this.mac_volume_label; + executionEnv.NIX_INSTALLER_VOLUME_LABEL = this.macVolumeLabel; } - if (this.mac_root_disk !== null) { - if (process.env.RUNNER_OS !== "macOS") { + if (this.macRootDisk !== null) { + if (runnerOs !== "macOS") { throw new Error("`mac-root-disk` while `$RUNNER_OS` was not `macOS`"); } - execution_env.NIX_INSTALLER_ROOT_DISK = this.mac_root_disk; + executionEnv.NIX_INSTALLER_ROOT_DISK = this.macRootDisk; } if (this.logger !== null) { - execution_env.NIX_INSTALLER_LOGGER = this.logger; + executionEnv.NIX_INSTALLER_LOGGER = this.logger; } - if (this.log_directives !== null) { - execution_env.NIX_INSTALLER_LOG_DIRECTIVES = this.log_directives; + if (this.logDirectives !== null) { + executionEnv.NIX_INSTALLER_LOG_DIRECTIVES = this.logDirectives; } // TODO: Error if the user uses these on MacOS if (this.init !== null) { - if (process.env.RUNNER_OS === "macOS") { + if (runnerOs === "macOS") { throw new Error( "`init` is not a valid option when `$RUNNER_OS` is `macOS`", ); } - execution_env.NIX_INSTALLER_INIT = this.init; + executionEnv.NIX_INSTALLER_INIT = this.init; } - if (this.start_daemon !== null) { - if (this.start_daemon) { - execution_env.NIX_INSTALLER_START_DAEMON = "true"; + if (this.startDaemon !== null) { + if (this.startDaemon) { + executionEnv.NIX_INSTALLER_START_DAEMON = "true"; } else { - execution_env.NIX_INSTALLER_START_DAEMON = "false"; + executionEnv.NIX_INSTALLER_START_DAEMON = "false"; } } - let extra_conf = ""; - if (this.github_server_url !== null && this.github_token !== null) { - const server_url = this.github_server_url.replace("https://", ""); - extra_conf += `access-tokens = ${server_url}=${this.github_token}`; - extra_conf += "\n"; + let extraConf = ""; + if (this.githubServerUrl !== null && this.githubToken !== null) { + const serverUrl = this.githubServerUrl.replace("https://", ""); + extraConf += `access-tokens = ${serverUrl}=${this.githubToken}`; + extraConf += "\n"; } - if (this.trust_runner_user !== null) { + if (this.trustRunnerUser !== null) { const user = userInfo().username; if (user) { - extra_conf += `trusted-users = root ${user}`; + extraConf += `trusted-users = root ${user}`; } else { - extra_conf += `trusted-users = root`; + extraConf += `trusted-users = root`; } - extra_conf += "\n"; + extraConf += "\n"; } if (this.flakehub) { try { - const flakehub_netrc_file = await this.flakehub_login(); - extra_conf += `netrc-file = ${flakehub_netrc_file}`; - extra_conf += "\n"; + const flakeHubNetrcFile = await this.flakehubLogin(); + extraConf += `netrc-file = ${flakeHubNetrcFile}`; + extraConf += "\n"; } catch (e) { - actions_core.warning(`Failed to setup FlakeHub: ${e}`); + actionsCore.warning(`Failed to set up FlakeHub: ${e}`); } } - if (this.extra_conf !== null && this.extra_conf.length !== 0) { - extra_conf += this.extra_conf.join("\n"); - extra_conf += "\n"; + if (this.extraConf !== null && this.extraConf.length !== 0) { + extraConf += this.extraConf.join("\n"); + extraConf += "\n"; } - execution_env.NIX_INSTALLER_EXTRA_CONF = extra_conf; + executionEnv.NIX_INSTALLER_EXTRA_CONF = extraConf; - if (process.env.ACT && !process.env.NOT_ACT) { - this.idslib.addFact("in_act", true); - actions_core.info( + if (process.env["ACT"] && !process.env["NOT_ACT"]) { + this.idslib.addFact(FACT_IN_GITHUB_ACTIONS, true); + actionsCore.info( "Detected `$ACT` environment, assuming this is a https://github.com/nektos/act created container, set `NOT_ACT=true` to override this. This will change the setting of the `init` to be compatible with `act`", ); - execution_env.NIX_INSTALLER_INIT = "none"; + executionEnv.NIX_INSTALLER_INIT = "none"; } - if (process.env.NSC_VM_ID && !process.env.NOT_NAMESPACE) { - this.idslib.addFact("in_namespace_so", true); - actions_core.info( + if (process.env["NSC_VM_ID"] && !process.env["NOT_NAMESPACE"]) { + this.idslib.addFact(FACT_IN_NAMESPACE_SO, true); + actionsCore.info( "Detected Namespace runner, assuming this is a https://namespace.so created container, set `NOT_NAMESPACE=true` to override this. This will change the setting of the `init` to be compatible with Namespace", ); - execution_env.NIX_INSTALLER_INIT = "none"; + executionEnv.NIX_INSTALLER_INIT = "none"; } - return execution_env; + return executionEnv; } - private async execute_install(binary_path: string): Promise { - const execution_env = await this.executionEnvironment(); - actions_core.debug( - `Execution environment: ${JSON.stringify(execution_env, null, 4)}`, + private async executeInstall(binaryPath: string): Promise { + const executionEnv = await this.executionEnvironment(); + actionsCore.debug( + `Execution environment: ${JSON.stringify(executionEnv, null, 4)}`, ); const args = ["install"]; if (this.planner) { - this.idslib.addFact("nix_installer_planner", this.planner); + this.idslib.addFact(FACT_NIX_INSTALLER_PLANNER, this.planner); args.push(this.planner); } else { - this.idslib.addFact("nix_installer_planner", get_default_planner()); - args.push(get_default_planner()); + this.idslib.addFact(FACT_NIX_INSTALLER_PLANNER, getDefaultPlanner()); + args.push(getDefaultPlanner()); } - if (this.extra_args) { - const extra_args = stringArgv(this.extra_args); - args.concat(extra_args); + if (this.extraArgs) { + const extraArgs = stringArgv(this.extraArgs); + args.concat(extraArgs); } - this.idslib.recordEvent("install_nix_start"); - const exit_code = await actions_exec.exec(binary_path, args, { + this.idslib.recordEvent(EVENT_INSTALL_NIX_START); + const exitCode = await actionsExec.exec(binaryPath, args, { env: { - ...execution_env, + ...executionEnv, ...process.env, // To get $PATH, etc }, }); - if (exit_code !== 0) { - this.idslib.recordEvent("install_nix_failure", { - exit_code, + if (exitCode !== 0) { + this.idslib.recordEvent(EVENT_INSTALL_NIX_FAILURE, { + exitCode, }); - throw new Error(`Non-zero exit code of \`${exit_code}\` detected`); + throw new Error(`Non-zero exit code of \`${exitCode}\` detected`); } - this.idslib.recordEvent("install_nix_success"); + this.idslib.recordEvent(EVENT_INSTALL_NIX_SUCCESS); - return exit_code; + return exitCode; } async install(): Promise { - const existing_install = await this.detect_existing(); - if (existing_install) { + const existingInstall = await this.detectExisting(); + if (existingInstall) { if (this.reinstall) { // We need to uninstall, then reinstall - actions_core.info( + actionsCore.info( "Nix was already installed, `reinstall` is set, uninstalling for a reinstall", ); - await this.execute_uninstall(); + await this.executeUninstall(); } else { // We're already installed, and not reinstalling, just set GITHUB_PATH and finish early - await this.set_github_path(); - actions_core.info("Nix was already installed, using existing install"); + await this.setGithubPath(); + actionsCore.info("Nix was already installed, using existing install"); return; } } if (this.kvm) { - actions_core.startGroup("Configuring KVM"); - if (await this.setup_kvm()) { - actions_core.endGroup(); - actions_core.info( - "\u001b[32m Accelerated KVM is enabled \u001b[33m⚡️", - ); - actions_core.exportVariable("DETERMINATE_NIX_KVM", "1"); + actionsCore.startGroup("Configuring KVM"); + if (await this.setupKvm()) { + actionsCore.endGroup(); + actionsCore.info("\u001b[32m Accelerated KVM is enabled \u001b[33m⚡️"); + actionsCore.exportVariable("DETERMINATE_NIX_KVM", "1"); } else { - actions_core.endGroup(); - actions_core.info("KVM is not available."); - actions_core.exportVariable("DETERMINATE_NIX_KVM", "0"); + actionsCore.endGroup(); + actionsCore.info("KVM is not available."); + actionsCore.exportVariable("DETERMINATE_NIX_KVM", "0"); } } // Normal just doing of the install - actions_core.startGroup("Installing Nix"); - const binary_path = await this.fetch_binary(); - await this.execute_install(binary_path); - actions_core.endGroup(); + actionsCore.startGroup("Installing Nix"); + const binaryPath = await this.fetchBinary(); + await this.executeInstall(binaryPath); + actionsCore.endGroup(); - if (this.force_docker_shim) { + if (this.forceDockerShim) { await this.spawnDockerShim(); } - await this.set_github_path(); + await this.setGithubPath(); } async spawnDockerShim(): Promise { - actions_core.startGroup( + actionsCore.startGroup( "Configuring the Docker shim as the Nix Daemon's process supervisor", ); @@ -547,17 +563,19 @@ class NixInstallerAction { ARM64: path.join(__dirname, "/../docker-shim/arm64.tar.gz"), }; + const runnerArch = process.env["RUNNER_ARCH"]; let arch; - if (process.env.RUNNER_ARCH === "X64") { + + if (runnerArch === "X64") { arch = "X64"; - } else if (process.env.RUNNER_ARCH === "ARM64") { + } else if (runnerArch === "ARM64") { arch = "ARM64"; } else { throw Error("Architecture not supported in Docker shim mode."); } - actions_core.debug("Loading image: determinate-nix-shim:latest..."); + actionsCore.debug("Loading image: determinate-nix-shim:latest..."); { - const exit_code = await actions_exec.exec( + const exitCode = await actionsExec.exec( "docker", ["image", "load", "--input", images[arch]], { @@ -566,30 +584,30 @@ class NixInstallerAction { stdout: (data: Buffer) => { const trimmed = data.toString("utf-8").trimEnd(); if (trimmed.length >= 0) { - actions_core.debug(trimmed); + actionsCore.debug(trimmed); } }, stderr: (data: Buffer) => { const trimmed = data.toString("utf-8").trimEnd(); if (trimmed.length >= 0) { - actions_core.debug(trimmed); + actionsCore.debug(trimmed); } }, }, }, ); - if (exit_code !== 0) { + if (exitCode !== 0) { throw new Error( - `Failed to build the shim image, exit code: \`${exit_code}\``, + `Failed to build the shim image, exit code: \`${exitCode}\``, ); } } { - actions_core.debug("Starting the Nix daemon through Docker..."); - this.idslib.recordEvent("start_docker_shim"); - const exit_code = await actions_exec.exec( + actionsCore.debug("Starting the Nix daemon through Docker..."); + this.idslib.recordEvent(EVENT_START_DOCKER_SHIM); + const exitCode = await actionsExec.exec( "docker", [ "--log-level=debug", @@ -622,123 +640,120 @@ class NixInstallerAction { silent: true, listeners: { stdline: (data: string) => { - actions_core.saveState( - "docker_shim_container_id", - data.trimEnd(), - ); + actionsCore.saveState("docker_shim_container_id", data.trimEnd()); }, stdout: (data: Buffer) => { const trimmed = data.toString("utf-8").trimEnd(); if (trimmed.length >= 0) { - actions_core.debug(trimmed); + actionsCore.debug(trimmed); } }, stderr: (data: Buffer) => { const trimmed = data.toString("utf-8").trimEnd(); if (trimmed.length >= 0) { - actions_core.debug(trimmed); + actionsCore.debug(trimmed); } }, }, }, ); - if (exit_code !== 0) { + if (exitCode !== 0) { throw new Error( - `Failed to start the Nix daemon through Docker, exit code: \`${exit_code}\``, + `Failed to start the Nix daemon through Docker, exit code: \`${exitCode}\``, ); } } - actions_core.endGroup(); + actionsCore.endGroup(); return; } async cleanupDockerShim(): Promise { - const container_id = actions_core.getState("docker_shim_container_id"); + const containerId = actionsCore.getState("docker_shim_container_id"); - if (container_id !== "") { - actions_core.startGroup("Cleaning up the Nix daemon's Docker shim"); + if (containerId !== "") { + actionsCore.startGroup("Cleaning up the Nix daemon's Docker shim"); let cleaned = false; try { - await actions_exec.exec("docker", ["rm", "--force", container_id]); + await actionsExec.exec("docker", ["rm", "--force", containerId]); cleaned = true; } catch { - actions_core.warning("failed to cleanup nix daemon container"); + actionsCore.warning("failed to cleanup nix daemon container"); } if (!cleaned) { - actions_core.info("trying to pkill the container's shim process"); + actionsCore.info("trying to pkill the container's shim process"); try { - await actions_exec.exec("pkill", [container_id]); + await actionsExec.exec("pkill", [containerId]); cleaned = true; } catch { - actions_core.warning( + actionsCore.warning( "failed to forcibly kill the container's shim process", ); } } if (cleaned) { - this.idslib.recordEvent("clean_up_docker_shim"); + this.idslib.recordEvent(EVENT_CLEAN_UP_DOCKER_SHIM); } else { - actions_core.warning( + actionsCore.warning( "Giving up on cleaning up the nix daemon container", ); } - actions_core.endGroup(); + actionsCore.endGroup(); } } - async set_github_path(): Promise { + async setGithubPath(): Promise { // Interim versions of the `nix-installer` crate may have already manipulated `$GITHUB_PATH`, as root even! Accessing that will be an error. try { - const nix_var_nix_profile_path = "/nix/var/nix/profiles/default/bin"; - const home_nix_profile_path = `${process.env.HOME}/.nix-profile/bin`; - actions_core.addPath(nix_var_nix_profile_path); - actions_core.addPath(home_nix_profile_path); - actions_core.info( - `Added \`${nix_var_nix_profile_path}\` and \`${home_nix_profile_path}\` to \`$GITHUB_PATH\``, + const nixVarNixProfilePath = "/nix/var/nix/profiles/default/bin"; + const homeNixProfilePath = `${process.env["HOME"]}/.nix-profile/bin`; + actionsCore.addPath(nixVarNixProfilePath); + actionsCore.addPath(homeNixProfilePath); + actionsCore.info( + `Added \`${nixVarNixProfilePath}\` and \`${homeNixProfilePath}\` to \`$GITHUB_PATH\``, ); - } catch (error) { - actions_core.info( + } catch { + actionsCore.info( "Skipping setting $GITHUB_PATH in action, the `nix-installer` crate seems to have done this already. From `nix-installer` version 0.11.0 and up, this step is done in the action. Prior to 0.11.0, this was only done in the `nix-installer` binary.", ); } } - async flakehub_login(): Promise { - this.idslib.recordEvent("login_to_flakehub"); - const netrc_path = `${process.env["RUNNER_TEMP"]}/determinate-nix-installer-netrc`; + async flakehubLogin(): Promise { + this.idslib.recordEvent(EVENT_LOGIN_TO_FLAKEHUB); + const netrcPath = `${process.env["RUNNER_TEMP"]}/determinate-nix-installer-netrc`; - const jwt = await actions_core.getIDToken("api.flakehub.com"); + const jwt = await actionsCore.getIDToken("api.flakehub.com"); await writeFile( - netrc_path, + netrcPath, [ `machine api.flakehub.com login flakehub password ${jwt}`, `machine flakehub.com login flakehub password ${jwt}`, ].join("\n"), ); - actions_core.info("Logging in to FlakeHub."); + actionsCore.info("Logging in to FlakeHub."); // the join followed by a match on ^... looks silly, but extra_config // could contain multi-line values - if (this.extra_conf?.join("\n").match(/^netrc-file/m)) { - actions_core.warning( + if (this.extraConf?.join("\n").match(/^netrc-file/m)) { + actionsCore.warning( "Logging in to FlakeHub conflicts with the Nix option `netrc-file`.", ); } - return netrc_path; + return netrcPath; } - async execute_uninstall(): Promise { - this.idslib.recordEvent("uninstall"); - const exit_code = await actions_exec.exec( + async executeUninstall(): Promise { + this.idslib.recordEvent(EVENT_UNINSTALL_NIX); + const exitCode = await actionsExec.exec( `/nix/nix-installer`, ["uninstall"], { @@ -749,17 +764,17 @@ class NixInstallerAction { }, ); - if (exit_code !== 0) { - throw new Error(`Non-zero exit code of \`${exit_code}\` detected`); + if (exitCode !== 0) { + throw new Error(`Non-zero exit code of \`${exitCode}\` detected`); } - return exit_code; + return exitCode; } - async detect_existing(): Promise { - const receipt_path = "/nix/receipt.json"; + async detectExisting(): Promise { + const receiptPath = "/nix/receipt.json"; try { - await access(receipt_path); + await access(receiptPath); // There is a /nix/receipt.json return true; } catch { @@ -768,20 +783,19 @@ class NixInstallerAction { } } - private async setup_kvm(): Promise { - this.idslib.recordEvent("setup_kvm"); - const current_user = userInfo(); - const is_root = current_user.uid === 0; - const maybe_sudo = is_root ? "" : "sudo"; + private async setupKvm(): Promise { + this.idslib.recordEvent(EVENT_SETUP_KVM); + const currentUser = userInfo(); + const isRoot = currentUser.uid === 0; + const maybeSudo = isRoot ? "" : "sudo"; - const kvm_rules = - "/etc/udev/rules.d/99-determinate-nix-installer-kvm.rules"; + const kvmRules = "/etc/udev/rules.d/99-determinate-nix-installer-kvm.rules"; try { - const write_file_exit_code = await actions_exec.exec( + const writeFileExitCode = await actionsExec.exec( "sh", [ "-c", - `echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | ${maybe_sudo} tee ${kvm_rules} > /dev/null`, + `echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | ${maybeSudo} tee ${kvmRules} > /dev/null`, ], { silent: true, @@ -789,125 +803,121 @@ class NixInstallerAction { stdout: (data: Buffer) => { const trimmed = data.toString("utf-8").trimEnd(); if (trimmed.length >= 0) { - actions_core.debug(trimmed); + actionsCore.debug(trimmed); } }, stderr: (data: Buffer) => { const trimmed = data.toString("utf-8").trimEnd(); if (trimmed.length >= 0) { - actions_core.debug(trimmed); + actionsCore.debug(trimmed); } }, }, }, ); - if (write_file_exit_code !== 0) { + if (writeFileExitCode !== 0) { throw new Error( - `Non-zero exit code of \`${write_file_exit_code}\` detected while writing '${kvm_rules}'`, + `Non-zero exit code of \`${writeFileExitCode}\` detected while writing '${kvmRules}'`, ); } - const debug_root_run_throw = async ( + const debugRootRunThrow = async ( action: string, command: string, args: string[], ): Promise => { - if (!is_root) { + if (!isRoot) { args = [command, ...args]; command = "sudo"; } - const reload_exit_code = await actions_exec.exec(command, args, { + const reloadExitCode = await actionsExec.exec(command, args, { silent: true, listeners: { stdout: (data: Buffer) => { const trimmed = data.toString("utf-8").trimEnd(); if (trimmed.length >= 0) { - actions_core.debug(trimmed); + actionsCore.debug(trimmed); } }, stderr: (data: Buffer) => { const trimmed = data.toString("utf-8").trimEnd(); if (trimmed.length >= 0) { - actions_core.debug(trimmed); + actionsCore.debug(trimmed); } }, }, }); - if (reload_exit_code !== 0) { + if (reloadExitCode !== 0) { throw new Error( - `Non-zero exit code of \`${reload_exit_code}\` detected while ${action}.`, + `Non-zero exit code of \`${reloadExitCode}\` detected while ${action}.`, ); } }; - await debug_root_run_throw("reloading udev rules", "udevadm", [ + await debugRootRunThrow("reloading udev rules", "udevadm", [ "control", "--reload-rules", ]); - await debug_root_run_throw("triggering udev against kvm", "udevadm", [ + await debugRootRunThrow("triggering udev against kvm", "udevadm", [ "trigger", "--name-match=kvm", ]); return true; - } catch (error) { - if (is_root) { - await actions_exec.exec("rm", ["-f", kvm_rules]); + } catch { + if (isRoot) { + await actionsExec.exec("rm", ["-f", kvmRules]); } else { - await actions_exec.exec("sudo", ["rm", "-f", kvm_rules]); + await actionsExec.exec("sudo", ["rm", "-f", kvmRules]); } return false; } } - private async fetch_binary(): Promise { - if (!this.local_root) { + private async fetchBinary(): Promise { + if (!this.localRoot) { return await this.idslib.fetchExecutable(); } else { - const local_path = join( - this.local_root, - `nix-installer-${this.platform}`, - ); - actions_core.info(`Using binary ${local_path}`); - return local_path; + const localPath = join(this.localRoot, `nix-installer-${this.platform}`); + actionsCore.info(`Using binary ${localPath}`); + return localPath; } } - async report_overall(): Promise { + async reportOverall(): Promise { try { - this.idslib.recordEvent("conclude_workflow", { - conclusion: await this.get_workflow_conclusion(), + this.idslib.recordEvent(EVENT_CONCLUDE_WORKFLOW, { + conclusion: await this.getWorkflowConclusion(), }); - } catch (error) { - actions_core.debug( - `Error submitting post-run diagnostics report: ${error}`, - ); + } catch (e) { + actionsCore.debug(`Error submitting post-run diagnostics report: ${e}`); } } - private async get_workflow_conclusion(): Promise< + private async getWorkflowConclusion(): Promise< undefined | "success" | "failure" | "cancelled" | "unavailable" | "no-jobs" > { - if (this.github_token == null) { + if (this.githubToken == null) { return undefined; } try { - const octokit = github.getOctokit(this.github_token); + const octokit = github.getOctokit(this.githubToken); const jobs = await octokit.paginate( octokit.rest.actions.listJobsForWorkflowRun, { owner: github.context.repo.owner, repo: github.context.repo.repo, + /* eslint-disable camelcase */ run_id: github.context.runId, }, ); - actions_core.debug(`awaited jobs: ${jobs}`); + actionsCore.debug(`awaited jobs: ${jobs}`); const job = jobs .filter((candidate) => candidate.name === github.context.job) .at(0); @@ -915,7 +925,7 @@ class NixInstallerAction { return "no-jobs"; } - const outcomes = (job.steps || []).map((j) => j.conclusion || "unknown"); + const outcomes = (job.steps ?? []).map((j) => j.conclusion ?? "unknown"); // Possible values: success, failure, cancelled, or skipped // from: https://docs.github.com/en/actions/learn-github-actions/contexts @@ -931,8 +941,8 @@ class NixInstallerAction { // Assume success if no jobs failed or were canceled return "success"; - } catch (error) { - actions_core.debug(`Error determining final disposition: ${error}`); + } catch (e) { + actionsCore.debug(`Error determining final disposition: ${e}`); return "unavailable"; } } @@ -964,68 +974,18 @@ type ExecuteEnvironment = { NIX_INSTALLER_LOGGER?: string; }; -function get_nix_platform(): string { - const env_os = process.env.RUNNER_OS; - const env_arch = process.env.RUNNER_ARCH; +function getDefaultPlanner(): string { + const envOs = process.env["RUNNER_OS"]; - if (env_os === "macOS" && env_arch === "X64") { - return "x86_64-darwin"; - } else if (env_os === "macOS" && env_arch === "ARM64") { - return "aarch64-darwin"; - } else if (env_os === "Linux" && env_arch === "X64") { - return "x86_64-linux"; - } else if (env_os === "Linux" && env_arch === "ARM64") { - return "aarch64-linux"; - } else { - throw new Error( - `Unsupported \`RUNNER_OS\` (currently \`${env_os}\`) and \`RUNNER_ARCH\` (currently \`${env_arch}\`) combination`, - ); - } -} - -function get_default_planner(): string { - const env_os = process.env.RUNNER_OS; - - if (env_os === "macOS") { + if (envOs === "macOS") { return "macos"; - } else if (env_os === "Linux") { + } else if (envOs === "Linux") { return "linux"; } else { - throw new Error(`Unsupported \`RUNNER_OS\` (currently \`${env_os}\`)`); + throw new Error(`Unsupported \`RUNNER_OS\` (currently \`${envOs}\`)`); } } -function action_input_string_or_null(name: string): string | null { - const value = actions_core.getInput(name); - if (value === "") { - return null; - } else { - return value; - } -} - -function action_input_multiline_string_or_null(name: string): string[] | null { - const value = actions_core.getMultilineInput(name); - if (value.length === 0) { - return null; - } else { - return value; - } -} - -function action_input_number_or_null(name: string): number | null { - const value = actions_core.getInput(name); - if (value === "") { - return null; - } else { - return Number(value); - } -} - -function action_input_bool(name: string): boolean { - return actions_core.getBooleanInput(name); -} - function main(): void { const installer = new NixInstallerAction(); @@ -1036,7 +996,7 @@ function main(): void { installer.idslib.onPost(async () => { await installer.cleanupDockerShim(); - await installer.report_overall(); + await installer.reportOverall(); }); installer.idslib.execute();