diff --git a/dist/index.js b/dist/index.js index 939a5f7..6c4ebc8 100644 --- a/dist/index.js +++ b/dist/index.js @@ -95103,6 +95103,7 @@ var FlakeHubPushAction = class extends DetSysAction { this.repository = inputs_exports.getString("repository"); this.directory = inputs_exports.getString("directory"); this.gitRoot = inputs_exports.getString("git-root"); + this.myFlakeIsTooBig = inputs_exports.getBool("my-flake-is-too-big"); this.spdxExpression = inputs_exports.getString("spdx-expression"); this.errorOnConflict = inputs_exports.getBool("error-on-conflict"); this.includeOutputPaths = inputs_exports.getBool("include-output-paths"); @@ -95143,6 +95144,7 @@ var FlakeHubPushAction = class extends DetSysAction { env.FLAKEHUB_PUSH_REPOSITORY = this.repository; env.FLAKEHUB_PUSH_DIRECTORY = this.directory; env.FLAKEHUB_PUSH_GIT_ROOT = this.gitRoot; + env.FLAKEHUB_PUSH_MY_FLAKE_IS_TOO_BIG = this.myFlakeIsTooBig.toString(); env.FLAKEHUB_PUSH_EXTRA_LABELS = this.extraLabels; env.FLAKEHUB_PUSH_SPDX_EXPRESSION = this.spdxExpression; env.FLAKEHUB_PUSH_ERROR_ON_CONFLICT = this.errorOnConflict.toString(); diff --git a/dist/index.js.map b/dist/index.js.map index ed91b7c..7751ffc 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["../ts/index.ts"],"sourcesContent":["import * as actionsCore from \"@actions/core\";\nimport * as actionsExec from \"@actions/exec\";\nimport { DetSysAction, inputs } from \"detsys-ts\";\n\nconst EVENT_EXECUTION_FAILURE = \"execution_failure\";\n\ntype ExecutionEnvironment = {\n FLAKEHUB_PUSH_VISIBILITY?: string;\n FLAKEHUB_PUSH_TAG?: string;\n FLAKEHUB_PUSH_HOST?: string;\n FLAKEHUB_PUSH_LOG_DIRECTIVES?: string;\n FLAKEHUB_PUSH_LOGGER?: string;\n FLAKEHUB_PUSH_GITHUB_TOKEN?: string;\n FLAKEHUB_PUSH_NAME?: string;\n FLAKEHUB_PUSH_REPOSITORY?: string;\n FLAKEHUB_PUSH_DIRECTORY?: string;\n FLAKEHUB_PUSH_GIT_ROOT?: string;\n FLAKEHUB_PUSH_EXTRA_LABELS?: string;\n FLAKEHUB_PUSH_SPDX_EXPRESSION?: string;\n FLAKEHUB_PUSH_ERROR_ON_CONFLICT?: string;\n FLAKEHUB_PUSH_INCLUDE_OUTPUT_PATHS?: string;\n FLAKEHUB_PUSH_ROLLING?: string;\n FLAKEHUB_PUSH_MIRROR?: string;\n FLAKEHUB_PUSH_ROLLING_MINOR?: string;\n};\n\nclass FlakeHubPushAction extends DetSysAction {\n // Action inputs translated into environment variables to pass to flakehub-push\n private visibility: string;\n private tag: string;\n private host: string;\n private logDirectives: string;\n private logger: string;\n private gitHubToken: string;\n private repository: string;\n private directory: string;\n private gitRoot: string;\n private spdxExpression: string;\n private errorOnConflict: boolean;\n private includeOutputPaths: boolean;\n private rolling: boolean;\n private mirror: boolean;\n private name: string | null;\n private rollingMinor: number | null;\n\n constructor() {\n super({\n name: \"flakehub-push\",\n fetchStyle: \"gh-env-style\",\n diagnosticsSuffix: \"diagnostic\",\n legacySourcePrefix: \"flakehub-push\",\n requireNix: \"fail\",\n });\n\n // Inputs translated into environment variables for flakehub-push\n this.visibility = inputs.getString(\"visibility\");\n this.tag = inputs.getString(\"tag\");\n this.host = inputs.getString(\"host\");\n this.logDirectives = inputs.getString(\"log-directives\");\n this.logger = inputs.getString(\"logger\");\n this.gitHubToken = inputs.getString(\"github-token\");\n this.repository = inputs.getString(\"repository\");\n this.directory = inputs.getString(\"directory\");\n this.gitRoot = inputs.getString(\"git-root\");\n this.spdxExpression = inputs.getString(\"spdx-expression\");\n this.errorOnConflict = inputs.getBool(\"error-on-conflict\");\n this.includeOutputPaths = inputs.getBool(\"include-output-paths\");\n this.rolling = inputs.getBool(\"rolling\");\n this.mirror = inputs.getBool(\"mirror\");\n this.name = inputs.getStringOrNull(\"name\");\n this.rollingMinor = inputs.getNumberOrNull(\"rolling-minor\");\n }\n\n async main(): Promise {\n await this.pushFlakeToFlakeHub();\n }\n\n // No post step\n async post(): Promise {}\n\n // extra-tags is deprecated but we still honor it\n private get extraLabels(): string {\n const labels = inputs.getString(\"extra-labels\"); // current input name\n const tags = inputs.getString(\"extra-tags\"); // deprecated input name\n\n // If `extra-labels` is set to something use it, otherwise use `extra-tags`.\n // It `extra-tags` is also not set, which means that it's an empty string, that's\n // still valid, as the flakehub-push CLI expects a comma-separated list here.\n return labels !== \"\" ? labels : tags;\n }\n\n // We first check for a value using the `source-binary` input and fall back to the\n // now-deprecated `flakehub-push-binary`\n private get sourceBinary(): string | null {\n const sourceBinaryInput = inputs.getStringOrNull(\"source-binary\");\n const flakeHubPushBinaryInput = inputs.getStringOrNull(\n \"flakehub-push-binary\",\n );\n\n return sourceBinaryInput !== \"\"\n ? sourceBinaryInput\n : flakeHubPushBinaryInput;\n }\n\n private executionEnvironment(): ExecutionEnvironment {\n const env: ExecutionEnvironment = {};\n\n env.FLAKEHUB_PUSH_VISIBILITY = this.visibility;\n env.FLAKEHUB_PUSH_TAG = this.tag;\n env.FLAKEHUB_PUSH_HOST = this.host;\n env.FLAKEHUB_PUSH_LOG_DIRECTIVES = this.logDirectives;\n env.FLAKEHUB_PUSH_LOGGER = this.logger;\n env.FLAKEHUB_PUSH_GITHUB_TOKEN = this.gitHubToken;\n env.FLAKEHUB_PUSH_REPOSITORY = this.repository;\n env.FLAKEHUB_PUSH_DIRECTORY = this.directory;\n env.FLAKEHUB_PUSH_GIT_ROOT = this.gitRoot;\n // not included: the now-deprecated FLAKEHUB_PUSH_EXTRA_TAGS\n env.FLAKEHUB_PUSH_EXTRA_LABELS = this.extraLabels;\n env.FLAKEHUB_PUSH_SPDX_EXPRESSION = this.spdxExpression;\n env.FLAKEHUB_PUSH_ERROR_ON_CONFLICT = this.errorOnConflict.toString();\n env.FLAKEHUB_PUSH_INCLUDE_OUTPUT_PATHS = this.includeOutputPaths.toString();\n env.FLAKEHUB_PUSH_ROLLING = this.rolling.toString();\n env.FLAKEHUB_PUSH_MIRROR = this.mirror.toString();\n\n if (this.name !== null) {\n env.FLAKEHUB_PUSH_NAME = this.name;\n }\n\n if (this.rollingMinor !== null) {\n env.FLAKEHUB_PUSH_ROLLING_MINOR = this.rollingMinor.toString();\n }\n\n return env;\n }\n\n async pushFlakeToFlakeHub(): Promise {\n const executionEnv = this.executionEnvironment();\n\n const flakeHubPushBinary =\n this.sourceBinary !== null\n ? this.sourceBinary\n : await this.fetchExecutable();\n\n actionsCore.debug(\n `execution environment: ${JSON.stringify(executionEnv, null, 2)}`,\n );\n\n const exitCode = await actionsExec.exec(flakeHubPushBinary, [], {\n env: {\n ...executionEnv,\n ...process.env, // To get PATH, etc.\n },\n });\n\n if (exitCode !== 0) {\n this.recordEvent(EVENT_EXECUTION_FAILURE, {\n exitCode,\n });\n actionsCore.setFailed(`non-zero exit code of ${exitCode} detected`);\n } else {\n actionsCore.info(`Flake release was successfully published`);\n }\n }\n}\n\nfunction main(): void {\n new FlakeHubPushAction().execute();\n}\n\nmain();\n"],"mappings":";AAAA,YAAY,iBAAiB;AAC7B,YAAY,iBAAiB;AAC7B,SAAS,cAAc,cAAc;AAErC,IAAM,0BAA0B;AAsBhC,IAAM,qBAAN,cAAiC,aAAa;AAAA,EAmB5C,cAAc;AACZ,UAAM;AAAA,MACJ,MAAM;AAAA,MACN,YAAY;AAAA,MACZ,mBAAmB;AAAA,MACnB,oBAAoB;AAAA,MACpB,YAAY;AAAA,IACd,CAAC;AAGD,SAAK,aAAa,OAAO,UAAU,YAAY;AAC/C,SAAK,MAAM,OAAO,UAAU,KAAK;AACjC,SAAK,OAAO,OAAO,UAAU,MAAM;AACnC,SAAK,gBAAgB,OAAO,UAAU,gBAAgB;AACtD,SAAK,SAAS,OAAO,UAAU,QAAQ;AACvC,SAAK,cAAc,OAAO,UAAU,cAAc;AAClD,SAAK,aAAa,OAAO,UAAU,YAAY;AAC/C,SAAK,YAAY,OAAO,UAAU,WAAW;AAC7C,SAAK,UAAU,OAA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,SAAS;AAEhD,QAAI,KAAK,SAAS,MAAM;AACtB,UAAI,qBAAqB,KAAK;AAAA,IAChC;AAEA,QAAI,KAAK,iBAAiB,MAAM;AAC9B,UAAI,8BAA8B,KAAK,aAAa,SAAS;AAAA,IAC/D;AAEA,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,sBAAqC;AACzC,UAAM,eAAe,KAAK,qBAAqB;AAE/C,UAAM,qBACJ,KAAK,iBAAiB,OAClB,KAAK,eACL,MAAM,KAAK,gBAAgB;AAEjC,IAAY;AAAA,MACV,0BAA0B,KAAK,UAAU,cAAc,MAAM,CAAC,CAAC;AAAA,IACjE;AAEA,UAAM,WAAW,MAAkB,iBAAK,oBAAoB,CAAC,GAAG;AAAA,MAC9D,KAAK;AAAA,QACH,GAAG;AAAA,QACH,GAAG,QAAQ;AAAA;AAAA,MACb;AAAA,IACF,CAAC;AAED,QAAI,aAAa,GAAG;AAClB,WAAK,YAAY,yBAAyB;AAAA,QACxC;AAAA,MACF,CAAC;AACD,MAAY,sBAAU,yBAAyB,QAAQ,WAAW;AAAA,IACpE,OAAO;AACL,MAAY,iBAAK,0CAA0C;AAAA,IAC7D;AAAA,EACF;AACF;AAEA,SAAS,OAAa;AACpB,MAAI,mBAAmB,EAAE,QAAQ;AACnC;AAEA,KAAK;","names":[]} \ No newline at end of file +{"version":3,"sources":["../ts/index.ts"],"sourcesContent":["import * as actionsCore from \"@actions/core\";\nimport * as actionsExec from \"@actions/exec\";\nimport { DetSysAction, inputs } from \"detsys-ts\";\n\nconst EVENT_EXECUTION_FAILURE = \"execution_failure\";\n\ntype ExecutionEnvironment = {\n FLAKEHUB_PUSH_VISIBILITY?: string;\n FLAKEHUB_PUSH_TAG?: string;\n FLAKEHUB_PUSH_HOST?: string;\n FLAKEHUB_PUSH_LOG_DIRECTIVES?: string;\n FLAKEHUB_PUSH_LOGGER?: string;\n FLAKEHUB_PUSH_GITHUB_TOKEN?: string;\n FLAKEHUB_PUSH_NAME?: string;\n FLAKEHUB_PUSH_REPOSITORY?: string;\n FLAKEHUB_PUSH_DIRECTORY?: string;\n FLAKEHUB_PUSH_GIT_ROOT?: string;\n FLAKEHUB_PUSH_MY_FLAKE_IS_TOO_BIG?: string;\n FLAKEHUB_PUSH_EXTRA_LABELS?: string;\n FLAKEHUB_PUSH_SPDX_EXPRESSION?: string;\n FLAKEHUB_PUSH_ERROR_ON_CONFLICT?: string;\n FLAKEHUB_PUSH_INCLUDE_OUTPUT_PATHS?: string;\n FLAKEHUB_PUSH_ROLLING?: string;\n FLAKEHUB_PUSH_MIRROR?: string;\n FLAKEHUB_PUSH_ROLLING_MINOR?: string;\n};\n\nclass FlakeHubPushAction extends DetSysAction {\n // Action inputs translated into environment variables to pass to flakehub-push\n private visibility: string;\n private tag: string;\n private host: string;\n private logDirectives: string;\n private logger: string;\n private gitHubToken: string;\n private repository: string;\n private directory: string;\n private gitRoot: string;\n private myFlakeIsTooBig: boolean;\n private spdxExpression: string;\n private errorOnConflict: boolean;\n private includeOutputPaths: boolean;\n private rolling: boolean;\n private mirror: boolean;\n private name: string | null;\n private rollingMinor: number | null;\n\n constructor() {\n super({\n name: \"flakehub-push\",\n fetchStyle: \"gh-env-style\",\n diagnosticsSuffix: \"diagnostic\",\n legacySourcePrefix: \"flakehub-push\",\n requireNix: \"fail\",\n });\n\n // Inputs translated into environment variables for flakehub-push\n this.visibility = inputs.getString(\"visibility\");\n this.tag = inputs.getString(\"tag\");\n this.host = inputs.getString(\"host\");\n this.logDirectives = inputs.getString(\"log-directives\");\n this.logger = inputs.getString(\"logger\");\n this.gitHubToken = inputs.getString(\"github-token\");\n this.repository = inputs.getString(\"repository\");\n this.directory = inputs.getString(\"directory\");\n this.gitRoot = inputs.getString(\"git-root\");\n this.myFlakeIsTooBig = inputs.getBool(\"my-flake-is-too-big\");\n this.spdxExpression = inputs.getString(\"spdx-expression\");\n this.errorOnConflict = inputs.getBool(\"error-on-conflict\");\n this.includeOutputPaths = inputs.getBool(\"include-output-paths\");\n this.rolling = inputs.getBool(\"rolling\");\n this.mirror = inputs.getBool(\"mirror\");\n this.name = inputs.getStringOrNull(\"name\");\n this.rollingMinor = inputs.getNumberOrNull(\"rolling-minor\");\n }\n\n async main(): Promise {\n await this.pushFlakeToFlakeHub();\n }\n\n // No post step\n async post(): Promise {}\n\n // extra-tags is deprecated but we still honor it\n private get extraLabels(): string {\n const labels = inputs.getString(\"extra-labels\"); // current input name\n const tags = inputs.getString(\"extra-tags\"); // deprecated input name\n\n // If `extra-labels` is set to something use it, otherwise use `extra-tags`.\n // It `extra-tags` is also not set, which means that it's an empty string, that's\n // still valid, as the flakehub-push CLI expects a comma-separated list here.\n return labels !== \"\" ? labels : tags;\n }\n\n // We first check for a value using the `source-binary` input and fall back to the\n // now-deprecated `flakehub-push-binary`\n private get sourceBinary(): string | null {\n const sourceBinaryInput = inputs.getStringOrNull(\"source-binary\");\n const flakeHubPushBinaryInput = inputs.getStringOrNull(\n \"flakehub-push-binary\",\n );\n\n return sourceBinaryInput !== \"\"\n ? sourceBinaryInput\n : flakeHubPushBinaryInput;\n }\n\n private executionEnvironment(): ExecutionEnvironment {\n const env: ExecutionEnvironment = {};\n\n env.FLAKEHUB_PUSH_VISIBILITY = this.visibility;\n env.FLAKEHUB_PUSH_TAG = this.tag;\n env.FLAKEHUB_PUSH_HOST = this.host;\n env.FLAKEHUB_PUSH_LOG_DIRECTIVES = this.logDirectives;\n env.FLAKEHUB_PUSH_LOGGER = this.logger;\n env.FLAKEHUB_PUSH_GITHUB_TOKEN = this.gitHubToken;\n env.FLAKEHUB_PUSH_REPOSITORY = this.repository;\n env.FLAKEHUB_PUSH_DIRECTORY = this.directory;\n env.FLAKEHUB_PUSH_GIT_ROOT = this.gitRoot;\n env.FLAKEHUB_PUSH_MY_FLAKE_IS_TOO_BIG = this.myFlakeIsTooBig.toString();\n // not included: the now-deprecated FLAKEHUB_PUSH_EXTRA_TAGS\n env.FLAKEHUB_PUSH_EXTRA_LABELS = this.extraLabels;\n env.FLAKEHUB_PUSH_SPDX_EXPRESSION = this.spdxExpression;\n env.FLAKEHUB_PUSH_ERROR_ON_CONFLICT = this.errorOnConflict.toString();\n env.FLAKEHUB_PUSH_INCLUDE_OUTPUT_PATHS = this.includeOutputPaths.toString();\n env.FLAKEHUB_PUSH_ROLLING = this.rolling.toString();\n env.FLAKEHUB_PUSH_MIRROR = this.mirror.toString();\n\n if (this.name !== null) {\n env.FLAKEHUB_PUSH_NAME = this.name;\n }\n\n if (this.rollingMinor !== null) {\n env.FLAKEHUB_PUSH_ROLLING_MINOR = this.rollingMinor.toString();\n }\n\n return env;\n }\n\n async pushFlakeToFlakeHub(): Promise {\n const executionEnv = this.executionEnvironment();\n\n const flakeHubPushBinary =\n this.sourceBinary !== null\n ? this.sourceBinary\n : await this.fetchExecutable();\n\n actionsCore.debug(\n `execution environment: ${JSON.stringify(executionEnv, null, 2)}`,\n );\n\n const exitCode = await actionsExec.exec(flakeHubPushBinary, [], {\n env: {\n ...executionEnv,\n ...process.env, // To get PATH, etc.\n },\n });\n\n if (exitCode !== 0) {\n this.recordEvent(EVENT_EXECUTION_FAILURE, {\n exitCode,\n });\n actionsCore.setFailed(`non-zero exit code of ${exitCode} detected`);\n } else {\n actionsCore.info(`Flake release was successfully published`);\n }\n }\n}\n\nfunction main(): void {\n new FlakeHubPushAction().execute();\n}\n\nmain();\n"],"mappings":";AAAA,YAAY,iBAAiB;AAC7B,YAAY,iBAAiB;AAC7B,SAAS,cAAc,cAAc;AAErC,IAAM,0BAA0B;AAuBhC,IAAM,qBAAN,cAAiC,aAAa;AAAA,EAoB5C,cAAc;AACZ,UAAM;AAAA,MACJ,MAAM;AAAA,MACN,YAAY;AAAA,MACZ,mBAAmB;AAAA,MACnB,oBAAoB;AAAA,MACpB,YAAY;AAAA,IACd,CAAC;AAGD,SAAK,aAAa,OAAO,UAAU,YAAY;AAC/C,SAAK,MAAM,OAAO,UAAU,KAAK;AACjC,SAAK,OAAO,OAAO,UAAU,MAAM;AACnC,SAA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A0B,KAAK;AACnC,QAAI,yBAAyB,KAAK;AAClC,QAAI,oCAAoC,KAAK,gBAAgB,SAAS;AAEtE,QAAI,6BAA6B,KAAK;AACtC,QAAI,gCAAgC,KAAK;AACzC,QAAI,kCAAkC,KAAK,gBAAgB,SAAS;AACpE,QAAI,qCAAqC,KAAK,mBAAmB,SAAS;AAC1E,QAAI,wBAAwB,KAAK,QAAQ,SAAS;AAClD,QAAI,uBAAuB,KAAK,OAAO,SAAS;AAEhD,QAAI,KAAK,SAAS,MAAM;AACtB,UAAI,qBAAqB,KAAK;AAAA,IAChC;AAEA,QAAI,KAAK,iBAAiB,MAAM;AAC9B,UAAI,8BAA8B,KAAK,aAAa,SAAS;AAAA,IAC/D;AAEA,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,sBAAqC;AACzC,UAAM,eAAe,KAAK,qBAAqB;AAE/C,UAAM,qBACJ,KAAK,iBAAiB,OAClB,KAAK,eACL,MAAM,KAAK,gBAAgB;AAEjC,IAAY;AAAA,MACV,0BAA0B,KAAK,UAAU,cAAc,MAAM,CAAC,CAAC;AAAA,IACjE;AAEA,UAAM,WAAW,MAAkB,iBAAK,oBAAoB,CAAC,GAAG;AAAA,MAC9D,KAAK;AAAA,QACH,GAAG;AAAA,QACH,GAAG,QAAQ;AAAA;AAAA,MACb;AAAA,IACF,CAAC;AAED,QAAI,aAAa,GAAG;AAClB,WAAK,YAAY,yBAAyB;AAAA,QACxC;AAAA,MACF,CAAC;AACD,MAAY,sBAAU,yBAAyB,QAAQ,WAAW;AAAA,IACpE,OAAO;AACL,MAAY,iBAAK,0CAA0C;AAAA,IAC7D;AAAA,EACF;AACF;AAEA,SAAS,OAAa;AACpB,MAAI,mBAAmB,EAAE,QAAQ;AACnC;AAEA,KAAK;","names":[]} \ No newline at end of file diff --git a/src/cli/mod.rs b/src/cli/mod.rs index 138a2ec..4da5ef3 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -87,6 +87,22 @@ pub(crate) struct FlakeHubPushCli { )] pub(crate) error_on_conflict: bool, + /// Do less work on extremely large flakes. + /// + /// This flag is intended to limit the scope of evaluations which are too large to complete on one machine. + /// This flag should NOT be used to paper over evaluation errors across different architectures. + /// + /// Please do not turn this flag on without opening an issue to decide if it applies to your scenario. + /// + /// Note: the behavior of this flag could change at any time, please don't count on it for anything specific. + #[clap( + long, + env = "FLAKEHUB_PUSH_MY_FLAKE_IS_TOO_BIG", + value_parser = EmptyBoolParser, + default_value_t = false + )] + pub(crate) my_flake_is_too_big: bool, + #[clap(flatten)] pub instrumentation: instrumentation::Instrumentation, diff --git a/src/flake_info.rs b/src/flake_info.rs index 9f670f7..d79830b 100644 --- a/src/flake_info.rs +++ b/src/flake_info.rs @@ -19,13 +19,14 @@ pub struct FlakeMetadata { pub(crate) source_dir: std::path::PathBuf, pub(crate) flake_locked_url: String, pub(crate) metadata_json: serde_json::Value, + my_flake_is_too_big: bool, } #[derive(Debug, Deserialize)] pub struct FlakeOutputs(pub serde_json::Value); impl FlakeMetadata { - pub async fn from_dir(directory: &Path) -> Result { + pub async fn from_dir(directory: &Path, my_flake_is_too_big: bool) -> Result { let output = tokio::process::Command::new("nix") .arg("flake") .arg("metadata") @@ -77,27 +78,31 @@ impl FlakeMetadata { source_dir: source, flake_locked_url: flake_locked_url.to_string(), metadata_json, + my_flake_is_too_big, }) } /// check_evalutes checks that the flake evaluates /// (note it is not necessary for the target to have a flake.lock) pub async fn check_evaluates(&self) -> Result<()> { - let output = tokio::process::Command::new("nix") - .arg("flake") - .arg("show") - .arg("--all-systems") - .arg("--json") - .arg("--no-write-lock-file") - .arg(&self.source_dir) - .output() - .await - .wrap_err_with(|| { - eyre!( - "Failed to execute `nix flake show --all-systems --json --no-write-lock-file {}`", - self.source_dir.display() - ) - })?; + let mut command = tokio::process::Command::new("nix"); + command.arg("flake"); + command.arg("show"); + + if !self.my_flake_is_too_big { + command.arg("--all-systems"); + } + + command.arg("--json"); + command.arg("--no-write-lock-file"); + command.arg(&self.source_dir); + + let output = command.output().await.wrap_err_with(|| { + eyre!( + "Failed to execute `nix flake show --all-systems --json --no-write-lock-file {}`", + self.source_dir.display() + ) + })?; if !output.status.success() { let command = format!( @@ -236,6 +241,10 @@ impl FlakeMetadata { } pub async fn outputs(&self, include_output_paths: bool) -> Result { + if self.my_flake_is_too_big { + return Ok(FlakeOutputs(serde_json::json!({}))); + } + let tempdir = tempfile::Builder::new() .prefix("flakehub_push_outputs") .tempdir() diff --git a/src/push_context.rs b/src/push_context.rs index 2b71887..05a45fa 100644 --- a/src/push_context.rs +++ b/src/push_context.rs @@ -325,9 +325,10 @@ impl PushContext { let flake_dir = local_git_root.join(&subdir); // FIXME: bail out if flake_metadata denotes a dirty tree. - let flake_metadata = flake_info::FlakeMetadata::from_dir(&flake_dir) - .await - .wrap_err("Getting flake metadata")?; + let flake_metadata = + flake_info::FlakeMetadata::from_dir(&flake_dir, cli.my_flake_is_too_big) + .await + .wrap_err("Getting flake metadata")?; tracing::debug!("Got flake metadata: {:?}", flake_metadata); // sanity checks diff --git a/ts/index.ts b/ts/index.ts index 60025c4..50dc295 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -15,6 +15,7 @@ type ExecutionEnvironment = { FLAKEHUB_PUSH_REPOSITORY?: string; FLAKEHUB_PUSH_DIRECTORY?: string; FLAKEHUB_PUSH_GIT_ROOT?: string; + FLAKEHUB_PUSH_MY_FLAKE_IS_TOO_BIG?: string; FLAKEHUB_PUSH_EXTRA_LABELS?: string; FLAKEHUB_PUSH_SPDX_EXPRESSION?: string; FLAKEHUB_PUSH_ERROR_ON_CONFLICT?: string; @@ -35,6 +36,7 @@ class FlakeHubPushAction extends DetSysAction { private repository: string; private directory: string; private gitRoot: string; + private myFlakeIsTooBig: boolean; private spdxExpression: string; private errorOnConflict: boolean; private includeOutputPaths: boolean; @@ -62,6 +64,7 @@ class FlakeHubPushAction extends DetSysAction { this.repository = inputs.getString("repository"); this.directory = inputs.getString("directory"); this.gitRoot = inputs.getString("git-root"); + this.myFlakeIsTooBig = inputs.getBool("my-flake-is-too-big"); this.spdxExpression = inputs.getString("spdx-expression"); this.errorOnConflict = inputs.getBool("error-on-conflict"); this.includeOutputPaths = inputs.getBool("include-output-paths"); @@ -114,6 +117,7 @@ class FlakeHubPushAction extends DetSysAction { env.FLAKEHUB_PUSH_REPOSITORY = this.repository; env.FLAKEHUB_PUSH_DIRECTORY = this.directory; env.FLAKEHUB_PUSH_GIT_ROOT = this.gitRoot; + env.FLAKEHUB_PUSH_MY_FLAKE_IS_TOO_BIG = this.myFlakeIsTooBig.toString(); // not included: the now-deprecated FLAKEHUB_PUSH_EXTRA_TAGS env.FLAKEHUB_PUSH_EXTRA_LABELS = this.extraLabels; env.FLAKEHUB_PUSH_SPDX_EXPRESSION = this.spdxExpression;