mirror of
https://github.com/DeterminateSystems/nix-installer-action.git
synced 2024-12-23 13:32:06 +01:00
Add extra_conf, reinstall
This commit is contained in:
parent
74554e45ae
commit
8e89511534
9 changed files with 8259 additions and 266 deletions
|
@ -49,6 +49,7 @@ inputs:
|
|||
modify-profile:
|
||||
description: Modify the user profile to automatically load nix
|
||||
required: false
|
||||
default: true
|
||||
nix-build-group-id:
|
||||
description: The Nix build group GID
|
||||
required: false
|
||||
|
@ -88,9 +89,11 @@ inputs:
|
|||
reinstall:
|
||||
description: Force a reinstall if an existing installation is detected (consider backing up `/nix/store`)
|
||||
required: false
|
||||
default: false
|
||||
start-daemon:
|
||||
description: "If the daemon should be started, requires `planner: linux-multi`"
|
||||
required: false
|
||||
default: true
|
||||
diagnostic-endpoint:
|
||||
description: "Diagnostic endpoint url where the installer sends data to. To disable set this to an empty string."
|
||||
default: "https://install.determinate.systems/nix/diagnostic"
|
||||
|
|
453
dist/37.index.js
vendored
Normal file
453
dist/37.index.js
vendored
Normal file
|
@ -0,0 +1,453 @@
|
|||
"use strict";
|
||||
exports.id = 37;
|
||||
exports.ids = [37];
|
||||
exports.modules = {
|
||||
|
||||
/***/ 4037:
|
||||
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
||||
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ "toFormData": () => (/* binding */ toFormData)
|
||||
/* harmony export */ });
|
||||
/* harmony import */ var fetch_blob_from_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2185);
|
||||
/* harmony import */ var formdata_polyfill_esm_min_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8010);
|
||||
|
||||
|
||||
|
||||
let s = 0;
|
||||
const S = {
|
||||
START_BOUNDARY: s++,
|
||||
HEADER_FIELD_START: s++,
|
||||
HEADER_FIELD: s++,
|
||||
HEADER_VALUE_START: s++,
|
||||
HEADER_VALUE: s++,
|
||||
HEADER_VALUE_ALMOST_DONE: s++,
|
||||
HEADERS_ALMOST_DONE: s++,
|
||||
PART_DATA_START: s++,
|
||||
PART_DATA: s++,
|
||||
END: s++
|
||||
};
|
||||
|
||||
let f = 1;
|
||||
const F = {
|
||||
PART_BOUNDARY: f,
|
||||
LAST_BOUNDARY: f *= 2
|
||||
};
|
||||
|
||||
const LF = 10;
|
||||
const CR = 13;
|
||||
const SPACE = 32;
|
||||
const HYPHEN = 45;
|
||||
const COLON = 58;
|
||||
const A = 97;
|
||||
const Z = 122;
|
||||
|
||||
const lower = c => c | 0x20;
|
||||
|
||||
const noop = () => {};
|
||||
|
||||
class MultipartParser {
|
||||
/**
|
||||
* @param {string} boundary
|
||||
*/
|
||||
constructor(boundary) {
|
||||
this.index = 0;
|
||||
this.flags = 0;
|
||||
|
||||
this.onHeaderEnd = noop;
|
||||
this.onHeaderField = noop;
|
||||
this.onHeadersEnd = noop;
|
||||
this.onHeaderValue = noop;
|
||||
this.onPartBegin = noop;
|
||||
this.onPartData = noop;
|
||||
this.onPartEnd = noop;
|
||||
|
||||
this.boundaryChars = {};
|
||||
|
||||
boundary = '\r\n--' + boundary;
|
||||
const ui8a = new Uint8Array(boundary.length);
|
||||
for (let i = 0; i < boundary.length; i++) {
|
||||
ui8a[i] = boundary.charCodeAt(i);
|
||||
this.boundaryChars[ui8a[i]] = true;
|
||||
}
|
||||
|
||||
this.boundary = ui8a;
|
||||
this.lookbehind = new Uint8Array(this.boundary.length + 8);
|
||||
this.state = S.START_BOUNDARY;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Uint8Array} data
|
||||
*/
|
||||
write(data) {
|
||||
let i = 0;
|
||||
const length_ = data.length;
|
||||
let previousIndex = this.index;
|
||||
let {lookbehind, boundary, boundaryChars, index, state, flags} = this;
|
||||
const boundaryLength = this.boundary.length;
|
||||
const boundaryEnd = boundaryLength - 1;
|
||||
const bufferLength = data.length;
|
||||
let c;
|
||||
let cl;
|
||||
|
||||
const mark = name => {
|
||||
this[name + 'Mark'] = i;
|
||||
};
|
||||
|
||||
const clear = name => {
|
||||
delete this[name + 'Mark'];
|
||||
};
|
||||
|
||||
const callback = (callbackSymbol, start, end, ui8a) => {
|
||||
if (start === undefined || start !== end) {
|
||||
this[callbackSymbol](ui8a && ui8a.subarray(start, end));
|
||||
}
|
||||
};
|
||||
|
||||
const dataCallback = (name, clear) => {
|
||||
const markSymbol = name + 'Mark';
|
||||
if (!(markSymbol in this)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (clear) {
|
||||
callback(name, this[markSymbol], i, data);
|
||||
delete this[markSymbol];
|
||||
} else {
|
||||
callback(name, this[markSymbol], data.length, data);
|
||||
this[markSymbol] = 0;
|
||||
}
|
||||
};
|
||||
|
||||
for (i = 0; i < length_; i++) {
|
||||
c = data[i];
|
||||
|
||||
switch (state) {
|
||||
case S.START_BOUNDARY:
|
||||
if (index === boundary.length - 2) {
|
||||
if (c === HYPHEN) {
|
||||
flags |= F.LAST_BOUNDARY;
|
||||
} else if (c !== CR) {
|
||||
return;
|
||||
}
|
||||
|
||||
index++;
|
||||
break;
|
||||
} else if (index - 1 === boundary.length - 2) {
|
||||
if (flags & F.LAST_BOUNDARY && c === HYPHEN) {
|
||||
state = S.END;
|
||||
flags = 0;
|
||||
} else if (!(flags & F.LAST_BOUNDARY) && c === LF) {
|
||||
index = 0;
|
||||
callback('onPartBegin');
|
||||
state = S.HEADER_FIELD_START;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (c !== boundary[index + 2]) {
|
||||
index = -2;
|
||||
}
|
||||
|
||||
if (c === boundary[index + 2]) {
|
||||
index++;
|
||||
}
|
||||
|
||||
break;
|
||||
case S.HEADER_FIELD_START:
|
||||
state = S.HEADER_FIELD;
|
||||
mark('onHeaderField');
|
||||
index = 0;
|
||||
// falls through
|
||||
case S.HEADER_FIELD:
|
||||
if (c === CR) {
|
||||
clear('onHeaderField');
|
||||
state = S.HEADERS_ALMOST_DONE;
|
||||
break;
|
||||
}
|
||||
|
||||
index++;
|
||||
if (c === HYPHEN) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (c === COLON) {
|
||||
if (index === 1) {
|
||||
// empty header field
|
||||
return;
|
||||
}
|
||||
|
||||
dataCallback('onHeaderField', true);
|
||||
state = S.HEADER_VALUE_START;
|
||||
break;
|
||||
}
|
||||
|
||||
cl = lower(c);
|
||||
if (cl < A || cl > Z) {
|
||||
return;
|
||||
}
|
||||
|
||||
break;
|
||||
case S.HEADER_VALUE_START:
|
||||
if (c === SPACE) {
|
||||
break;
|
||||
}
|
||||
|
||||
mark('onHeaderValue');
|
||||
state = S.HEADER_VALUE;
|
||||
// falls through
|
||||
case S.HEADER_VALUE:
|
||||
if (c === CR) {
|
||||
dataCallback('onHeaderValue', true);
|
||||
callback('onHeaderEnd');
|
||||
state = S.HEADER_VALUE_ALMOST_DONE;
|
||||
}
|
||||
|
||||
break;
|
||||
case S.HEADER_VALUE_ALMOST_DONE:
|
||||
if (c !== LF) {
|
||||
return;
|
||||
}
|
||||
|
||||
state = S.HEADER_FIELD_START;
|
||||
break;
|
||||
case S.HEADERS_ALMOST_DONE:
|
||||
if (c !== LF) {
|
||||
return;
|
||||
}
|
||||
|
||||
callback('onHeadersEnd');
|
||||
state = S.PART_DATA_START;
|
||||
break;
|
||||
case S.PART_DATA_START:
|
||||
state = S.PART_DATA;
|
||||
mark('onPartData');
|
||||
// falls through
|
||||
case S.PART_DATA:
|
||||
previousIndex = index;
|
||||
|
||||
if (index === 0) {
|
||||
// boyer-moore derrived algorithm to safely skip non-boundary data
|
||||
i += boundaryEnd;
|
||||
while (i < bufferLength && !(data[i] in boundaryChars)) {
|
||||
i += boundaryLength;
|
||||
}
|
||||
|
||||
i -= boundaryEnd;
|
||||
c = data[i];
|
||||
}
|
||||
|
||||
if (index < boundary.length) {
|
||||
if (boundary[index] === c) {
|
||||
if (index === 0) {
|
||||
dataCallback('onPartData', true);
|
||||
}
|
||||
|
||||
index++;
|
||||
} else {
|
||||
index = 0;
|
||||
}
|
||||
} else if (index === boundary.length) {
|
||||
index++;
|
||||
if (c === CR) {
|
||||
// CR = part boundary
|
||||
flags |= F.PART_BOUNDARY;
|
||||
} else if (c === HYPHEN) {
|
||||
// HYPHEN = end boundary
|
||||
flags |= F.LAST_BOUNDARY;
|
||||
} else {
|
||||
index = 0;
|
||||
}
|
||||
} else if (index - 1 === boundary.length) {
|
||||
if (flags & F.PART_BOUNDARY) {
|
||||
index = 0;
|
||||
if (c === LF) {
|
||||
// unset the PART_BOUNDARY flag
|
||||
flags &= ~F.PART_BOUNDARY;
|
||||
callback('onPartEnd');
|
||||
callback('onPartBegin');
|
||||
state = S.HEADER_FIELD_START;
|
||||
break;
|
||||
}
|
||||
} else if (flags & F.LAST_BOUNDARY) {
|
||||
if (c === HYPHEN) {
|
||||
callback('onPartEnd');
|
||||
state = S.END;
|
||||
flags = 0;
|
||||
} else {
|
||||
index = 0;
|
||||
}
|
||||
} else {
|
||||
index = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (index > 0) {
|
||||
// when matching a possible boundary, keep a lookbehind reference
|
||||
// in case it turns out to be a false lead
|
||||
lookbehind[index - 1] = c;
|
||||
} else if (previousIndex > 0) {
|
||||
// if our boundary turned out to be rubbish, the captured lookbehind
|
||||
// belongs to partData
|
||||
const _lookbehind = new Uint8Array(lookbehind.buffer, lookbehind.byteOffset, lookbehind.byteLength);
|
||||
callback('onPartData', 0, previousIndex, _lookbehind);
|
||||
previousIndex = 0;
|
||||
mark('onPartData');
|
||||
|
||||
// reconsider the current character even so it interrupted the sequence
|
||||
// it could be the beginning of a new sequence
|
||||
i--;
|
||||
}
|
||||
|
||||
break;
|
||||
case S.END:
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unexpected state entered: ${state}`);
|
||||
}
|
||||
}
|
||||
|
||||
dataCallback('onHeaderField');
|
||||
dataCallback('onHeaderValue');
|
||||
dataCallback('onPartData');
|
||||
|
||||
// Update properties for the next call
|
||||
this.index = index;
|
||||
this.state = state;
|
||||
this.flags = flags;
|
||||
}
|
||||
|
||||
end() {
|
||||
if ((this.state === S.HEADER_FIELD_START && this.index === 0) ||
|
||||
(this.state === S.PART_DATA && this.index === this.boundary.length)) {
|
||||
this.onPartEnd();
|
||||
} else if (this.state !== S.END) {
|
||||
throw new Error('MultipartParser.end(): stream ended unexpectedly');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _fileName(headerValue) {
|
||||
// matches either a quoted-string or a token (RFC 2616 section 19.5.1)
|
||||
const m = headerValue.match(/\bfilename=("(.*?)"|([^()<>@,;:\\"/[\]?={}\s\t]+))($|;\s)/i);
|
||||
if (!m) {
|
||||
return;
|
||||
}
|
||||
|
||||
const match = m[2] || m[3] || '';
|
||||
let filename = match.slice(match.lastIndexOf('\\') + 1);
|
||||
filename = filename.replace(/%22/g, '"');
|
||||
filename = filename.replace(/&#(\d{4});/g, (m, code) => {
|
||||
return String.fromCharCode(code);
|
||||
});
|
||||
return filename;
|
||||
}
|
||||
|
||||
async function toFormData(Body, ct) {
|
||||
if (!/multipart/i.test(ct)) {
|
||||
throw new TypeError('Failed to fetch');
|
||||
}
|
||||
|
||||
const m = ct.match(/boundary=(?:"([^"]+)"|([^;]+))/i);
|
||||
|
||||
if (!m) {
|
||||
throw new TypeError('no or bad content-type header, no multipart boundary');
|
||||
}
|
||||
|
||||
const parser = new MultipartParser(m[1] || m[2]);
|
||||
|
||||
let headerField;
|
||||
let headerValue;
|
||||
let entryValue;
|
||||
let entryName;
|
||||
let contentType;
|
||||
let filename;
|
||||
const entryChunks = [];
|
||||
const formData = new formdata_polyfill_esm_min_js__WEBPACK_IMPORTED_MODULE_1__/* .FormData */ .Ct();
|
||||
|
||||
const onPartData = ui8a => {
|
||||
entryValue += decoder.decode(ui8a, {stream: true});
|
||||
};
|
||||
|
||||
const appendToFile = ui8a => {
|
||||
entryChunks.push(ui8a);
|
||||
};
|
||||
|
||||
const appendFileToFormData = () => {
|
||||
const file = new fetch_blob_from_js__WEBPACK_IMPORTED_MODULE_0__/* .File */ .$B(entryChunks, filename, {type: contentType});
|
||||
formData.append(entryName, file);
|
||||
};
|
||||
|
||||
const appendEntryToFormData = () => {
|
||||
formData.append(entryName, entryValue);
|
||||
};
|
||||
|
||||
const decoder = new TextDecoder('utf-8');
|
||||
decoder.decode();
|
||||
|
||||
parser.onPartBegin = function () {
|
||||
parser.onPartData = onPartData;
|
||||
parser.onPartEnd = appendEntryToFormData;
|
||||
|
||||
headerField = '';
|
||||
headerValue = '';
|
||||
entryValue = '';
|
||||
entryName = '';
|
||||
contentType = '';
|
||||
filename = null;
|
||||
entryChunks.length = 0;
|
||||
};
|
||||
|
||||
parser.onHeaderField = function (ui8a) {
|
||||
headerField += decoder.decode(ui8a, {stream: true});
|
||||
};
|
||||
|
||||
parser.onHeaderValue = function (ui8a) {
|
||||
headerValue += decoder.decode(ui8a, {stream: true});
|
||||
};
|
||||
|
||||
parser.onHeaderEnd = function () {
|
||||
headerValue += decoder.decode();
|
||||
headerField = headerField.toLowerCase();
|
||||
|
||||
if (headerField === 'content-disposition') {
|
||||
// matches either a quoted-string or a token (RFC 2616 section 19.5.1)
|
||||
const m = headerValue.match(/\bname=("([^"]*)"|([^()<>@,;:\\"/[\]?={}\s\t]+))/i);
|
||||
|
||||
if (m) {
|
||||
entryName = m[2] || m[3] || '';
|
||||
}
|
||||
|
||||
filename = _fileName(headerValue);
|
||||
|
||||
if (filename) {
|
||||
parser.onPartData = appendToFile;
|
||||
parser.onPartEnd = appendFileToFormData;
|
||||
}
|
||||
} else if (headerField === 'content-type') {
|
||||
contentType = headerValue;
|
||||
}
|
||||
|
||||
headerValue = '';
|
||||
headerField = '';
|
||||
};
|
||||
|
||||
for await (const chunk of Body) {
|
||||
parser.write(chunk);
|
||||
}
|
||||
|
||||
parser.end();
|
||||
|
||||
return formData;
|
||||
}
|
||||
|
||||
|
||||
/***/ })
|
||||
|
||||
};
|
||||
;
|
||||
//# sourceMappingURL=37.index.js.map
|
1
dist/37.index.js.map
vendored
Normal file
1
dist/37.index.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
7587
dist/index.js
vendored
7587
dist/index.js
vendored
File diff suppressed because it is too large
Load diff
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
62
dist/licenses.txt
vendored
62
dist/licenses.txt
vendored
|
@ -1,45 +1,8 @@
|
|||
@actions/core
|
||||
node-fetch
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright 2019 GitHub
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
@actions/http-client
|
||||
MIT
|
||||
Actions Http Client for Node.js
|
||||
|
||||
Copyright (c) GitHub, Inc.
|
||||
|
||||
All rights reserved.
|
||||
|
||||
MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
tunnel
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2012 Koichi Kobayashi
|
||||
Copyright (c) 2016 - 2020 Node Fetch Team
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -48,26 +11,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
uuid
|
||||
MIT
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2010-2020 Robert Kieffer and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
|
177
package-lock.json
generated
177
package-lock.json
generated
|
@ -10,7 +10,9 @@
|
|||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.10.0",
|
||||
"@actions/github": "^5.1.1"
|
||||
"@actions/github": "^5.1.1",
|
||||
"node-fetch": "^3.3.1",
|
||||
"string-argv": "^0.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^18.16.3",
|
||||
|
@ -278,6 +280,25 @@
|
|||
"once": "^1.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/request/node_modules/node-fetch": {
|
||||
"version": "2.6.12",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.12.tgz",
|
||||
"integrity": "sha512-C/fGU2E8ToujUivIO0H+tpQ6HWo4eEmchoPIoXtxCrVghxdKq+QOHqEZW7tuP3KlV3bC8FRMO5nMCC7Zm1VP6g==",
|
||||
"dependencies": {
|
||||
"whatwg-url": "^5.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "4.x || >=6.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"encoding": "^0.1.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"encoding": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@octokit/types": {
|
||||
"version": "6.41.0",
|
||||
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-6.41.0.tgz",
|
||||
|
@ -890,6 +911,14 @@
|
|||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/data-uri-to-buffer": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz",
|
||||
"integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==",
|
||||
"engines": {
|
||||
"node": ">= 12"
|
||||
}
|
||||
},
|
||||
"node_modules/debug": {
|
||||
"version": "4.3.4",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
|
||||
|
@ -1632,6 +1661,28 @@
|
|||
"reusify": "^1.0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/fetch-blob": {
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz",
|
||||
"integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/jimmywarting"
|
||||
},
|
||||
{
|
||||
"type": "paypal",
|
||||
"url": "https://paypal.me/jimmywarting"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"node-domexception": "^1.0.0",
|
||||
"web-streams-polyfill": "^3.0.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^12.20 || >= 14.13"
|
||||
}
|
||||
},
|
||||
"node_modules/file-entry-cache": {
|
||||
"version": "6.0.1",
|
||||
"resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz",
|
||||
|
@ -1700,6 +1751,17 @@
|
|||
"is-callable": "^1.1.3"
|
||||
}
|
||||
},
|
||||
"node_modules/formdata-polyfill": {
|
||||
"version": "4.0.10",
|
||||
"resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz",
|
||||
"integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==",
|
||||
"dependencies": {
|
||||
"fetch-blob": "^3.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12.20.0"
|
||||
}
|
||||
},
|
||||
"node_modules/fs.realpath": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||
|
@ -2543,23 +2605,39 @@
|
|||
"integrity": "sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/node-domexception": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",
|
||||
"integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/jimmywarting"
|
||||
},
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://paypal.me/jimmywarting"
|
||||
}
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=10.5.0"
|
||||
}
|
||||
},
|
||||
"node_modules/node-fetch": {
|
||||
"version": "2.6.12",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.12.tgz",
|
||||
"integrity": "sha512-C/fGU2E8ToujUivIO0H+tpQ6HWo4eEmchoPIoXtxCrVghxdKq+QOHqEZW7tuP3KlV3bC8FRMO5nMCC7Zm1VP6g==",
|
||||
"version": "3.3.1",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.1.tgz",
|
||||
"integrity": "sha512-cRVc/kyto/7E5shrWca1Wsea4y6tL9iYJE5FBCius3JQfb/4P4I295PfhgbJQBLTx6lATE4z+wK0rPM4VS2uow==",
|
||||
"dependencies": {
|
||||
"whatwg-url": "^5.0.0"
|
||||
"data-uri-to-buffer": "^4.0.0",
|
||||
"fetch-blob": "^3.1.4",
|
||||
"formdata-polyfill": "^4.0.10"
|
||||
},
|
||||
"engines": {
|
||||
"node": "4.x || >=6.0.0"
|
||||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"encoding": "^0.1.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"encoding": {
|
||||
"optional": true
|
||||
}
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/node-fetch"
|
||||
}
|
||||
},
|
||||
"node_modules/node-releases": {
|
||||
|
@ -3147,6 +3225,14 @@
|
|||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/string-argv": {
|
||||
"version": "0.3.2",
|
||||
"resolved": "https://registry.npmjs.org/string-argv/-/string-argv-0.3.2.tgz",
|
||||
"integrity": "sha512-aqD2Q0144Z+/RqG52NeHEkZauTAUWJO8c6yTftGJKO3Tja5tUgIfmIl6kExvhtxSDP7fXB6DvzkfMpCd/F3G+Q==",
|
||||
"engines": {
|
||||
"node": ">=0.6.19"
|
||||
}
|
||||
},
|
||||
"node_modules/string.prototype.trim": {
|
||||
"version": "1.2.7",
|
||||
"resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.2.7.tgz",
|
||||
|
@ -3496,6 +3582,14 @@
|
|||
"uuid": "dist/bin/uuid"
|
||||
}
|
||||
},
|
||||
"node_modules/web-streams-polyfill": {
|
||||
"version": "3.2.1",
|
||||
"resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz",
|
||||
"integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==",
|
||||
"engines": {
|
||||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/webidl-conversions": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
|
||||
|
@ -3782,6 +3876,16 @@
|
|||
"is-plain-object": "^5.0.0",
|
||||
"node-fetch": "^2.6.7",
|
||||
"universal-user-agent": "^6.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"node-fetch": {
|
||||
"version": "2.6.12",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.12.tgz",
|
||||
"integrity": "sha512-C/fGU2E8ToujUivIO0H+tpQ6HWo4eEmchoPIoXtxCrVghxdKq+QOHqEZW7tuP3KlV3bC8FRMO5nMCC7Zm1VP6g==",
|
||||
"requires": {
|
||||
"whatwg-url": "^5.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@octokit/request-error": {
|
||||
|
@ -4194,6 +4298,11 @@
|
|||
"which": "^2.0.1"
|
||||
}
|
||||
},
|
||||
"data-uri-to-buffer": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz",
|
||||
"integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A=="
|
||||
},
|
||||
"debug": {
|
||||
"version": "4.3.4",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
|
||||
|
@ -4741,6 +4850,15 @@
|
|||
"reusify": "^1.0.4"
|
||||
}
|
||||
},
|
||||
"fetch-blob": {
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz",
|
||||
"integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==",
|
||||
"requires": {
|
||||
"node-domexception": "^1.0.0",
|
||||
"web-streams-polyfill": "^3.0.3"
|
||||
}
|
||||
},
|
||||
"file-entry-cache": {
|
||||
"version": "6.0.1",
|
||||
"resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz",
|
||||
|
@ -4794,6 +4912,14 @@
|
|||
"is-callable": "^1.1.3"
|
||||
}
|
||||
},
|
||||
"formdata-polyfill": {
|
||||
"version": "4.0.10",
|
||||
"resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz",
|
||||
"integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==",
|
||||
"requires": {
|
||||
"fetch-blob": "^3.1.2"
|
||||
}
|
||||
},
|
||||
"fs.realpath": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||
|
@ -5381,12 +5507,19 @@
|
|||
"integrity": "sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==",
|
||||
"dev": true
|
||||
},
|
||||
"node-domexception": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",
|
||||
"integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ=="
|
||||
},
|
||||
"node-fetch": {
|
||||
"version": "2.6.12",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.12.tgz",
|
||||
"integrity": "sha512-C/fGU2E8ToujUivIO0H+tpQ6HWo4eEmchoPIoXtxCrVghxdKq+QOHqEZW7tuP3KlV3bC8FRMO5nMCC7Zm1VP6g==",
|
||||
"version": "3.3.1",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.1.tgz",
|
||||
"integrity": "sha512-cRVc/kyto/7E5shrWca1Wsea4y6tL9iYJE5FBCius3JQfb/4P4I295PfhgbJQBLTx6lATE4z+wK0rPM4VS2uow==",
|
||||
"requires": {
|
||||
"whatwg-url": "^5.0.0"
|
||||
"data-uri-to-buffer": "^4.0.0",
|
||||
"fetch-blob": "^3.1.4",
|
||||
"formdata-polyfill": "^4.0.10"
|
||||
}
|
||||
},
|
||||
"node-releases": {
|
||||
|
@ -5772,6 +5905,11 @@
|
|||
"integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",
|
||||
"dev": true
|
||||
},
|
||||
"string-argv": {
|
||||
"version": "0.3.2",
|
||||
"resolved": "https://registry.npmjs.org/string-argv/-/string-argv-0.3.2.tgz",
|
||||
"integrity": "sha512-aqD2Q0144Z+/RqG52NeHEkZauTAUWJO8c6yTftGJKO3Tja5tUgIfmIl6kExvhtxSDP7fXB6DvzkfMpCd/F3G+Q=="
|
||||
},
|
||||
"string.prototype.trim": {
|
||||
"version": "1.2.7",
|
||||
"resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.2.7.tgz",
|
||||
|
@ -6008,6 +6146,11 @@
|
|||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg=="
|
||||
},
|
||||
"web-streams-polyfill": {
|
||||
"version": "3.2.1",
|
||||
"resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz",
|
||||
"integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q=="
|
||||
},
|
||||
"webidl-conversions": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
|
||||
|
|
|
@ -23,7 +23,9 @@
|
|||
"homepage": "https://github.com/DeterminateSystems/nix-installer-action#readme",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.10.0",
|
||||
"@actions/github": "^5.1.1"
|
||||
"@actions/github": "^5.1.1",
|
||||
"node-fetch": "^3.3.1",
|
||||
"string-argv": "^0.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^18.16.3",
|
||||
|
|
236
src/main.ts
236
src/main.ts
|
@ -1,12 +1,17 @@
|
|||
import * as actions_core from '@actions/core'
|
||||
import {mkdtemp, open} from 'node:fs/promises'
|
||||
import {mkdtemp, chmod, access} from 'node:fs/promises'
|
||||
import {spawn} from 'node:child_process'
|
||||
import {join} from 'node:path'
|
||||
import {tmpdir} from 'node:os'
|
||||
import {Readable} from 'node:stream'
|
||||
import {pipeline} from 'node:stream'
|
||||
import fetch from 'node-fetch'
|
||||
import {promisify} from 'node:util'
|
||||
import fs from 'node:fs'
|
||||
import stringArgv from 'string-argv'
|
||||
|
||||
class NixInstallerAction {
|
||||
platform: string
|
||||
nix_package_url: string | null
|
||||
backtrace: string | null
|
||||
extra_args: string | null
|
||||
extra_conf: string[] | null
|
||||
|
@ -22,21 +27,22 @@ class NixInstallerAction {
|
|||
mac_encrypt: string | null
|
||||
mac_root_disk: string | null
|
||||
mac_volume_label: string | null
|
||||
modify_profile: boolean | 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
|
||||
planner: string | null
|
||||
reinstall: boolean | null
|
||||
start_daemon: boolean | null
|
||||
reinstall: boolean
|
||||
start_daemon: boolean
|
||||
diagnostic_endpoint: string | null
|
||||
trust_runner_user: boolean | null
|
||||
nix_installer_url: URL
|
||||
|
||||
constructor() {
|
||||
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')
|
||||
|
@ -51,7 +57,7 @@ class NixInstallerAction {
|
|||
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_or_null('modify-profile')
|
||||
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'
|
||||
|
@ -66,102 +72,151 @@ class NixInstallerAction {
|
|||
'nix-build-user-prefix'
|
||||
)
|
||||
this.planner = action_input_string_or_null('planner')
|
||||
this.reinstall = action_input_bool_or_null('reinstall')
|
||||
this.start_daemon = action_input_bool_or_null('start-daemon')
|
||||
this.reinstall = action_input_bool('reinstall')
|
||||
this.start_daemon = action_input_bool('start-daemon')
|
||||
this.diagnostic_endpoint = action_input_string_or_null(
|
||||
'diagnostic-endpoint'
|
||||
)
|
||||
this.trust_runner_user = action_input_bool_or_null('trust-runner-user')
|
||||
this.trust_runner_user = action_input_bool('trust-runner-user')
|
||||
this.nix_installer_url = resolve_nix_installer_url(this.platform)
|
||||
}
|
||||
|
||||
private executionEnvironment(): ExecuteEnvironment {
|
||||
const env: ExecuteEnvironment = {}
|
||||
const execution_env: ExecuteEnvironment = {}
|
||||
|
||||
execution_env.NIX_INSTALLER_NO_CONFIRM = 'true'
|
||||
|
||||
if (this.backtrace !== null) {
|
||||
env.RUST_BACKTRACE = this.backtrace
|
||||
execution_env.RUST_BACKTRACE = this.backtrace
|
||||
}
|
||||
if (this.modify_profile !== null) {
|
||||
if (this.modify_profile) {
|
||||
env.NIX_INSTALLER_MODIFY_PROFILE = '1'
|
||||
execution_env.NIX_INSTALLER_MODIFY_PROFILE = 'true'
|
||||
} else {
|
||||
env.NIX_INSTALLER_MODIFY_PROFILE = '0'
|
||||
execution_env.NIX_INSTALLER_MODIFY_PROFILE = 'false'
|
||||
}
|
||||
}
|
||||
|
||||
if (this.nix_build_group_id !== null) {
|
||||
env.NIX_INSTALLER_NIX_BUILD_GROUP_ID = `${this.nix_build_group_id}`
|
||||
execution_env.NIX_INSTALLER_NIX_BUILD_GROUP_ID = `${this.nix_build_group_id}`
|
||||
}
|
||||
|
||||
if (this.nix_build_group_name !== null) {
|
||||
env.NIX_INSTALLER_NIX_BUILD_GROUP_NAME = this.nix_build_group_name
|
||||
execution_env.NIX_INSTALLER_NIX_BUILD_GROUP_NAME =
|
||||
this.nix_build_group_name
|
||||
}
|
||||
|
||||
if (this.nix_build_user_prefix !== null) {
|
||||
env.NIX_INSTALLER_NIX_BUILD_USER_PREFIX = this.nix_build_user_prefix
|
||||
execution_env.NIX_INSTALLER_NIX_BUILD_USER_PREFIX =
|
||||
this.nix_build_user_prefix
|
||||
}
|
||||
|
||||
if (this.nix_build_user_count !== null) {
|
||||
env.NIX_INSTALLER_NIX_BUILD_USER_COUNT = `${this.nix_build_user_count}`
|
||||
execution_env.NIX_INSTALLER_NIX_BUILD_USER_COUNT = `${this.nix_build_user_count}`
|
||||
}
|
||||
|
||||
if (this.nix_build_user_base !== null) {
|
||||
env.NIX_INSTALLER_NIX_BUILD_USER_ID_BASE = `${this.nix_build_user_count}`
|
||||
execution_env.NIX_INSTALLER_NIX_BUILD_USER_ID_BASE = `${this.nix_build_user_count}`
|
||||
}
|
||||
|
||||
if (this.nix_installer_url !== null) {
|
||||
env.NIX_INSTALLER_NIX_PACKAGE_URL = `${this.nix_installer_url}`
|
||||
if (this.nix_package_url !== null) {
|
||||
execution_env.NIX_INSTALLER_NIX_PACKAGE_URL = `${this.nix_package_url}`
|
||||
}
|
||||
|
||||
if (this.proxy !== null) {
|
||||
env.NIX_INSTALLER_PROXY = this.proxy
|
||||
execution_env.NIX_INSTALLER_PROXY = this.proxy
|
||||
}
|
||||
|
||||
if (this.ssl_cert_file !== null) {
|
||||
env.NIX_INSTALLER_SSL_CERT_FILE = this.ssl_cert_file
|
||||
execution_env.NIX_INSTALLER_SSL_CERT_FILE = this.ssl_cert_file
|
||||
}
|
||||
|
||||
if (this.diagnostic_endpoint !== null) {
|
||||
env.NIX_INSTALLER_DIAGNOSTIC_ENDPOINT = this.diagnostic_endpoint
|
||||
execution_env.NIX_INSTALLER_DIAGNOSTIC_ENDPOINT = this.diagnostic_endpoint
|
||||
}
|
||||
|
||||
// TODO: Error if the user uses these on not-MacOS
|
||||
if (this.mac_encrypt !== null) {
|
||||
env.NIX_INSTALLER_ENCRYPT = this.mac_encrypt
|
||||
execution_env.NIX_INSTALLER_ENCRYPT = this.mac_encrypt
|
||||
}
|
||||
|
||||
if (this.mac_case_sensitive !== null) {
|
||||
env.NIX_INSTALLER_CASE_SENSITIVE = this.mac_case_sensitive
|
||||
execution_env.NIX_INSTALLER_CASE_SENSITIVE = this.mac_case_sensitive
|
||||
}
|
||||
|
||||
if (this.mac_volume_label !== null) {
|
||||
env.NIX_INSTALLER_VOLUME_LABEL = this.mac_volume_label
|
||||
execution_env.NIX_INSTALLER_VOLUME_LABEL = this.mac_volume_label
|
||||
}
|
||||
|
||||
if (this.mac_root_disk !== null) {
|
||||
env.NIX_INSTALLER_ROOT_DISK = this.mac_root_disk
|
||||
execution_env.NIX_INSTALLER_ROOT_DISK = this.mac_root_disk
|
||||
}
|
||||
|
||||
// TODO: Error if the user uses these on MacOS
|
||||
if (this.init !== null) {
|
||||
env.NIX_INSTALLER_INIT = this.init
|
||||
execution_env.NIX_INSTALLER_INIT = this.init
|
||||
}
|
||||
|
||||
if (this.start_daemon !== null) {
|
||||
if (this.start_daemon) {
|
||||
env.NIX_INSTALLER_START_DAEMON = '1'
|
||||
execution_env.NIX_INSTALLER_START_DAEMON = 'true'
|
||||
} else {
|
||||
env.NIX_INSTALLER_START_DAEMON = '0'
|
||||
execution_env.NIX_INSTALLER_START_DAEMON = 'false'
|
||||
}
|
||||
}
|
||||
|
||||
return env
|
||||
let extra_conf = ''
|
||||
if (this.github_token !== null) {
|
||||
extra_conf += `access-tokens = github.com=${this.github_token}`
|
||||
extra_conf += '\n'
|
||||
}
|
||||
if (this.trust_runner_user !== null) {
|
||||
// TODO: Consider how to improve this
|
||||
extra_conf += `trusted-users = root ${process.env.USER}`
|
||||
extra_conf += '\n'
|
||||
}
|
||||
if (this.extra_conf !== null && this.extra_conf.length !== 0) {
|
||||
extra_conf += this.extra_conf.join('\n')
|
||||
extra_conf += '\n'
|
||||
}
|
||||
execution_env.NIX_INSTALLER_EXTRA_CONF = extra_conf
|
||||
|
||||
if (process.env.ACT && !process.env.NOT_ACT) {
|
||||
actions_core.debug(
|
||||
'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 settings of the `init` as well as `extra-conf` to be compatible with `act`'
|
||||
)
|
||||
execution_env.NIX_INSTALLER_INIT = 'none'
|
||||
}
|
||||
|
||||
private async execute(binary_path: string): Promise<number> {
|
||||
const env = this.executionEnvironment()
|
||||
return execution_env
|
||||
}
|
||||
|
||||
const spawned = spawn(`${binary_path} ${this.extra_args}`, {env})
|
||||
private async execute_install(binary_path: string): Promise<number> {
|
||||
const execution_env = this.executionEnvironment()
|
||||
actions_core.debug(
|
||||
`Execution environment: ${JSON.stringify(execution_env)}`
|
||||
)
|
||||
|
||||
const args = ['install']
|
||||
if (this.planner) {
|
||||
args.push(this.planner)
|
||||
} else {
|
||||
args.push(get_default_planner())
|
||||
}
|
||||
|
||||
if (this.extra_args) {
|
||||
const extra_args = stringArgv(this.extra_args)
|
||||
args.concat(extra_args)
|
||||
}
|
||||
|
||||
const merged_env = {
|
||||
...process.env, // To get $PATH, etc
|
||||
...execution_env
|
||||
}
|
||||
|
||||
const spawned = spawn(`${binary_path}`, args, {
|
||||
env: merged_env
|
||||
})
|
||||
|
||||
spawned.stdout.on('data', data => {
|
||||
actions_core.debug(`stdout: ${data}`)
|
||||
|
@ -183,17 +238,76 @@ class NixInstallerAction {
|
|||
}
|
||||
|
||||
async install(): Promise<void> {
|
||||
const existing_install = await this.detect_existing()
|
||||
if (existing_install) {
|
||||
if (this.reinstall) {
|
||||
// We need to uninstall, then reinstall
|
||||
actions_core.debug(
|
||||
'Nix was already installed, `reinstall` is set, uninstalling for a reinstall'
|
||||
)
|
||||
await this.uninstall()
|
||||
} else {
|
||||
// We're already installed, and not reinstalling, just set GITHUB_PATH and finish early
|
||||
this.set_github_path()
|
||||
actions_core.debug('Nix was already installed, using existing install')
|
||||
return
|
||||
}
|
||||
}
|
||||
// Normal just doing of the install
|
||||
const binary_path = await this.fetch_binary()
|
||||
await this.execute(binary_path)
|
||||
await this.execute_install(binary_path)
|
||||
// TODO: Add `this.set_github_path()` and remove that from the installer crate
|
||||
}
|
||||
|
||||
set_github_path(): void {
|
||||
actions_core.addPath('/nix/var/nix/profiles/default/bin')
|
||||
actions_core.addPath(`${process.env.HOME}/.nix-profile/bin`)
|
||||
}
|
||||
|
||||
async uninstall(): Promise<number> {
|
||||
const spawned = spawn(`/nix/nix-installer`, ['uninstall'], {
|
||||
env: {
|
||||
NIX_INSTALLER_NO_CONFIRM: 'true',
|
||||
...process.env // To get $PATH, etc
|
||||
}
|
||||
})
|
||||
|
||||
spawned.stdout.on('data', data => {
|
||||
actions_core.debug(`stdout: ${data}`)
|
||||
})
|
||||
|
||||
spawned.stderr.on('data', data => {
|
||||
actions_core.debug(`stderr: ${data}`)
|
||||
})
|
||||
|
||||
const exit_code: number = await new Promise((resolve, _reject) => {
|
||||
spawned.on('close', resolve)
|
||||
})
|
||||
|
||||
if (exit_code !== 0) {
|
||||
throw new Error(`Non-zero exit code of \`${exit_code}\` detected`)
|
||||
}
|
||||
|
||||
return exit_code
|
||||
}
|
||||
|
||||
async detect_existing(): Promise<boolean> {
|
||||
const receipt_path = '/nix/receipt.json'
|
||||
// TODO: Maybe this should be a bit smarter?
|
||||
try {
|
||||
await access(receipt_path)
|
||||
// There is a /nix/receipt.json
|
||||
return true
|
||||
} catch {
|
||||
// No /nix/receipt.json
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
private async fetch_binary(): Promise<string> {
|
||||
if (!this.local_root) {
|
||||
const request = new Request(this.nix_installer_url, {
|
||||
redirect: 'follow'
|
||||
})
|
||||
|
||||
const response = await fetch(request)
|
||||
actions_core.debug(`Fetching binary from ${this.nix_installer_url}`)
|
||||
const response = await fetch(this.nix_installer_url)
|
||||
if (!response.ok) {
|
||||
throw new Error(
|
||||
`Got a status of ${response.status} from \`${this.nix_installer_url}\`, expected a 200`
|
||||
|
@ -203,17 +317,26 @@ class NixInstallerAction {
|
|||
const tempdir = await mkdtemp(join(tmpdir(), 'nix-installer-'))
|
||||
const tempfile = join(tempdir, `nix-installer-${this.platform}`)
|
||||
|
||||
const handle = await open(tempfile)
|
||||
const writer = handle.createWriteStream()
|
||||
if (!response.ok) {
|
||||
throw new Error(`unexpected response ${response.statusText}`)
|
||||
}
|
||||
|
||||
const blob = await response.blob()
|
||||
const stream = blob.stream() as unknown as Readable
|
||||
stream.pipe(writer)
|
||||
writer.close()
|
||||
if (response.body !== null) {
|
||||
const streamPipeline = promisify(pipeline)
|
||||
await streamPipeline(response.body, fs.createWriteStream(tempfile))
|
||||
actions_core.debug(`Downloaded \`nix-installer\` to \`${tempfile}\``)
|
||||
} else {
|
||||
throw new Error('No response body recieved')
|
||||
}
|
||||
|
||||
// Make executable
|
||||
await chmod(tempfile, fs.constants.S_IXUSR | fs.constants.S_IXGRP)
|
||||
|
||||
return tempfile
|
||||
} else {
|
||||
return join(this.local_root, `nix-installer-${this.platform}`)
|
||||
const local_path = join(this.local_root, `nix-installer-${this.platform}`)
|
||||
actions_core.debug(`Using binary ${local_path}`)
|
||||
return local_path
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -237,6 +360,8 @@ type ExecuteEnvironment = {
|
|||
NIX_INSTALLER_ROOT_DISK?: string
|
||||
NIX_INSTALLER_INIT?: string
|
||||
NIX_INSTALLER_START_DAEMON?: string
|
||||
NIX_INSTALLER_NO_CONFIRM?: string
|
||||
NIX_INSTALLER_EXTRA_CONF?: string
|
||||
}
|
||||
|
||||
function get_nix_platform(): string {
|
||||
|
@ -258,6 +383,18 @@ function get_nix_platform(): string {
|
|||
}
|
||||
}
|
||||
|
||||
function get_default_planner(): string {
|
||||
const env_os = process.env.RUNNER_OS
|
||||
|
||||
if (env_os === 'macOS') {
|
||||
return 'macos'
|
||||
} else if (env_os === 'Linux') {
|
||||
return 'linux'
|
||||
} else {
|
||||
throw new Error(`Unsupported \`RUNNER_OS\` (currently \`${env_os}\`)`)
|
||||
}
|
||||
}
|
||||
|
||||
function resolve_nix_installer_url(platform: string): URL {
|
||||
// Only one of these are allowed.
|
||||
const nix_installer_branch = action_input_string_or_null(
|
||||
|
@ -344,16 +481,17 @@ function action_input_number_or_null(name: string): number | null {
|
|||
}
|
||||
}
|
||||
|
||||
function action_input_bool_or_null(name: string): boolean {
|
||||
function action_input_bool(name: string): boolean {
|
||||
return actions_core.getBooleanInput(name)
|
||||
}
|
||||
|
||||
async function main(): Promise<void> {
|
||||
try {
|
||||
const installer = new NixInstallerAction()
|
||||
|
||||
await installer.install()
|
||||
} catch (error) {
|
||||
if (error instanceof Error) actions_core.setFailed(error.message)
|
||||
if (error instanceof Error) actions_core.setFailed(error)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue