Merge pull request #58 from DeterminateSystems/diff-store-fact

Add store diff fact
This commit is contained in:
Luc Perkins 2024-05-29 15:38:31 -03:00 committed by GitHub
commit 7718b5acea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 21 additions and 11 deletions

12
dist/index.js generated vendored
View file

@ -95218,6 +95218,9 @@ async function flakeHubLogin(netrc) {
var ENV_DAEMON_DIR = "MAGIC_NIX_CACHE_DAEMONDIR"; var ENV_DAEMON_DIR = "MAGIC_NIX_CACHE_DAEMONDIR";
var FACT_ENV_VARS_PRESENT = "required_env_vars_present";
var FACT_DIFF_STORE_ENABLED = "diff_store";
var FACT_NOOP_MODE = "noop_mode";
var STATE_DAEMONDIR = "MAGIC_NIX_CACHE_DAEMONDIR"; var STATE_DAEMONDIR = "MAGIC_NIX_CACHE_DAEMONDIR";
var STATE_STARTED = "MAGIC_NIX_CACHE_STARTED"; var STATE_STARTED = "MAGIC_NIX_CACHE_STARTED";
var STARTED_HINT = "true"; var STARTED_HINT = "true";
@ -95233,6 +95236,8 @@ var MagicNixCacheAction = class extends DetSysAction {
requireNix: "warn" requireNix: "warn"
}); });
this.hostAndPort = inputs_exports.getString("listen"); this.hostAndPort = inputs_exports.getString("listen");
this.diffStore = inputs_exports.getBool("diff-store");
this.addFact(FACT_DIFF_STORE_ENABLED, this.diffStore);
this.httpClient = got_dist_source.extend({ this.httpClient = got_dist_source.extend({
retry: { retry: {
limit: 1, limit: 1,
@ -95262,7 +95267,7 @@ var MagicNixCacheAction = class extends DetSysAction {
} else { } else {
this.noopMode = process.env[ENV_DAEMON_DIR] !== this.daemonDir; this.noopMode = process.env[ENV_DAEMON_DIR] !== this.daemonDir;
} }
this.addFact("noop_mode", this.noopMode); this.addFact(FACT_NOOP_MODE, this.noopMode);
this.stapleFile("daemon.log", external_node_path_namespaceObject.join(this.daemonDir, "daemon.log")); this.stapleFile("daemon.log", external_node_path_namespaceObject.join(this.daemonDir, "daemon.log"));
} }
async main() { async main() {
@ -95307,7 +95312,7 @@ var MagicNixCacheAction = class extends DetSysAction {
); );
} }
} }
this.addFact("authenticated_env", !anyMissing); this.addFact(FACT_ENV_VARS_PRESENT, !anyMissing);
if (anyMissing) { if (anyMissing) {
return; return;
} }
@ -95360,7 +95365,6 @@ var MagicNixCacheAction = class extends DetSysAction {
const flakeHubApiServer = inputs_exports.getString("flakehub-api-server"); const flakeHubApiServer = inputs_exports.getString("flakehub-api-server");
const flakeHubFlakeName = inputs_exports.getString("flakehub-flake-name"); const flakeHubFlakeName = inputs_exports.getString("flakehub-flake-name");
const useGhaCache = inputs_exports.getBool("use-gha-cache"); const useGhaCache = inputs_exports.getBool("use-gha-cache");
const diffStore = inputs_exports.getBool("diff-store");
const daemonCliFlags = [ const daemonCliFlags = [
"--startup-notification-url", "--startup-notification-url",
`http://127.0.0.1:${notifyPort}`, `http://127.0.0.1:${notifyPort}`,
@ -95372,7 +95376,7 @@ var MagicNixCacheAction = class extends DetSysAction {
diagnosticEndpoint, diagnosticEndpoint,
"--nix-conf", "--nix-conf",
nixConfPath nixConfPath
].concat(diffStore ? ["--diff-store"] : []).concat( ].concat(this.diffStore ? ["--diff-store"] : []).concat(
useFlakeHub ? [ useFlakeHub ? [
"--use-flakehub", "--use-flakehub",
"--flakehub-cache-server", "--flakehub-cache-server",

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View file

@ -14,6 +14,10 @@ import { inspect } from "node:util";
// twice. // twice.
const ENV_DAEMON_DIR = "MAGIC_NIX_CACHE_DAEMONDIR"; const ENV_DAEMON_DIR = "MAGIC_NIX_CACHE_DAEMONDIR";
const FACT_ENV_VARS_PRESENT = "required_env_vars_present";
const FACT_DIFF_STORE_ENABLED = "diff_store";
const FACT_NOOP_MODE = "noop_mode";
const STATE_DAEMONDIR = "MAGIC_NIX_CACHE_DAEMONDIR"; const STATE_DAEMONDIR = "MAGIC_NIX_CACHE_DAEMONDIR";
const STATE_STARTED = "MAGIC_NIX_CACHE_STARTED"; const STATE_STARTED = "MAGIC_NIX_CACHE_STARTED";
const STARTED_HINT = "true"; const STARTED_HINT = "true";
@ -27,9 +31,9 @@ const TEXT_TRUST_UNKNOWN =
class MagicNixCacheAction extends DetSysAction { class MagicNixCacheAction extends DetSysAction {
private hostAndPort: string; private hostAndPort: string;
private diffStore: boolean;
private httpClient: Got; private httpClient: Got;
private noopMode: boolean;
noopMode: boolean;
private daemonDir: string; private daemonDir: string;
private daemonStarted: boolean; private daemonStarted: boolean;
@ -42,6 +46,9 @@ class MagicNixCacheAction extends DetSysAction {
}); });
this.hostAndPort = inputs.getString("listen"); this.hostAndPort = inputs.getString("listen");
this.diffStore = inputs.getBool("diff-store");
this.addFact(FACT_DIFF_STORE_ENABLED, this.diffStore);
this.httpClient = got.extend({ this.httpClient = got.extend({
retry: { retry: {
@ -75,7 +82,7 @@ class MagicNixCacheAction extends DetSysAction {
} else { } else {
this.noopMode = process.env[ENV_DAEMON_DIR] !== this.daemonDir; this.noopMode = process.env[ENV_DAEMON_DIR] !== this.daemonDir;
} }
this.addFact("noop_mode", this.noopMode); this.addFact(FACT_NOOP_MODE, this.noopMode);
this.stapleFile("daemon.log", path.join(this.daemonDir, "daemon.log")); this.stapleFile("daemon.log", path.join(this.daemonDir, "daemon.log"));
} }
@ -130,7 +137,7 @@ class MagicNixCacheAction extends DetSysAction {
} }
} }
this.addFact("authenticated_env", !anyMissing); this.addFact(FACT_ENV_VARS_PRESENT, !anyMissing);
if (anyMissing) { if (anyMissing) {
return; return;
} }
@ -192,7 +199,6 @@ class MagicNixCacheAction extends DetSysAction {
const flakeHubApiServer = inputs.getString("flakehub-api-server"); const flakeHubApiServer = inputs.getString("flakehub-api-server");
const flakeHubFlakeName = inputs.getString("flakehub-flake-name"); const flakeHubFlakeName = inputs.getString("flakehub-flake-name");
const useGhaCache = inputs.getBool("use-gha-cache"); const useGhaCache = inputs.getBool("use-gha-cache");
const diffStore = inputs.getBool("diff-store");
const daemonCliFlags: string[] = [ const daemonCliFlags: string[] = [
"--startup-notification-url", "--startup-notification-url",
@ -206,7 +212,7 @@ class MagicNixCacheAction extends DetSysAction {
"--nix-conf", "--nix-conf",
nixConfPath, nixConfPath,
] ]
.concat(diffStore ? ["--diff-store"] : []) .concat(this.diffStore ? ["--diff-store"] : [])
.concat( .concat(
useFlakeHub useFlakeHub
? [ ? [