mirror of
https://codeberg.org/icewind/attic-action.git
synced 2026-06-03 17:44:07 +02:00
Install Nix via the action
This commit is contained in:
parent
a6de7cd0c2
commit
4db446a512
7 changed files with 131 additions and 46 deletions
62
lib/main.js
62
lib/main.js
|
|
@ -18,35 +18,43 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const exec = __importStar(require("@actions/exec"));
|
||||
const tc = __importStar(require("@actions/tool-cache"));
|
||||
const os_1 = require("os");
|
||||
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 {
|
||||
const file = core.getInput('file');
|
||||
const attributes = core.getInput('attributes');
|
||||
const cachixPush = core.getInput('cachixPush', { required: true });
|
||||
console.log(`Installing Nix ...`);
|
||||
const nixInstall = yield tc.downloadTool('https://nixos.org/nix/install');
|
||||
yield exec.exec(nixInstall);
|
||||
// required for macos
|
||||
core.exportVariable('NIX_SSL_CERT_FILE', '/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt');
|
||||
console.log(`Installing Cachix ...`);
|
||||
yield exec.exec(os_1.homedir() + '/.nix-profile/bin/nix-env', ['-iA', 'cachix', '-f', 'https://cachix.org/api/v1/install']);
|
||||
// TODO: cachix use --watch-store
|
||||
console.log(`Setting up cache ` + cachixPush + `...`);
|
||||
yield exec.exec(os_1.homedir() + '/.nix-profile/bin/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(os_1.homedir() + '/.nix-profile/bin/nix-build', args, options);
|
||||
console.log(`Pushing to cache ` + cachixPush + `...`);
|
||||
yield exec.exec(os_1.homedir() + '/.nix-profile/bin/cachix', ['push', cachixPush].concat(paths.split(/\s/).join(' ')));
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(`Action failed with error: ${error}`);
|
||||
throw (error);
|
||||
}
|
||||
});
|
||||
}
|
||||
try {
|
||||
run();
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
run();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue