anodizer_core/config/publishers/nix.rs
1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4use super::super::{StringOrBool, deserialize_string_or_bool_opt};
5use super::{CommitAuthorConfig, RepositoryConfig};
6
7// ---------------------------------------------------------------------------
8// NixConfig
9// ---------------------------------------------------------------------------
10
11#[derive(Debug, Clone, Serialize, Deserialize, Default, JsonSchema)]
12#[serde(default, deny_unknown_fields)]
13pub struct NixConfig {
14 /// Override the derivation name (default: crate name).
15 pub name: Option<String>,
16 /// Path for the .nix file in the repository (default: `pkgs/<name>/default.nix`).
17 pub path: Option<String>,
18 /// Unified repository config with branch, token, PR, git SSH support.
19 pub repository: Option<RepositoryConfig>,
20 /// Commit author with optional signing.
21 pub commit_author: Option<CommitAuthorConfig>,
22 /// Custom commit message template.
23 pub commit_msg_template: Option<String>,
24 /// Build IDs filter: only include artifacts whose `id` is in this list.
25 pub ids: Option<Vec<String>>,
26 /// Custom URL template for download URLs (overrides release URL).
27 pub url_template: Option<String>,
28 /// Skip publishing. `"true"` always skips; `"auto"` skips for prereleases.
29 /// Accepts bool or template string.
30 #[serde(deserialize_with = "deserialize_string_or_bool_opt", default)]
31 pub skip_upload: Option<StringOrBool>,
32 /// Skip this Nix config. Accepts bool or template string
33 /// (e.g. `"{{ if .IsSnapshot }}true{{ endif }}"` for conditional skip).
34 /// Distinct from `skip_upload` so users can model both intents — disable
35 /// means "don't generate at all", skip_upload means "generate but don't
36 /// push". Without this field, `nix: { skip: true }` was silently
37 /// dropped by the serde unknown-field default.
38 #[serde(deserialize_with = "deserialize_string_or_bool_opt", default)]
39 pub skip: Option<StringOrBool>,
40 /// Custom install commands (replaces auto-generated binary install).
41 pub install: Option<String>,
42 /// Additional install commands appended after the main install.
43 pub extra_install: Option<String>,
44 /// Post-install commands (postInstall phase).
45 pub post_install: Option<String>,
46 /// Short description of the Nix derivation.
47 pub description: Option<String>,
48 /// Project homepage URL.
49 pub homepage: Option<String>,
50 /// Nix license identifier (e.g. "mit", "asl20"). Validated against known licenses.
51 pub license: Option<String>,
52 /// Nix package dependencies with optional OS filtering.
53 pub dependencies: Option<Vec<NixDependency>>,
54 /// Nix formatter to run on the generated file: "alejandra" or "nixfmt".
55 pub formatter: Option<String>,
56 /// amd64 microarchitecture variant filter (e.g. "v1", "v2", "v3", "v4").
57 /// Only artifacts matching this variant are included. Default: "v1".
58 pub amd64_variant: Option<String>,
59 /// Value for `meta.mainProgram` in the generated Nix derivation.
60 /// When set, the rendered derivation includes
61 /// `mainProgram = "<value>";` inside the `meta` block, telling Nix
62 /// which binary `nix run` should execute when the derivation
63 /// contains multiple executables. Templated: supports
64 /// `{{ .Version }}` etc. Omitted when unset.
65 pub main_program: Option<String>,
66}
67
68/// Nix package dependency with optional OS restriction.
69#[derive(Debug, Clone, Serialize, Deserialize, Default, JsonSchema)]
70#[serde(default)]
71pub struct NixDependency {
72 /// Nix attribute path for the dependency (e.g., "openssl", "pkgs.libgit2").
73 pub name: String,
74 /// OS restriction: "linux", "darwin", or empty for all.
75 pub os: Option<String>,
76}