Initial commit

This commit is contained in:
Domen Kožar 2019-09-29 21:52:02 +02:00 committed by Domen Kožar
commit a6de7cd0c2
No known key found for this signature in database
GPG key ID: C2FFBCAFD2C24246
14 changed files with 4063 additions and 0 deletions

52
lib/main.js Normal file
View file

@ -0,0 +1,52 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(require("@actions/core"));
const exec = __importStar(require("@actions/exec"));
const utils_1 = require("./utils");
function run() {
return __awaiter(this, void 0, void 0, function* () {
const file = core.getInput('file');
const attributes = core.getInput('attributes');
const cachixPush = core.getInput('cachixPush', { required: true });
console.log(`Installing Cachix ...`);
yield exec.exec('nix-env', ['-iA', 'cachix', '-f', 'https://cachix.org/api/v1/install']);
// TODO: cachix watch
console.log(`Setting up cache ` + cachixPush + `...`);
yield exec.exec('cachix', ['use', cachixPush]);
console.log(`Invoking nix-build...`);
let paths = '';
const options = {
listeners: {
stdout: (data) => {
paths += data.toString();
},
}
};
const args = ['-f', file || "default.nix"].concat(utils_1.extrasperse('-A', attributes.split(/\s/)));
yield exec.exec('nix-build', args, options);
console.log(`Pushing to cache ` + cachixPush + `...`);
yield exec.exec('cachix', ['push', cachixPush].concat(paths.split(/\s/).join(' ')));
});
}
try {
run();
}
catch (error) {
core.setFailed(error.message);
}

8
lib/utils.js Normal file
View file

@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function extrasperse(elem, array) {
const init = [];
return array.reduce((r, a) => r.concat(elem, a), init);
}
exports.extrasperse = extrasperse;
;