mirror of
https://github.com/DeterminateSystems/nix-installer-action.git
synced 2024-12-23 05:22:21 +01:00
Log in to flakehub on existing installs (#129)
* Log in to flakehub if the machine is already installed * Put the nix store paths first (in the PATH) * set the path earlier * Warn on login failures
This commit is contained in:
parent
25431d2798
commit
e50d5f73bf
2 changed files with 37 additions and 18 deletions
23
dist/index.js
generated
vendored
23
dist/index.js
generated
vendored
|
@ -102680,6 +102680,9 @@ ${stderrBuffer}`
|
||||||
await this.executeUninstall();
|
await this.executeUninstall();
|
||||||
} else {
|
} else {
|
||||||
await this.setGithubPath();
|
await this.setGithubPath();
|
||||||
|
if (this.determinate) {
|
||||||
|
await this.flakehubLogin();
|
||||||
|
}
|
||||||
core.info("Nix was already installed, using existing install");
|
core.info("Nix was already installed, using existing install");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -102703,10 +102706,10 @@ ${stderrBuffer}`
|
||||||
if (this.forceDockerShim) {
|
if (this.forceDockerShim) {
|
||||||
await this.spawnDockerShim();
|
await this.spawnDockerShim();
|
||||||
}
|
}
|
||||||
|
await this.setGithubPath();
|
||||||
if (this.determinate) {
|
if (this.determinate) {
|
||||||
await this.flakehubLogin();
|
await this.flakehubLogin();
|
||||||
}
|
}
|
||||||
await this.setGithubPath();
|
|
||||||
}
|
}
|
||||||
async spawnDockerShim() {
|
async spawnDockerShim() {
|
||||||
core.startGroup(
|
core.startGroup(
|
||||||
|
@ -102893,13 +102896,16 @@ ${stderrBuffer}`
|
||||||
}
|
}
|
||||||
async setGithubPath() {
|
async setGithubPath() {
|
||||||
try {
|
try {
|
||||||
const nixVarNixProfilePath = "/nix/var/nix/profiles/default/bin";
|
const paths = [];
|
||||||
const homeNixProfilePath = `${process.env["HOME"]}/.nix-profile/bin`;
|
if (this.determinate) {
|
||||||
core.addPath(nixVarNixProfilePath);
|
paths.push("/usr/local/bin");
|
||||||
core.addPath(homeNixProfilePath);
|
}
|
||||||
core.info(
|
paths.push("/nix/var/nix/profiles/default/bin");
|
||||||
`Added \`${nixVarNixProfilePath}\` and \`${homeNixProfilePath}\` to \`$GITHUB_PATH\``
|
paths.push(`${process.env["HOME"]}/.nix-profile/bin`);
|
||||||
);
|
for (const p of paths) {
|
||||||
|
core.addPath(p);
|
||||||
|
core.debug(`Added \`${p}\` to \`$GITHUB_PATH\``);
|
||||||
|
}
|
||||||
} catch {
|
} catch {
|
||||||
core.info(
|
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."
|
"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."
|
||||||
|
@ -102913,6 +102919,7 @@ ${stderrBuffer}`
|
||||||
try {
|
try {
|
||||||
await exec.exec(`determinate-nixd`, ["login", "github-action"]);
|
await exec.exec(`determinate-nixd`, ["login", "github-action"]);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
core.warning(`FlakeHub Login failure: ${stringifyError(e)}`);
|
||||||
this.recordEvent("flakehub-login:failure", {
|
this.recordEvent("flakehub-login:failure", {
|
||||||
exception: stringifyError(e)
|
exception: stringifyError(e)
|
||||||
});
|
});
|
||||||
|
|
32
src/index.ts
32
src/index.ts
|
@ -614,8 +614,13 @@ class NixInstallerAction extends DetSysAction {
|
||||||
);
|
);
|
||||||
await this.executeUninstall();
|
await this.executeUninstall();
|
||||||
} else {
|
} else {
|
||||||
// We're already installed, and not reinstalling, just set GITHUB_PATH and finish early
|
// We're already installed, and not reinstalling, just log in to FlakeHub, set GITHUB_PATH and finish early
|
||||||
await this.setGithubPath();
|
await this.setGithubPath();
|
||||||
|
|
||||||
|
if (this.determinate) {
|
||||||
|
await this.flakehubLogin();
|
||||||
|
}
|
||||||
|
|
||||||
actionsCore.info("Nix was already installed, using existing install");
|
actionsCore.info("Nix was already installed, using existing install");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -643,11 +648,11 @@ class NixInstallerAction extends DetSysAction {
|
||||||
await this.spawnDockerShim();
|
await this.spawnDockerShim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await this.setGithubPath();
|
||||||
|
|
||||||
if (this.determinate) {
|
if (this.determinate) {
|
||||||
await this.flakehubLogin();
|
await this.flakehubLogin();
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.setGithubPath();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async spawnDockerShim(): Promise<void> {
|
async spawnDockerShim(): Promise<void> {
|
||||||
|
@ -859,13 +864,19 @@ class NixInstallerAction extends DetSysAction {
|
||||||
async setGithubPath(): Promise<void> {
|
async setGithubPath(): Promise<void> {
|
||||||
// Interim versions of the `nix-installer` crate may have already manipulated `$GITHUB_PATH`, as root even! Accessing that will be an error.
|
// Interim versions of the `nix-installer` crate may have already manipulated `$GITHUB_PATH`, as root even! Accessing that will be an error.
|
||||||
try {
|
try {
|
||||||
const nixVarNixProfilePath = "/nix/var/nix/profiles/default/bin";
|
const paths = [];
|
||||||
const homeNixProfilePath = `${process.env["HOME"]}/.nix-profile/bin`;
|
|
||||||
actionsCore.addPath(nixVarNixProfilePath);
|
if (this.determinate) {
|
||||||
actionsCore.addPath(homeNixProfilePath);
|
paths.push("/usr/local/bin");
|
||||||
actionsCore.info(
|
}
|
||||||
`Added \`${nixVarNixProfilePath}\` and \`${homeNixProfilePath}\` to \`$GITHUB_PATH\``,
|
|
||||||
);
|
paths.push("/nix/var/nix/profiles/default/bin");
|
||||||
|
paths.push(`${process.env["HOME"]}/.nix-profile/bin`);
|
||||||
|
|
||||||
|
for (const p of paths) {
|
||||||
|
actionsCore.addPath(p);
|
||||||
|
actionsCore.debug(`Added \`${p}\` to \`$GITHUB_PATH\``);
|
||||||
|
}
|
||||||
} catch {
|
} catch {
|
||||||
actionsCore.info(
|
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.",
|
"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.",
|
||||||
|
@ -883,6 +894,7 @@ class NixInstallerAction extends DetSysAction {
|
||||||
try {
|
try {
|
||||||
await actionsExec.exec(`determinate-nixd`, ["login", "github-action"]);
|
await actionsExec.exec(`determinate-nixd`, ["login", "github-action"]);
|
||||||
} catch (e: unknown) {
|
} catch (e: unknown) {
|
||||||
|
actionsCore.warning(`FlakeHub Login failure: ${stringifyError(e)}`);
|
||||||
this.recordEvent("flakehub-login:failure", {
|
this.recordEvent("flakehub-login:failure", {
|
||||||
exception: stringifyError(e),
|
exception: stringifyError(e),
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue